@aperture-browser/session-react 0.0.0-nightly.157.ca2272d9932d → 0.0.0-nightly.158.e9ed26eebaf2

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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Toaster","Sonner","SessionError","MOVES","Drawer","DrawerPrimitive","MenuPrimitive","Drawer","DrawerPrimitive","ContextMenu","ContextMenuPrimitive","Button","ButtonPrimitive","TooltipPrimitive","Tooltip","Tooltip","Button","Input","InputPrimitive","Input","PreviewCardPrimitive","ScrollArea","ScrollAreaPrimitive","Avatar","AvatarPrimitive","Popover","PopoverPrimitive","ROLES","Popover","Button","Tooltip","Avatar","ScrollArea","ContextMenu","Button","Tooltip","Button","Tooltip","Button","Button","Input","Tooltip","Popover","Tooltip","Button","Button","Dialog","DialogPrimitive","Button","Dialog","pageOf","BarButton","Button","Drawer","Button","Button","Drawer","Toaster"],"sources":["../../ui/src/components/sonner.tsx","../src/workbench/contributions.ts","../src/features.ts","../src/notices.ts","../src/workbench/context.tsx","../../ui/src/utils.ts","../../ui/src/portal.tsx","../../ui/src/components/drawer.tsx","../../ui/src/components/dropdown-menu.tsx","../../ui/src/components/context-menu.tsx","../src/workbench/slot.tsx","../src/components/page-menu.tsx","../../ui/src/components/spinner.tsx","../../ui/src/components/button.tsx","../../ui/src/components/tooltip.tsx","../src/components/menu-parts.tsx","../src/components/page-mode.tsx","../../ui/src/components/input.tsx","../../ui/src/components/input-group.tsx","../src/hooks/use-media.ts","../../ui/src/components/hover-card.tsx","../../ui/src/components/scroll-area.tsx","../../ui/src/components/avatar.tsx","../../ui/src/components/popover.tsx","../src/components/session-presence.tsx","../src/components/browser-tab-strip.tsx","../src/components/browser-toolbar.tsx","../src/components/toolbar-actions.tsx","../src/components/phone-menu.tsx","../src/hooks/use-pointers.ts","../src/components/picture-menu.tsx","../src/components/recording-menu.tsx","../src/components/session-files.tsx","../src/components/tab-menu.tsx","../src/workbench/own.ts","../../ui/src/components/badge.tsx","../../ui/src/components/empty.tsx","../src/components/member-marks.tsx","../src/components/browser-viewport.tsx","../../ui/src/components/dialog.tsx","../src/components/kept-gallery.tsx","../src/components/tab-switcher.tsx","../src/components/phone-bar.tsx","../src/components/session-workbench.tsx","../src/ui-root.tsx","../src/aperture-session.tsx","../../ui/src/keyboard-inset.ts"],"sourcesContent":["\"use client\";\n\nimport { useTheme } from \"next-themes\";\nimport { Toaster as Sonner, type ToasterProps } from \"sonner\";\nimport {\n CircleCheckIcon,\n InfoIcon,\n TriangleAlertIcon,\n OctagonXIcon,\n Loader2Icon,\n} from \"lucide-react\";\n\nconst Toaster = ({ ...props }: ToasterProps) => {\n const { theme = \"system\" } = useTheme();\n\n return (\n <Sonner\n theme={theme as ToasterProps[\"theme\"]}\n className=\"toaster aperture:group\"\n icons={{\n success: <CircleCheckIcon className=\"aperture:size-4\" />,\n info: <InfoIcon className=\"aperture:size-4\" />,\n warning: <TriangleAlertIcon className=\"aperture:size-4\" />,\n error: <OctagonXIcon className=\"aperture:size-4\" />,\n loading: <Loader2Icon className=\"aperture:size-4 aperture:animate-spin\" />,\n }}\n style={\n {\n \"--normal-bg\": \"var(--popover)\",\n \"--normal-text\": \"var(--popover-foreground)\",\n \"--normal-border\": \"var(--border)\",\n \"--border-radius\": \"var(--radius)\",\n } as React.CSSProperties\n }\n toastOptions={{\n classNames: {\n toast: \"cn-toast\",\n },\n }}\n {...props}\n />\n );\n};\n\nexport { Toaster };\n","import type { ComponentType } from \"react\";\nimport type { Target } from \"@aperture-browser/session-client\";\n\n/**\n * A place of the workbench that takes contributions.\n *\n * - `titlebar.start`, `titlebar.end`: beside the tab strip and the members.\n * - `toolbar.start`, `toolbar.end`: before the navigation buttons, and after the address.\n * - `toolbar.actions`: the buttons at the toolbar's end.\n * - `menu.browser`, `menu.picture`, `menu.recording`: the menus of those buttons.\n * - `menu.phone`: the menu of a phone's bar, in place of `menu.browser`.\n * - `menu.tab`: the menu of a right click on a tab, which is given as `target`.\n * - `menu.page`: the menu of a right click in the session.\n * - `viewport`: laid over the picture.\n *\n * On a phone the workbench is the picture with a bar over its foot: the toolbar's slots\n * are in the bar, and the title bar's slots and `menu.browser` are shown nowhere. The\n * bar's menu is `menu.phone`, a sheet whose submenus are pages of it: what is contributed\n * for a phone as well has a place there.\n */\nexport type WorkbenchSlotName =\n | \"titlebar.start\"\n | \"titlebar.end\"\n | \"toolbar.start\"\n | \"toolbar.end\"\n | \"toolbar.actions\"\n | \"menu.browser\"\n | \"menu.phone\"\n | \"menu.picture\"\n | \"menu.recording\"\n | \"menu.tab\"\n | \"menu.page\"\n | \"viewport\";\n\nexport interface WorkbenchSlotProps {\n /** The tab the menu is of, in `menu.tab`. */\n readonly target?: Target | undefined;\n}\n\n/**\n * One thing in one place of the workbench. Everything the workbench shows in its slots is\n * a contribution, its own included: one with the id of another takes its place.\n */\nexport interface WorkbenchContribution {\n readonly id: string;\n readonly slot: WorkbenchSlotName;\n /**\n * In a menu, the contributions of one group stand together, apart from the other groups.\n * Groups come in the order of their first contribution.\n */\n readonly group?: string | undefined;\n /** Lower comes first; the workbench's own are a hundred apart. */\n readonly order?: number | undefined;\n /**\n * What is shown. A menu's contribution renders items of the menu's kind: of a dropdown\n * menu, and in `menu.tab` of a context menu. Rendering nothing leaves no trace.\n */\n readonly component: ComponentType<WorkbenchSlotProps>;\n}\n\n/**\n * The contributions an embedder gives: more of them, each replacing the one of its id, or\n * a function of the workbench's own that gives all there are to be.\n */\nexport type WorkbenchContributions =\n | readonly WorkbenchContribution[]\n | ((own: readonly WorkbenchContribution[]) => readonly WorkbenchContribution[]);\n\nexport function resolveContributions(\n own: readonly WorkbenchContribution[],\n given: WorkbenchContributions | undefined,\n): readonly WorkbenchContribution[] {\n if (given === undefined) {\n return own;\n }\n if (typeof given === \"function\") {\n return given(own);\n }\n const replaced = new Set(given.map((one) => one.id));\n return [...own.filter((one) => !replaced.has(one.id)), ...given];\n}\n\n/** A slot's contributions in their order, by group. */\nexport function groupContributions(\n contributions: readonly WorkbenchContribution[],\n slot: WorkbenchSlotName,\n): ReadonlyArray<readonly [group: string, contributions: readonly WorkbenchContribution[]]> {\n const ordered = contributions\n .filter((one) => one.slot === slot)\n .toSorted((left, right) => (left.order ?? 0) - (right.order ?? 0));\n const groups = new Map<string, WorkbenchContribution[]>();\n for (const one of ordered) {\n const group = one.group ?? \"\";\n groups.set(group, [...(groups.get(group) ?? []), one]);\n }\n return [...groups];\n}\n","import type { Features } from \"@aperture-browser/session-client\";\n\n/** The parts of the workbench an embedder may leave out. All are shown unless said. */\nexport interface SessionFeatures {\n /** The tab strip. */\n readonly tabs?: boolean;\n /** Back, forward and reload. */\n readonly navigation?: boolean;\n readonly addressBar?: boolean;\n /** Who is in the session, and the lease of the watched tab. */\n readonly presence?: boolean;\n /** The buttons and menus at the toolbar's end. */\n readonly menus?: boolean;\n /** The session's files: uploads, downloads and what pages ask for. */\n readonly files?: boolean;\n readonly recordings?: boolean;\n /** The menu shown for a right click in the session. */\n readonly pageMenu?: boolean;\n /** Which tabs sound, and muting them. */\n readonly sound?: boolean;\n /** Copying from the session and pasting into it, from the menus. */\n readonly clipboard?: boolean;\n}\n\nexport interface ApertureSessionFeatures extends SessionFeatures {\n /** Notices as toasts. Without it the embedding page shows none of its own accord. */\n readonly toaster?: boolean;\n}\n\n/**\n * What the workbench shows: what the embedder did not leave out, of what this client may\n * read or write at all. `access` tells which of the two, for what depends on it.\n */\nexport interface ResolvedSessionFeatures extends Required<SessionFeatures> {\n readonly uploads: boolean;\n readonly downloads: boolean;\n readonly access: Features;\n}\n\nconst any = (grant: { readonly read: boolean; readonly write: boolean }) =>\n grant.read || grant.write;\n\nexport function resolveSessionFeatures(\n features: SessionFeatures | undefined,\n access: Features,\n): ResolvedSessionFeatures {\n const files = features?.files ?? true;\n const uploads = files && any(access.uploads);\n const downloads = files && access.downloads.read;\n return {\n tabs: true,\n navigation: true,\n addressBar: true,\n presence: true,\n menus: true,\n pageMenu: true,\n ...features,\n recordings: (features?.recordings ?? true) && any(access.recordings),\n clipboard: (features?.clipboard ?? true) && any(access.clipboard),\n sound: (features?.sound ?? true) && access.sound.read,\n uploads,\n downloads,\n files: uploads || downloads,\n access,\n };\n}\n","import { toast } from \"sonner\";\nimport { SessionError, type Session } from \"@aperture-browser/session-client\";\n\nexport interface SessionNotice {\n readonly level: \"info\" | \"error\";\n readonly message: string;\n readonly description?: string | undefined;\n}\n\nexport function showNotice(notice: SessionNotice): void {\n const options = notice.description === undefined ? {} : { description: notice.description };\n if (notice.level === \"error\") {\n toast.error(notice.message, options);\n } else {\n toast.success(notice.message, options);\n }\n}\n\n/** What a failed request to the session says, for a notice's second line. */\nexport function failureText(cause: unknown): string {\n if (cause instanceof SessionError) {\n return cause.status === 403 ? \"Your role in the session does not allow this.\" : cause.message;\n }\n return cause instanceof Error ? cause.message : \"The session could not be reached.\";\n}\n\n/**\n * Copies text to this browser's clipboard from a click, and tells how it went. A page may\n * always copy text from a click, so a failure is worth a notice.\n */\nexport function copyTextHere(session: Session, text: string, copied: string): void {\n session.copyHere([{ type: \"text/plain\", data: new TextEncoder().encode(text) }]).then(\n (written) => {\n showNotice(\n written\n ? { level: \"info\", message: copied }\n : { level: \"error\", message: \"This browser did not take the copy\" },\n );\n },\n () => showNotice({ level: \"error\", message: \"This browser did not take the copy\" }),\n );\n}\n\n/** Pastes this browser's clipboard into the session, and tells when there was nothing to. */\nexport function pasteHere(session: Session): void {\n const nothing = (description?: string) =>\n showNotice({ level: \"error\", message: \"Nothing was pasted\", description });\n session.paste().then(\n (pasted) => {\n if (!pasted) {\n nothing(\n \"This browser's clipboard is empty or may not be read by the page. Paste with the keyboard instead.\",\n );\n }\n },\n () => nothing(),\n );\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { toast } from \"sonner\";\nimport type { Recording, Session, Target } from \"@aperture-browser/session-client\";\nimport {\n resolveSessionFeatures,\n type ResolvedSessionFeatures,\n type SessionFeatures,\n} from \"../features.ts\";\nimport { useRememberedFit } from \"../hooks/use-fit.ts\";\nimport {\n recordingIsEdited,\n recordingRuns,\n useRecordings,\n type RecordingsControl,\n} from \"../hooks/use-recordings.ts\";\nimport { showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport type { ApertureTheme } from \"../ui-root.tsx\";\nimport type { WorkbenchContribution } from \"./contributions.ts\";\n\n/** The theme, where the embedding page lets the workbench's menu change it. */\nexport interface Appearance {\n readonly theme: ApertureTheme;\n readonly onThemeChange: (theme: ApertureTheme) => void;\n}\n\nexport interface Workbench {\n readonly features: ResolvedSessionFeatures;\n readonly recordings: RecordingsControl;\n readonly contributions: readonly WorkbenchContribution[];\n /** The id of the recording or screenshot the gallery shows; none while it is closed. */\n readonly viewed: string | undefined;\n readonly view: (id: string | undefined) => void;\n /** Whether this member draws over the picture, which then takes no input from it. */\n readonly drawing: boolean;\n readonly setDrawing: (drawing: boolean) => void;\n readonly appearance: Appearance | undefined;\n readonly targetFaviconUrl: (target: Target) => string | undefined;\n}\n\nconst WorkbenchContext = createContext<Workbench | null>(null);\n\nexport interface WorkbenchProviderProps {\n readonly features?: SessionFeatures | undefined;\n /** What the workbench's slots show; see `workbenchContributions` for its own. */\n readonly contributions: readonly WorkbenchContribution[];\n /**\n * Whether targets take the size of this window unless the person switched that off.\n * False leaves them the size they have until the person chooses another.\n */\n readonly fit?: boolean | undefined;\n /** Lets the browser menu change the theme. */\n readonly appearance?: Appearance | undefined;\n /**\n * A tab's icon, in place of the one the session fetches for its page. The session's\n * own browser asks the page's site for it, which is told nothing of who watches.\n */\n readonly targetFaviconUrl?: ((target: Target) => string | undefined) | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * What the parts of a workbench share: the session's recordings, what is shown, and what\n * is contributed to the slots. The parts work anywhere below it, in any arrangement.\n */\nexport function WorkbenchProvider({\n features: given,\n contributions,\n fit = true,\n appearance,\n targetFaviconUrl,\n children,\n}: WorkbenchProviderProps) {\n const offered = useSessionSnapshot().features;\n const features = useMemo(() => resolveSessionFeatures(given, offered), [given, offered]);\n const recordings = useRecordings(features.recordings);\n useClipboardNotices();\n useFailureNotices();\n useRecordingNotices(recordings);\n usePageModeNotices();\n useRememberedFit(fit);\n\n const session = useSession();\n const faviconUrl = targetFaviconUrl ?? session.faviconUrl;\n\n const [viewed, view] = useState<string | undefined>(undefined);\n const [drawing, setDrawing] = useState(false);\n useEscapeEndsDrawing(drawing, setDrawing);\n\n const value = useMemo(\n () => ({\n features,\n recordings,\n contributions,\n viewed,\n view,\n drawing,\n setDrawing,\n appearance,\n targetFaviconUrl: faviconUrl,\n }),\n [features, recordings, contributions, viewed, drawing, appearance, faviconUrl],\n );\n return <WorkbenchContext.Provider value={value}>{children}</WorkbenchContext.Provider>;\n}\n\n/**\n * Escape puts the pencil down. It is heard before the session's keyboard is, so the page\n * gets none of it; a menu or dialog that is open keeps its own Escape.\n */\nfunction useEscapeEndsDrawing(drawing: boolean, setDrawing: (drawing: boolean) => void) {\n useEffect(() => {\n if (!drawing) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n if (\n event.key !== \"Escape\" ||\n (event.target instanceof Element &&\n event.target.closest(\"[role=menu], [role=dialog], [role=listbox]\") !== null)\n ) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n setDrawing(false);\n };\n window.addEventListener(\"keydown\", onKey, true);\n return () => window.removeEventListener(\"keydown\", onKey, true);\n }, [drawing, setDrawing]);\n}\n\nexport function useWorkbench(): Workbench {\n const value = useContext(WorkbenchContext);\n if (value === null) {\n throw new Error(\"The workbench's parts are used outside a WorkbenchProvider\");\n }\n return value;\n}\n\n/**\n * What the session copied goes to this browser's clipboard by itself where the browser\n * lets a page write to it at any time. Where it does not, a notice offers the click that\n * the browser wants.\n */\nfunction useClipboardNotices() {\n const session = useSession();\n\n useEffect(() => {\n // Each is a notice of its own that takes the place of the one before: one that came\n // under the same name as a notice that is on its way out went out with it.\n let shown: string | number | undefined;\n return session.onClipboard((event) => {\n if (event.written) {\n return;\n }\n const picture = !event.forms.some((form) => form.type.startsWith(\"text/\"));\n if (shown !== undefined) {\n toast.dismiss(shown);\n }\n shown = toast(\"The session copied something\", {\n description: picture\n ? \"This browser did not take it. Open the picture to copy it by hand.\"\n : \"This browser did not take it without a click.\",\n duration: 15_000,\n action: {\n label: picture ? \"Open\" : \"Copy\",\n onClick: () => copyByHand(session, event.forms),\n },\n });\n });\n }, [session]);\n}\n\nconst NOT_DONE = {\n go: \"The page did not open\",\n close: \"The tab was not closed\",\n copyPicture: \"The picture was not copied\",\n chooseFiles: \"The page did not get the files\",\n follow: \"That member is not followed\",\n setMode: \"The tab is shown as it was\",\n} as const;\n\nfunction useFailureNotices() {\n const session = useSession();\n\n useEffect(\n () =>\n session.onFailure((failure) => {\n showNotice({\n level: \"error\",\n message:\n failure.asked === undefined ? \"The session did not do that\" : NOT_DONE[failure.asked],\n description: failure.reason,\n });\n }),\n [session],\n );\n}\n\n/**\n * A tab that goes by its holder is shown another way once this member holds it from\n * another kind of device, and the page it has stays as it loaded: a page that chose what\n * it looks like by the browser that asked for it is the other kind's until it loads again,\n * which a notice offers.\n */\nfunction usePageModeNotices() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const holds =\n snapshot.presence?.held.some(\n (held) => held.tab === watched?.tab && held.holder === snapshot.presence?.you,\n ) ?? false;\n const shown = watched === undefined ? undefined : `${watched.id} ${watched.mobile}`;\n const before = useRef<{ id: string; mobile: boolean; url: string } | undefined>(undefined);\n\n useEffect(() => {\n const was = before.current;\n before.current =\n watched === undefined\n ? undefined\n : { id: watched.id, mobile: watched.mobile, url: watched.url };\n if (\n watched === undefined ||\n was === undefined ||\n was.id !== watched.id ||\n was.mobile === watched.mobile ||\n watched.mode !== \"auto\" ||\n !holds ||\n // Nothing of the web is there to load again.\n !/^https?:/u.test(was.url)\n ) {\n return;\n }\n toast(\n watched.mobile\n ? \"This tab is now shown as on a phone\"\n : \"This tab is now shown as on a desktop\",\n {\n id: \"aperture-session-page-mode\",\n description: watched.mobile\n ? \"Reload it if the page still has its desktop layout.\"\n : \"Reload it if the page still has its phone layout.\",\n duration: 8000,\n action: { label: \"Reload\", onClick: () => session.go({ along: \"reload\" }) },\n },\n );\n // What the tab is shown as is all this goes by.\n }, [shown]);\n}\n\nfunction copyByHand(session: Session, forms: Parameters<Session[\"copyHere\"]>[0]) {\n const refused = () =>\n showNotice({ level: \"error\", message: \"This browser did not take the copy\" });\n session.copyHere(forms).then((written) => {\n if (written) {\n showNotice({ level: \"info\", message: \"Copied\" });\n } else {\n refused();\n }\n }, refused);\n}\n\n/** Tells when a recording ends and when its edit is made, whoever started it. */\nfunction useRecordingNotices({ recordings }: RecordingsControl) {\n const before = useRef<ReadonlyMap<string, Recording> | undefined>(undefined);\n\n useEffect(() => {\n const known = before.current;\n before.current = new Map(recordings.map((recording) => [recording.id, recording]));\n // The recordings there were when the page opened are no news.\n if (known === undefined) {\n return;\n }\n for (const recording of recordings) {\n const was = known.get(recording.id);\n if (was === undefined) {\n continue;\n }\n if (recordingRuns(was) && recording.state === \"finished\") {\n showNotice({\n level: \"info\",\n message: \"Recording finished\",\n description: recordingIsEdited(recording)\n ? \"The raw recording is in the session's files. Its edit is being made.\"\n : \"The raw recording is in the session's files.\",\n });\n }\n if (recordingRuns(was) && recording.state === \"failed\") {\n showNotice({\n level: \"error\",\n message: \"Recording failed\",\n description: recording.failure ?? undefined,\n });\n }\n if (recordingIsEdited(was) && recording.edit?.state === \"finished\") {\n showNotice({\n level: \"info\",\n message: \"Recording edit finished\",\n description: \"It is in the recording menu, next to the raw recording.\",\n });\n }\n if (recordingIsEdited(was) && recording.edit?.state === \"failed\") {\n showNotice({\n level: \"error\",\n message: \"Recording edit failed\",\n description: recording.edit.failure ?? undefined,\n });\n }\n }\n }, [recordings]);\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({ prefix: \"aperture\" });\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n// Without a provider, portals keep Base UI's default container, the document body.\nconst PortalContainerContext = createContext<HTMLElement | undefined>(undefined);\n\nexport function PortalContainerProvider({\n container,\n children,\n}: {\n container: HTMLElement;\n children: ReactNode;\n}) {\n return (\n <PortalContainerContext.Provider value={container}>{children}</PortalContainerContext.Provider>\n );\n}\n\nexport function usePortalContainer(): HTMLElement | undefined {\n return useContext(PortalContainerContext);\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"@base-ui/react/drawer\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\n/** The edge of the window a sheet stands at, and is dragged to to be rid of it. */\ntype DrawerSide = \"bottom\" | \"left\" | \"right\";\n\nconst SideContext = React.createContext<DrawerSide>(\"bottom\");\n\nconst SWIPED = { bottom: \"down\", left: \"left\", right: \"right\" } as const;\n\n/** How the sheet and what dims the page behind it move: as a sheet of a phone's own does. */\nconst MOVES =\n \"aperture:duration-[450ms] aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:data-swiping:duration-0 aperture:data-ending-style:duration-[calc(var(--drawer-swipe-strength,1)*400ms)] aperture:motion-reduce:duration-0\";\n\nconst BACKDROP = cn(\n \"aperture:fixed aperture:inset-0 aperture:z-50 aperture:bg-black aperture:opacity-[calc(0.12+0.2*(1-var(--drawer-swipe-progress,0)))] aperture:transition-opacity aperture:data-closed:pointer-events-none aperture:data-ending-style:opacity-0 aperture:data-starting-style:opacity-0\",\n MOVES,\n);\n\n/** Where a sheet is laid in the window: above the keyboard, where one is there. */\nconst VIEWPORT = {\n bottom: \"aperture:items-end aperture:justify-center\",\n left: \"aperture:items-stretch aperture:justify-start\",\n right: \"aperture:items-stretch aperture:justify-end\",\n} as const;\n\nconst POPUP = {\n bottom: cn(\n // What is below a height it is dragged to is off the window: the room it takes there\n // is left empty, so that all it holds is scrolled to above it.\n \"aperture:max-h-[calc(100%-env(safe-area-inset-top)-1.5rem)] aperture:w-full aperture:rounded-t-2xl aperture:[padding-bottom:max(0px,calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] aperture:[transform:translateY(calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] aperture:data-ending-style:[padding-bottom:0] aperture:data-ending-style:[transform:translateY(100%)] aperture:data-starting-style:[padding-bottom:0] aperture:data-starting-style:[transform:translateY(100%)]\",\n // Dragged above where it rests, it shows nothing of the page below its foot.\n \"aperture:after:inset-x-0 aperture:after:top-full aperture:after:h-24\",\n ),\n left: cn(\n \"aperture:h-full aperture:w-[min(calc(23rem+env(safe-area-inset-left)),calc(100%-3.5rem))] aperture:rounded-r-2xl aperture:pl-[env(safe-area-inset-left)] aperture:[transform:translateX(var(--drawer-swipe-movement-x,0px))] aperture:data-ending-style:[transform:translateX(-100%)] aperture:data-starting-style:[transform:translateX(-100%)]\",\n \"aperture:after:inset-y-0 aperture:after:right-full aperture:after:w-24\",\n ),\n right: cn(\n \"aperture:h-full aperture:w-[min(calc(23rem+env(safe-area-inset-right)),calc(100%-3.5rem))] aperture:rounded-l-2xl aperture:pr-[env(safe-area-inset-right)] aperture:[transform:translateX(var(--drawer-swipe-movement-x,0px))] aperture:data-ending-style:[transform:translateX(100%)] aperture:data-starting-style:[transform:translateX(100%)]\",\n \"aperture:after:inset-y-0 aperture:after:left-full aperture:after:w-24\",\n ),\n} as const;\n\n/** The mark of where a sheet is dragged by: at its head, or along the edge it came in by. */\nconst HANDLE = {\n bottom: \"aperture:mx-auto aperture:mt-2 aperture:h-1 aperture:w-9 aperture:shrink-0\",\n left: \"aperture:absolute aperture:top-1/2 aperture:right-1.5 aperture:h-9 aperture:w-1 aperture:-translate-y-1/2\",\n right:\n \"aperture:absolute aperture:top-1/2 aperture:left-1.5 aperture:h-9 aperture:w-1 aperture:-translate-y-1/2\",\n} as const;\n\n/**\n * A sheet that follows the finger. At the window's foot it is dragged down to be rid of\n * it and between the heights named as `snapPoints`; at a `side` of the window, as where\n * the window is wider than tall, it is dragged to that side to be rid of it.\n */\nfunction Drawer({\n side = \"bottom\",\n ...props\n}: Omit<DrawerPrimitive.Root.Props, \"swipeDirection\"> & { side?: DrawerSide }) {\n return (\n <SideContext.Provider value={side}>\n <DrawerPrimitive.Root data-slot=\"drawer\" swipeDirection={SWIPED[side]} {...props} />\n </SideContext.Provider>\n );\n}\n\nfunction DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {\n return <DrawerPrimitive.Trigger data-slot=\"drawer-trigger\" {...props} />;\n}\n\nfunction DrawerClose({ ...props }: DrawerPrimitive.Close.Props) {\n return <DrawerPrimitive.Close data-slot=\"drawer-close\" {...props} />;\n}\n\n/** What a sheet is made of, for what lays out a sheet's popup itself. */\nfunction drawerPopupClassName(side: DrawerSide, className?: string) {\n return cn(\n \"aperture:relative aperture:flex aperture:min-h-0 aperture:touch-none aperture:flex-col aperture:bg-popover aperture:text-sm aperture:text-popover-foreground aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:outline-none aperture:transition-transform aperture:after:pointer-events-none aperture:after:absolute aperture:after:bg-[inherit] aperture:data-swiping:select-none\",\n POPUP[side],\n MOVES,\n className,\n );\n}\n\nfunction DrawerHandle({ side }: { side: DrawerSide }) {\n return (\n <div\n aria-hidden\n data-slot=\"drawer-handle\"\n className={cn(\"aperture:rounded-full aperture:bg-foreground/20\", HANDLE[side])}\n />\n );\n}\n\n/** What dims the page behind a sheet, and where the sheet is laid over it. */\nfunction DrawerFrame({ children }: { children: React.ReactNode }) {\n const side = React.useContext(SideContext);\n return (\n <DrawerPrimitive.Portal container={usePortalContainer()}>\n <DrawerPrimitive.Backdrop data-slot=\"drawer-overlay\" className={BACKDROP} />\n <DrawerPrimitive.Viewport\n data-slot=\"drawer-viewport\"\n className={cn(\n \"aperture:fixed aperture:inset-x-0 aperture:top-0 aperture:bottom-(--keyboard-inset,0px) aperture:z-50 aperture:flex aperture:touch-none aperture:data-closed:pointer-events-none\",\n VIEWPORT[side],\n )}\n >\n {children}\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n}\n\n/** The sheet itself. What scrolls in it is a `DrawerBody`. */\nfunction DrawerContent({ className, children, ...props }: DrawerPrimitive.Popup.Props) {\n const side = React.useContext(SideContext);\n return (\n <DrawerFrame>\n <DrawerPrimitive.Popup\n data-slot=\"drawer-content\"\n data-side={side}\n className={\n typeof className === \"function\"\n ? (state) => drawerPopupClassName(side, className(state))\n : drawerPopupClassName(side, className)\n }\n {...props}\n >\n <DrawerHandle side={side} />\n {children}\n </DrawerPrimitive.Popup>\n </DrawerFrame>\n );\n}\n\n/** What the sheet holds that scrolls: dragging it moves the sheet once it is at its top. */\nfunction DrawerBody({ className, ...props }: DrawerPrimitive.Content.Props) {\n return (\n <DrawerPrimitive.Content\n data-slot=\"drawer-body\"\n className={cn(\n \"aperture:min-h-0 aperture:flex-1 aperture:touch-auto aperture:overflow-y-auto aperture:overscroll-contain\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props) {\n return (\n <DrawerPrimitive.Title\n data-slot=\"drawer-title\"\n className={cn(\"aperture:text-base aperture:font-medium aperture:text-foreground\", className)}\n {...props}\n />\n );\n}\n\nfunction DrawerDescription({ className, ...props }: DrawerPrimitive.Description.Props) {\n return (\n <DrawerPrimitive.Description\n data-slot=\"drawer-description\"\n className={cn(\"aperture:text-sm aperture:text-muted-foreground\", className)}\n {...props}\n />\n );\n}\n\nexport {\n Drawer,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerFrame,\n DrawerHandle,\n DrawerBody,\n DrawerTitle,\n DrawerDescription,\n drawerPopupClassName,\n type DrawerSide,\n};\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"@base-ui/react/drawer\";\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\";\n\nimport { cn } from \"../utils.ts\";\nimport { ChevronLeftIcon, ChevronRightIcon, CheckIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\nimport {\n Drawer,\n DrawerFrame,\n DrawerHandle,\n drawerPopupClassName,\n type DrawerSide,\n} from \"./drawer.tsx\";\n\n/**\n * Whether the menu is a sheet, as a phone has it: its submenus are then pages that slide\n * in over it, each with the way back, in place of menus beside it.\n */\nconst SheetContext = React.createContext(false);\n\n/** A menu that is a sheet, for what it is made of. */\nconst SheetMenuContext = React.createContext<\n | {\n readonly side: DrawerSide;\n readonly open: boolean;\n readonly close: () => void;\n /** The sheet has gone from the window: the menu is then closed for itself as well. */\n readonly gone: () => void;\n }\n | undefined\n>(undefined);\n\n/** Where the pages of a sheet are laid, over what the sheet shows first. */\nconst SheetPagesContext = React.createContext<HTMLElement | null>(null);\n\n/** The submenu a part is of, where the menu is a sheet. */\nconst SheetSubContext = React.createContext<\n | {\n readonly close: () => void;\n /** What opens it, which names its page. */\n readonly trigger: React.RefObject<HTMLElement | null>;\n }\n | undefined\n>(undefined);\n\n/**\n * How much of the window's height a sheet at its foot takes: as it opens, low, where a\n * thumb reaches all of it, and dragged up. The sheet is as tall for every page of it.\n */\nconst SHEET_HEIGHTS = [0.5, 1];\n\n/** A menu laid in a sheet in place of beside what opened it, whatever its anchor says. */\nconst SHEET_PLACED =\n \"aperture:static! aperture:size-full aperture:min-h-0 aperture:transform-none! aperture:outline-none\";\n\n/** A sheet's page, which scrolls within itself. */\nconst SHEET_PAGE =\n \"aperture:flex aperture:size-full aperture:min-h-0 aperture:flex-col aperture:overflow-hidden aperture:rounded-[inherit] aperture:bg-popover aperture:text-popover-foreground aperture:outline-none\";\n\n/** What scrolls in a sheet's page. */\nconst SHEET_SCROLLS =\n \"aperture:min-h-0 aperture:flex-1 aperture:touch-auto aperture:overflow-x-hidden aperture:overflow-y-auto aperture:overscroll-contain aperture:pr-[max(0.5rem,env(safe-area-inset-right))] aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))] aperture:pl-[max(0.5rem,env(safe-area-inset-left))]\";\n\n/** A sheet at a side of the window has that side's inset already. */\nconst SHEET_SCROLLS_SIDE = {\n bottom: \"\",\n left: \"aperture:pl-2\",\n right: \"aperture:pr-2\",\n} as const;\n\n/** A sheet's row: as tall as a finger needs, and written larger than a menu's. */\nconst SHEET_ROW =\n \"aperture:min-h-11 aperture:gap-3 aperture:rounded-lg aperture:px-3 aperture:text-[0.9375rem] aperture:[&_svg:not([class*='size-'])]:size-5\";\n\n/** A sheet's row that is checked or chosen, with the mark of that at its end. */\nconst SHEET_MARKED_ROW = cn(SHEET_ROW, \"aperture:pr-10\");\n\ntype DropdownMenuProps = Omit<MenuPrimitive.Root.Props, \"onOpenChange\"> & {\n sheet?: DrawerSide | false;\n /** Told without what changed it where a sheet was dragged away. */\n onOpenChange?: (open: boolean, details?: MenuPrimitive.Root.ChangeEventDetails) => void;\n};\n\n/**\n * A menu. One that is a `sheet` is shown as a sheet that follows the finger, for a phone,\n * at the window's foot or at the side named: it is then opened and closed by whoever\n * shows it, and stays until the sheet has gone from the window.\n */\nfunction DropdownMenu({ sheet = false, ...props }: DropdownMenuProps) {\n if (sheet === false) {\n return <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n }\n return <SheetMenu side={sheet} {...props} />;\n}\n\nfunction SheetMenu({\n side,\n open = false,\n onOpenChange,\n ...props\n}: Omit<DropdownMenuProps, \"sheet\"> & { side: DrawerSide }) {\n const [lingers, setLingers] = React.useState(open);\n if (open && !lingers) {\n setLingers(true);\n }\n const change = React.useRef(onOpenChange);\n change.current = onOpenChange;\n const menu = React.useMemo(\n () => ({\n side,\n open,\n close: () => change.current?.(false),\n gone: () => setLingers(false),\n }),\n [side, open],\n );\n return (\n <SheetMenuContext.Provider value={menu}>\n <MenuPrimitive.Root\n data-slot=\"dropdown-menu\"\n // The sheet is what keeps the page behind it from being used.\n modal={false}\n open={open || lingers}\n onOpenChange={onOpenChange}\n {...props}\n />\n </SheetMenuContext.Provider>\n );\n}\n\n/** The menu as a sheet: what it holds scrolls, with its `footer` kept below that. */\nfunction SheetMenuContent({\n footer,\n className,\n children,\n finalFocus,\n ...props\n}: MenuPrimitive.Popup.Props & { footer?: React.ReactNode }) {\n const menu = React.useContext(SheetMenuContext);\n const container = usePortalContainer();\n const [pages, setPages] = React.useState<HTMLElement | null>(null);\n const [height, setHeight] = React.useState<number | string | null>(SHEET_HEIGHTS[0] ?? null);\n // It comes in from the window's edge, which it is not at before it is there.\n const [entered, setEntered] = React.useState(false);\n React.useEffect(() => setEntered(true), []);\n if (menu === undefined) {\n throw new Error(\"A menu's sheet is shown outside a menu that is a sheet\");\n }\n const { side } = menu;\n const snaps = side === \"bottom\";\n\n return (\n <MenuPrimitive.Portal container={container}>\n <Drawer\n side={side}\n open={menu.open && entered}\n onOpenChange={(next) => {\n if (!next) {\n menu.close();\n }\n }}\n onOpenChangeComplete={(next) => {\n if (!next && !menu.open) {\n menu.gone();\n }\n }}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: SHEET_HEIGHTS } : {})}\n >\n <DrawerFrame>\n <DrawerPrimitive.Popup\n data-menu-sheet=\"\"\n data-side={side}\n data-height={!snaps || height === SHEET_HEIGHTS[1] ? \"full\" : \"part\"}\n finalFocus={finalFocus}\n className={drawerPopupClassName(\n side,\n side === \"bottom\" ? \"aperture:h-[min(40rem,100%)]\" : undefined,\n )}\n >\n <MenuPrimitive.Positioner positionMethod=\"fixed\" className={SHEET_PLACED}>\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n finalFocus={finalFocus}\n className={cn(SHEET_PAGE, \"aperture:relative\", className)}\n {...props}\n >\n <SheetContext.Provider value>\n <SheetPagesContext.Provider value={pages}>\n <div\n data-slot=\"dropdown-menu-sheet-grip\"\n className=\"aperture:flex aperture:h-6 aperture:shrink-0 aperture:items-start aperture:justify-center\"\n >\n <DrawerHandle side={side} />\n </div>\n <DrawerPrimitive.Content\n className={cn(SHEET_SCROLLS, SHEET_SCROLLS_SIDE[side])}\n >\n {children}\n </DrawerPrimitive.Content>\n {footer}\n </SheetPagesContext.Provider>\n </SheetContext.Provider>\n <div\n ref={setPages}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:overflow-hidden aperture:rounded-[inherit]\"\n />\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </DrawerPrimitive.Popup>\n </DrawerFrame>\n </Drawer>\n </MenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return <MenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" container={container} {...props} />;\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n return <MenuPrimitive.Trigger data-slot=\"dropdown-menu-trigger\" {...props} />;\n}\n\nfunction DropdownMenuContent({\n align = \"start\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n anchor,\n collisionPadding,\n collisionAvoidance,\n footer,\n className,\n children,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n | \"align\"\n | \"alignOffset\"\n | \"side\"\n | \"sideOffset\"\n | \"anchor\"\n | \"collisionPadding\"\n | \"collisionAvoidance\"\n > & {\n /** What a menu that is a sheet keeps below what scrolls in it. */\n footer?: React.ReactNode;\n }) {\n const container = usePortalContainer();\n if (React.useContext(SheetMenuContext) !== undefined) {\n return (\n <SheetMenuContent footer={footer} className={className} {...props}>\n {children}\n </SheetMenuContent>\n );\n }\n return (\n <MenuPrimitive.Portal container={container}>\n <MenuPrimitive.Positioner\n className=\"aperture:isolate aperture:z-50 aperture:outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n // A menu without a trigger, such as one shown where a click was, is told its place.\n anchor={anchor}\n collisionPadding={collisionPadding}\n collisionAvoidance={collisionAvoidance}\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n className={cn(\n \"aperture:z-50 aperture:max-h-(--available-height) aperture:w-(--anchor-width) aperture:min-w-32 aperture:origin-(--transform-origin) aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:overflow-hidden aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n >\n {children}\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />;\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<\"div\"> & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <div\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n \"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:data-inset:pl-7\",\n sheet && \"aperture:px-3 aperture:pt-3\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean;\n variant?: \"default\" | \"destructive\";\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"aperture:group/dropdown-menu-item aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:not-data-[variant=destructive]:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-[variant=destructive]:text-destructive aperture:data-[variant=destructive]:data-highlighted:bg-destructive/10 aperture:data-[variant=destructive]:data-highlighted:text-destructive aperture:dark:data-[variant=destructive]:data-highlighted:bg-destructive/20 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4 aperture:data-[variant=destructive]:*:[svg]:text-destructive\",\n sheet && SHEET_ROW,\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n const sheet = React.useContext(SheetContext);\n const [open, setOpen] = React.useState(false);\n const trigger = React.useRef<HTMLElement | null>(null);\n const sub = React.useMemo(() => ({ close: () => setOpen(false), trigger }), []);\n if (!sheet) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />;\n }\n // Open for as long as its page is not left: nothing hovers on a phone to close it.\n return (\n <SheetSubContext.Provider value={sub}>\n <MenuPrimitive.SubmenuRoot\n data-slot=\"dropdown-menu-sub\"\n open={open}\n onOpenChange={setOpen}\n {...props}\n />\n </SheetSubContext.Provider>\n );\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.SubmenuTrigger\n ref={React.useContext(SheetSubContext)?.trigger}\n data-slot=\"dropdown-menu-sub-trigger\"\n // A sheet's page is opened by a press: a pointer left over its row asks for nothing.\n {...(sheet ? { openOnHover: false } : {})}\n data-inset={inset}\n className={cn(\n \"aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:not-data-[variant=destructive]:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-popup-open:bg-accent aperture:data-popup-open:text-accent-foreground aperture:data-open:bg-accent aperture:data-open:text-accent-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_ROW,\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"aperture:ml-auto\" />\n </MenuPrimitive.SubmenuTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n align = \"start\",\n alignOffset = -3,\n side = \"right\",\n sideOffset = 0,\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n const sheet = React.useContext(SheetContext);\n const sub = React.useContext(SheetSubContext);\n const pages = React.useContext(SheetPagesContext);\n const edge = React.useContext(SheetMenuContext)?.side ?? \"bottom\";\n // What its page is called: what opens it says, by the part of it that names it where\n // it says more than that.\n const [title, setTitle] = React.useState(\"\");\n const named = React.useCallback(\n (element: HTMLElement | null) => {\n const opener = sub?.trigger.current;\n if (element !== null && opener != null) {\n const names = opener.querySelector(\"[data-menu-title]\") ?? opener;\n setTitle((names.textContent ?? \"\").trim());\n }\n },\n [sub],\n );\n if (sheet && sub !== undefined) {\n const {\n anchor: _anchor,\n collisionPadding: _padding,\n collisionAvoidance: _avoidance,\n footer: _footer,\n ...page\n } = props;\n return (\n <MenuPrimitive.Portal container={pages}>\n <MenuPrimitive.Positioner\n positionMethod=\"fixed\"\n className=\"aperture:absolute! aperture:inset-0! aperture:transform-none! aperture:outline-none\"\n >\n <MenuPrimitive.Popup\n ref={named}\n data-slot=\"dropdown-menu-sub-content\"\n data-menu-sheet-page={title}\n className={cn(\n SHEET_PAGE,\n // A page that is on its way out takes no press: one meant for the row under it\n // would be a press beside the menu, which is rid of the menu.\n \"aperture:pointer-events-auto aperture:transition-transform aperture:duration-300 aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:data-ending-style:pointer-events-none aperture:data-ending-style:translate-x-full aperture:data-starting-style:translate-x-full aperture:motion-reduce:duration-0\",\n )}\n {...page}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:px-[max(0.5rem,env(safe-area-inset-left))]\">\n <button\n type=\"button\"\n data-menu-sheet-back=\"\"\n aria-label=\"Back\"\n className=\"aperture:flex aperture:size-11 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:active:bg-accent\"\n onClick={sub.close}\n >\n <ChevronLeftIcon className=\"aperture:size-5\" />\n </button>\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:pr-11 aperture:text-center aperture:text-base aperture:font-medium\">\n {title}\n </span>\n </div>\n <DrawerPrimitive.Content className={cn(SHEET_SCROLLS, SHEET_SCROLLS_SIDE[edge])}>\n {children}\n </DrawerPrimitive.Content>\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n }\n return (\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n \"aperture:w-auto aperture:min-w-[96px] aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n >\n {children}\n </DropdownMenuContent>\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_MARKED_ROW,\n className,\n )}\n checked={checked}\n {...props}\n >\n <span\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:right-2 aperture:flex aperture:items-center aperture:justify-center\",\n sheet && \"aperture:right-3\",\n )}\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return <MenuPrimitive.RadioGroup data-slot=\"dropdown-menu-radio-group\" {...props} />;\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_MARKED_ROW,\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:right-2 aperture:flex aperture:items-center aperture:justify-center\",\n sheet && \"aperture:right-3\",\n )}\n data-slot=\"dropdown-menu-radio-item-indicator\"\n >\n <MenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\"aperture:-mx-1 aperture:my-1 aperture:h-px aperture:bg-border\", className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n \"aperture:ml-auto aperture:text-xs aperture:tracking-widest aperture:text-muted-foreground aperture:group-focus/dropdown-menu-item:text-accent-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n","import * as React from \"react\";\nimport { ContextMenu as ContextMenuPrimitive } from \"@base-ui/react/context-menu\";\n\nimport { cn } from \"../utils.ts\";\nimport { ChevronRightIcon, CheckIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props) {\n return <ContextMenuPrimitive.Root data-slot=\"context-menu\" {...props} />;\n}\n\nfunction ContextMenuPortal({ ...props }: ContextMenuPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return (\n <ContextMenuPrimitive.Portal data-slot=\"context-menu-portal\" container={container} {...props} />\n );\n}\n\nfunction ContextMenuTrigger({ className, ...props }: ContextMenuPrimitive.Trigger.Props) {\n return (\n <ContextMenuPrimitive.Trigger\n data-slot=\"context-menu-trigger\"\n className={cn(\"aperture:select-none\", className)}\n {...props}\n />\n );\n}\n\nfunction ContextMenuContent({\n className,\n align = \"start\",\n alignOffset = 4,\n side = \"right\",\n sideOffset = 0,\n ...props\n}: ContextMenuPrimitive.Popup.Props &\n Pick<ContextMenuPrimitive.Positioner.Props, \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\">) {\n return (\n <ContextMenuPrimitive.Portal container={usePortalContainer()}>\n <ContextMenuPrimitive.Positioner\n className=\"aperture:isolate aperture:z-50 aperture:outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <ContextMenuPrimitive.Popup\n data-slot=\"context-menu-content\"\n className={cn(\n \"aperture:z-50 aperture:max-h-(--available-height) aperture:min-w-36 aperture:origin-(--transform-origin) aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n </ContextMenuPrimitive.Positioner>\n </ContextMenuPrimitive.Portal>\n );\n}\n\nfunction ContextMenuGroup({ ...props }: ContextMenuPrimitive.Group.Props) {\n return <ContextMenuPrimitive.Group data-slot=\"context-menu-group\" {...props} />;\n}\n\nfunction ContextMenuLabel({\n className,\n inset,\n ...props\n}: ContextMenuPrimitive.GroupLabel.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.GroupLabel\n data-slot=\"context-menu-label\"\n data-inset={inset}\n className={cn(\n \"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:data-inset:pl-7\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ContextMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: ContextMenuPrimitive.Item.Props & {\n inset?: boolean;\n variant?: \"default\" | \"destructive\";\n}) {\n return (\n <ContextMenuPrimitive.Item\n data-slot=\"context-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"aperture:group/context-menu-item aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-[variant=destructive]:text-destructive aperture:data-[variant=destructive]:focus:bg-destructive/10 aperture:data-[variant=destructive]:focus:text-destructive aperture:dark:data-[variant=destructive]:focus:bg-destructive/20 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4 aperture:focus:*:[svg]:text-accent-foreground aperture:data-[variant=destructive]:*:[svg]:text-destructive\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ContextMenuSub({ ...props }: ContextMenuPrimitive.SubmenuRoot.Props) {\n return <ContextMenuPrimitive.SubmenuRoot data-slot=\"context-menu-sub\" {...props} />;\n}\n\nfunction ContextMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: ContextMenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.SubmenuTrigger\n data-slot=\"context-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n \"aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-open:bg-accent aperture:data-open:text-accent-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"aperture:ml-auto\" />\n </ContextMenuPrimitive.SubmenuTrigger>\n );\n}\n\nfunction ContextMenuSubContent({ ...props }: React.ComponentProps<typeof ContextMenuContent>) {\n return (\n <ContextMenuContent\n data-slot=\"context-menu-sub-content\"\n className=\"aperture:shadow-lg\"\n side=\"right\"\n {...props}\n />\n );\n}\n\nfunction ContextMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: ContextMenuPrimitive.CheckboxItem.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n data-slot=\"context-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"aperture:pointer-events-none aperture:absolute aperture:right-2\">\n <ContextMenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </ContextMenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction ContextMenuRadioGroup({ ...props }: ContextMenuPrimitive.RadioGroup.Props) {\n return <ContextMenuPrimitive.RadioGroup data-slot=\"context-menu-radio-group\" {...props} />;\n}\n\nfunction ContextMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: ContextMenuPrimitive.RadioItem.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.RadioItem\n data-slot=\"context-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"aperture:pointer-events-none aperture:absolute aperture:right-2\">\n <ContextMenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </ContextMenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n}\n\nfunction ContextMenuSeparator({ className, ...props }: ContextMenuPrimitive.Separator.Props) {\n return (\n <ContextMenuPrimitive.Separator\n data-slot=\"context-menu-separator\"\n className={cn(\"aperture:-mx-1 aperture:my-1 aperture:h-px aperture:bg-border\", className)}\n {...props}\n />\n );\n}\n\nfunction ContextMenuShortcut({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"context-menu-shortcut\"\n className={cn(\n \"aperture:ml-auto aperture:text-xs aperture:tracking-widest aperture:text-muted-foreground aperture:group-focus/context-menu-item:text-accent-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioItem,\n ContextMenuLabel,\n ContextMenuSeparator,\n ContextMenuShortcut,\n ContextMenuGroup,\n ContextMenuPortal,\n ContextMenuSub,\n ContextMenuSubContent,\n ContextMenuSubTrigger,\n ContextMenuRadioGroup,\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { ContextMenuGroup } from \"@aperture-browser/ui/components/context-menu\";\nimport { DropdownMenuGroup } from \"@aperture-browser/ui/components/dropdown-menu\";\nimport {\n groupContributions,\n type WorkbenchSlotName as SlotName,\n type WorkbenchSlotProps,\n} from \"./contributions.ts\";\nimport { useWorkbench } from \"./context.tsx\";\n\nexport interface SlotProps extends WorkbenchSlotProps {\n readonly name: SlotName;\n}\n\n/** What is contributed to a slot, one after the other. */\nexport function WorkbenchSlot({ name, ...props }: SlotProps) {\n const { contributions } = useWorkbench();\n return groupContributions(contributions, name).flatMap(([, group]) =>\n group.map((one) => <one.component key={one.id} {...props} />),\n );\n}\n\nconst MENU_GROUPS = {\n dropdown: DropdownMenuGroup,\n context: ContextMenuGroup,\n} satisfies Record<string, ComponentType<{ children?: ReactNode; className?: string }>>;\n\n/**\n * A line before a group that shows something and comes after another that does: a group\n * whose contributions render nothing is empty, and takes no line. It is the group's own\n * classes, so that every page that has the menu has its lines, whichever stylesheet it is\n * built with.\n */\nconst PARTED =\n \"aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:-mx-1 aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:my-1 aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:block aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:h-px aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:bg-border\";\n\n/** What is contributed to a menu, group by group, with a line between the groups. */\nexport function WorkbenchMenuSlot({\n name,\n kind = \"dropdown\",\n ...props\n}: SlotProps & { readonly kind?: keyof typeof MENU_GROUPS }) {\n const { contributions } = useWorkbench();\n const Group = MENU_GROUPS[kind];\n return groupContributions(contributions, name).map(([group, items]) => (\n <Group key={group} data-workbench-menu-group={group} className={PARTED}>\n {items.map((one) => (\n <one.component key={one.id} {...props} />\n ))}\n </Group>\n ));\n}\n","import { useMemo } from \"react\";\nimport {\n ArrowLeft,\n ArrowRight,\n ClipboardPaste,\n Copy,\n ExternalLink,\n Image,\n Link2,\n RefreshCw,\n TextSelect,\n} from \"lucide-react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { copyTextHere, pasteHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\n\n/**\n * The menu of a right click in the session. The session's browser shows none: the session\n * tells what the click was on when the page made nothing of it, and the menu is shown\n * here, where the click was.\n */\nexport function PageMenu() {\n const session = useSession();\n const { menu } = useSessionSnapshot();\n const x = menu?.x ?? 0;\n const y = menu?.y ?? 0;\n\n // The place of the click, as an element the menu is laid out against.\n const anchor = useMemo(() => ({ getBoundingClientRect: () => new DOMRect(x, y, 0, 0) }), [x, y]);\n\n if (menu === undefined) {\n return null;\n }\n return (\n <DropdownMenu\n open\n modal={false}\n onOpenChange={(open) => {\n if (!open) {\n session.dismissMenu();\n }\n }}\n >\n <DropdownMenuContent\n data-session-page-menu=\"\"\n anchor={anchor}\n side=\"bottom\"\n align=\"start\"\n sideOffset={0}\n collisionPadding={4}\n className=\"aperture:w-auto aperture:min-w-52\"\n >\n <WorkbenchMenuSlot name=\"menu.page\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n// The keyboard is the session's again once the menu has closed and given focus back.\nfunction useAct() {\n const session = useSession();\n return (action: () => void) => () => {\n action();\n requestAnimationFrame(() => session.focus());\n };\n}\n\n/** For a click on a link. */\nexport function PageLinkItems() {\n const session = useSession();\n const link = useSessionSnapshot().menu?.link;\n const act = useAct();\n\n if (link === undefined) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ url: link }, { newTab: true }))}>\n <ExternalLink />\n Open link in new tab\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => copyTextHere(session, link, \"Link copied\"))}>\n <Link2 />\n Copy link address\n </DropdownMenuItem>\n </>\n );\n}\n\n/** For a click on a picture. */\nexport function PagePictureItems() {\n const session = useSession();\n const image = useSessionSnapshot().menu?.image;\n const { features } = useWorkbench();\n const act = useAct();\n\n if (image === undefined) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ url: image }, { newTab: true }))}>\n <ExternalLink />\n Open picture in new tab\n </DropdownMenuItem>\n {features.access.clipboard.read ? (\n <DropdownMenuItem onClick={act(() => session.copyPicture(image))}>\n <Image />\n Copy picture\n </DropdownMenuItem>\n ) : null}\n <DropdownMenuItem onClick={act(() => copyTextHere(session, image, \"Picture address copied\"))}>\n <Link2 />\n Copy picture address\n </DropdownMenuItem>\n </>\n );\n}\n\n/** For a click on selected text, or in a field to write into. */\nexport function PageTextItems() {\n const session = useSession();\n const menu = useSessionSnapshot().menu;\n const { features } = useWorkbench();\n const act = useAct();\n\n return (\n <>\n {menu?.text === undefined || !features.access.clipboard.read ? null : (\n <DropdownMenuItem onClick={act(session.copySelection)}>\n <Copy />\n Copy\n </DropdownMenuItem>\n )}\n {menu?.editable ? (\n <>\n {features.access.clipboard.write ? (\n <DropdownMenuItem onClick={act(() => pasteHere(session))}>\n <ClipboardPaste />\n Paste\n </DropdownMenuItem>\n ) : null}\n <DropdownMenuItem onClick={act(session.selectAll)}>\n <TextSelect />\n Select all\n </DropdownMenuItem>\n </>\n ) : null}\n </>\n );\n}\n\nexport function PageNavigationItems() {\n const session = useSession();\n const act = useAct();\n\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"back\" }))}>\n <ArrowLeft />\n Back\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"forward\" }))}>\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"reload\" }))}>\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n );\n}\n","import { Loader2Icon } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Spinner({ className, ...props }: ComponentProps<\"svg\">) {\n return (\n <Loader2Icon\n data-slot=\"spinner\"\n role=\"status\"\n aria-label=\"Loading\"\n className={cn(\"aperture:size-4 aperture:animate-spin\", className)}\n {...props}\n />\n );\n}\n\nexport { Spinner };\n","import { Button as ButtonPrimitive } from \"@base-ui/react/button\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { ReactNode } from \"react\";\n\nimport { cn } from \"../utils.ts\";\nimport { Spinner } from \"./spinner.tsx\";\n\nconst buttonVariants = cva(\n \"aperture:group/button aperture:inline-flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-lg aperture:border aperture:border-transparent aperture:bg-clip-padding aperture:text-sm aperture:leading-none aperture:font-medium aperture:whitespace-nowrap aperture:transition-all aperture:outline-none aperture:select-none aperture:focus-visible:border-ring aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:active:not-aria-[haspopup]:translate-y-px aperture:disabled:pointer-events-none aperture:disabled:opacity-50 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-3 aperture:aria-invalid:ring-destructive/20 aperture:dark:aria-invalid:border-destructive/50 aperture:dark:aria-invalid:ring-destructive/40 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n default:\n \"aperture:bg-primary aperture:text-primary-foreground aperture:hover:bg-primary/80\",\n outline:\n \"aperture:border-border aperture:bg-background aperture:hover:bg-muted aperture:hover:text-foreground aperture:aria-expanded:bg-muted aperture:aria-expanded:text-foreground aperture:dark:border-input aperture:dark:bg-input/30 aperture:dark:hover:bg-input/50\",\n secondary:\n \"aperture:bg-secondary aperture:text-secondary-foreground aperture:hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aperture:aria-expanded:bg-secondary aperture:aria-expanded:text-secondary-foreground\",\n ghost:\n \"aperture:hover:bg-muted aperture:hover:text-foreground aperture:aria-expanded:bg-muted aperture:aria-expanded:text-foreground aperture:dark:hover:bg-muted/50\",\n destructive:\n \"aperture:bg-destructive/10 aperture:text-destructive aperture:hover:bg-destructive/20 aperture:focus-visible:border-destructive/40 aperture:focus-visible:ring-destructive/20 aperture:dark:bg-destructive/20 aperture:dark:hover:bg-destructive/30 aperture:dark:focus-visible:ring-destructive/40\",\n link: \"aperture:text-primary aperture:underline-offset-4 aperture:hover:underline\",\n },\n size: {\n default:\n \"aperture:h-8 aperture:gap-1.5 aperture:px-2.5 aperture:pt-px aperture:has-data-[icon=inline-end]:pr-2 aperture:has-data-[icon=inline-start]:pl-2\",\n xs: \"aperture:h-6 aperture:gap-1 aperture:rounded-[min(--theme(--radius-md),10px)] aperture:px-2 aperture:pt-px aperture:text-xs aperture:in-data-[slot=button-group]:rounded-lg aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:[&_svg:not([class*='size-'])]:size-3\",\n sm: \"aperture:h-7 aperture:gap-1 aperture:rounded-[min(--theme(--radius-md),12px)] aperture:px-2.5 aperture:pt-px aperture:text-[0.8rem] aperture:in-data-[slot=button-group]:rounded-lg aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:[&_svg:not([class*='size-'])]:size-3.5\",\n lg: \"aperture:h-9 aperture:gap-1.5 aperture:px-2.5 aperture:pt-px aperture:has-data-[icon=inline-end]:pr-2 aperture:has-data-[icon=inline-start]:pl-2\",\n icon: \"aperture:size-8\",\n \"icon-xs\":\n \"aperture:size-6 aperture:rounded-[min(--theme(--radius-md),10px)] aperture:in-data-[slot=button-group]:rounded-lg aperture:[&_svg:not([class*='size-'])]:size-3\",\n \"icon-sm\":\n \"aperture:size-7 aperture:rounded-[min(--theme(--radius-md),12px)] aperture:in-data-[slot=button-group]:rounded-lg\",\n \"icon-lg\": \"aperture:size-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nfunction Button({\n className,\n variant = \"default\",\n size = \"default\",\n pending,\n disabled,\n children,\n ...props\n}: ButtonPrimitive.Props &\n VariantProps<typeof buttonVariants> & {\n /**\n * Whether what it does is being done: it is pressed no more until that ends, and says\n * so in place of what it says, as wide as it was.\n */\n pending?: boolean;\n }) {\n // Exposed so dense toolbars can keep icon buttons square when they shrink their height.\n const iconOnly = size === \"icon\" || (size?.startsWith(\"icon-\") ?? false);\n return (\n <ButtonPrimitive\n data-slot=\"button\"\n // What it is whatever slot it is given: the sizes for a finger go by it.\n data-button=\"\"\n data-icon-button={iconOnly ? \"\" : undefined}\n data-pending={pending === true ? \"\" : undefined}\n aria-busy={pending === true ? true : undefined}\n disabled={pending === true ? true : disabled}\n className={cn(\n buttonVariants({ variant, size, className }),\n pending === undefined ? undefined : \"aperture:relative\",\n )}\n {...props}\n >\n {pending === undefined ? (\n children\n ) : (\n <>\n {/* It keeps its room while it is not seen: the button stays as wide as it was. */}\n <span className={cn(\"aperture:contents\", pending && \"aperture:invisible\")}>\n {children as ReactNode}\n </span>\n {pending ? <Spinner className=\"aperture:absolute aperture:size-4\" /> : null}\n </>\n )}\n </ButtonPrimitive>\n );\n}\n\nexport { Button, buttonVariants };\n","import { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction TooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {\n return <TooltipPrimitive.Provider data-slot=\"tooltip-provider\" delay={delay} {...props} />;\n}\n\nfunction Tooltip({ ...props }: TooltipPrimitive.Root.Props) {\n return <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />;\n}\n\nfunction TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n side = \"top\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n children,\n ...props\n}: TooltipPrimitive.Popup.Props &\n Pick<TooltipPrimitive.Positioner.Props, \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\">) {\n return (\n <TooltipPrimitive.Portal container={usePortalContainer()}>\n <TooltipPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"aperture:isolate aperture:z-50\"\n >\n <TooltipPrimitive.Popup\n data-slot=\"tooltip-content\"\n className={cn(\n \"aperture:z-50 aperture:inline-flex aperture:w-fit aperture:max-w-xs aperture:origin-(--transform-origin) aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:bg-foreground aperture:px-3 aperture:py-1.5 aperture:text-xs aperture:text-background aperture:has-data-[slot=kbd]:pr-1.5 aperture:**:data-[slot=kbd]:relative aperture:**:data-[slot=kbd]:isolate aperture:**:data-[slot=kbd]:z-50 aperture:**:data-[slot=kbd]:rounded-sm aperture:data-[state=delayed-open]:animate-in aperture:data-[state=delayed-open]:fade-in-0 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"aperture:z-50 aperture:size-2.5 aperture:translate-y-[calc(-50%-2px)] aperture:rotate-45 aperture:rounded-[2px] aperture:bg-foreground aperture:fill-foreground aperture:data-[side=bottom]:top-1 aperture:data-[side=inline-end]:top-1/2! aperture:data-[side=inline-end]:-left-1 aperture:data-[side=inline-end]:-translate-y-1/2 aperture:data-[side=inline-start]:top-1/2! aperture:data-[side=inline-start]:-right-1 aperture:data-[side=inline-start]:-translate-y-1/2 aperture:data-[side=left]:top-1/2! aperture:data-[side=left]:-right-1 aperture:data-[side=left]:-translate-y-1/2 aperture:data-[side=right]:top-1/2! aperture:data-[side=right]:-left-1 aperture:data-[side=right]:-translate-y-1/2 aperture:data-[side=top]:-bottom-2.5\" />\n </TooltipPrimitive.Popup>\n </TooltipPrimitive.Positioner>\n </TooltipPrimitive.Portal>\n );\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n","import { useState, type ComponentProps, type ReactNode } from \"react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\n\n/** A toolbar button that opens a menu, with its name as a tooltip. */\nexport function MenuButton({\n label,\n variant = \"ghost\",\n children,\n ...props\n}: {\n label: string;\n variant?: ComponentProps<typeof Button>[\"variant\"];\n children: ReactNode;\n} & Omit<ComponentProps<typeof Button>, \"children\" | \"variant\">) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant={variant}\n size=\"icon-sm\"\n aria-label={label}\n {...props}\n />\n }\n />\n }\n >\n {children}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n\n/** A submenu's trigger that names a setting and shows what it is set to. */\nexport function SettingSubTrigger({\n name,\n value,\n disabled,\n}: {\n name: string;\n value: ReactNode;\n disabled?: boolean;\n}) {\n return (\n <DropdownMenuSubTrigger disabled={disabled}>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n {name}\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">{value}</span>\n </span>\n </DropdownMenuSubTrigger>\n );\n}\n\n/** A menu item's two lines: what it is, and what that means. */\nexport function Described({ title, children }: { title: ReactNode; children: ReactNode }) {\n return (\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-col\">\n <span>{title}</span>\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">{children}</span>\n </span>\n );\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes >= 1024 * 1024 * 1024) {\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n }\n if (bytes >= 1024 * 1024) {\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n if (bytes >= 1024) {\n return `${Math.ceil(bytes / 1024)} kB`;\n }\n return `${bytes} B`;\n}\n\nexport function formatDuration(milliseconds: number): string {\n const elapsed = Math.max(0, Math.floor(milliseconds / 1000));\n const hours = Math.floor(elapsed / 3600);\n const minutes = String(Math.floor((elapsed % 3600) / 60)).padStart(2, \"0\");\n const seconds = String(elapsed % 60).padStart(2, \"0\");\n return hours > 0 ? `${hours}:${minutes}:${seconds}` : `${minutes}:${seconds}`;\n}\n\nexport function formatStarted(startedAtMs: number): string {\n return new Date(startedAtMs).toLocaleString(undefined, {\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n}\n\n/** The small picture of a list's entry, and what stands for it where there is none. */\nexport function Thumbnail({\n src,\n className,\n children,\n}: {\n src: string | undefined;\n className?: string;\n children: ReactNode;\n}) {\n const [failed, setFailed] = useState(false);\n return (\n <span\n className={cn(\n \"aperture:flex aperture:h-9 aperture:w-16 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:overflow-hidden aperture:rounded aperture:bg-muted aperture:text-muted-foreground aperture:ring-1 aperture:ring-foreground/10\",\n className,\n )}\n >\n {src === undefined || failed ? (\n children\n ) : (\n <img\n src={src}\n alt=\"\"\n loading=\"lazy\"\n onError={() => setFailed(true)}\n className=\"aperture:size-full aperture:object-cover aperture:object-top\"\n />\n )}\n </span>\n );\n}\n","import { Monitor, Smartphone } from \"lucide-react\";\nimport type { PageMode } from \"@aperture-browser/session-client\";\nimport {\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useSession, useWatchedTarget } from \"../session.tsx\";\nimport { Described } from \"./menu-parts.tsx\";\n\nconst MODES: readonly { mode: PageMode; label: string; detail: string }[] = [\n { mode: \"auto\", label: \"Auto\", detail: \"As on the device of whoever holds the tab.\" },\n { mode: \"desktop\", label: \"Desktop\", detail: \"As a desktop's browser shows it.\" },\n { mode: \"mobile\", label: \"Mobile\", detail: \"As a phone's browser shows it.\" },\n];\n\nconst isMode = (value: unknown): value is PageMode => MODES.some((one) => one.mode === value);\n\n/**\n * How the watched tab's pages are shown: as on a desktop, as on a phone, or as on what its\n * holder uses. The page loads again when that changes how it is shown.\n */\nexport function PageModeItem() {\n const session = useSession();\n const watched = useWatchedTarget();\n const { changes } = useInputState();\n const label = MODES.find((one) => one.mode === watched?.mode)?.label ?? \"\";\n const shown = watched?.mobile === true ? \"mobile\" : \"desktop\";\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger\n disabled={!changes || watched === undefined}\n data-workbench-page-mode={watched?.mode}\n >\n {watched?.mobile === true ? <Smartphone /> : <Monitor />}\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n Page mode\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">\n {watched?.mode === \"auto\" ? `Auto · ${shown}` : label}\n </span>\n </span>\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"How the tab's pages are shown\"\n value={watched?.mode ?? \"\"}\n onValueChange={(value) => {\n if (isMode(value)) {\n session.setMode(value);\n }\n }}\n >\n {MODES.map(({ mode, label: name, detail }) => (\n <DropdownMenuRadioItem key={mode} value={mode} data-page-mode={mode} closeOnClick>\n <Described title={name}>{detail}</Described>\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n","import * as React from \"react\";\nimport { Input as InputPrimitive } from \"@base-ui/react/input\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Input({ className, type, ...props }: React.ComponentProps<\"input\">) {\n return (\n <InputPrimitive\n type={type}\n data-slot=\"input\"\n className={cn(\n \"aperture:h-8 aperture:w-full aperture:min-w-0 aperture:rounded-lg aperture:border aperture:border-input aperture:bg-transparent aperture:px-2.5 aperture:py-1 aperture:text-base aperture:transition-colors aperture:outline-none aperture:file:inline-flex aperture:file:h-6 aperture:file:border-0 aperture:file:bg-transparent aperture:file:text-sm aperture:file:font-medium aperture:file:text-foreground aperture:placeholder:text-muted-foreground aperture:focus-visible:border-ring aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:disabled:pointer-events-none aperture:disabled:cursor-not-allowed aperture:disabled:bg-input/50 aperture:disabled:opacity-50 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-3 aperture:aria-invalid:ring-destructive/20 aperture:md:text-sm aperture:dark:bg-input/30 aperture:dark:disabled:bg-input/80 aperture:dark:aria-invalid:border-destructive/50 aperture:dark:aria-invalid:ring-destructive/40\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Input };\n","import * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\nimport { Button } from \"./button.tsx\";\nimport { Input } from \"./input.tsx\";\nimport { Textarea } from \"./textarea.tsx\";\n\nfunction InputGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n \"aperture:group/input-group aperture:relative aperture:flex aperture:h-8 aperture:w-full aperture:min-w-0 aperture:items-center aperture:rounded-lg aperture:border aperture:border-input aperture:transition-colors aperture:outline-none aperture:in-data-[slot=combobox-content]:focus-within:border-inherit aperture:in-data-[slot=combobox-content]:focus-within:ring-0 aperture:has-disabled:bg-input/50 aperture:has-disabled:opacity-50 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-ring aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-3 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 aperture:has-[[data-slot][aria-invalid=true]]:border-destructive aperture:has-[[data-slot][aria-invalid=true]]:ring-3 aperture:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 aperture:has-[>[data-align=block-end]]:h-auto aperture:has-[>[data-align=block-end]]:flex-col aperture:has-[>[data-align=block-start]]:h-auto aperture:has-[>[data-align=block-start]]:flex-col aperture:has-[>textarea]:h-auto aperture:dark:bg-input/30 aperture:dark:has-disabled:bg-input/80 aperture:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 aperture:has-[>[data-align=block-end]]:[&>input]:pt-3 aperture:has-[>[data-align=block-start]]:[&>input]:pb-3 aperture:has-[>[data-align=inline-end]]:[&>input]:pr-1.5 aperture:has-[>[data-align=inline-start]]:[&>input]:pl-1.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\nconst inputGroupAddonVariants = cva(\n \"aperture:flex aperture:h-auto aperture:cursor-text aperture:items-center aperture:justify-center aperture:gap-2 aperture:py-1.5 aperture:text-sm aperture:font-medium aperture:text-muted-foreground aperture:select-none aperture:group-data-[disabled=true]/input-group:opacity-50 aperture:[&>kbd]:rounded-[calc(var(--radius)-5px)] aperture:[&>svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n align: {\n \"inline-start\":\n \"aperture:order-first aperture:pl-2 aperture:has-[>button]:ml-[-0.3rem] aperture:has-[>kbd]:ml-[-0.15rem]\",\n \"inline-end\":\n \"aperture:order-last aperture:pr-2 aperture:has-[>button]:mr-[-0.3rem] aperture:has-[>kbd]:mr-[-0.15rem]\",\n \"block-start\":\n \"aperture:order-first aperture:w-full aperture:justify-start aperture:px-2.5 aperture:pt-2 aperture:group-has-[>input]/input-group:pt-2 aperture:[[class~='aperture:border-b']]:pb-2\",\n \"block-end\":\n \"aperture:order-last aperture:w-full aperture:justify-start aperture:px-2.5 aperture:pb-2 aperture:group-has-[>input]/input-group:pb-2 aperture:[[class~='aperture:border-t']]:pt-2\",\n },\n },\n defaultVariants: {\n align: \"inline-start\",\n },\n },\n);\n\nfunction InputGroupAddon({\n className,\n align = \"inline-start\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof inputGroupAddonVariants>) {\n return (\n <div\n role=\"group\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(inputGroupAddonVariants({ align }), className)}\n onClick={(e) => {\n if ((e.target as HTMLElement).closest(\"button\")) {\n return;\n }\n e.currentTarget.parentElement?.querySelector(\"input\")?.focus();\n }}\n {...props}\n />\n );\n}\n\nconst inputGroupButtonVariants = cva(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm aperture:shadow-none\",\n {\n variants: {\n size: {\n xs: \"aperture:h-6 aperture:gap-1 aperture:rounded-[calc(var(--radius)-3px)] aperture:px-1.5 aperture:[&>svg:not([class*='size-'])]:size-3.5\",\n sm: \"\",\n \"icon-xs\":\n \"aperture:size-6 aperture:rounded-[calc(var(--radius)-3px)] aperture:p-0 aperture:has-[>svg]:p-0\",\n \"icon-sm\": \"aperture:size-8 aperture:p-0 aperture:has-[>svg]:p-0\",\n },\n },\n defaultVariants: {\n size: \"xs\",\n },\n },\n);\n\nfunction InputGroupButton({\n className,\n type = \"button\",\n variant = \"ghost\",\n size = \"xs\",\n ...props\n}: Omit<React.ComponentProps<typeof Button>, \"size\" | \"type\"> &\n VariantProps<typeof inputGroupButtonVariants> & {\n type?: \"button\" | \"submit\" | \"reset\";\n }) {\n return (\n <Button\n type={type}\n data-size={size}\n variant={variant}\n className={cn(inputGroupButtonVariants({ size }), className)}\n {...props}\n />\n );\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n className={cn(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm aperture:text-muted-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction InputGroupInput({ className, ...props }: React.ComponentProps<\"input\">) {\n return (\n <Input\n data-slot=\"input-group-control\"\n className={cn(\n \"aperture:flex-1 aperture:rounded-none aperture:border-0 aperture:bg-transparent aperture:shadow-none aperture:ring-0 aperture:focus-visible:ring-0 aperture:disabled:bg-transparent aperture:aria-invalid:ring-0 aperture:dark:bg-transparent aperture:dark:disabled:bg-transparent\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction InputGroupTextarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\n return (\n <Textarea\n data-slot=\"input-group-control\"\n className={cn(\n \"aperture:flex-1 aperture:resize-none aperture:rounded-none aperture:border-0 aperture:bg-transparent aperture:py-2 aperture:shadow-none aperture:ring-0 aperture:focus-visible:ring-0 aperture:disabled:bg-transparent aperture:aria-invalid:ring-0 aperture:dark:bg-transparent aperture:dark:disabled:bg-transparent\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupText,\n InputGroupInput,\n InputGroupTextarea,\n};\n","import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { useSessionSnapshot } from \"../session.tsx\";\n\n/** Whether a media query holds, as the window and what points at it change. */\nexport function useMedia(query: string): boolean {\n return useSyncExternalStore(\n (changed) => {\n const media = window.matchMedia(query);\n media.addEventListener(\"change\", changed);\n return () => media.removeEventListener(\"change\", changed);\n },\n () => window.matchMedia(query).matches,\n () => false,\n );\n}\n\n/**\n * Whether the session is used from a phone, as the session is told it is: the workbench\n * is then the picture with a bar below it, in place of a browser's rows above it.\n */\nexport const usePhone = () => useSessionSnapshot().phone;\n\n/** Whether a finger is what points: what is pressed is larger then, and takes more room. */\nexport const useFinger = () => useMedia(\"(pointer: coarse)\");\n\n/**\n * Whether the window is as short as a phone held on its side: the workbench then keeps one\n * row above the picture in place of two.\n */\nexport const useShortWindow = () => useMedia(\"(pointer: coarse) and (max-height: 30rem)\");\n\n/** Calls `changed` whenever the window is turned or gets another size. */\nfunction turned(changed: () => void) {\n const media = window.matchMedia(\"(orientation: landscape)\");\n // Not every browser that has a screen tells of its turning.\n const screen = window.screen.orientation as ScreenOrientation | undefined;\n media.addEventListener(\"change\", changed);\n screen?.addEventListener(\"change\", changed);\n window.addEventListener(\"resize\", changed);\n return () => {\n media.removeEventListener(\"change\", changed);\n screen?.removeEventListener(\"change\", changed);\n window.removeEventListener(\"resize\", changed);\n };\n}\n\n/** How the screen is held, where it tells: a window is wider than tall for a keyboard too. */\nconst screenTurn = (): string | undefined =>\n (window.screen.orientation as ScreenOrientation | undefined)?.type;\n\nconst onSide = () =>\n screenTurn()?.startsWith(\"landscape\") ?? window.matchMedia(\"(orientation: landscape)\").matches;\n\n/**\n * Whether the session is used from a phone held on its side: height is what there is\n * least of then, and the workbench is laid out along a side of the picture.\n */\nexport function usePhoneOnSide(): boolean {\n const phone = usePhone();\n const side = useSyncExternalStore(turned, onSide, () => false);\n return phone && side;\n}\n\n/** What of the window's sides a screen's cutout and corners take, in CSS pixels. */\ninterface Insets {\n readonly left: number;\n readonly right: number;\n}\n\n/**\n * The side of the window a phone held on its side has the workbench's rail at: the one\n * away from the camera's cutout, which is the one with less of an inset. An iPhone gives\n * both sides the same inset, and then it is how the screen is turned that tells where the\n * cutout is: at the left as a phone is first turned, at the right turned the other way.\n * A screen with no cutout has the rail at the right.\n */\nexport function useRailSide(): \"left\" | \"right\" {\n const [side, setSide] = useState<\"left\" | \"right\">(\"right\");\n useEffect(() => {\n const probe = document.createElement(\"div\");\n probe.style.cssText =\n \"position:fixed;visibility:hidden;pointer-events:none;inset:0 auto auto 0;padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)\";\n document.body.append(probe);\n const look = () => {\n const style = getComputedStyle(probe);\n const insets: Insets = {\n left: Number.parseFloat(style.paddingLeft) || 0,\n right: Number.parseFloat(style.paddingRight) || 0,\n };\n if (insets.left !== insets.right) {\n setSide(insets.left > insets.right ? \"right\" : \"left\");\n } else {\n setSide(insets.left > 0 && screenTurn() === \"landscape-secondary\" ? \"left\" : \"right\");\n }\n };\n look();\n const stop = turned(look);\n return () => {\n stop();\n probe.remove();\n };\n }, []);\n return side;\n}\n","\"use client\";\n\nimport { PreviewCard as PreviewCardPrimitive } from \"@base-ui/react/preview-card\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction HoverCard<Payload>(props: PreviewCardPrimitive.Root.Props<Payload>) {\n return <PreviewCardPrimitive.Root data-slot=\"hover-card\" {...props} />;\n}\n\nfunction HoverCardTrigger<Payload>(props: PreviewCardPrimitive.Trigger.Props<Payload>) {\n return <PreviewCardPrimitive.Trigger data-slot=\"hover-card-trigger\" {...props} />;\n}\n\nfunction HoverCardContent({\n className,\n positionerClassName,\n side = \"bottom\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n collisionPadding,\n ...props\n}: PreviewCardPrimitive.Popup.Props &\n Pick<\n PreviewCardPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\" | \"collisionPadding\"\n > & { positionerClassName?: string }) {\n return (\n <PreviewCardPrimitive.Portal container={usePortalContainer()}>\n <PreviewCardPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\"aperture:isolate aperture:z-50\", positionerClassName)}\n >\n <PreviewCardPrimitive.Popup\n data-slot=\"hover-card-content\"\n className={cn(\n \"aperture:z-50 aperture:w-64 aperture:rounded-lg aperture:bg-popover aperture:p-2.5 aperture:text-sm aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:outline-hidden\",\n className,\n )}\n {...props}\n />\n </PreviewCardPrimitive.Positioner>\n </PreviewCardPrimitive.Portal>\n );\n}\n\nconst createHoverCardHandle = PreviewCardPrimitive.createHandle;\n\nexport { HoverCard, HoverCardTrigger, HoverCardContent, createHoverCardHandle };\nexport type HoverCardHandle<Payload> = PreviewCardPrimitive.Handle<Payload>;\n","\"use client\";\n\nimport { ScrollArea as ScrollAreaPrimitive } from \"@base-ui/react/scroll-area\";\nimport type { Ref } from \"react\";\n\nimport { cn } from \"../utils.ts\";\n\ntype ScrollAreaProps = ScrollAreaPrimitive.Root.Props & {\n viewportClassName?: string;\n viewportRef?: Ref<HTMLDivElement>;\n scrollbars?: \"vertical\" | \"horizontal\" | \"both\";\n};\n\nfunction ScrollArea({\n className,\n viewportClassName,\n viewportRef,\n scrollbars = \"vertical\",\n children,\n ...props\n}: ScrollAreaProps) {\n const vertical = scrollbars === \"vertical\" || scrollbars === \"both\";\n const horizontal = scrollbars === \"horizontal\" || scrollbars === \"both\";\n\n return (\n <ScrollAreaPrimitive.Root\n data-slot=\"scroll-area\"\n className={cn(\"aperture:relative\", className)}\n {...props}\n >\n <ScrollAreaPrimitive.Viewport\n ref={viewportRef}\n data-slot=\"scroll-area-viewport\"\n style={{\n overflowX: horizontal ? \"scroll\" : \"hidden\",\n overflowY: vertical ? \"scroll\" : \"hidden\",\n }}\n className={cn(\n \"aperture:size-full aperture:rounded-[inherit] aperture:transition-[color,box-shadow] aperture:outline-none aperture:focus-visible:ring-[3px] aperture:focus-visible:ring-ring/50 aperture:focus-visible:outline-1\",\n viewportClassName,\n )}\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n {vertical ? <ScrollBar /> : null}\n {horizontal ? <ScrollBar orientation=\"horizontal\" /> : null}\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n );\n}\n\nfunction ScrollBar({\n className,\n orientation = \"vertical\",\n ...props\n}: ScrollAreaPrimitive.Scrollbar.Props) {\n return (\n <ScrollAreaPrimitive.Scrollbar\n data-slot=\"scroll-area-scrollbar\"\n data-orientation={orientation}\n orientation={orientation}\n className={cn(\n \"aperture:flex aperture:touch-none aperture:p-px aperture:transition-colors aperture:select-none aperture:hover:bg-muted/50 aperture:data-[orientation=horizontal]:h-2.5 aperture:data-[orientation=horizontal]:flex-col aperture:data-[orientation=horizontal]:border-t aperture:data-[orientation=horizontal]:border-t-transparent aperture:data-[orientation=vertical]:h-full aperture:data-[orientation=vertical]:w-2.5 aperture:data-[orientation=vertical]:border-l aperture:data-[orientation=vertical]:border-l-transparent\",\n className,\n )}\n {...props}\n >\n <ScrollAreaPrimitive.Thumb\n data-slot=\"scroll-area-thumb\"\n className=\"aperture:relative aperture:flex-1 aperture:rounded-full aperture:bg-border aperture:transition-colors aperture:hover:bg-foreground/35\"\n />\n </ScrollAreaPrimitive.Scrollbar>\n );\n}\n\nexport { ScrollArea, ScrollBar };\n","import * as React from \"react\";\nimport { Avatar as AvatarPrimitive } from \"@base-ui/react/avatar\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Avatar({\n className,\n size = \"default\",\n ...props\n}: AvatarPrimitive.Root.Props & {\n size?: \"default\" | \"sm\" | \"lg\";\n}) {\n return (\n <AvatarPrimitive.Root\n data-slot=\"avatar\"\n data-size={size}\n className={cn(\n \"aperture:group/avatar aperture:relative aperture:flex aperture:size-8 aperture:shrink-0 aperture:rounded-full aperture:select-none aperture:after:absolute aperture:after:inset-0 aperture:after:rounded-full aperture:after:border aperture:after:border-border aperture:after:mix-blend-darken aperture:data-[size=lg]:size-10 aperture:data-[size=sm]:size-6 aperture:dark:after:mix-blend-lighten\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {\n return (\n <AvatarPrimitive.Image\n data-slot=\"avatar-image\"\n className={cn(\n \"aperture:aspect-square aperture:size-full aperture:rounded-full aperture:object-cover\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarFallback({ className, ...props }: AvatarPrimitive.Fallback.Props) {\n return (\n <AvatarPrimitive.Fallback\n data-slot=\"avatar-fallback\"\n className={cn(\n \"aperture:flex aperture:size-full aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-muted aperture:text-sm aperture:text-muted-foreground aperture:group-data-[size=sm]/avatar:text-xs\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarBadge({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"avatar-badge\"\n className={cn(\n \"aperture:absolute aperture:right-0 aperture:bottom-0 aperture:z-10 aperture:inline-flex aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-primary aperture:text-primary-foreground aperture:bg-blend-color aperture:ring-2 aperture:ring-background aperture:select-none\",\n \"aperture:group-data-[size=sm]/avatar:size-2 aperture:group-data-[size=sm]/avatar:[&>svg]:hidden\",\n \"aperture:group-data-[size=default]/avatar:size-2.5 aperture:group-data-[size=default]/avatar:[&>svg]:size-2\",\n \"aperture:group-data-[size=lg]/avatar:size-3 aperture:group-data-[size=lg]/avatar:[&>svg]:size-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"avatar-group\"\n className={cn(\n \"aperture:group/avatar-group aperture:flex aperture:-space-x-2 aperture:*:data-[slot=avatar]:ring-2 aperture:*:data-[slot=avatar]:ring-background\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarGroupCount({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"avatar-group-count\"\n className={cn(\n \"aperture:relative aperture:flex aperture:size-8 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-muted aperture:text-sm aperture:text-muted-foreground aperture:ring-2 aperture:ring-background aperture:group-has-data-[size=lg]/avatar-group:size-10 aperture:group-has-data-[size=sm]/avatar-group:size-6 aperture:[&>svg]:size-4 aperture:group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 aperture:group-has-data-[size=sm]/avatar-group:[&>svg]:size-3\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge };\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction Popover({ ...props }: PopoverPrimitive.Root.Props) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nfunction PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\n}\n\nfunction PopoverContent({\n className,\n align = \"center\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n anchor,\n ...props\n}: PopoverPrimitive.Popup.Props &\n Pick<\n PopoverPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\" | \"anchor\"\n >) {\n return (\n <PopoverPrimitive.Portal container={usePortalContainer()}>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n anchor={anchor}\n className=\"aperture:isolate aperture:z-50\"\n >\n <PopoverPrimitive.Popup\n data-slot=\"popover-content\"\n className={cn(\n \"aperture:z-50 aperture:flex aperture:w-72 aperture:origin-(--transform-origin) aperture:flex-col aperture:gap-2.5 aperture:rounded-lg aperture:bg-popover aperture:p-2.5 aperture:text-sm aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:outline-hidden aperture:duration-100 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"popover-header\"\n className={cn(\"aperture:flex aperture:flex-col aperture:gap-0.5 aperture:text-sm\", className)}\n {...props}\n />\n );\n}\n\nfunction PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {\n return (\n <PopoverPrimitive.Title\n data-slot=\"popover-title\"\n className={cn(\"aperture:font-medium\", className)}\n {...props}\n />\n );\n}\n\nfunction PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {\n return (\n <PopoverPrimitive.Description\n data-slot=\"popover-description\"\n className={cn(\"aperture:text-muted-foreground\", className)}\n {...props}\n />\n );\n}\n\nexport { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger };\n","import { useEffect, useState } from \"react\";\nimport { Bot, Hand, Hourglass, Radio } from \"lucide-react\";\nimport type { Member, Presence } from \"@aperture-browser/session-client\";\nimport { Avatar, AvatarBadge, AvatarFallback } from \"@aperture-browser/ui/components/avatar\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Popover,\n PopoverContent,\n PopoverTitle,\n PopoverTrigger,\n} from \"@aperture-browser/ui/components/popover\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useLease, useSession, useSessionSnapshot } from \"../session.tsx\";\n\nconst VISIBLE_MEMBERS = 5;\n\n/** The session gives a tab to whoever asked when its holder has not answered for this long. */\nconst ANSWER_WITHIN_SECONDS = 10;\n\nconst ROLES = { view: \"may watch\", control: \"may give input\", admin: \"admin\" } as const;\n\n/** Who is in the session, as the old workbench showed its collaborators. */\nexport function SessionPresence() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { presence } = snapshot;\n if (presence === undefined || presence.members.length === 0) {\n return null;\n }\n\n const holds = (member: Member) => presence.held.some((held) => held.holder === member.id);\n const members = presence.members.toSorted((left, right) => {\n if (left.id === presence.you) {\n return -1;\n }\n if (right.id === presence.you) {\n return 1;\n }\n if (holds(left) !== holds(right)) {\n return holds(left) ? -1 : 1;\n }\n return left.name.localeCompare(right.name);\n });\n const visible = members.slice(0, VISIBLE_MEMBERS);\n const overflow = members.length - visible.length;\n\n const button = (member: Member) => (\n <MemberButton key={member.id} member={member} presence={presence} onFollow={session.follow} />\n );\n\n return (\n <div\n data-session-presence=\"\"\n className=\"aperture:group aperture:flex aperture:shrink-0 aperture:items-center aperture:px-2\"\n aria-label=\"Members of the session\"\n >\n {overflow > 0 ? (\n <div className=\"aperture:relative\" style={{ zIndex: visible.length + 1 }}>\n <Popover>\n <PopoverTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"aperture:shrink-0 aperture:rounded-full aperture:border aperture:bg-background aperture:text-[0.65rem] aperture:text-muted-foreground\"\n aria-label={`${overflow} more members`}\n />\n }\n >\n +{overflow}\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"aperture:w-auto aperture:gap-2\">\n <PopoverTitle className=\"aperture:text-xs aperture:text-muted-foreground\">\n Everyone\n </PopoverTitle>\n <div className=\"aperture:flex aperture:max-w-64 aperture:flex-wrap aperture:items-center aperture:gap-1\">\n {members.map(button)}\n </div>\n </PopoverContent>\n </Popover>\n </div>\n ) : null}\n {visible.map((member, index) => (\n <div\n key={member.id}\n className={cn(\n \"aperture:relative aperture:transition-[margin] aperture:duration-200\",\n (index > 0 || overflow > 0) &&\n // A finger rests on nothing to spread them: there each stands whole.\n \"aperture:-ml-2 aperture:group-focus-within:ml-0 aperture:group-hover:ml-0 aperture:pointer-coarse:ml-0\",\n )}\n style={{ zIndex: visible.length - index }}\n >\n {button(member)}\n </div>\n ))}\n </div>\n );\n}\n\nfunction MemberButton({\n member,\n presence,\n onFollow,\n}: {\n member: Member;\n presence: Presence;\n onFollow: (member?: number) => void;\n}) {\n const you = member.id === presence.you;\n const followed = presence.members.find((one) => one.id === presence.you)?.follows === member.id;\n const follower = member.follows === presence.you;\n const held = presence.held.filter((one) => one.holder === member.id);\n\n const details = [\n you ? `${member.name} (you)` : member.name,\n member.agent ? \"automation\" : member.role === undefined ? undefined : ROLES[member.role],\n member.tab === undefined ? undefined : `watches tab ${member.tab}`,\n held.length === 0 ? undefined : `holds tab ${held.map((one) => one.tab).join(\", \")}`,\n follower ? \"follows you\" : undefined,\n followed ? \"you follow them · click to stop\" : undefined,\n !you && !followed ? \"click to follow them\" : undefined,\n ].filter((part) => part !== undefined);\n const label = details.join(\" · \");\n\n const trigger = you ? (\n <span\n className=\"aperture:inline-flex aperture:size-7 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full\"\n aria-label={label}\n />\n ) : (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n className={cn(\n \"aperture:shrink-0 aperture:rounded-full aperture:p-0\",\n followed && \"aperture:ring-2 aperture:ring-primary\",\n )}\n aria-label={label}\n aria-pressed={followed}\n data-member-follow={member.id}\n onClick={() => onFollow(followed ? undefined : member.id)}\n />\n );\n return (\n <Tooltip>\n <TooltipTrigger render={trigger}>\n <MemberAvatar member={member} holds={held.length > 0} />\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n\nexport function MemberAvatar({\n member,\n holds = false,\n className,\n}: {\n member: Member;\n /** The member holds the lease of a tab. */\n holds?: boolean;\n className?: string;\n}) {\n return (\n <Avatar\n size=\"sm\"\n className={cn(\"aperture:shrink-0 aperture:ring-2 aperture:ring-background\", className)}\n >\n <AvatarFallback\n className=\"aperture:text-[0.625rem] aperture:font-medium aperture:text-white\"\n style={{ backgroundColor: memberColor(member) }}\n >\n {member.agent ? <Bot className=\"aperture:size-3.5\" /> : initials(member.name)}\n </AvatarFallback>\n {holds ? (\n <AvatarBadge\n className=\"aperture:bg-emerald-500 aperture:group-data-[size=sm]/avatar:size-2.5\"\n title=\"Holds a tab's lease\"\n >\n <Radio />\n </AvatarBadge>\n ) : null}\n </Avatar>\n );\n}\n\n/** One member, as a mark on the tab they watch. */\nexport function MemberDot({ member, holds }: { member: Member; holds: boolean }) {\n return (\n <span\n className={cn(\n \"aperture:flex aperture:size-4 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:text-[0.5rem] aperture:leading-none aperture:font-semibold aperture:text-white aperture:ring-1 aperture:ring-background\",\n holds && \"aperture:ring-2 aperture:ring-emerald-500\",\n )}\n style={{ backgroundColor: memberColor(member) }}\n title={holds ? `${member.name} holds this tab` : `${member.name} watches this tab`}\n >\n {member.agent ? <Bot className=\"aperture:size-2.5\" /> : initials(member.name).slice(0, 1)}\n </span>\n );\n}\n\n/**\n * The lease of the watched tab, where it concerns this member: someone else holds the tab,\n * or someone asks this member for it. Laid over the picture, where input that does not\n * land is noticed.\n */\nexport function LeaseOverlay() {\n const session = useSession();\n const lease = useLease();\n const { state, holder, asker } = lease;\n\n if (state === \"asked-of-you\") {\n return (\n <LeaseRequest\n key={asker?.id}\n asker={asker}\n onAllow={() => session.lease(\"allow\")}\n onKeep={() => session.lease(\"keep\")}\n />\n );\n }\n\n if (state !== \"theirs\" && state !== \"theirs-asked\" && state !== \"you-asked\") {\n return null;\n }\n\n const name = holder?.agent ? automationName(holder) : (holder?.name ?? \"Someone\");\n // An admin's asking takes the tab, and so does a person's from the automation.\n const takes = lease.role === \"admin\" || holder?.agent === true;\n\n return (\n <div\n data-session-lease={state}\n role=\"status\"\n className=\"aperture:absolute aperture:top-2 aperture:left-1/2 aperture:z-30 aperture:flex aperture:max-w-[calc(100%-1rem)] aperture:-translate-x-1/2 aperture:items-center aperture:gap-2 aperture:rounded-full aperture:border aperture:bg-popover/95 aperture:py-1 aperture:pr-1 aperture:pl-1.5 aperture:text-xs aperture:text-popover-foreground aperture:shadow-md aperture:backdrop-blur\"\n >\n {holder === undefined ? null : <MemberAvatar member={holder} holds />}\n <span className=\"aperture:min-w-0 aperture:truncate\">\n <span className=\"aperture:font-medium\">{name}</span> holds this tab\n </span>\n {state === \"you-asked\" ? (\n <span className=\"aperture:flex aperture:h-6 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:rounded-full aperture:bg-muted aperture:px-2 aperture:text-muted-foreground\">\n <Hourglass className=\"aperture:size-3\" />\n Asked\n </span>\n ) : (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"secondary\"\n className=\"aperture:shrink-0 aperture:rounded-full\"\n disabled={state === \"theirs-asked\" && !takes}\n onClick={() => session.lease(\"take\")}\n >\n <Hand />\n {takes ? \"Take the lease\" : \"Ask for the lease\"}\n </Button>\n )}\n </div>\n );\n}\n\nfunction LeaseRequest({\n asker,\n onAllow,\n onKeep,\n}: {\n asker: Member | undefined;\n onAllow: () => void;\n onKeep: () => void;\n}) {\n const [left, setLeft] = useState(ANSWER_WITHIN_SECONDS);\n\n useEffect(() => {\n const timer = setInterval(() => setLeft((current) => Math.max(0, current - 1)), 1000);\n return () => clearInterval(timer);\n }, []);\n\n return (\n <div\n data-session-lease=\"asked-of-you\"\n role=\"alertdialog\"\n aria-label=\"Someone asks for this tab\"\n className=\"aperture:absolute aperture:top-3 aperture:left-1/2 aperture:z-40 aperture:w-88 aperture:max-w-[calc(100%-1rem)] aperture:-translate-x-1/2 aperture:animate-in aperture:overflow-hidden aperture:rounded-xl aperture:border aperture:border-amber-500/60 aperture:bg-popover aperture:text-popover-foreground aperture:shadow-xl aperture:ring-4 aperture:ring-amber-500/25 aperture:duration-200 aperture:fade-in-0 aperture:slide-in-from-top-4\"\n >\n <div className=\"aperture:flex aperture:items-start aperture:gap-3 aperture:p-3\">\n <span className=\"aperture:relative aperture:flex aperture:shrink-0\">\n <span className=\"aperture:absolute aperture:inset-0 aperture:animate-ping aperture:rounded-full aperture:bg-amber-500/50\" />\n {asker === undefined ? (\n <span className=\"aperture:flex aperture:size-6 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-amber-500 aperture:text-white\">\n <Hand className=\"aperture:size-3.5\" />\n </span>\n ) : (\n <MemberAvatar member={asker} className=\"aperture:ring-amber-500\" />\n )}\n </span>\n <div className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:gap-0.5\">\n <span className=\"aperture:text-sm aperture:font-medium\">\n {asker?.name ?? \"Someone\"} asks for this tab\n </span>\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">\n You hold its lease. It goes to them in{\" \"}\n <span className=\"aperture:font-medium aperture:text-foreground aperture:tabular-nums\">\n {left} s\n </span>{\" \"}\n unless you keep it.\n </span>\n </div>\n </div>\n <div className=\"aperture:flex aperture:items-center aperture:justify-end aperture:gap-2 aperture:border-t aperture:bg-muted/40 aperture:px-3 aperture:py-2\">\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={onKeep}>\n Keep\n </Button>\n <Button type=\"button\" size=\"sm\" onClick={onAllow}>\n Allow\n </Button>\n </div>\n <div\n className=\"aperture:h-0.5 aperture:bg-amber-500 aperture:transition-[width] aperture:duration-1000 aperture:ease-linear\"\n style={{ width: `${(left / ANSWER_WITHIN_SECONDS) * 100}%` }}\n />\n </div>\n );\n}\n\n/** What the automation is called when it acts for nobody: with the session's own token. */\nconst OWN_AUTOMATION = \"Agent\";\n\n/**\n * What the automation is called where it holds a tab or points at something: automation\n * as such, and whose it is where it acts for someone. `opens` where a sentence starts\n * with it.\n */\nexport function automationName(member: Member, opens = true): string {\n if (member.name !== OWN_AUTOMATION) {\n return `${member.name}'s automation`;\n }\n return opens ? \"Automation\" : \"automation\";\n}\n\n// None near the green that marks who holds a lease.\nconst MEMBER_HUES = [12, 38, 70, 200, 230, 260, 290, 320, 350];\n\nexport function memberColor(member: Member): string {\n if (member.agent) {\n return \"oklch(0.45 0.02 260)\";\n }\n let hash = 0;\n for (const letter of member.name) {\n hash = (hash * 31 + (letter.codePointAt(0) ?? 0)) % 9973;\n }\n return `oklch(0.55 0.15 ${MEMBER_HUES[hash % MEMBER_HUES.length]})`;\n}\n\nfunction initials(name: string): string {\n return name\n .split(/\\s+/u)\n .slice(0, 2)\n .map((part) => Array.from(part)[0]?.toUpperCase() ?? \"\")\n .join(\"\");\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport { Globe2, Paperclip, Plus, Volume2, VolumeX, X } from \"lucide-react\";\nimport type { Member, Presence, Target } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n ContextMenu,\n ContextMenuContent,\n ContextMenuTrigger,\n} from \"@aperture-browser/ui/components/context-menu\";\nimport {\n createHoverCardHandle,\n HoverCard,\n HoverCardContent,\n HoverCardTrigger,\n type HoverCardHandle,\n} from \"@aperture-browser/ui/components/hover-card\";\nimport { ScrollArea } from \"@aperture-browser/ui/components/scroll-area\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport { MemberDot } from \"./session-presence.tsx\";\n\nconst VISIBLE_WATCHERS = 3;\n\n/** One tab per target. Tabs keep the order the session tells them in: it has no other. */\nexport function BrowserTabStrip() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, recordings, targetFaviconUrl } = useWorkbench();\n const { open, changes } = useInputState();\n const showPresence = features.presence;\n const recordingTabs = new Set(\n recordings.recordings.filter(recordingRuns).map((recording) => recording.tab),\n );\n const [previewHandle] = useState(() => createHoverCardHandle<number>());\n const { targets, presence } = snapshot;\n\n const closePreview = () => {\n if (previewHandle.isOpen) {\n previewHandle.close();\n }\n };\n\n if (targets.length === 0) {\n return (\n <div\n data-browser-tab-strip=\"\"\n className=\"aperture:flex aperture:h-8 aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:gap-2 aperture:px-2 aperture:text-xs aperture:text-muted-foreground\"\n >\n <span>No tabs</span>\n <NewTabButton disabled={!changes} onCreate={() => session.newTab()} />\n </div>\n );\n }\n\n return (\n <>\n <ScrollArea\n data-browser-tab-strip=\"\"\n scrollbars=\"horizontal\"\n // A finger moves the tabs themselves: a bar over them would only cover them.\n className=\"aperture:h-8 aperture:min-w-0 aperture:flex-1 aperture:pointer-coarse:h-10 aperture:pointer-coarse:[&>[data-slot=scroll-area-scrollbar]]:hidden\"\n >\n <div\n data-browser-tab-strip-tabs=\"\"\n // Under a finger a tab is as tall as the strip: nothing of it is too small to press.\n className=\"aperture:flex aperture:min-w-max aperture:items-end aperture:gap-0.5 aperture:px-1 aperture:pt-1 aperture:pointer-coarse:pt-0\"\n >\n {targets.map((target) => (\n <BrowserTab\n key={target.tab}\n target={target}\n active={target.tab === snapshot.selected}\n recording={recordingTabs.has(target.tab)}\n asksForFiles={snapshot.fileRequests.some((request) => request.tab === target.tab)}\n presence={showPresence ? presence : undefined}\n faviconSrc={targetFaviconUrl(target)}\n disabled={!open}\n changes={changes}\n previewHandle={previewHandle}\n onPreviewClose={closePreview}\n />\n ))}\n <NewTabButton disabled={!changes} onCreate={() => session.newTab()} />\n </div>\n </ScrollArea>\n <HoverCard handle={previewHandle}>\n {({ payload }) => {\n const target = targets.find((current) => current.tab === payload);\n // The watched tab is in full view already.\n if (target === undefined || target.tab === snapshot.selected) {\n return null;\n }\n return <TabPreview target={target} />;\n }}\n </HoverCard>\n </>\n );\n}\n\nfunction BrowserTab({\n target,\n active,\n recording,\n asksForFiles,\n presence,\n faviconSrc,\n disabled,\n changes,\n previewHandle,\n onPreviewClose,\n}: {\n target: Target;\n active: boolean;\n recording: boolean;\n asksForFiles: boolean;\n presence: Presence | undefined;\n faviconSrc: string | undefined;\n disabled: boolean;\n /** This member may open and close tabs. */\n changes: boolean;\n previewHandle: HoverCardHandle<number>;\n onPreviewClose: () => void;\n}) {\n const session = useSession();\n const tabRef = useRef<HTMLDivElement>(null);\n const held = presence?.held.find((one) => one.tab === target.tab);\n\n // The watched tab is in sight, also when it was selected elsewhere or the strip is narrow.\n useEffect(() => {\n if (active) {\n tabRef.current?.scrollIntoView({ block: \"nearest\", inline: \"nearest\" });\n }\n }, [active]);\n const watchers =\n presence?.members.filter(\n (member) =>\n member.id !== presence.you && (member.tab === target.tab || member.id === held?.holder),\n ) ?? [];\n // Someone asks this member for the tab: the tab says so too, also while another is watched.\n const askedOfYou = held?.holder === presence?.you && held?.askedBy !== undefined;\n\n const tab = (\n <div\n ref={tabRef}\n data-browser-tab=\"\"\n data-tab={target.tab}\n data-active={active ? \"\" : undefined}\n className={cn(\n \"aperture:group aperture:relative aperture:flex aperture:h-7 aperture:pointer-coarse:h-10 aperture:w-52 aperture:max-w-[38vw] aperture:min-w-28 aperture:items-center aperture:gap-1.5 aperture:rounded-t-lg aperture:border aperture:border-b-0 aperture:px-2 aperture:text-left aperture:text-xs aperture:transition-[background-color,border-color,color] aperture:select-none\",\n active\n ? \"aperture:border-border aperture:bg-background aperture:text-foreground\"\n : \"aperture:border-transparent aperture:bg-muted/55 aperture:text-muted-foreground aperture:hover:bg-muted\",\n )}\n onMouseDown={(event) => {\n // A middle click closes the tab and does not start the browser's scrolling.\n if (event.button === 1) {\n event.preventDefault();\n }\n }}\n onAuxClick={(event) => {\n if (event.button === 1 && changes) {\n event.preventDefault();\n session.closeTab(target.tab);\n }\n }}\n />\n );\n\n return (\n <ContextMenu>\n <ContextMenuTrigger\n render={\n <HoverCardTrigger\n handle={previewHandle}\n payload={target.tab}\n delay={0}\n // Long enough to reach the next tab, which then takes the preview over.\n closeDelay={80}\n render={tab}\n />\n }\n >\n <button\n type=\"button\"\n aria-current={active ? \"page\" : undefined}\n disabled={disabled}\n className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:gap-1.5 aperture:self-stretch aperture:text-left aperture:outline-none\"\n onClick={() => {\n onPreviewClose();\n session.select(target.tab);\n }}\n >\n <TabFavicon src={faviconSrc} />\n {recording ? (\n <>\n <span\n aria-hidden\n className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-destructive\"\n />\n <span className=\"aperture:sr-only\">Being recorded</span>\n </>\n ) : null}\n {asksForFiles ? (\n <>\n <Paperclip\n aria-hidden\n className=\"aperture:size-3.5 aperture:shrink-0 aperture:text-amber-600 aperture:dark:text-amber-400\"\n />\n <span className=\"aperture:sr-only\">Asks for files</span>\n </>\n ) : null}\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {tabLabel(target)}\n </span>\n </button>\n {askedOfYou ? (\n <span\n title=\"Someone asks you for this tab\"\n className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-amber-500\"\n />\n ) : null}\n <TabSoundButton target={target} />\n {watchers.length > 0 ? <TabWatchers watchers={watchers} holder={held?.holder} /> : null}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n // Small among the tabs, and pressed around it as well where a finger points.\n data-touch-dense=\"\"\n className=\"aperture:relative aperture:-mr-1 aperture:size-5 aperture:shrink-0 aperture:opacity-55 aperture:group-hover:opacity-100 aperture:hover:opacity-100 aperture:pointer-coarse:opacity-100 aperture:pointer-coarse:after:absolute aperture:pointer-coarse:after:-inset-2.5\"\n aria-label=\"Close tab\"\n disabled={!changes}\n onClick={() => session.closeTab(target.tab)}\n >\n <X />\n </Button>\n </ContextMenuTrigger>\n <ContextMenuContent className=\"aperture:min-w-48\">\n <WorkbenchMenuSlot name=\"menu.tab\" kind=\"context\" target={target} />\n </ContextMenuContent>\n </ContextMenu>\n );\n}\n\nfunction TabWatchers({\n watchers,\n holder,\n}: {\n watchers: readonly Member[];\n holder: number | undefined;\n}) {\n // The holder first: who drives the tab matters more than who watches it.\n const ordered = watchers.toSorted(\n (left, right) => Number(right.id === holder) - Number(left.id === holder),\n );\n const visible = ordered.slice(0, VISIBLE_WATCHERS);\n const overflow = ordered.length - visible.length;\n\n return (\n <span\n data-browser-tab-watchers=\"\"\n className=\"aperture:flex aperture:shrink-0 aperture:-space-x-1\"\n >\n {visible.map((member) => (\n <MemberDot key={member.id} member={member} holds={member.id === holder} />\n ))}\n {overflow > 0 ? (\n <span className=\"aperture:flex aperture:h-4 aperture:items-center aperture:rounded-full aperture:bg-muted aperture:px-1 aperture:text-[0.5rem] aperture:ring-1 aperture:ring-background\">\n +{overflow}\n </span>\n ) : null}\n </span>\n );\n}\n\nfunction NewTabButton({ disabled, onCreate }: { disabled: boolean; onCreate: () => void }) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n className=\"aperture:mb-px aperture:shrink-0\"\n aria-label=\"New tab\"\n disabled={disabled}\n onClick={onCreate}\n />\n }\n >\n <Plus />\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">New tab</TooltipContent>\n </Tooltip>\n );\n}\n\nexport function TabFavicon({ src }: { src: string | undefined }) {\n const [failedSrc, setFailedSrc] = useState<string | undefined>(undefined);\n\n if (src === undefined || failedSrc === src) {\n return (\n <Globe2 className=\"aperture:size-3.5 aperture:shrink-0 aperture:text-muted-foreground\" />\n );\n }\n\n return (\n <img\n src={src}\n alt=\"\"\n // A page draws its icon for a light tab or for a dark one, and is shown on either.\n className=\"aperture:size-4 aperture:shrink-0 aperture:rounded-[3px] aperture:dark:bg-white/85 aperture:dark:ring-1 aperture:dark:ring-white/85\"\n onError={() => setFailedSrc(src)}\n />\n );\n}\n\nexport function tabLabel(target: Target): string {\n return target.title.trim() === \"\" ? simplifyUrl(target.url) : target.title;\n}\n\nfunction simplifyUrl(url: string): string {\n if (url === \"\" || url === \"about:blank\") {\n return \"about:blank\";\n }\n try {\n const parsed = new URL(url);\n return `${parsed.host}${parsed.pathname === \"/\" ? \"\" : parsed.pathname}`;\n } catch {\n return url;\n }\n}\n\n/** Tells that a tab sounds, and mutes it for this client; shown for a muted tab too. */\nfunction TabSoundButton({ target }: { target: Target }) {\n const { features } = useWorkbench();\n const sound = useTabSound(target);\n\n if (!features.sound || (!sound.sounds && !sound.muted)) {\n return null;\n }\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n className=\"aperture:size-5 aperture:shrink-0\"\n aria-label={sound.muted ? \"Unmute tab\" : \"Mute tab\"}\n aria-pressed={sound.muted}\n data-browser-tab-sound={sound.muted ? \"muted\" : \"sounds\"}\n onClick={sound.toggle}\n >\n {sound.muted ? <VolumeX /> : <Volume2 />}\n </Button>\n );\n}\n\n/** How wide a tab's preview is asked for: twice the popup's width, for sharp screens. */\nconst PREVIEW_WIDTH = 640;\n\n/** The preview each tab was last shown with, which is there at once the next time. */\nconst lastPreviews = new Map<number, string>();\n\n/**\n * A tab's preview. One popup serves every tab: it fades in for the first one the pointer\n * is over, and moves along to the next.\n */\nfunction TabPreview({ target }: { target: Target }) {\n // The popup is put in its place when it opens, and moves only from there on: a move\n // from where it was before it had a place is not one to show.\n const [placed, setPlaced] = useState(false);\n useEffect(() => {\n let frame = requestAnimationFrame(() => {\n frame = requestAnimationFrame(() => setPlaced(true));\n });\n return () => cancelAnimationFrame(frame);\n }, []);\n\n return (\n <HoverCardContent\n data-browser-tab-preview=\"\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={16}\n positionerClassName={cn(\n \"aperture:pointer-events-none\",\n placed &&\n \"aperture:transition-[top,left,right,bottom,transform] aperture:duration-200 aperture:ease-out\",\n )}\n className=\"aperture:pointer-events-none aperture:flex aperture:w-80 aperture:max-w-[calc(100vw-2rem)] aperture:flex-col aperture:gap-2 aperture:p-2 aperture:transition-opacity aperture:duration-150 aperture:data-ending-style:opacity-0 aperture:data-starting-style:opacity-0\"\n >\n <TabPreviewPicture key={target.tab} target={target} />\n <span className=\"aperture:truncate aperture:text-xs aperture:font-medium\">\n {tabLabel(target)}\n </span>\n <span className=\"aperture:truncate aperture:font-mono aperture:text-xs aperture:text-muted-foreground\">\n {target.url || \"about:blank\"}\n </span>\n </HoverCardContent>\n );\n}\n\nfunction TabPreviewPicture({ target }: { target: Target }) {\n const session = useSession();\n // Made when the tab's preview shows, so it is the page as it is then and not a picture\n // the browser kept.\n const [src] = useState(() => {\n const url = new URL(session.screenshotUrl(target.tab, PREVIEW_WIDTH));\n url.searchParams.set(\"at\", String(Date.now()));\n return url.toString();\n });\n const [before] = useState(() => lastPreviews.get(target.tab));\n const [loaded, setLoaded] = useState(false);\n return (\n <div\n className=\"aperture:aspect-video aperture:w-full aperture:overflow-hidden aperture:rounded-md aperture:bg-muted aperture:bg-cover aperture:bg-top\"\n // What the tab looked like the last time, until it is known what it looks like now.\n style={before === undefined ? undefined : { backgroundImage: `url(\"${before}\")` }}\n >\n <img\n src={src}\n alt=\"\"\n onLoad={() => {\n lastPreviews.set(target.tab, src);\n setLoaded(true);\n }}\n className={cn(\n \"aperture:size-full aperture:object-cover aperture:object-top aperture:transition-opacity aperture:duration-150\",\n loaded ? \"aperture:opacity-100\" : \"aperture:opacity-0\",\n )}\n />\n </div>\n );\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n type ComponentProps,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { ArrowLeft, ArrowRight, Check, Layers2, Loader2, Plus, RefreshCw, X } from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { InputGroup, InputGroupInput } from \"@aperture-browser/ui/components/input-group\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useAddress } from \"../hooks/use-address.ts\";\nimport { useFinger, useShortWindow } from \"../hooks/use-media.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { BrowserTabStrip } from \"./browser-tab-strip.tsx\";\nimport { SessionPresence } from \"./session-presence.tsx\";\n\n/** The workbench's first row: the tab strip, and who is in the session. */\nexport function WorkbenchTitlebar() {\n const { features, contributions } = useWorkbench();\n const open = useSessionSnapshot().connection.state === \"open\";\n const contributed = contributions.some((one) => one.slot.startsWith(\"titlebar.\"));\n const short = useShortWindow();\n\n // A window too short for two rows has what is here in the toolbar.\n if (short || (!features.tabs && !features.presence && !contributed)) {\n return null;\n }\n return (\n <div\n data-workbench-titlebar=\"\"\n className=\"aperture:flex aperture:h-8 aperture:min-w-0 aperture:shrink-0 aperture:items-stretch aperture:border-b aperture:bg-muted/35 aperture:pointer-coarse:h-10\"\n >\n <WorkbenchSlot name=\"titlebar.start\" />\n {features.tabs ? <BrowserTabStrip /> : <div className=\"aperture:min-w-0 aperture:flex-1\" />}\n {/* Who was here when a connection closed is not who is here now. */}\n {features.presence && open ? <SessionPresence /> : null}\n <WorkbenchSlot name=\"titlebar.end\" />\n </div>\n );\n}\n\nexport const CompactContext = createContext(false);\n\n/** Whether the toolbar is narrow: what has a place in the browser menu shows there alone. */\nexport function useCompactToolbar(): boolean {\n return useContext(CompactContext);\n}\n\n/**\n * Whether the toolbar is narrow under a finger, whose buttons are larger: then only going\n * back, the keyboard and the files keep a button, and the rest is in the browser menu.\n */\nexport function useCrowdedToolbar(): boolean {\n return useFinger() && useContext(CompactContext);\n}\n\n/** Below this width the toolbar keeps the address bar its room by showing fewer buttons. */\nconst COMPACT_BELOW = 520;\n\n/**\n * The workbench's second row: navigation, the address, and the buttons at its end. Without\n * children it is the usual arrangement of its parts.\n */\nexport function WorkbenchToolbar({ children }: { readonly children?: ReactNode }) {\n const toolbarRef = useRef<HTMLDivElement>(null);\n const compact = useNarrowerThan(toolbarRef, COMPACT_BELOW);\n const { features, contributions } = useWorkbench();\n const open = useSessionSnapshot().connection.state === \"open\";\n const connecting = useSessionSnapshot().connection.state === \"connecting\";\n const short = useShortWindow();\n const shows =\n children !== undefined ||\n features.navigation ||\n features.addressBar ||\n features.menus ||\n short ||\n contributions.some((one) => one.slot === \"toolbar.start\" || one.slot === \"toolbar.end\");\n\n if (!shows) {\n return null;\n }\n return (\n <CompactContext.Provider value={compact}>\n <div\n ref={toolbarRef}\n data-workbench-toolbar=\"\"\n data-compact={compact ? \"\" : undefined}\n data-short={short ? \"\" : undefined}\n className=\"aperture:flex aperture:h-9 aperture:min-w-0 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:border-b aperture:bg-background aperture:px-1.5 aperture:pointer-coarse:h-11 aperture:data-short:pl-0\"\n >\n {children ?? (\n <>\n {short ? <WorkbenchSlot name=\"titlebar.start\" /> : null}\n {short && features.tabs ? <TabsMenu /> : null}\n <WorkbenchSlot name=\"toolbar.start\" />\n {features.navigation ? <NavigationButtons /> : null}\n {features.addressBar ? (\n <AddressBar />\n ) : (\n <div className=\"aperture:min-w-0 aperture:flex-1\" />\n )}\n {connecting ? (\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n ) : null}\n <WorkbenchSlot name=\"toolbar.end\" />\n {short && features.presence && open ? <SessionPresence /> : null}\n {short ? <WorkbenchSlot name=\"titlebar.end\" /> : null}\n {features.menus ? <ToolbarActions /> : null}\n </>\n )}\n </div>\n </CompactContext.Provider>\n );\n}\n\n/** Back, forward and reload of the watched tab. */\nexport function NavigationButtons() {\n const session = useSession();\n const input = useInputState();\n const snapshot = useSessionSnapshot();\n // Where a tab goes is no input to its page: it takes no lease.\n const gives = input.changes && snapshot.selected !== undefined;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const crowded = useCrowdedToolbar();\n\n return (\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center aperture:gap-0.5\">\n <ToolbarButton\n label=\"Back\"\n disabled={!gives || watched?.goesBack !== true}\n onClick={() => session.go({ along: \"back\" })}\n >\n <ArrowLeft />\n </ToolbarButton>\n {crowded ? null : (\n <>\n <ToolbarButton\n label=\"Forward\"\n disabled={!gives || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n </ToolbarButton>\n <ToolbarButton\n label=\"Reload\"\n disabled={!gives}\n onClick={() => session.go({ along: \"reload\" })}\n >\n <RefreshCw />\n </ToolbarButton>\n </>\n )}\n </div>\n );\n}\n\n/** The watched tab's address, and the field to take it elsewhere. */\nexport function AddressBar() {\n const session = useSession();\n const address = useAddress();\n\n return (\n <InputGroup className=\"aperture:h-7 aperture:min-w-0 aperture:pointer-coarse:h-10 aperture:border-transparent aperture:bg-transparent aperture:transition-colors aperture:hover:border-input/50 aperture:hover:bg-muted/35 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-input/70 aperture:has-[[data-slot=input-group-control]:focus-visible]:bg-background aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-2 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/20 aperture:dark:hover:bg-input/20\">\n <InputGroupInput\n data-workbench-address=\"\"\n aria-label=\"Address\"\n value={address.value}\n onChange={(event) => address.type(event.target.value)}\n onFocus={(event) => event.currentTarget.select()}\n onBlur={address.reset}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (address.submit(event.currentTarget.value)) {\n // The page is what the keyboard is for once it is on its way.\n session.focus();\n }\n }\n if (event.key === \"Escape\") {\n address.reset();\n event.currentTarget.blur();\n }\n }}\n placeholder=\"URL\"\n inputMode=\"url\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n // A phone zooms into a field whose text is smaller than this.\n className=\"aperture:h-7 aperture:px-2 aperture:font-mono aperture:text-xs aperture:text-muted-foreground aperture:transition-colors aperture:focus-visible:text-foreground aperture:pointer-coarse:h-10 aperture:pointer-coarse:text-base\"\n disabled={!address.navigates}\n />\n </InputGroup>\n );\n}\n\n/**\n * The tabs as a menu, for a window too short to keep a row of them: which is watched, the\n * way to another, to close one and to open a new one.\n */\nfunction TabsMenu() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { changes } = useInputState();\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Tabs\"\n data-workbench-tabs-menu=\"\"\n className=\"aperture:shrink-0 aperture:tabular-nums\"\n />\n }\n >\n <Layers2 />\n {snapshot.targets.length}\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" className=\"aperture:w-72\">\n {snapshot.targets.map((target) => (\n <div key={target.tab} className=\"aperture:flex aperture:items-center\">\n <DropdownMenuItem\n className=\"aperture:min-w-0 aperture:flex-1\"\n onClick={() => session.select(target.tab)}\n >\n <Check\n className={target.tab === snapshot.selected ? undefined : \"aperture:invisible\"}\n />\n <span className=\"aperture:truncate\">{target.title || target.url || \"New tab\"}</span>\n </DropdownMenuItem>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={`Close ${target.title || \"tab\"}`}\n disabled={!changes}\n onClick={() => session.closeTab(target.tab)}\n >\n <X />\n </Button>\n </div>\n ))}\n {snapshot.targets.length > 0 ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem disabled={!changes} onClick={() => session.newTab()}>\n <Plus />\n New tab\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** The buttons at the toolbar's end, which are what is contributed to `toolbar.actions`. */\nexport function ToolbarActions() {\n return (\n <div\n data-workbench-menus=\"\"\n className=\"aperture:flex aperture:shrink-0 aperture:items-center aperture:gap-0.5\"\n >\n <WorkbenchSlot name=\"toolbar.actions\" />\n </div>\n );\n}\n\nfunction useNarrowerThan(ref: RefObject<HTMLElement | null>, width: number): boolean {\n const [narrower, setNarrower] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return undefined;\n }\n const measure = () => setNarrower(element.clientWidth < width);\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => sizes.disconnect();\n }, [ref, width]);\n\n return narrower;\n}\n\n/** A button of the toolbar, with its name as a tooltip. */\nexport function ToolbarButton({\n label,\n disabled,\n onClick,\n children,\n ...props\n}: {\n label: string;\n disabled?: boolean;\n onClick?: () => void;\n children: ReactNode;\n} & Omit<ComponentProps<typeof Button>, \"children\" | \"onClick\" | \"disabled\">) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={label}\n disabled={disabled}\n onClick={onClick}\n {...props}\n />\n }\n >\n {children}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n","import {\n ArrowRight,\n Circle,\n ClipboardPaste,\n Copy,\n Eye,\n Hand,\n Hourglass,\n Keyboard,\n Link2,\n Monitor,\n MoreVertical,\n Pencil,\n RefreshCw,\n RotateCcw,\n SunMoon,\n TextSelect,\n Undo2,\n Volume2,\n VolumeX,\n} from \"lucide-react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { copyTextHere, pasteHere } from \"../notices.ts\";\nimport {\n useLease,\n useReconnect,\n useSession,\n useSessionSnapshot,\n useWatchedTarget,\n} from \"../session.tsx\";\nimport type { ApertureTheme } from \"../ui-root.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport { ToolbarButton, useCompactToolbar, useCrowdedToolbar } from \"./browser-toolbar.tsx\";\nimport { MenuButton } from \"./menu-parts.tsx\";\nimport { automationName } from \"./session-presence.tsx\";\n\nconst THEMES: Readonly<Record<ApertureTheme, string>> = {\n system: \"As the system\",\n light: \"Light\",\n dark: \"Dark\",\n};\n\n/**\n * A toolbar's menu opens below it and stays there: where the window is short it scrolls\n * in the room there is, and never turns up over the toolbar it was opened from.\n */\nconst BELOW = { side: \"none\", align: \"shift\" } as const;\n\nconst isTheme = (value: unknown): value is ApertureTheme =>\n typeof value === \"string\" && value in THEMES;\n\n/** Brings up a phone's keyboard, which comes only for a field that is focused in a tap. */\nexport function KeyboardAction() {\n const session = useSession();\n const { gives } = useInputState();\n return (\n <ToolbarButton\n label=\"Type into the session\"\n className=\"aperture:hidden aperture:any-pointer-coarse:inline-flex\"\n disabled={!gives}\n onClick={() => session.focus()}\n >\n <Keyboard />\n </ToolbarButton>\n );\n}\n\n/** Draws over the picture for the others to see, instead of giving it input. */\nexport function DrawAction() {\n const { features, drawing, setDrawing } = useWorkbench();\n const members = useSessionSnapshot().presence?.members.length ?? 0;\n\n // Nobody to draw for but oneself.\n if (!features.presence || (members < 2 && !drawing)) {\n return null;\n }\n return (\n <ToolbarButton\n label={drawing ? \"Stop drawing\" : \"Draw over the page for the others\"}\n variant={drawing ? \"secondary\" : \"ghost\"}\n aria-pressed={drawing}\n data-workbench-draw=\"\"\n onClick={() => setDrawing(!drawing)}\n >\n <Pencil />\n </ToolbarButton>\n );\n}\n\n/** The recording menu, from a button that tells when a recording runs. */\nexport function RecordingAction() {\n const { features, recordings } = useWorkbench();\n const compact = useCompactToolbar();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings || compact) {\n return null;\n }\n return (\n <DropdownMenu>\n <MenuButton\n label={active ? \"Recording in progress\" : \"Recording\"}\n variant={active ? \"destructive\" : \"ghost\"}\n data-workbench-recording=\"\"\n >\n <Circle fill={active ? \"currentColor\" : \"none\"} />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-72\">\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** How the picture comes, and the watched tab's viewport. */\nexport function PictureAction() {\n if (useCrowdedToolbar()) {\n return null;\n }\n return (\n <DropdownMenu>\n <MenuButton label=\"Picture and viewport\" data-workbench-picture=\"\">\n <Monitor />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-64\">\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** The menu with the lease, the clipboard and the rest. */\nexport function BrowserMenuAction() {\n return (\n <DropdownMenu>\n <MenuButton label=\"Browser menu\" data-workbench-menu=\"\">\n <MoreVertical />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-60\">\n <WorkbenchMenuSlot name=\"menu.browser\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n// The keyboard goes back to the session once the menu has closed and given focus back.\nfunction useThenFocus() {\n const session = useSession();\n return (act: () => void) => () => {\n act();\n requestAnimationFrame(() => session.focus());\n };\n}\n\nexport function CopyItem() {\n const session = useSession();\n const { features } = useWorkbench();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n\n if (!features.access.clipboard.read) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(session.copySelection)}>\n <Copy />\n Copy from the session\n </DropdownMenuItem>\n );\n}\n\nexport function PasteItem() {\n const session = useSession();\n const { features } = useWorkbench();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n\n if (!features.access.clipboard.write) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(() => pasteHere(session))}>\n <ClipboardPaste />\n Paste into the session\n </DropdownMenuItem>\n );\n}\n\nexport function SelectAllItem() {\n const session = useSession();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(session.selectAll)}>\n <TextSelect />\n Select all\n </DropdownMenuItem>\n );\n}\n\nexport function TypeItem() {\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n return (\n <DropdownMenuItem\n // Where a finger points, the toolbar has a button for it.\n className=\"aperture:any-pointer-coarse:hidden\"\n disabled={!gives}\n onClick={thenFocus(() => undefined)}\n >\n <Keyboard />\n Type into the session\n </DropdownMenuItem>\n );\n}\n\n/** Mutes the watched tab for this client, or lets it be heard again. */\nexport function MuteItem() {\n const { features } = useWorkbench();\n const watched = useWatchedTarget();\n const sound = useTabSound(watched);\n\n if (!features.sound) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={watched === undefined} onClick={sound.toggle}>\n {sound.muted ? <Volume2 /> : <VolumeX />}\n {sound.muted ? \"Unmute the tab\" : \"Mute the tab\"}\n </DropdownMenuItem>\n );\n}\n\n/** The recording menu inside the browser menu, where the toolbar has no room for its button. */\nexport function RecordingSubmenuItem() {\n const { features, recordings } = useWorkbench();\n const compact = useCompactToolbar();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings || !compact) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Circle\n fill={active ? \"currentColor\" : \"none\"}\n className={active ? \"aperture:text-destructive\" : undefined}\n />\n Recording\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-72\">\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** The picture menu inside the browser menu, where the toolbar has no room for its button. */\nexport function PictureSubmenuItem() {\n if (!useCrowdedToolbar()) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Monitor />\n Picture and viewport\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** Forward and reload inside the browser menu, where the toolbar keeps only the way back. */\nexport function NavigationItems() {\n const session = useSession();\n const { features } = useWorkbench();\n const input = useInputState();\n const watched = useWatchedTarget();\n const gives = input.changes && watched !== undefined;\n\n if (!useCrowdedToolbar() || !features.navigation) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem\n disabled={!gives || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem disabled={!gives} onClick={() => session.go({ along: \"reload\" })}>\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n );\n}\n\nexport function CopyUrlItem() {\n const session = useSession();\n const watched = useWatchedTarget();\n return (\n <DropdownMenuItem\n disabled={watched === undefined}\n onClick={() => {\n if (watched !== undefined) {\n copyTextHere(session, watched.url, \"URL copied\");\n }\n }}\n >\n <Link2 />\n Copy the tab's URL\n </DropdownMenuItem>\n );\n}\n\nexport function AppearanceItem() {\n const { appearance } = useWorkbench();\n\n if (appearance === undefined) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <SunMoon />\n Appearance\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-44\">\n <DropdownMenuRadioGroup\n aria-label=\"Appearance\"\n value={appearance.theme}\n onValueChange={(value) => {\n if (isTheme(value)) {\n appearance.onThemeChange(value);\n }\n }}\n >\n {Object.entries(THEMES).map(([theme, label]) => (\n <DropdownMenuRadioItem key={theme} value={theme} closeOnClick={false}>\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nexport function ReconnectItem() {\n const reconnect = useReconnect();\n\n if (reconnect === undefined) {\n return null;\n }\n return (\n <DropdownMenuItem onClick={() => reconnect()}>\n <RotateCcw />\n Reconnect\n </DropdownMenuItem>\n );\n}\n\n/** What this member may do about the lease of the watched tab. */\nexport function LeaseItems() {\n const { features } = useWorkbench();\n const session = useSession();\n const lease = useLease();\n const snapshot = useSessionSnapshot();\n const watches = snapshot.connection.state === \"open\" && snapshot.selected !== undefined;\n const holder =\n lease.holder?.agent === true\n ? automationName(lease.holder, false)\n : (lease.holder?.name ?? \"someone\");\n\n if (!features.presence) {\n return null;\n }\n switch (lease.state) {\n case \"view-only\": {\n return (\n <DropdownMenuItem disabled>\n <Eye />\n View only\n </DropdownMenuItem>\n );\n }\n case \"free\": {\n return (\n <DropdownMenuItem disabled={!watches} onClick={() => session.lease(\"take\")}>\n <Hand />\n Take the lease\n </DropdownMenuItem>\n );\n }\n case \"yours\": {\n return (\n <DropdownMenuItem onClick={() => session.lease(\"release\")}>\n <Undo2 />\n Release the lease\n </DropdownMenuItem>\n );\n }\n case \"asked-of-you\": {\n return (\n <>\n <DropdownMenuItem onClick={() => session.lease(\"allow\")}>\n <Undo2 />\n Allow {lease.asker?.name ?? \"them\"} the lease\n </DropdownMenuItem>\n <DropdownMenuItem onClick={() => session.lease(\"keep\")}>\n <Hand />\n Keep the lease\n </DropdownMenuItem>\n </>\n );\n }\n case \"you-asked\": {\n return (\n <DropdownMenuItem disabled>\n <Hourglass />\n Asked {holder} for the lease\n </DropdownMenuItem>\n );\n }\n case \"theirs\":\n case \"theirs-asked\": {\n const takes = lease.role === \"admin\" || lease.holder?.agent === true;\n return (\n <DropdownMenuItem\n disabled={lease.state === \"theirs-asked\" && !takes}\n onClick={() => session.lease(\"take\")}\n >\n <Hand />\n {takes ? `Take the lease from ${holder}` : `Ask ${holder} for the lease`}\n </DropdownMenuItem>\n );\n }\n }\n}\n","import { createContext, useContext, type RefObject } from \"react\";\nimport {\n ArrowRight,\n Circle,\n ClipboardList,\n Eye,\n FolderOpen,\n Keyboard,\n Link2,\n Monitor,\n MoreHorizontal,\n Pencil,\n Plus,\n RefreshCw,\n} from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport type { DrawerSide } from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { copyTextHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport type { useSessionFiles } from \"./session-files.tsx\";\nimport {\n AppearanceItem,\n CopyItem,\n MuteItem,\n PasteItem,\n SelectAllItem,\n} from \"./toolbar-actions.tsx\";\n\n/** What the phone's menu and what is contributed to it share with the bar it is opened from. */\nexport interface PhoneMenuState {\n /** Where the keyboard goes once the menu has closed, where an entry said so. */\n readonly typed: RefObject<HTMLElement | null>;\n /** Puts the bar away, as scrolling down the page does. */\n readonly hideBar: () => void;\n readonly files: ReturnType<typeof useSessionFiles>;\n /** The edge of the window the bar's sheets come in from. */\n readonly side: DrawerSide;\n}\n\nexport const PhoneMenuContext = createContext<PhoneMenuState | null>(null);\n\nfunction usePhoneMenu(): PhoneMenuState {\n const value = useContext(PhoneMenuContext);\n if (value === null) {\n throw new Error(\"A phone menu's entry is used outside the phone's workbench\");\n }\n return value;\n}\n\n/** One of the row of things done most, below the menu's rows: its icon over its name. */\nconst QUICK =\n \"aperture:min-h-14 aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:justify-center aperture:gap-1 aperture:rounded-xl aperture:bg-muted/60 aperture:px-1 aperture:text-xs\";\n\n/**\n * The phone's menu: a sheet with what is contributed to `menu.phone`, whose submenus are\n * pages of it, and below that, nearest the thumb, what is done most as a row of buttons.\n * It opens low at the window's foot and is dragged up for the rest; where the phone is\n * held on its side it comes in from the bar's side, as tall as the window.\n */\nexport function PhoneMenu({\n open,\n onOpenChange,\n className,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n className?: string | undefined;\n}) {\n const session = useSession();\n const { features, recordings } = useWorkbench();\n const { changes } = useInputState();\n const watched = useWatchedTarget();\n const { typed, files, side } = usePhoneMenu();\n const goes = changes && watched !== undefined;\n const recording = recordings.recordings.some(recordingRuns);\n\n return (\n <DropdownMenu\n sheet={side}\n open={open}\n onOpenChange={(next) => {\n if (next) {\n typed.current = null;\n }\n onOpenChange(next);\n }}\n >\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n aria-label=\"Menu\"\n data-workbench-menu=\"\"\n className={cn(\"aperture:relative\", className)}\n />\n }\n >\n <MoreHorizontal />\n {files.request !== undefined || recording ? (\n <span\n className={cn(\n \"aperture:absolute aperture:top-1.5 aperture:right-1.5 aperture:size-2 aperture:rounded-full aperture:ring-2 aperture:ring-background\",\n files.request === undefined\n ? \"aperture:bg-destructive\"\n : \"aperture:animate-pulse aperture:bg-amber-500\",\n )}\n />\n ) : null}\n </DropdownMenuTrigger>\n <DropdownMenuContent\n finalFocus={() => typed.current ?? true}\n data-workbench-phone-menu=\"\"\n footer={\n <DropdownMenuGroup\n className={cn(\n \"aperture:flex aperture:shrink-0 aperture:gap-2 aperture:border-t aperture:border-foreground/8 aperture:px-[max(0.5rem,env(safe-area-inset-left))] aperture:pt-2 aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))]\",\n side === \"left\" && \"aperture:pl-2\",\n side === \"right\" && \"aperture:pr-2\",\n )}\n >\n {features.navigation ? (\n <>\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-forward=\"\"\n disabled={!goes || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-reload=\"\"\n disabled={!goes}\n onClick={() => session.go({ along: \"reload\" })}\n >\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n ) : null}\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-copy-url=\"\"\n disabled={watched === undefined}\n onClick={() => {\n if (watched !== undefined) {\n copyTextHere(session, watched.url, \"URL copied\");\n }\n }}\n >\n <Link2 />\n Copy URL\n </DropdownMenuItem>\n {features.tabs ? (\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-new-tab=\"\"\n disabled={!changes}\n onClick={() => session.newTab()}\n >\n <Plus />\n New tab\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuGroup>\n }\n >\n <WorkbenchMenuSlot name=\"menu.phone\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** Brings up the phone's keyboard for the session, and puts the bar out of its way. */\nexport function PhoneTypeItem() {\n const session = useSession();\n const { gives } = useInputState();\n const { typed, hideBar } = usePhoneMenu();\n return (\n <DropdownMenuItem\n disabled={!gives}\n data-workbench-keyboard=\"\"\n onClick={(event) => {\n const workbench = event.currentTarget.ownerDocument.querySelector(\"[data-workbench-phone]\");\n typed.current =\n workbench?.querySelector<HTMLElement>(\"[data-aperture-surface=keys]\") ?? null;\n // Within the tap: a phone's keyboard comes for nothing later.\n session.focus();\n hideBar();\n }}\n >\n <Keyboard />\n Type into the session\n </DropdownMenuItem>\n );\n}\n\n/** What is copied out of the session and pasted into it. */\nexport function PhoneClipboardItem() {\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"clipboard\">\n <ClipboardList />\n Clipboard\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <CopyItem />\n <PasteItem />\n <SelectAllItem />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nexport function PhoneDrawItem() {\n const { features, drawing, setDrawing } = useWorkbench();\n const members = useSessionSnapshot().presence?.members.length ?? 0;\n\n // Nobody to draw for but oneself.\n if (!features.presence || (members < 2 && !drawing)) {\n return null;\n }\n return (\n <DropdownMenuItem data-workbench-draw=\"\" onClick={() => setDrawing(!drawing)}>\n <Pencil />\n {drawing ? \"Stop drawing\" : \"Draw over the page for the others\"}\n </DropdownMenuItem>\n );\n}\n\nexport function PhoneFilesItem() {\n const { features } = useWorkbench();\n const { files } = usePhoneMenu();\n\n if (!features.files) {\n return null;\n }\n return (\n <DropdownMenuItem data-session-files-button=\"\" onClick={() => files.setOpen(true)}>\n <FolderOpen />\n {files.label}\n </DropdownMenuItem>\n );\n}\n\nexport function PhoneRecordingItem() {\n const { features, recordings } = useWorkbench();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"recording\">\n <Circle\n fill={active ? \"currentColor\" : \"none\"}\n className={active ? \"aperture:text-destructive\" : undefined}\n />\n Recording\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** How the session is shown here: the picture, the sound and the theme. */\nexport function PhoneViewItem() {\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"view\">\n <Eye />\n View\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"picture\">\n <Monitor />\n Picture and viewport\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <MuteItem />\n <AppearanceItem />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n","import { useStored } from \"./use-stored.ts\";\n\nconst POINTERS_KEY = \"aperture.session.pointers\";\n\nconst isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\n/**\n * Whether the other members' pointers are shown over the picture, which they are unless\n * this browser was told otherwise. What this member's own pointer shows the others is not\n * part of it.\n */\nexport function useShownPointers() {\n return useStored(POINTERS_KEY, true, isBoolean);\n}\n","import { useId, useState } from \"react\";\nimport { Maximize2, MousePointer2 } from \"lucide-react\";\nimport type {\n Picture,\n PictureWay,\n Target,\n VideoFormat,\n VideoQuality,\n} from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenuCheckboxItem,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Input } from \"@aperture-browser/ui/components/input\";\nimport { useShownPointers } from \"../hooks/use-pointers.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { Described, SettingSubTrigger } from \"./menu-parts.tsx\";\n\nconst AUTO = \"auto\";\n\nconst WAYS: readonly { way: PictureWay; label: string; detail: string }[] = [\n { way: \"video\", label: \"WebRTC\", detail: \"Video on a connection of its own.\" },\n { way: \"frames\", label: \"Frames\", detail: \"The same video on the session socket.\" },\n { way: \"tiles\", label: \"Tiles\", detail: \"Lossless parts of the picture as they change.\" },\n];\n\nconst FORMATS: Readonly<Record<VideoFormat, string>> = {\n h264: \"H.264\",\n \"full-chroma\": \"H.264 4:4:4\",\n h265: \"H.265\",\n vp9: \"VP9\",\n \"vp9-full-chroma\": \"VP9 4:4:4\",\n av1: \"AV1\",\n};\n\nconst QUALITIES: Readonly<Record<VideoQuality, string>> = {\n low: \"Low\",\n medium: \"Medium\",\n full: \"Full\",\n};\n\nconst FRAME_RATES = [15, 30, 60];\n\nconst VIEWPORTS = [\n { width: 1280, height: 720, label: \"1280 × 720\" },\n { width: 1920, height: 1080, label: \"1920 × 1080\" },\n { width: 1440, height: 900, label: \"1440 × 900\" },\n { width: 1024, height: 768, label: \"1024 × 768\" },\n { width: 768, height: 1024, label: \"768 × 1024\", detail: \"Tablet\" },\n { width: 390, height: 844, label: \"390 × 844\", detail: \"Phone\" },\n];\n\nconst SCALES = [1, 1.25, 1.5, 2, 3];\n\nconst VIEWPORT_LIMITS = { min: 100, max: 8192 };\n\nconst isWay = (value: unknown): value is PictureWay => WAYS.some((one) => one.way === value);\n\nconst isFormat = (value: unknown): value is VideoFormat =>\n typeof value === \"string\" && value in FORMATS;\n\nconst isQuality = (value: unknown): value is VideoQuality =>\n typeof value === \"string\" && value in QUALITIES;\n\n/** What the session says it sends, in a line. */\nexport function pictureStatus(picture: Picture): string {\n const way = WAYS.find((one) => one.way === picture.way)?.label ?? picture.way;\n if (picture.way === \"tiles\") {\n return way;\n }\n if (picture.way === \"video\" && picture.rtc !== undefined && picture.rtc !== \"connected\") {\n return `${way} · ${picture.rtc}`;\n }\n const { status } = picture;\n if (status === undefined) {\n return way;\n }\n const parts = [\n way,\n status.format === undefined ? undefined : FORMATS[status.format],\n status.quality === undefined ? undefined : QUALITIES[status.quality].toLowerCase(),\n `${status.fps} fps`,\n ];\n return parts.filter((part) => part !== undefined).join(\" · \");\n}\n\n/** How the picture comes, and the size and scale of the watched target's viewport. */\n/** How the picture comes: its transport, codec, quality and frame rate. */\nexport function PictureItems() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { picture } = snapshot;\n const open = snapshot.connection.state === \"open\";\n const encoded = picture.way !== \"tiles\";\n const { status, settings } = picture;\n\n // A choice left to the session shows what the session chose.\n const chosen = (set: string | undefined, told: string | undefined) => {\n if (set !== undefined) {\n return set;\n }\n return told === undefined ? \"Auto\" : `Auto · ${told}`;\n };\n\n return (\n <>\n <DropdownMenuLabel>\n <span className=\"aperture:flex aperture:flex-col aperture:gap-0.5\">\n <span>Picture</span>\n <span\n data-picture-status=\"\"\n className=\"aperture:font-normal aperture:text-foreground aperture:tabular-nums\"\n >\n {open ? pictureStatus(picture) : \"Not connected\"}\n </span>\n </span>\n </DropdownMenuLabel>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Transport\"\n value={WAYS.find((one) => one.way === picture.way)?.label}\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"How the picture comes\"\n value={picture.way}\n onValueChange={(value) => {\n if (isWay(value)) {\n session.setPicture({ way: value });\n }\n }}\n >\n {WAYS.map(({ way, label, detail }) => (\n <DropdownMenuRadioItem\n key={way}\n value={way}\n disabled={!picture.ways.includes(way)}\n closeOnClick={false}\n >\n <Described title={label}>\n {picture.ways.includes(way) ? detail : \"This browser cannot show it.\"}\n </Described>\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Codec\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.format === undefined ? undefined : FORMATS[settings.format],\n status?.format === undefined ? undefined : FORMATS[status.format],\n )\n : \"None\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-48\">\n <DropdownMenuRadioGroup\n aria-label=\"Codec\"\n value={settings.format ?? AUTO}\n onValueChange={(value) =>\n session.setPicture({ format: isFormat(value) ? value : undefined })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n Auto\n </DropdownMenuRadioItem>\n {Object.entries(FORMATS).map(([format, label]) => (\n <DropdownMenuRadioItem\n key={format}\n value={format}\n disabled={!isFormat(format) || !picture.formats.includes(format)}\n closeOnClick={false}\n >\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Quality\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.quality === undefined ? undefined : QUALITIES[settings.quality],\n status?.quality === undefined ? undefined : QUALITIES[status.quality],\n )\n : \"Lossless\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Quality\"\n value={settings.quality ?? AUTO}\n onValueChange={(value) =>\n session.setPicture({ quality: isQuality(value) ? value : undefined })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n <Described title=\"Auto\">As much as the link carries.</Described>\n </DropdownMenuRadioItem>\n {Object.entries(QUALITIES).map(([quality, label]) => (\n <DropdownMenuRadioItem key={quality} value={quality} closeOnClick={false}>\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Frame rate\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.fps === undefined ? undefined : `${settings.fps} fps`,\n status === undefined ? undefined : `${status.fps} fps`,\n )\n : \"As it changes\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-40\">\n <DropdownMenuRadioGroup\n aria-label=\"Frames a second at most\"\n value={settings.fps === undefined ? AUTO : String(settings.fps)}\n onValueChange={(value) =>\n session.setPicture({ fps: value === AUTO ? undefined : Number(value) })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n Auto\n </DropdownMenuRadioItem>\n {FRAME_RATES.map((fps) => (\n <DropdownMenuRadioItem key={fps} value={String(fps)} closeOnClick={false}>\n {fps} fps\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n </>\n );\n}\n\n/** Whether the other members' pointers are shown over the picture. */\nexport function PointersItem() {\n const { features } = useWorkbench();\n const [shown, show] = useShownPointers();\n\n if (!features.presence) {\n return null;\n }\n return (\n <DropdownMenuCheckboxItem checked={shown} closeOnClick={false} onCheckedChange={show}>\n <MousePointer2 />\n Show the others' pointers\n </DropdownMenuCheckboxItem>\n );\n}\n\n/** The watched tab's viewport: whether it fits this window, its size and its scale. */\nexport function ViewportItems() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const open = snapshot.connection.state === \"open\";\n const resizes = open && snapshot.features.tabs.write && watched !== undefined;\n\n return (\n <>\n <DropdownMenuLabel>Viewport</DropdownMenuLabel>\n <DropdownMenuCheckboxItem\n checked={snapshot.fit}\n disabled={!resizes}\n closeOnClick={false}\n onCheckedChange={(fit) => {\n if (fit) {\n session.setViewport(\"fit\");\n } else if (watched !== undefined) {\n // Says the size the target has, which ends the fitting and changes nothing else.\n session.setViewport({ width: watched.width, height: watched.height });\n }\n }}\n >\n <Maximize2 />\n Fit to this window\n </DropdownMenuCheckboxItem>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Size\"\n disabled={!resizes}\n value={watched === undefined ? \"\" : `${watched.width} × ${watched.height}`}\n />\n <DropdownMenuSubContent className=\"aperture:w-60\">\n <DropdownMenuRadioGroup\n aria-label=\"Size of the viewport\"\n value={watched === undefined || snapshot.fit ? \"\" : sizeId(watched)}\n onValueChange={(value) => {\n const preset = VIEWPORTS.find((one) => sizeId(one) === value);\n if (preset !== undefined) {\n session.setViewport({ width: preset.width, height: preset.height });\n }\n }}\n >\n {VIEWPORTS.map((preset) => (\n <DropdownMenuRadioItem\n key={sizeId(preset)}\n value={sizeId(preset)}\n closeOnClick={false}\n >\n <span className=\"aperture:tabular-nums\">{preset.label}</span>\n {preset.detail === undefined ? null : (\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">\n {preset.detail}\n </span>\n )}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n <DropdownMenuSeparator />\n {watched === undefined ? null : (\n <CustomViewport\n key={sizeId(watched)}\n target={watched}\n onApply={(width, height) => session.setViewport({ width, height })}\n />\n )}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Scale\"\n disabled={!resizes}\n value={watched === undefined ? \"\" : `${formatScale(watched.scale)}x`}\n />\n <DropdownMenuSubContent className=\"aperture:w-40\">\n <DropdownMenuRadioGroup\n aria-label=\"Pixels to a logical pixel\"\n value={watched === undefined ? \"\" : formatScale(watched.scale)}\n onValueChange={(value) => session.setScale(Number(value))}\n >\n {SCALES.map((scale) => (\n <DropdownMenuRadioItem key={scale} value={formatScale(scale)} closeOnClick={false}>\n {formatScale(scale)}x\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n </>\n );\n}\n\nfunction CustomViewport({\n target,\n onApply,\n}: {\n target: Target;\n onApply: (width: number, height: number) => void;\n}) {\n const [width, setWidth] = useState(String(target.width));\n const [height, setHeight] = useState(String(target.height));\n const size = parseSize(width, height);\n const unchanged = size?.width === target.width && size.height === target.height;\n\n return (\n <div\n className=\"aperture:grid aperture:gap-2 aperture:px-1.5 aperture:py-1.5\"\n // Typing a size is not the menu's typeahead, and a click in a field closes nothing.\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => event.stopPropagation()}\n >\n <DropdownMenuLabel className=\"aperture:px-0\">Custom</DropdownMenuLabel>\n <div className=\"aperture:grid aperture:grid-cols-2 aperture:gap-2\">\n <SizeField label=\"Width\" value={width} onChange={setWidth} />\n <SizeField label=\"Height\" value={height} onChange={setHeight} />\n </div>\n <Button\n type=\"button\"\n size=\"sm\"\n className=\"aperture:h-7\"\n disabled={size === undefined || unchanged}\n onClick={() => {\n if (size !== undefined) {\n onApply(size.width, size.height);\n }\n }}\n >\n Apply\n </Button>\n </div>\n );\n}\n\nfunction SizeField({\n label,\n value,\n onChange,\n}: {\n label: string;\n value: string;\n onChange: (value: string) => void;\n}) {\n const id = useId();\n return (\n <div className=\"aperture:grid aperture:gap-1\">\n <label htmlFor={id} className=\"aperture:text-xs aperture:text-muted-foreground\">\n {label}\n </label>\n <Input\n id={id}\n type=\"text\"\n inputMode=\"numeric\"\n value={value}\n onChange={(event) => onChange(event.currentTarget.value.replaceAll(/\\D/gu, \"\"))}\n onFocus={(event) => event.currentTarget.select()}\n className=\"aperture:h-7 aperture:tabular-nums\"\n />\n </div>\n );\n}\n\nfunction parseSize(width: string, height: string) {\n if (width === \"\" || height === \"\") {\n return undefined;\n }\n const clamp = (side: number) =>\n Math.min(Math.max(Math.round(side), VIEWPORT_LIMITS.min), VIEWPORT_LIMITS.max);\n return { width: clamp(Number(width)), height: clamp(Number(height)) };\n}\n\nfunction sizeId(size: { width: number; height: number }): string {\n return `${size.width}x${size.height}`;\n}\n\nfunction formatScale(scale: number): string {\n return String(Math.round(scale * 100) / 100);\n}\n","import { Fragment, useEffect, useState } from \"react\";\nimport {\n Camera,\n Circle,\n CircleAlert,\n CircleCheck,\n Film,\n Gauge,\n Images,\n Loader2,\n Square,\n} from \"lucide-react\";\nimport type {\n EditRecording,\n Pace,\n Recording,\n RecordingOptions,\n Target,\n} from \"@aperture-browser/session-client\";\nimport {\n DropdownMenuCheckboxItem,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { keptOf, recordingIsEdited, recordingRuns, type Kept } from \"../hooks/use-recordings.ts\";\nimport { useStored } from \"../hooks/use-stored.ts\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport {\n Described,\n formatBytes,\n formatDuration,\n formatStarted,\n SettingSubTrigger,\n Thumbnail,\n} from \"./menu-parts.tsx\";\n\n/** How many recordings that ended and screenshots the menu lists. */\nconst LISTED = 6;\n\nconst SETTINGS_KEY = \"aperture.session.recording\";\n\n/** How an edit is made, as the workbench offers it. */\nexport interface EditSettings {\n readonly capture: \"continuous\" | \"bursts\";\n readonly idle: \"keep\" | \"cut\" | \"speed\";\n readonly ripple: boolean;\n readonly fps: 30 | 60;\n}\n\n/** What a recording is started and stopped with, as this browser remembers it. */\nexport interface RecordingSettings extends EditSettings {\n /** A new recording goes on with whichever tab automation acts on. */\n readonly follow: boolean;\n}\n\nconst DEFAULT_SETTINGS: RecordingSettings = {\n follow: false,\n capture: \"continuous\",\n idle: \"keep\",\n ripple: false,\n fps: 60,\n};\n\nconst CAPTURES = { continuous: \"Continuous\", bursts: \"Bursts\" } as const;\nconst IDLES = { keep: \"Keep\", cut: \"Cut\", speed: \"Speed up\" } as const;\nconst RATES = [30, 60] as const;\n\nconst isSettings = (value: unknown): value is RecordingSettings => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { follow, capture, idle, ripple, fps } = value as Record<string, unknown>;\n return (\n typeof follow === \"boolean\" &&\n typeof capture === \"string\" &&\n capture in CAPTURES &&\n typeof idle === \"string\" &&\n idle in IDLES &&\n typeof ripple === \"boolean\" &&\n RATES.some((rate) => rate === fps)\n );\n};\n\nexport function useRecordingSettings() {\n return useStored(SETTINGS_KEY, DEFAULT_SETTINGS, isSettings);\n}\n\n/** What the session is asked for an edit made as `settings` say. */\nexport function editOptions(settings: EditSettings): EditRecording {\n const bursts = settings.capture === \"bursts\";\n return {\n capture: settings.capture,\n // Bursts keep only what happens, so there are no quiet stretches to shorten.\n idle: bursts || settings.idle === \"keep\" ? null : settings.idle,\n ripple: settings.ripple,\n fps: settings.fps,\n };\n}\n\n/** What the workbench offers of the options an edit was made with. */\nexport function editSettings(options: RecordingOptions | undefined): EditSettings {\n if (options === undefined) {\n return DEFAULT_SETTINGS;\n }\n return {\n capture: options.capture,\n idle: options.idle ?? \"keep\",\n ripple: options.ripple,\n fps: options.fps > 30 ? 60 : 30,\n };\n}\n\n/** Starts a recording of the watched tab. */\nexport function RecordItem() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const [settings] = useRecordingSettings();\n const watched = useWatchedTarget();\n const allowed = snapshot.features.recordings.write;\n const recordsWatched = recordings.recordings.some(\n (one) => recordingRuns(one) && one.tab === watched?.tab,\n );\n const canStart =\n snapshot.connection.state === \"open\" &&\n allowed &&\n watched !== undefined &&\n !recordsWatched &&\n !recordings.busy;\n\n const start = () => {\n if (watched === undefined) {\n return;\n }\n recordings.start({ tab: watched.tab, follow: settings.follow }).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The recording did not start\",\n description: failureText(cause),\n });\n });\n };\n\n return (\n <DropdownMenuItem disabled={!canStart} onClick={start}>\n <Circle />\n {allowed ? (\n \"Record this tab\"\n ) : (\n <Described title=\"Record this tab\">Not yours to make here</Described>\n )}\n </DropdownMenuItem>\n );\n}\n\n/** The recordings that run, each with the means to stop it. */\nexport function RunningRecordingItems() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const running = recordings.recordings.filter(recordingRuns);\n const now = useNow(running.length > 0);\n const allowed = snapshot.features.recordings.write;\n const [settings] = useRecordingSettings();\n\n // One press: the edit is made as this browser last chose, which the menu shows below.\n const stop = (recording: Recording) => {\n recordings.stop(recording.id, editOptions(settings)).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The recording did not stop\",\n description: failureText(cause),\n });\n });\n };\n\n return running.map((recording) => (\n <Fragment key={recording.id}>\n <DropdownMenuLabel>\n <span className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:justify-between aperture:gap-2\">\n <span className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:gap-1.5\">\n <span className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-destructive\" />\n <span className=\"aperture:truncate\">{targetName(snapshot.targets, recording.tab)}</span>\n </span>\n <span className=\"aperture:shrink-0 aperture:tabular-nums\">\n {formatDuration(now - recording.started_at_ms)}\n </span>\n </span>\n </DropdownMenuLabel>\n <DropdownMenuItem disabled={recordings.busy || !allowed} onClick={() => stop(recording)}>\n <Square />\n Stop recording\n </DropdownMenuItem>\n </Fragment>\n ));\n}\n\n/**\n * What the session kept of its tabs: the recordings that ended and the screenshots, as one\n * list. Each opens in the gallery.\n */\nexport function KeptItems() {\n const { recordings, view } = useWorkbench();\n const session = useSession();\n const kept = keptOf(recordings);\n\n if (kept.length === 0) {\n return null;\n }\n return (\n <>\n <DropdownMenuLabel>Recordings and screenshots</DropdownMenuLabel>\n {kept.slice(0, LISTED).map((one) => (\n <DropdownMenuItem\n key={one.id}\n data-kept={one.kind}\n data-kept-id={one.id}\n onClick={() => view(one.id)}\n >\n <Thumbnail src={keptPreview(one, session.fileUrl)}>\n {one.kind === \"recording\" ? <Film /> : <Camera />}\n </Thumbnail>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:tabular-nums\">{formatStarted(one.at)}</span>\n <KeptFacts kept={one} />\n </span>\n </DropdownMenuItem>\n ))}\n {kept.length > LISTED ? (\n <DropdownMenuItem onClick={() => view(kept[0]?.id)}>\n <Images />\n All {kept.length}\n </DropdownMenuItem>\n ) : null}\n </>\n );\n}\n\nexport function keptPreview(kept: Kept, fileUrl: (path: string) => string): string | undefined {\n if (kept.kind === \"screenshot\") {\n return fileUrl(kept.screenshot.preview);\n }\n return kept.recording.preview === null ? undefined : fileUrl(kept.recording.preview);\n}\n\n/** What a kept thing is and how it went, in a line. */\nexport function KeptFacts({ kept }: { kept: Kept }) {\n if (kept.kind === \"screenshot\") {\n return (\n <span className=\"aperture:truncate aperture:text-xs aperture:text-muted-foreground\">\n Screenshot · {formatBytes(kept.screenshot.bytes)}\n </span>\n );\n }\n const { recording } = kept;\n const editing = recordingIsEdited(recording);\n const failed = recording.state === \"failed\" || recording.edit?.state === \"failed\";\n let state = \"Finished\";\n if (recording.state === \"failed\") {\n state = \"Failed\";\n } else if (editing) {\n state = \"Editing\";\n } else if (recording.edit?.state === \"failed\") {\n state = \"Edit failed\";\n }\n const facts = [\n \"Recording\",\n recording.duration_ms === null ? undefined : formatDuration(recording.duration_ms),\n recording.bytes === null ? undefined : formatBytes(recording.bytes),\n state,\n ].filter((fact) => fact !== undefined);\n\n return (\n <span\n data-recording-state={state}\n className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:gap-1 aperture:text-xs aperture:text-muted-foreground aperture:[&_svg]:size-3 aperture:[&_svg]:shrink-0\"\n >\n {editing ? <Loader2 className=\"aperture:animate-spin\" /> : null}\n {!editing && failed ? <CircleAlert className=\"aperture:text-destructive\" /> : null}\n {!editing && !failed ? <CircleCheck className=\"aperture:text-emerald-600\" /> : null}\n <span className=\"aperture:truncate\">{facts.join(\" · \")}</span>\n </span>\n );\n}\n\n/** Takes a screenshot of the watched tab, which the session keeps in its files. */\nexport function ScreenshotItem() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const watched = useWatchedTarget();\n const allowed = snapshot.features.recordings.write;\n const takes = snapshot.connection.state === \"open\" && allowed && watched !== undefined;\n\n const take = () => {\n if (watched === undefined) {\n return;\n }\n recordings.takeScreenshot(watched.tab).then(\n () =>\n showNotice({\n level: \"info\",\n message: \"Screenshot taken\",\n description: \"It is in the recording menu and in the session's files.\",\n }),\n (cause: unknown) =>\n showNotice({\n level: \"error\",\n message: \"The screenshot was not taken\",\n description: failureText(cause),\n }),\n );\n };\n\n return (\n <DropdownMenuItem disabled={!takes} closeOnClick={false} onClick={take}>\n <Camera />\n {allowed ? \"Screenshot\" : <Described title=\"Screenshot\">Not yours to make here</Described>}\n </DropdownMenuItem>\n );\n}\n\n/** How a new recording is made, and how the one that stops is edited. */\nexport function RecordingSettingsItems() {\n const [settings, onChange] = useRecordingSettings();\n\n return (\n <>\n <DropdownMenuLabel>New recording</DropdownMenuLabel>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuCheckboxItem\n checked={settings.follow}\n closeOnClick={false}\n onCheckedChange={(follow) => onChange({ ...settings, follow })}\n />\n }\n >\n Follow automation\n </TooltipTrigger>\n <TooltipContent side=\"left\">\n The recording goes on with whichever tab automation acts on, in the same video.\n </TooltipContent>\n </Tooltip>\n <DropdownMenuLabel>When a recording stops</DropdownMenuLabel>\n <EditSettingsItems\n settings={settings}\n onChange={(edit) => onChange({ ...settings, ...edit })}\n />\n </>\n );\n}\n\n/** The session's pace: how automation moves the pointer in what is recorded. */\nexport function AutomationPaceItem() {\n const { features } = useWorkbench();\n const session = useSession();\n const snapshot = useSessionSnapshot();\n\n if (!features.recordings) {\n return null;\n }\n const set = (pace: Pace) => {\n session.pace.set(pace).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The pace was not set\",\n description: failureText(cause),\n });\n });\n };\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger disabled={!snapshot.features.recordings.write}>\n <Gauge />\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n Automation pace\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">\n {PACES[snapshot.pace]}\n </span>\n </span>\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Automation pace\"\n value={snapshot.pace}\n onValueChange={(value) => {\n if (value === \"instant\" || value === \"fast\" || value === \"slow\") {\n set(value);\n }\n }}\n >\n <DropdownMenuRadioItem value=\"instant\" closeOnClick={false}>\n <Described title=\"Instant\">The pointer jumps straight to each action.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"fast\" closeOnClick={false}>\n <Described title=\"Fast\">\n In a recorded tab the pointer travels there, quickly but so that the eye can follow.\n </Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"slow\" closeOnClick={false}>\n <Described title=\"Slow\">Unhurried travel and longer pauses, for demos.</Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nconst PACES = { instant: \"Instant\", fast: \"Fast\", slow: \"Slow\" } as const;\n\n/** How an edit is made: what a recording is stopped with, or edited again with. */\nexport function EditSettingsItems({\n settings,\n onChange,\n}: {\n settings: EditSettings;\n onChange: (settings: EditSettings) => void;\n}) {\n const bursts = settings.capture === \"bursts\";\n\n return (\n <>\n <DropdownMenuSub>\n <SettingSubTrigger name=\"Capture\" value={CAPTURES[settings.capture]} />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Capture\"\n value={settings.capture}\n onValueChange={(value) => {\n if (value === \"continuous\" || value === \"bursts\") {\n onChange({ ...settings, capture: value });\n }\n }}\n >\n <DropdownMenuRadioItem value=\"continuous\" closeOnClick={false}>\n <Described title=\"Continuous\">\n Keep the tab from start to stop, with what is done by hand.\n </Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"bursts\" closeOnClick={false}>\n <Described title=\"Automation bursts\">\n Keep only the stretches around what automation did. Clicking or typing here starts\n none.\n </Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Quiet stretches\"\n value={bursts ? \"Continuous only\" : IDLES[settings.idle]}\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Quiet stretches\"\n value={settings.idle}\n onValueChange={(value) => {\n if (value === \"keep\" || value === \"cut\" || value === \"speed\") {\n onChange({ ...settings, idle: value });\n }\n }}\n >\n <DropdownMenuRadioItem value=\"keep\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Keep\">Leave pauses as long as they were.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"cut\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Cut\">Leave out the stretches in which nothing happens.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"speed\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Speed up\">Play those stretches faster.</Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger name=\"Frame rate\" value={`${settings.fps} fps`} />\n <DropdownMenuSubContent className=\"aperture:w-44\">\n <DropdownMenuRadioGroup\n aria-label=\"Frame rate\"\n value={String(settings.fps)}\n onValueChange={(value) => {\n const fps = RATES.find((rate) => String(rate) === value);\n if (fps !== undefined) {\n onChange({ ...settings, fps });\n }\n }}\n >\n {RATES.map((rate) => (\n <DropdownMenuRadioItem key={rate} value={String(rate)} closeOnClick={false}>\n {rate} fps\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuCheckboxItem\n checked={settings.ripple}\n closeOnClick={false}\n onCheckedChange={(ripple) => onChange({ ...settings, ripple })}\n />\n }\n >\n Highlight clicks\n </TooltipTrigger>\n <TooltipContent side=\"left\">\n Marks clicks with a ripple in the recording edit. The raw recording stays as it is.\n </TooltipContent>\n </Tooltip>\n </>\n );\n}\n\nfunction targetName(targets: readonly Target[], tab: number): string {\n const target = targets.find((one) => one.tab === tab);\n if (target === undefined) {\n return \"A closed tab\";\n }\n return target.title.trim() === \"\" ? target.url : target.title;\n}\n\nfunction useNow(ticking: boolean): number {\n const [now, setNow] = useState(() => Date.now());\n\n useEffect(() => {\n if (!ticking) {\n return undefined;\n }\n setNow(Date.now());\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [ticking]);\n\n return now;\n}\n","import { useEffect, useRef, useState, type DragEvent } from \"react\";\nimport {\n ArrowDownToLine,\n ArrowUpFromLine,\n Check,\n CircleAlert,\n FileIcon,\n FolderOpen,\n Loader2,\n Trash2,\n} from \"lucide-react\";\nimport type { Download, FileRequest, Uploaded } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@aperture-browser/ui/components/popover\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useUploads, type UploadsControl } from \"../hooks/use-uploads.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { formatBytes } from \"./menu-parts.tsx\";\n\n/**\n * The session's files, from a button of the toolbar: what was uploaded for its browser to\n * take, what it downloaded, and the files a page of the watched tab asks for. The panel\n * opens by itself when a page asks and when a download is done.\n */\nexport function SessionFilesButton() {\n const { features } = useWorkbench();\n const { open, setOpen, request, busy, label, panel } = useSessionFiles();\n\n if (!features.files) {\n return null;\n }\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger\n render={\n <PopoverTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={label}\n data-session-files-button=\"\"\n className=\"aperture:relative\"\n />\n }\n />\n }\n >\n <FolderOpen />\n {request !== undefined ? (\n <span className=\"aperture:absolute aperture:top-0.5 aperture:right-0.5 aperture:size-2 aperture:animate-pulse aperture:rounded-full aperture:bg-amber-500 aperture:ring-2 aperture:ring-background\" />\n ) : null}\n {request === undefined && busy > 0 ? (\n <span className=\"aperture:absolute aperture:-top-0.5 aperture:-right-0.5 aperture:flex aperture:h-3.5 aperture:min-w-3.5 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-primary aperture:px-0.5 aperture:text-[0.5625rem] aperture:leading-none aperture:font-medium aperture:text-primary-foreground\">\n {busy}\n </span>\n ) : null}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n <PopoverContent\n align=\"end\"\n className=\"aperture:w-88 aperture:max-w-[calc(100vw-1rem)] aperture:gap-0 aperture:p-0\"\n aria-label=\"Files\"\n data-session-files=\"\"\n >\n {panel}\n </PopoverContent>\n </Popover>\n );\n}\n\n/**\n * The session's files as a panel that is opened from somewhere: whether it is open, which\n * it is by itself when a page asks for a file and when a download is done, and what tells\n * of it where it is opened from. In a `sheet` the panel is as long as what it holds, and\n * the sheet is what scrolls.\n */\nexport function useSessionFiles({ sheet = false }: { sheet?: boolean } = {}) {\n const snapshot = useSessionSnapshot();\n const { features } = useWorkbench();\n const uploads = useUploads(features.uploads);\n const [open, setOpen] = useState(false);\n const request = snapshot.fileRequests.find((one) => one.tab === snapshot.selected);\n const running = snapshot.downloads.filter((download) => download.state === \"running\").length;\n const done = snapshot.downloads.filter((download) => download.state === \"done\").length;\n const busy = running + uploads.inProgress.length;\n\n const { refresh } = uploads;\n const seen = useRef({ request: request?.id, done });\n useEffect(() => {\n const asked = request !== undefined && request.id !== seen.current.request;\n const finished = done > seen.current.done;\n seen.current = { request: request?.id, done };\n if (asked || finished) {\n setOpen(true);\n }\n }, [request, done]);\n\n // Another member may have uploaded since the panel was last open.\n useEffect(() => {\n if (open) {\n refresh();\n }\n }, [open, refresh]);\n\n return {\n open,\n setOpen,\n request,\n busy,\n label: request === undefined ? \"Files\" : \"Files: a page asks for one\",\n panel: (\n <SessionFiles\n uploads={uploads}\n request={request}\n downloads={snapshot.downloads}\n offers={features}\n puts={features.access.uploads.write}\n sheet={sheet}\n />\n ),\n };\n}\n\nfunction SessionFiles({\n uploads,\n request,\n downloads,\n offers,\n puts,\n sheet,\n}: {\n uploads: UploadsControl;\n request: FileRequest | undefined;\n downloads: readonly Download[];\n /** Which of the two the session has. */\n offers: { readonly uploads: boolean; readonly downloads: boolean };\n /** This member may put files into the session, and answer pages with them. */\n puts: boolean;\n sheet: boolean;\n}) {\n const session = useSession();\n const picker = useRef<HTMLInputElement>(null);\n const [dragging, setDragging] = useState(false);\n const [chosen, setChosen] = useState<readonly string[]>([]);\n\n // A choice made for one request is not one for the next.\n const requestId = request?.id;\n useEffect(() => setChosen([]), [requestId]);\n\n const failed = (file: File, cause: unknown) =>\n showNotice({\n level: \"error\",\n message: `${file.name} was not uploaded`,\n description: failureText(cause),\n });\n\n const put = async (files: readonly File[], answers: FileRequest | undefined) => {\n const uploaded = await uploads.upload(files, failed);\n // Files picked while a page asks are the answer, as they are in a browser of one's own.\n if (answers !== undefined && uploaded.length > 0) {\n const names = uploaded.map((file) => file.name);\n session.chooseFiles(answers.id, answers.multiple ? names : names.slice(0, 1));\n }\n };\n\n const toggle = (name: string) => {\n if (request === undefined) {\n return;\n }\n if (!request.multiple) {\n setChosen(chosen.includes(name) ? [] : [name]);\n return;\n }\n setChosen(chosen.includes(name) ? chosen.filter((one) => one !== name) : [...chosen, name]);\n };\n\n const remove = (file: Uploaded) => {\n uploads.remove(file.name).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: `${file.name} was not removed`,\n description: failureText(cause),\n });\n });\n };\n\n const drop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragging(false);\n const files = Array.from(event.dataTransfer.files);\n if (files.length > 0) {\n void put(files, undefined);\n }\n };\n\n const existing = chosen.filter((name) => uploads.uploads.some((file) => file.name === name));\n const listed = downloads.toReversed();\n\n return (\n <div\n className={cn(\n \"aperture:relative aperture:flex aperture:flex-col\",\n sheet ? \"aperture:min-h-full\" : \"aperture:max-h-[min(32rem,calc(100dvh-6rem))]\",\n )}\n onDragOver={(event) => {\n if (offers.uploads && puts && event.dataTransfer.types.includes(\"Files\")) {\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n setDragging(true);\n }\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setDragging(false);\n }\n }}\n onDrop={drop}\n >\n <input\n ref={picker}\n type=\"file\"\n hidden\n multiple={request === undefined || request.multiple}\n data-session-file-input=\"\"\n onChange={(event) => {\n const files = Array.from(event.currentTarget.files ?? []);\n event.currentTarget.value = \"\";\n if (files.length > 0) {\n void put(files, request);\n }\n }}\n />\n {request === undefined ? null : (\n <div\n data-session-file-request=\"\"\n className=\"aperture:flex aperture:flex-col aperture:gap-2 aperture:border-b aperture:border-amber-500/40 aperture:bg-amber-500/10 aperture:p-2.5\"\n >\n <span className=\"aperture:text-sm aperture:font-medium\">\n {request.multiple ? \"The page asks for files\" : \"The page asks for a file\"}\n </span>\n <div className=\"aperture:flex aperture:flex-wrap aperture:items-center aperture:gap-1.5\">\n <Button\n type=\"button\"\n size=\"sm\"\n disabled={!puts}\n onClick={() => picker.current?.click()}\n >\n <ArrowUpFromLine />\n Upload…\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n disabled={existing.length === 0 || !puts}\n onClick={() => session.chooseFiles(request.id, existing)}\n >\n <Check />\n {giveLabel(request, existing.length)}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n className=\"aperture:ml-auto\"\n disabled={!puts}\n onClick={() => session.chooseFiles(request.id, [])}\n >\n Cancel\n </Button>\n </div>\n </div>\n )}\n <div className={cn(\"aperture:flex-1\", !sheet && \"aperture:min-h-0 aperture:overflow-y-auto\")}>\n {offers.uploads ? (\n <section className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:p-2.5\">\n <header className=\"aperture:flex aperture:h-6 aperture:items-center aperture:justify-between aperture:gap-2\">\n <h3 className=\"aperture:text-xs aperture:text-muted-foreground\">Uploads</h3>\n {request === undefined ? (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"outline\"\n disabled={!puts}\n onClick={() => picker.current?.click()}\n >\n <ArrowUpFromLine />\n Upload\n </Button>\n ) : null}\n </header>\n {uploads.inProgress.map((file) => (\n <div\n key={file.name}\n data-session-upload-progress=\"\"\n className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:rounded-md aperture:px-1.5 aperture:py-1\"\n >\n <div className=\"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm\">\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {file.name}\n </span>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {percent(file.loaded, file.total)}\n </span>\n </div>\n <div className=\"aperture:h-1 aperture:overflow-hidden aperture:rounded-full aperture:bg-muted\">\n <div\n className=\"aperture:h-full aperture:rounded-full aperture:bg-primary aperture:transition-[width]\"\n style={{ width: percent(file.loaded, file.total) }}\n />\n </div>\n </div>\n ))}\n {uploads.uploads.map((file) => {\n const picked = chosen.includes(file.name);\n return (\n <div\n key={file.name}\n data-session-upload={file.name}\n className={cn(\n \"aperture:group/file aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm\",\n request !== undefined && \"aperture:cursor-default aperture:hover:bg-muted\",\n picked && \"aperture:bg-accent aperture:text-accent-foreground\",\n )}\n role={request === undefined ? undefined : \"option\"}\n aria-selected={request === undefined ? undefined : picked}\n onClick={() => toggle(file.name)}\n >\n {picked ? (\n <Check className=\"aperture:size-4 aperture:shrink-0\" />\n ) : (\n <FileIcon className=\"aperture:size-4 aperture:shrink-0 aperture:text-muted-foreground\" />\n )}\n <span\n className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\"\n title={file.path}\n >\n {file.name}\n </span>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {formatBytes(file.size)}\n </span>\n <Button\n type=\"button\"\n size=\"icon-xs\"\n variant=\"ghost\"\n aria-label={`Remove ${file.name}`}\n className=\"aperture:shrink-0 aperture:opacity-55 aperture:group-hover/file:opacity-100 aperture:hover:opacity-100 aperture:pointer-coarse:opacity-100\"\n disabled={!puts}\n onClick={(event) => {\n event.stopPropagation();\n remove(file);\n }}\n >\n <Trash2 />\n </Button>\n </div>\n );\n })}\n {uploads.uploads.length === 0 && uploads.inProgress.length === 0 ? (\n <p\n title={puts ? \"Drop files here, or onto the page itself\" : undefined}\n className=\"aperture:rounded-md aperture:border aperture:border-dashed aperture:px-2 aperture:py-3 aperture:text-center aperture:text-xs aperture:text-muted-foreground\"\n >\n Nothing uploaded\n </p>\n ) : null}\n </section>\n ) : null}\n {offers.downloads ? (\n <section className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:p-2.5 aperture:not-first:border-t\">\n <header className=\"aperture:flex aperture:h-6 aperture:items-center\">\n <span className=\"aperture:text-xs aperture:font-medium aperture:text-muted-foreground\">\n Downloads\n </span>\n </header>\n {listed.map((download) => (\n <DownloadRow\n key={download.id}\n download={download}\n href={session.fileUrl(`downloads/${download.name}`)}\n />\n ))}\n {listed.length === 0 ? (\n <p className=\"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:text-muted-foreground\">\n No downloads\n </p>\n ) : null}\n </section>\n ) : null}\n </div>\n {dragging ? (\n <div className=\"aperture:pointer-events-none aperture:absolute aperture:inset-1 aperture:flex aperture:items-center aperture:justify-center aperture:rounded-md aperture:border-2 aperture:border-dashed aperture:border-primary/60 aperture:bg-background/90 aperture:text-sm aperture:font-medium\">\n Drop to upload\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction DownloadRow({ download, href }: { download: Download; href: string }) {\n const { state } = download;\n const received = formatBytes(download.receivedBytes);\n const progress =\n download.totalBytes === undefined || download.totalBytes === 0\n ? received\n : percent(download.receivedBytes, download.totalBytes);\n\n return (\n <div\n data-session-download={download.name}\n data-state={state}\n className=\"aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm\"\n title={download.url}\n >\n {state === \"done\" ? (\n <ArrowDownToLine className=\"aperture:size-4 aperture:shrink-0 aperture:text-muted-foreground\" />\n ) : null}\n {state === \"failed\" ? (\n <CircleAlert className=\"aperture:size-4 aperture:shrink-0 aperture:text-destructive\" />\n ) : null}\n {state !== \"done\" && state !== \"failed\" ? (\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n ) : null}\n {state === \"done\" ? (\n <a\n href={href}\n download={download.name}\n className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:underline aperture:decoration-muted-foreground/50 aperture:underline-offset-2 aperture:hover:decoration-foreground\"\n >\n {download.name}\n </a>\n ) : (\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">{download.name}</span>\n )}\n <span\n className={cn(\n \"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\",\n state === \"failed\" && \"aperture:text-destructive\",\n )}\n >\n {state === \"done\" ? received : null}\n {state === \"failed\" ? \"Failed\" : null}\n {state !== \"done\" && state !== \"failed\" ? progress : null}\n </span>\n </div>\n );\n}\n\nfunction giveLabel(request: FileRequest, chosen: number): string {\n if (chosen > 1) {\n return `Give ${chosen} files`;\n }\n return request.multiple && chosen === 0 ? \"Give the files\" : \"Give the file\";\n}\n\nfunction percent(loaded: number, total: number): string {\n return total <= 0 ? \"0%\" : `${Math.min(100, Math.round((100 * loaded) / total))}%`;\n}\n","import { ContextMenuItem } from \"@aperture-browser/ui/components/context-menu\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { copyTextHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport type { WorkbenchSlotProps } from \"../workbench/contributions.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\n\nexport function TabReloadItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const watched = useSessionSnapshot().selected === target?.tab;\n return (\n <ContextMenuItem\n disabled={!changes || !watched}\n onClick={() => session.go({ along: \"reload\" })}\n >\n Reload\n </ContextMenuItem>\n );\n}\n\nexport function TabDuplicateItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const url = target?.url ?? \"\";\n return (\n <ContextMenuItem\n disabled={!changes || url === \"\"}\n onClick={() => session.go({ url }, { newTab: true })}\n >\n Duplicate\n </ContextMenuItem>\n );\n}\n\nexport function TabCopyUrlItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n return (\n <ContextMenuItem\n onClick={() => copyTextHere(session, target?.url || \"about:blank\", \"URL copied\")}\n >\n Copy URL\n </ContextMenuItem>\n );\n}\n\n/** Mutes the tab for this client, or lets it be heard again. */\nexport function TabMuteItem({ target }: WorkbenchSlotProps) {\n const { features } = useWorkbench();\n const sound = useTabSound(target);\n\n if (!features.sound) {\n return null;\n }\n return (\n <ContextMenuItem onClick={sound.toggle}>{sound.muted ? \"Unmute\" : \"Mute\"}</ContextMenuItem>\n );\n}\n\nexport function TabCloseItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n return (\n <ContextMenuItem\n disabled={!changes || target === undefined}\n onClick={() => {\n if (target !== undefined) {\n session.closeTab(target.tab);\n }\n }}\n >\n Close\n </ContextMenuItem>\n );\n}\n\nexport function TabCloseOthersItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const others = useSessionSnapshot().targets.filter((other) => other.tab !== target?.tab);\n return (\n <ContextMenuItem\n disabled={!changes || others.length === 0}\n onClick={() => {\n for (const other of others) {\n session.closeTab(other.tab);\n }\n }}\n >\n Close other tabs\n </ContextMenuItem>\n );\n}\n\nexport function TabCloseRightItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const { targets } = useSessionSnapshot();\n const at = targets.findIndex((other) => other.tab === target?.tab);\n const toTheRight = at < 0 ? [] : targets.slice(at + 1);\n return (\n <ContextMenuItem\n disabled={!changes || toTheRight.length === 0}\n onClick={() => {\n for (const other of toTheRight) {\n session.closeTab(other.tab);\n }\n }}\n >\n Close tabs to the right\n </ContextMenuItem>\n );\n}\n","import {\n PageLinkItems,\n PageNavigationItems,\n PagePictureItems,\n PageTextItems,\n} from \"../components/page-menu.tsx\";\nimport { PageModeItem } from \"../components/page-mode.tsx\";\nimport {\n PhoneClipboardItem,\n PhoneDrawItem,\n PhoneFilesItem,\n PhoneRecordingItem,\n PhoneTypeItem,\n PhoneViewItem,\n} from \"../components/phone-menu.tsx\";\nimport { PictureItems, PointersItem, ViewportItems } from \"../components/picture-menu.tsx\";\nimport {\n AutomationPaceItem,\n KeptItems,\n RecordingSettingsItems,\n RecordItem,\n RunningRecordingItems,\n ScreenshotItem,\n} from \"../components/recording-menu.tsx\";\nimport { SessionFilesButton } from \"../components/session-files.tsx\";\nimport {\n TabCloseItem,\n TabCloseOthersItem,\n TabCloseRightItem,\n TabCopyUrlItem,\n TabDuplicateItem,\n TabMuteItem,\n TabReloadItem,\n} from \"../components/tab-menu.tsx\";\nimport {\n AppearanceItem,\n BrowserMenuAction,\n DrawAction,\n CopyItem,\n CopyUrlItem,\n KeyboardAction,\n LeaseItems,\n MuteItem,\n NavigationItems,\n PasteItem,\n PictureAction,\n PictureSubmenuItem,\n ReconnectItem,\n RecordingAction,\n RecordingSubmenuItem,\n SelectAllItem,\n TypeItem,\n} from \"../components/toolbar-actions.tsx\";\nimport type { WorkbenchContribution } from \"./contributions.ts\";\n\n/**\n * What the workbench puts into its own slots. An embedder's contribution with one of these\n * ids takes that one's place, and a function of this list can leave any of them out.\n */\nexport const workbenchContributions: readonly WorkbenchContribution[] = [\n { id: \"action.keyboard\", slot: \"toolbar.actions\", order: 100, component: KeyboardAction },\n { id: \"action.files\", slot: \"toolbar.actions\", order: 200, component: SessionFilesButton },\n { id: \"action.draw\", slot: \"toolbar.actions\", order: 250, component: DrawAction },\n { id: \"action.recording\", slot: \"toolbar.actions\", order: 300, component: RecordingAction },\n { id: \"action.picture\", slot: \"toolbar.actions\", order: 400, component: PictureAction },\n { id: \"action.menu\", slot: \"toolbar.actions\", order: 500, component: BrowserMenuAction },\n\n {\n id: \"browser.navigation\",\n slot: \"menu.browser\",\n group: \"navigation\",\n order: 80,\n component: NavigationItems,\n },\n { id: \"browser.lease\", slot: \"menu.browser\", group: \"lease\", order: 100, component: LeaseItems },\n { id: \"browser.copy\", slot: \"menu.browser\", group: \"clipboard\", order: 200, component: CopyItem },\n {\n id: \"browser.paste\",\n slot: \"menu.browser\",\n group: \"clipboard\",\n order: 300,\n component: PasteItem,\n },\n {\n id: \"browser.select-all\",\n slot: \"menu.browser\",\n group: \"clipboard\",\n order: 400,\n component: SelectAllItem,\n },\n { id: \"browser.type\", slot: \"menu.browser\", group: \"clipboard\", order: 500, component: TypeItem },\n { id: \"browser.mute\", slot: \"menu.browser\", group: \"tab\", order: 600, component: MuteItem },\n {\n id: \"browser.recording\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 700,\n component: RecordingSubmenuItem,\n },\n {\n id: \"browser.picture\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 750,\n component: PictureSubmenuItem,\n },\n {\n id: \"browser.page-mode\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 760,\n component: PageModeItem,\n },\n {\n id: \"browser.copy-url\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 800,\n component: CopyUrlItem,\n },\n {\n id: \"browser.pace\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 850,\n component: AutomationPaceItem,\n },\n {\n id: \"browser.appearance\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 900,\n component: AppearanceItem,\n },\n {\n id: \"browser.reconnect\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 1000,\n component: ReconnectItem,\n },\n\n { id: \"phone.lease\", slot: \"menu.phone\", group: \"lease\", order: 100, component: LeaseItems },\n { id: \"phone.type\", slot: \"menu.phone\", group: \"input\", order: 200, component: PhoneTypeItem },\n {\n id: \"phone.clipboard\",\n slot: \"menu.phone\",\n group: \"input\",\n order: 300,\n component: PhoneClipboardItem,\n },\n { id: \"phone.draw\", slot: \"menu.phone\", group: \"input\", order: 400, component: PhoneDrawItem },\n { id: \"phone.page-mode\", slot: \"menu.phone\", group: \"page\", order: 500, component: PageModeItem },\n {\n id: \"phone.files\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 600,\n component: PhoneFilesItem,\n },\n {\n id: \"phone.recording\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 700,\n component: PhoneRecordingItem,\n },\n {\n id: \"phone.pace\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 750,\n component: AutomationPaceItem,\n },\n { id: \"phone.view\", slot: \"menu.phone\", group: \"view\", order: 900, component: PhoneViewItem },\n {\n id: \"phone.reconnect\",\n slot: \"menu.phone\",\n group: \"connection\",\n order: 1100,\n component: ReconnectItem,\n },\n\n {\n id: \"picture.transport\",\n slot: \"menu.picture\",\n group: \"picture\",\n order: 100,\n component: PictureItems,\n },\n {\n id: \"picture.viewport\",\n slot: \"menu.picture\",\n group: \"viewport\",\n order: 200,\n component: ViewportItems,\n },\n {\n id: \"picture.pointers\",\n slot: \"menu.picture\",\n group: \"picture\",\n order: 150,\n component: PointersItem,\n },\n\n {\n id: \"recording.record\",\n slot: \"menu.recording\",\n group: \"take\",\n order: 100,\n component: RecordItem,\n },\n {\n id: \"recording.screenshot\",\n slot: \"menu.recording\",\n group: \"take\",\n order: 200,\n component: ScreenshotItem,\n },\n {\n id: \"recording.running\",\n slot: \"menu.recording\",\n group: \"running\",\n order: 300,\n component: RunningRecordingItems,\n },\n { id: \"recording.kept\", slot: \"menu.recording\", group: \"kept\", order: 400, component: KeptItems },\n {\n id: \"recording.settings\",\n slot: \"menu.recording\",\n group: \"settings\",\n order: 500,\n component: RecordingSettingsItems,\n },\n\n { id: \"tab.reload\", slot: \"menu.tab\", group: \"tab\", order: 100, component: TabReloadItem },\n { id: \"tab.duplicate\", slot: \"menu.tab\", group: \"tab\", order: 200, component: TabDuplicateItem },\n { id: \"tab.copy-url\", slot: \"menu.tab\", group: \"tab\", order: 300, component: TabCopyUrlItem },\n { id: \"tab.mute\", slot: \"menu.tab\", group: \"tab\", order: 400, component: TabMuteItem },\n { id: \"tab.close\", slot: \"menu.tab\", group: \"close\", order: 500, component: TabCloseItem },\n {\n id: \"tab.close-others\",\n slot: \"menu.tab\",\n group: \"close\",\n order: 600,\n component: TabCloseOthersItem,\n },\n {\n id: \"tab.close-right\",\n slot: \"menu.tab\",\n group: \"close\",\n order: 700,\n component: TabCloseRightItem,\n },\n\n { id: \"page.link\", slot: \"menu.page\", group: \"link\", order: 100, component: PageLinkItems },\n {\n id: \"page.picture\",\n slot: \"menu.page\",\n group: \"picture\",\n order: 200,\n component: PagePictureItems,\n },\n { id: \"page.text\", slot: \"menu.page\", group: \"text\", order: 300, component: PageTextItems },\n {\n id: \"page.navigation\",\n slot: \"menu.page\",\n group: \"navigation\",\n order: 400,\n component: PageNavigationItems,\n },\n];\n","import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\n\nconst badgeVariants = cva(\n \"aperture:group/badge aperture:inline-flex aperture:h-5 aperture:w-fit aperture:shrink-0 aperture:items-center aperture:justify-center aperture:gap-1 aperture:overflow-hidden aperture:rounded-4xl aperture:border aperture:border-transparent aperture:px-2 aperture:py-0.5 aperture:text-xs aperture:font-medium aperture:whitespace-nowrap aperture:transition-all aperture:focus-visible:border-ring aperture:focus-visible:ring-[3px] aperture:focus-visible:ring-ring/50 aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-destructive/20 aperture:dark:aria-invalid:ring-destructive/40 aperture:[&>svg]:pointer-events-none aperture:[&>svg]:size-3!\",\n {\n variants: {\n variant: {\n default:\n \"aperture:bg-primary aperture:text-primary-foreground aperture:[a]:hover:bg-primary/80\",\n secondary:\n \"aperture:bg-secondary aperture:text-secondary-foreground aperture:[a]:hover:bg-secondary/80\",\n destructive:\n \"aperture:bg-destructive/10 aperture:text-destructive aperture:focus-visible:ring-destructive/20 aperture:dark:bg-destructive/20 aperture:dark:focus-visible:ring-destructive/40 aperture:[a]:hover:bg-destructive/20\",\n outline:\n \"aperture:border-border aperture:text-foreground aperture:[a]:hover:bg-muted aperture:[a]:hover:text-muted-foreground\",\n ghost:\n \"aperture:hover:bg-muted aperture:hover:text-muted-foreground aperture:dark:hover:bg-muted/50\",\n link: \"aperture:text-primary aperture:underline-offset-4 aperture:hover:underline\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction Badge({\n className,\n variant = \"default\",\n render,\n ...props\n}: useRender.ComponentProps<\"span\"> & VariantProps<typeof badgeVariants>) {\n return useRender({\n defaultTagName: \"span\",\n props: mergeProps<\"span\">(\n {\n className: cn(badgeVariants({ variant }), className),\n },\n props,\n ),\n render,\n state: {\n slot: \"badge\",\n variant,\n },\n });\n}\n\nexport { Badge, badgeVariants };\n","import { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Empty({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty\"\n className={cn(\n \"aperture:flex aperture:w-full aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-4 aperture:rounded-xl aperture:border-dashed aperture:p-6 aperture:text-center aperture:text-balance\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction EmptyHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-header\"\n className={cn(\n \"aperture:flex aperture:max-w-sm aperture:flex-col aperture:items-center aperture:gap-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nconst emptyMediaVariants = cva(\n \"aperture:mb-2 aperture:flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"aperture:bg-transparent\",\n icon: \"aperture:flex aperture:size-8 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-lg aperture:bg-muted aperture:text-foreground aperture:[&_svg:not([class*='size-'])]:size-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction EmptyMedia({\n className,\n variant = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof emptyMediaVariants>) {\n return (\n <div\n data-slot=\"empty-icon\"\n data-variant={variant}\n className={cn(emptyMediaVariants({ variant, className }))}\n {...props}\n />\n );\n}\n\nfunction EmptyTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-title\"\n className={cn(\"aperture:text-sm aperture:font-medium aperture:tracking-tight\", className)}\n {...props}\n />\n );\n}\n\nfunction EmptyDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n return (\n <div\n data-slot=\"empty-description\"\n className={cn(\n \"aperture:text-sm/relaxed aperture:text-muted-foreground aperture:[&>a]:underline aperture:[&>a]:underline-offset-4 aperture:[&>a:hover]:text-primary\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction EmptyContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-content\"\n className={cn(\n \"aperture:flex aperture:w-full aperture:max-w-sm aperture:min-w-0 aperture:flex-col aperture:items-center aperture:gap-2.5 aperture:text-sm aperture:text-balance\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };\n","import { useEffect, useRef, useState, type PointerEvent as ReactPointerEvent } from \"react\";\nimport { MousePointer2 } from \"lucide-react\";\nimport type { Member, Target } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useShownPointers } from \"../hooks/use-pointers.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { automationName, memberColor } from \"./session-presence.tsx\";\nimport { pictureBox } from \"./session-viewport.tsx\";\n\n/** How long a stroke that ended takes to fade. */\nconst STROKE_FADES_MS = 7000;\nconst STROKE_WIDTH = 4;\n/** A stroke that long is thinned out: nobody sees its every point. */\nconst STROKE_POINTS = 2048;\n/** The others are told where a stroke goes this often at most. */\nconst DRAW_EVERY_MS = 24;\n/** And where the pointer that draws is. */\nconst POINT_EVERY_MS = 40;\n/** Of a member who left, or whose colour is not known yet. */\nconst UNKNOWN_COLOR = \"oklch(0.55 0.02 260)\";\n\ninterface Point {\n readonly x: number;\n readonly y: number;\n}\n\ninterface Stroke {\n readonly member: number;\n readonly stroke: number;\n points: Point[];\n /** When it ended, on the page's clock; none while it is drawn. */\n endedAt: number | undefined;\n}\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * What the session's members show each other over the watched tab: where their pointers\n * are, unless this browser was told not to show them, and the strokes they draw. Drawing\n * is this member's while the workbench is told to draw; the picture then takes no input\n * from it, and the others still see where its pointer is.\n */\nexport function MemberMarks() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { drawing } = useWorkbench();\n const [shownPointers] = useShownPointers();\n const pointed = useRef(0);\n const frameRef = useRef<HTMLDivElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const [frame, setFrame] = useState<Size>({ width: 0, height: 0 });\n const [pointers, setPointers] = useState<ReadonlyMap<number, Point>>(new Map());\n const strokes = useRef<Stroke[]>([]);\n const painting = useRef<number | undefined>(undefined);\n const own = useRef<{ stroke: number; told: number } | undefined>(undefined);\n const drawn = useRef(0);\n\n const { presence } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const box = watched === undefined ? { width: 0, height: 0 } : pictureBox(frame, watched);\n const members = useRef<readonly Member[]>([]);\n members.current = presence?.members ?? [];\n const shown = useRef<{ box: Size; watched: Target | undefined }>({ box, watched });\n shown.current = { box, watched };\n\n useEffect(() => {\n const element = frameRef.current;\n if (element === null) {\n return undefined;\n }\n const measure = () => setFrame({ width: element.clientWidth, height: element.clientHeight });\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => sizes.disconnect();\n }, []);\n\n const paint = useRef(() => {});\n paint.current = () => {\n painting.current = undefined;\n const canvas = canvasRef.current;\n const context = canvas?.getContext(\"2d\");\n const { box: size, watched: target } = shown.current;\n if (canvas === null || canvas === undefined || context === null || context === undefined) {\n return;\n }\n const now = performance.now();\n strokes.current = strokes.current.filter(\n (stroke) => stroke.endedAt === undefined || now - stroke.endedAt < STROKE_FADES_MS,\n );\n const pixels = window.devicePixelRatio;\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n if (target === undefined || target.width <= 0) {\n return;\n }\n const scale = (size.width / target.width) * pixels;\n context.setTransform(scale, 0, 0, scale, 0, 0);\n context.lineCap = \"round\";\n context.lineJoin = \"round\";\n context.lineWidth = STROKE_WIDTH / (size.width / target.width);\n for (const stroke of strokes.current) {\n const member = members.current.find((one) => one.id === stroke.member);\n const color = member === undefined ? UNKNOWN_COLOR : memberColor(member);\n context.globalAlpha =\n stroke.endedAt === undefined ? 1 : 1 - (now - stroke.endedAt) / STROKE_FADES_MS;\n context.strokeStyle = color;\n context.fillStyle = color;\n trace(context, stroke.points);\n }\n if (strokes.current.length > 0) {\n painting.current = requestAnimationFrame(() => paint.current());\n }\n };\n const repaint = () => {\n painting.current ??= requestAnimationFrame(() => paint.current());\n };\n\n const add = (member: number, stroke: number, phase: \"start\" | \"move\" | \"end\", at: Point) => {\n let open = strokes.current.find(\n (one) => one.member === member && one.stroke === stroke && one.endedAt === undefined,\n );\n if (open === undefined) {\n // A stroke whose start was missed begins where it is first seen.\n open = { member, stroke, points: [], endedAt: undefined };\n strokes.current.push(open);\n }\n open.points.push(at);\n if (open.points.length > STROKE_POINTS) {\n open.points = open.points.filter((_, index) => index % 2 === 0);\n }\n if (phase === \"end\") {\n open.endedAt = performance.now();\n }\n repaint();\n };\n const addRef = useRef(add);\n addRef.current = add;\n\n useEffect(() => {\n const unheard = [\n session.onPointer(({ member, at }) =>\n setPointers((before) => {\n const after = new Map(before);\n if (at === undefined) {\n after.delete(member);\n } else {\n after.set(member, at);\n }\n return after;\n }),\n ),\n session.onStroke((point) => addRef.current(point.member, point.stroke, point.phase, point)),\n ];\n return () => {\n for (const unhear of unheard) {\n unhear();\n }\n };\n }, [session]);\n\n // What was shown over another tab is not shown over this one.\n useEffect(() => {\n setPointers(new Map());\n strokes.current = [];\n own.current = undefined;\n repaint();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- only the tab matters\n }, [snapshot.selected]);\n\n // Whoever left drew their last, and points nowhere.\n useEffect(() => {\n const here = new Set(presence?.members.map((member) => member.id));\n const now = performance.now();\n for (const stroke of strokes.current) {\n if (stroke.endedAt === undefined && !here.has(stroke.member)) {\n stroke.endedAt = now;\n }\n }\n setPointers((before) => {\n const gone = [...before.keys()].filter((member) => !here.has(member));\n if (gone.length === 0) {\n return before;\n }\n const after = new Map(before);\n for (const member of gone) {\n after.delete(member);\n }\n return after;\n });\n }, [presence]);\n\n useEffect(() => repaint());\n\n useEffect(\n () => () => {\n if (painting.current !== undefined) {\n cancelAnimationFrame(painting.current);\n }\n },\n [],\n );\n\n if (watched === undefined || presence === undefined || box.width <= 0) {\n return (\n <div\n ref={frameRef}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0\"\n />\n );\n }\n\n const scale = box.width / watched.width;\n const at = (event: ReactPointerEvent<HTMLDivElement>): Point => {\n const bounds = event.currentTarget.getBoundingClientRect();\n return { x: (event.clientX - bounds.left) / scale, y: (event.clientY - bounds.top) / scale };\n };\n const draw = (phase: \"start\" | \"move\" | \"end\", point: Point) => {\n const mine = own.current;\n if (mine === undefined) {\n return;\n }\n session.draw(mine.stroke, phase, point);\n add(presence.you, mine.stroke, phase, point);\n };\n const end = (event: ReactPointerEvent<HTMLDivElement>) => {\n draw(\"end\", at(event));\n own.current = undefined;\n };\n\n return (\n <div\n ref={frameRef}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:z-10 aperture:flex aperture:items-center aperture:justify-center\"\n >\n <div\n data-member-marks={drawing ? \"drawing\" : \"\"}\n className=\"aperture:relative aperture:flex-none aperture:overflow-hidden\"\n style={{\n width: box.width,\n height: box.height,\n pointerEvents: drawing ? \"auto\" : \"none\",\n cursor: drawing ? \"crosshair\" : undefined,\n touchAction: \"none\",\n }}\n onPointerDown={(event) => {\n if (!drawing || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n drawn.current += 1;\n own.current = { stroke: drawn.current, told: performance.now() };\n draw(\"start\", at(event));\n }}\n onPointerMove={(event) => {\n const now = performance.now();\n if (now - pointed.current >= POINT_EVERY_MS) {\n pointed.current = now;\n session.point(at(event));\n }\n const mine = own.current;\n if (mine === undefined || now - mine.told < DRAW_EVERY_MS) {\n return;\n }\n mine.told = now;\n draw(\"move\", at(event));\n }}\n onPointerLeave={() => session.point()}\n onPointerUp={end}\n onPointerCancel={end}\n >\n <canvas\n ref={canvasRef}\n width={Math.round(box.width * window.devicePixelRatio)}\n height={Math.round(box.height * window.devicePixelRatio)}\n className=\"aperture:absolute aperture:inset-0 aperture:size-full\"\n />\n {(shownPointers ? [...pointers] : []).map(([id, point]) => {\n const member = presence.members.find((one) => one.id === id);\n if (member === undefined) {\n return null;\n }\n return (\n <div\n key={id}\n data-member-pointer={id}\n className=\"aperture:absolute aperture:top-0 aperture:left-0 aperture:flex aperture:items-start aperture:gap-0.5 aperture:transition-transform aperture:duration-75 aperture:ease-linear\"\n style={{\n transform: `translate(${point.x * scale}px, ${point.y * scale}px)`,\n color: memberColor(member),\n }}\n >\n <MousePointer2 className=\"aperture:size-4 aperture:fill-current aperture:drop-shadow\" />\n <span\n className=\"aperture:mt-3 aperture:max-w-32 aperture:truncate aperture:rounded-full aperture:px-1.5 aperture:py-0.5 aperture:text-[0.625rem] aperture:leading-none aperture:font-medium aperture:text-white aperture:shadow\"\n style={{ backgroundColor: memberColor(member) }}\n >\n {member.agent ? automationName(member) : member.name}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** Draws a stroke through its points, rounded; one point is a dot. */\nfunction trace(context: CanvasRenderingContext2D, points: readonly Point[]) {\n const [first, ...rest] = points;\n if (first === undefined) {\n return;\n }\n if (rest.length === 0) {\n context.beginPath();\n context.arc(first.x, first.y, context.lineWidth / 2, 0, Math.PI * 2);\n context.fill();\n return;\n }\n context.beginPath();\n context.moveTo(first.x, first.y);\n let last = first;\n for (const point of rest) {\n // Through the middle of each stretch, bent at the points: a hand's line has no corners.\n context.quadraticCurveTo(last.x, last.y, (last.x + point.x) / 2, (last.y + point.y) / 2);\n last = point;\n }\n context.lineTo(last.x, last.y);\n context.stroke();\n}\n","import type { ReactNode } from \"react\";\nimport { AppWindow, Eye, Loader2, Plus, RotateCcw, Unplug } from \"lucide-react\";\nimport { Badge } from \"@aperture-browser/ui/components/badge\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from \"@aperture-browser/ui/components/empty\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useLease, useReconnect, useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { MemberMarks } from \"./member-marks.tsx\";\nimport { LeaseOverlay } from \"./session-presence.tsx\";\nimport { SessionViewport } from \"./session-viewport.tsx\";\n\nexport interface BrowserViewportProps {\n readonly className?: string | undefined;\n}\n\n/**\n * The picture with what the workbench lays over it: the connection's state, the lease, and\n * what is contributed to `viewport`.\n */\nexport function BrowserViewport({ className }: BrowserViewportProps) {\n const showLease = useWorkbench().features.presence;\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const reconnect = useReconnect();\n const lease = useLease();\n const { connection } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const open = connection.state === \"open\";\n\n return (\n <SessionViewport className={cn(\"aperture:bg-muted/40\", className)}>\n {connection.state === \"connecting\" ? (\n <Placeholder>\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Connecting to the session\n </Placeholder>\n ) : null}\n {connection.state === \"closed\" ? (\n <div className=\"aperture:absolute aperture:inset-0 aperture:z-20 aperture:flex aperture:items-center aperture:justify-center aperture:bg-background/80 aperture:backdrop-blur-sm\">\n <Empty className=\"aperture:border-none\" data-session-closed=\"\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Unplug />\n </EmptyMedia>\n <EmptyTitle>Disconnected from the session</EmptyTitle>\n <EmptyDescription>\n {connection.reason === undefined || connection.reason === \"\"\n ? \"The connection to the session closed.\"\n : connection.reason}\n </EmptyDescription>\n </EmptyHeader>\n {reconnect === undefined ? null : (\n <EmptyContent>\n <Button type=\"button\" size=\"sm\" onClick={() => reconnect()}>\n <RotateCcw />\n Reconnect\n </Button>\n </EmptyContent>\n )}\n </Empty>\n </div>\n ) : null}\n {open && snapshot.targets.length === 0 ? (\n <Empty\n className=\"aperture:absolute aperture:inset-0 aperture:border-none\"\n data-session-empty=\"\"\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <AppWindow />\n </EmptyMedia>\n <EmptyTitle>No tabs</EmptyTitle>\n <EmptyDescription>The session's browser has no tab open.</EmptyDescription>\n </EmptyHeader>\n {snapshot.features.tabs.write ? (\n <EmptyContent>\n <Button type=\"button\" size=\"sm\" onClick={() => session.newTab()}>\n <Plus />\n New tab\n </Button>\n </EmptyContent>\n ) : null}\n </Empty>\n ) : null}\n {open && snapshot.targets.length > 0 && watched === undefined ? (\n <Placeholder>\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Waiting for a tab\n </Placeholder>\n ) : null}\n {open && showLease ? <MemberMarks /> : null}\n {open && showLease ? <LeaseOverlay /> : null}\n {open && showLease && lease.state === \"view-only\" ? (\n <div\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:left-2 aperture:z-10\",\n // A phone's bar is over the picture's foot.\n snapshot.phone ? \"aperture:top-2\" : \"aperture:bottom-2\",\n )}\n >\n <Badge variant=\"outline\" className=\"aperture:bg-background/90\" data-session-view-only=\"\">\n <Eye />\n View only\n </Badge>\n </div>\n ) : null}\n <WorkbenchSlot name=\"viewport\" />\n </SessionViewport>\n );\n}\n\nfunction Placeholder({ children }: { children: ReactNode }) {\n return (\n <div className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:flex aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-2 aperture:text-sm aperture:text-muted-foreground\">\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { Dialog as DialogPrimitive } from \"@base-ui/react/dialog\";\n\nimport { cn } from \"../utils.ts\";\nimport { Button } from \"./button.tsx\";\nimport { XIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\nimport { ScrollArea } from \"./scroll-area.tsx\";\n\n/** What opens over a dialog from within it, while it is open: a list, a menu. */\nconst POPUPS = [\n '[data-slot=\"select-content\"][data-open]',\n '[data-slot=\"combobox-content\"][data-open]',\n '[data-slot$=\"menu-content\"][data-open]',\n '[data-slot=\"popover-content\"][data-open]',\n].join(\", \");\n\n/**\n * The presses of Escape that found something open over a dialog. They are noted before\n * anything hears them: what was open closes on the same press, and is closed by the time\n * the dialog is asked to.\n */\nconst forPopup = new WeakSet<Event>();\nif (typeof window !== \"undefined\") {\n window.addEventListener(\n \"keydown\",\n (event) => {\n if (event.key === \"Escape\" && document.querySelector(POPUPS) !== null) {\n forPopup.add(event);\n }\n },\n true,\n );\n}\n\nfunction Dialog({\n onOpenChange,\n dismissible = true,\n ...props\n}: DialogPrimitive.Root.Props & {\n /**\n * Whether Escape and a press beside it close it. Not where it shows what is shown once:\n * that is closed by a button of its own, and by nothing done in passing.\n */\n dismissible?: boolean;\n}) {\n return (\n <DialogPrimitive.Root\n data-slot=\"dialog\"\n onOpenChange={(open, details) => {\n if (\n !open &&\n !dismissible &&\n (details.reason === \"escape-key\" || details.reason === \"outside-press\")\n ) {\n details.cancel();\n return;\n }\n // Escape closes what opened last: a list that is open over the dialog, and not the\n // dialog with what was typed into it.\n if (!open && details.reason === \"escape-key\" && forPopup.has(details.event)) {\n details.cancel();\n return;\n }\n onOpenChange?.(open, details);\n }}\n {...props}\n />\n );\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" container={container} {...props} />;\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot=\"dialog-overlay\"\n // Over a dialog it opened from as well: that one is behind it, and is seen to be.\n forceRender\n className={cn(\n \"aperture:fixed aperture:inset-0 aperture:isolate aperture:z-50 aperture:bg-black/10 aperture:duration-100 aperture:supports-backdrop-filter:backdrop-blur-xs aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** What a dialog is whichever way it stands: a column, a sheet at the foot on a phone. */\nconst CONTENT =\n // A column no taller than what is seen of the window: its header, its footer and\n // what else stands in it take the room they need, whatever the size of what is\n // pressed, and a `DialogBody` among them gives way and scrolls. With no body the\n // whole of it scrolls. On a phone it is a sheet at the foot, above the keyboard.\n \"aperture:group/dialog aperture:fixed aperture:inset-x-0 aperture:bottom-(--keyboard-inset,0px) aperture:z-50 aperture:flex aperture:max-h-[calc(100dvh-0.75rem-env(safe-area-inset-top)-var(--keyboard-inset,0px)-var(--keyboard-top,0px))] aperture:w-full aperture:max-w-none aperture:flex-col aperture:gap-4 aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-t-xl aperture:bg-popover aperture:p-4 aperture:pb-(--dialog-pad-bottom) aperture:text-sm aperture:[--dialog-pad-bottom:max(1rem,env(safe-area-inset-bottom))] aperture:sm:[--dialog-pad-bottom:1rem] aperture:text-popover-foreground aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-closed:animate-out aperture:data-closed:fade-out-0 aperture:data-open:animate-in aperture:data-open:fade-in-0\";\n\n/** In the middle of the window, where the window is wider than a phone's. */\nconst MODAL =\n \"aperture:data-closed:slide-out-to-bottom-2 aperture:data-open:slide-in-from-bottom-2 aperture:sm:top-[calc(var(--keyboard-top,0px)+(100svh-var(--keyboard-top,0px)-var(--keyboard-inset,0px))/2)] aperture:sm:left-1/2 aperture:sm:bottom-auto aperture:sm:max-h-[calc(100svh-2rem-var(--keyboard-top,0px)-var(--keyboard-inset,0px))] aperture:sm:max-w-md aperture:sm:-translate-x-1/2 aperture:sm:-translate-y-1/2 aperture:sm:rounded-xl aperture:sm:data-closed:zoom-out-95 aperture:sm:data-open:zoom-in-95\";\n\n/**\n * At the window's right edge and as tall as what is seen of the window, where the window is\n * wider than a phone's: its header and footer stay, and its body has what is left.\n */\nconst SIDE =\n \"aperture:max-sm:data-closed:slide-out-to-bottom-2 aperture:max-sm:data-open:slide-in-from-bottom-2 aperture:sm:top-[calc(var(--keyboard-top,0px)+env(safe-area-inset-top))] aperture:sm:right-[env(safe-area-inset-right)] aperture:sm:bottom-(--keyboard-inset,0px) aperture:sm:left-auto aperture:sm:max-h-none aperture:sm:max-w-lg aperture:sm:rounded-none aperture:sm:shadow-lg aperture:sm:duration-200 aperture:sm:data-closed:slide-out-to-right-8 aperture:sm:data-open:slide-in-from-right-8\";\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n side,\n ...props\n}: DialogPrimitive.Popup.Props & {\n showCloseButton?: boolean;\n /**\n * Where it stands in a window wider than a phone's: at that edge, as tall as the window,\n * for what shows or changes a thing among others, or has much in it. In the middle,\n * without. On a phone it is a sheet at the foot either way.\n */\n side?: \"right\";\n}) {\n return (\n <DialogPortal>\n {/* As long on its way as what it is behind. */}\n <DialogOverlay className={side === undefined ? undefined : \"aperture:sm:duration-200\"} />\n <DialogPrimitive.Popup\n data-slot=\"dialog-content\"\n data-side={side}\n className={cn(CONTENT, side === undefined ? MODAL : SIDE, className)}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n render={\n <Button\n variant=\"ghost\"\n className=\"aperture:absolute aperture:top-2 aperture:right-2 aperture:pointer-coarse:top-1 aperture:pointer-coarse:right-1\"\n size=\"icon-sm\"\n />\n }\n >\n <XIcon />\n <span className=\"aperture:sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Popup>\n </DialogPortal>\n );\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(\n // Beside the button that closes it, where there is one.\n \"aperture:flex aperture:min-w-0 aperture:shrink-0 aperture:flex-col aperture:gap-2 aperture:pb-2 aperture:group-has-[>[data-slot=dialog-close]]/dialog:pr-8\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/**\n * What a dialog holds between its header and footer: the part of it that gives way where\n * the window is short, and scrolls then. Its class is for how what it holds is laid out.\n */\nfunction DialogBody({\n className,\n height,\n style,\n ...props\n}: Omit<React.ComponentProps<typeof ScrollArea>, \"style\"> & {\n /**\n * How tall it is whatever it holds, as a CSS length, where what it holds changes while the\n * dialog is open: tabs, a list that loads or grows. The room for the tallest of what it\n * shows, so that the dialog is as tall for each. Where what it holds is what is pressed,\n * the length counts those in `--control-height`, which is more where a finger presses.\n * Left out, it is as tall as what it holds. At a window's side the dialog is as tall as\n * the window whatever it holds, and its body has what is left of that.\n */\n height?: string;\n style?: React.CSSProperties;\n}) {\n return (\n <ScrollArea\n data-slot=\"dialog-body\"\n className={cn(\n // Out to the dialog's edges, so the rings of what has the focus are not cut off; and\n // further at its foot, where what stands out of the last thing it holds would\n // have it scroll: the line kept for what a field's rules say, the room a finger\n // has around a switch.\n \"aperture:-mx-4 aperture:-mt-1 aperture:-mb-2 aperture:flex aperture:min-h-0 aperture:flex-col\",\n height === undefined\n ? \"aperture:shrink aperture:grow-0 aperture:basis-auto\"\n : \"aperture:shrink aperture:grow-0 aperture:basis-(--dialog-body-height)\",\n \"aperture:sm:group-data-[side=right]/dialog:grow aperture:sm:group-data-[side=right]/dialog:basis-0\",\n )}\n style={\n height === undefined\n ? style\n : ({ \"--dialog-body-height\": height, ...style } as React.CSSProperties)\n }\n viewportClassName={cn(\n \"aperture:flex aperture:h-auto aperture:min-h-0 aperture:flex-1 aperture:flex-col aperture:gap-4 aperture:px-4 aperture:pt-1 aperture:pb-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n showCloseButton?: boolean;\n}) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n // On a phone it stays at the sheet's foot while what is above it scrolls, clear of\n // the home indicator.\n \"aperture:-mx-4 aperture:-mb-(--dialog-pad-bottom) aperture:flex aperture:shrink-0 aperture:gap-2 aperture:max-sm:*:min-w-0 aperture:max-sm:*:flex-1 aperture:border-t aperture:bg-[color-mix(in_oklch,var(--popover),var(--muted)_50%)] aperture:p-4 aperture:pb-(--dialog-pad-bottom) aperture:max-sm:sticky aperture:max-sm:-bottom-(--dialog-pad-bottom) aperture:sm:justify-end aperture:sm:rounded-b-xl aperture:sm:group-data-[side=right]/dialog:mt-auto aperture:sm:group-data-[side=right]/dialog:rounded-none\",\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant=\"outline\" />}>Close</DialogPrimitive.Close>\n )}\n </div>\n );\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn(\n \"aperture:min-w-0 aperture:text-base aperture:leading-tight aperture:font-medium aperture:wrap-anywhere\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn(\n \"aperture:min-w-0 aperture:text-sm aperture:text-muted-foreground aperture:wrap-anywhere aperture:*:[a]:underline aperture:*:[a]:underline-offset-3 aperture:*:[a]:hover:text-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n Dialog,\n DialogBody,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport type { Recording } from \"@aperture-browser/session-client\";\nimport {\n Camera,\n ChevronLeft,\n ChevronRight,\n Download,\n Film,\n PanelRight,\n Pause,\n Play,\n Scissors,\n Volume2,\n VolumeX,\n X,\n} from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogTitle,\n} from \"@aperture-browser/ui/components/dialog\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { keptOf, recordingIsEdited, type Kept } from \"../hooks/use-recordings.ts\";\nimport {\n useRecordingTimeline,\n type RecordingTimeline,\n type TimelineEvent,\n} from \"../hooks/use-timeline.ts\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { formatDuration, formatStarted, Thumbnail } from \"./menu-parts.tsx\";\nimport {\n editOptions,\n editSettings,\n EditSettingsItems,\n KeptFacts,\n keptPreview,\n type EditSettings,\n} from \"./recording-menu.tsx\";\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/** What the dialog is as wide as until what it shows has told its size. */\nconst UNKNOWN: Size = { width: 1280, height: 720 };\n\n/** How long the bars over the picture stay once the pointer rests. */\nconst BARS_STAY_MS = 2500;\n\nconst BAR =\n \"aperture:absolute aperture:inset-x-0 aperture:z-10 aperture:flex aperture:items-center aperture:gap-2 aperture:bg-background/70 aperture:backdrop-blur-md aperture:transition-opacity aperture:duration-200\";\n\n/**\n * One of the session's recordings or screenshots, as large as the window lets it be and no\n * larger than it is: a screenshot as the picture it is, a recording in a player that shows\n * what happened in it. The others are a panel away. Opened by the workbench's `view`.\n */\nexport function KeptGallery() {\n const { recordings, viewed, view } = useWorkbench();\n const session = useSession();\n const kept = keptOf(recordings);\n // What was shown stays while the dialog closes: it leaves as it was, not emptied.\n const last = useRef(viewed);\n if (viewed !== undefined) {\n last.current = viewed;\n }\n const showing = viewed ?? last.current;\n const at = kept.findIndex((one) => one.id === showing);\n const shown = kept[at];\n const [listed, setListed] = useState(false);\n const [size, setSize] = useState<{ id: string; size: Size } | undefined>(undefined);\n const content =\n (size !== undefined && size.id === shown?.id ? size.size : undefined) ?? sizeOf(shown);\n\n // The bars show while the pointer moves, and while it rests on one of them.\n const [moved, setMoved] = useState(0);\n const [awake, setAwake] = useState(true);\n const [onBar, setOnBar] = useState(false);\n const [resting, setResting] = useState(true);\n useEffect(() => {\n setAwake(true);\n const sleeping = setTimeout(() => setAwake(false), BARS_STAY_MS);\n return () => clearTimeout(sleeping);\n }, [moved, showing]);\n const bars =\n awake || onBar || listed || shown === undefined || (shown.kind === \"recording\" && resting);\n const bar = {\n \"data-kept-bars\": bars ? \"shown\" : \"hidden\",\n onPointerEnter: () => setOnBar(true),\n onPointerLeave: () => setOnBar(false),\n };\n const hidden = bars ? undefined : \"aperture:pointer-events-none aperture:opacity-0\";\n\n const step = (by: number) => {\n const next = kept[at + by];\n if (next !== undefined) {\n view(next.id);\n }\n };\n\n return (\n <Dialog\n open={viewed !== undefined}\n onOpenChange={(open) => {\n if (!open) {\n view(undefined);\n setListed(false);\n }\n }}\n >\n <DialogContent\n data-kept-gallery=\"\"\n showCloseButton={false}\n className=\"aperture:flex aperture:max-w-none aperture:min-w-[min(26rem,calc(100vw-1rem))] aperture:flex-col aperture:gap-0 aperture:overflow-hidden aperture:bg-black aperture:p-0 aperture:max-sm:mx-auto aperture:sm:max-w-none\"\n style={{\n // As wide as the picture, and as the window's width and height leave it.\n width: `min(${content.width}px, calc(100vw - 2rem), calc((100svh - 2rem) * ${content.width / content.height}))`,\n }}\n onPointerMove={() => setMoved((count) => count + 1)}\n onKeyDown={() => setMoved((count) => count + 1)}\n >\n <div\n className={cn(\"aperture:relative aperture:w-full\", !bars && \"aperture:cursor-none\")}\n style={{ aspectRatio: `${content.width} / ${content.height}` }}\n >\n {shown === undefined ? (\n <p className=\"aperture:flex aperture:size-full aperture:items-center aperture:justify-center aperture:px-4 aperture:text-center aperture:text-sm aperture:text-white/80\">\n It is no longer in the session's files.\n </p>\n ) : shown.kind === \"screenshot\" ? (\n <img\n key={shown.id}\n data-kept-shown=\"screenshot\"\n src={session.fileUrl(shown.screenshot.file)}\n alt=\"\"\n className=\"aperture:size-full aperture:object-contain\"\n />\n ) : (\n <RecordingView\n key={shown.id}\n kept={shown}\n bar={bar}\n hidden={hidden}\n onSize={(told) => setSize({ id: shown.id, size: told })}\n onResting={setResting}\n />\n )}\n <header\n {...bar}\n className={cn(BAR, \"aperture:top-0 aperture:h-9 aperture:pr-1 aperture:pl-3\", hidden)}\n >\n <DialogTitle className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-baseline aperture:gap-2 aperture:text-xs aperture:font-normal\">\n <span className=\"aperture:shrink-0 aperture:font-medium aperture:tabular-nums\">\n {shown === undefined ? \"Recordings and screenshots\" : formatStarted(shown.at)}\n </span>\n {shown === undefined ? null : <KeptFacts kept={shown} />}\n {shown === undefined ? null : (\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:text-muted-foreground\">\n {pageOf(shown)}\n </span>\n )}\n </DialogTitle>\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center\">\n {shown?.kind === \"screenshot\" ? (\n <FileLinks\n href={session.fileUrl(shown.screenshot.file)}\n file={shown.screenshot.file}\n />\n ) : null}\n <BarButton label=\"Newer\" disabled={at <= 0} onClick={() => step(-1)}>\n <ChevronLeft />\n </BarButton>\n <BarButton\n label=\"Older\"\n disabled={at < 0 || at >= kept.length - 1}\n onClick={() => step(1)}\n >\n <ChevronRight />\n </BarButton>\n <BarButton\n label=\"All recordings and screenshots\"\n pressed={listed}\n data-kept-list-button=\"\"\n onClick={() => setListed(!listed)}\n >\n <PanelRight />\n </BarButton>\n <DialogClose\n render={<Button type=\"button\" variant=\"ghost\" size=\"icon-xs\" aria-label=\"Close\" />}\n >\n <X />\n </DialogClose>\n </div>\n </header>\n {listed ? (\n <KeptList\n kept={kept}\n viewed={showing}\n onView={(id) => {\n view(id);\n setListed(false);\n }}\n />\n ) : null}\n </div>\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The size a kept thing says it has, before its picture is there to tell. */\nfunction sizeOf(kept: Kept | undefined): Size {\n if (kept?.kind === \"screenshot\" && kept.screenshot.width > 0 && kept.screenshot.height > 0) {\n return { width: kept.screenshot.width, height: kept.screenshot.height };\n }\n return UNKNOWN;\n}\n\n/** The page a kept thing is of. */\nfunction pageOf(kept: Kept): string {\n const { title, url } = kept.kind === \"screenshot\" ? kept.screenshot : kept.recording;\n return title.trim() === \"\" ? url : title;\n}\n\nfunction BarButton({\n label,\n pressed,\n children,\n ...props\n}: {\n label: string;\n pressed?: boolean;\n children: ReactNode;\n} & Omit<React.ComponentProps<typeof Button>, \"children\">) {\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={label}\n title={label}\n aria-pressed={pressed}\n className={cn(pressed && \"aperture:bg-foreground/10\")}\n {...props}\n >\n {children}\n </Button>\n );\n}\n\n/**\n * The link every kept file has, to a file on this machine. A file of the session's is\n * shown here or kept, and is no page of its own: the session answers with it as a file.\n */\nfunction FileLinks({ href, file }: { href: string; file: string }) {\n return (\n <Button\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Download\"\n title=\"Download\"\n render={<a href={href} download={file.split(\"/\").at(-1) ?? \"\"} />}\n >\n <Download />\n </Button>\n );\n}\n\nfunction RecordingView({\n kept,\n bar,\n hidden,\n onSize,\n onResting,\n}: {\n kept: Kept & { kind: \"recording\" };\n /** What makes the player's bar one of the bars over the picture. */\n bar: Record<string, unknown>;\n /** The classes that hide the bars, while they are hidden. */\n hidden: string | undefined;\n onSize: (size: Size) => void;\n /** Tells whether the video rests, which keeps the bars in sight. */\n onResting: (resting: boolean) => void;\n}) {\n const session = useSession();\n const { recording } = kept;\n const timeline = useRecordingTimeline(recording);\n const edited =\n recording.edit?.state === \"finished\" && recording.edit.file !== null\n ? recording.edit.file\n : undefined;\n // The edit is what a recording was made for, and what every browser plays.\n const [raw, setRaw] = useState(false);\n const playsRaw = raw || edited === undefined;\n const file = playsRaw ? recording.file : (edited ?? recording.file);\n // An edit that was made again has the file of the one before, and is another video.\n const made = playsRaw ? null : (recording.edit?.made_at_ms ?? null);\n const src = made === null ? session.fileUrl(file) : madeAt(session.fileUrl(file), made);\n const videoRef = useRef<HTMLVideoElement>(null);\n const [playing, setPlaying] = useState(false);\n const [muted, setMuted] = useState(false);\n const [time, setTime] = useState(0);\n const [length, setLength] = useState(0);\n const [failed, setFailed] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n onResting(!playing);\n return () => onResting(true);\n }, [playing, onResting]);\n\n // The playhead moves with the picture, which says where it is less often than it is drawn.\n useEffect(() => {\n if (!playing) {\n return undefined;\n }\n let frame = requestAnimationFrame(function follow() {\n setTime(videoRef.current?.currentTime ?? 0);\n frame = requestAnimationFrame(follow);\n });\n return () => cancelAnimationFrame(frame);\n }, [playing]);\n\n const told = playsRaw ? timeline?.duration_ms : timeline?.edited_duration_ms;\n const duration = told === undefined ? length : told / 1000;\n\n const toggle = () => {\n const video = videoRef.current;\n if (video === null) {\n return;\n }\n if (video.paused) {\n void video.play().catch(() => {});\n } else {\n video.pause();\n }\n };\n\n const seek = (seconds: number) => {\n const video = videoRef.current;\n if (video !== null) {\n video.currentTime = Math.min(Math.max(seconds, 0), duration);\n setTime(video.currentTime);\n }\n };\n\n return (\n <div\n className=\"aperture:flex aperture:size-full aperture:items-center aperture:justify-center\"\n onKeyDown={(event) => {\n if (event.key === \" \" && !(event.target instanceof HTMLButtonElement)) {\n event.preventDefault();\n toggle();\n }\n if (event.key === \"ArrowLeft\") {\n seek(time - 5);\n }\n if (event.key === \"ArrowRight\") {\n seek(time + 5);\n }\n }}\n >\n {failed === undefined ? (\n <video\n key={src}\n ref={videoRef}\n data-kept-shown=\"recording\"\n src={src}\n poster={keptPreview(kept, session.fileUrl)}\n playsInline\n preload=\"metadata\"\n muted={muted}\n onClick={toggle}\n onPlay={() => setPlaying(true)}\n onPause={() => setPlaying(false)}\n onEnded={() => setPlaying(false)}\n onLoadedMetadata={(event) => {\n const video = event.currentTarget;\n setLength(Number.isFinite(video.duration) ? video.duration : 0);\n setTime(0);\n if (video.videoWidth > 0 && video.videoHeight > 0) {\n onSize({ width: video.videoWidth, height: video.videoHeight });\n }\n }}\n onTimeUpdate={(event) => setTime(event.currentTarget.currentTime)}\n onError={() =>\n setFailed(\n recording.failure ??\n (playsRaw && edited !== undefined\n ? \"This browser does not play the raw recording. Download it, or watch the edit.\"\n : \"This browser does not play the file. Download it instead.\"),\n )\n }\n className=\"aperture:size-full aperture:object-contain aperture:outline-none\"\n />\n ) : (\n <p className=\"aperture:max-w-sm aperture:px-4 aperture:text-center aperture:text-sm aperture:text-white/80\">\n {failed}\n </p>\n )}\n <div\n {...bar}\n data-kept-player=\"\"\n className={cn(BAR, \"aperture:bottom-0 aperture:h-9 aperture:px-1\", hidden)}\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={playing ? \"Pause\" : \"Play\"}\n disabled={failed !== undefined}\n onClick={toggle}\n >\n {playing ? <Pause /> : <Play />}\n </Button>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {formatDuration(time * 1000)} / {formatDuration(duration * 1000)}\n </span>\n <Track duration={duration} time={time} timeline={timeline} raw={playsRaw} onSeek={seek} />\n {edited === undefined ? null : (\n <div className=\"aperture:flex aperture:shrink-0 aperture:rounded-md aperture:bg-foreground/10 aperture:p-0.5\">\n {[false, true].map((one) => (\n <button\n key={String(one)}\n type=\"button\"\n aria-pressed={raw === one}\n title={one ? \"The video as it was recorded\" : \"With the cuts and marks of its edit\"}\n className={cn(\n \"aperture:rounded aperture:px-1.5 aperture:text-xs aperture:leading-5 aperture:outline-none aperture:focus-visible:ring-2 aperture:focus-visible:ring-ring\",\n raw === one\n ? \"aperture:bg-background aperture:shadow-xs\"\n : \"aperture:text-muted-foreground aperture:hover:text-foreground\",\n )}\n onClick={() => {\n setRaw(one);\n setFailed(undefined);\n setPlaying(false);\n }}\n >\n {one ? \"Raw\" : \"Edit\"}\n </button>\n ))}\n </div>\n )}\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center\">\n <EditAgain recording={recording} />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={muted ? \"Unmute\" : \"Mute\"}\n aria-pressed={muted}\n onClick={() => setMuted(!muted)}\n >\n {muted ? <VolumeX /> : <Volume2 />}\n </Button>\n <FileLinks href={src} file={file} />\n </div>\n </div>\n </div>\n );\n}\n\n/**\n * Makes the edit of a recording again, of the same raw video and as chosen here: what the\n * edit there is was made with, until something else is. The new edit takes its place.\n */\nfunction EditAgain({ recording }: { recording: Recording }) {\n const { recordings } = useWorkbench();\n const allowed = useSessionSnapshot().features.recordings.write;\n const [chosen, setChosen] = useState<EditSettings | undefined>(undefined);\n const settings = chosen ?? editSettings(recording.edit?.options);\n const editing = recordingIsEdited(recording);\n\n // A session that makes no edits has none to make again, and a recording that failed has\n // no video to make one of.\n if (recording.edit === null || recording.state !== \"finished\") {\n return null;\n }\n const edit = () => {\n recordings.edit(recording.id, editOptions(settings)).then(\n () => setChosen(undefined),\n (cause: unknown) =>\n showNotice({\n level: \"error\",\n message: \"The recording was not edited again\",\n description: failureText(cause),\n }),\n );\n };\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Edit again…\"\n title={editing ? \"The edit is being made\" : \"Edit again…\"}\n data-kept-edit-again=\"\"\n disabled={editing || !allowed}\n />\n }\n >\n <Scissors />\n </DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"end\" className=\"aperture:w-64\">\n <DropdownMenuLabel>Edit again</DropdownMenuLabel>\n <EditSettingsItems settings={settings} onChange={setChosen} />\n <DropdownMenuSeparator />\n <DropdownMenuItem data-kept-edit-make=\"\" onClick={edit}>\n <Scissors />\n Make the edit\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** A file's address as of one making of it, which no cache has for another. */\nfunction madeAt(address: string, made: number): string {\n const url = new URL(address);\n url.searchParams.set(\"made\", String(made));\n return url.toString();\n}\n\n/** What an event of the timeline is, in a few words. */\nfunction eventLabel(event: TimelineEvent): string {\n const text = (field: string) => {\n const value = event[field];\n return typeof value === \"string\" ? value : undefined;\n };\n switch (event.kind) {\n case \"call\": {\n return `${text(\"tool\") ?? \"tool\"}${event.ok === false ? \" (failed)\" : \"\"}`;\n }\n case \"press\": {\n const button = text(\"button\") ?? \"left\";\n const times = event.count === 2 ? \"double \" : \"\";\n return button === \"left\" ? `${times}click` : `${times}${button} click`;\n }\n case \"wheel\": {\n return \"scroll\";\n }\n case \"caption\": {\n return text(\"text\") ?? \"caption\";\n }\n default: {\n return event.kind;\n }\n }\n}\n\n/** Pointer moves and wheel turns no further apart than this are one run of them. */\nconst RUN_GAP_MS = 300;\n\n/** A stretch of the track: where it is, and what the edit made of it. */\ninterface Stretch {\n readonly start: number;\n readonly end: number;\n readonly note: string;\n readonly cut: boolean;\n}\n\n/** The stretches the edit sped up or cut, in the time of the video that plays. */\nfunction stretches(timeline: RecordingTimeline, raw: boolean): readonly Stretch[] {\n const found: Stretch[] = [];\n let before = 0;\n for (const piece of timeline.map) {\n if (raw && piece.raw_start_ms > before) {\n found.push({ start: before, end: piece.raw_start_ms, note: \"Cut from the edit\", cut: true });\n }\n before = piece.raw_end_ms;\n if (piece.speed > 1) {\n const length = piece.raw_end_ms - piece.raw_start_ms;\n found.push({\n start: raw ? piece.raw_start_ms : piece.edited_start_ms,\n end: raw ? piece.raw_end_ms : piece.edited_start_ms + length / piece.speed,\n note: raw\n ? `${piece.speed}× faster in the edit`\n : `${piece.speed}× faster than it happened`,\n cut: false,\n });\n }\n }\n if (raw && timeline.duration_ms > before) {\n found.push({ start: before, end: timeline.duration_ms, note: \"Cut from the edit\", cut: true });\n }\n return found;\n}\n\n/**\n * The player's track: where the picture is, where to take it, and what happened when. The\n * automation's tools are bars above the line, clicks are dots on it, and the stretches the\n * edit sped up or cut are marked along it. Pointing tells what is there.\n */\nfunction Track({\n duration,\n time,\n timeline,\n raw,\n onSeek,\n}: {\n /** In seconds, as `time` is. */\n duration: number;\n time: number;\n timeline: RecordingTimeline | undefined;\n /** The raw video plays, and not its edit. */\n raw: boolean;\n onSeek: (seconds: number) => void;\n}) {\n const trackRef = useRef<HTMLDivElement>(null);\n const [pointed, setPointed] = useState<number | undefined>(undefined);\n const total = Math.max(duration * 1000, 1);\n const share = (ms: number) => `${Math.min(Math.max(ms / total, 0), 1) * 100}%`;\n const span = (event: TimelineEvent) =>\n raw\n ? ([event.at_ms, event.end_ms] as const)\n : ([event.edited_at_ms, event.edited_end_ms] as const);\n const events = timeline?.events ?? [];\n const calls = events.filter((event) => event.kind === \"call\");\n const marks = events.filter((event) => ![\"call\", \"move\", \"wheel\"].includes(event.kind));\n // The pointer's way and the wheel's turns are many small events: each run of them is one.\n const runs = (kind: string, label: string) => {\n const found: { start: number; end: number; label: string }[] = [];\n for (const event of events) {\n if (event.kind !== kind) {\n continue;\n }\n const [start, end] = span(event);\n const before = found.at(-1);\n if (before !== undefined && start - before.end <= RUN_GAP_MS) {\n before.end = Math.max(before.end, end);\n } else {\n found.push({ start, end, label });\n }\n }\n return found;\n };\n const moves = [...runs(\"move\", \"pointer moves\"), ...runs(\"wheel\", \"scroll\")];\n const marked = timeline === undefined ? [] : stretches(timeline, raw);\n\n const msAt = (clientX: number) => {\n const box = trackRef.current?.getBoundingClientRect();\n if (box === undefined || box.width === 0) {\n return 0;\n }\n return Math.min(Math.max((clientX - box.left) / box.width, 0), 1) * total;\n };\n\n // What is near enough to the pointer to be meant: a few pixels of the track either way.\n const near = total * 0.012;\n const there =\n pointed === undefined\n ? []\n : [\n ...calls.filter(\n (event) => span(event)[0] - near <= pointed && pointed <= span(event)[1] + near,\n ),\n ...marks.filter((event) => Math.abs(span(event)[0] - pointed) <= near),\n ];\n const moving =\n pointed === undefined\n ? []\n : moves.filter((run) => run.start - near <= pointed && pointed <= run.end + near);\n const stretch = marked.find(\n (one) => pointed !== undefined && one.start <= pointed && pointed <= one.end,\n );\n\n return (\n <div\n ref={trackRef}\n data-kept-track=\"\"\n role=\"slider\"\n tabIndex={0}\n aria-label=\"Position in the recording\"\n aria-valuemin={0}\n aria-valuemax={Math.round(duration)}\n aria-valuenow={Math.round(time)}\n aria-valuetext={formatDuration(time * 1000)}\n className=\"aperture:relative aperture:h-9 aperture:min-w-0 aperture:flex-1 aperture:cursor-pointer aperture:touch-none aperture:outline-none\"\n onPointerDown={(event) => {\n onSeek(msAt(event.clientX) / 1000);\n // The drag goes on outside the track; a pointer that cannot be held still seeks.\n try {\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {\n // Followed while it is over the track.\n }\n }}\n onPointerMove={(event) => {\n setPointed(msAt(event.clientX));\n if (event.buttons === 1) {\n onSeek(msAt(event.clientX) / 1000);\n }\n }}\n onPointerLeave={() => setPointed(undefined)}\n >\n {moves.map((run, index) => (\n <span\n key={index}\n data-kept-run={run.label}\n className=\"aperture:absolute aperture:top-1.5 aperture:h-0.5 aperture:min-w-0.5 aperture:rounded-full aperture:bg-foreground/35\"\n style={{ left: share(run.start), width: `calc(${share(run.end)} - ${share(run.start)})` }}\n />\n ))}\n {calls.map((event, index) => (\n <span\n key={index}\n data-kept-call=\"\"\n className={cn(\n \"aperture:absolute aperture:top-2.5 aperture:h-1 aperture:min-w-1 aperture:rounded-full\",\n event.ok === false ? \"aperture:bg-destructive\" : \"aperture:bg-sky-500\",\n )}\n style={{\n left: share(span(event)[0]),\n width: `calc(${share(span(event)[1])} - ${share(span(event)[0])})`,\n }}\n />\n ))}\n <span className=\"aperture:absolute aperture:inset-x-0 aperture:top-5 aperture:h-1 aperture:overflow-hidden aperture:rounded-full aperture:bg-foreground/15\">\n {marked.map((one, index) => (\n <span\n key={index}\n className={cn(\n \"aperture:absolute aperture:inset-y-0\",\n one.cut ? \"aperture:bg-foreground/35\" : \"aperture:bg-amber-500/60\",\n )}\n style={{\n left: share(one.start),\n width: `calc(${share(one.end)} - ${share(one.start)})`,\n }}\n />\n ))}\n <span\n className=\"aperture:absolute aperture:inset-y-0 aperture:left-0 aperture:bg-primary/70\"\n style={{ width: share(time * 1000) }}\n />\n </span>\n {marks.map((event, index) => (\n <span\n key={index}\n data-kept-mark={event.kind}\n className={cn(\n \"aperture:absolute aperture:top-4.5 aperture:size-2 aperture:-translate-x-1/2 aperture:rounded-full aperture:ring-1 aperture:ring-background\",\n event.kind === \"caption\" ? \"aperture:bg-amber-500\" : \"aperture:bg-foreground/70\",\n )}\n style={{ left: share(span(event)[0]) }}\n />\n ))}\n <span\n className=\"aperture:absolute aperture:top-3.5 aperture:h-4 aperture:w-0.5 aperture:-translate-x-1/2 aperture:rounded-full aperture:bg-primary\"\n style={{ left: share(time * 1000) }}\n />\n {pointed === undefined ? null : (\n <span\n data-kept-track-tip=\"\"\n className=\"aperture:pointer-events-none aperture:absolute aperture:bottom-full aperture:z-10 aperture:mb-1 aperture:flex aperture:w-max aperture:max-w-64 aperture:-translate-x-1/2 aperture:flex-col aperture:gap-0.5 aperture:rounded-md aperture:bg-popover aperture:px-2 aperture:py-1 aperture:text-xs aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10\"\n style={{ left: `clamp(4rem, ${share(pointed)}, calc(100% - 4rem))` }}\n >\n <span className=\"aperture:text-muted-foreground aperture:tabular-nums\">\n {formatDuration(pointed)}\n </span>\n {there.slice(0, 4).map((event, index) => (\n <span key={index} className=\"aperture:truncate\">\n {eventLabel(event)}\n {span(event)[1] - span(event)[0] >= 100 ? (\n <span className=\"aperture:text-muted-foreground\">\n {\" \"}\n · {((span(event)[1] - span(event)[0]) / 1000).toFixed(1)} s\n </span>\n ) : null}\n </span>\n ))}\n {there.length === 0\n ? moving.slice(0, 2).map((run, index) => <span key={index}>{run.label}</span>)\n : null}\n {stretch === undefined ? null : (\n <span className=\"aperture:text-muted-foreground\">{stretch.note}</span>\n )}\n </span>\n )}\n </div>\n );\n}\n\n/** Everything kept, as a panel over the picture's right side. */\nfunction KeptList({\n kept,\n viewed,\n onView,\n}: {\n kept: readonly Kept[];\n viewed: string | undefined;\n onView: (id: string) => void;\n}) {\n const session = useSession();\n\n return (\n <div\n data-kept-list=\"\"\n className=\"aperture:absolute aperture:top-9 aperture:right-0 aperture:bottom-0 aperture:z-20 aperture:flex aperture:w-72 aperture:max-w-full aperture:flex-col aperture:gap-0.5 aperture:overflow-y-auto aperture:border-l aperture:bg-popover aperture:p-1.5 aperture:shadow-lg aperture:animate-in aperture:slide-in-from-right-4 aperture:fade-in-0 aperture:duration-150\"\n >\n {kept.map((one) => (\n <button\n key={one.id}\n type=\"button\"\n aria-current={one.id === viewed}\n className={cn(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:p-1.5 aperture:text-left aperture:text-sm aperture:outline-none aperture:hover:bg-muted aperture:focus-visible:bg-muted\",\n one.id === viewed && \"aperture:bg-muted\",\n )}\n onClick={() => onView(one.id)}\n >\n <Thumbnail src={keptPreview(one, session.fileUrl)}>\n {one.kind === \"recording\" ? <Film /> : <Camera />}\n </Thumbnail>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:tabular-nums\">{formatStarted(one.at)}</span>\n <KeptFacts kept={one} />\n </span>\n </button>\n ))}\n </div>\n );\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport { Plus, Smartphone, X } from \"lucide-react\";\nimport type { Presence, Session, Target } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Drawer,\n DrawerBody,\n DrawerContent,\n DrawerDescription,\n DrawerTitle,\n type DrawerSide,\n} from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { TabFavicon, tabLabel } from \"./browser-tab-strip.tsx\";\nimport { automationName, MemberDot } from \"./session-presence.tsx\";\n\n/** How much of the window's height the sheet takes: as it opens, and dragged up. */\nconst HEIGHTS = [0.5, 1];\n\n/** How often the picture of a tab that is in view is asked for again. */\nconst PICTURE_EVERY_MS = 4000;\n\n/** The picture each tab was last shown with, which is there at once the next time. */\nconst lastPictures = new Map<string, { readonly tag: string | null; readonly url: string }>();\n\nexport interface TabSwitcherProps {\n /** The edge of the window it comes in from: a side's where the phone is held on its side. */\n readonly side?: DrawerSide;\n readonly open: boolean;\n readonly onOpenChange: (open: boolean) => void;\n}\n\n/**\n * The session's tabs as cards, each with a small picture of its page: the way from one tab\n * to another where there is no room for a row of them. It is a sheet over the window's\n * foot, half of the way up, that is dragged up for more of them and down to be rid of it;\n * a tab that is chosen and a press beside it are rid of it as well. At a side of the\n * window it is as tall as the window, with the cards two abreast, dragged to that side.\n */\nexport function TabSwitcher({ side = \"bottom\", open, onOpenChange }: TabSwitcherProps) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, targetFaviconUrl } = useWorkbench();\n const { changes } = useInputState();\n const snaps = side === \"bottom\";\n const { targets, presence } = snapshot;\n const [height, setHeight] = useState<number | string | null>(HEIGHTS[0] ?? null);\n // Each time it opens it is part of the way up again.\n useEffect(() => {\n if (open) {\n setHeight(HEIGHTS[0] ?? null);\n }\n }, [open]);\n\n return (\n <Drawer\n side={side}\n open={open}\n onOpenChange={onOpenChange}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: HEIGHTS } : {})}\n >\n <DrawerContent\n data-workbench-tab-switcher=\"\"\n data-height={!snaps || height === HEIGHTS[1] ? \"full\" : \"part\"}\n className={cn(\n snaps &&\n \"aperture:h-full aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\",\n )}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:gap-2 aperture:pr-3 aperture:pl-4 aperture:select-none\">\n <DrawerTitle className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {targets.length === 1 ? \"1 tab\" : `${targets.length} tabs`}\n </DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n The session's tabs. Choose one to watch it.\n </DrawerDescription>\n <Button\n type=\"button\"\n variant=\"secondary\"\n data-tab-switcher-new=\"\"\n disabled={!changes}\n onClick={() => {\n session.newTab();\n onOpenChange(false);\n }}\n >\n <Plus />\n New tab\n </Button>\n </div>\n <DrawerBody\n role=\"list\"\n className={cn(\n \"aperture:grid aperture:auto-rows-min aperture:gap-3 aperture:px-3 aperture:pt-1 aperture:pb-[max(1rem,env(safe-area-inset-bottom))]\",\n snaps\n ? \"aperture:grid-cols-[repeat(auto-fill,minmax(9.5rem,1fr))]\"\n : \"aperture:grid-cols-2\",\n )}\n >\n {targets.map((target) => (\n <TabCard\n key={target.tab}\n target={target}\n active={target.tab === snapshot.selected}\n presence={features.presence ? presence : undefined}\n faviconSrc={targetFaviconUrl(target)}\n wide={!snaps}\n closes={changes}\n onSelect={() => {\n session.select(target.tab);\n onOpenChange(false);\n }}\n onClose={() => session.closeTab(target.tab)}\n />\n ))}\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n\nfunction TabCard({\n target,\n active,\n presence,\n faviconSrc,\n wide,\n closes,\n onSelect,\n onClose,\n}: {\n target: Target;\n active: boolean;\n presence: Presence | undefined;\n faviconSrc: string | undefined;\n /** The picture is as a page on a phone held on its side: wider than tall. */\n wide: boolean;\n closes: boolean;\n onSelect: () => void;\n onClose: () => void;\n}) {\n const card = useRef<HTMLDivElement>(null);\n const inView = useInView(card);\n const label = tabLabel(target);\n const held = presence?.held.find((one) => one.tab === target.tab);\n const holder = presence?.members.find((member) => member.id === held?.holder);\n const watchers =\n presence?.members.filter((member) => member.tab === target.tab && member.id !== holder?.id) ??\n [];\n const holds =\n holder === undefined\n ? undefined\n : holder.id === presence?.you\n ? \"You\"\n : holder.agent\n ? automationName(holder)\n : holder.name;\n\n return (\n <div\n ref={card}\n role=\"listitem\"\n data-tab-card={target.tab}\n data-active={active ? \"\" : undefined}\n className={cn(\n \"aperture:relative aperture:flex aperture:min-w-0 aperture:flex-col aperture:overflow-hidden aperture:rounded-xl aperture:bg-card aperture:ring-1 aperture:ring-foreground/10\",\n active && \"aperture:ring-2 aperture:ring-primary\",\n )}\n >\n <button\n type=\"button\"\n aria-label={`Switch to ${label}`}\n aria-current={active ? \"true\" : undefined}\n className=\"aperture:absolute aperture:inset-0 aperture:z-10 aperture:rounded-xl aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\"\n onClick={onSelect}\n />\n <div className=\"aperture:flex aperture:h-10 aperture:shrink-0 aperture:items-center aperture:gap-1.5 aperture:pl-2.5\">\n <TabFavicon src={faviconSrc} />\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:text-xs aperture:font-medium\">\n {label}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={`Close ${label}`}\n data-tab-card-close=\"\"\n disabled={!closes}\n className=\"aperture:relative aperture:z-20 aperture:shrink-0 aperture:text-muted-foreground\"\n onClick={onClose}\n >\n <X />\n </Button>\n </div>\n <TabPicture target={target} asked={inView} wide={wide} />\n <div className=\"aperture:flex aperture:h-8 aperture:shrink-0 aperture:items-center aperture:gap-1.5 aperture:px-2.5 aperture:text-[0.6875rem] aperture:text-muted-foreground\">\n {target.mobile ? (\n <Smartphone\n aria-label=\"Shown as on a phone\"\n className=\"aperture:size-3 aperture:shrink-0\"\n />\n ) : null}\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {hostOf(target.url)}\n </span>\n {holder === undefined ? null : (\n <span\n data-tab-card-holder=\"\"\n className=\"aperture:flex aperture:max-w-[60%] aperture:shrink-0 aperture:items-center aperture:gap-1\"\n >\n <MemberDot member={holder} holds />\n <span className=\"aperture:truncate aperture:text-foreground\">{holds}</span>\n </span>\n )}\n {watchers.slice(0, 3).map((member) => (\n <MemberDot key={member.id} member={member} holds={false} />\n ))}\n </div>\n </div>\n );\n}\n\n/** What a tab's address says of where its page is from. */\nexport function hostOf(url: string): string {\n try {\n const parsed = new URL(url);\n return parsed.host === \"\"\n ? parsed.protocol.replace(/:$/u, \"\")\n : parsed.host.replace(/^www\\./u, \"\");\n } catch {\n return url;\n }\n}\n\nfunction TabPicture({ target, asked, wide }: { target: Target; asked: boolean; wide: boolean }) {\n const session = useSession();\n const src = useTabPicture(session, target, asked);\n return (\n <div\n className={cn(\n \"aperture:w-full aperture:overflow-hidden aperture:bg-muted\",\n wide ? \"aperture:aspect-[16/9]\" : \"aperture:aspect-[4/3]\",\n )}\n >\n {src === undefined ? null : (\n <img\n src={src}\n alt=\"\"\n data-tab-card-picture=\"\"\n className=\"aperture:size-full aperture:object-cover aperture:object-left-top\"\n />\n )}\n </div>\n );\n}\n\n/**\n * A tab's small picture, asked for again every while for as long as it is `asked` for.\n * The session makes one in a while and tells when it is the one this browser has already,\n * which then keeps the picture it shows.\n */\nfunction useTabPicture(session: Session, target: Target, asked: boolean): string | undefined {\n // By the target and not by the tab's number: another session's tab may have the number.\n const key = target.id;\n const [src, setSrc] = useState(() => lastPictures.get(key)?.url);\n const tab = target.tab;\n\n useEffect(() => {\n if (!asked) {\n return undefined;\n }\n let ended = false;\n const look = async () => {\n const answer = await fetch(session.previewUrl(tab), { cache: \"no-cache\" });\n if (!answer.ok || ended) {\n return;\n }\n const tag = answer.headers.get(\"etag\");\n const before = lastPictures.get(key);\n if (before !== undefined && tag !== null && before.tag === tag) {\n return;\n }\n const url = URL.createObjectURL(await answer.blob());\n if (ended) {\n URL.revokeObjectURL(url);\n return;\n }\n lastPictures.set(key, { tag, url });\n setSrc(url);\n if (before !== undefined) {\n // After the picture that replaces it is shown.\n setTimeout(() => URL.revokeObjectURL(before.url), 1000);\n }\n };\n // A picture that does not come leaves the one there is, or none.\n const again = () => void look().catch(() => undefined);\n again();\n const timer = setInterval(again, PICTURE_EVERY_MS);\n return () => {\n ended = true;\n clearInterval(timer);\n };\n }, [session, tab, key, asked]);\n\n return src;\n}\n\n/** Whether an element is where it can be seen. */\nfunction useInView(ref: React.RefObject<HTMLElement | null>): boolean {\n const [inView, setInView] = useState(false);\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return undefined;\n }\n if (typeof IntersectionObserver === \"undefined\") {\n setInView(true);\n return undefined;\n }\n const seen = new IntersectionObserver((entries) => {\n setInView(entries.some((entry) => entry.isIntersecting));\n });\n seen.observe(element);\n return () => seen.disconnect();\n }, [ref]);\n return inView;\n}\n","import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { ArrowLeft, Pencil, Search, X } from \"lucide-react\";\nimport type { Member, Presence } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Drawer,\n DrawerBody,\n DrawerContent,\n DrawerDescription,\n DrawerTitle,\n type DrawerSide,\n} from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useAddress } from \"../hooks/use-address.ts\";\nimport { usePhoneOnSide, useRailSide } from \"../hooks/use-media.ts\";\nimport { useLease, useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { CompactContext } from \"./browser-toolbar.tsx\";\nimport { BrowserViewport } from \"./browser-viewport.tsx\";\nimport { KeptGallery } from \"./kept-gallery.tsx\";\nimport { PageMenu } from \"./page-menu.tsx\";\nimport { PhoneMenu, PhoneMenuContext, type PhoneMenuState } from \"./phone-menu.tsx\";\nimport { useSessionFiles } from \"./session-files.tsx\";\nimport { automationName, MemberAvatar, MemberDot } from \"./session-presence.tsx\";\nimport { hostOf, TabSwitcher } from \"./tab-switcher.tsx\";\n\n/** How long the on-screen keyboard takes to be gone once what was typed into is left. */\nconst KEYBOARD_LEAVES_MS = 400;\n\nconst ROLES = { view: \"may watch\", control: \"may give input\", admin: \"admin\" } as const;\n\n/** What is pressed in the bar: round, and as large as a finger needs. */\nconst PRESSED = \"aperture:size-10 aperture:shrink-0 aperture:rounded-full\";\n\n/** What the bar and what stands for it while it is away are made of: the page shows through. */\nconst GLASS =\n \"aperture:bg-background/75 aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:backdrop-blur-xl aperture:backdrop-saturate-150\";\n\n/** How the bar comes and goes. */\nconst MOVES =\n \"aperture:transition-[translate,opacity,scale] aperture:duration-300 aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:motion-reduce:duration-0\";\n\n/**\n * Where the bar is laid: across the picture's `foot`, or as a rail along its `left` or\n * `right`, where the phone is held on its side and height is what there is least of.\n */\ntype BarLay = \"foot\" | \"left\" | \"right\";\n\n/** How much room beside the picture the rail needs to stand there and not over it. */\nconst RAIL_ROOM = 48;\n\n/** The picture as tall as it is with no keyboard over the window's foot. */\nconst UNDER_KEYBOARD = \"calc(100% + var(--keyboard-inset, 0px))\";\n\n/** How far down the page a finger moves it before the bar goes, and how far up before it is back. */\nconst HIDES_AFTER = 48;\nconst SHOWS_AFTER = 24;\n/** How long a finger rests before what it moved the page by counts anew. */\nconst DRAG_RESTS_MS = 400;\n/** How far a finger goes across the bar before it is a swipe and no press. */\nconst SWIPED_PX = 20;\nconst MARK_SWIPED_PX = 8;\n\n/** The page a tab shows, as far as another one brings the bar back: not what it scrolled to. */\nconst pageOf = (url: string) => {\n try {\n const parsed = new URL(url);\n return `${parsed.origin}${parsed.pathname}`;\n } catch {\n return url;\n }\n};\n\n/**\n * Where the bar is: `shown`; `away`, with a small mark standing for it at the picture's\n * foot; or `gone`, with nothing of it over the page at all.\n */\ntype BarPlace = \"shown\" | \"away\" | \"gone\";\n\n/**\n * Where the bar is, and the means to put it elsewhere.\n *\n * It goes when a finger moves the page down, and is back when one moves it up, however\n * little the page had left to go: it is the finger that is followed, not the page, so a\n * page that scrolls nowhere brings it back as well. Another page and another tab bring it\n * back, and it is shown for as long as `stays` holds.\n */\nfunction useBarPlace(stays: boolean) {\n const session = useSession();\n const watched = useWatchedTarget();\n const [place, setPlace] = useState<BarPlace>(\"shown\");\n const staying = useRef(stays);\n staying.current = stays;\n\n useEffect(() => {\n let moved = 0;\n let last = 0;\n return session.onDragged((by) => {\n // Along the page's width is no scrolling of it.\n if (Math.abs(by.y) <= Math.abs(by.x)) {\n return;\n }\n const now = performance.now();\n if (now - last > DRAG_RESTS_MS || Math.sign(by.y) !== Math.sign(moved)) {\n moved = 0;\n }\n last = now;\n moved += by.y;\n if (staying.current) {\n return;\n }\n if (moved > HIDES_AFTER) {\n // What was put out of the way altogether stays so.\n setPlace((before) => (before === \"shown\" ? \"away\" : before));\n } else if (moved < -SHOWS_AFTER) {\n setPlace(\"shown\");\n }\n });\n }, [session]);\n\n const page = watched === undefined ? undefined : `${watched.id} ${pageOf(watched.url)}`;\n useEffect(() => setPlace(\"shown\"), [page]);\n // What it was shown for leaves it shown, and what put it away meanwhile is done.\n useEffect(() => {\n if (stays) {\n setPlace(\"shown\");\n }\n }, [stays]);\n\n return [stays ? \"shown\" : place, setPlace] as const;\n}\n\n/**\n * Tells a swipe across the bar from a press: into the picture and out of it are what the\n * bar does with it, and the press that would follow a swipe is nobody's.\n */\nfunction useSwipe(lay: BarLay, swiped: (inward: boolean) => void, after = SWIPED_PX) {\n const from = useRef<{ x: number; y: number; done: boolean } | undefined>(undefined);\n return {\n onPointerDown: (event: React.PointerEvent) => {\n // What is pressed in a sheet opened from here is told here as well, and is no\n // swipe of this.\n const within = event.target instanceof Node && event.currentTarget.contains(event.target);\n from.current = within ? { x: event.clientX, y: event.clientY, done: false } : undefined;\n },\n onPointerMove: (event: React.PointerEvent) => {\n const began = from.current;\n if (began === undefined || began.done) {\n return;\n }\n const by = { x: event.clientX - began.x, y: event.clientY - began.y };\n const [across, along] = lay === \"foot\" ? [by.y, by.x] : [by.x, by.y];\n if (Math.abs(across) >= after && Math.abs(across) > Math.abs(along)) {\n began.done = true;\n swiped(lay === \"left\" ? across > 0 : across < 0);\n }\n },\n // A press that ended as none, as one whose finger left the bar, begins no swipe later.\n onPointerUp: () => {\n if (from.current?.done === false) {\n from.current = undefined;\n }\n },\n onPointerCancel: () => {\n from.current = undefined;\n },\n onClickCapture: (event: React.MouseEvent) => {\n if (from.current?.done === true) {\n event.preventDefault();\n event.stopPropagation();\n }\n from.current = undefined;\n },\n };\n}\n\n/**\n * How much room there is beside the workbench at a side of the window: what a screen's\n * cutout and corners keep the picture out of, where whoever shows the workbench leaves\n * that empty.\n */\nfunction useRoomBeside(root: React.RefObject<HTMLElement | null>, lay: BarLay): number {\n const [room, setRoom] = useState(0);\n useLayoutEffect(() => {\n const element = root.current;\n if (element === null || lay === \"foot\") {\n setRoom(0);\n return undefined;\n }\n const measure = () => {\n const box = element.getBoundingClientRect();\n const beside = lay === \"left\" ? box.left : window.innerWidth - box.right;\n setRoom(Math.max(0, Math.round(beside)));\n };\n measure();\n const resized = new ResizeObserver(measure);\n resized.observe(element);\n window.addEventListener(\"resize\", measure);\n return () => {\n resized.disconnect();\n window.removeEventListener(\"resize\", measure);\n };\n }, [root, lay]);\n return room;\n}\n\n/**\n * The workbench on a phone: the picture, and over it one bar with the way back, the\n * address, the tabs and a menu with all the rest.\n *\n * The bar is laid over the picture and takes none of its room: the page keeps its size\n * whether the bar is there or away, so nothing of it is drawn anew as the bar comes and\n * goes. It goes as the page is moved down, and a small mark stands for it, which is\n * swiped away where a page has something of its own under it; it is back as the page is\n * moved up or the mark is pressed.\n *\n * A phone held upright has the bar across the picture's foot. One held on its side has a\n * rail along a side of the picture in its place, since height is what there is least of:\n * the address is typed across the picture's head then, and what opens from the rail\n * comes in from its side. Where there is room beside the picture, as a screen's cutout\n * and corners leave, the rail stands there, over nothing, and stays.\n */\nexport function PhoneWorkbench() {\n const snapshot = useSessionSnapshot();\n const { features, drawing } = useWorkbench();\n const lease = useLease();\n const files = useSessionFiles({ sheet: true });\n const onSide = usePhoneOnSide();\n const railSide = useRailSide();\n const lay: BarLay = onSide ? railSide : \"foot\";\n const sheetSide = lay === \"foot\" ? \"bottom\" : lay;\n const root = useRef<HTMLDivElement>(null);\n const room = useRoomBeside(root, lay);\n const stands = room >= RAIL_ROOM;\n const stage = useRef<HTMLDivElement>(null);\n // The height the picture keeps while the address is typed: the keyboard that comes for\n // it covers the picture's foot, and is no reason to give the page another size.\n const [kept, setKept] = useState<number | string>();\n const leaving = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(leaving.current), []);\n const [editing, setEditing] = useState(false);\n const [switching, setSwitching] = useState(false);\n const [people, setPeople] = useState(false);\n const [menu, setMenu] = useState(false);\n const typed = useRef<HTMLElement | null>(null);\n\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n // The bar stays while it is used, while there is no page to move, and while someone\n // asks this member for the tab or a page asks for a file, which the bar tells of.\n const stays =\n stands ||\n editing ||\n switching ||\n people ||\n menu ||\n files.open ||\n files.request !== undefined ||\n drawing ||\n lease.state === \"asked-of-you\" ||\n snapshot.connection.state !== \"open\" ||\n watched === undefined;\n const [place, setPlace] = useBarPlace(stays);\n\n // A phone that is turned while the address is typed has another height to keep.\n const turned = useRef(lay);\n useEffect(() => {\n if (turned.current !== lay) {\n turned.current = lay;\n setKept((before) => (before === undefined ? undefined : UNDER_KEYBOARD));\n }\n }, [lay]);\n\n const edit = (now: boolean) => {\n clearTimeout(leaving.current);\n setEditing(now);\n if (now) {\n setKept(stage.current?.clientHeight);\n } else {\n leaving.current = setTimeout(() => setKept(undefined), KEYBOARD_LEAVES_MS);\n }\n };\n\n const shared = useMemo<PhoneMenuState>(\n () => ({ typed, hideBar: () => setPlace(\"away\"), files, side: sheetSide }),\n [files, sheetSide, setPlace],\n );\n\n return (\n <PhoneMenuContext.Provider value={shared}>\n <CompactContext.Provider value>\n <div\n ref={root}\n data-workbench-phone=\"\"\n data-bar={place}\n data-lay={lay}\n className=\"aperture:relative aperture:min-h-0 aperture:min-w-0 aperture:flex-1 aperture:overflow-hidden\"\n >\n <div\n ref={stage}\n className=\"aperture:absolute aperture:inset-x-0 aperture:top-0 aperture:flex aperture:flex-col aperture:overflow-hidden\"\n style={{ height: kept ?? \"100%\" }}\n >\n <BrowserViewport />\n </div>\n <PhoneBar\n lay={lay}\n beside={stands ? room : 0}\n away={place !== \"shown\"}\n editing={editing}\n menu={menu}\n onEdit={edit}\n onAway={() => setPlace(\"away\")}\n onSwitching={setSwitching}\n onPeople={setPeople}\n onMenu={setMenu}\n />\n <BarMark\n lay={lay}\n there={place === \"away\"}\n onShow={() => setPlace(\"shown\")}\n onGone={() => setPlace(\"gone\")}\n />\n {features.pageMenu ? <PageMenu /> : null}\n {features.recordings ? <KeptGallery /> : null}\n </div>\n {features.tabs ? (\n <TabSwitcher side={sheetSide} open={switching} onOpenChange={setSwitching} />\n ) : null}\n {features.presence ? (\n <PeopleSheet side={sheetSide} open={people} onOpenChange={setPeople} />\n ) : null}\n {features.files ? (\n <FilesSheet side={sheetSide} open={files.open} onOpenChange={files.setOpen}>\n {files.panel}\n </FilesSheet>\n ) : null}\n </CompactContext.Provider>\n </PhoneMenuContext.Provider>\n );\n}\n\nfunction PhoneBar({\n lay,\n beside,\n away,\n editing,\n menu,\n onEdit,\n onAway,\n onSwitching,\n onPeople,\n onMenu,\n}: {\n lay: BarLay;\n /** The room beside the picture a rail stands in, where it does not stand over it. */\n beside: number;\n away: boolean;\n editing: boolean;\n menu: boolean;\n onEdit: (editing: boolean) => void;\n onAway: () => void;\n onSwitching: (switching: boolean) => void;\n onPeople: (open: boolean) => void;\n onMenu: (open: boolean) => void;\n}) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, drawing, setDrawing } = useWorkbench();\n const input = useInputState();\n const watched = useWatchedTarget();\n const goes = input.changes && watched !== undefined;\n const open = snapshot.connection.state === \"open\";\n const rail = lay !== \"foot\" && !editing;\n // Into the picture for the tabs, out of it to put the bar away; neither while the\n // address is typed, nor the latter where the rail stays.\n const swipe = useSwipe(lay, (inward) => {\n if (editing) {\n return;\n }\n if (!inward) {\n if (beside === 0) {\n onAway();\n }\n } else if (features.tabs) {\n onSwitching(true);\n }\n });\n\n return (\n <div\n data-workbench-phone-bar=\"\"\n data-editing={editing ? \"\" : undefined}\n data-rail={rail ? lay : undefined}\n data-away={away ? \"\" : undefined}\n inert={away}\n className={cn(\n \"aperture:pointer-events-none aperture:z-30 aperture:flex aperture:justify-center\",\n // Beside the picture is outside of what the workbench is laid in, and may be\n // outside of what shows it as well: there the rail is laid by the window.\n rail && beside > 0 ? \"aperture:fixed\" : \"aperture:absolute\",\n MOVES,\n !rail &&\n (lay === \"foot\"\n ? \"aperture:inset-x-0 aperture:bottom-0 aperture:px-2 aperture:pb-1.5\"\n : // The keyboard is over the window's foot, so the address is typed at its head.\n \"aperture:inset-x-0 aperture:top-0 aperture:px-2 aperture:pt-1.5\"),\n rail && \"aperture:inset-y-0 aperture:items-center aperture:px-1\",\n rail && beside === 0 && (lay === \"left\" ? \"aperture:left-0\" : \"aperture:right-0\"),\n away &&\n (lay === \"foot\"\n ? \"aperture:translate-y-[calc(100%+0.5rem)] aperture:opacity-0\"\n : lay === \"left\"\n ? \"aperture:-translate-x-[calc(100%+0.5rem)] aperture:opacity-0\"\n : \"aperture:translate-x-[calc(100%+0.5rem)] aperture:opacity-0\"),\n )}\n style={rail && beside > 0 ? { [lay]: 0, width: beside, paddingInline: 0 } : undefined}\n >\n <div\n data-workbench-phone-pill=\"\"\n className={cn(\n \"aperture:pointer-events-auto aperture:relative aperture:flex aperture:min-w-0 aperture:touch-none aperture:items-center aperture:gap-0.5 aperture:rounded-full aperture:select-none\",\n rail\n ? \"aperture:max-h-full aperture:w-12 aperture:flex-col aperture:py-1\"\n : \"aperture:h-12 aperture:w-full aperture:px-1\",\n GLASS,\n )}\n {...swipe}\n >\n {editing ? (\n <AddressField onDone={() => onEdit(false)} />\n ) : (\n <>\n <WorkbenchSlot name=\"toolbar.start\" />\n {features.navigation ? (\n <BarButton\n label=\"Back\"\n className={PRESSED}\n disabled={!goes || watched?.goesBack !== true}\n onClick={() => session.go({ along: \"back\" })}\n >\n <ArrowLeft />\n </BarButton>\n ) : null}\n {features.addressBar ? (\n <AddressButton rail={rail} onEdit={() => onEdit(true)} />\n ) : (\n <div className=\"aperture:min-w-0 aperture:flex-1\" />\n )}\n {drawing ? (\n <BarButton\n label=\"Stop drawing\"\n variant=\"secondary\"\n aria-pressed\n className={PRESSED}\n onClick={() => setDrawing(false)}\n >\n <Pencil />\n </BarButton>\n ) : null}\n {features.presence && open ? (\n <PeopleButton rail={rail} onOpen={() => onPeople(true)} />\n ) : null}\n <WorkbenchSlot name=\"toolbar.end\" />\n {features.tabs ? (\n <BarButton\n label={`Tabs: ${snapshot.targets.length}`}\n data-workbench-tabs=\"\"\n className={PRESSED}\n onClick={() => onSwitching(true)}\n >\n <span className=\"aperture:flex aperture:size-5.5 aperture:items-center aperture:justify-center aperture:rounded-md aperture:border-[1.5px] aperture:border-current aperture:text-[0.6875rem] aperture:leading-none aperture:font-semibold aperture:tabular-nums\">\n {snapshot.targets.length > 99 ? \":)\" : snapshot.targets.length}\n </span>\n </BarButton>\n ) : null}\n {features.menus ? (\n <PhoneMenu open={menu} onOpenChange={onMenu} className={PRESSED} />\n ) : null}\n </>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * What stands for the bar while it is away: where the page is from and who else is here,\n * small, at the middle of the picture's foot; and for a rail a grip with who else is\n * here, at the middle of its side. Pressed or swiped into the picture, the bar is back;\n * swiped out of it, it is gone as well, for a page that has something of its own right\n * there.\n *\n * It is pressed where it is drawn and no further around it, smaller than a finger likes:\n * what it stands over is the page's, and the bar is back by moving the page up as well.\n */\nfunction BarMark({\n lay,\n there,\n onShow,\n onGone,\n}: {\n lay: BarLay;\n there: boolean;\n onShow: () => void;\n onGone: () => void;\n}) {\n const { features } = useWorkbench();\n const { presence, connection } = useSessionSnapshot();\n const watched = useWatchedTarget();\n // The window ends right beside it: a finger has little way to go out of it.\n const swipe = useSwipe(lay, (inward) => (inward ? onShow() : onGone()), MARK_SWIPED_PX);\n const others =\n features.presence && connection.state === \"open\"\n ? (presence?.members.filter((member) => member.id !== presence.you) ?? [])\n : [];\n const holds = (member: Member) =>\n presence?.held.some((held) => held.holder === member.id) ?? false;\n const host = watched === undefined ? \"\" : hostOf(watched.url);\n const foot = lay === \"foot\";\n\n return (\n <div\n inert={!there}\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:z-30 aperture:flex aperture:justify-center\",\n foot\n ? \"aperture:inset-x-0 aperture:bottom-0 aperture:pb-0.5\"\n : \"aperture:inset-y-0 aperture:items-center aperture:px-0.5\",\n lay === \"left\" && \"aperture:left-0\",\n lay === \"right\" && \"aperture:right-0\",\n MOVES,\n !there &&\n (foot\n ? \"aperture:translate-y-3 aperture:opacity-0\"\n : lay === \"left\"\n ? \"aperture:-translate-x-3 aperture:opacity-0\"\n : \"aperture:translate-x-3 aperture:opacity-0\"),\n )}\n >\n <button\n type=\"button\"\n data-workbench-phone-mark=\"\"\n aria-label=\"Show the bar\"\n className={cn(\n \"aperture:pointer-events-auto aperture:flex aperture:touch-none aperture:items-center aperture:justify-center aperture:gap-1 aperture:rounded-full aperture:text-[0.6875rem] aperture:leading-none aperture:font-medium aperture:outline-none aperture:select-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\",\n foot\n ? \"aperture:h-6 aperture:max-w-[60%] aperture:min-w-16 aperture:px-2.5\"\n : \"aperture:min-h-16 aperture:w-5 aperture:flex-col aperture:py-2.5\",\n GLASS,\n )}\n onClick={onShow}\n {...swipe}\n >\n {foot ? (\n <span className=\"aperture:truncate\">{host}</span>\n ) : (\n <span\n aria-hidden\n className=\"aperture:h-6 aperture:w-1 aperture:rounded-full aperture:bg-foreground/40\"\n />\n )}\n {others.slice(0, 3).map((member) => (\n <MemberDot key={member.id} member={member} holds={holds(member)} />\n ))}\n </button>\n </div>\n );\n}\n\nfunction BarButton({\n label,\n children,\n ...props\n}: { label: string; children: ReactNode } & Omit<\n React.ComponentProps<typeof Button>,\n \"children\" | \"aria-label\"\n>) {\n return (\n <Button type=\"button\" variant=\"ghost\" aria-label={label} {...props}>\n {children}\n </Button>\n );\n}\n\n/**\n * Where the watched tab's page is from, which is pressed to say where it is to go. A rail\n * has no room to say where the page is from: there it is the way to the address alone.\n */\nfunction AddressButton({ rail, onEdit }: { rail: boolean; onEdit: () => void }) {\n const address = useAddress();\n const watched = useWatchedTarget();\n const connecting = useSessionSnapshot().connection.state === \"connecting\";\n const shown = watched === undefined ? \"\" : hostOf(watched.url);\n\n return (\n <button\n type=\"button\"\n aria-label=\"Address\"\n title={rail ? shown : undefined}\n data-workbench-address-button=\"\"\n disabled={!address.navigates}\n className={cn(\n \"aperture:relative aperture:flex aperture:h-10 aperture:min-w-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:disabled:opacity-50\",\n rail\n ? \"aperture:w-10 aperture:shrink-0 aperture:active:bg-accent aperture:[&_svg]:size-4\"\n : \"aperture:flex-1 aperture:bg-foreground/6 aperture:px-3 aperture:text-sm\",\n )}\n onClick={onEdit}\n >\n {rail ? (\n <Search />\n ) : (\n <span className=\"aperture:truncate\">\n {connecting ? \"Connecting…\" : shown === \"\" ? \"Search or type an address\" : shown}\n </span>\n )}\n </button>\n );\n}\n\n/** The address as a field, across the bar, for as long as it is typed into. */\nfunction AddressField({ onDone }: { onDone: () => void }) {\n const address = useAddress();\n const field = useRef<HTMLInputElement>(null);\n\n // Within the tap that asked for it: a phone's keyboard comes for nothing later.\n useEffect(() => {\n field.current?.focus();\n field.current?.select();\n }, []);\n\n const leave = () => {\n address.reset();\n onDone();\n };\n\n return (\n <>\n <input\n ref={field}\n data-workbench-address=\"\"\n aria-label=\"Address\"\n value={address.value}\n onChange={(event) => address.type(event.target.value)}\n onBlur={leave}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (address.submit(event.currentTarget.value)) {\n event.currentTarget.blur();\n }\n }\n if (event.key === \"Escape\") {\n event.currentTarget.blur();\n }\n }}\n placeholder=\"Search or type an address\"\n inputMode=\"url\"\n enterKeyHint=\"go\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n // A phone zooms into a field whose text is smaller than this.\n className=\"aperture:h-10 aperture:min-w-0 aperture:flex-1 aperture:rounded-full aperture:bg-foreground/6 aperture:px-4 aperture:text-base aperture:outline-none\"\n />\n <BarButton\n label=\"Cancel\"\n className={PRESSED}\n // Before the field is left, which the press would otherwise be too late for.\n onPointerDown={(event) => event.preventDefault()}\n onClick={() => field.current?.blur()}\n >\n <X />\n </BarButton>\n </>\n );\n}\n\n/** The others in the session, as far as there is room; pressed, everyone. */\nfunction PeopleButton({ rail, onOpen }: { rail: boolean; onOpen: () => void }) {\n const { presence } = useSessionSnapshot();\n const others = presence?.members.filter((member) => member.id !== presence.you) ?? [];\n if (presence === undefined || others.length === 0) {\n return null;\n }\n const holds = (member: Member) => presence.held.some((held) => held.holder === member.id);\n const first = others.toSorted((left, right) => Number(holds(right)) - Number(holds(left)));\n const [shown] = first;\n const more = others.length - 1;\n\n return (\n <button\n type=\"button\"\n data-session-presence=\"\"\n aria-label={`${others.length + 1} people in the session`}\n className={cn(\n \"aperture:relative aperture:flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:gap-0.5 aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\",\n // Under the rail and not in it: the rail's buttons stay where they are as people\n // come and go, so a finger on its way to one does not land on another.\n rail\n ? cn(\n \"aperture:absolute aperture:top-full aperture:left-1/2 aperture:mt-1 aperture:min-h-12 aperture:w-12 aperture:-translate-x-1/2 aperture:flex-col aperture:py-1\",\n GLASS,\n )\n : \"aperture:h-10 aperture:min-w-10 aperture:px-1\",\n )}\n onClick={onOpen}\n >\n {shown === undefined ? null : <MemberAvatar member={shown} holds={holds(shown)} />}\n {more > 0 ? (\n <span className=\"aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:tabular-nums\">\n +{more}\n </span>\n ) : null}\n </button>\n );\n}\n\n/** Everyone in the session: what each may do, watches and holds, and following them. */\nfunction PeopleSheet({\n side,\n open,\n onOpenChange,\n}: {\n side: DrawerSide;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}) {\n const session = useSession();\n const { presence } = useSessionSnapshot();\n // Who was there stays while the sheet closes.\n const last = useRef<Presence | undefined>(presence);\n if (presence !== undefined) {\n last.current = presence;\n }\n const told = presence ?? last.current;\n const you = told?.members.find((member) => member.id === told.you);\n const members = (told?.members ?? []).toSorted(\n (left, right) => Number(right.id === told?.you) - Number(left.id === told?.you),\n );\n\n return (\n <Drawer side={side} open={open} onOpenChange={onOpenChange}>\n <DrawerContent\n data-workbench-people=\"\"\n className={cn(\n \"aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))]\",\n side === \"bottom\" &&\n \"aperture:max-h-[60%] aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\",\n )}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:px-4 aperture:select-none\">\n <DrawerTitle>In the session</DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n Who is in the session, and what each watches and holds.\n </DrawerDescription>\n </div>\n <DrawerBody render={<ul />} className=\"aperture:flex aperture:flex-col aperture:px-2\">\n {members.map((member) => {\n const held = told?.held.filter((one) => one.holder === member.id) ?? [];\n const followed = you?.follows === member.id;\n const said = [\n member.agent\n ? \"automation\"\n : member.role === undefined\n ? undefined\n : ROLES[member.role],\n member.tab === undefined ? undefined : `watches tab ${member.tab}`,\n held.length === 0 ? undefined : `holds tab ${held.map((one) => one.tab).join(\", \")}`,\n ].filter((part) => part !== undefined);\n return (\n <li\n key={member.id}\n data-member={member.id}\n className=\"aperture:flex aperture:min-h-14 aperture:items-center aperture:gap-3 aperture:px-2\"\n >\n <MemberAvatar member={member} holds={held.length > 0} />\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:truncate aperture:text-sm aperture:font-medium\">\n {member.agent ? automationName(member) : member.name}\n {member.id === told?.you ? \" (you)\" : \"\"}\n </span>\n <span className=\"aperture:truncate aperture:text-xs aperture:text-muted-foreground\">\n {said.join(\" · \")}\n </span>\n </span>\n {member.id === told?.you ? null : (\n <Button\n type=\"button\"\n variant={followed ? \"secondary\" : \"outline\"}\n aria-pressed={followed}\n data-member-follow={member.id}\n onClick={() => session.follow(followed ? undefined : member.id)}\n >\n {followed ? \"Following\" : \"Follow\"}\n </Button>\n )}\n </li>\n );\n })}\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n\n/** How much of the window's height the files take: as they open, and dragged up. */\nconst FILES_HEIGHTS = [0.5, 1];\n\n/** The session's files, as a sheet that is dragged like the others. */\nfunction FilesSheet({\n side,\n open,\n onOpenChange,\n children,\n}: {\n side: DrawerSide;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n}) {\n const [height, setHeight] = useState<number | string | null>(FILES_HEIGHTS[0] ?? null);\n // Each time it opens it is part of the way up again.\n useEffect(() => {\n if (open) {\n setHeight(FILES_HEIGHTS[0] ?? null);\n }\n }, [open]);\n const snaps = side === \"bottom\";\n\n return (\n <Drawer\n side={side}\n open={open}\n onOpenChange={onOpenChange}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: FILES_HEIGHTS } : {})}\n >\n <DrawerContent\n data-session-files=\"\"\n data-height={!snaps || height === FILES_HEIGHTS[1] ? \"full\" : \"part\"}\n className={cn(\n side === \"bottom\"\n ? \"aperture:h-full aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\"\n : \"aperture:pt-2\",\n )}\n >\n <DrawerTitle className=\"aperture:sr-only\">Files</DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n What was put into the session, and what its browser downloaded.\n </DrawerDescription>\n <DrawerBody className=\"aperture:pb-[env(safe-area-inset-bottom)]\">{children}</DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n","import { useMemo, type ReactNode } from \"react\";\nimport { resolveContributions, type WorkbenchContributions } from \"../workbench/contributions.ts\";\nimport {\n useWorkbench,\n WorkbenchProvider,\n type WorkbenchProviderProps,\n} from \"../workbench/context.tsx\";\nimport { workbenchContributions } from \"../workbench/own.ts\";\nimport { WorkbenchTitlebar, WorkbenchToolbar } from \"./browser-toolbar.tsx\";\nimport { BrowserViewport } from \"./browser-viewport.tsx\";\nimport { KeptGallery } from \"./kept-gallery.tsx\";\nimport { PageMenu } from \"./page-menu.tsx\";\nimport { PhoneWorkbench } from \"./phone-bar.tsx\";\nimport { usePhone } from \"../hooks/use-media.ts\";\n\nexport interface SessionWorkbenchProps extends Omit<\n WorkbenchProviderProps,\n \"contributions\" | \"children\"\n> {\n /**\n * More for the workbench's slots, each in place of the workbench's own of the same id;\n * or a function of the workbench's own that gives all there are to be.\n */\n readonly contributions?: WorkbenchContributions | undefined;\n /**\n * Another arrangement of the workbench's parts, in place of the usual one: the title\n * bar, the toolbar, the picture and the page's menu.\n */\n readonly children?: ReactNode;\n}\n\n/**\n * One session as a browser to work in: the tab strip with the session's members, the\n * toolbar with its menus, the picture, and the menu of a right click in it.\n */\nexport function SessionWorkbench({ contributions, children, ...provider }: SessionWorkbenchProps) {\n const resolved = useMemo(\n () => resolveContributions(workbenchContributions, contributions),\n [contributions],\n );\n\n return (\n <WorkbenchProvider {...provider} contributions={resolved}>\n <WorkbenchFrame>{children ?? <WorkbenchParts />}</WorkbenchFrame>\n </WorkbenchProvider>\n );\n}\n\n/** The box the workbench's parts stand in, one below the other. */\nexport function WorkbenchFrame({ children }: { readonly children?: ReactNode }) {\n return (\n <div\n data-session-workbench=\"\"\n className=\"aperture:flex aperture:h-full aperture:min-h-0 aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:overflow-hidden aperture:bg-background\"\n >\n {children}\n </div>\n );\n}\n\nfunction WorkbenchParts() {\n const { features } = useWorkbench();\n const phone = usePhone();\n if (phone) {\n return <PhoneWorkbench />;\n }\n return (\n <>\n <WorkbenchTitlebar />\n <WorkbenchToolbar />\n <BrowserViewport />\n {features.pageMenu ? <PageMenu /> : null}\n {features.recordings ? <KeptGallery /> : null}\n </>\n );\n}\n","import { useEffect, useState, type ReactNode } from \"react\";\nimport { TooltipProvider } from \"@aperture-browser/ui/components/tooltip\";\nimport { PortalContainerProvider } from \"@aperture-browser/ui/portal\";\nimport { cn } from \"@aperture-browser/ui/utils\";\n\nexport type ApertureTheme = \"light\" | \"dark\" | \"system\";\n\nexport interface ApertureUIRootProps {\n readonly theme?: ApertureTheme;\n readonly className?: string;\n readonly children?: ReactNode;\n}\n\nexport function ApertureUIRoot({ theme = \"system\", className, children }: ApertureUIRootProps) {\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const dark = useDarkTheme(theme);\n\n return (\n <div\n ref={setRoot}\n className={cn(\n \"aperture-root aperture:relative aperture:h-full aperture:w-full\",\n dark && \"aperture-dark\",\n className,\n )}\n >\n {root ? (\n <PortalContainerProvider container={root}>\n <TooltipProvider>{children}</TooltipProvider>\n </PortalContainerProvider>\n ) : null}\n </div>\n );\n}\n\nfunction useDarkTheme(theme: ApertureTheme): boolean {\n const [systemDark, setSystemDark] = useState(false);\n\n useEffect(() => {\n if (theme !== \"system\") {\n return;\n }\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const update = () => setSystemDark(query.matches);\n update();\n query.addEventListener(\"change\", update);\n return () => query.removeEventListener(\"change\", update);\n }, [theme]);\n\n return theme === \"dark\" || (theme === \"system\" && systemDark);\n}\n","import { useEffect } from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport type { ConnectOptions, Session } from \"@aperture-browser/session-client\";\nimport { Toaster } from \"@aperture-browser/ui/components/sonner\";\nimport { SessionWorkbench, type SessionWorkbenchProps } from \"./components/session-workbench.tsx\";\nimport type { ApertureSessionFeatures } from \"./features.ts\";\nimport { SessionProvider, useConnectedSession } from \"./session.tsx\";\nimport { ApertureUIRoot, type ApertureTheme } from \"./ui-root.tsx\";\n\nexport interface ApertureSessionProps\n extends ConnectOptions, Omit<SessionWorkbenchProps, \"features\" | \"appearance\" | \"children\"> {\n readonly features?: ApertureSessionFeatures | undefined;\n readonly theme?: ApertureTheme | undefined;\n /** With it, the browser menu offers to change the theme. */\n readonly onThemeChange?: ((theme: ApertureTheme) => void) | undefined;\n readonly className?: string | undefined;\n /** Hears of the session's client when there is one, and of none when it is closed. */\n readonly onSession?: ((session: Session | null) => void) | undefined;\n}\n\n/**\n * The workbench of one session: connects to it, shows it, and ends the connection when\n * unmounted. Needs `@aperture-browser/session-react/styles.css`.\n */\nexport function ApertureSession({\n url,\n token,\n name,\n pixels,\n features,\n theme = \"system\",\n onThemeChange,\n className,\n onSession,\n ...workbench\n}: ApertureSessionProps) {\n const { session, reconnect } = useConnectedSession({ url, token, name, pixels });\n\n useEffect(() => {\n if (session === null || onSession === undefined) {\n return undefined;\n }\n onSession(session);\n // Also when the component is unmounted, which no later render tells.\n return () => onSession(null);\n }, [onSession, session]);\n\n return (\n <ApertureUIRoot theme={theme} className={className}>\n {session === null ? (\n <div className=\"aperture:flex aperture:h-full aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-2 aperture:bg-background aperture:text-sm aperture:text-muted-foreground\">\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Connecting to the session\n </div>\n ) : (\n <SessionProvider session={session} reconnect={reconnect}>\n <SessionWorkbench\n {...workbench}\n features={features}\n appearance={onThemeChange === undefined ? undefined : { theme, onThemeChange }}\n />\n </SessionProvider>\n )}\n {features?.toaster === false ? null : (\n <Toaster\n theme={theme}\n richColors\n closeButton\n position=\"bottom-center\"\n // Above the bar a phone's workbench has over its foot, and the keyboard.\n mobileOffset={{\n bottom: \"calc(var(--keyboard-inset, 0px) + env(safe-area-inset-bottom, 0px) + 4.5rem)\",\n }}\n />\n )}\n </ApertureUIRoot>\n );\n}\n","import { useCallback, useEffect, useSyncExternalStore } from \"react\";\n\n/**\n * Tells the styles what of the window the on-screen keyboard leaves to be seen, where the\n * browser lays the page out behind the keyboard and does not make the window shorter for\n * it: how much of the window's foot is covered, as `--keyboard-inset`, and how far down the\n * window what is seen begins, as `--keyboard-top`, which is more than nothing where the\n * browser moved the window up to show what is typed into. A sheet at the foot stands above\n * the keyboard then, and is no taller than what is left.\n */\nexport function useKeyboardInset() {\n useEffect(() => {\n const viewport = window.visualViewport;\n if (viewport === null) {\n return undefined;\n }\n const root = document.documentElement;\n let revealing = 0;\n const tell = () => {\n // A page that is zoomed into shows less of itself with no keyboard there.\n const whole = Math.abs(viewport.scale - 1) < 0.01;\n const top = whole ? Math.max(0, viewport.offsetTop) : 0;\n const covered = whole ? Math.max(0, window.innerHeight - viewport.height - top) : 0;\n root.style.setProperty(\"--keyboard-inset\", `${Math.round(covered)}px`);\n root.style.setProperty(\"--keyboard-top\", `${Math.round(top)}px`);\n // What is typed into in a dialog may be under where the dialog now ends: it is brought\n // back into what the dialog shows, once the dialog is as tall as it is to be.\n cancelAnimationFrame(revealing);\n revealing = requestAnimationFrame(() => {\n const typed = document.activeElement;\n if (\n typed instanceof HTMLElement &&\n typed.matches(\"input, textarea\") &&\n typed.closest('[data-slot=\"dialog-content\"]') !== null\n ) {\n typed.scrollIntoView({ block: \"nearest\" });\n }\n });\n };\n tell();\n viewport.addEventListener(\"resize\", tell);\n viewport.addEventListener(\"scroll\", tell);\n return () => {\n cancelAnimationFrame(revealing);\n viewport.removeEventListener(\"resize\", tell);\n viewport.removeEventListener(\"scroll\", tell);\n root.style.removeProperty(\"--keyboard-inset\");\n root.style.removeProperty(\"--keyboard-top\");\n };\n }, []);\n}\n\n/**\n * What of the window's top and foot is not seen, mostly for an on-screen keyboard: for what\n * is placed by a script, and stays clear of it.\n */\nexport function useKeyboardCovered() {\n const subscribe = useCallback((tell: () => void) => {\n const viewport = window.visualViewport;\n viewport?.addEventListener(\"resize\", tell);\n viewport?.addEventListener(\"scroll\", tell);\n return () => {\n viewport?.removeEventListener(\"resize\", tell);\n viewport?.removeEventListener(\"scroll\", tell);\n };\n }, []);\n // One string, so that what is told is the same until it changes.\n const told = useSyncExternalStore(\n subscribe,\n () => {\n const viewport = window.visualViewport;\n if (viewport === null || Math.abs(viewport.scale - 1) >= 0.01) {\n return \"0 0\";\n }\n const top = Math.max(0, Math.round(viewport.offsetTop));\n return `${top} ${Math.max(0, Math.round(window.innerHeight - viewport.height - top))}`;\n },\n () => \"0 0\",\n );\n const [top = 0, bottom = 0] = told.split(\" \").map(Number);\n return { top, bottom };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAMA,aAAW,EAAE,GAAG,YAA0B;CAC9C,MAAM,EAAE,QAAQ,aAAa,SAAS;CAEtC,OACE,oBAACC,SAAD;EACS;EACP,WAAU;EACV,OAAO;GACL,SAAS,oBAAC,iBAAD,EAAiB,WAAU,kBAAmB,CAAA;GACvD,MAAM,oBAAC,UAAD,E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BAAkB,GAAG,KAAK,MAAM,GAAG,EAAE,GAAG;GAG/D,qBAAqB,SAAS;GAC9B,YAAY,4BAA4B;IACtC,MAAM,QAAQ,SAAS;IACvB,IACE,iBAAiB,eACjB,MAAM,QAAQ,iBAAiB,KAC/B,MAAM,QAAQ,gCAA8B,MAAM,MAElD,MAAM,eAAe,EAAE,OAAO,UAAU,CAAC;GAE7C,CAAC;EACH;EACA,KAAK;EACL,SAAS,iBAAiB,UAAU,IAAI;EACxC,SAAS,iBAAiB,UAAU,IAAI;EACxC,aAAa;GACX,qBAAqB,SAAS;GAC9B,SAAS,oBAAoB,UAAU,IAAI;GAC3C,SAAS,oBAAoB,UAAU,IAAI;GAC3C,KAAK,MAAM,eAAe,kBAAkB;GAC5C,KAAK,MAAM,eAAe,gBAAgB;EAC5C;CACF,GAAG,CAAC,CAAC;AACP"}
1
+ {"version":3,"file":"index.js","names":["Toaster","Sonner","SessionError","MOVES","Drawer","DrawerPrimitive","MenuPrimitive","Drawer","DrawerPrimitive","ContextMenu","ContextMenuPrimitive","Button","ButtonPrimitive","TooltipPrimitive","Tooltip","Tooltip","Button","Input","InputPrimitive","Input","PreviewCardPrimitive","ScrollArea","ScrollAreaPrimitive","Avatar","AvatarPrimitive","Popover","PopoverPrimitive","ROLES","Popover","Button","Tooltip","Avatar","ScrollArea","ContextMenu","Button","Tooltip","Button","Tooltip","Button","Button","Input","Tooltip","Popover","Tooltip","Button","Button","Dialog","DialogPrimitive","Button","Dialog","pageOf","BarButton","Button","Drawer","Button","Button","Drawer","Toaster"],"sources":["../../ui/src/components/sonner.tsx","../src/workbench/contributions.ts","../src/features.ts","../src/notices.ts","../src/workbench/context.tsx","../../ui/src/utils.ts","../../ui/src/portal.tsx","../../ui/src/components/drawer.tsx","../../ui/src/components/dropdown-menu.tsx","../../ui/src/components/context-menu.tsx","../src/workbench/slot.tsx","../src/components/page-menu.tsx","../../ui/src/components/spinner.tsx","../../ui/src/components/button.tsx","../../ui/src/components/tooltip.tsx","../src/components/menu-parts.tsx","../src/components/page-mode.tsx","../../ui/src/components/input.tsx","../../ui/src/components/input-group.tsx","../src/hooks/use-media.ts","../../ui/src/components/hover-card.tsx","../../ui/src/components/scroll-area.tsx","../../ui/src/components/avatar.tsx","../../ui/src/components/popover.tsx","../src/components/session-presence.tsx","../src/components/browser-tab-strip.tsx","../src/components/browser-toolbar.tsx","../src/components/toolbar-actions.tsx","../src/components/phone-menu.tsx","../src/hooks/use-pointers.ts","../src/components/picture-menu.tsx","../src/components/recording-menu.tsx","../src/components/session-files.tsx","../src/components/tab-menu.tsx","../src/workbench/own.ts","../../ui/src/components/badge.tsx","../../ui/src/components/empty.tsx","../src/components/member-marks.tsx","../src/components/browser-viewport.tsx","../../ui/src/components/dialog.tsx","../src/components/kept-gallery.tsx","../src/components/tab-switcher.tsx","../src/components/phone-bar.tsx","../src/components/session-workbench.tsx","../src/ui-root.tsx","../src/aperture-session.tsx","../../ui/src/keyboard-inset.ts"],"sourcesContent":["\"use client\";\n\nimport { useTheme } from \"next-themes\";\nimport { Toaster as Sonner, type ToasterProps } from \"sonner\";\nimport {\n CircleCheckIcon,\n InfoIcon,\n TriangleAlertIcon,\n OctagonXIcon,\n Loader2Icon,\n} from \"lucide-react\";\n\nconst Toaster = ({ ...props }: ToasterProps) => {\n const { theme = \"system\" } = useTheme();\n\n return (\n <Sonner\n theme={theme as ToasterProps[\"theme\"]}\n className=\"toaster aperture:group\"\n icons={{\n success: <CircleCheckIcon className=\"aperture:size-4\" />,\n info: <InfoIcon className=\"aperture:size-4\" />,\n warning: <TriangleAlertIcon className=\"aperture:size-4\" />,\n error: <OctagonXIcon className=\"aperture:size-4\" />,\n loading: <Loader2Icon className=\"aperture:size-4 aperture:animate-spin\" />,\n }}\n style={\n {\n \"--normal-bg\": \"var(--popover)\",\n \"--normal-text\": \"var(--popover-foreground)\",\n \"--normal-border\": \"var(--border)\",\n \"--border-radius\": \"var(--radius)\",\n } as React.CSSProperties\n }\n toastOptions={{\n classNames: {\n toast: \"cn-toast\",\n },\n }}\n {...props}\n />\n );\n};\n\nexport { Toaster };\n","import type { ComponentType } from \"react\";\nimport type { Target } from \"@aperture-browser/session-client\";\n\n/**\n * A place of the workbench that takes contributions.\n *\n * - `titlebar.start`, `titlebar.end`: beside the tab strip and the members.\n * - `toolbar.start`, `toolbar.end`: before the navigation buttons, and after the address.\n * - `toolbar.actions`: the buttons at the toolbar's end.\n * - `menu.browser`, `menu.picture`, `menu.recording`: the menus of those buttons.\n * - `menu.phone`: the menu of a phone's bar, in place of `menu.browser`.\n * - `menu.tab`: the menu of a right click on a tab, which is given as `target`.\n * - `menu.page`: the menu of a right click in the session.\n * - `viewport`: laid over the picture.\n *\n * On a phone the workbench is the picture with a bar over its foot: the toolbar's slots\n * are in the bar, and the title bar's slots and `menu.browser` are shown nowhere. The\n * bar's menu is `menu.phone`, a sheet whose submenus are pages of it: what is contributed\n * for a phone as well has a place there.\n */\nexport type WorkbenchSlotName =\n | \"titlebar.start\"\n | \"titlebar.end\"\n | \"toolbar.start\"\n | \"toolbar.end\"\n | \"toolbar.actions\"\n | \"menu.browser\"\n | \"menu.phone\"\n | \"menu.picture\"\n | \"menu.recording\"\n | \"menu.tab\"\n | \"menu.page\"\n | \"viewport\";\n\nexport interface WorkbenchSlotProps {\n /** The tab the menu is of, in `menu.tab`. */\n readonly target?: Target | undefined;\n}\n\n/**\n * One thing in one place of the workbench. Everything the workbench shows in its slots is\n * a contribution, its own included: one with the id of another takes its place.\n */\nexport interface WorkbenchContribution {\n readonly id: string;\n readonly slot: WorkbenchSlotName;\n /**\n * In a menu, the contributions of one group stand together, apart from the other groups.\n * Groups come in the order of their first contribution.\n */\n readonly group?: string | undefined;\n /** Lower comes first; the workbench's own are a hundred apart. */\n readonly order?: number | undefined;\n /**\n * What is shown. A menu's contribution renders items of the menu's kind: of a dropdown\n * menu, and in `menu.tab` of a context menu. Rendering nothing leaves no trace.\n */\n readonly component: ComponentType<WorkbenchSlotProps>;\n}\n\n/**\n * The contributions an embedder gives: more of them, each replacing the one of its id, or\n * a function of the workbench's own that gives all there are to be.\n */\nexport type WorkbenchContributions =\n | readonly WorkbenchContribution[]\n | ((own: readonly WorkbenchContribution[]) => readonly WorkbenchContribution[]);\n\nexport function resolveContributions(\n own: readonly WorkbenchContribution[],\n given: WorkbenchContributions | undefined,\n): readonly WorkbenchContribution[] {\n if (given === undefined) {\n return own;\n }\n if (typeof given === \"function\") {\n return given(own);\n }\n const replaced = new Set(given.map((one) => one.id));\n return [...own.filter((one) => !replaced.has(one.id)), ...given];\n}\n\n/** A slot's contributions in their order, by group. */\nexport function groupContributions(\n contributions: readonly WorkbenchContribution[],\n slot: WorkbenchSlotName,\n): ReadonlyArray<readonly [group: string, contributions: readonly WorkbenchContribution[]]> {\n const ordered = contributions\n .filter((one) => one.slot === slot)\n .toSorted((left, right) => (left.order ?? 0) - (right.order ?? 0));\n const groups = new Map<string, WorkbenchContribution[]>();\n for (const one of ordered) {\n const group = one.group ?? \"\";\n groups.set(group, [...(groups.get(group) ?? []), one]);\n }\n return [...groups];\n}\n","import type { Features } from \"@aperture-browser/session-client\";\n\n/** The parts of the workbench an embedder may leave out. All are shown unless said. */\nexport interface SessionFeatures {\n /** The tab strip. */\n readonly tabs?: boolean;\n /** Back, forward and reload. */\n readonly navigation?: boolean;\n readonly addressBar?: boolean;\n /** Who is in the session, and the lease of the watched tab. */\n readonly presence?: boolean;\n /** The buttons and menus at the toolbar's end. */\n readonly menus?: boolean;\n /** The session's files: uploads, downloads and what pages ask for. */\n readonly files?: boolean;\n readonly recordings?: boolean;\n /** The menu shown for a right click in the session. */\n readonly pageMenu?: boolean;\n /** Which tabs sound, and muting them. */\n readonly sound?: boolean;\n /** Copying from the session and pasting into it, from the menus. */\n readonly clipboard?: boolean;\n}\n\nexport interface ApertureSessionFeatures extends SessionFeatures {\n /** Notices as toasts. Without it the embedding page shows none of its own accord. */\n readonly toaster?: boolean;\n}\n\n/**\n * What the workbench shows: what the embedder did not leave out, of what this client may\n * read or write at all. `access` tells which of the two, for what depends on it.\n */\nexport interface ResolvedSessionFeatures extends Required<SessionFeatures> {\n readonly uploads: boolean;\n readonly downloads: boolean;\n readonly access: Features;\n}\n\nconst any = (grant: { readonly read: boolean; readonly write: boolean }) =>\n grant.read || grant.write;\n\nexport function resolveSessionFeatures(\n features: SessionFeatures | undefined,\n access: Features,\n): ResolvedSessionFeatures {\n const files = features?.files ?? true;\n const uploads = files && any(access.uploads);\n const downloads = files && access.downloads.read;\n return {\n tabs: true,\n navigation: true,\n addressBar: true,\n presence: true,\n menus: true,\n pageMenu: true,\n ...features,\n recordings: (features?.recordings ?? true) && any(access.recordings),\n clipboard: (features?.clipboard ?? true) && any(access.clipboard),\n sound: (features?.sound ?? true) && access.sound.read,\n uploads,\n downloads,\n files: uploads || downloads,\n access,\n };\n}\n","import { toast } from \"sonner\";\nimport { SessionError, type Session } from \"@aperture-browser/session-client\";\n\nexport interface SessionNotice {\n readonly level: \"info\" | \"error\";\n readonly message: string;\n readonly description?: string | undefined;\n}\n\nexport function showNotice(notice: SessionNotice): void {\n const options = notice.description === undefined ? {} : { description: notice.description };\n if (notice.level === \"error\") {\n toast.error(notice.message, options);\n } else {\n toast.success(notice.message, options);\n }\n}\n\n/** What a failed request to the session says, for a notice's second line. */\nexport function failureText(cause: unknown): string {\n if (cause instanceof SessionError) {\n return cause.status === 403 ? \"Your role in the session does not allow this.\" : cause.message;\n }\n return cause instanceof Error ? cause.message : \"The session could not be reached.\";\n}\n\n/**\n * Copies text to this browser's clipboard from a click, and tells how it went. A page may\n * always copy text from a click, so a failure is worth a notice.\n */\nexport function copyTextHere(session: Session, text: string, copied: string): void {\n session.copyHere([{ type: \"text/plain\", data: new TextEncoder().encode(text) }]).then(\n (written) => {\n showNotice(\n written\n ? { level: \"info\", message: copied }\n : { level: \"error\", message: \"This browser did not take the copy\" },\n );\n },\n () => showNotice({ level: \"error\", message: \"This browser did not take the copy\" }),\n );\n}\n\n/** Pastes this browser's clipboard into the session, and tells when there was nothing to. */\nexport function pasteHere(session: Session): void {\n const nothing = (description?: string) =>\n showNotice({ level: \"error\", message: \"Nothing was pasted\", description });\n session.paste().then(\n (pasted) => {\n if (!pasted) {\n nothing(\n \"This browser's clipboard is empty or may not be read by the page. Paste with the keyboard instead.\",\n );\n }\n },\n () => nothing(),\n );\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { toast } from \"sonner\";\nimport type { Recording, Session, Target } from \"@aperture-browser/session-client\";\nimport {\n resolveSessionFeatures,\n type ResolvedSessionFeatures,\n type SessionFeatures,\n} from \"../features.ts\";\nimport { useRememberedFit } from \"../hooks/use-fit.ts\";\nimport {\n recordingIsEdited,\n recordingRuns,\n useRecordings,\n type RecordingsControl,\n} from \"../hooks/use-recordings.ts\";\nimport { showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport type { ApertureTheme } from \"../ui-root.tsx\";\nimport type { WorkbenchContribution } from \"./contributions.ts\";\n\n/** The theme, where the embedding page lets the workbench's menu change it. */\nexport interface Appearance {\n readonly theme: ApertureTheme;\n readonly onThemeChange: (theme: ApertureTheme) => void;\n}\n\nexport interface Workbench {\n readonly features: ResolvedSessionFeatures;\n readonly recordings: RecordingsControl;\n readonly contributions: readonly WorkbenchContribution[];\n /** The id of the recording or screenshot the gallery shows; none while it is closed. */\n readonly viewed: string | undefined;\n readonly view: (id: string | undefined) => void;\n /** Whether this member draws over the picture, which then takes no input from it. */\n readonly drawing: boolean;\n readonly setDrawing: (drawing: boolean) => void;\n readonly appearance: Appearance | undefined;\n readonly targetFaviconUrl: (target: Target) => string | undefined;\n}\n\nconst WorkbenchContext = createContext<Workbench | null>(null);\n\nexport interface WorkbenchProviderProps {\n readonly features?: SessionFeatures | undefined;\n /** What the workbench's slots show; see `workbenchContributions` for its own. */\n readonly contributions: readonly WorkbenchContribution[];\n /**\n * Whether targets take the size of this window unless the person switched that off.\n * False leaves them the size they have until the person chooses another.\n */\n readonly fit?: boolean | undefined;\n /** Lets the browser menu change the theme. */\n readonly appearance?: Appearance | undefined;\n /**\n * A tab's icon, in place of the one the session fetches for its page. The session's\n * own browser asks the page's site for it, which is told nothing of who watches.\n */\n readonly targetFaviconUrl?: ((target: Target) => string | undefined) | undefined;\n readonly children?: ReactNode;\n}\n\n/**\n * What the parts of a workbench share: the session's recordings, what is shown, and what\n * is contributed to the slots. The parts work anywhere below it, in any arrangement.\n */\nexport function WorkbenchProvider({\n features: given,\n contributions,\n fit = true,\n appearance,\n targetFaviconUrl,\n children,\n}: WorkbenchProviderProps) {\n const offered = useSessionSnapshot().features;\n const features = useMemo(() => resolveSessionFeatures(given, offered), [given, offered]);\n const recordings = useRecordings(features.recordings);\n useClipboardNotices();\n useFailureNotices();\n useRecordingNotices(recordings);\n usePageModeNotices();\n useRememberedFit(fit);\n\n const session = useSession();\n const faviconUrl = targetFaviconUrl ?? session.faviconUrl;\n\n const [viewed, view] = useState<string | undefined>(undefined);\n const [drawing, setDrawing] = useState(false);\n useEscapeEndsDrawing(drawing, setDrawing);\n\n const value = useMemo(\n () => ({\n features,\n recordings,\n contributions,\n viewed,\n view,\n drawing,\n setDrawing,\n appearance,\n targetFaviconUrl: faviconUrl,\n }),\n [features, recordings, contributions, viewed, drawing, appearance, faviconUrl],\n );\n return <WorkbenchContext.Provider value={value}>{children}</WorkbenchContext.Provider>;\n}\n\n/**\n * Escape puts the pencil down. It is heard before the session's keyboard is, so the page\n * gets none of it; a menu or dialog that is open keeps its own Escape.\n */\nfunction useEscapeEndsDrawing(drawing: boolean, setDrawing: (drawing: boolean) => void) {\n useEffect(() => {\n if (!drawing) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n if (\n event.key !== \"Escape\" ||\n (event.target instanceof Element &&\n event.target.closest(\"[role=menu], [role=dialog], [role=listbox]\") !== null)\n ) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n setDrawing(false);\n };\n window.addEventListener(\"keydown\", onKey, true);\n return () => window.removeEventListener(\"keydown\", onKey, true);\n }, [drawing, setDrawing]);\n}\n\nexport function useWorkbench(): Workbench {\n const value = useContext(WorkbenchContext);\n if (value === null) {\n throw new Error(\"The workbench's parts are used outside a WorkbenchProvider\");\n }\n return value;\n}\n\n/**\n * What the session copied goes to this browser's clipboard by itself where the browser\n * lets a page write to it at any time. Where it does not, a notice offers the click that\n * the browser wants.\n */\nfunction useClipboardNotices() {\n const session = useSession();\n\n useEffect(() => {\n // Each is a notice of its own that takes the place of the one before: one that came\n // under the same name as a notice that is on its way out went out with it.\n let shown: string | number | undefined;\n return session.onClipboard((event) => {\n if (event.written) {\n return;\n }\n const picture = !event.forms.some((form) => form.type.startsWith(\"text/\"));\n if (shown !== undefined) {\n toast.dismiss(shown);\n }\n shown = toast(\"The session copied something\", {\n description: picture\n ? \"This browser did not take it. Open the picture to copy it by hand.\"\n : \"This browser did not take it without a click.\",\n duration: 15_000,\n action: {\n label: picture ? \"Open\" : \"Copy\",\n onClick: () => copyByHand(session, event.forms),\n },\n });\n });\n }, [session]);\n}\n\nconst NOT_DONE = {\n go: \"The page did not open\",\n close: \"The tab was not closed\",\n copyPicture: \"The picture was not copied\",\n chooseFiles: \"The page did not get the files\",\n follow: \"That member is not followed\",\n setMode: \"The tab is shown as it was\",\n} as const;\n\nfunction useFailureNotices() {\n const session = useSession();\n\n useEffect(\n () =>\n session.onFailure((failure) => {\n showNotice({\n level: \"error\",\n message:\n failure.asked === undefined ? \"The session did not do that\" : NOT_DONE[failure.asked],\n description: failure.reason,\n });\n }),\n [session],\n );\n}\n\n/**\n * A tab that goes by its holder is shown another way once this member holds it from\n * another kind of device, and the page it has stays as it loaded: a page that chose what\n * it looks like by the browser that asked for it is the other kind's until it loads again,\n * which a notice offers.\n */\nfunction usePageModeNotices() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const holds =\n snapshot.presence?.held.some(\n (held) => held.tab === watched?.tab && held.holder === snapshot.presence?.you,\n ) ?? false;\n const shown = watched === undefined ? undefined : `${watched.id} ${watched.mobile}`;\n const before = useRef<{ id: string; mobile: boolean; url: string } | undefined>(undefined);\n\n useEffect(() => {\n const was = before.current;\n before.current =\n watched === undefined\n ? undefined\n : { id: watched.id, mobile: watched.mobile, url: watched.url };\n if (\n watched === undefined ||\n was === undefined ||\n was.id !== watched.id ||\n was.mobile === watched.mobile ||\n watched.mode !== \"auto\" ||\n !holds ||\n // Nothing of the web is there to load again.\n !/^https?:/u.test(was.url)\n ) {\n return;\n }\n toast(\n watched.mobile\n ? \"This tab is now shown as on a phone\"\n : \"This tab is now shown as on a desktop\",\n {\n id: \"aperture-session-page-mode\",\n description: watched.mobile\n ? \"Reload it if the page still has its desktop layout.\"\n : \"Reload it if the page still has its phone layout.\",\n duration: 8000,\n action: { label: \"Reload\", onClick: () => session.go({ along: \"reload\" }) },\n },\n );\n // What the tab is shown as is all this goes by.\n }, [shown]);\n}\n\nfunction copyByHand(session: Session, forms: Parameters<Session[\"copyHere\"]>[0]) {\n const refused = () =>\n showNotice({ level: \"error\", message: \"This browser did not take the copy\" });\n session.copyHere(forms).then((written) => {\n if (written) {\n showNotice({ level: \"info\", message: \"Copied\" });\n } else {\n refused();\n }\n }, refused);\n}\n\n/** Tells when a recording ends and when its edit is made, whoever started it. */\nfunction useRecordingNotices({ recordings }: RecordingsControl) {\n const before = useRef<ReadonlyMap<string, Recording> | undefined>(undefined);\n\n useEffect(() => {\n const known = before.current;\n before.current = new Map(recordings.map((recording) => [recording.id, recording]));\n // The recordings there were when the page opened are no news.\n if (known === undefined) {\n return;\n }\n for (const recording of recordings) {\n const was = known.get(recording.id);\n if (was === undefined) {\n continue;\n }\n if (recordingRuns(was) && recording.state === \"finished\") {\n showNotice({\n level: \"info\",\n message: \"Recording finished\",\n description: recordingIsEdited(recording)\n ? \"The raw recording is in the session's files. Its edit is being made.\"\n : \"The raw recording is in the session's files.\",\n });\n }\n if (recordingRuns(was) && recording.state === \"failed\") {\n showNotice({\n level: \"error\",\n message: \"Recording failed\",\n description: recording.failure ?? undefined,\n });\n }\n if (recordingIsEdited(was) && recording.edit?.state === \"finished\") {\n showNotice({\n level: \"info\",\n message: \"Recording edit finished\",\n description: \"It is in the recording menu, next to the raw recording.\",\n });\n }\n if (recordingIsEdited(was) && recording.edit?.state === \"failed\") {\n showNotice({\n level: \"error\",\n message: \"Recording edit failed\",\n description: recording.edit.failure ?? undefined,\n });\n }\n }\n }, [recordings]);\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({ prefix: \"aperture\" });\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n// Without a provider, portals keep Base UI's default container, the document body.\nconst PortalContainerContext = createContext<HTMLElement | undefined>(undefined);\n\nexport function PortalContainerProvider({\n container,\n children,\n}: {\n container: HTMLElement;\n children: ReactNode;\n}) {\n return (\n <PortalContainerContext.Provider value={container}>{children}</PortalContainerContext.Provider>\n );\n}\n\nexport function usePortalContainer(): HTMLElement | undefined {\n return useContext(PortalContainerContext);\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"@base-ui/react/drawer\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\n/** The edge of the window a sheet stands at, and is dragged to to be rid of it. */\ntype DrawerSide = \"bottom\" | \"left\" | \"right\";\n\nconst SideContext = React.createContext<DrawerSide>(\"bottom\");\n\nconst SWIPED = { bottom: \"down\", left: \"left\", right: \"right\" } as const;\n\n/** How the sheet and what dims the page behind it move: as a sheet of a phone's own does. */\nconst MOVES =\n \"aperture:duration-[450ms] aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:data-swiping:duration-0 aperture:data-ending-style:duration-[calc(var(--drawer-swipe-strength,1)*400ms)] aperture:motion-reduce:duration-0\";\n\nconst BACKDROP = cn(\n \"aperture:fixed aperture:inset-0 aperture:z-50 aperture:bg-black aperture:opacity-[calc(0.12+0.2*(1-var(--drawer-swipe-progress,0)))] aperture:transition-opacity aperture:data-closed:pointer-events-none aperture:data-ending-style:opacity-0 aperture:data-starting-style:opacity-0\",\n MOVES,\n);\n\n/** Where a sheet is laid in the window: above the keyboard, where one is there. */\nconst VIEWPORT = {\n bottom: \"aperture:items-end aperture:justify-center\",\n left: \"aperture:items-stretch aperture:justify-start\",\n right: \"aperture:items-stretch aperture:justify-end\",\n} as const;\n\nconst POPUP = {\n bottom: cn(\n // What is below a height it is dragged to is off the window: the room it takes there\n // is left empty, so that all it holds is scrolled to above it.\n \"aperture:max-h-[calc(100%-env(safe-area-inset-top)-1.5rem)] aperture:w-full aperture:rounded-t-2xl aperture:[padding-bottom:max(0px,calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] aperture:[transform:translateY(calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y,0px)))] aperture:data-ending-style:[padding-bottom:0] aperture:data-ending-style:[transform:translateY(100%)] aperture:data-starting-style:[padding-bottom:0] aperture:data-starting-style:[transform:translateY(100%)]\",\n // Dragged above where it rests, it shows nothing of the page below its foot.\n \"aperture:after:inset-x-0 aperture:after:top-full aperture:after:h-24\",\n ),\n left: cn(\n \"aperture:h-full aperture:w-[min(calc(23rem+env(safe-area-inset-left)),calc(100%-3.5rem))] aperture:rounded-r-2xl aperture:pl-[env(safe-area-inset-left)] aperture:[transform:translateX(var(--drawer-swipe-movement-x,0px))] aperture:data-ending-style:[transform:translateX(-100%)] aperture:data-starting-style:[transform:translateX(-100%)]\",\n \"aperture:after:inset-y-0 aperture:after:right-full aperture:after:w-24\",\n ),\n right: cn(\n \"aperture:h-full aperture:w-[min(calc(23rem+env(safe-area-inset-right)),calc(100%-3.5rem))] aperture:rounded-l-2xl aperture:pr-[env(safe-area-inset-right)] aperture:[transform:translateX(var(--drawer-swipe-movement-x,0px))] aperture:data-ending-style:[transform:translateX(100%)] aperture:data-starting-style:[transform:translateX(100%)]\",\n \"aperture:after:inset-y-0 aperture:after:left-full aperture:after:w-24\",\n ),\n} as const;\n\n/** The mark of where a sheet is dragged by: at its head, or along the edge it came in by. */\nconst HANDLE = {\n bottom: \"aperture:mx-auto aperture:mt-2 aperture:h-1 aperture:w-9 aperture:shrink-0\",\n left: \"aperture:absolute aperture:top-1/2 aperture:right-1.5 aperture:h-9 aperture:w-1 aperture:-translate-y-1/2\",\n right:\n \"aperture:absolute aperture:top-1/2 aperture:left-1.5 aperture:h-9 aperture:w-1 aperture:-translate-y-1/2\",\n} as const;\n\n/**\n * A sheet that follows the finger. At the window's foot it is dragged down to be rid of\n * it and between the heights named as `snapPoints`; at a `side` of the window, as where\n * the window is wider than tall, it is dragged to that side to be rid of it.\n */\nfunction Drawer({\n side = \"bottom\",\n ...props\n}: Omit<DrawerPrimitive.Root.Props, \"swipeDirection\"> & { side?: DrawerSide }) {\n return (\n <SideContext.Provider value={side}>\n <DrawerPrimitive.Root data-slot=\"drawer\" swipeDirection={SWIPED[side]} {...props} />\n </SideContext.Provider>\n );\n}\n\nfunction DrawerTrigger({ ...props }: DrawerPrimitive.Trigger.Props) {\n return <DrawerPrimitive.Trigger data-slot=\"drawer-trigger\" {...props} />;\n}\n\nfunction DrawerClose({ ...props }: DrawerPrimitive.Close.Props) {\n return <DrawerPrimitive.Close data-slot=\"drawer-close\" {...props} />;\n}\n\n/** What a sheet is made of, for what lays out a sheet's popup itself. */\nfunction drawerPopupClassName(side: DrawerSide, className?: string) {\n return cn(\n \"aperture:relative aperture:flex aperture:min-h-0 aperture:touch-none aperture:flex-col aperture:bg-popover aperture:text-sm aperture:text-popover-foreground aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:outline-none aperture:transition-transform aperture:after:pointer-events-none aperture:after:absolute aperture:after:bg-[inherit] aperture:data-swiping:select-none\",\n POPUP[side],\n MOVES,\n className,\n );\n}\n\nfunction DrawerHandle({ side }: { side: DrawerSide }) {\n return (\n <div\n aria-hidden\n data-slot=\"drawer-handle\"\n className={cn(\"aperture:rounded-full aperture:bg-foreground/20\", HANDLE[side])}\n />\n );\n}\n\n/** What dims the page behind a sheet, and where the sheet is laid over it. */\nfunction DrawerFrame({ children }: { children: React.ReactNode }) {\n const side = React.useContext(SideContext);\n return (\n <DrawerPrimitive.Portal container={usePortalContainer()}>\n <DrawerPrimitive.Backdrop data-slot=\"drawer-overlay\" className={BACKDROP} />\n <DrawerPrimitive.Viewport\n data-slot=\"drawer-viewport\"\n className={cn(\n \"aperture:fixed aperture:inset-x-0 aperture:top-0 aperture:bottom-(--keyboard-inset,0px) aperture:z-50 aperture:flex aperture:touch-none aperture:data-closed:pointer-events-none\",\n VIEWPORT[side],\n )}\n >\n {children}\n </DrawerPrimitive.Viewport>\n </DrawerPrimitive.Portal>\n );\n}\n\n/** The sheet itself. What scrolls in it is a `DrawerBody`. */\nfunction DrawerContent({ className, children, ...props }: DrawerPrimitive.Popup.Props) {\n const side = React.useContext(SideContext);\n return (\n <DrawerFrame>\n <DrawerPrimitive.Popup\n data-slot=\"drawer-content\"\n data-side={side}\n className={\n typeof className === \"function\"\n ? (state) => drawerPopupClassName(side, className(state))\n : drawerPopupClassName(side, className)\n }\n {...props}\n >\n <DrawerHandle side={side} />\n {children}\n </DrawerPrimitive.Popup>\n </DrawerFrame>\n );\n}\n\n/** What the sheet holds that scrolls: dragging it moves the sheet once it is at its top. */\nfunction DrawerBody({ className, ...props }: DrawerPrimitive.Content.Props) {\n return (\n <DrawerPrimitive.Content\n data-slot=\"drawer-body\"\n className={cn(\n \"aperture:min-h-0 aperture:flex-1 aperture:touch-auto aperture:overflow-y-auto aperture:overscroll-contain\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props) {\n return (\n <DrawerPrimitive.Title\n data-slot=\"drawer-title\"\n className={cn(\"aperture:text-base aperture:font-medium aperture:text-foreground\", className)}\n {...props}\n />\n );\n}\n\nfunction DrawerDescription({ className, ...props }: DrawerPrimitive.Description.Props) {\n return (\n <DrawerPrimitive.Description\n data-slot=\"drawer-description\"\n className={cn(\"aperture:text-sm aperture:text-muted-foreground\", className)}\n {...props}\n />\n );\n}\n\nexport {\n Drawer,\n DrawerTrigger,\n DrawerClose,\n DrawerContent,\n DrawerFrame,\n DrawerHandle,\n DrawerBody,\n DrawerTitle,\n DrawerDescription,\n drawerPopupClassName,\n type DrawerSide,\n};\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"@base-ui/react/drawer\";\nimport { Menu as MenuPrimitive } from \"@base-ui/react/menu\";\n\nimport { cn } from \"../utils.ts\";\nimport { ChevronLeftIcon, ChevronRightIcon, CheckIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\nimport {\n Drawer,\n DrawerFrame,\n DrawerHandle,\n drawerPopupClassName,\n type DrawerSide,\n} from \"./drawer.tsx\";\n\n/**\n * Whether the menu is a sheet, as a phone has it: its submenus are then pages that slide\n * in over it, each with the way back, in place of menus beside it.\n */\nconst SheetContext = React.createContext(false);\n\n/** A menu that is a sheet, for what it is made of. */\nconst SheetMenuContext = React.createContext<\n | {\n readonly side: DrawerSide;\n readonly open: boolean;\n readonly close: () => void;\n /** The sheet has gone from the window: the menu is then closed for itself as well. */\n readonly gone: () => void;\n }\n | undefined\n>(undefined);\n\n/** Where the pages of a sheet are laid, over what the sheet shows first. */\nconst SheetPagesContext = React.createContext<HTMLElement | null>(null);\n\n/** The submenu a part is of, where the menu is a sheet. */\nconst SheetSubContext = React.createContext<\n | {\n readonly close: () => void;\n /** What opens it, which names its page. */\n readonly trigger: React.RefObject<HTMLElement | null>;\n }\n | undefined\n>(undefined);\n\n/**\n * How much of the window's height a sheet at its foot takes: as it opens, low, where a\n * thumb reaches all of it, and dragged up. The sheet is as tall for every page of it.\n */\nconst SHEET_HEIGHTS = [0.5, 1];\n\n/** A menu laid in a sheet in place of beside what opened it, whatever its anchor says. */\nconst SHEET_PLACED =\n \"aperture:static! aperture:size-full aperture:min-h-0 aperture:transform-none! aperture:outline-none\";\n\n/** A sheet's page, which scrolls within itself. */\nconst SHEET_PAGE =\n \"aperture:flex aperture:size-full aperture:min-h-0 aperture:flex-col aperture:overflow-hidden aperture:rounded-[inherit] aperture:bg-popover aperture:text-popover-foreground aperture:outline-none\";\n\n/** What scrolls in a sheet's page. */\nconst SHEET_SCROLLS =\n \"aperture:min-h-0 aperture:flex-1 aperture:touch-auto aperture:overflow-x-hidden aperture:overflow-y-auto aperture:overscroll-contain aperture:pr-[max(0.5rem,env(safe-area-inset-right))] aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))] aperture:pl-[max(0.5rem,env(safe-area-inset-left))]\";\n\n/** A sheet at a side of the window has that side's inset already. */\nconst SHEET_SCROLLS_SIDE = {\n bottom: \"\",\n left: \"aperture:pl-2\",\n right: \"aperture:pr-2\",\n} as const;\n\n/** A sheet's row: as tall as a finger needs, and written larger than a menu's. */\nconst SHEET_ROW =\n \"aperture:min-h-11 aperture:gap-3 aperture:rounded-lg aperture:px-3 aperture:text-[0.9375rem] aperture:[&_svg:not([class*='size-'])]:size-5\";\n\n/** A sheet's row that is checked or chosen, with the mark of that at its end. */\nconst SHEET_MARKED_ROW = cn(SHEET_ROW, \"aperture:pr-10\");\n\ntype DropdownMenuProps = Omit<MenuPrimitive.Root.Props, \"onOpenChange\"> & {\n sheet?: DrawerSide | false;\n /** Told without what changed it where a sheet was dragged away. */\n onOpenChange?: (open: boolean, details?: MenuPrimitive.Root.ChangeEventDetails) => void;\n};\n\n/**\n * A menu. One that is a `sheet` is shown as a sheet that follows the finger, for a phone,\n * at the window's foot or at the side named: it is then opened and closed by whoever\n * shows it, and stays until the sheet has gone from the window.\n */\nfunction DropdownMenu({ sheet = false, ...props }: DropdownMenuProps) {\n if (sheet === false) {\n return <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n }\n return <SheetMenu side={sheet} {...props} />;\n}\n\nfunction SheetMenu({\n side,\n open = false,\n onOpenChange,\n ...props\n}: Omit<DropdownMenuProps, \"sheet\"> & { side: DrawerSide }) {\n const [lingers, setLingers] = React.useState(open);\n if (open && !lingers) {\n setLingers(true);\n }\n const change = React.useRef(onOpenChange);\n change.current = onOpenChange;\n const menu = React.useMemo(\n () => ({\n side,\n open,\n close: () => change.current?.(false),\n gone: () => setLingers(false),\n }),\n [side, open],\n );\n return (\n <SheetMenuContext.Provider value={menu}>\n <MenuPrimitive.Root\n data-slot=\"dropdown-menu\"\n // The sheet is what keeps the page behind it from being used.\n modal={false}\n open={open || lingers}\n onOpenChange={onOpenChange}\n {...props}\n />\n </SheetMenuContext.Provider>\n );\n}\n\n/** The menu as a sheet: what it holds scrolls, with its `footer` kept below that. */\nfunction SheetMenuContent({\n footer,\n className,\n children,\n finalFocus,\n ...props\n}: MenuPrimitive.Popup.Props & { footer?: React.ReactNode }) {\n const menu = React.useContext(SheetMenuContext);\n const container = usePortalContainer();\n const [pages, setPages] = React.useState<HTMLElement | null>(null);\n const [height, setHeight] = React.useState<number | string | null>(SHEET_HEIGHTS[0] ?? null);\n // It comes in from the window's edge, which it is not at before it is there.\n const [entered, setEntered] = React.useState(false);\n React.useEffect(() => setEntered(true), []);\n if (menu === undefined) {\n throw new Error(\"A menu's sheet is shown outside a menu that is a sheet\");\n }\n const { side } = menu;\n const snaps = side === \"bottom\";\n\n return (\n <MenuPrimitive.Portal container={container}>\n <Drawer\n side={side}\n open={menu.open && entered}\n onOpenChange={(next) => {\n if (!next) {\n menu.close();\n }\n }}\n onOpenChangeComplete={(next) => {\n if (!next && !menu.open) {\n menu.gone();\n }\n }}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: SHEET_HEIGHTS } : {})}\n >\n <DrawerFrame>\n <DrawerPrimitive.Popup\n data-menu-sheet=\"\"\n data-side={side}\n data-height={!snaps || height === SHEET_HEIGHTS[1] ? \"full\" : \"part\"}\n finalFocus={finalFocus}\n className={drawerPopupClassName(\n side,\n side === \"bottom\" ? \"aperture:h-[min(40rem,100%)]\" : undefined,\n )}\n >\n <MenuPrimitive.Positioner positionMethod=\"fixed\" className={SHEET_PLACED}>\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n finalFocus={finalFocus}\n className={cn(SHEET_PAGE, \"aperture:relative\", className)}\n {...props}\n >\n <SheetContext.Provider value>\n <SheetPagesContext.Provider value={pages}>\n <div\n data-slot=\"dropdown-menu-sheet-grip\"\n className=\"aperture:flex aperture:h-6 aperture:shrink-0 aperture:items-start aperture:justify-center\"\n >\n <DrawerHandle side={side} />\n </div>\n <DrawerPrimitive.Content\n className={cn(SHEET_SCROLLS, SHEET_SCROLLS_SIDE[side])}\n >\n {children}\n </DrawerPrimitive.Content>\n {footer}\n </SheetPagesContext.Provider>\n </SheetContext.Provider>\n <div\n ref={setPages}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:overflow-hidden aperture:rounded-[inherit]\"\n />\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </DrawerPrimitive.Popup>\n </DrawerFrame>\n </Drawer>\n </MenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return <MenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" container={container} {...props} />;\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n return <MenuPrimitive.Trigger data-slot=\"dropdown-menu-trigger\" {...props} />;\n}\n\nfunction DropdownMenuContent({\n align = \"start\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n anchor,\n collisionPadding,\n collisionAvoidance,\n footer,\n className,\n children,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n | \"align\"\n | \"alignOffset\"\n | \"side\"\n | \"sideOffset\"\n | \"anchor\"\n | \"collisionPadding\"\n | \"collisionAvoidance\"\n > & {\n /** What a menu that is a sheet keeps below what scrolls in it. */\n footer?: React.ReactNode;\n }) {\n const container = usePortalContainer();\n if (React.useContext(SheetMenuContext) !== undefined) {\n return (\n <SheetMenuContent footer={footer} className={className} {...props}>\n {children}\n </SheetMenuContent>\n );\n }\n return (\n <MenuPrimitive.Portal container={container}>\n <MenuPrimitive.Positioner\n className=\"aperture:isolate aperture:z-50 aperture:outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n // A menu without a trigger, such as one shown where a click was, is told its place.\n anchor={anchor}\n collisionPadding={collisionPadding}\n collisionAvoidance={collisionAvoidance}\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n className={cn(\n \"aperture:z-50 aperture:max-h-(--available-height) aperture:w-(--anchor-width) aperture:min-w-32 aperture:origin-(--transform-origin) aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:overflow-hidden aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n >\n {children}\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />;\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<\"div\"> & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <div\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n \"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:data-inset:pl-7\",\n sheet && \"aperture:px-3 aperture:pt-3\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean;\n variant?: \"default\" | \"destructive\";\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"aperture:group/dropdown-menu-item aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:not-data-[variant=destructive]:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-[variant=destructive]:text-destructive aperture:data-[variant=destructive]:data-highlighted:bg-destructive/10 aperture:data-[variant=destructive]:data-highlighted:text-destructive aperture:dark:data-[variant=destructive]:data-highlighted:bg-destructive/20 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4 aperture:data-[variant=destructive]:*:[svg]:text-destructive\",\n sheet && SHEET_ROW,\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n const sheet = React.useContext(SheetContext);\n const [open, setOpen] = React.useState(false);\n const trigger = React.useRef<HTMLElement | null>(null);\n const sub = React.useMemo(() => ({ close: () => setOpen(false), trigger }), []);\n if (!sheet) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />;\n }\n // Open for as long as its page is not left: nothing hovers on a phone to close it.\n return (\n <SheetSubContext.Provider value={sub}>\n <MenuPrimitive.SubmenuRoot\n data-slot=\"dropdown-menu-sub\"\n open={open}\n onOpenChange={setOpen}\n {...props}\n />\n </SheetSubContext.Provider>\n );\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.SubmenuTrigger\n ref={React.useContext(SheetSubContext)?.trigger}\n data-slot=\"dropdown-menu-sub-trigger\"\n // A sheet's page is opened by a press: a pointer left over its row asks for nothing.\n {...(sheet ? { openOnHover: false } : {})}\n data-inset={inset}\n className={cn(\n \"aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:not-data-[variant=destructive]:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-popup-open:bg-accent aperture:data-popup-open:text-accent-foreground aperture:data-open:bg-accent aperture:data-open:text-accent-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_ROW,\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"aperture:ml-auto\" />\n </MenuPrimitive.SubmenuTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n align = \"start\",\n alignOffset = -3,\n side = \"right\",\n sideOffset = 0,\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n const sheet = React.useContext(SheetContext);\n const sub = React.useContext(SheetSubContext);\n const pages = React.useContext(SheetPagesContext);\n const edge = React.useContext(SheetMenuContext)?.side ?? \"bottom\";\n // What its page is called: what opens it says, by the part of it that names it where\n // it says more than that.\n const [title, setTitle] = React.useState(\"\");\n const named = React.useCallback(\n (element: HTMLElement | null) => {\n const opener = sub?.trigger.current;\n if (element !== null && opener != null) {\n const names = opener.querySelector(\"[data-menu-title]\") ?? opener;\n setTitle((names.textContent ?? \"\").trim());\n }\n },\n [sub],\n );\n if (sheet && sub !== undefined) {\n const {\n anchor: _anchor,\n collisionPadding: _padding,\n collisionAvoidance: _avoidance,\n footer: _footer,\n ...page\n } = props;\n return (\n <MenuPrimitive.Portal container={pages}>\n <MenuPrimitive.Positioner\n positionMethod=\"fixed\"\n className=\"aperture:absolute! aperture:inset-0! aperture:transform-none! aperture:outline-none\"\n >\n <MenuPrimitive.Popup\n ref={named}\n data-slot=\"dropdown-menu-sub-content\"\n data-menu-sheet-page={title}\n className={cn(\n SHEET_PAGE,\n // A page that is on its way out takes no press: one meant for the row under it\n // would be a press beside the menu, which is rid of the menu.\n \"aperture:pointer-events-auto aperture:transition-transform aperture:duration-300 aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:data-ending-style:pointer-events-none aperture:data-ending-style:translate-x-full aperture:data-starting-style:translate-x-full aperture:motion-reduce:duration-0\",\n )}\n {...page}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:px-[max(0.5rem,env(safe-area-inset-left))]\">\n <button\n type=\"button\"\n data-menu-sheet-back=\"\"\n aria-label=\"Back\"\n className=\"aperture:flex aperture:size-11 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:active:bg-accent\"\n onClick={sub.close}\n >\n <ChevronLeftIcon className=\"aperture:size-5\" />\n </button>\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:pr-11 aperture:text-center aperture:text-base aperture:font-medium\">\n {title}\n </span>\n </div>\n <DrawerPrimitive.Content className={cn(SHEET_SCROLLS, SHEET_SCROLLS_SIDE[edge])}>\n {children}\n </DrawerPrimitive.Content>\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n }\n return (\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n \"aperture:w-auto aperture:min-w-[96px] aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n >\n {children}\n </DropdownMenuContent>\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_MARKED_ROW,\n className,\n )}\n checked={checked}\n {...props}\n >\n <span\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:right-2 aperture:flex aperture:items-center aperture:justify-center\",\n sheet && \"aperture:right-3\",\n )}\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return <MenuPrimitive.RadioGroup data-slot=\"dropdown-menu-radio-group\" {...props} />;\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean;\n}) {\n const sheet = React.useContext(SheetContext);\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:data-highlighted:bg-accent aperture:data-highlighted:text-accent-foreground aperture:data-highlighted:**:[svg]:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n sheet && SHEET_MARKED_ROW,\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:right-2 aperture:flex aperture:items-center aperture:justify-center\",\n sheet && \"aperture:right-3\",\n )}\n data-slot=\"dropdown-menu-radio-item-indicator\"\n >\n <MenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\"aperture:-mx-1 aperture:my-1 aperture:h-px aperture:bg-border\", className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n \"aperture:ml-auto aperture:text-xs aperture:tracking-widest aperture:text-muted-foreground aperture:group-focus/dropdown-menu-item:text-accent-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n","import * as React from \"react\";\nimport { ContextMenu as ContextMenuPrimitive } from \"@base-ui/react/context-menu\";\n\nimport { cn } from \"../utils.ts\";\nimport { ChevronRightIcon, CheckIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props) {\n return <ContextMenuPrimitive.Root data-slot=\"context-menu\" {...props} />;\n}\n\nfunction ContextMenuPortal({ ...props }: ContextMenuPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return (\n <ContextMenuPrimitive.Portal data-slot=\"context-menu-portal\" container={container} {...props} />\n );\n}\n\nfunction ContextMenuTrigger({ className, ...props }: ContextMenuPrimitive.Trigger.Props) {\n return (\n <ContextMenuPrimitive.Trigger\n data-slot=\"context-menu-trigger\"\n className={cn(\"aperture:select-none\", className)}\n {...props}\n />\n );\n}\n\nfunction ContextMenuContent({\n className,\n align = \"start\",\n alignOffset = 4,\n side = \"right\",\n sideOffset = 0,\n ...props\n}: ContextMenuPrimitive.Popup.Props &\n Pick<ContextMenuPrimitive.Positioner.Props, \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\">) {\n return (\n <ContextMenuPrimitive.Portal container={usePortalContainer()}>\n <ContextMenuPrimitive.Positioner\n className=\"aperture:isolate aperture:z-50 aperture:outline-none\"\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <ContextMenuPrimitive.Popup\n data-slot=\"context-menu-content\"\n className={cn(\n \"aperture:z-50 aperture:max-h-(--available-height) aperture:min-w-36 aperture:origin-(--transform-origin) aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-lg aperture:bg-popover aperture:p-1 aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n </ContextMenuPrimitive.Positioner>\n </ContextMenuPrimitive.Portal>\n );\n}\n\nfunction ContextMenuGroup({ ...props }: ContextMenuPrimitive.Group.Props) {\n return <ContextMenuPrimitive.Group data-slot=\"context-menu-group\" {...props} />;\n}\n\nfunction ContextMenuLabel({\n className,\n inset,\n ...props\n}: ContextMenuPrimitive.GroupLabel.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.GroupLabel\n data-slot=\"context-menu-label\"\n data-inset={inset}\n className={cn(\n \"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:data-inset:pl-7\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ContextMenuItem({\n className,\n inset,\n variant = \"default\",\n ...props\n}: ContextMenuPrimitive.Item.Props & {\n inset?: boolean;\n variant?: \"default\" | \"destructive\";\n}) {\n return (\n <ContextMenuPrimitive.Item\n data-slot=\"context-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"aperture:group/context-menu-item aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-[variant=destructive]:text-destructive aperture:data-[variant=destructive]:focus:bg-destructive/10 aperture:data-[variant=destructive]:focus:text-destructive aperture:dark:data-[variant=destructive]:focus:bg-destructive/20 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4 aperture:focus:*:[svg]:text-accent-foreground aperture:data-[variant=destructive]:*:[svg]:text-destructive\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ContextMenuSub({ ...props }: ContextMenuPrimitive.SubmenuRoot.Props) {\n return <ContextMenuPrimitive.SubmenuRoot data-slot=\"context-menu-sub\" {...props} />;\n}\n\nfunction ContextMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: ContextMenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.SubmenuTrigger\n data-slot=\"context-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n \"aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-open:bg-accent aperture:data-open:text-accent-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"aperture:ml-auto\" />\n </ContextMenuPrimitive.SubmenuTrigger>\n );\n}\n\nfunction ContextMenuSubContent({ ...props }: React.ComponentProps<typeof ContextMenuContent>) {\n return (\n <ContextMenuContent\n data-slot=\"context-menu-sub-content\"\n className=\"aperture:shadow-lg\"\n side=\"right\"\n {...props}\n />\n );\n}\n\nfunction ContextMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: ContextMenuPrimitive.CheckboxItem.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n data-slot=\"context-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"aperture:pointer-events-none aperture:absolute aperture:right-2\">\n <ContextMenuPrimitive.CheckboxItemIndicator>\n <CheckIcon />\n </ContextMenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction ContextMenuRadioGroup({ ...props }: ContextMenuPrimitive.RadioGroup.Props) {\n return <ContextMenuPrimitive.RadioGroup data-slot=\"context-menu-radio-group\" {...props} />;\n}\n\nfunction ContextMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: ContextMenuPrimitive.RadioItem.Props & {\n inset?: boolean;\n}) {\n return (\n <ContextMenuPrimitive.RadioItem\n data-slot=\"context-menu-radio-item\"\n data-inset={inset}\n className={cn(\n \"aperture:relative aperture:flex aperture:cursor-default aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:py-1 aperture:pr-8 aperture:pl-1.5 aperture:text-sm aperture:outline-hidden aperture:select-none aperture:focus:bg-accent aperture:focus:text-accent-foreground aperture:data-inset:pl-7 aperture:data-disabled:pointer-events-none aperture:data-disabled:opacity-50 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"aperture:pointer-events-none aperture:absolute aperture:right-2\">\n <ContextMenuPrimitive.RadioItemIndicator>\n <CheckIcon />\n </ContextMenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n}\n\nfunction ContextMenuSeparator({ className, ...props }: ContextMenuPrimitive.Separator.Props) {\n return (\n <ContextMenuPrimitive.Separator\n data-slot=\"context-menu-separator\"\n className={cn(\"aperture:-mx-1 aperture:my-1 aperture:h-px aperture:bg-border\", className)}\n {...props}\n />\n );\n}\n\nfunction ContextMenuShortcut({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"context-menu-shortcut\"\n className={cn(\n \"aperture:ml-auto aperture:text-xs aperture:tracking-widest aperture:text-muted-foreground aperture:group-focus/context-menu-item:text-accent-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuContent,\n ContextMenuItem,\n ContextMenuCheckboxItem,\n ContextMenuRadioItem,\n ContextMenuLabel,\n ContextMenuSeparator,\n ContextMenuShortcut,\n ContextMenuGroup,\n ContextMenuPortal,\n ContextMenuSub,\n ContextMenuSubContent,\n ContextMenuSubTrigger,\n ContextMenuRadioGroup,\n};\n","import type { ComponentType, ReactNode } from \"react\";\nimport { ContextMenuGroup } from \"@aperture-browser/ui/components/context-menu\";\nimport { DropdownMenuGroup } from \"@aperture-browser/ui/components/dropdown-menu\";\nimport {\n groupContributions,\n type WorkbenchSlotName as SlotName,\n type WorkbenchSlotProps,\n} from \"./contributions.ts\";\nimport { useWorkbench } from \"./context.tsx\";\n\nexport interface SlotProps extends WorkbenchSlotProps {\n readonly name: SlotName;\n}\n\n/** What is contributed to a slot, one after the other. */\nexport function WorkbenchSlot({ name, ...props }: SlotProps) {\n const { contributions } = useWorkbench();\n return groupContributions(contributions, name).flatMap(([, group]) =>\n group.map((one) => <one.component key={one.id} {...props} />),\n );\n}\n\nconst MENU_GROUPS = {\n dropdown: DropdownMenuGroup,\n context: ContextMenuGroup,\n} satisfies Record<string, ComponentType<{ children?: ReactNode; className?: string }>>;\n\n/**\n * A line before a group that shows something and comes after another that does: a group\n * whose contributions render nothing is empty, and takes no line. It is the group's own\n * classes, so that every page that has the menu has its lines, whichever stylesheet it is\n * built with.\n */\nconst PARTED =\n \"aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:-mx-1 aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:my-1 aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:block aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:h-px aperture:[[data-workbench-menu-group]:not(:empty)~&:not(:empty)]:before:bg-border\";\n\n/** What is contributed to a menu, group by group, with a line between the groups. */\nexport function WorkbenchMenuSlot({\n name,\n kind = \"dropdown\",\n ...props\n}: SlotProps & { readonly kind?: keyof typeof MENU_GROUPS }) {\n const { contributions } = useWorkbench();\n const Group = MENU_GROUPS[kind];\n return groupContributions(contributions, name).map(([group, items]) => (\n <Group key={group} data-workbench-menu-group={group} className={PARTED}>\n {items.map((one) => (\n <one.component key={one.id} {...props} />\n ))}\n </Group>\n ));\n}\n","import { useMemo } from \"react\";\nimport {\n ArrowLeft,\n ArrowRight,\n ClipboardPaste,\n Copy,\n ExternalLink,\n Image,\n Link2,\n RefreshCw,\n TextSelect,\n} from \"lucide-react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { copyTextHere, pasteHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\n\n/**\n * The menu of a right click in the session. The session's browser shows none: the session\n * tells what the click was on when the page made nothing of it, and the menu is shown\n * here, where the click was.\n */\nexport function PageMenu() {\n const session = useSession();\n const { menu } = useSessionSnapshot();\n const x = menu?.x ?? 0;\n const y = menu?.y ?? 0;\n\n // The place of the click, as an element the menu is laid out against.\n const anchor = useMemo(() => ({ getBoundingClientRect: () => new DOMRect(x, y, 0, 0) }), [x, y]);\n\n if (menu === undefined) {\n return null;\n }\n return (\n <DropdownMenu\n open\n modal={false}\n onOpenChange={(open) => {\n if (!open) {\n session.dismissMenu();\n }\n }}\n >\n <DropdownMenuContent\n data-session-page-menu=\"\"\n anchor={anchor}\n side=\"bottom\"\n align=\"start\"\n sideOffset={0}\n collisionPadding={4}\n className=\"aperture:w-auto aperture:min-w-52\"\n >\n <WorkbenchMenuSlot name=\"menu.page\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n// The keyboard is the session's again once the menu has closed and given focus back.\nfunction useAct() {\n const session = useSession();\n return (action: () => void) => () => {\n action();\n requestAnimationFrame(() => session.focus());\n };\n}\n\n/** For a click on a link. */\nexport function PageLinkItems() {\n const session = useSession();\n const link = useSessionSnapshot().menu?.link;\n const act = useAct();\n\n if (link === undefined) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ url: link }, { newTab: true }))}>\n <ExternalLink />\n Open link in new tab\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => copyTextHere(session, link, \"Link copied\"))}>\n <Link2 />\n Copy link address\n </DropdownMenuItem>\n </>\n );\n}\n\n/** For a click on a picture. */\nexport function PagePictureItems() {\n const session = useSession();\n const image = useSessionSnapshot().menu?.image;\n const { features } = useWorkbench();\n const act = useAct();\n\n if (image === undefined) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ url: image }, { newTab: true }))}>\n <ExternalLink />\n Open picture in new tab\n </DropdownMenuItem>\n {features.access.clipboard.read ? (\n <DropdownMenuItem onClick={act(() => session.copyPicture(image))}>\n <Image />\n Copy picture\n </DropdownMenuItem>\n ) : null}\n <DropdownMenuItem onClick={act(() => copyTextHere(session, image, \"Picture address copied\"))}>\n <Link2 />\n Copy picture address\n </DropdownMenuItem>\n </>\n );\n}\n\n/** For a click on selected text, or in a field to write into. */\nexport function PageTextItems() {\n const session = useSession();\n const menu = useSessionSnapshot().menu;\n const { features } = useWorkbench();\n const act = useAct();\n\n return (\n <>\n {menu?.text === undefined || !features.access.clipboard.read ? null : (\n <DropdownMenuItem onClick={act(session.copySelection)}>\n <Copy />\n Copy\n </DropdownMenuItem>\n )}\n {menu?.editable ? (\n <>\n {features.access.clipboard.write ? (\n <DropdownMenuItem onClick={act(() => pasteHere(session))}>\n <ClipboardPaste />\n Paste\n </DropdownMenuItem>\n ) : null}\n <DropdownMenuItem onClick={act(session.selectAll)}>\n <TextSelect />\n Select all\n </DropdownMenuItem>\n </>\n ) : null}\n </>\n );\n}\n\nexport function PageNavigationItems() {\n const session = useSession();\n const act = useAct();\n\n return (\n <>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"back\" }))}>\n <ArrowLeft />\n Back\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"forward\" }))}>\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem onClick={act(() => session.go({ along: \"reload\" }))}>\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n );\n}\n","import { Loader2Icon } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Spinner({ className, ...props }: ComponentProps<\"svg\">) {\n return (\n <Loader2Icon\n data-slot=\"spinner\"\n role=\"status\"\n aria-label=\"Loading\"\n className={cn(\"aperture:size-4 aperture:animate-spin\", className)}\n {...props}\n />\n );\n}\n\nexport { Spinner };\n","import { Button as ButtonPrimitive } from \"@base-ui/react/button\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type { ReactNode } from \"react\";\n\nimport { cn } from \"../utils.ts\";\nimport { Spinner } from \"./spinner.tsx\";\n\nconst buttonVariants = cva(\n \"aperture:group/button aperture:inline-flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-lg aperture:border aperture:border-transparent aperture:bg-clip-padding aperture:text-sm aperture:leading-none aperture:font-medium aperture:whitespace-nowrap aperture:transition-all aperture:outline-none aperture:select-none aperture:focus-visible:border-ring aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:active:not-aria-[haspopup]:translate-y-px aperture:disabled:pointer-events-none aperture:disabled:opacity-50 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-3 aperture:aria-invalid:ring-destructive/20 aperture:dark:aria-invalid:border-destructive/50 aperture:dark:aria-invalid:ring-destructive/40 aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0 aperture:[&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n default:\n \"aperture:bg-primary aperture:text-primary-foreground aperture:hover:bg-primary/80\",\n outline:\n \"aperture:border-border aperture:bg-background aperture:hover:bg-muted aperture:hover:text-foreground aperture:aria-expanded:bg-muted aperture:aria-expanded:text-foreground aperture:dark:border-input aperture:dark:bg-input/30 aperture:dark:hover:bg-input/50\",\n secondary:\n \"aperture:bg-secondary aperture:text-secondary-foreground aperture:hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aperture:aria-expanded:bg-secondary aperture:aria-expanded:text-secondary-foreground\",\n ghost:\n \"aperture:hover:bg-muted aperture:hover:text-foreground aperture:aria-expanded:bg-muted aperture:aria-expanded:text-foreground aperture:dark:hover:bg-muted/50\",\n destructive:\n \"aperture:bg-destructive/10 aperture:text-destructive aperture:hover:bg-destructive/20 aperture:focus-visible:border-destructive/40 aperture:focus-visible:ring-destructive/20 aperture:dark:bg-destructive/20 aperture:dark:hover:bg-destructive/30 aperture:dark:focus-visible:ring-destructive/40\",\n link: \"aperture:text-primary aperture:underline-offset-4 aperture:hover:underline\",\n },\n size: {\n default:\n \"aperture:h-8 aperture:gap-1.5 aperture:px-2.5 aperture:pt-px aperture:has-data-[icon=inline-end]:pr-2 aperture:has-data-[icon=inline-start]:pl-2\",\n xs: \"aperture:h-6 aperture:gap-1 aperture:rounded-[min(--theme(--radius-md),10px)] aperture:px-2 aperture:pt-px aperture:text-xs aperture:in-data-[slot=button-group]:rounded-lg aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:[&_svg:not([class*='size-'])]:size-3\",\n sm: \"aperture:h-7 aperture:gap-1 aperture:rounded-[min(--theme(--radius-md),12px)] aperture:px-2.5 aperture:pt-px aperture:text-[0.8rem] aperture:in-data-[slot=button-group]:rounded-lg aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:[&_svg:not([class*='size-'])]:size-3.5\",\n lg: \"aperture:h-9 aperture:gap-1.5 aperture:px-2.5 aperture:pt-px aperture:has-data-[icon=inline-end]:pr-2 aperture:has-data-[icon=inline-start]:pl-2\",\n icon: \"aperture:size-8\",\n \"icon-xs\":\n \"aperture:size-6 aperture:rounded-[min(--theme(--radius-md),10px)] aperture:in-data-[slot=button-group]:rounded-lg aperture:[&_svg:not([class*='size-'])]:size-3\",\n \"icon-sm\":\n \"aperture:size-7 aperture:rounded-[min(--theme(--radius-md),12px)] aperture:in-data-[slot=button-group]:rounded-lg\",\n \"icon-lg\": \"aperture:size-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\nfunction Button({\n className,\n variant = \"default\",\n size = \"default\",\n pending,\n disabled,\n children,\n ...props\n}: ButtonPrimitive.Props &\n VariantProps<typeof buttonVariants> & {\n /**\n * Whether what it does is being done: it is pressed no more until that ends, and says\n * so in place of what it says, as wide as it was.\n */\n pending?: boolean;\n }) {\n // Exposed so dense toolbars can keep icon buttons square when they shrink their height.\n const iconOnly = size === \"icon\" || (size?.startsWith(\"icon-\") ?? false);\n return (\n <ButtonPrimitive\n data-slot=\"button\"\n // What it is whatever slot it is given: the sizes for a finger go by it.\n data-button=\"\"\n data-icon-button={iconOnly ? \"\" : undefined}\n data-pending={pending === true ? \"\" : undefined}\n aria-busy={pending === true ? true : undefined}\n disabled={pending === true ? true : disabled}\n className={cn(\n buttonVariants({ variant, size, className }),\n pending === undefined ? undefined : \"aperture:relative\",\n )}\n {...props}\n >\n {pending === undefined ? (\n children\n ) : (\n <>\n {/* It keeps its room while it is not seen: the button stays as wide as it was. */}\n <span className={cn(\"aperture:contents\", pending && \"aperture:invisible\")}>\n {children as ReactNode}\n </span>\n {pending ? <Spinner className=\"aperture:absolute aperture:size-4\" /> : null}\n </>\n )}\n </ButtonPrimitive>\n );\n}\n\nexport { Button, buttonVariants };\n","import { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction TooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {\n return <TooltipPrimitive.Provider data-slot=\"tooltip-provider\" delay={delay} {...props} />;\n}\n\nfunction Tooltip({ ...props }: TooltipPrimitive.Root.Props) {\n return <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />;\n}\n\nfunction TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n side = \"top\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n children,\n ...props\n}: TooltipPrimitive.Popup.Props &\n Pick<TooltipPrimitive.Positioner.Props, \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\">) {\n return (\n <TooltipPrimitive.Portal container={usePortalContainer()}>\n <TooltipPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"aperture:isolate aperture:z-50\"\n >\n <TooltipPrimitive.Popup\n data-slot=\"tooltip-content\"\n className={cn(\n \"aperture:z-50 aperture:inline-flex aperture:w-fit aperture:max-w-xs aperture:origin-(--transform-origin) aperture:items-center aperture:gap-1.5 aperture:rounded-md aperture:bg-foreground aperture:px-3 aperture:py-1.5 aperture:text-xs aperture:text-background aperture:has-data-[slot=kbd]:pr-1.5 aperture:**:data-[slot=kbd]:relative aperture:**:data-[slot=kbd]:isolate aperture:**:data-[slot=kbd]:z-50 aperture:**:data-[slot=kbd]:rounded-sm aperture:data-[state=delayed-open]:animate-in aperture:data-[state=delayed-open]:fade-in-0 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"aperture:z-50 aperture:size-2.5 aperture:translate-y-[calc(-50%-2px)] aperture:rotate-45 aperture:rounded-[2px] aperture:bg-foreground aperture:fill-foreground aperture:data-[side=bottom]:top-1 aperture:data-[side=inline-end]:top-1/2! aperture:data-[side=inline-end]:-left-1 aperture:data-[side=inline-end]:-translate-y-1/2 aperture:data-[side=inline-start]:top-1/2! aperture:data-[side=inline-start]:-right-1 aperture:data-[side=inline-start]:-translate-y-1/2 aperture:data-[side=left]:top-1/2! aperture:data-[side=left]:-right-1 aperture:data-[side=left]:-translate-y-1/2 aperture:data-[side=right]:top-1/2! aperture:data-[side=right]:-left-1 aperture:data-[side=right]:-translate-y-1/2 aperture:data-[side=top]:-bottom-2.5\" />\n </TooltipPrimitive.Popup>\n </TooltipPrimitive.Positioner>\n </TooltipPrimitive.Portal>\n );\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n","import { useState, type ComponentProps, type ReactNode } from \"react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\n\n/** A toolbar button that opens a menu, with its name as a tooltip. */\nexport function MenuButton({\n label,\n variant = \"ghost\",\n children,\n ...props\n}: {\n label: string;\n variant?: ComponentProps<typeof Button>[\"variant\"];\n children: ReactNode;\n} & Omit<ComponentProps<typeof Button>, \"children\" | \"variant\">) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant={variant}\n size=\"icon-sm\"\n aria-label={label}\n {...props}\n />\n }\n />\n }\n >\n {children}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n\n/** A submenu's trigger that names a setting and shows what it is set to. */\nexport function SettingSubTrigger({\n name,\n value,\n disabled,\n}: {\n name: string;\n value: ReactNode;\n disabled?: boolean;\n}) {\n return (\n <DropdownMenuSubTrigger disabled={disabled}>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n {name}\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">{value}</span>\n </span>\n </DropdownMenuSubTrigger>\n );\n}\n\n/** A menu item's two lines: what it is, and what that means. */\nexport function Described({ title, children }: { title: ReactNode; children: ReactNode }) {\n return (\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-col\">\n <span>{title}</span>\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">{children}</span>\n </span>\n );\n}\n\nexport function formatBytes(bytes: number): string {\n if (bytes >= 1024 * 1024 * 1024) {\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;\n }\n if (bytes >= 1024 * 1024) {\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n }\n if (bytes >= 1024) {\n return `${Math.ceil(bytes / 1024)} kB`;\n }\n return `${bytes} B`;\n}\n\nexport function formatDuration(milliseconds: number): string {\n const elapsed = Math.max(0, Math.floor(milliseconds / 1000));\n const hours = Math.floor(elapsed / 3600);\n const minutes = String(Math.floor((elapsed % 3600) / 60)).padStart(2, \"0\");\n const seconds = String(elapsed % 60).padStart(2, \"0\");\n return hours > 0 ? `${hours}:${minutes}:${seconds}` : `${minutes}:${seconds}`;\n}\n\nexport function formatStarted(startedAtMs: number): string {\n return new Date(startedAtMs).toLocaleString(undefined, {\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n}\n\n/** The small picture of a list's entry, and what stands for it where there is none. */\nexport function Thumbnail({\n src,\n className,\n children,\n}: {\n src: string | undefined;\n className?: string;\n children: ReactNode;\n}) {\n const [failed, setFailed] = useState(false);\n return (\n <span\n className={cn(\n \"aperture:flex aperture:h-9 aperture:w-16 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:overflow-hidden aperture:rounded aperture:bg-muted aperture:text-muted-foreground aperture:ring-1 aperture:ring-foreground/10\",\n className,\n )}\n >\n {src === undefined || failed ? (\n children\n ) : (\n <img\n src={src}\n alt=\"\"\n loading=\"lazy\"\n onError={() => setFailed(true)}\n className=\"aperture:size-full aperture:object-cover aperture:object-top\"\n />\n )}\n </span>\n );\n}\n","import { Monitor, Smartphone } from \"lucide-react\";\nimport type { PageMode } from \"@aperture-browser/session-client\";\nimport {\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useSession, useWatchedTarget } from \"../session.tsx\";\nimport { Described } from \"./menu-parts.tsx\";\n\nconst MODES: readonly { mode: PageMode; label: string; detail: string }[] = [\n { mode: \"auto\", label: \"Auto\", detail: \"As on the device of whoever holds the tab.\" },\n { mode: \"desktop\", label: \"Desktop\", detail: \"As a desktop's browser shows it.\" },\n { mode: \"mobile\", label: \"Mobile\", detail: \"As a phone's browser shows it.\" },\n];\n\nconst isMode = (value: unknown): value is PageMode => MODES.some((one) => one.mode === value);\n\n/**\n * How the watched tab's pages are shown: as on a desktop, as on a phone, or as on what its\n * holder uses. The page loads again when that changes how it is shown.\n */\nexport function PageModeItem() {\n const session = useSession();\n const watched = useWatchedTarget();\n const { changes } = useInputState();\n const label = MODES.find((one) => one.mode === watched?.mode)?.label ?? \"\";\n const shown = watched?.mobile === true ? \"mobile\" : \"desktop\";\n\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger\n disabled={!changes || watched === undefined}\n data-workbench-page-mode={watched?.mode}\n >\n {watched?.mobile === true ? <Smartphone /> : <Monitor />}\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n Page mode\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">\n {watched?.mode === \"auto\" ? `Auto · ${shown}` : label}\n </span>\n </span>\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"How the tab's pages are shown\"\n value={watched?.mode ?? \"\"}\n onValueChange={(value) => {\n if (isMode(value)) {\n session.setMode(value);\n }\n }}\n >\n {MODES.map(({ mode, label: name, detail }) => (\n <DropdownMenuRadioItem key={mode} value={mode} data-page-mode={mode} closeOnClick>\n <Described title={name}>{detail}</Described>\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n","import * as React from \"react\";\nimport { Input as InputPrimitive } from \"@base-ui/react/input\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Input({ className, type, ...props }: React.ComponentProps<\"input\">) {\n return (\n <InputPrimitive\n type={type}\n data-slot=\"input\"\n className={cn(\n \"aperture:h-8 aperture:w-full aperture:min-w-0 aperture:rounded-lg aperture:border aperture:border-input aperture:bg-transparent aperture:px-2.5 aperture:py-1 aperture:text-base aperture:transition-colors aperture:outline-none aperture:file:inline-flex aperture:file:h-6 aperture:file:border-0 aperture:file:bg-transparent aperture:file:text-sm aperture:file:font-medium aperture:file:text-foreground aperture:placeholder:text-muted-foreground aperture:focus-visible:border-ring aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:disabled:pointer-events-none aperture:disabled:cursor-not-allowed aperture:disabled:bg-input/50 aperture:disabled:opacity-50 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-3 aperture:aria-invalid:ring-destructive/20 aperture:md:text-sm aperture:dark:bg-input/30 aperture:dark:disabled:bg-input/80 aperture:dark:aria-invalid:border-destructive/50 aperture:dark:aria-invalid:ring-destructive/40\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Input };\n","import * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\nimport { Button } from \"./button.tsx\";\nimport { Input } from \"./input.tsx\";\nimport { Textarea } from \"./textarea.tsx\";\n\nfunction InputGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"input-group\"\n role=\"group\"\n className={cn(\n \"aperture:group/input-group aperture:relative aperture:flex aperture:h-8 aperture:w-full aperture:min-w-0 aperture:items-center aperture:rounded-lg aperture:border aperture:border-input aperture:transition-colors aperture:outline-none aperture:in-data-[slot=combobox-content]:focus-within:border-inherit aperture:in-data-[slot=combobox-content]:focus-within:ring-0 aperture:has-disabled:bg-input/50 aperture:has-disabled:opacity-50 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-ring aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-3 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 aperture:has-[[data-slot][aria-invalid=true]]:border-destructive aperture:has-[[data-slot][aria-invalid=true]]:ring-3 aperture:has-[[data-slot][aria-invalid=true]]:ring-destructive/20 aperture:has-[>[data-align=block-end]]:h-auto aperture:has-[>[data-align=block-end]]:flex-col aperture:has-[>[data-align=block-start]]:h-auto aperture:has-[>[data-align=block-start]]:flex-col aperture:has-[>textarea]:h-auto aperture:dark:bg-input/30 aperture:dark:has-disabled:bg-input/80 aperture:dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 aperture:has-[>[data-align=block-end]]:[&>input]:pt-3 aperture:has-[>[data-align=block-start]]:[&>input]:pb-3 aperture:has-[>[data-align=inline-end]]:[&>input]:pr-1.5 aperture:has-[>[data-align=inline-start]]:[&>input]:pl-1.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\nconst inputGroupAddonVariants = cva(\n \"aperture:flex aperture:h-auto aperture:cursor-text aperture:items-center aperture:justify-center aperture:gap-2 aperture:py-1.5 aperture:text-sm aperture:font-medium aperture:text-muted-foreground aperture:select-none aperture:group-data-[disabled=true]/input-group:opacity-50 aperture:[&>kbd]:rounded-[calc(var(--radius)-5px)] aperture:[&>svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n align: {\n \"inline-start\":\n \"aperture:order-first aperture:pl-2 aperture:has-[>button]:ml-[-0.3rem] aperture:has-[>kbd]:ml-[-0.15rem]\",\n \"inline-end\":\n \"aperture:order-last aperture:pr-2 aperture:has-[>button]:mr-[-0.3rem] aperture:has-[>kbd]:mr-[-0.15rem]\",\n \"block-start\":\n \"aperture:order-first aperture:w-full aperture:justify-start aperture:px-2.5 aperture:pt-2 aperture:group-has-[>input]/input-group:pt-2 aperture:[[class~='aperture:border-b']]:pb-2\",\n \"block-end\":\n \"aperture:order-last aperture:w-full aperture:justify-start aperture:px-2.5 aperture:pb-2 aperture:group-has-[>input]/input-group:pb-2 aperture:[[class~='aperture:border-t']]:pt-2\",\n },\n },\n defaultVariants: {\n align: \"inline-start\",\n },\n },\n);\n\nfunction InputGroupAddon({\n className,\n align = \"inline-start\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof inputGroupAddonVariants>) {\n return (\n <div\n role=\"group\"\n data-slot=\"input-group-addon\"\n data-align={align}\n className={cn(inputGroupAddonVariants({ align }), className)}\n onClick={(e) => {\n if ((e.target as HTMLElement).closest(\"button\")) {\n return;\n }\n e.currentTarget.parentElement?.querySelector(\"input\")?.focus();\n }}\n {...props}\n />\n );\n}\n\nconst inputGroupButtonVariants = cva(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm aperture:shadow-none\",\n {\n variants: {\n size: {\n xs: \"aperture:h-6 aperture:gap-1 aperture:rounded-[calc(var(--radius)-3px)] aperture:px-1.5 aperture:[&>svg:not([class*='size-'])]:size-3.5\",\n sm: \"\",\n \"icon-xs\":\n \"aperture:size-6 aperture:rounded-[calc(var(--radius)-3px)] aperture:p-0 aperture:has-[>svg]:p-0\",\n \"icon-sm\": \"aperture:size-8 aperture:p-0 aperture:has-[>svg]:p-0\",\n },\n },\n defaultVariants: {\n size: \"xs\",\n },\n },\n);\n\nfunction InputGroupButton({\n className,\n type = \"button\",\n variant = \"ghost\",\n size = \"xs\",\n ...props\n}: Omit<React.ComponentProps<typeof Button>, \"size\" | \"type\"> &\n VariantProps<typeof inputGroupButtonVariants> & {\n type?: \"button\" | \"submit\" | \"reset\";\n }) {\n return (\n <Button\n type={type}\n data-size={size}\n variant={variant}\n className={cn(inputGroupButtonVariants({ size }), className)}\n {...props}\n />\n );\n}\n\nfunction InputGroupText({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n className={cn(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm aperture:text-muted-foreground aperture:[&_svg]:pointer-events-none aperture:[&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction InputGroupInput({ className, ...props }: React.ComponentProps<\"input\">) {\n return (\n <Input\n data-slot=\"input-group-control\"\n className={cn(\n \"aperture:flex-1 aperture:rounded-none aperture:border-0 aperture:bg-transparent aperture:shadow-none aperture:ring-0 aperture:focus-visible:ring-0 aperture:disabled:bg-transparent aperture:aria-invalid:ring-0 aperture:dark:bg-transparent aperture:dark:disabled:bg-transparent\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction InputGroupTextarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\n return (\n <Textarea\n data-slot=\"input-group-control\"\n className={cn(\n \"aperture:flex-1 aperture:resize-none aperture:rounded-none aperture:border-0 aperture:bg-transparent aperture:py-2 aperture:shadow-none aperture:ring-0 aperture:focus-visible:ring-0 aperture:disabled:bg-transparent aperture:aria-invalid:ring-0 aperture:dark:bg-transparent aperture:dark:disabled:bg-transparent\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupText,\n InputGroupInput,\n InputGroupTextarea,\n};\n","import { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { useSessionSnapshot } from \"../session.tsx\";\n\n/** Whether a media query holds, as the window and what points at it change. */\nexport function useMedia(query: string): boolean {\n return useSyncExternalStore(\n (changed) => {\n const media = window.matchMedia(query);\n media.addEventListener(\"change\", changed);\n return () => media.removeEventListener(\"change\", changed);\n },\n () => window.matchMedia(query).matches,\n () => false,\n );\n}\n\n/**\n * Whether the session is used from a phone, as the session is told it is: the workbench\n * is then the picture with a bar below it, in place of a browser's rows above it.\n */\nexport const usePhone = () => useSessionSnapshot().phone;\n\n/** Whether a finger is what points: what is pressed is larger then, and takes more room. */\nexport const useFinger = () => useMedia(\"(pointer: coarse)\");\n\n/**\n * Whether the window is as short as a phone held on its side: the workbench then keeps one\n * row above the picture in place of two.\n */\nexport const useShortWindow = () => useMedia(\"(pointer: coarse) and (max-height: 30rem)\");\n\n/** Calls `changed` whenever the window is turned or gets another size. */\nfunction turned(changed: () => void) {\n const media = window.matchMedia(\"(orientation: landscape)\");\n // Not every browser that has a screen tells of its turning.\n const screen = window.screen.orientation as ScreenOrientation | undefined;\n media.addEventListener(\"change\", changed);\n screen?.addEventListener(\"change\", changed);\n window.addEventListener(\"resize\", changed);\n return () => {\n media.removeEventListener(\"change\", changed);\n screen?.removeEventListener(\"change\", changed);\n window.removeEventListener(\"resize\", changed);\n };\n}\n\n/** How the screen is held, where it tells: a window is wider than tall for a keyboard too. */\nconst screenTurn = (): string | undefined =>\n (window.screen.orientation as ScreenOrientation | undefined)?.type;\n\nconst onSide = () =>\n screenTurn()?.startsWith(\"landscape\") ?? window.matchMedia(\"(orientation: landscape)\").matches;\n\n/**\n * Whether the session is used from a phone held on its side: height is what there is\n * least of then, and the workbench is laid out along a side of the picture.\n */\nexport function usePhoneOnSide(): boolean {\n const phone = usePhone();\n const side = useSyncExternalStore(turned, onSide, () => false);\n return phone && side;\n}\n\n/** What of the window's sides a screen's cutout and corners take, in CSS pixels. */\ninterface Insets {\n readonly left: number;\n readonly right: number;\n}\n\n/**\n * The side of the window a phone held on its side has the workbench's rail at: the one\n * away from the camera's cutout, which is the one with less of an inset. An iPhone gives\n * both sides the same inset, and then it is how the screen is turned that tells where the\n * cutout is: at the left as a phone is first turned, at the right turned the other way.\n * A screen with no cutout has the rail at the right.\n */\nexport function useRailSide(): \"left\" | \"right\" {\n const [side, setSide] = useState<\"left\" | \"right\">(\"right\");\n useEffect(() => {\n const probe = document.createElement(\"div\");\n probe.style.cssText =\n \"position:fixed;visibility:hidden;pointer-events:none;inset:0 auto auto 0;padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)\";\n document.body.append(probe);\n const look = () => {\n const style = getComputedStyle(probe);\n const insets: Insets = {\n left: Number.parseFloat(style.paddingLeft) || 0,\n right: Number.parseFloat(style.paddingRight) || 0,\n };\n if (insets.left !== insets.right) {\n setSide(insets.left > insets.right ? \"right\" : \"left\");\n } else {\n setSide(insets.left > 0 && screenTurn() === \"landscape-secondary\" ? \"left\" : \"right\");\n }\n };\n look();\n const stop = turned(look);\n return () => {\n stop();\n probe.remove();\n };\n }, []);\n return side;\n}\n","\"use client\";\n\nimport { PreviewCard as PreviewCardPrimitive } from \"@base-ui/react/preview-card\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction HoverCard<Payload>(props: PreviewCardPrimitive.Root.Props<Payload>) {\n return <PreviewCardPrimitive.Root data-slot=\"hover-card\" {...props} />;\n}\n\nfunction HoverCardTrigger<Payload>(props: PreviewCardPrimitive.Trigger.Props<Payload>) {\n return <PreviewCardPrimitive.Trigger data-slot=\"hover-card-trigger\" {...props} />;\n}\n\nfunction HoverCardContent({\n className,\n positionerClassName,\n side = \"bottom\",\n sideOffset = 4,\n align = \"center\",\n alignOffset = 0,\n collisionPadding,\n ...props\n}: PreviewCardPrimitive.Popup.Props &\n Pick<\n PreviewCardPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\" | \"collisionPadding\"\n > & { positionerClassName?: string }) {\n return (\n <PreviewCardPrimitive.Portal container={usePortalContainer()}>\n <PreviewCardPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n className={cn(\"aperture:isolate aperture:z-50\", positionerClassName)}\n >\n <PreviewCardPrimitive.Popup\n data-slot=\"hover-card-content\"\n className={cn(\n \"aperture:z-50 aperture:w-64 aperture:rounded-lg aperture:bg-popover aperture:p-2.5 aperture:text-sm aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:outline-hidden\",\n className,\n )}\n {...props}\n />\n </PreviewCardPrimitive.Positioner>\n </PreviewCardPrimitive.Portal>\n );\n}\n\nconst createHoverCardHandle = PreviewCardPrimitive.createHandle;\n\nexport { HoverCard, HoverCardTrigger, HoverCardContent, createHoverCardHandle };\nexport type HoverCardHandle<Payload> = PreviewCardPrimitive.Handle<Payload>;\n","\"use client\";\n\nimport { ScrollArea as ScrollAreaPrimitive } from \"@base-ui/react/scroll-area\";\nimport type { Ref } from \"react\";\n\nimport { cn } from \"../utils.ts\";\n\ntype ScrollAreaProps = ScrollAreaPrimitive.Root.Props & {\n viewportClassName?: string;\n viewportRef?: Ref<HTMLDivElement>;\n scrollbars?: \"vertical\" | \"horizontal\" | \"both\";\n};\n\nfunction ScrollArea({\n className,\n viewportClassName,\n viewportRef,\n scrollbars = \"vertical\",\n children,\n ...props\n}: ScrollAreaProps) {\n const vertical = scrollbars === \"vertical\" || scrollbars === \"both\";\n const horizontal = scrollbars === \"horizontal\" || scrollbars === \"both\";\n\n return (\n <ScrollAreaPrimitive.Root\n data-slot=\"scroll-area\"\n className={cn(\"aperture:relative\", className)}\n {...props}\n >\n <ScrollAreaPrimitive.Viewport\n ref={viewportRef}\n data-slot=\"scroll-area-viewport\"\n style={{\n overflowX: horizontal ? \"scroll\" : \"hidden\",\n overflowY: vertical ? \"scroll\" : \"hidden\",\n }}\n className={cn(\n \"aperture:size-full aperture:rounded-[inherit] aperture:transition-[color,box-shadow] aperture:outline-none aperture:focus-visible:ring-[3px] aperture:focus-visible:ring-ring/50 aperture:focus-visible:outline-1\",\n viewportClassName,\n )}\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n {vertical ? <ScrollBar /> : null}\n {horizontal ? <ScrollBar orientation=\"horizontal\" /> : null}\n <ScrollAreaPrimitive.Corner />\n </ScrollAreaPrimitive.Root>\n );\n}\n\nfunction ScrollBar({\n className,\n orientation = \"vertical\",\n ...props\n}: ScrollAreaPrimitive.Scrollbar.Props) {\n return (\n <ScrollAreaPrimitive.Scrollbar\n data-slot=\"scroll-area-scrollbar\"\n data-orientation={orientation}\n orientation={orientation}\n className={cn(\n \"aperture:flex aperture:touch-none aperture:p-px aperture:transition-colors aperture:select-none aperture:hover:bg-muted/50 aperture:data-[orientation=horizontal]:h-2.5 aperture:data-[orientation=horizontal]:flex-col aperture:data-[orientation=horizontal]:border-t aperture:data-[orientation=horizontal]:border-t-transparent aperture:data-[orientation=vertical]:h-full aperture:data-[orientation=vertical]:w-2.5 aperture:data-[orientation=vertical]:border-l aperture:data-[orientation=vertical]:border-l-transparent\",\n className,\n )}\n {...props}\n >\n <ScrollAreaPrimitive.Thumb\n data-slot=\"scroll-area-thumb\"\n className=\"aperture:relative aperture:flex-1 aperture:rounded-full aperture:bg-border aperture:transition-colors aperture:hover:bg-foreground/35\"\n />\n </ScrollAreaPrimitive.Scrollbar>\n );\n}\n\nexport { ScrollArea, ScrollBar };\n","import * as React from \"react\";\nimport { Avatar as AvatarPrimitive } from \"@base-ui/react/avatar\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Avatar({\n className,\n size = \"default\",\n ...props\n}: AvatarPrimitive.Root.Props & {\n size?: \"default\" | \"sm\" | \"lg\";\n}) {\n return (\n <AvatarPrimitive.Root\n data-slot=\"avatar\"\n data-size={size}\n className={cn(\n \"aperture:group/avatar aperture:relative aperture:flex aperture:size-8 aperture:shrink-0 aperture:rounded-full aperture:select-none aperture:after:absolute aperture:after:inset-0 aperture:after:rounded-full aperture:after:border aperture:after:border-border aperture:after:mix-blend-darken aperture:data-[size=lg]:size-10 aperture:data-[size=sm]:size-6 aperture:dark:after:mix-blend-lighten\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {\n return (\n <AvatarPrimitive.Image\n data-slot=\"avatar-image\"\n className={cn(\n \"aperture:aspect-square aperture:size-full aperture:rounded-full aperture:object-cover\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarFallback({ className, ...props }: AvatarPrimitive.Fallback.Props) {\n return (\n <AvatarPrimitive.Fallback\n data-slot=\"avatar-fallback\"\n className={cn(\n \"aperture:flex aperture:size-full aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-muted aperture:text-sm aperture:text-muted-foreground aperture:group-data-[size=sm]/avatar:text-xs\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarBadge({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"avatar-badge\"\n className={cn(\n \"aperture:absolute aperture:right-0 aperture:bottom-0 aperture:z-10 aperture:inline-flex aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-primary aperture:text-primary-foreground aperture:bg-blend-color aperture:ring-2 aperture:ring-background aperture:select-none\",\n \"aperture:group-data-[size=sm]/avatar:size-2 aperture:group-data-[size=sm]/avatar:[&>svg]:hidden\",\n \"aperture:group-data-[size=default]/avatar:size-2.5 aperture:group-data-[size=default]/avatar:[&>svg]:size-2\",\n \"aperture:group-data-[size=lg]/avatar:size-3 aperture:group-data-[size=lg]/avatar:[&>svg]:size-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"avatar-group\"\n className={cn(\n \"aperture:group/avatar-group aperture:flex aperture:-space-x-2 aperture:*:data-[slot=avatar]:ring-2 aperture:*:data-[slot=avatar]:ring-background\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarGroupCount({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"avatar-group-count\"\n className={cn(\n \"aperture:relative aperture:flex aperture:size-8 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-muted aperture:text-sm aperture:text-muted-foreground aperture:ring-2 aperture:ring-background aperture:group-has-data-[size=lg]/avatar-group:size-10 aperture:group-has-data-[size=sm]/avatar-group:size-6 aperture:[&>svg]:size-4 aperture:group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 aperture:group-has-data-[size=sm]/avatar-group:[&>svg]:size-3\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge };\n","\"use client\";\n\nimport * as React from \"react\";\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\";\n\nimport { cn } from \"../utils.ts\";\nimport { usePortalContainer } from \"../portal.tsx\";\n\nfunction Popover({ ...props }: PopoverPrimitive.Root.Props) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nfunction PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\n}\n\nfunction PopoverContent({\n className,\n align = \"center\",\n alignOffset = 0,\n side = \"bottom\",\n sideOffset = 4,\n anchor,\n ...props\n}: PopoverPrimitive.Popup.Props &\n Pick<\n PopoverPrimitive.Positioner.Props,\n \"align\" | \"alignOffset\" | \"side\" | \"sideOffset\" | \"anchor\"\n >) {\n return (\n <PopoverPrimitive.Portal container={usePortalContainer()}>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n anchor={anchor}\n className=\"aperture:isolate aperture:z-50\"\n >\n <PopoverPrimitive.Popup\n data-slot=\"popover-content\"\n className={cn(\n \"aperture:z-50 aperture:flex aperture:w-72 aperture:origin-(--transform-origin) aperture:flex-col aperture:gap-2.5 aperture:rounded-lg aperture:bg-popover aperture:p-2.5 aperture:text-sm aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10 aperture:outline-hidden aperture:duration-100 aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n );\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"popover-header\"\n className={cn(\"aperture:flex aperture:flex-col aperture:gap-0.5 aperture:text-sm\", className)}\n {...props}\n />\n );\n}\n\nfunction PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {\n return (\n <PopoverPrimitive.Title\n data-slot=\"popover-title\"\n className={cn(\"aperture:font-medium\", className)}\n {...props}\n />\n );\n}\n\nfunction PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {\n return (\n <PopoverPrimitive.Description\n data-slot=\"popover-description\"\n className={cn(\"aperture:text-muted-foreground\", className)}\n {...props}\n />\n );\n}\n\nexport { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger };\n","import { useEffect, useState } from \"react\";\nimport { Bot, Hand, Hourglass, Radio } from \"lucide-react\";\nimport type { Member, Presence } from \"@aperture-browser/session-client\";\nimport { Avatar, AvatarBadge, AvatarFallback } from \"@aperture-browser/ui/components/avatar\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Popover,\n PopoverContent,\n PopoverTitle,\n PopoverTrigger,\n} from \"@aperture-browser/ui/components/popover\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useLease, useSession, useSessionSnapshot } from \"../session.tsx\";\n\nconst VISIBLE_MEMBERS = 5;\n\n/** The session gives a tab to whoever asked when its holder has not answered for this long. */\nconst ANSWER_WITHIN_SECONDS = 10;\n\nconst ROLES = { view: \"may watch\", control: \"may give input\", admin: \"admin\" } as const;\n\n/** Who is in the session, as the old workbench showed its collaborators. */\nexport function SessionPresence() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { presence } = snapshot;\n if (presence === undefined || presence.members.length === 0) {\n return null;\n }\n\n const holds = (member: Member) => presence.held.some((held) => held.holder === member.id);\n const members = presence.members.toSorted((left, right) => {\n if (left.id === presence.you) {\n return -1;\n }\n if (right.id === presence.you) {\n return 1;\n }\n if (holds(left) !== holds(right)) {\n return holds(left) ? -1 : 1;\n }\n return left.name.localeCompare(right.name);\n });\n const visible = members.slice(0, VISIBLE_MEMBERS);\n const overflow = members.length - visible.length;\n\n const button = (member: Member) => (\n <MemberButton key={member.id} member={member} presence={presence} onFollow={session.follow} />\n );\n\n return (\n <div\n data-session-presence=\"\"\n className=\"aperture:group aperture:flex aperture:shrink-0 aperture:items-center aperture:px-2\"\n aria-label=\"Members of the session\"\n >\n {overflow > 0 ? (\n <div className=\"aperture:relative\" style={{ zIndex: visible.length + 1 }}>\n <Popover>\n <PopoverTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"aperture:shrink-0 aperture:rounded-full aperture:border aperture:bg-background aperture:text-[0.65rem] aperture:text-muted-foreground\"\n aria-label={`${overflow} more members`}\n />\n }\n >\n +{overflow}\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"aperture:w-auto aperture:gap-2\">\n <PopoverTitle className=\"aperture:text-xs aperture:text-muted-foreground\">\n Everyone\n </PopoverTitle>\n <div className=\"aperture:flex aperture:max-w-64 aperture:flex-wrap aperture:items-center aperture:gap-1\">\n {members.map(button)}\n </div>\n </PopoverContent>\n </Popover>\n </div>\n ) : null}\n {visible.map((member, index) => (\n <div\n key={member.id}\n className={cn(\n \"aperture:relative aperture:transition-[margin] aperture:duration-200\",\n (index > 0 || overflow > 0) &&\n // A finger rests on nothing to spread them: there each stands whole.\n \"aperture:-ml-2 aperture:group-focus-within:ml-0 aperture:group-hover:ml-0 aperture:pointer-coarse:ml-0\",\n )}\n style={{ zIndex: visible.length - index }}\n >\n {button(member)}\n </div>\n ))}\n </div>\n );\n}\n\nfunction MemberButton({\n member,\n presence,\n onFollow,\n}: {\n member: Member;\n presence: Presence;\n onFollow: (member?: number) => void;\n}) {\n const you = member.id === presence.you;\n const followed = presence.members.find((one) => one.id === presence.you)?.follows === member.id;\n const follower = member.follows === presence.you;\n const held = presence.held.filter((one) => one.holder === member.id);\n\n const details = [\n you ? `${member.name} (you)` : member.name,\n member.agent ? \"automation\" : member.role === undefined ? undefined : ROLES[member.role],\n member.tab === undefined ? undefined : `watches tab ${member.tab}`,\n held.length === 0 ? undefined : `holds tab ${held.map((one) => one.tab).join(\", \")}`,\n follower ? \"follows you\" : undefined,\n followed ? \"you follow them · click to stop\" : undefined,\n !you && !followed ? \"click to follow them\" : undefined,\n ].filter((part) => part !== undefined);\n const label = details.join(\" · \");\n\n const trigger = you ? (\n <span\n className=\"aperture:inline-flex aperture:size-7 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full\"\n aria-label={label}\n />\n ) : (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n className={cn(\n \"aperture:shrink-0 aperture:rounded-full aperture:p-0\",\n followed && \"aperture:ring-2 aperture:ring-primary\",\n )}\n aria-label={label}\n aria-pressed={followed}\n data-member-follow={member.id}\n onClick={() => onFollow(followed ? undefined : member.id)}\n />\n );\n return (\n <Tooltip>\n <TooltipTrigger render={trigger}>\n <MemberAvatar member={member} holds={held.length > 0} />\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n\nexport function MemberAvatar({\n member,\n holds = false,\n className,\n}: {\n member: Member;\n /** The member holds the lease of a tab. */\n holds?: boolean;\n className?: string;\n}) {\n return (\n <Avatar\n size=\"sm\"\n className={cn(\"aperture:shrink-0 aperture:ring-2 aperture:ring-background\", className)}\n >\n <AvatarFallback\n className=\"aperture:text-[0.625rem] aperture:font-medium aperture:text-white\"\n style={{ backgroundColor: memberColor(member) }}\n >\n {member.agent ? <Bot className=\"aperture:size-3.5\" /> : initials(member.name)}\n </AvatarFallback>\n {holds ? (\n <AvatarBadge\n className=\"aperture:bg-emerald-500 aperture:group-data-[size=sm]/avatar:size-2.5\"\n title=\"Holds a tab's lease\"\n >\n <Radio />\n </AvatarBadge>\n ) : null}\n </Avatar>\n );\n}\n\n/** One member, as a mark on the tab they watch. */\nexport function MemberDot({ member, holds }: { member: Member; holds: boolean }) {\n return (\n <span\n className={cn(\n \"aperture:flex aperture:size-4 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:text-[0.5rem] aperture:leading-none aperture:font-semibold aperture:text-white aperture:ring-1 aperture:ring-background\",\n holds && \"aperture:ring-2 aperture:ring-emerald-500\",\n )}\n style={{ backgroundColor: memberColor(member) }}\n title={holds ? `${member.name} holds this tab` : `${member.name} watches this tab`}\n >\n {member.agent ? <Bot className=\"aperture:size-2.5\" /> : initials(member.name).slice(0, 1)}\n </span>\n );\n}\n\n/**\n * The lease of the watched tab, where it concerns this member: someone else holds the tab,\n * or someone asks this member for it. Laid over the picture, where input that does not\n * land is noticed.\n */\nexport function LeaseOverlay() {\n const session = useSession();\n const lease = useLease();\n const { state, holder, asker } = lease;\n\n if (state === \"asked-of-you\") {\n return (\n <LeaseRequest\n key={asker?.id}\n asker={asker}\n onAllow={() => session.lease(\"allow\")}\n onKeep={() => session.lease(\"keep\")}\n />\n );\n }\n\n if (state !== \"theirs\" && state !== \"theirs-asked\" && state !== \"you-asked\") {\n return null;\n }\n\n const name = holder?.agent ? automationName(holder) : (holder?.name ?? \"Someone\");\n // An admin's asking takes the tab, and so does a person's from the automation.\n const takes = lease.role === \"admin\" || holder?.agent === true;\n\n return (\n <div\n data-session-lease={state}\n role=\"status\"\n className=\"aperture:absolute aperture:top-2 aperture:left-1/2 aperture:z-30 aperture:flex aperture:max-w-[calc(100%-1rem)] aperture:-translate-x-1/2 aperture:items-center aperture:gap-2 aperture:rounded-full aperture:border aperture:bg-popover/95 aperture:py-1 aperture:pr-1 aperture:pl-1.5 aperture:text-xs aperture:text-popover-foreground aperture:shadow-md aperture:backdrop-blur\"\n >\n {holder === undefined ? null : <MemberAvatar member={holder} holds />}\n <span className=\"aperture:min-w-0 aperture:truncate\">\n <span className=\"aperture:font-medium\">{name}</span> holds this tab\n </span>\n {state === \"you-asked\" ? (\n <span className=\"aperture:flex aperture:h-6 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:rounded-full aperture:bg-muted aperture:px-2 aperture:text-muted-foreground\">\n <Hourglass className=\"aperture:size-3\" />\n Asked\n </span>\n ) : (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"secondary\"\n className=\"aperture:shrink-0 aperture:rounded-full\"\n disabled={state === \"theirs-asked\" && !takes}\n onClick={() => session.lease(\"take\")}\n >\n <Hand />\n {takes ? \"Take the lease\" : \"Ask for the lease\"}\n </Button>\n )}\n </div>\n );\n}\n\nfunction LeaseRequest({\n asker,\n onAllow,\n onKeep,\n}: {\n asker: Member | undefined;\n onAllow: () => void;\n onKeep: () => void;\n}) {\n const [left, setLeft] = useState(ANSWER_WITHIN_SECONDS);\n\n useEffect(() => {\n const timer = setInterval(() => setLeft((current) => Math.max(0, current - 1)), 1000);\n return () => clearInterval(timer);\n }, []);\n\n return (\n <div\n data-session-lease=\"asked-of-you\"\n role=\"alertdialog\"\n aria-label=\"Someone asks for this tab\"\n className=\"aperture:absolute aperture:top-3 aperture:left-1/2 aperture:z-40 aperture:w-88 aperture:max-w-[calc(100%-1rem)] aperture:-translate-x-1/2 aperture:animate-in aperture:overflow-hidden aperture:rounded-xl aperture:border aperture:border-amber-500/60 aperture:bg-popover aperture:text-popover-foreground aperture:shadow-xl aperture:ring-4 aperture:ring-amber-500/25 aperture:duration-200 aperture:fade-in-0 aperture:slide-in-from-top-4\"\n >\n <div className=\"aperture:flex aperture:items-start aperture:gap-3 aperture:p-3\">\n <span className=\"aperture:relative aperture:flex aperture:shrink-0\">\n <span className=\"aperture:absolute aperture:inset-0 aperture:animate-ping aperture:rounded-full aperture:bg-amber-500/50\" />\n {asker === undefined ? (\n <span className=\"aperture:flex aperture:size-6 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-amber-500 aperture:text-white\">\n <Hand className=\"aperture:size-3.5\" />\n </span>\n ) : (\n <MemberAvatar member={asker} className=\"aperture:ring-amber-500\" />\n )}\n </span>\n <div className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:gap-0.5\">\n <span className=\"aperture:text-sm aperture:font-medium\">\n {asker?.name ?? \"Someone\"} asks for this tab\n </span>\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">\n You hold its lease. It goes to them in{\" \"}\n <span className=\"aperture:font-medium aperture:text-foreground aperture:tabular-nums\">\n {left} s\n </span>{\" \"}\n unless you keep it.\n </span>\n </div>\n </div>\n <div className=\"aperture:flex aperture:items-center aperture:justify-end aperture:gap-2 aperture:border-t aperture:bg-muted/40 aperture:px-3 aperture:py-2\">\n <Button type=\"button\" size=\"sm\" variant=\"outline\" onClick={onKeep}>\n Keep\n </Button>\n <Button type=\"button\" size=\"sm\" onClick={onAllow}>\n Allow\n </Button>\n </div>\n <div\n className=\"aperture:h-0.5 aperture:bg-amber-500 aperture:transition-[width] aperture:duration-1000 aperture:ease-linear\"\n style={{ width: `${(left / ANSWER_WITHIN_SECONDS) * 100}%` }}\n />\n </div>\n );\n}\n\n/** What the automation is called when it acts for nobody: with the session's own token. */\nconst OWN_AUTOMATION = \"Agent\";\n\n/**\n * What the automation is called where it holds a tab or points at something: automation\n * as such, and whose it is where it acts for someone. `opens` where a sentence starts\n * with it.\n */\nexport function automationName(member: Member, opens = true): string {\n if (member.name !== OWN_AUTOMATION) {\n return `${member.name}'s automation`;\n }\n return opens ? \"Automation\" : \"automation\";\n}\n\n// None near the green that marks who holds a lease.\nconst MEMBER_HUES = [12, 38, 70, 200, 230, 260, 290, 320, 350];\n\nexport function memberColor(member: Member): string {\n if (member.agent) {\n return \"oklch(0.45 0.02 260)\";\n }\n let hash = 0;\n for (const letter of member.name) {\n hash = (hash * 31 + (letter.codePointAt(0) ?? 0)) % 9973;\n }\n return `oklch(0.55 0.15 ${MEMBER_HUES[hash % MEMBER_HUES.length]})`;\n}\n\nfunction initials(name: string): string {\n return name\n .split(/\\s+/u)\n .slice(0, 2)\n .map((part) => Array.from(part)[0]?.toUpperCase() ?? \"\")\n .join(\"\");\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport { Globe2, Paperclip, Plus, Volume2, VolumeX, X } from \"lucide-react\";\nimport type { Member, Presence, Target } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n ContextMenu,\n ContextMenuContent,\n ContextMenuTrigger,\n} from \"@aperture-browser/ui/components/context-menu\";\nimport {\n createHoverCardHandle,\n HoverCard,\n HoverCardContent,\n HoverCardTrigger,\n type HoverCardHandle,\n} from \"@aperture-browser/ui/components/hover-card\";\nimport { ScrollArea } from \"@aperture-browser/ui/components/scroll-area\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport { MemberDot } from \"./session-presence.tsx\";\n\nconst VISIBLE_WATCHERS = 3;\n\n/** One tab per target. Tabs keep the order the session tells them in: it has no other. */\nexport function BrowserTabStrip() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, recordings, targetFaviconUrl } = useWorkbench();\n const { open, changes } = useInputState();\n const showPresence = features.presence;\n const recordingTabs = new Set(\n recordings.recordings.filter(recordingRuns).map((recording) => recording.tab),\n );\n const [previewHandle] = useState(() => createHoverCardHandle<number>());\n const { targets, presence } = snapshot;\n\n const closePreview = () => {\n if (previewHandle.isOpen) {\n previewHandle.close();\n }\n };\n\n if (targets.length === 0) {\n return (\n <div\n data-browser-tab-strip=\"\"\n className=\"aperture:flex aperture:h-8 aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:gap-2 aperture:px-2 aperture:text-xs aperture:text-muted-foreground\"\n >\n <span>No tabs</span>\n <NewTabButton disabled={!changes} onCreate={() => session.newTab()} />\n </div>\n );\n }\n\n return (\n <>\n <ScrollArea\n data-browser-tab-strip=\"\"\n scrollbars=\"horizontal\"\n // A finger moves the tabs themselves: a bar over them would only cover them.\n className=\"aperture:h-8 aperture:min-w-0 aperture:flex-1 aperture:pointer-coarse:h-10 aperture:pointer-coarse:[&>[data-slot=scroll-area-scrollbar]]:hidden\"\n >\n <div\n data-browser-tab-strip-tabs=\"\"\n // Under a finger a tab is as tall as the strip: nothing of it is too small to press.\n className=\"aperture:flex aperture:min-w-max aperture:items-end aperture:gap-0.5 aperture:px-1 aperture:pt-1 aperture:pointer-coarse:pt-0\"\n >\n {targets.map((target) => (\n <BrowserTab\n key={target.tab}\n target={target}\n active={target.tab === snapshot.selected}\n recording={recordingTabs.has(target.tab)}\n asksForFiles={snapshot.fileRequests.some((request) => request.tab === target.tab)}\n presence={showPresence ? presence : undefined}\n faviconSrc={targetFaviconUrl(target)}\n disabled={!open}\n changes={changes}\n previewHandle={previewHandle}\n onPreviewClose={closePreview}\n />\n ))}\n <NewTabButton disabled={!changes} onCreate={() => session.newTab()} />\n </div>\n </ScrollArea>\n <HoverCard handle={previewHandle}>\n {({ payload }) => {\n const target = targets.find((current) => current.tab === payload);\n // The watched tab is in full view already.\n if (target === undefined || target.tab === snapshot.selected) {\n return null;\n }\n return <TabPreview target={target} />;\n }}\n </HoverCard>\n </>\n );\n}\n\nfunction BrowserTab({\n target,\n active,\n recording,\n asksForFiles,\n presence,\n faviconSrc,\n disabled,\n changes,\n previewHandle,\n onPreviewClose,\n}: {\n target: Target;\n active: boolean;\n recording: boolean;\n asksForFiles: boolean;\n presence: Presence | undefined;\n faviconSrc: string | undefined;\n disabled: boolean;\n /** This member may open and close tabs. */\n changes: boolean;\n previewHandle: HoverCardHandle<number>;\n onPreviewClose: () => void;\n}) {\n const session = useSession();\n const tabRef = useRef<HTMLDivElement>(null);\n const held = presence?.held.find((one) => one.tab === target.tab);\n\n // The watched tab is in sight, also when it was selected elsewhere or the strip is narrow.\n useEffect(() => {\n if (active) {\n tabRef.current?.scrollIntoView({ block: \"nearest\", inline: \"nearest\" });\n }\n }, [active]);\n const watchers =\n presence?.members.filter(\n (member) =>\n member.id !== presence.you && (member.tab === target.tab || member.id === held?.holder),\n ) ?? [];\n // Someone asks this member for the tab: the tab says so too, also while another is watched.\n const askedOfYou = held?.holder === presence?.you && held?.askedBy !== undefined;\n\n const tab = (\n <div\n ref={tabRef}\n data-browser-tab=\"\"\n data-tab={target.tab}\n data-active={active ? \"\" : undefined}\n className={cn(\n \"aperture:group aperture:relative aperture:flex aperture:h-7 aperture:pointer-coarse:h-10 aperture:w-52 aperture:max-w-[38vw] aperture:min-w-28 aperture:items-center aperture:gap-1.5 aperture:rounded-t-lg aperture:border aperture:border-b-0 aperture:px-2 aperture:text-left aperture:text-xs aperture:transition-[background-color,border-color,color] aperture:select-none\",\n active\n ? \"aperture:border-border aperture:bg-background aperture:text-foreground\"\n : \"aperture:border-transparent aperture:bg-muted/55 aperture:text-muted-foreground aperture:hover:bg-muted\",\n )}\n onMouseDown={(event) => {\n // A middle click closes the tab and does not start the browser's scrolling.\n if (event.button === 1) {\n event.preventDefault();\n }\n }}\n onAuxClick={(event) => {\n if (event.button === 1 && changes) {\n event.preventDefault();\n session.closeTab(target.tab);\n }\n }}\n />\n );\n\n return (\n <ContextMenu>\n <ContextMenuTrigger\n render={\n <HoverCardTrigger\n handle={previewHandle}\n payload={target.tab}\n delay={0}\n // Long enough to reach the next tab, which then takes the preview over.\n closeDelay={80}\n render={tab}\n />\n }\n >\n <button\n type=\"button\"\n aria-current={active ? \"page\" : undefined}\n disabled={disabled}\n className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:gap-1.5 aperture:self-stretch aperture:text-left aperture:outline-none\"\n onClick={() => {\n onPreviewClose();\n session.select(target.tab);\n }}\n >\n <TabFavicon src={faviconSrc} />\n {recording ? (\n <>\n <span\n aria-hidden\n className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-destructive\"\n />\n <span className=\"aperture:sr-only\">Being recorded</span>\n </>\n ) : null}\n {asksForFiles ? (\n <>\n <Paperclip\n aria-hidden\n className=\"aperture:size-3.5 aperture:shrink-0 aperture:text-amber-600 aperture:dark:text-amber-400\"\n />\n <span className=\"aperture:sr-only\">Asks for files</span>\n </>\n ) : null}\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {tabLabel(target)}\n </span>\n </button>\n {askedOfYou ? (\n <span\n title=\"Someone asks you for this tab\"\n className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-amber-500\"\n />\n ) : null}\n <TabSoundButton target={target} />\n {watchers.length > 0 ? <TabWatchers watchers={watchers} holder={held?.holder} /> : null}\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n // Small among the tabs, and pressed around it as well where a finger points.\n data-touch-dense=\"\"\n className=\"aperture:relative aperture:-mr-1 aperture:size-5 aperture:shrink-0 aperture:opacity-55 aperture:group-hover:opacity-100 aperture:hover:opacity-100 aperture:pointer-coarse:opacity-100 aperture:pointer-coarse:after:absolute aperture:pointer-coarse:after:-inset-2.5\"\n aria-label=\"Close tab\"\n disabled={!changes}\n onClick={() => session.closeTab(target.tab)}\n >\n <X />\n </Button>\n </ContextMenuTrigger>\n <ContextMenuContent className=\"aperture:min-w-48\">\n <WorkbenchMenuSlot name=\"menu.tab\" kind=\"context\" target={target} />\n </ContextMenuContent>\n </ContextMenu>\n );\n}\n\nfunction TabWatchers({\n watchers,\n holder,\n}: {\n watchers: readonly Member[];\n holder: number | undefined;\n}) {\n // The holder first: who drives the tab matters more than who watches it.\n const ordered = watchers.toSorted(\n (left, right) => Number(right.id === holder) - Number(left.id === holder),\n );\n const visible = ordered.slice(0, VISIBLE_WATCHERS);\n const overflow = ordered.length - visible.length;\n\n return (\n <span\n data-browser-tab-watchers=\"\"\n className=\"aperture:flex aperture:shrink-0 aperture:-space-x-1\"\n >\n {visible.map((member) => (\n <MemberDot key={member.id} member={member} holds={member.id === holder} />\n ))}\n {overflow > 0 ? (\n <span className=\"aperture:flex aperture:h-4 aperture:items-center aperture:rounded-full aperture:bg-muted aperture:px-1 aperture:text-[0.5rem] aperture:ring-1 aperture:ring-background\">\n +{overflow}\n </span>\n ) : null}\n </span>\n );\n}\n\nfunction NewTabButton({ disabled, onCreate }: { disabled: boolean; onCreate: () => void }) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n className=\"aperture:mb-px aperture:shrink-0\"\n aria-label=\"New tab\"\n disabled={disabled}\n onClick={onCreate}\n />\n }\n >\n <Plus />\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">New tab</TooltipContent>\n </Tooltip>\n );\n}\n\nexport function TabFavicon({ src }: { src: string | undefined }) {\n const [failedSrc, setFailedSrc] = useState<string | undefined>(undefined);\n\n if (src === undefined || failedSrc === src) {\n return (\n <Globe2 className=\"aperture:size-3.5 aperture:shrink-0 aperture:text-muted-foreground\" />\n );\n }\n\n return (\n <img\n src={src}\n alt=\"\"\n // A page draws its icon for a light tab or for a dark one, and is shown on either.\n className=\"aperture:size-4 aperture:shrink-0 aperture:rounded-[3px] aperture:dark:bg-white/85 aperture:dark:ring-1 aperture:dark:ring-white/85\"\n onError={() => setFailedSrc(src)}\n />\n );\n}\n\nexport function tabLabel(target: Target): string {\n return target.title.trim() === \"\" ? simplifyUrl(target.url) : target.title;\n}\n\nfunction simplifyUrl(url: string): string {\n if (url === \"\" || url === \"about:blank\") {\n return \"about:blank\";\n }\n try {\n const parsed = new URL(url);\n return `${parsed.host}${parsed.pathname === \"/\" ? \"\" : parsed.pathname}`;\n } catch {\n return url;\n }\n}\n\n/** Tells that a tab sounds, and mutes it for this client; shown for a muted tab too. */\nfunction TabSoundButton({ target }: { target: Target }) {\n const { features } = useWorkbench();\n const sound = useTabSound(target);\n\n if (!features.sound || (!sound.sounds && !sound.muted)) {\n return null;\n }\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n className=\"aperture:size-5 aperture:shrink-0\"\n aria-label={sound.muted ? \"Unmute tab\" : \"Mute tab\"}\n aria-pressed={sound.muted}\n data-browser-tab-sound={sound.muted ? \"muted\" : \"sounds\"}\n onClick={sound.toggle}\n >\n {sound.muted ? <VolumeX /> : <Volume2 />}\n </Button>\n );\n}\n\n/** How wide a tab's preview is asked for: twice the popup's width, for sharp screens. */\nconst PREVIEW_WIDTH = 640;\n\n/** The preview each tab was last shown with, which is there at once the next time. */\nconst lastPreviews = new Map<number, string>();\n\n/**\n * A tab's preview. One popup serves every tab: it fades in for the first one the pointer\n * is over, and moves along to the next.\n */\nfunction TabPreview({ target }: { target: Target }) {\n // The popup is put in its place when it opens, and moves only from there on: a move\n // from where it was before it had a place is not one to show.\n const [placed, setPlaced] = useState(false);\n useEffect(() => {\n let frame = requestAnimationFrame(() => {\n frame = requestAnimationFrame(() => setPlaced(true));\n });\n return () => cancelAnimationFrame(frame);\n }, []);\n\n return (\n <HoverCardContent\n data-browser-tab-preview=\"\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={16}\n positionerClassName={cn(\n \"aperture:pointer-events-none\",\n placed &&\n \"aperture:transition-[top,left,right,bottom,transform] aperture:duration-200 aperture:ease-out\",\n )}\n className=\"aperture:pointer-events-none aperture:flex aperture:w-80 aperture:max-w-[calc(100vw-2rem)] aperture:flex-col aperture:gap-2 aperture:p-2 aperture:transition-opacity aperture:duration-150 aperture:data-ending-style:opacity-0 aperture:data-starting-style:opacity-0\"\n >\n <TabPreviewPicture key={target.tab} target={target} />\n <span className=\"aperture:truncate aperture:text-xs aperture:font-medium\">\n {tabLabel(target)}\n </span>\n <span className=\"aperture:truncate aperture:font-mono aperture:text-xs aperture:text-muted-foreground\">\n {target.url || \"about:blank\"}\n </span>\n </HoverCardContent>\n );\n}\n\nfunction TabPreviewPicture({ target }: { target: Target }) {\n const session = useSession();\n // Made when the tab's preview shows, so it is the page as it is then and not a picture\n // the browser kept.\n const [src] = useState(() => {\n const url = new URL(session.screenshotUrl(target.tab, PREVIEW_WIDTH));\n url.searchParams.set(\"at\", String(Date.now()));\n return url.toString();\n });\n const [before] = useState(() => lastPreviews.get(target.tab));\n const [loaded, setLoaded] = useState(false);\n return (\n <div\n className=\"aperture:aspect-video aperture:w-full aperture:overflow-hidden aperture:rounded-md aperture:bg-muted aperture:bg-cover aperture:bg-top\"\n // What the tab looked like the last time, until it is known what it looks like now.\n style={before === undefined ? undefined : { backgroundImage: `url(\"${before}\")` }}\n >\n <img\n src={src}\n alt=\"\"\n onLoad={() => {\n lastPreviews.set(target.tab, src);\n setLoaded(true);\n }}\n className={cn(\n \"aperture:size-full aperture:object-cover aperture:object-top aperture:transition-opacity aperture:duration-150\",\n loaded ? \"aperture:opacity-100\" : \"aperture:opacity-0\",\n )}\n />\n </div>\n );\n}\n","import {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n type ComponentProps,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { ArrowLeft, ArrowRight, Check, Layers2, Loader2, Plus, RefreshCw, X } from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { InputGroup, InputGroupInput } from \"@aperture-browser/ui/components/input-group\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useAddress } from \"../hooks/use-address.ts\";\nimport { useFinger, useShortWindow } from \"../hooks/use-media.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { BrowserTabStrip } from \"./browser-tab-strip.tsx\";\nimport { SessionPresence } from \"./session-presence.tsx\";\n\n/** The workbench's first row: the tab strip, and who is in the session. */\nexport function WorkbenchTitlebar() {\n const { features, contributions } = useWorkbench();\n const open = useSessionSnapshot().connection.state === \"open\";\n const contributed = contributions.some((one) => one.slot.startsWith(\"titlebar.\"));\n const short = useShortWindow();\n\n // A window too short for two rows has what is here in the toolbar.\n if (short || (!features.tabs && !features.presence && !contributed)) {\n return null;\n }\n return (\n <div\n data-workbench-titlebar=\"\"\n className=\"aperture:flex aperture:h-8 aperture:min-w-0 aperture:shrink-0 aperture:items-stretch aperture:border-b aperture:bg-muted/35 aperture:pointer-coarse:h-10\"\n >\n <WorkbenchSlot name=\"titlebar.start\" />\n {features.tabs ? <BrowserTabStrip /> : <div className=\"aperture:min-w-0 aperture:flex-1\" />}\n {/* Who was here when a connection closed is not who is here now. */}\n {features.presence && open ? <SessionPresence /> : null}\n <WorkbenchSlot name=\"titlebar.end\" />\n </div>\n );\n}\n\nexport const CompactContext = createContext(false);\n\n/** Whether the toolbar is narrow: what has a place in the browser menu shows there alone. */\nexport function useCompactToolbar(): boolean {\n return useContext(CompactContext);\n}\n\n/**\n * Whether the toolbar is narrow under a finger, whose buttons are larger: then only going\n * back, the keyboard and the files keep a button, and the rest is in the browser menu.\n */\nexport function useCrowdedToolbar(): boolean {\n return useFinger() && useContext(CompactContext);\n}\n\n/** Below this width the toolbar keeps the address bar its room by showing fewer buttons. */\nconst COMPACT_BELOW = 520;\n\n/**\n * The workbench's second row: navigation, the address, and the buttons at its end. Without\n * children it is the usual arrangement of its parts.\n */\nexport function WorkbenchToolbar({ children }: { readonly children?: ReactNode }) {\n const toolbarRef = useRef<HTMLDivElement>(null);\n const compact = useNarrowerThan(toolbarRef, COMPACT_BELOW);\n const { features, contributions } = useWorkbench();\n const open = useSessionSnapshot().connection.state === \"open\";\n const connecting = useSessionSnapshot().connection.state === \"connecting\";\n const short = useShortWindow();\n const shows =\n children !== undefined ||\n features.navigation ||\n features.addressBar ||\n features.menus ||\n short ||\n contributions.some((one) => one.slot === \"toolbar.start\" || one.slot === \"toolbar.end\");\n\n if (!shows) {\n return null;\n }\n return (\n <CompactContext.Provider value={compact}>\n <div\n ref={toolbarRef}\n data-workbench-toolbar=\"\"\n data-compact={compact ? \"\" : undefined}\n data-short={short ? \"\" : undefined}\n className=\"aperture:flex aperture:h-9 aperture:min-w-0 aperture:shrink-0 aperture:items-center aperture:gap-1 aperture:border-b aperture:bg-background aperture:px-1.5 aperture:pointer-coarse:h-11 aperture:data-short:pl-0\"\n >\n {children ?? (\n <>\n {short ? <WorkbenchSlot name=\"titlebar.start\" /> : null}\n {short && features.tabs ? <TabsMenu /> : null}\n <WorkbenchSlot name=\"toolbar.start\" />\n {features.navigation ? <NavigationButtons /> : null}\n {features.addressBar ? (\n <AddressBar />\n ) : (\n <div className=\"aperture:min-w-0 aperture:flex-1\" />\n )}\n {connecting ? (\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n ) : null}\n <WorkbenchSlot name=\"toolbar.end\" />\n {short && features.presence && open ? <SessionPresence /> : null}\n {short ? <WorkbenchSlot name=\"titlebar.end\" /> : null}\n {features.menus ? <ToolbarActions /> : null}\n </>\n )}\n </div>\n </CompactContext.Provider>\n );\n}\n\n/** Back, forward and reload of the watched tab. */\nexport function NavigationButtons() {\n const session = useSession();\n const input = useInputState();\n const snapshot = useSessionSnapshot();\n // Where a tab goes is no input to its page: it takes no lease.\n const gives = input.changes && snapshot.selected !== undefined;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const crowded = useCrowdedToolbar();\n\n return (\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center aperture:gap-0.5\">\n <ToolbarButton\n label=\"Back\"\n disabled={!gives || watched?.goesBack !== true}\n onClick={() => session.go({ along: \"back\" })}\n >\n <ArrowLeft />\n </ToolbarButton>\n {crowded ? null : (\n <>\n <ToolbarButton\n label=\"Forward\"\n disabled={!gives || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n </ToolbarButton>\n <ToolbarButton\n label=\"Reload\"\n disabled={!gives}\n onClick={() => session.go({ along: \"reload\" })}\n >\n <RefreshCw />\n </ToolbarButton>\n </>\n )}\n </div>\n );\n}\n\n/** The watched tab's address, and the field to take it elsewhere. */\nexport function AddressBar() {\n const session = useSession();\n const address = useAddress();\n\n return (\n <InputGroup className=\"aperture:h-7 aperture:min-w-0 aperture:pointer-coarse:h-10 aperture:border-transparent aperture:bg-transparent aperture:transition-colors aperture:hover:border-input/50 aperture:hover:bg-muted/35 aperture:has-[[data-slot=input-group-control]:focus-visible]:border-input/70 aperture:has-[[data-slot=input-group-control]:focus-visible]:bg-background aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-2 aperture:has-[[data-slot=input-group-control]:focus-visible]:ring-ring/20 aperture:dark:hover:bg-input/20\">\n <InputGroupInput\n data-workbench-address=\"\"\n aria-label=\"Address\"\n value={address.value}\n onChange={(event) => address.type(event.target.value)}\n onFocus={(event) => event.currentTarget.select()}\n onBlur={address.reset}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (address.submit(event.currentTarget.value)) {\n // The page is what the keyboard is for once it is on its way.\n session.focus();\n }\n }\n if (event.key === \"Escape\") {\n address.reset();\n event.currentTarget.blur();\n }\n }}\n placeholder=\"URL\"\n inputMode=\"url\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n // A phone zooms into a field whose text is smaller than this.\n className=\"aperture:h-7 aperture:px-2 aperture:font-mono aperture:text-xs aperture:text-muted-foreground aperture:transition-colors aperture:focus-visible:text-foreground aperture:pointer-coarse:h-10 aperture:pointer-coarse:text-base\"\n disabled={!address.navigates}\n />\n </InputGroup>\n );\n}\n\n/**\n * The tabs as a menu, for a window too short to keep a row of them: which is watched, the\n * way to another, to close one and to open a new one.\n */\nfunction TabsMenu() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { changes } = useInputState();\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Tabs\"\n data-workbench-tabs-menu=\"\"\n className=\"aperture:shrink-0 aperture:tabular-nums\"\n />\n }\n >\n <Layers2 />\n {snapshot.targets.length}\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" className=\"aperture:w-72\">\n {snapshot.targets.map((target) => (\n <div key={target.tab} className=\"aperture:flex aperture:items-center\">\n <DropdownMenuItem\n className=\"aperture:min-w-0 aperture:flex-1\"\n onClick={() => session.select(target.tab)}\n >\n <Check\n className={target.tab === snapshot.selected ? undefined : \"aperture:invisible\"}\n />\n <span className=\"aperture:truncate\">{target.title || target.url || \"New tab\"}</span>\n </DropdownMenuItem>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={`Close ${target.title || \"tab\"}`}\n disabled={!changes}\n onClick={() => session.closeTab(target.tab)}\n >\n <X />\n </Button>\n </div>\n ))}\n {snapshot.targets.length > 0 ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem disabled={!changes} onClick={() => session.newTab()}>\n <Plus />\n New tab\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** The buttons at the toolbar's end, which are what is contributed to `toolbar.actions`. */\nexport function ToolbarActions() {\n return (\n <div\n data-workbench-menus=\"\"\n className=\"aperture:flex aperture:shrink-0 aperture:items-center aperture:gap-0.5\"\n >\n <WorkbenchSlot name=\"toolbar.actions\" />\n </div>\n );\n}\n\nfunction useNarrowerThan(ref: RefObject<HTMLElement | null>, width: number): boolean {\n const [narrower, setNarrower] = useState(false);\n\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return undefined;\n }\n const measure = () => setNarrower(element.clientWidth < width);\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => sizes.disconnect();\n }, [ref, width]);\n\n return narrower;\n}\n\n/** A button of the toolbar, with its name as a tooltip. */\nexport function ToolbarButton({\n label,\n disabled,\n onClick,\n children,\n ...props\n}: {\n label: string;\n disabled?: boolean;\n onClick?: () => void;\n children: ReactNode;\n} & Omit<ComponentProps<typeof Button>, \"children\" | \"onClick\" | \"disabled\">) {\n return (\n <Tooltip>\n <TooltipTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={label}\n disabled={disabled}\n onClick={onClick}\n {...props}\n />\n }\n >\n {children}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n","import {\n ArrowRight,\n Circle,\n ClipboardPaste,\n Copy,\n Eye,\n Hand,\n Hourglass,\n Keyboard,\n Link2,\n Monitor,\n MoreVertical,\n Pencil,\n RefreshCw,\n RotateCcw,\n SunMoon,\n TextSelect,\n Undo2,\n Volume2,\n VolumeX,\n} from \"lucide-react\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { copyTextHere, pasteHere } from \"../notices.ts\";\nimport {\n useLease,\n useReconnect,\n useSession,\n useSessionSnapshot,\n useWatchedTarget,\n} from \"../session.tsx\";\nimport type { ApertureTheme } from \"../ui-root.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport { ToolbarButton, useCompactToolbar, useCrowdedToolbar } from \"./browser-toolbar.tsx\";\nimport { MenuButton } from \"./menu-parts.tsx\";\nimport { automationName } from \"./session-presence.tsx\";\n\nconst THEMES: Readonly<Record<ApertureTheme, string>> = {\n system: \"As the system\",\n light: \"Light\",\n dark: \"Dark\",\n};\n\n/**\n * A toolbar's menu opens below it and stays there: where the window is short it scrolls\n * in the room there is, and never turns up over the toolbar it was opened from.\n */\nconst BELOW = { side: \"none\", align: \"shift\" } as const;\n\nconst isTheme = (value: unknown): value is ApertureTheme =>\n typeof value === \"string\" && value in THEMES;\n\n/** Brings up a phone's keyboard, which comes only for a field that is focused in a tap. */\nexport function KeyboardAction() {\n const session = useSession();\n const { gives } = useInputState();\n return (\n <ToolbarButton\n label=\"Type into the session\"\n className=\"aperture:hidden aperture:any-pointer-coarse:inline-flex\"\n disabled={!gives}\n onClick={() => session.focus()}\n >\n <Keyboard />\n </ToolbarButton>\n );\n}\n\n/** Draws over the picture for the others to see, instead of giving it input. */\nexport function DrawAction() {\n const { features, drawing, setDrawing } = useWorkbench();\n const members = useSessionSnapshot().presence?.members.length ?? 0;\n\n // Nobody to draw for but oneself.\n if (!features.presence || (members < 2 && !drawing)) {\n return null;\n }\n return (\n <ToolbarButton\n label={drawing ? \"Stop drawing\" : \"Draw over the page for the others\"}\n variant={drawing ? \"secondary\" : \"ghost\"}\n aria-pressed={drawing}\n data-workbench-draw=\"\"\n onClick={() => setDrawing(!drawing)}\n >\n <Pencil />\n </ToolbarButton>\n );\n}\n\n/** The recording menu, from a button that tells when a recording runs. */\nexport function RecordingAction() {\n const { features, recordings } = useWorkbench();\n const compact = useCompactToolbar();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings || compact) {\n return null;\n }\n return (\n <DropdownMenu>\n <MenuButton\n label={active ? \"Recording in progress\" : \"Recording\"}\n variant={active ? \"destructive\" : \"ghost\"}\n data-workbench-recording=\"\"\n >\n <Circle fill={active ? \"currentColor\" : \"none\"} />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-72\">\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** How the picture comes, and the watched tab's viewport. */\nexport function PictureAction() {\n if (useCrowdedToolbar()) {\n return null;\n }\n return (\n <DropdownMenu>\n <MenuButton label=\"Picture and viewport\" data-workbench-picture=\"\">\n <Monitor />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-64\">\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** The menu with the lease, the clipboard and the rest. */\nexport function BrowserMenuAction() {\n return (\n <DropdownMenu>\n <MenuButton label=\"Browser menu\" data-workbench-menu=\"\">\n <MoreVertical />\n </MenuButton>\n <DropdownMenuContent align=\"end\" collisionAvoidance={BELOW} className=\"aperture:w-60\">\n <WorkbenchMenuSlot name=\"menu.browser\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n// The keyboard goes back to the session once the menu has closed and given focus back.\nfunction useThenFocus() {\n const session = useSession();\n return (act: () => void) => () => {\n act();\n requestAnimationFrame(() => session.focus());\n };\n}\n\nexport function CopyItem() {\n const session = useSession();\n const { features } = useWorkbench();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n\n if (!features.access.clipboard.read) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(session.copySelection)}>\n <Copy />\n Copy from the session\n </DropdownMenuItem>\n );\n}\n\nexport function PasteItem() {\n const session = useSession();\n const { features } = useWorkbench();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n\n if (!features.access.clipboard.write) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(() => pasteHere(session))}>\n <ClipboardPaste />\n Paste into the session\n </DropdownMenuItem>\n );\n}\n\nexport function SelectAllItem() {\n const session = useSession();\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n return (\n <DropdownMenuItem disabled={!gives} onClick={thenFocus(session.selectAll)}>\n <TextSelect />\n Select all\n </DropdownMenuItem>\n );\n}\n\nexport function TypeItem() {\n const { gives } = useInputState();\n const thenFocus = useThenFocus();\n return (\n <DropdownMenuItem\n // Where a finger points, the toolbar has a button for it.\n className=\"aperture:any-pointer-coarse:hidden\"\n disabled={!gives}\n onClick={thenFocus(() => undefined)}\n >\n <Keyboard />\n Type into the session\n </DropdownMenuItem>\n );\n}\n\n/** Mutes the watched tab for this client, or lets it be heard again. */\nexport function MuteItem() {\n const { features } = useWorkbench();\n const watched = useWatchedTarget();\n const sound = useTabSound(watched);\n\n if (!features.sound) {\n return null;\n }\n return (\n <DropdownMenuItem disabled={watched === undefined} onClick={sound.toggle}>\n {sound.muted ? <Volume2 /> : <VolumeX />}\n {sound.muted ? \"Unmute the tab\" : \"Mute the tab\"}\n </DropdownMenuItem>\n );\n}\n\n/** The recording menu inside the browser menu, where the toolbar has no room for its button. */\nexport function RecordingSubmenuItem() {\n const { features, recordings } = useWorkbench();\n const compact = useCompactToolbar();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings || !compact) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Circle\n fill={active ? \"currentColor\" : \"none\"}\n className={active ? \"aperture:text-destructive\" : undefined}\n />\n Recording\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-72\">\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** The picture menu inside the browser menu, where the toolbar has no room for its button. */\nexport function PictureSubmenuItem() {\n if (!useCrowdedToolbar()) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <Monitor />\n Picture and viewport\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** Forward and reload inside the browser menu, where the toolbar keeps only the way back. */\nexport function NavigationItems() {\n const session = useSession();\n const { features } = useWorkbench();\n const input = useInputState();\n const watched = useWatchedTarget();\n const gives = input.changes && watched !== undefined;\n\n if (!useCrowdedToolbar() || !features.navigation) {\n return null;\n }\n return (\n <>\n <DropdownMenuItem\n disabled={!gives || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem disabled={!gives} onClick={() => session.go({ along: \"reload\" })}>\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n );\n}\n\nexport function CopyUrlItem() {\n const session = useSession();\n const watched = useWatchedTarget();\n return (\n <DropdownMenuItem\n disabled={watched === undefined}\n onClick={() => {\n if (watched !== undefined) {\n copyTextHere(session, watched.url, \"URL copied\");\n }\n }}\n >\n <Link2 />\n Copy the tab's URL\n </DropdownMenuItem>\n );\n}\n\nexport function AppearanceItem() {\n const { appearance } = useWorkbench();\n\n if (appearance === undefined) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger>\n <SunMoon />\n Appearance\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-44\">\n <DropdownMenuRadioGroup\n aria-label=\"Appearance\"\n value={appearance.theme}\n onValueChange={(value) => {\n if (isTheme(value)) {\n appearance.onThemeChange(value);\n }\n }}\n >\n {Object.entries(THEMES).map(([theme, label]) => (\n <DropdownMenuRadioItem key={theme} value={theme} closeOnClick={false}>\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nexport function ReconnectItem() {\n const reconnect = useReconnect();\n\n if (reconnect === undefined) {\n return null;\n }\n return (\n <DropdownMenuItem onClick={() => reconnect()}>\n <RotateCcw />\n Reconnect\n </DropdownMenuItem>\n );\n}\n\n/** What this member may do about the lease of the watched tab. */\nexport function LeaseItems() {\n const { features } = useWorkbench();\n const session = useSession();\n const lease = useLease();\n const snapshot = useSessionSnapshot();\n const watches = snapshot.connection.state === \"open\" && snapshot.selected !== undefined;\n const holder =\n lease.holder?.agent === true\n ? automationName(lease.holder, false)\n : (lease.holder?.name ?? \"someone\");\n\n if (!features.presence) {\n return null;\n }\n switch (lease.state) {\n case \"view-only\": {\n return (\n <DropdownMenuItem disabled>\n <Eye />\n View only\n </DropdownMenuItem>\n );\n }\n case \"free\": {\n return (\n <DropdownMenuItem disabled={!watches} onClick={() => session.lease(\"take\")}>\n <Hand />\n Take the lease\n </DropdownMenuItem>\n );\n }\n case \"yours\": {\n return (\n <DropdownMenuItem onClick={() => session.lease(\"release\")}>\n <Undo2 />\n Release the lease\n </DropdownMenuItem>\n );\n }\n case \"asked-of-you\": {\n return (\n <>\n <DropdownMenuItem onClick={() => session.lease(\"allow\")}>\n <Undo2 />\n Allow {lease.asker?.name ?? \"them\"} the lease\n </DropdownMenuItem>\n <DropdownMenuItem onClick={() => session.lease(\"keep\")}>\n <Hand />\n Keep the lease\n </DropdownMenuItem>\n </>\n );\n }\n case \"you-asked\": {\n return (\n <DropdownMenuItem disabled>\n <Hourglass />\n Asked {holder} for the lease\n </DropdownMenuItem>\n );\n }\n case \"theirs\":\n case \"theirs-asked\": {\n const takes = lease.role === \"admin\" || lease.holder?.agent === true;\n return (\n <DropdownMenuItem\n disabled={lease.state === \"theirs-asked\" && !takes}\n onClick={() => session.lease(\"take\")}\n >\n <Hand />\n {takes ? `Take the lease from ${holder}` : `Ask ${holder} for the lease`}\n </DropdownMenuItem>\n );\n }\n }\n}\n","import { createContext, useContext, type RefObject } from \"react\";\nimport {\n ArrowRight,\n Circle,\n ClipboardList,\n Eye,\n FolderOpen,\n Keyboard,\n Link2,\n Monitor,\n MoreHorizontal,\n Pencil,\n Plus,\n RefreshCw,\n} from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport type { DrawerSide } from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { recordingRuns } from \"../hooks/use-recordings.ts\";\nimport { copyTextHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchMenuSlot } from \"../workbench/slot.tsx\";\nimport type { useSessionFiles } from \"./session-files.tsx\";\nimport {\n AppearanceItem,\n CopyItem,\n MuteItem,\n PasteItem,\n SelectAllItem,\n} from \"./toolbar-actions.tsx\";\n\n/** What the phone's menu and what is contributed to it share with the bar it is opened from. */\nexport interface PhoneMenuState {\n /** Where the keyboard goes once the menu has closed, where an entry said so. */\n readonly typed: RefObject<HTMLElement | null>;\n /** Puts the bar away, as scrolling down the page does. */\n readonly hideBar: () => void;\n readonly files: ReturnType<typeof useSessionFiles>;\n /** The edge of the window the bar's sheets come in from. */\n readonly side: DrawerSide;\n}\n\nexport const PhoneMenuContext = createContext<PhoneMenuState | null>(null);\n\nfunction usePhoneMenu(): PhoneMenuState {\n const value = useContext(PhoneMenuContext);\n if (value === null) {\n throw new Error(\"A phone menu's entry is used outside the phone's workbench\");\n }\n return value;\n}\n\n/** One of the row of things done most, below the menu's rows: its icon over its name. */\nconst QUICK =\n \"aperture:min-h-14 aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:justify-center aperture:gap-1 aperture:rounded-xl aperture:bg-muted/60 aperture:px-1 aperture:text-xs\";\n\n/**\n * The phone's menu: a sheet with what is contributed to `menu.phone`, whose submenus are\n * pages of it, and below that, nearest the thumb, what is done most as a row of buttons.\n * It opens low at the window's foot and is dragged up for the rest; where the phone is\n * held on its side it comes in from the bar's side, as tall as the window.\n */\nexport function PhoneMenu({\n open,\n onOpenChange,\n className,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n className?: string | undefined;\n}) {\n const session = useSession();\n const { features, recordings } = useWorkbench();\n const { changes } = useInputState();\n const watched = useWatchedTarget();\n const { typed, files, side } = usePhoneMenu();\n const goes = changes && watched !== undefined;\n const recording = recordings.recordings.some(recordingRuns);\n\n return (\n <DropdownMenu\n sheet={side}\n open={open}\n onOpenChange={(next) => {\n if (next) {\n typed.current = null;\n }\n onOpenChange(next);\n }}\n >\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n aria-label=\"Menu\"\n data-workbench-menu=\"\"\n className={cn(\"aperture:relative\", className)}\n />\n }\n >\n <MoreHorizontal />\n {files.request !== undefined || recording ? (\n <span\n className={cn(\n \"aperture:absolute aperture:top-1.5 aperture:right-1.5 aperture:size-2 aperture:rounded-full aperture:ring-2 aperture:ring-background\",\n files.request === undefined\n ? \"aperture:bg-destructive\"\n : \"aperture:animate-pulse aperture:bg-amber-500\",\n )}\n />\n ) : null}\n </DropdownMenuTrigger>\n <DropdownMenuContent\n finalFocus={() => typed.current ?? true}\n data-workbench-phone-menu=\"\"\n footer={\n <DropdownMenuGroup\n className={cn(\n \"aperture:flex aperture:shrink-0 aperture:gap-2 aperture:border-t aperture:border-foreground/8 aperture:px-[max(0.5rem,env(safe-area-inset-left))] aperture:pt-2 aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))]\",\n side === \"left\" && \"aperture:pl-2\",\n side === \"right\" && \"aperture:pr-2\",\n )}\n >\n {features.navigation ? (\n <>\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-forward=\"\"\n disabled={!goes || watched?.goesForward !== true}\n onClick={() => session.go({ along: \"forward\" })}\n >\n <ArrowRight />\n Forward\n </DropdownMenuItem>\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-reload=\"\"\n disabled={!goes}\n onClick={() => session.go({ along: \"reload\" })}\n >\n <RefreshCw />\n Reload\n </DropdownMenuItem>\n </>\n ) : null}\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-copy-url=\"\"\n disabled={watched === undefined}\n onClick={() => {\n if (watched !== undefined) {\n copyTextHere(session, watched.url, \"URL copied\");\n }\n }}\n >\n <Link2 />\n Copy URL\n </DropdownMenuItem>\n {features.tabs ? (\n <DropdownMenuItem\n className={QUICK}\n data-phone-menu-new-tab=\"\"\n disabled={!changes}\n onClick={() => session.newTab()}\n >\n <Plus />\n New tab\n </DropdownMenuItem>\n ) : null}\n </DropdownMenuGroup>\n }\n >\n <WorkbenchMenuSlot name=\"menu.phone\" />\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** Brings up the phone's keyboard for the session, and puts the bar out of its way. */\nexport function PhoneTypeItem() {\n const session = useSession();\n const { gives } = useInputState();\n const { typed, hideBar } = usePhoneMenu();\n return (\n <DropdownMenuItem\n disabled={!gives}\n data-workbench-keyboard=\"\"\n onClick={(event) => {\n const workbench = event.currentTarget.ownerDocument.querySelector(\"[data-workbench-phone]\");\n typed.current =\n workbench?.querySelector<HTMLElement>(\"[data-aperture-surface=keys]\") ?? null;\n // Within the tap: a phone's keyboard comes for nothing later.\n session.focus();\n hideBar();\n }}\n >\n <Keyboard />\n Type into the session\n </DropdownMenuItem>\n );\n}\n\n/** What is copied out of the session and pasted into it. */\nexport function PhoneClipboardItem() {\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"clipboard\">\n <ClipboardList />\n Clipboard\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <CopyItem />\n <PasteItem />\n <SelectAllItem />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nexport function PhoneDrawItem() {\n const { features, drawing, setDrawing } = useWorkbench();\n const members = useSessionSnapshot().presence?.members.length ?? 0;\n\n // Nobody to draw for but oneself.\n if (!features.presence || (members < 2 && !drawing)) {\n return null;\n }\n return (\n <DropdownMenuItem data-workbench-draw=\"\" onClick={() => setDrawing(!drawing)}>\n <Pencil />\n {drawing ? \"Stop drawing\" : \"Draw over the page for the others\"}\n </DropdownMenuItem>\n );\n}\n\nexport function PhoneFilesItem() {\n const { features } = useWorkbench();\n const { files } = usePhoneMenu();\n\n if (!features.files) {\n return null;\n }\n return (\n <DropdownMenuItem data-session-files-button=\"\" onClick={() => files.setOpen(true)}>\n <FolderOpen />\n {files.label}\n </DropdownMenuItem>\n );\n}\n\nexport function PhoneRecordingItem() {\n const { features, recordings } = useWorkbench();\n const active = recordings.recordings.some(recordingRuns);\n\n if (!features.recordings) {\n return null;\n }\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"recording\">\n <Circle\n fill={active ? \"currentColor\" : \"none\"}\n className={active ? \"aperture:text-destructive\" : undefined}\n />\n Recording\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <WorkbenchMenuSlot name=\"menu.recording\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\n/** How the session is shown here: the picture, the sound and the theme. */\nexport function PhoneViewItem() {\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"view\">\n <Eye />\n View\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <DropdownMenuSub>\n <DropdownMenuSubTrigger data-phone-menu-page=\"picture\">\n <Monitor />\n Picture and viewport\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent>\n <WorkbenchMenuSlot name=\"menu.picture\" />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <MuteItem />\n <AppearanceItem />\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n","import { useStored } from \"./use-stored.ts\";\n\nconst POINTERS_KEY = \"aperture.session.pointers\";\n\nconst isBoolean = (value: unknown): value is boolean => typeof value === \"boolean\";\n\n/**\n * Whether the other members' pointers are shown over the picture, which they are unless\n * this browser was told otherwise. What this member's own pointer shows the others is not\n * part of it.\n */\nexport function useShownPointers() {\n return useStored(POINTERS_KEY, true, isBoolean);\n}\n","import { useId, useState } from \"react\";\nimport { Maximize2, MousePointer2 } from \"lucide-react\";\nimport type {\n Picture,\n PictureWay,\n Target,\n VideoFormat,\n VideoQuality,\n} from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n DropdownMenuCheckboxItem,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuSub,\n DropdownMenuSubContent,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Input } from \"@aperture-browser/ui/components/input\";\nimport { useShownPointers } from \"../hooks/use-pointers.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { Described, SettingSubTrigger } from \"./menu-parts.tsx\";\n\nconst AUTO = \"auto\";\n\nconst WAYS: readonly { way: PictureWay; label: string; detail: string }[] = [\n { way: \"video\", label: \"WebRTC\", detail: \"Video on a connection of its own.\" },\n { way: \"frames\", label: \"Frames\", detail: \"The same video on the session socket.\" },\n { way: \"tiles\", label: \"Tiles\", detail: \"Lossless parts of the picture as they change.\" },\n];\n\nconst FORMATS: Readonly<Record<VideoFormat, string>> = {\n h264: \"H.264\",\n \"full-chroma\": \"H.264 4:4:4\",\n h265: \"H.265\",\n vp9: \"VP9\",\n \"vp9-full-chroma\": \"VP9 4:4:4\",\n av1: \"AV1\",\n};\n\nconst QUALITIES: Readonly<Record<VideoQuality, string>> = {\n low: \"Low\",\n medium: \"Medium\",\n full: \"Full\",\n};\n\nconst FRAME_RATES = [15, 30, 60];\n\nconst VIEWPORTS = [\n { width: 1280, height: 720, label: \"1280 × 720\" },\n { width: 1920, height: 1080, label: \"1920 × 1080\" },\n { width: 1440, height: 900, label: \"1440 × 900\" },\n { width: 1024, height: 768, label: \"1024 × 768\" },\n { width: 768, height: 1024, label: \"768 × 1024\", detail: \"Tablet\" },\n { width: 390, height: 844, label: \"390 × 844\", detail: \"Phone\" },\n];\n\nconst SCALES = [1, 1.25, 1.5, 2, 3];\n\nconst VIEWPORT_LIMITS = { min: 100, max: 8192 };\n\nconst isWay = (value: unknown): value is PictureWay => WAYS.some((one) => one.way === value);\n\nconst isFormat = (value: unknown): value is VideoFormat =>\n typeof value === \"string\" && value in FORMATS;\n\nconst isQuality = (value: unknown): value is VideoQuality =>\n typeof value === \"string\" && value in QUALITIES;\n\n/** What the session says it sends, in a line. */\nexport function pictureStatus(picture: Picture): string {\n const way = WAYS.find((one) => one.way === picture.way)?.label ?? picture.way;\n if (picture.way === \"tiles\") {\n return way;\n }\n if (picture.way === \"video\" && picture.rtc !== undefined && picture.rtc !== \"connected\") {\n return `${way} · ${picture.rtc}`;\n }\n const { status } = picture;\n if (status === undefined) {\n return way;\n }\n const parts = [\n way,\n status.format === undefined ? undefined : FORMATS[status.format],\n status.quality === undefined ? undefined : QUALITIES[status.quality].toLowerCase(),\n `${status.fps} fps`,\n ];\n return parts.filter((part) => part !== undefined).join(\" · \");\n}\n\n/** How the picture comes, and the size and scale of the watched target's viewport. */\n/** How the picture comes: its transport, codec, quality and frame rate. */\nexport function PictureItems() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { picture } = snapshot;\n const open = snapshot.connection.state === \"open\";\n const encoded = picture.way !== \"tiles\";\n const { status, settings } = picture;\n\n // A choice left to the session shows what the session chose.\n const chosen = (set: string | undefined, told: string | undefined) => {\n if (set !== undefined) {\n return set;\n }\n return told === undefined ? \"Auto\" : `Auto · ${told}`;\n };\n\n return (\n <>\n <DropdownMenuLabel>\n <span className=\"aperture:flex aperture:flex-col aperture:gap-0.5\">\n <span>Picture</span>\n <span\n data-picture-status=\"\"\n className=\"aperture:font-normal aperture:text-foreground aperture:tabular-nums\"\n >\n {open ? pictureStatus(picture) : \"Not connected\"}\n </span>\n </span>\n </DropdownMenuLabel>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Transport\"\n value={WAYS.find((one) => one.way === picture.way)?.label}\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"How the picture comes\"\n value={picture.way}\n onValueChange={(value) => {\n if (isWay(value)) {\n session.setPicture({ way: value });\n }\n }}\n >\n {WAYS.map(({ way, label, detail }) => (\n <DropdownMenuRadioItem\n key={way}\n value={way}\n disabled={!picture.ways.includes(way)}\n closeOnClick={false}\n >\n <Described title={label}>\n {picture.ways.includes(way) ? detail : \"This browser cannot show it.\"}\n </Described>\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Codec\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.format === undefined ? undefined : FORMATS[settings.format],\n status?.format === undefined ? undefined : FORMATS[status.format],\n )\n : \"None\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-48\">\n <DropdownMenuRadioGroup\n aria-label=\"Codec\"\n value={settings.format ?? AUTO}\n onValueChange={(value) =>\n session.setPicture({ format: isFormat(value) ? value : undefined })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n Auto\n </DropdownMenuRadioItem>\n {Object.entries(FORMATS).map(([format, label]) => (\n <DropdownMenuRadioItem\n key={format}\n value={format}\n disabled={!isFormat(format) || !picture.formats.includes(format)}\n closeOnClick={false}\n >\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Quality\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.quality === undefined ? undefined : QUALITIES[settings.quality],\n status?.quality === undefined ? undefined : QUALITIES[status.quality],\n )\n : \"Lossless\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Quality\"\n value={settings.quality ?? AUTO}\n onValueChange={(value) =>\n session.setPicture({ quality: isQuality(value) ? value : undefined })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n <Described title=\"Auto\">As much as the link carries.</Described>\n </DropdownMenuRadioItem>\n {Object.entries(QUALITIES).map(([quality, label]) => (\n <DropdownMenuRadioItem key={quality} value={quality} closeOnClick={false}>\n {label}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Frame rate\"\n disabled={!encoded}\n value={\n encoded\n ? chosen(\n settings.fps === undefined ? undefined : `${settings.fps} fps`,\n status === undefined ? undefined : `${status.fps} fps`,\n )\n : \"As it changes\"\n }\n />\n <DropdownMenuSubContent className=\"aperture:w-40\">\n <DropdownMenuRadioGroup\n aria-label=\"Frames a second at most\"\n value={settings.fps === undefined ? AUTO : String(settings.fps)}\n onValueChange={(value) =>\n session.setPicture({ fps: value === AUTO ? undefined : Number(value) })\n }\n >\n <DropdownMenuRadioItem value={AUTO} closeOnClick={false}>\n Auto\n </DropdownMenuRadioItem>\n {FRAME_RATES.map((fps) => (\n <DropdownMenuRadioItem key={fps} value={String(fps)} closeOnClick={false}>\n {fps} fps\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n </>\n );\n}\n\n/** Whether the other members' pointers are shown over the picture. */\nexport function PointersItem() {\n const { features } = useWorkbench();\n const [shown, show] = useShownPointers();\n\n if (!features.presence) {\n return null;\n }\n return (\n <DropdownMenuCheckboxItem checked={shown} closeOnClick={false} onCheckedChange={show}>\n <MousePointer2 />\n Show the others' pointers\n </DropdownMenuCheckboxItem>\n );\n}\n\n/** The watched tab's viewport: whether it fits this window, its size and its scale. */\nexport function ViewportItems() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const open = snapshot.connection.state === \"open\";\n const resizes = open && snapshot.features.tabs.write && watched !== undefined;\n\n return (\n <>\n <DropdownMenuLabel>Viewport</DropdownMenuLabel>\n <DropdownMenuCheckboxItem\n checked={snapshot.fit}\n disabled={!resizes}\n closeOnClick={false}\n onCheckedChange={(fit) => {\n if (fit) {\n session.setViewport(\"fit\");\n } else if (watched !== undefined) {\n // Says the size the target has, which ends the fitting and changes nothing else.\n session.setViewport({ width: watched.width, height: watched.height });\n }\n }}\n >\n <Maximize2 />\n Fit to this window\n </DropdownMenuCheckboxItem>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Size\"\n disabled={!resizes}\n value={watched === undefined ? \"\" : `${watched.width} × ${watched.height}`}\n />\n <DropdownMenuSubContent className=\"aperture:w-60\">\n <DropdownMenuRadioGroup\n aria-label=\"Size of the viewport\"\n value={watched === undefined || snapshot.fit ? \"\" : sizeId(watched)}\n onValueChange={(value) => {\n const preset = VIEWPORTS.find((one) => sizeId(one) === value);\n if (preset !== undefined) {\n session.setViewport({ width: preset.width, height: preset.height });\n }\n }}\n >\n {VIEWPORTS.map((preset) => (\n <DropdownMenuRadioItem\n key={sizeId(preset)}\n value={sizeId(preset)}\n closeOnClick={false}\n >\n <span className=\"aperture:tabular-nums\">{preset.label}</span>\n {preset.detail === undefined ? null : (\n <span className=\"aperture:text-xs aperture:text-muted-foreground\">\n {preset.detail}\n </span>\n )}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n <DropdownMenuSeparator />\n {watched === undefined ? null : (\n <CustomViewport\n key={sizeId(watched)}\n target={watched}\n onApply={(width, height) => session.setViewport({ width, height })}\n />\n )}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Scale\"\n disabled={!resizes}\n value={watched === undefined ? \"\" : `${formatScale(watched.scale)}x`}\n />\n <DropdownMenuSubContent className=\"aperture:w-40\">\n <DropdownMenuRadioGroup\n aria-label=\"Pixels to a logical pixel\"\n value={watched === undefined ? \"\" : formatScale(watched.scale)}\n onValueChange={(value) => session.setScale(Number(value))}\n >\n {SCALES.map((scale) => (\n <DropdownMenuRadioItem key={scale} value={formatScale(scale)} closeOnClick={false}>\n {formatScale(scale)}x\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n </>\n );\n}\n\nfunction CustomViewport({\n target,\n onApply,\n}: {\n target: Target;\n onApply: (width: number, height: number) => void;\n}) {\n const [width, setWidth] = useState(String(target.width));\n const [height, setHeight] = useState(String(target.height));\n const size = parseSize(width, height);\n const unchanged = size?.width === target.width && size.height === target.height;\n\n return (\n <div\n className=\"aperture:grid aperture:gap-2 aperture:px-1.5 aperture:py-1.5\"\n // Typing a size is not the menu's typeahead, and a click in a field closes nothing.\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => event.stopPropagation()}\n >\n <DropdownMenuLabel className=\"aperture:px-0\">Custom</DropdownMenuLabel>\n <div className=\"aperture:grid aperture:grid-cols-2 aperture:gap-2\">\n <SizeField label=\"Width\" value={width} onChange={setWidth} />\n <SizeField label=\"Height\" value={height} onChange={setHeight} />\n </div>\n <Button\n type=\"button\"\n size=\"sm\"\n className=\"aperture:h-7\"\n disabled={size === undefined || unchanged}\n onClick={() => {\n if (size !== undefined) {\n onApply(size.width, size.height);\n }\n }}\n >\n Apply\n </Button>\n </div>\n );\n}\n\nfunction SizeField({\n label,\n value,\n onChange,\n}: {\n label: string;\n value: string;\n onChange: (value: string) => void;\n}) {\n const id = useId();\n return (\n <div className=\"aperture:grid aperture:gap-1\">\n <label htmlFor={id} className=\"aperture:text-xs aperture:text-muted-foreground\">\n {label}\n </label>\n <Input\n id={id}\n type=\"text\"\n inputMode=\"numeric\"\n value={value}\n onChange={(event) => onChange(event.currentTarget.value.replaceAll(/\\D/gu, \"\"))}\n onFocus={(event) => event.currentTarget.select()}\n className=\"aperture:h-7 aperture:tabular-nums\"\n />\n </div>\n );\n}\n\nfunction parseSize(width: string, height: string) {\n if (width === \"\" || height === \"\") {\n return undefined;\n }\n const clamp = (side: number) =>\n Math.min(Math.max(Math.round(side), VIEWPORT_LIMITS.min), VIEWPORT_LIMITS.max);\n return { width: clamp(Number(width)), height: clamp(Number(height)) };\n}\n\nfunction sizeId(size: { width: number; height: number }): string {\n return `${size.width}x${size.height}`;\n}\n\nfunction formatScale(scale: number): string {\n return String(Math.round(scale * 100) / 100);\n}\n","import { Fragment, useEffect, useState } from \"react\";\nimport {\n Camera,\n Circle,\n CircleAlert,\n CircleCheck,\n Film,\n Gauge,\n Images,\n Loader2,\n Square,\n} from \"lucide-react\";\nimport type {\n EditRecording,\n Pace,\n Recording,\n RecordingOptions,\n Target,\n} from \"@aperture-browser/session-client\";\nimport {\n DropdownMenuCheckboxItem,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { keptOf, recordingIsEdited, recordingRuns, type Kept } from \"../hooks/use-recordings.ts\";\nimport { useStored } from \"../hooks/use-stored.ts\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport {\n Described,\n formatBytes,\n formatDuration,\n formatStarted,\n SettingSubTrigger,\n Thumbnail,\n} from \"./menu-parts.tsx\";\n\n/** How many recordings that ended and screenshots the menu lists. */\nconst LISTED = 6;\n\nconst SETTINGS_KEY = \"aperture.session.recording\";\n\n/** How an edit is made, as the workbench offers it. */\nexport interface EditSettings {\n readonly capture: \"continuous\" | \"bursts\";\n readonly idle: \"keep\" | \"cut\" | \"speed\";\n readonly ripple: boolean;\n readonly fps: 30 | 60;\n}\n\n/** What a recording is started and stopped with, as this browser remembers it. */\nexport interface RecordingSettings extends EditSettings {\n /** A new recording goes on with whichever tab automation acts on. */\n readonly follow: boolean;\n}\n\nconst DEFAULT_SETTINGS: RecordingSettings = {\n follow: false,\n capture: \"continuous\",\n idle: \"keep\",\n ripple: false,\n fps: 60,\n};\n\nconst CAPTURES = { continuous: \"Continuous\", bursts: \"Bursts\" } as const;\nconst IDLES = { keep: \"Keep\", cut: \"Cut\", speed: \"Speed up\" } as const;\nconst RATES = [30, 60] as const;\n\nconst isSettings = (value: unknown): value is RecordingSettings => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const { follow, capture, idle, ripple, fps } = value as Record<string, unknown>;\n return (\n typeof follow === \"boolean\" &&\n typeof capture === \"string\" &&\n capture in CAPTURES &&\n typeof idle === \"string\" &&\n idle in IDLES &&\n typeof ripple === \"boolean\" &&\n RATES.some((rate) => rate === fps)\n );\n};\n\nexport function useRecordingSettings() {\n return useStored(SETTINGS_KEY, DEFAULT_SETTINGS, isSettings);\n}\n\n/** What the session is asked for an edit made as `settings` say. */\nexport function editOptions(settings: EditSettings): EditRecording {\n const bursts = settings.capture === \"bursts\";\n return {\n capture: settings.capture,\n // Bursts keep only what happens, so there are no quiet stretches to shorten.\n idle: bursts || settings.idle === \"keep\" ? null : settings.idle,\n ripple: settings.ripple,\n fps: settings.fps,\n };\n}\n\n/** What the workbench offers of the options an edit was made with. */\nexport function editSettings(options: RecordingOptions | undefined): EditSettings {\n if (options === undefined) {\n return DEFAULT_SETTINGS;\n }\n return {\n capture: options.capture,\n idle: options.idle ?? \"keep\",\n ripple: options.ripple,\n fps: options.fps > 30 ? 60 : 30,\n };\n}\n\n/** Starts a recording of the watched tab. */\nexport function RecordItem() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const [settings] = useRecordingSettings();\n const watched = useWatchedTarget();\n const allowed = snapshot.features.recordings.write;\n const recordsWatched = recordings.recordings.some(\n (one) => recordingRuns(one) && one.tab === watched?.tab,\n );\n const canStart =\n snapshot.connection.state === \"open\" &&\n allowed &&\n watched !== undefined &&\n !recordsWatched &&\n !recordings.busy;\n\n const start = () => {\n if (watched === undefined) {\n return;\n }\n recordings.start({ tab: watched.tab, follow: settings.follow }).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The recording did not start\",\n description: failureText(cause),\n });\n });\n };\n\n return (\n <DropdownMenuItem disabled={!canStart} onClick={start}>\n <Circle />\n {allowed ? (\n \"Record this tab\"\n ) : (\n <Described title=\"Record this tab\">Not yours to make here</Described>\n )}\n </DropdownMenuItem>\n );\n}\n\n/** The recordings that run, each with the means to stop it. */\nexport function RunningRecordingItems() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const running = recordings.recordings.filter(recordingRuns);\n const now = useNow(running.length > 0);\n const allowed = snapshot.features.recordings.write;\n const [settings] = useRecordingSettings();\n\n // One press: the edit is made as this browser last chose, which the menu shows below.\n const stop = (recording: Recording) => {\n recordings.stop(recording.id, editOptions(settings)).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The recording did not stop\",\n description: failureText(cause),\n });\n });\n };\n\n return running.map((recording) => (\n <Fragment key={recording.id}>\n <DropdownMenuLabel>\n <span className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:justify-between aperture:gap-2\">\n <span className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:gap-1.5\">\n <span className=\"aperture:size-2 aperture:shrink-0 aperture:animate-pulse aperture:rounded-full aperture:bg-destructive\" />\n <span className=\"aperture:truncate\">{targetName(snapshot.targets, recording.tab)}</span>\n </span>\n <span className=\"aperture:shrink-0 aperture:tabular-nums\">\n {formatDuration(now - recording.started_at_ms)}\n </span>\n </span>\n </DropdownMenuLabel>\n <DropdownMenuItem disabled={recordings.busy || !allowed} onClick={() => stop(recording)}>\n <Square />\n Stop recording\n </DropdownMenuItem>\n </Fragment>\n ));\n}\n\n/**\n * What the session kept of its tabs: the recordings that ended and the screenshots, as one\n * list. Each opens in the gallery.\n */\nexport function KeptItems() {\n const { recordings, view } = useWorkbench();\n const session = useSession();\n const kept = keptOf(recordings);\n\n if (kept.length === 0) {\n return null;\n }\n return (\n <>\n <DropdownMenuLabel>Recordings and screenshots</DropdownMenuLabel>\n {kept.slice(0, LISTED).map((one) => (\n <DropdownMenuItem\n key={one.id}\n data-kept={one.kind}\n data-kept-id={one.id}\n onClick={() => view(one.id)}\n >\n <Thumbnail src={keptPreview(one, session.fileUrl)}>\n {one.kind === \"recording\" ? <Film /> : <Camera />}\n </Thumbnail>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:tabular-nums\">{formatStarted(one.at)}</span>\n <KeptFacts kept={one} />\n </span>\n </DropdownMenuItem>\n ))}\n {kept.length > LISTED ? (\n <DropdownMenuItem onClick={() => view(kept[0]?.id)}>\n <Images />\n All {kept.length}\n </DropdownMenuItem>\n ) : null}\n </>\n );\n}\n\nexport function keptPreview(kept: Kept, fileUrl: (path: string) => string): string | undefined {\n if (kept.kind === \"screenshot\") {\n return fileUrl(kept.screenshot.preview);\n }\n return kept.recording.preview === null ? undefined : fileUrl(kept.recording.preview);\n}\n\n/** What a kept thing is and how it went, in a line. */\nexport function KeptFacts({ kept }: { kept: Kept }) {\n if (kept.kind === \"screenshot\") {\n return (\n <span className=\"aperture:truncate aperture:text-xs aperture:text-muted-foreground\">\n Screenshot · {formatBytes(kept.screenshot.bytes)}\n </span>\n );\n }\n const { recording } = kept;\n const editing = recordingIsEdited(recording);\n const failed = recording.state === \"failed\" || recording.edit?.state === \"failed\";\n let state = \"Finished\";\n if (recording.state === \"failed\") {\n state = \"Failed\";\n } else if (editing) {\n state = \"Editing\";\n } else if (recording.edit?.state === \"failed\") {\n state = \"Edit failed\";\n }\n const facts = [\n \"Recording\",\n recording.duration_ms === null ? undefined : formatDuration(recording.duration_ms),\n recording.bytes === null ? undefined : formatBytes(recording.bytes),\n state,\n ].filter((fact) => fact !== undefined);\n\n return (\n <span\n data-recording-state={state}\n className=\"aperture:flex aperture:min-w-0 aperture:items-center aperture:gap-1 aperture:text-xs aperture:text-muted-foreground aperture:[&_svg]:size-3 aperture:[&_svg]:shrink-0\"\n >\n {editing ? <Loader2 className=\"aperture:animate-spin\" /> : null}\n {!editing && failed ? <CircleAlert className=\"aperture:text-destructive\" /> : null}\n {!editing && !failed ? <CircleCheck className=\"aperture:text-emerald-600\" /> : null}\n <span className=\"aperture:truncate\">{facts.join(\" · \")}</span>\n </span>\n );\n}\n\n/** Takes a screenshot of the watched tab, which the session keeps in its files. */\nexport function ScreenshotItem() {\n const { recordings } = useWorkbench();\n const snapshot = useSessionSnapshot();\n const watched = useWatchedTarget();\n const allowed = snapshot.features.recordings.write;\n const takes = snapshot.connection.state === \"open\" && allowed && watched !== undefined;\n\n const take = () => {\n if (watched === undefined) {\n return;\n }\n recordings.takeScreenshot(watched.tab).then(\n () =>\n showNotice({\n level: \"info\",\n message: \"Screenshot taken\",\n description: \"It is in the recording menu and in the session's files.\",\n }),\n (cause: unknown) =>\n showNotice({\n level: \"error\",\n message: \"The screenshot was not taken\",\n description: failureText(cause),\n }),\n );\n };\n\n return (\n <DropdownMenuItem disabled={!takes} closeOnClick={false} onClick={take}>\n <Camera />\n {allowed ? \"Screenshot\" : <Described title=\"Screenshot\">Not yours to make here</Described>}\n </DropdownMenuItem>\n );\n}\n\n/** How a new recording is made, and how the one that stops is edited. */\nexport function RecordingSettingsItems() {\n const [settings, onChange] = useRecordingSettings();\n\n return (\n <>\n <DropdownMenuLabel>New recording</DropdownMenuLabel>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuCheckboxItem\n checked={settings.follow}\n closeOnClick={false}\n onCheckedChange={(follow) => onChange({ ...settings, follow })}\n />\n }\n >\n Follow automation\n </TooltipTrigger>\n <TooltipContent side=\"left\">\n The recording goes on with whichever tab automation acts on, in the same video.\n </TooltipContent>\n </Tooltip>\n <DropdownMenuLabel>When a recording stops</DropdownMenuLabel>\n <EditSettingsItems\n settings={settings}\n onChange={(edit) => onChange({ ...settings, ...edit })}\n />\n </>\n );\n}\n\n/** The session's pace: how automation moves the pointer in what is recorded. */\nexport function AutomationPaceItem() {\n const { features } = useWorkbench();\n const session = useSession();\n const snapshot = useSessionSnapshot();\n\n if (!features.recordings) {\n return null;\n }\n const set = (pace: Pace) => {\n session.pace.set(pace).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: \"The pace was not set\",\n description: failureText(cause),\n });\n });\n };\n return (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger disabled={!snapshot.features.recordings.write}>\n <Gauge />\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-center aperture:justify-between aperture:gap-3\">\n <span data-menu-title=\"\" className=\"aperture:shrink-0\">\n Automation pace\n </span>\n <span className=\"aperture:truncate aperture:text-muted-foreground\">\n {PACES[snapshot.pace]}\n </span>\n </span>\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Automation pace\"\n value={snapshot.pace}\n onValueChange={(value) => {\n if (value === \"instant\" || value === \"fast\" || value === \"slow\") {\n set(value);\n }\n }}\n >\n <DropdownMenuRadioItem value=\"instant\" closeOnClick={false}>\n <Described title=\"Instant\">The pointer jumps straight to each action.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"fast\" closeOnClick={false}>\n <Described title=\"Fast\">\n In a recorded tab the pointer travels there, quickly but so that the eye can follow.\n </Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"slow\" closeOnClick={false}>\n <Described title=\"Slow\">Unhurried travel and longer pauses, for demos.</Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n}\n\nconst PACES = { instant: \"Instant\", fast: \"Fast\", slow: \"Slow\" } as const;\n\n/** How an edit is made: what a recording is stopped with, or edited again with. */\nexport function EditSettingsItems({\n settings,\n onChange,\n}: {\n settings: EditSettings;\n onChange: (settings: EditSettings) => void;\n}) {\n const bursts = settings.capture === \"bursts\";\n\n return (\n <>\n <DropdownMenuSub>\n <SettingSubTrigger name=\"Capture\" value={CAPTURES[settings.capture]} />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Capture\"\n value={settings.capture}\n onValueChange={(value) => {\n if (value === \"continuous\" || value === \"bursts\") {\n onChange({ ...settings, capture: value });\n }\n }}\n >\n <DropdownMenuRadioItem value=\"continuous\" closeOnClick={false}>\n <Described title=\"Continuous\">\n Keep the tab from start to stop, with what is done by hand.\n </Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"bursts\" closeOnClick={false}>\n <Described title=\"Automation bursts\">\n Keep only the stretches around what automation did. Clicking or typing here starts\n none.\n </Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger\n name=\"Quiet stretches\"\n value={bursts ? \"Continuous only\" : IDLES[settings.idle]}\n />\n <DropdownMenuSubContent className=\"aperture:w-64\">\n <DropdownMenuRadioGroup\n aria-label=\"Quiet stretches\"\n value={settings.idle}\n onValueChange={(value) => {\n if (value === \"keep\" || value === \"cut\" || value === \"speed\") {\n onChange({ ...settings, idle: value });\n }\n }}\n >\n <DropdownMenuRadioItem value=\"keep\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Keep\">Leave pauses as long as they were.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"cut\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Cut\">Leave out the stretches in which nothing happens.</Described>\n </DropdownMenuRadioItem>\n <DropdownMenuRadioItem value=\"speed\" disabled={bursts} closeOnClick={false}>\n <Described title=\"Speed up\">Play those stretches faster.</Described>\n </DropdownMenuRadioItem>\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <DropdownMenuSub>\n <SettingSubTrigger name=\"Frame rate\" value={`${settings.fps} fps`} />\n <DropdownMenuSubContent className=\"aperture:w-44\">\n <DropdownMenuRadioGroup\n aria-label=\"Frame rate\"\n value={String(settings.fps)}\n onValueChange={(value) => {\n const fps = RATES.find((rate) => String(rate) === value);\n if (fps !== undefined) {\n onChange({ ...settings, fps });\n }\n }}\n >\n {RATES.map((rate) => (\n <DropdownMenuRadioItem key={rate} value={String(rate)} closeOnClick={false}>\n {rate} fps\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n <Tooltip>\n <TooltipTrigger\n render={\n <DropdownMenuCheckboxItem\n checked={settings.ripple}\n closeOnClick={false}\n onCheckedChange={(ripple) => onChange({ ...settings, ripple })}\n />\n }\n >\n Highlight clicks\n </TooltipTrigger>\n <TooltipContent side=\"left\">\n Marks clicks with a ripple in the recording edit. The raw recording stays as it is.\n </TooltipContent>\n </Tooltip>\n </>\n );\n}\n\nfunction targetName(targets: readonly Target[], tab: number): string {\n const target = targets.find((one) => one.tab === tab);\n if (target === undefined) {\n return \"A closed tab\";\n }\n return target.title.trim() === \"\" ? target.url : target.title;\n}\n\nfunction useNow(ticking: boolean): number {\n const [now, setNow] = useState(() => Date.now());\n\n useEffect(() => {\n if (!ticking) {\n return undefined;\n }\n setNow(Date.now());\n const timer = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(timer);\n }, [ticking]);\n\n return now;\n}\n","import { useEffect, useRef, useState, type DragEvent } from \"react\";\nimport {\n ArrowDownToLine,\n ArrowUpFromLine,\n Check,\n CircleAlert,\n FileIcon,\n FolderOpen,\n Loader2,\n Trash2,\n} from \"lucide-react\";\nimport type { Download, FileRequest, Uploaded } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@aperture-browser/ui/components/popover\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@aperture-browser/ui/components/tooltip\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useUploads, type UploadsControl } from \"../hooks/use-uploads.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { formatBytes } from \"./menu-parts.tsx\";\n\n/**\n * The session's files, from a button of the toolbar: what was uploaded for its browser to\n * take, what it downloaded, and the files a page of the watched tab asks for. The panel\n * opens by itself when a page asks and when a download is done.\n */\nexport function SessionFilesButton() {\n const { features } = useWorkbench();\n const { open, setOpen, request, busy, label, panel } = useSessionFiles();\n\n if (!features.files) {\n return null;\n }\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <Tooltip>\n <TooltipTrigger\n render={\n <PopoverTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={label}\n data-session-files-button=\"\"\n className=\"aperture:relative\"\n />\n }\n />\n }\n >\n <FolderOpen />\n {request !== undefined ? (\n <span className=\"aperture:absolute aperture:top-0.5 aperture:right-0.5 aperture:size-2 aperture:animate-pulse aperture:rounded-full aperture:bg-amber-500 aperture:ring-2 aperture:ring-background\" />\n ) : null}\n {request === undefined && busy > 0 ? (\n <span className=\"aperture:absolute aperture:-top-0.5 aperture:-right-0.5 aperture:flex aperture:h-3.5 aperture:min-w-3.5 aperture:items-center aperture:justify-center aperture:rounded-full aperture:bg-primary aperture:px-0.5 aperture:text-[0.5625rem] aperture:leading-none aperture:font-medium aperture:text-primary-foreground\">\n {busy}\n </span>\n ) : null}\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{label}</TooltipContent>\n </Tooltip>\n <PopoverContent\n align=\"end\"\n className=\"aperture:w-88 aperture:max-w-[calc(100vw-1rem)] aperture:gap-0 aperture:p-0\"\n aria-label=\"Files\"\n data-session-files=\"\"\n >\n {panel}\n </PopoverContent>\n </Popover>\n );\n}\n\n/**\n * The session's files as a panel that is opened from somewhere: whether it is open, which\n * it is by itself when a page asks for a file and when a download is done, and what tells\n * of it where it is opened from. In a `sheet` the panel is as long as what it holds, and\n * the sheet is what scrolls.\n */\nexport function useSessionFiles({ sheet = false }: { sheet?: boolean } = {}) {\n const snapshot = useSessionSnapshot();\n const { features } = useWorkbench();\n const uploads = useUploads(features.uploads);\n const [open, setOpen] = useState(false);\n const request = snapshot.fileRequests.find((one) => one.tab === snapshot.selected);\n const running = snapshot.downloads.filter((download) => download.state === \"running\").length;\n const done = snapshot.downloads.filter((download) => download.state === \"done\").length;\n const busy = running + uploads.inProgress.length;\n\n const { refresh } = uploads;\n const seen = useRef({ request: request?.id, done });\n useEffect(() => {\n const asked = request !== undefined && request.id !== seen.current.request;\n const finished = done > seen.current.done;\n seen.current = { request: request?.id, done };\n if (asked || finished) {\n setOpen(true);\n }\n }, [request, done]);\n\n // Another member may have uploaded since the panel was last open.\n useEffect(() => {\n if (open) {\n refresh();\n }\n }, [open, refresh]);\n\n return {\n open,\n setOpen,\n request,\n busy,\n label: request === undefined ? \"Files\" : \"Files: a page asks for one\",\n panel: (\n <SessionFiles\n uploads={uploads}\n request={request}\n downloads={snapshot.downloads}\n offers={features}\n puts={features.access.uploads.write}\n sheet={sheet}\n />\n ),\n };\n}\n\nfunction SessionFiles({\n uploads,\n request,\n downloads,\n offers,\n puts,\n sheet,\n}: {\n uploads: UploadsControl;\n request: FileRequest | undefined;\n downloads: readonly Download[];\n /** Which of the two the session has. */\n offers: { readonly uploads: boolean; readonly downloads: boolean };\n /** This member may put files into the session, and answer pages with them. */\n puts: boolean;\n sheet: boolean;\n}) {\n const session = useSession();\n const picker = useRef<HTMLInputElement>(null);\n const [dragging, setDragging] = useState(false);\n const [chosen, setChosen] = useState<readonly string[]>([]);\n\n // A choice made for one request is not one for the next.\n const requestId = request?.id;\n useEffect(() => setChosen([]), [requestId]);\n\n const failed = (file: File, cause: unknown) =>\n showNotice({\n level: \"error\",\n message: `${file.name} was not uploaded`,\n description: failureText(cause),\n });\n\n const put = async (files: readonly File[], answers: FileRequest | undefined) => {\n const uploaded = await uploads.upload(files, failed);\n // Files picked while a page asks are the answer, as they are in a browser of one's own.\n if (answers !== undefined && uploaded.length > 0) {\n const names = uploaded.map((file) => file.name);\n session.chooseFiles(answers.id, answers.multiple ? names : names.slice(0, 1));\n }\n };\n\n const toggle = (name: string) => {\n if (request === undefined) {\n return;\n }\n if (!request.multiple) {\n setChosen(chosen.includes(name) ? [] : [name]);\n return;\n }\n setChosen(chosen.includes(name) ? chosen.filter((one) => one !== name) : [...chosen, name]);\n };\n\n const remove = (file: Uploaded) => {\n uploads.remove(file.name).catch((cause: unknown) => {\n showNotice({\n level: \"error\",\n message: `${file.name} was not removed`,\n description: failureText(cause),\n });\n });\n };\n\n const drop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragging(false);\n const files = Array.from(event.dataTransfer.files);\n if (files.length > 0) {\n void put(files, undefined);\n }\n };\n\n const existing = chosen.filter((name) => uploads.uploads.some((file) => file.name === name));\n const listed = downloads.toReversed();\n\n return (\n <div\n className={cn(\n \"aperture:relative aperture:flex aperture:flex-col\",\n sheet ? \"aperture:min-h-full\" : \"aperture:max-h-[min(32rem,calc(100dvh-6rem))]\",\n )}\n onDragOver={(event) => {\n if (offers.uploads && puts && event.dataTransfer.types.includes(\"Files\")) {\n event.preventDefault();\n event.dataTransfer.dropEffect = \"copy\";\n setDragging(true);\n }\n }}\n onDragLeave={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {\n setDragging(false);\n }\n }}\n onDrop={drop}\n >\n <input\n ref={picker}\n type=\"file\"\n hidden\n multiple={request === undefined || request.multiple}\n data-session-file-input=\"\"\n onChange={(event) => {\n const files = Array.from(event.currentTarget.files ?? []);\n event.currentTarget.value = \"\";\n if (files.length > 0) {\n void put(files, request);\n }\n }}\n />\n {request === undefined ? null : (\n <div\n data-session-file-request=\"\"\n className=\"aperture:flex aperture:flex-col aperture:gap-2 aperture:border-b aperture:border-amber-500/40 aperture:bg-amber-500/10 aperture:p-2.5\"\n >\n <span className=\"aperture:text-sm aperture:font-medium\">\n {request.multiple ? \"The page asks for files\" : \"The page asks for a file\"}\n </span>\n <div className=\"aperture:flex aperture:flex-wrap aperture:items-center aperture:gap-1.5\">\n <Button\n type=\"button\"\n size=\"sm\"\n disabled={!puts}\n onClick={() => picker.current?.click()}\n >\n <ArrowUpFromLine />\n Upload…\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n disabled={existing.length === 0 || !puts}\n onClick={() => session.chooseFiles(request.id, existing)}\n >\n <Check />\n {giveLabel(request, existing.length)}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n className=\"aperture:ml-auto\"\n disabled={!puts}\n onClick={() => session.chooseFiles(request.id, [])}\n >\n Cancel\n </Button>\n </div>\n </div>\n )}\n <div className={cn(\"aperture:flex-1\", !sheet && \"aperture:min-h-0 aperture:overflow-y-auto\")}>\n {offers.uploads ? (\n <section className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:p-2.5\">\n <header className=\"aperture:flex aperture:h-6 aperture:items-center aperture:justify-between aperture:gap-2\">\n <h3 className=\"aperture:text-xs aperture:text-muted-foreground\">Uploads</h3>\n {request === undefined ? (\n <Button\n type=\"button\"\n size=\"xs\"\n variant=\"outline\"\n disabled={!puts}\n onClick={() => picker.current?.click()}\n >\n <ArrowUpFromLine />\n Upload\n </Button>\n ) : null}\n </header>\n {uploads.inProgress.map((file) => (\n <div\n key={file.name}\n data-session-upload-progress=\"\"\n className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:rounded-md aperture:px-1.5 aperture:py-1\"\n >\n <div className=\"aperture:flex aperture:items-center aperture:gap-2 aperture:text-sm\">\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {file.name}\n </span>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {percent(file.loaded, file.total)}\n </span>\n </div>\n <div className=\"aperture:h-1 aperture:overflow-hidden aperture:rounded-full aperture:bg-muted\">\n <div\n className=\"aperture:h-full aperture:rounded-full aperture:bg-primary aperture:transition-[width]\"\n style={{ width: percent(file.loaded, file.total) }}\n />\n </div>\n </div>\n ))}\n {uploads.uploads.map((file) => {\n const picked = chosen.includes(file.name);\n return (\n <div\n key={file.name}\n data-session-upload={file.name}\n className={cn(\n \"aperture:group/file aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm\",\n request !== undefined && \"aperture:cursor-default aperture:hover:bg-muted\",\n picked && \"aperture:bg-accent aperture:text-accent-foreground\",\n )}\n role={request === undefined ? undefined : \"option\"}\n aria-selected={request === undefined ? undefined : picked}\n onClick={() => toggle(file.name)}\n >\n {picked ? (\n <Check className=\"aperture:size-4 aperture:shrink-0\" />\n ) : (\n <FileIcon className=\"aperture:size-4 aperture:shrink-0 aperture:text-muted-foreground\" />\n )}\n <span\n className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\"\n title={file.path}\n >\n {file.name}\n </span>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {formatBytes(file.size)}\n </span>\n <Button\n type=\"button\"\n size=\"icon-xs\"\n variant=\"ghost\"\n aria-label={`Remove ${file.name}`}\n className=\"aperture:shrink-0 aperture:opacity-55 aperture:group-hover/file:opacity-100 aperture:hover:opacity-100 aperture:pointer-coarse:opacity-100\"\n disabled={!puts}\n onClick={(event) => {\n event.stopPropagation();\n remove(file);\n }}\n >\n <Trash2 />\n </Button>\n </div>\n );\n })}\n {uploads.uploads.length === 0 && uploads.inProgress.length === 0 ? (\n <p\n title={puts ? \"Drop files here, or onto the page itself\" : undefined}\n className=\"aperture:rounded-md aperture:border aperture:border-dashed aperture:px-2 aperture:py-3 aperture:text-center aperture:text-xs aperture:text-muted-foreground\"\n >\n Nothing uploaded\n </p>\n ) : null}\n </section>\n ) : null}\n {offers.downloads ? (\n <section className=\"aperture:flex aperture:flex-col aperture:gap-1 aperture:p-2.5 aperture:not-first:border-t\">\n <header className=\"aperture:flex aperture:h-6 aperture:items-center\">\n <span className=\"aperture:text-xs aperture:font-medium aperture:text-muted-foreground\">\n Downloads\n </span>\n </header>\n {listed.map((download) => (\n <DownloadRow\n key={download.id}\n download={download}\n href={session.fileUrl(`downloads/${download.name}`)}\n />\n ))}\n {listed.length === 0 ? (\n <p className=\"aperture:px-1.5 aperture:py-1 aperture:text-xs aperture:text-muted-foreground\">\n No downloads\n </p>\n ) : null}\n </section>\n ) : null}\n </div>\n {dragging ? (\n <div className=\"aperture:pointer-events-none aperture:absolute aperture:inset-1 aperture:flex aperture:items-center aperture:justify-center aperture:rounded-md aperture:border-2 aperture:border-dashed aperture:border-primary/60 aperture:bg-background/90 aperture:text-sm aperture:font-medium\">\n Drop to upload\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction DownloadRow({ download, href }: { download: Download; href: string }) {\n const { state } = download;\n const received = formatBytes(download.receivedBytes);\n const progress =\n download.totalBytes === undefined || download.totalBytes === 0\n ? received\n : percent(download.receivedBytes, download.totalBytes);\n\n return (\n <div\n data-session-download={download.name}\n data-state={state}\n className=\"aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:px-1.5 aperture:py-1 aperture:text-sm\"\n title={download.url}\n >\n {state === \"done\" ? (\n <ArrowDownToLine className=\"aperture:size-4 aperture:shrink-0 aperture:text-muted-foreground\" />\n ) : null}\n {state === \"failed\" ? (\n <CircleAlert className=\"aperture:size-4 aperture:shrink-0 aperture:text-destructive\" />\n ) : null}\n {state !== \"done\" && state !== \"failed\" ? (\n <Loader2 className=\"aperture:size-4 aperture:shrink-0 aperture:animate-spin aperture:text-muted-foreground\" />\n ) : null}\n {state === \"done\" ? (\n <a\n href={href}\n download={download.name}\n className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:underline aperture:decoration-muted-foreground/50 aperture:underline-offset-2 aperture:hover:decoration-foreground\"\n >\n {download.name}\n </a>\n ) : (\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">{download.name}</span>\n )}\n <span\n className={cn(\n \"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\",\n state === \"failed\" && \"aperture:text-destructive\",\n )}\n >\n {state === \"done\" ? received : null}\n {state === \"failed\" ? \"Failed\" : null}\n {state !== \"done\" && state !== \"failed\" ? progress : null}\n </span>\n </div>\n );\n}\n\nfunction giveLabel(request: FileRequest, chosen: number): string {\n if (chosen > 1) {\n return `Give ${chosen} files`;\n }\n return request.multiple && chosen === 0 ? \"Give the files\" : \"Give the file\";\n}\n\nfunction percent(loaded: number, total: number): string {\n return total <= 0 ? \"0%\" : `${Math.min(100, Math.round((100 * loaded) / total))}%`;\n}\n","import { ContextMenuItem } from \"@aperture-browser/ui/components/context-menu\";\nimport { useInputState, useTabSound } from \"../hooks/use-actions.ts\";\nimport { copyTextHere } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport type { WorkbenchSlotProps } from \"../workbench/contributions.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\n\nexport function TabReloadItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const watched = useSessionSnapshot().selected === target?.tab;\n return (\n <ContextMenuItem\n disabled={!changes || !watched}\n onClick={() => session.go({ along: \"reload\" })}\n >\n Reload\n </ContextMenuItem>\n );\n}\n\nexport function TabDuplicateItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const url = target?.url ?? \"\";\n return (\n <ContextMenuItem\n disabled={!changes || url === \"\"}\n onClick={() => session.go({ url }, { newTab: true })}\n >\n Duplicate\n </ContextMenuItem>\n );\n}\n\nexport function TabCopyUrlItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n return (\n <ContextMenuItem\n onClick={() => copyTextHere(session, target?.url || \"about:blank\", \"URL copied\")}\n >\n Copy URL\n </ContextMenuItem>\n );\n}\n\n/** Mutes the tab for this client, or lets it be heard again. */\nexport function TabMuteItem({ target }: WorkbenchSlotProps) {\n const { features } = useWorkbench();\n const sound = useTabSound(target);\n\n if (!features.sound) {\n return null;\n }\n return (\n <ContextMenuItem onClick={sound.toggle}>{sound.muted ? \"Unmute\" : \"Mute\"}</ContextMenuItem>\n );\n}\n\nexport function TabCloseItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n return (\n <ContextMenuItem\n disabled={!changes || target === undefined}\n onClick={() => {\n if (target !== undefined) {\n session.closeTab(target.tab);\n }\n }}\n >\n Close\n </ContextMenuItem>\n );\n}\n\nexport function TabCloseOthersItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const others = useSessionSnapshot().targets.filter((other) => other.tab !== target?.tab);\n return (\n <ContextMenuItem\n disabled={!changes || others.length === 0}\n onClick={() => {\n for (const other of others) {\n session.closeTab(other.tab);\n }\n }}\n >\n Close other tabs\n </ContextMenuItem>\n );\n}\n\nexport function TabCloseRightItem({ target }: WorkbenchSlotProps) {\n const session = useSession();\n const { changes } = useInputState();\n const { targets } = useSessionSnapshot();\n const at = targets.findIndex((other) => other.tab === target?.tab);\n const toTheRight = at < 0 ? [] : targets.slice(at + 1);\n return (\n <ContextMenuItem\n disabled={!changes || toTheRight.length === 0}\n onClick={() => {\n for (const other of toTheRight) {\n session.closeTab(other.tab);\n }\n }}\n >\n Close tabs to the right\n </ContextMenuItem>\n );\n}\n","import {\n PageLinkItems,\n PageNavigationItems,\n PagePictureItems,\n PageTextItems,\n} from \"../components/page-menu.tsx\";\nimport { PageModeItem } from \"../components/page-mode.tsx\";\nimport {\n PhoneClipboardItem,\n PhoneDrawItem,\n PhoneFilesItem,\n PhoneRecordingItem,\n PhoneTypeItem,\n PhoneViewItem,\n} from \"../components/phone-menu.tsx\";\nimport { PictureItems, PointersItem, ViewportItems } from \"../components/picture-menu.tsx\";\nimport {\n AutomationPaceItem,\n KeptItems,\n RecordingSettingsItems,\n RecordItem,\n RunningRecordingItems,\n ScreenshotItem,\n} from \"../components/recording-menu.tsx\";\nimport { SessionFilesButton } from \"../components/session-files.tsx\";\nimport {\n TabCloseItem,\n TabCloseOthersItem,\n TabCloseRightItem,\n TabCopyUrlItem,\n TabDuplicateItem,\n TabMuteItem,\n TabReloadItem,\n} from \"../components/tab-menu.tsx\";\nimport {\n AppearanceItem,\n BrowserMenuAction,\n DrawAction,\n CopyItem,\n CopyUrlItem,\n KeyboardAction,\n LeaseItems,\n MuteItem,\n NavigationItems,\n PasteItem,\n PictureAction,\n PictureSubmenuItem,\n ReconnectItem,\n RecordingAction,\n RecordingSubmenuItem,\n SelectAllItem,\n TypeItem,\n} from \"../components/toolbar-actions.tsx\";\nimport type { WorkbenchContribution } from \"./contributions.ts\";\n\n/**\n * What the workbench puts into its own slots. An embedder's contribution with one of these\n * ids takes that one's place, and a function of this list can leave any of them out.\n */\nexport const workbenchContributions: readonly WorkbenchContribution[] = [\n { id: \"action.keyboard\", slot: \"toolbar.actions\", order: 100, component: KeyboardAction },\n { id: \"action.files\", slot: \"toolbar.actions\", order: 200, component: SessionFilesButton },\n { id: \"action.draw\", slot: \"toolbar.actions\", order: 250, component: DrawAction },\n { id: \"action.recording\", slot: \"toolbar.actions\", order: 300, component: RecordingAction },\n { id: \"action.picture\", slot: \"toolbar.actions\", order: 400, component: PictureAction },\n { id: \"action.menu\", slot: \"toolbar.actions\", order: 500, component: BrowserMenuAction },\n\n {\n id: \"browser.navigation\",\n slot: \"menu.browser\",\n group: \"navigation\",\n order: 80,\n component: NavigationItems,\n },\n { id: \"browser.lease\", slot: \"menu.browser\", group: \"lease\", order: 100, component: LeaseItems },\n { id: \"browser.copy\", slot: \"menu.browser\", group: \"clipboard\", order: 200, component: CopyItem },\n {\n id: \"browser.paste\",\n slot: \"menu.browser\",\n group: \"clipboard\",\n order: 300,\n component: PasteItem,\n },\n {\n id: \"browser.select-all\",\n slot: \"menu.browser\",\n group: \"clipboard\",\n order: 400,\n component: SelectAllItem,\n },\n { id: \"browser.type\", slot: \"menu.browser\", group: \"clipboard\", order: 500, component: TypeItem },\n { id: \"browser.mute\", slot: \"menu.browser\", group: \"tab\", order: 600, component: MuteItem },\n {\n id: \"browser.recording\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 700,\n component: RecordingSubmenuItem,\n },\n {\n id: \"browser.picture\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 750,\n component: PictureSubmenuItem,\n },\n {\n id: \"browser.page-mode\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 760,\n component: PageModeItem,\n },\n {\n id: \"browser.copy-url\",\n slot: \"menu.browser\",\n group: \"tab\",\n order: 800,\n component: CopyUrlItem,\n },\n {\n id: \"browser.pace\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 850,\n component: AutomationPaceItem,\n },\n {\n id: \"browser.appearance\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 900,\n component: AppearanceItem,\n },\n {\n id: \"browser.reconnect\",\n slot: \"menu.browser\",\n group: \"session\",\n order: 1000,\n component: ReconnectItem,\n },\n\n { id: \"phone.lease\", slot: \"menu.phone\", group: \"lease\", order: 100, component: LeaseItems },\n { id: \"phone.type\", slot: \"menu.phone\", group: \"input\", order: 200, component: PhoneTypeItem },\n {\n id: \"phone.clipboard\",\n slot: \"menu.phone\",\n group: \"input\",\n order: 300,\n component: PhoneClipboardItem,\n },\n { id: \"phone.draw\", slot: \"menu.phone\", group: \"input\", order: 400, component: PhoneDrawItem },\n { id: \"phone.page-mode\", slot: \"menu.phone\", group: \"page\", order: 500, component: PageModeItem },\n {\n id: \"phone.files\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 600,\n component: PhoneFilesItem,\n },\n {\n id: \"phone.recording\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 700,\n component: PhoneRecordingItem,\n },\n {\n id: \"phone.pace\",\n slot: \"menu.phone\",\n group: \"session\",\n order: 750,\n component: AutomationPaceItem,\n },\n { id: \"phone.view\", slot: \"menu.phone\", group: \"view\", order: 900, component: PhoneViewItem },\n {\n id: \"phone.reconnect\",\n slot: \"menu.phone\",\n group: \"connection\",\n order: 1100,\n component: ReconnectItem,\n },\n\n {\n id: \"picture.transport\",\n slot: \"menu.picture\",\n group: \"picture\",\n order: 100,\n component: PictureItems,\n },\n {\n id: \"picture.viewport\",\n slot: \"menu.picture\",\n group: \"viewport\",\n order: 200,\n component: ViewportItems,\n },\n {\n id: \"picture.pointers\",\n slot: \"menu.picture\",\n group: \"picture\",\n order: 150,\n component: PointersItem,\n },\n\n {\n id: \"recording.record\",\n slot: \"menu.recording\",\n group: \"take\",\n order: 100,\n component: RecordItem,\n },\n {\n id: \"recording.screenshot\",\n slot: \"menu.recording\",\n group: \"take\",\n order: 200,\n component: ScreenshotItem,\n },\n {\n id: \"recording.running\",\n slot: \"menu.recording\",\n group: \"running\",\n order: 300,\n component: RunningRecordingItems,\n },\n { id: \"recording.kept\", slot: \"menu.recording\", group: \"kept\", order: 400, component: KeptItems },\n {\n id: \"recording.settings\",\n slot: \"menu.recording\",\n group: \"settings\",\n order: 500,\n component: RecordingSettingsItems,\n },\n\n { id: \"tab.reload\", slot: \"menu.tab\", group: \"tab\", order: 100, component: TabReloadItem },\n { id: \"tab.duplicate\", slot: \"menu.tab\", group: \"tab\", order: 200, component: TabDuplicateItem },\n { id: \"tab.copy-url\", slot: \"menu.tab\", group: \"tab\", order: 300, component: TabCopyUrlItem },\n { id: \"tab.mute\", slot: \"menu.tab\", group: \"tab\", order: 400, component: TabMuteItem },\n { id: \"tab.close\", slot: \"menu.tab\", group: \"close\", order: 500, component: TabCloseItem },\n {\n id: \"tab.close-others\",\n slot: \"menu.tab\",\n group: \"close\",\n order: 600,\n component: TabCloseOthersItem,\n },\n {\n id: \"tab.close-right\",\n slot: \"menu.tab\",\n group: \"close\",\n order: 700,\n component: TabCloseRightItem,\n },\n\n { id: \"page.link\", slot: \"menu.page\", group: \"link\", order: 100, component: PageLinkItems },\n {\n id: \"page.picture\",\n slot: \"menu.page\",\n group: \"picture\",\n order: 200,\n component: PagePictureItems,\n },\n { id: \"page.text\", slot: \"menu.page\", group: \"text\", order: 300, component: PageTextItems },\n {\n id: \"page.navigation\",\n slot: \"menu.page\",\n group: \"navigation\",\n order: 400,\n component: PageNavigationItems,\n },\n];\n","import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\n\nconst badgeVariants = cva(\n \"aperture:group/badge aperture:inline-flex aperture:h-5 aperture:w-fit aperture:shrink-0 aperture:items-center aperture:justify-center aperture:gap-1 aperture:overflow-hidden aperture:rounded-4xl aperture:border aperture:border-transparent aperture:px-2 aperture:py-0.5 aperture:text-xs aperture:font-medium aperture:whitespace-nowrap aperture:transition-all aperture:focus-visible:border-ring aperture:focus-visible:ring-[3px] aperture:focus-visible:ring-ring/50 aperture:has-data-[icon=inline-end]:pr-1.5 aperture:has-data-[icon=inline-start]:pl-1.5 aperture:aria-invalid:border-destructive aperture:aria-invalid:ring-destructive/20 aperture:dark:aria-invalid:ring-destructive/40 aperture:[&>svg]:pointer-events-none aperture:[&>svg]:size-3!\",\n {\n variants: {\n variant: {\n default:\n \"aperture:bg-primary aperture:text-primary-foreground aperture:[a]:hover:bg-primary/80\",\n secondary:\n \"aperture:bg-secondary aperture:text-secondary-foreground aperture:[a]:hover:bg-secondary/80\",\n destructive:\n \"aperture:bg-destructive/10 aperture:text-destructive aperture:focus-visible:ring-destructive/20 aperture:dark:bg-destructive/20 aperture:dark:focus-visible:ring-destructive/40 aperture:[a]:hover:bg-destructive/20\",\n outline:\n \"aperture:border-border aperture:text-foreground aperture:[a]:hover:bg-muted aperture:[a]:hover:text-muted-foreground\",\n ghost:\n \"aperture:hover:bg-muted aperture:hover:text-muted-foreground aperture:dark:hover:bg-muted/50\",\n link: \"aperture:text-primary aperture:underline-offset-4 aperture:hover:underline\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction Badge({\n className,\n variant = \"default\",\n render,\n ...props\n}: useRender.ComponentProps<\"span\"> & VariantProps<typeof badgeVariants>) {\n return useRender({\n defaultTagName: \"span\",\n props: mergeProps<\"span\">(\n {\n className: cn(badgeVariants({ variant }), className),\n },\n props,\n ),\n render,\n state: {\n slot: \"badge\",\n variant,\n },\n });\n}\n\nexport { Badge, badgeVariants };\n","import { cva, type VariantProps } from \"class-variance-authority\";\n\nimport { cn } from \"../utils.ts\";\n\nfunction Empty({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty\"\n className={cn(\n \"aperture:flex aperture:w-full aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-4 aperture:rounded-xl aperture:border-dashed aperture:p-6 aperture:text-center aperture:text-balance\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction EmptyHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-header\"\n className={cn(\n \"aperture:flex aperture:max-w-sm aperture:flex-col aperture:items-center aperture:gap-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nconst emptyMediaVariants = cva(\n \"aperture:mb-2 aperture:flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:[&_svg]:pointer-events-none aperture:[&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"aperture:bg-transparent\",\n icon: \"aperture:flex aperture:size-8 aperture:shrink-0 aperture:items-center aperture:justify-center aperture:rounded-lg aperture:bg-muted aperture:text-foreground aperture:[&_svg:not([class*='size-'])]:size-4\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n\nfunction EmptyMedia({\n className,\n variant = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof emptyMediaVariants>) {\n return (\n <div\n data-slot=\"empty-icon\"\n data-variant={variant}\n className={cn(emptyMediaVariants({ variant, className }))}\n {...props}\n />\n );\n}\n\nfunction EmptyTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-title\"\n className={cn(\"aperture:text-sm aperture:font-medium aperture:tracking-tight\", className)}\n {...props}\n />\n );\n}\n\nfunction EmptyDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n return (\n <div\n data-slot=\"empty-description\"\n className={cn(\n \"aperture:text-sm/relaxed aperture:text-muted-foreground aperture:[&>a]:underline aperture:[&>a]:underline-offset-4 aperture:[&>a:hover]:text-primary\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction EmptyContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"empty-content\"\n className={cn(\n \"aperture:flex aperture:w-full aperture:max-w-sm aperture:min-w-0 aperture:flex-col aperture:items-center aperture:gap-2.5 aperture:text-sm aperture:text-balance\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };\n","import { useEffect, useRef, useState, type PointerEvent as ReactPointerEvent } from \"react\";\nimport { MousePointer2 } from \"lucide-react\";\nimport type { Member, Target } from \"@aperture-browser/session-client\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useShownPointers } from \"../hooks/use-pointers.ts\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { automationName, memberColor } from \"./session-presence.tsx\";\nimport { pictureBox } from \"./session-viewport.tsx\";\n\n/** How long a stroke that ended takes to fade. */\nconst STROKE_FADES_MS = 7000;\nconst STROKE_WIDTH = 4;\n/** A stroke that long is thinned out: nobody sees its every point. */\nconst STROKE_POINTS = 2048;\n/** The others are told where a stroke goes this often at most. */\nconst DRAW_EVERY_MS = 24;\n/** And where the pointer that draws is. */\nconst POINT_EVERY_MS = 40;\n/** Of a member who left, or whose colour is not known yet. */\nconst UNKNOWN_COLOR = \"oklch(0.55 0.02 260)\";\n\ninterface Point {\n readonly x: number;\n readonly y: number;\n}\n\ninterface Stroke {\n readonly member: number;\n readonly stroke: number;\n points: Point[];\n /** When it ended, on the page's clock; none while it is drawn. */\n endedAt: number | undefined;\n}\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * What the session's members show each other over the watched tab: where their pointers\n * are, unless this browser was told not to show them, and the strokes they draw. Drawing\n * is this member's while the workbench is told to draw; the picture then takes no input\n * from it, and the others still see where its pointer is.\n */\nexport function MemberMarks() {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { drawing } = useWorkbench();\n const [shownPointers] = useShownPointers();\n const pointed = useRef(0);\n const frameRef = useRef<HTMLDivElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const [frame, setFrame] = useState<Size>({ width: 0, height: 0 });\n const [pointers, setPointers] = useState<ReadonlyMap<number, Point>>(new Map());\n const strokes = useRef<Stroke[]>([]);\n const painting = useRef<number | undefined>(undefined);\n const own = useRef<{ stroke: number; told: number } | undefined>(undefined);\n const drawn = useRef(0);\n\n const { presence } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const box = watched === undefined ? { width: 0, height: 0 } : pictureBox(frame, watched);\n const members = useRef<readonly Member[]>([]);\n members.current = presence?.members ?? [];\n const shown = useRef<{ box: Size; watched: Target | undefined }>({ box, watched });\n shown.current = { box, watched };\n\n useEffect(() => {\n const element = frameRef.current;\n if (element === null) {\n return undefined;\n }\n const measure = () => setFrame({ width: element.clientWidth, height: element.clientHeight });\n measure();\n const sizes = new ResizeObserver(measure);\n sizes.observe(element);\n return () => sizes.disconnect();\n }, []);\n\n const paint = useRef(() => {});\n paint.current = () => {\n painting.current = undefined;\n const canvas = canvasRef.current;\n const context = canvas?.getContext(\"2d\");\n const { box: size, watched: target } = shown.current;\n if (canvas === null || canvas === undefined || context === null || context === undefined) {\n return;\n }\n const now = performance.now();\n strokes.current = strokes.current.filter(\n (stroke) => stroke.endedAt === undefined || now - stroke.endedAt < STROKE_FADES_MS,\n );\n const pixels = window.devicePixelRatio;\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n if (target === undefined || target.width <= 0) {\n return;\n }\n const scale = (size.width / target.width) * pixels;\n context.setTransform(scale, 0, 0, scale, 0, 0);\n context.lineCap = \"round\";\n context.lineJoin = \"round\";\n context.lineWidth = STROKE_WIDTH / (size.width / target.width);\n for (const stroke of strokes.current) {\n const member = members.current.find((one) => one.id === stroke.member);\n const color = member === undefined ? UNKNOWN_COLOR : memberColor(member);\n context.globalAlpha =\n stroke.endedAt === undefined ? 1 : 1 - (now - stroke.endedAt) / STROKE_FADES_MS;\n context.strokeStyle = color;\n context.fillStyle = color;\n trace(context, stroke.points);\n }\n if (strokes.current.length > 0) {\n painting.current = requestAnimationFrame(() => paint.current());\n }\n };\n const repaint = () => {\n painting.current ??= requestAnimationFrame(() => paint.current());\n };\n\n const add = (member: number, stroke: number, phase: \"start\" | \"move\" | \"end\", at: Point) => {\n let open = strokes.current.find(\n (one) => one.member === member && one.stroke === stroke && one.endedAt === undefined,\n );\n if (open === undefined) {\n // A stroke whose start was missed begins where it is first seen.\n open = { member, stroke, points: [], endedAt: undefined };\n strokes.current.push(open);\n }\n open.points.push(at);\n if (open.points.length > STROKE_POINTS) {\n open.points = open.points.filter((_, index) => index % 2 === 0);\n }\n if (phase === \"end\") {\n open.endedAt = performance.now();\n }\n repaint();\n };\n const addRef = useRef(add);\n addRef.current = add;\n\n useEffect(() => {\n const unheard = [\n session.onPointer(({ member, at }) =>\n setPointers((before) => {\n const after = new Map(before);\n if (at === undefined) {\n after.delete(member);\n } else {\n after.set(member, at);\n }\n return after;\n }),\n ),\n session.onStroke((point) => addRef.current(point.member, point.stroke, point.phase, point)),\n ];\n return () => {\n for (const unhear of unheard) {\n unhear();\n }\n };\n }, [session]);\n\n // What was shown over another tab is not shown over this one.\n useEffect(() => {\n setPointers(new Map());\n strokes.current = [];\n own.current = undefined;\n repaint();\n // oxlint-disable-next-line react-hooks/exhaustive-deps -- only the tab matters\n }, [snapshot.selected]);\n\n // Whoever left drew their last, and points nowhere.\n useEffect(() => {\n const here = new Set(presence?.members.map((member) => member.id));\n const now = performance.now();\n for (const stroke of strokes.current) {\n if (stroke.endedAt === undefined && !here.has(stroke.member)) {\n stroke.endedAt = now;\n }\n }\n setPointers((before) => {\n const gone = [...before.keys()].filter((member) => !here.has(member));\n if (gone.length === 0) {\n return before;\n }\n const after = new Map(before);\n for (const member of gone) {\n after.delete(member);\n }\n return after;\n });\n }, [presence]);\n\n useEffect(() => repaint());\n\n useEffect(\n () => () => {\n if (painting.current !== undefined) {\n cancelAnimationFrame(painting.current);\n }\n },\n [],\n );\n\n if (watched === undefined || presence === undefined || box.width <= 0) {\n return (\n <div\n ref={frameRef}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0\"\n />\n );\n }\n\n const scale = box.width / watched.width;\n const at = (event: ReactPointerEvent<HTMLDivElement>): Point => {\n const bounds = event.currentTarget.getBoundingClientRect();\n return { x: (event.clientX - bounds.left) / scale, y: (event.clientY - bounds.top) / scale };\n };\n const draw = (phase: \"start\" | \"move\" | \"end\", point: Point) => {\n const mine = own.current;\n if (mine === undefined) {\n return;\n }\n session.draw(mine.stroke, phase, point);\n add(presence.you, mine.stroke, phase, point);\n };\n const end = (event: ReactPointerEvent<HTMLDivElement>) => {\n draw(\"end\", at(event));\n own.current = undefined;\n };\n\n return (\n <div\n ref={frameRef}\n className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:z-10 aperture:flex aperture:items-center aperture:justify-center\"\n >\n <div\n data-member-marks={drawing ? \"drawing\" : \"\"}\n className=\"aperture:relative aperture:flex-none aperture:overflow-hidden\"\n style={{\n width: box.width,\n height: box.height,\n pointerEvents: drawing ? \"auto\" : \"none\",\n cursor: drawing ? \"crosshair\" : undefined,\n touchAction: \"none\",\n }}\n onPointerDown={(event) => {\n if (!drawing || event.button !== 0) {\n return;\n }\n event.currentTarget.setPointerCapture(event.pointerId);\n drawn.current += 1;\n own.current = { stroke: drawn.current, told: performance.now() };\n draw(\"start\", at(event));\n }}\n onPointerMove={(event) => {\n const now = performance.now();\n if (now - pointed.current >= POINT_EVERY_MS) {\n pointed.current = now;\n session.point(at(event));\n }\n const mine = own.current;\n if (mine === undefined || now - mine.told < DRAW_EVERY_MS) {\n return;\n }\n mine.told = now;\n draw(\"move\", at(event));\n }}\n onPointerLeave={() => session.point()}\n onPointerUp={end}\n onPointerCancel={end}\n >\n <canvas\n ref={canvasRef}\n width={Math.round(box.width * window.devicePixelRatio)}\n height={Math.round(box.height * window.devicePixelRatio)}\n className=\"aperture:absolute aperture:inset-0 aperture:size-full\"\n />\n {(shownPointers ? [...pointers] : []).map(([id, point]) => {\n const member = presence.members.find((one) => one.id === id);\n if (member === undefined) {\n return null;\n }\n return (\n <div\n key={id}\n data-member-pointer={id}\n className=\"aperture:absolute aperture:top-0 aperture:left-0 aperture:flex aperture:items-start aperture:gap-0.5 aperture:transition-transform aperture:duration-75 aperture:ease-linear\"\n style={{\n transform: `translate(${point.x * scale}px, ${point.y * scale}px)`,\n color: memberColor(member),\n }}\n >\n <MousePointer2 className=\"aperture:size-4 aperture:fill-current aperture:drop-shadow\" />\n <span\n className=\"aperture:mt-3 aperture:max-w-32 aperture:truncate aperture:rounded-full aperture:px-1.5 aperture:py-0.5 aperture:text-[0.625rem] aperture:leading-none aperture:font-medium aperture:text-white aperture:shadow\"\n style={{ backgroundColor: memberColor(member) }}\n >\n {member.agent ? automationName(member) : member.name}\n </span>\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\n/** Draws a stroke through its points, rounded; one point is a dot. */\nfunction trace(context: CanvasRenderingContext2D, points: readonly Point[]) {\n const [first, ...rest] = points;\n if (first === undefined) {\n return;\n }\n if (rest.length === 0) {\n context.beginPath();\n context.arc(first.x, first.y, context.lineWidth / 2, 0, Math.PI * 2);\n context.fill();\n return;\n }\n context.beginPath();\n context.moveTo(first.x, first.y);\n let last = first;\n for (const point of rest) {\n // Through the middle of each stretch, bent at the points: a hand's line has no corners.\n context.quadraticCurveTo(last.x, last.y, (last.x + point.x) / 2, (last.y + point.y) / 2);\n last = point;\n }\n context.lineTo(last.x, last.y);\n context.stroke();\n}\n","import type { ReactNode } from \"react\";\nimport { AppWindow, Eye, History, Loader2, Plus, RotateCcw, Unplug } from \"lucide-react\";\nimport { Badge } from \"@aperture-browser/ui/components/badge\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Empty,\n EmptyContent,\n EmptyDescription,\n EmptyHeader,\n EmptyMedia,\n EmptyTitle,\n} from \"@aperture-browser/ui/components/empty\";\nimport { Spinner } from \"@aperture-browser/ui/components/spinner\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport type { Restoring } from \"@aperture-browser/session-client\";\nimport { useLease, useReconnect, useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { MemberMarks } from \"./member-marks.tsx\";\nimport { LeaseOverlay } from \"./session-presence.tsx\";\nimport { SessionViewport } from \"./session-viewport.tsx\";\n\nexport interface BrowserViewportProps {\n readonly className?: string | undefined;\n}\n\n/**\n * The picture with what the workbench lays over it: the connection's state, the lease, and\n * what is contributed to `viewport`.\n */\nexport function BrowserViewport({ className }: BrowserViewportProps) {\n const showLease = useWorkbench().features.presence;\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const reconnect = useReconnect();\n const lease = useLease();\n const { connection } = snapshot;\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n const open = connection.state === \"open\";\n\n return (\n <SessionViewport className={cn(\"aperture:bg-muted/40\", className)}>\n {connection.state === \"connecting\" ? (\n <Placeholder>\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Connecting to the session\n </Placeholder>\n ) : null}\n {connection.state === \"closed\" ? (\n <div className=\"aperture:absolute aperture:inset-0 aperture:z-20 aperture:flex aperture:items-center aperture:justify-center aperture:bg-background/80 aperture:backdrop-blur-sm\">\n <Empty className=\"aperture:border-none\" data-session-closed=\"\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <Unplug />\n </EmptyMedia>\n <EmptyTitle>Disconnected from the session</EmptyTitle>\n <EmptyDescription>\n {connection.reason === undefined || connection.reason === \"\"\n ? \"The connection to the session closed.\"\n : connection.reason}\n </EmptyDescription>\n </EmptyHeader>\n {reconnect === undefined ? null : (\n <EmptyContent>\n <Button type=\"button\" size=\"sm\" onClick={() => reconnect()}>\n <RotateCcw />\n Reconnect\n </Button>\n </EmptyContent>\n )}\n </Empty>\n </div>\n ) : null}\n {open && snapshot.restoring !== undefined ? (\n <Restored restoring={snapshot.restoring} />\n ) : null}\n {open && snapshot.restoring === undefined && snapshot.targets.length === 0 ? (\n <Empty\n className=\"aperture:absolute aperture:inset-0 aperture:border-none\"\n data-session-empty=\"\"\n >\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">\n <AppWindow />\n </EmptyMedia>\n <EmptyTitle>No tabs</EmptyTitle>\n <EmptyDescription>The session's browser has no tab open.</EmptyDescription>\n </EmptyHeader>\n {snapshot.features.tabs.write ? (\n <EmptyContent>\n <Button type=\"button\" size=\"sm\" onClick={() => session.newTab()}>\n <Plus />\n New tab\n </Button>\n </EmptyContent>\n ) : null}\n </Empty>\n ) : null}\n {open && snapshot.targets.length > 0 && watched === undefined ? (\n <Placeholder>\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Waiting for a tab\n </Placeholder>\n ) : null}\n {open && showLease ? <MemberMarks /> : null}\n {open && showLease ? <LeaseOverlay /> : null}\n {open && showLease && lease.state === \"view-only\" ? (\n <div\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:left-2 aperture:z-10\",\n // A phone's bar is over the picture's foot.\n snapshot.phone ? \"aperture:top-2\" : \"aperture:bottom-2\",\n )}\n >\n <Badge variant=\"outline\" className=\"aperture:bg-background/90\" data-session-view-only=\"\">\n <Eye />\n View only\n </Badge>\n </div>\n ) : null}\n <WorkbenchSlot name=\"viewport\" />\n </SessionViewport>\n );\n}\n\nconst counted = (count: number, one: string, many: string) =>\n `${count} ${count === 1 ? one : many}`;\n\n/** What is being put into the session's browser, of what there is of each. */\nconst beingPut = ({ tabs, cookies, origins }: Restoring) =>\n [\n tabs > 0 ? counted(tabs, \"tab\", \"tabs\") : undefined,\n cookies > 0 ? counted(cookies, \"cookie\", \"cookies\") : undefined,\n origins > 0 ? `the storage of ${counted(origins, \"site\", \"sites\")}` : undefined,\n ].filter((part) => part !== undefined);\n\n/**\n * Over the picture while the session is given what its browser starts with: the tabs are\n * seen to arrive behind it, and nothing is pressed through it, as a press on a page that\n * is not yet what it is to be is a wrong one. The session takes no input meanwhile either.\n */\nfunction Restored({ restoring }: { restoring: Restoring }) {\n const parts = beingPut(restoring);\n const failed = restoring.failure !== undefined;\n return (\n <div\n data-session-restoring={failed ? \"failed\" : \"underway\"}\n className=\"aperture:absolute aperture:inset-0 aperture:z-20 aperture:flex aperture:items-center aperture:justify-center aperture:bg-background/60 aperture:backdrop-blur-[2px]\"\n >\n <Empty className=\"aperture:max-w-sm aperture:flex-none aperture:rounded-xl aperture:border aperture:border-solid aperture:bg-card/95 aperture:shadow-sm\">\n <EmptyHeader>\n <EmptyMedia variant=\"icon\">{failed ? <History /> : <Spinner />}</EmptyMedia>\n <EmptyTitle>\n {failed ? \"The session was not restored\" : \"Restoring the session\"}\n </EmptyTitle>\n <EmptyDescription role={failed ? \"alert\" : \"status\"}>\n {failed\n ? restoring.failure\n : parts.length === 0\n ? \"What its browser starts with is on its way.\"\n : `Putting in ${parts.join(\", \")}.`}\n </EmptyDescription>\n </EmptyHeader>\n </Empty>\n </div>\n );\n}\n\nfunction Placeholder({ children }: { children: ReactNode }) {\n return (\n <div className=\"aperture:pointer-events-none aperture:absolute aperture:inset-0 aperture:flex aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-2 aperture:text-sm aperture:text-muted-foreground\">\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { Dialog as DialogPrimitive } from \"@base-ui/react/dialog\";\n\nimport { cn } from \"../utils.ts\";\nimport { Button } from \"./button.tsx\";\nimport { XIcon } from \"lucide-react\";\nimport { usePortalContainer } from \"../portal.tsx\";\nimport { ScrollArea } from \"./scroll-area.tsx\";\n\n/** What opens over a dialog from within it, while it is open: a list, a menu. */\nconst POPUPS = [\n '[data-slot=\"select-content\"][data-open]',\n '[data-slot=\"combobox-content\"][data-open]',\n '[data-slot$=\"menu-content\"][data-open]',\n '[data-slot=\"popover-content\"][data-open]',\n].join(\", \");\n\n/**\n * The presses of Escape that found something open over a dialog. They are noted before\n * anything hears them: what was open closes on the same press, and is closed by the time\n * the dialog is asked to.\n */\nconst forPopup = new WeakSet<Event>();\nif (typeof window !== \"undefined\") {\n window.addEventListener(\n \"keydown\",\n (event) => {\n if (event.key === \"Escape\" && document.querySelector(POPUPS) !== null) {\n forPopup.add(event);\n }\n },\n true,\n );\n}\n\nfunction Dialog({\n onOpenChange,\n dismissible = true,\n ...props\n}: DialogPrimitive.Root.Props & {\n /**\n * Whether Escape and a press beside it close it. Not where it shows what is shown once:\n * that is closed by a button of its own, and by nothing done in passing.\n */\n dismissible?: boolean;\n}) {\n return (\n <DialogPrimitive.Root\n data-slot=\"dialog\"\n onOpenChange={(open, details) => {\n if (\n !open &&\n !dismissible &&\n (details.reason === \"escape-key\" || details.reason === \"outside-press\")\n ) {\n details.cancel();\n return;\n }\n // Escape closes what opened last: a list that is open over the dialog, and not the\n // dialog with what was typed into it.\n if (!open && details.reason === \"escape-key\" && forPopup.has(details.event)) {\n details.cancel();\n return;\n }\n onOpenChange?.(open, details);\n }}\n {...props}\n />\n );\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot=\"dialog-trigger\" {...props} />;\n}\n\nfunction DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {\n const container = usePortalContainer();\n return <DialogPrimitive.Portal data-slot=\"dialog-portal\" container={container} {...props} />;\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot=\"dialog-close\" {...props} />;\n}\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot=\"dialog-overlay\"\n // Over a dialog it opened from as well: that one is behind it, and is seen to be.\n forceRender\n className={cn(\n \"aperture:fixed aperture:inset-0 aperture:isolate aperture:z-50 aperture:bg-black/10 aperture:duration-100 aperture:supports-backdrop-filter:backdrop-blur-xs aperture:data-open:animate-in aperture:data-open:fade-in-0 aperture:data-closed:animate-out aperture:data-closed:fade-out-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** What a dialog is whichever way it stands: a column, a sheet at the foot on a phone. */\nconst CONTENT =\n // A column no taller than what is seen of the window: its header, its footer and\n // what else stands in it take the room they need, whatever the size of what is\n // pressed, and a `DialogBody` among them gives way and scrolls. With no body the\n // whole of it scrolls. On a phone it is a sheet at the foot, above the keyboard.\n \"aperture:group/dialog aperture:fixed aperture:inset-x-0 aperture:bottom-(--keyboard-inset,0px) aperture:z-50 aperture:flex aperture:max-h-[calc(100dvh-0.75rem-env(safe-area-inset-top)-var(--keyboard-inset,0px)-var(--keyboard-top,0px))] aperture:w-full aperture:max-w-none aperture:flex-col aperture:gap-4 aperture:overflow-x-hidden aperture:overflow-y-auto aperture:rounded-t-xl aperture:bg-popover aperture:p-4 aperture:pb-(--dialog-pad-bottom) aperture:text-sm aperture:[--dialog-pad-bottom:max(1rem,env(safe-area-inset-bottom))] aperture:sm:[--dialog-pad-bottom:1rem] aperture:text-popover-foreground aperture:ring-1 aperture:ring-foreground/10 aperture:duration-100 aperture:outline-none aperture:data-closed:animate-out aperture:data-closed:fade-out-0 aperture:data-open:animate-in aperture:data-open:fade-in-0\";\n\n/** In the middle of the window, where the window is wider than a phone's. */\nconst MODAL =\n \"aperture:data-closed:slide-out-to-bottom-2 aperture:data-open:slide-in-from-bottom-2 aperture:sm:top-[calc(var(--keyboard-top,0px)+(100svh-var(--keyboard-top,0px)-var(--keyboard-inset,0px))/2)] aperture:sm:left-1/2 aperture:sm:bottom-auto aperture:sm:max-h-[calc(100svh-2rem-var(--keyboard-top,0px)-var(--keyboard-inset,0px))] aperture:sm:max-w-md aperture:sm:-translate-x-1/2 aperture:sm:-translate-y-1/2 aperture:sm:rounded-xl aperture:sm:data-closed:zoom-out-95 aperture:sm:data-open:zoom-in-95\";\n\n/**\n * At the window's right edge and as tall as what is seen of the window, where the window is\n * wider than a phone's: its header and footer stay, and its body has what is left.\n */\nconst SIDE =\n \"aperture:max-sm:data-closed:slide-out-to-bottom-2 aperture:max-sm:data-open:slide-in-from-bottom-2 aperture:sm:top-[calc(var(--keyboard-top,0px)+env(safe-area-inset-top))] aperture:sm:right-[env(safe-area-inset-right)] aperture:sm:bottom-(--keyboard-inset,0px) aperture:sm:left-auto aperture:sm:max-h-none aperture:sm:max-w-lg aperture:sm:rounded-none aperture:sm:shadow-lg aperture:sm:duration-200 aperture:sm:data-closed:slide-out-to-right-8 aperture:sm:data-open:slide-in-from-right-8\";\n\nfunction DialogContent({\n className,\n children,\n showCloseButton = true,\n side,\n ...props\n}: DialogPrimitive.Popup.Props & {\n showCloseButton?: boolean;\n /**\n * Where it stands in a window wider than a phone's: at that edge, as tall as the window,\n * for what shows or changes a thing among others, or has much in it. In the middle,\n * without. On a phone it is a sheet at the foot either way.\n */\n side?: \"right\";\n}) {\n return (\n <DialogPortal>\n {/* As long on its way as what it is behind. */}\n <DialogOverlay className={side === undefined ? undefined : \"aperture:sm:duration-200\"} />\n <DialogPrimitive.Popup\n data-slot=\"dialog-content\"\n data-side={side}\n className={cn(CONTENT, side === undefined ? MODAL : SIDE, className)}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot=\"dialog-close\"\n render={\n <Button\n variant=\"ghost\"\n className=\"aperture:absolute aperture:top-2 aperture:right-2 aperture:pointer-coarse:top-1 aperture:pointer-coarse:right-1\"\n size=\"icon-sm\"\n />\n }\n >\n <XIcon />\n <span className=\"aperture:sr-only\">Close</span>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Popup>\n </DialogPortal>\n );\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"dialog-header\"\n className={cn(\n // Beside the button that closes it, where there is one.\n \"aperture:flex aperture:min-w-0 aperture:shrink-0 aperture:flex-col aperture:gap-2 aperture:pb-2 aperture:group-has-[>[data-slot=dialog-close]]/dialog:pr-8\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/**\n * What a dialog holds between its header and footer: the part of it that gives way where\n * the window is short, and scrolls then. Its class is for how what it holds is laid out.\n */\nfunction DialogBody({\n className,\n height,\n style,\n ...props\n}: Omit<React.ComponentProps<typeof ScrollArea>, \"style\"> & {\n /**\n * How tall it is whatever it holds, as a CSS length, where what it holds changes while the\n * dialog is open: tabs, a list that loads or grows. The room for the tallest of what it\n * shows, so that the dialog is as tall for each. Where what it holds is what is pressed,\n * the length counts those in `--control-height`, which is more where a finger presses.\n * Left out, it is as tall as what it holds. At a window's side the dialog is as tall as\n * the window whatever it holds, and its body has what is left of that.\n */\n height?: string;\n style?: React.CSSProperties;\n}) {\n return (\n <ScrollArea\n data-slot=\"dialog-body\"\n className={cn(\n // Out to the dialog's edges, so the rings of what has the focus are not cut off; and\n // further at its foot, where what stands out of the last thing it holds would\n // have it scroll: the line kept for what a field's rules say, the room a finger\n // has around a switch.\n \"aperture:-mx-4 aperture:-mt-1 aperture:-mb-2 aperture:flex aperture:min-h-0 aperture:flex-col\",\n height === undefined\n ? \"aperture:shrink aperture:grow-0 aperture:basis-auto\"\n : \"aperture:shrink aperture:grow-0 aperture:basis-(--dialog-body-height)\",\n \"aperture:sm:group-data-[side=right]/dialog:grow aperture:sm:group-data-[side=right]/dialog:basis-0\",\n )}\n style={\n height === undefined\n ? style\n : ({ \"--dialog-body-height\": height, ...style } as React.CSSProperties)\n }\n viewportClassName={cn(\n \"aperture:flex aperture:h-auto aperture:min-h-0 aperture:flex-1 aperture:flex-col aperture:gap-4 aperture:px-4 aperture:pt-1 aperture:pb-2\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n showCloseButton?: boolean;\n}) {\n return (\n <div\n data-slot=\"dialog-footer\"\n className={cn(\n // On a phone it stays at the sheet's foot while what is above it scrolls, clear of\n // the home indicator.\n \"aperture:-mx-4 aperture:-mb-(--dialog-pad-bottom) aperture:flex aperture:shrink-0 aperture:gap-2 aperture:max-sm:*:min-w-0 aperture:max-sm:*:flex-1 aperture:border-t aperture:bg-[color-mix(in_oklch,var(--popover),var(--muted)_50%)] aperture:p-4 aperture:pb-(--dialog-pad-bottom) aperture:max-sm:sticky aperture:max-sm:-bottom-(--dialog-pad-bottom) aperture:sm:justify-end aperture:sm:rounded-b-xl aperture:sm:group-data-[side=right]/dialog:mt-auto aperture:sm:group-data-[side=right]/dialog:rounded-none\",\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant=\"outline\" />}>Close</DialogPrimitive.Close>\n )}\n </div>\n );\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot=\"dialog-title\"\n className={cn(\n \"aperture:min-w-0 aperture:text-base aperture:leading-tight aperture:font-medium aperture:wrap-anywhere\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot=\"dialog-description\"\n className={cn(\n \"aperture:min-w-0 aperture:text-sm aperture:text-muted-foreground aperture:wrap-anywhere aperture:*:[a]:underline aperture:*:[a]:underline-offset-3 aperture:*:[a]:hover:text-foreground\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n Dialog,\n DialogBody,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n","import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport type { Recording } from \"@aperture-browser/session-client\";\nimport {\n Camera,\n ChevronLeft,\n ChevronRight,\n Download,\n Film,\n PanelRight,\n Pause,\n Play,\n Scissors,\n Volume2,\n VolumeX,\n X,\n} from \"lucide-react\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogTitle,\n} from \"@aperture-browser/ui/components/dialog\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@aperture-browser/ui/components/dropdown-menu\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { keptOf, recordingIsEdited, type Kept } from \"../hooks/use-recordings.ts\";\nimport {\n useRecordingTimeline,\n type RecordingTimeline,\n type TimelineEvent,\n} from \"../hooks/use-timeline.ts\";\nimport { failureText, showNotice } from \"../notices.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { formatDuration, formatStarted, Thumbnail } from \"./menu-parts.tsx\";\nimport {\n editOptions,\n editSettings,\n EditSettingsItems,\n KeptFacts,\n keptPreview,\n type EditSettings,\n} from \"./recording-menu.tsx\";\n\ninterface Size {\n readonly width: number;\n readonly height: number;\n}\n\n/** What the dialog is as wide as until what it shows has told its size. */\nconst UNKNOWN: Size = { width: 1280, height: 720 };\n\n/** How long the bars over the picture stay once the pointer rests. */\nconst BARS_STAY_MS = 2500;\n\nconst BAR =\n \"aperture:absolute aperture:inset-x-0 aperture:z-10 aperture:flex aperture:items-center aperture:gap-2 aperture:bg-background/70 aperture:backdrop-blur-md aperture:transition-opacity aperture:duration-200\";\n\n/**\n * One of the session's recordings or screenshots, as large as the window lets it be and no\n * larger than it is: a screenshot as the picture it is, a recording in a player that shows\n * what happened in it. The others are a panel away. Opened by the workbench's `view`.\n */\nexport function KeptGallery() {\n const { recordings, viewed, view } = useWorkbench();\n const session = useSession();\n const kept = keptOf(recordings);\n // What was shown stays while the dialog closes: it leaves as it was, not emptied.\n const last = useRef(viewed);\n if (viewed !== undefined) {\n last.current = viewed;\n }\n const showing = viewed ?? last.current;\n const at = kept.findIndex((one) => one.id === showing);\n const shown = kept[at];\n const [listed, setListed] = useState(false);\n const [size, setSize] = useState<{ id: string; size: Size } | undefined>(undefined);\n const content =\n (size !== undefined && size.id === shown?.id ? size.size : undefined) ?? sizeOf(shown);\n\n // The bars show while the pointer moves, and while it rests on one of them.\n const [moved, setMoved] = useState(0);\n const [awake, setAwake] = useState(true);\n const [onBar, setOnBar] = useState(false);\n const [resting, setResting] = useState(true);\n useEffect(() => {\n setAwake(true);\n const sleeping = setTimeout(() => setAwake(false), BARS_STAY_MS);\n return () => clearTimeout(sleeping);\n }, [moved, showing]);\n const bars =\n awake || onBar || listed || shown === undefined || (shown.kind === \"recording\" && resting);\n const bar = {\n \"data-kept-bars\": bars ? \"shown\" : \"hidden\",\n onPointerEnter: () => setOnBar(true),\n onPointerLeave: () => setOnBar(false),\n };\n const hidden = bars ? undefined : \"aperture:pointer-events-none aperture:opacity-0\";\n\n const step = (by: number) => {\n const next = kept[at + by];\n if (next !== undefined) {\n view(next.id);\n }\n };\n\n return (\n <Dialog\n open={viewed !== undefined}\n onOpenChange={(open) => {\n if (!open) {\n view(undefined);\n setListed(false);\n }\n }}\n >\n <DialogContent\n data-kept-gallery=\"\"\n showCloseButton={false}\n className=\"aperture:flex aperture:max-w-none aperture:min-w-[min(26rem,calc(100vw-1rem))] aperture:flex-col aperture:gap-0 aperture:overflow-hidden aperture:bg-black aperture:p-0 aperture:max-sm:mx-auto aperture:sm:max-w-none\"\n style={{\n // As wide as the picture, and as the window's width and height leave it.\n width: `min(${content.width}px, calc(100vw - 2rem), calc((100svh - 2rem) * ${content.width / content.height}))`,\n }}\n onPointerMove={() => setMoved((count) => count + 1)}\n onKeyDown={() => setMoved((count) => count + 1)}\n >\n <div\n className={cn(\"aperture:relative aperture:w-full\", !bars && \"aperture:cursor-none\")}\n style={{ aspectRatio: `${content.width} / ${content.height}` }}\n >\n {shown === undefined ? (\n <p className=\"aperture:flex aperture:size-full aperture:items-center aperture:justify-center aperture:px-4 aperture:text-center aperture:text-sm aperture:text-white/80\">\n It is no longer in the session's files.\n </p>\n ) : shown.kind === \"screenshot\" ? (\n <img\n key={shown.id}\n data-kept-shown=\"screenshot\"\n src={session.fileUrl(shown.screenshot.file)}\n alt=\"\"\n className=\"aperture:size-full aperture:object-contain\"\n />\n ) : (\n <RecordingView\n key={shown.id}\n kept={shown}\n bar={bar}\n hidden={hidden}\n onSize={(told) => setSize({ id: shown.id, size: told })}\n onResting={setResting}\n />\n )}\n <header\n {...bar}\n className={cn(BAR, \"aperture:top-0 aperture:h-9 aperture:pr-1 aperture:pl-3\", hidden)}\n >\n <DialogTitle className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:items-baseline aperture:gap-2 aperture:text-xs aperture:font-normal\">\n <span className=\"aperture:shrink-0 aperture:font-medium aperture:tabular-nums\">\n {shown === undefined ? \"Recordings and screenshots\" : formatStarted(shown.at)}\n </span>\n {shown === undefined ? null : <KeptFacts kept={shown} />}\n {shown === undefined ? null : (\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:text-muted-foreground\">\n {pageOf(shown)}\n </span>\n )}\n </DialogTitle>\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center\">\n {shown?.kind === \"screenshot\" ? (\n <FileLinks\n href={session.fileUrl(shown.screenshot.file)}\n file={shown.screenshot.file}\n />\n ) : null}\n <BarButton label=\"Newer\" disabled={at <= 0} onClick={() => step(-1)}>\n <ChevronLeft />\n </BarButton>\n <BarButton\n label=\"Older\"\n disabled={at < 0 || at >= kept.length - 1}\n onClick={() => step(1)}\n >\n <ChevronRight />\n </BarButton>\n <BarButton\n label=\"All recordings and screenshots\"\n pressed={listed}\n data-kept-list-button=\"\"\n onClick={() => setListed(!listed)}\n >\n <PanelRight />\n </BarButton>\n <DialogClose\n render={<Button type=\"button\" variant=\"ghost\" size=\"icon-xs\" aria-label=\"Close\" />}\n >\n <X />\n </DialogClose>\n </div>\n </header>\n {listed ? (\n <KeptList\n kept={kept}\n viewed={showing}\n onView={(id) => {\n view(id);\n setListed(false);\n }}\n />\n ) : null}\n </div>\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The size a kept thing says it has, before its picture is there to tell. */\nfunction sizeOf(kept: Kept | undefined): Size {\n if (kept?.kind === \"screenshot\" && kept.screenshot.width > 0 && kept.screenshot.height > 0) {\n return { width: kept.screenshot.width, height: kept.screenshot.height };\n }\n return UNKNOWN;\n}\n\n/** The page a kept thing is of. */\nfunction pageOf(kept: Kept): string {\n const { title, url } = kept.kind === \"screenshot\" ? kept.screenshot : kept.recording;\n return title.trim() === \"\" ? url : title;\n}\n\nfunction BarButton({\n label,\n pressed,\n children,\n ...props\n}: {\n label: string;\n pressed?: boolean;\n children: ReactNode;\n} & Omit<React.ComponentProps<typeof Button>, \"children\">) {\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={label}\n title={label}\n aria-pressed={pressed}\n className={cn(pressed && \"aperture:bg-foreground/10\")}\n {...props}\n >\n {children}\n </Button>\n );\n}\n\n/**\n * The link every kept file has, to a file on this machine. A file of the session's is\n * shown here or kept, and is no page of its own: the session answers with it as a file.\n */\nfunction FileLinks({ href, file }: { href: string; file: string }) {\n return (\n <Button\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Download\"\n title=\"Download\"\n render={<a href={href} download={file.split(\"/\").at(-1) ?? \"\"} />}\n >\n <Download />\n </Button>\n );\n}\n\nfunction RecordingView({\n kept,\n bar,\n hidden,\n onSize,\n onResting,\n}: {\n kept: Kept & { kind: \"recording\" };\n /** What makes the player's bar one of the bars over the picture. */\n bar: Record<string, unknown>;\n /** The classes that hide the bars, while they are hidden. */\n hidden: string | undefined;\n onSize: (size: Size) => void;\n /** Tells whether the video rests, which keeps the bars in sight. */\n onResting: (resting: boolean) => void;\n}) {\n const session = useSession();\n const { recording } = kept;\n const timeline = useRecordingTimeline(recording);\n const edited =\n recording.edit?.state === \"finished\" && recording.edit.file !== null\n ? recording.edit.file\n : undefined;\n // The edit is what a recording was made for, and what every browser plays.\n const [raw, setRaw] = useState(false);\n const playsRaw = raw || edited === undefined;\n const file = playsRaw ? recording.file : (edited ?? recording.file);\n // An edit that was made again has the file of the one before, and is another video.\n const made = playsRaw ? null : (recording.edit?.made_at_ms ?? null);\n const src = made === null ? session.fileUrl(file) : madeAt(session.fileUrl(file), made);\n const videoRef = useRef<HTMLVideoElement>(null);\n const [playing, setPlaying] = useState(false);\n const [muted, setMuted] = useState(false);\n const [time, setTime] = useState(0);\n const [length, setLength] = useState(0);\n const [failed, setFailed] = useState<string | undefined>(undefined);\n\n useEffect(() => {\n onResting(!playing);\n return () => onResting(true);\n }, [playing, onResting]);\n\n // The playhead moves with the picture, which says where it is less often than it is drawn.\n useEffect(() => {\n if (!playing) {\n return undefined;\n }\n let frame = requestAnimationFrame(function follow() {\n setTime(videoRef.current?.currentTime ?? 0);\n frame = requestAnimationFrame(follow);\n });\n return () => cancelAnimationFrame(frame);\n }, [playing]);\n\n const told = playsRaw ? timeline?.duration_ms : timeline?.edited_duration_ms;\n const duration = told === undefined ? length : told / 1000;\n\n const toggle = () => {\n const video = videoRef.current;\n if (video === null) {\n return;\n }\n if (video.paused) {\n void video.play().catch(() => {});\n } else {\n video.pause();\n }\n };\n\n const seek = (seconds: number) => {\n const video = videoRef.current;\n if (video !== null) {\n video.currentTime = Math.min(Math.max(seconds, 0), duration);\n setTime(video.currentTime);\n }\n };\n\n return (\n <div\n className=\"aperture:flex aperture:size-full aperture:items-center aperture:justify-center\"\n onKeyDown={(event) => {\n if (event.key === \" \" && !(event.target instanceof HTMLButtonElement)) {\n event.preventDefault();\n toggle();\n }\n if (event.key === \"ArrowLeft\") {\n seek(time - 5);\n }\n if (event.key === \"ArrowRight\") {\n seek(time + 5);\n }\n }}\n >\n {failed === undefined ? (\n <video\n key={src}\n ref={videoRef}\n data-kept-shown=\"recording\"\n src={src}\n poster={keptPreview(kept, session.fileUrl)}\n playsInline\n preload=\"metadata\"\n muted={muted}\n onClick={toggle}\n onPlay={() => setPlaying(true)}\n onPause={() => setPlaying(false)}\n onEnded={() => setPlaying(false)}\n onLoadedMetadata={(event) => {\n const video = event.currentTarget;\n setLength(Number.isFinite(video.duration) ? video.duration : 0);\n setTime(0);\n if (video.videoWidth > 0 && video.videoHeight > 0) {\n onSize({ width: video.videoWidth, height: video.videoHeight });\n }\n }}\n onTimeUpdate={(event) => setTime(event.currentTarget.currentTime)}\n onError={() =>\n setFailed(\n recording.failure ??\n (playsRaw && edited !== undefined\n ? \"This browser does not play the raw recording. Download it, or watch the edit.\"\n : \"This browser does not play the file. Download it instead.\"),\n )\n }\n className=\"aperture:size-full aperture:object-contain aperture:outline-none\"\n />\n ) : (\n <p className=\"aperture:max-w-sm aperture:px-4 aperture:text-center aperture:text-sm aperture:text-white/80\">\n {failed}\n </p>\n )}\n <div\n {...bar}\n data-kept-player=\"\"\n className={cn(BAR, \"aperture:bottom-0 aperture:h-9 aperture:px-1\", hidden)}\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={playing ? \"Pause\" : \"Play\"}\n disabled={failed !== undefined}\n onClick={toggle}\n >\n {playing ? <Pause /> : <Play />}\n </Button>\n <span className=\"aperture:shrink-0 aperture:text-xs aperture:text-muted-foreground aperture:tabular-nums\">\n {formatDuration(time * 1000)} / {formatDuration(duration * 1000)}\n </span>\n <Track duration={duration} time={time} timeline={timeline} raw={playsRaw} onSeek={seek} />\n {edited === undefined ? null : (\n <div className=\"aperture:flex aperture:shrink-0 aperture:rounded-md aperture:bg-foreground/10 aperture:p-0.5\">\n {[false, true].map((one) => (\n <button\n key={String(one)}\n type=\"button\"\n aria-pressed={raw === one}\n title={one ? \"The video as it was recorded\" : \"With the cuts and marks of its edit\"}\n className={cn(\n \"aperture:rounded aperture:px-1.5 aperture:text-xs aperture:leading-5 aperture:outline-none aperture:focus-visible:ring-2 aperture:focus-visible:ring-ring\",\n raw === one\n ? \"aperture:bg-background aperture:shadow-xs\"\n : \"aperture:text-muted-foreground aperture:hover:text-foreground\",\n )}\n onClick={() => {\n setRaw(one);\n setFailed(undefined);\n setPlaying(false);\n }}\n >\n {one ? \"Raw\" : \"Edit\"}\n </button>\n ))}\n </div>\n )}\n <div className=\"aperture:flex aperture:shrink-0 aperture:items-center\">\n <EditAgain recording={recording} />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label={muted ? \"Unmute\" : \"Mute\"}\n aria-pressed={muted}\n onClick={() => setMuted(!muted)}\n >\n {muted ? <VolumeX /> : <Volume2 />}\n </Button>\n <FileLinks href={src} file={file} />\n </div>\n </div>\n </div>\n );\n}\n\n/**\n * Makes the edit of a recording again, of the same raw video and as chosen here: what the\n * edit there is was made with, until something else is. The new edit takes its place.\n */\nfunction EditAgain({ recording }: { recording: Recording }) {\n const { recordings } = useWorkbench();\n const allowed = useSessionSnapshot().features.recordings.write;\n const [chosen, setChosen] = useState<EditSettings | undefined>(undefined);\n const settings = chosen ?? editSettings(recording.edit?.options);\n const editing = recordingIsEdited(recording);\n\n // A session that makes no edits has none to make again, and a recording that failed has\n // no video to make one of.\n if (recording.edit === null || recording.state !== \"finished\") {\n return null;\n }\n const edit = () => {\n recordings.edit(recording.id, editOptions(settings)).then(\n () => setChosen(undefined),\n (cause: unknown) =>\n showNotice({\n level: \"error\",\n message: \"The recording was not edited again\",\n description: failureText(cause),\n }),\n );\n };\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Edit again…\"\n title={editing ? \"The edit is being made\" : \"Edit again…\"}\n data-kept-edit-again=\"\"\n disabled={editing || !allowed}\n />\n }\n >\n <Scissors />\n </DropdownMenuTrigger>\n <DropdownMenuContent side=\"top\" align=\"end\" className=\"aperture:w-64\">\n <DropdownMenuLabel>Edit again</DropdownMenuLabel>\n <EditSettingsItems settings={settings} onChange={setChosen} />\n <DropdownMenuSeparator />\n <DropdownMenuItem data-kept-edit-make=\"\" onClick={edit}>\n <Scissors />\n Make the edit\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** A file's address as of one making of it, which no cache has for another. */\nfunction madeAt(address: string, made: number): string {\n const url = new URL(address);\n url.searchParams.set(\"made\", String(made));\n return url.toString();\n}\n\n/** What an event of the timeline is, in a few words. */\nfunction eventLabel(event: TimelineEvent): string {\n const text = (field: string) => {\n const value = event[field];\n return typeof value === \"string\" ? value : undefined;\n };\n switch (event.kind) {\n case \"call\": {\n return `${text(\"tool\") ?? \"tool\"}${event.ok === false ? \" (failed)\" : \"\"}`;\n }\n case \"press\": {\n const button = text(\"button\") ?? \"left\";\n const times = event.count === 2 ? \"double \" : \"\";\n return button === \"left\" ? `${times}click` : `${times}${button} click`;\n }\n case \"wheel\": {\n return \"scroll\";\n }\n case \"caption\": {\n return text(\"text\") ?? \"caption\";\n }\n default: {\n return event.kind;\n }\n }\n}\n\n/** Pointer moves and wheel turns no further apart than this are one run of them. */\nconst RUN_GAP_MS = 300;\n\n/** A stretch of the track: where it is, and what the edit made of it. */\ninterface Stretch {\n readonly start: number;\n readonly end: number;\n readonly note: string;\n readonly cut: boolean;\n}\n\n/** The stretches the edit sped up or cut, in the time of the video that plays. */\nfunction stretches(timeline: RecordingTimeline, raw: boolean): readonly Stretch[] {\n const found: Stretch[] = [];\n let before = 0;\n for (const piece of timeline.map) {\n if (raw && piece.raw_start_ms > before) {\n found.push({ start: before, end: piece.raw_start_ms, note: \"Cut from the edit\", cut: true });\n }\n before = piece.raw_end_ms;\n if (piece.speed > 1) {\n const length = piece.raw_end_ms - piece.raw_start_ms;\n found.push({\n start: raw ? piece.raw_start_ms : piece.edited_start_ms,\n end: raw ? piece.raw_end_ms : piece.edited_start_ms + length / piece.speed,\n note: raw\n ? `${piece.speed}× faster in the edit`\n : `${piece.speed}× faster than it happened`,\n cut: false,\n });\n }\n }\n if (raw && timeline.duration_ms > before) {\n found.push({ start: before, end: timeline.duration_ms, note: \"Cut from the edit\", cut: true });\n }\n return found;\n}\n\n/**\n * The player's track: where the picture is, where to take it, and what happened when. The\n * automation's tools are bars above the line, clicks are dots on it, and the stretches the\n * edit sped up or cut are marked along it. Pointing tells what is there.\n */\nfunction Track({\n duration,\n time,\n timeline,\n raw,\n onSeek,\n}: {\n /** In seconds, as `time` is. */\n duration: number;\n time: number;\n timeline: RecordingTimeline | undefined;\n /** The raw video plays, and not its edit. */\n raw: boolean;\n onSeek: (seconds: number) => void;\n}) {\n const trackRef = useRef<HTMLDivElement>(null);\n const [pointed, setPointed] = useState<number | undefined>(undefined);\n const total = Math.max(duration * 1000, 1);\n const share = (ms: number) => `${Math.min(Math.max(ms / total, 0), 1) * 100}%`;\n const span = (event: TimelineEvent) =>\n raw\n ? ([event.at_ms, event.end_ms] as const)\n : ([event.edited_at_ms, event.edited_end_ms] as const);\n const events = timeline?.events ?? [];\n const calls = events.filter((event) => event.kind === \"call\");\n const marks = events.filter((event) => ![\"call\", \"move\", \"wheel\"].includes(event.kind));\n // The pointer's way and the wheel's turns are many small events: each run of them is one.\n const runs = (kind: string, label: string) => {\n const found: { start: number; end: number; label: string }[] = [];\n for (const event of events) {\n if (event.kind !== kind) {\n continue;\n }\n const [start, end] = span(event);\n const before = found.at(-1);\n if (before !== undefined && start - before.end <= RUN_GAP_MS) {\n before.end = Math.max(before.end, end);\n } else {\n found.push({ start, end, label });\n }\n }\n return found;\n };\n const moves = [...runs(\"move\", \"pointer moves\"), ...runs(\"wheel\", \"scroll\")];\n const marked = timeline === undefined ? [] : stretches(timeline, raw);\n\n const msAt = (clientX: number) => {\n const box = trackRef.current?.getBoundingClientRect();\n if (box === undefined || box.width === 0) {\n return 0;\n }\n return Math.min(Math.max((clientX - box.left) / box.width, 0), 1) * total;\n };\n\n // What is near enough to the pointer to be meant: a few pixels of the track either way.\n const near = total * 0.012;\n const there =\n pointed === undefined\n ? []\n : [\n ...calls.filter(\n (event) => span(event)[0] - near <= pointed && pointed <= span(event)[1] + near,\n ),\n ...marks.filter((event) => Math.abs(span(event)[0] - pointed) <= near),\n ];\n const moving =\n pointed === undefined\n ? []\n : moves.filter((run) => run.start - near <= pointed && pointed <= run.end + near);\n const stretch = marked.find(\n (one) => pointed !== undefined && one.start <= pointed && pointed <= one.end,\n );\n\n return (\n <div\n ref={trackRef}\n data-kept-track=\"\"\n role=\"slider\"\n tabIndex={0}\n aria-label=\"Position in the recording\"\n aria-valuemin={0}\n aria-valuemax={Math.round(duration)}\n aria-valuenow={Math.round(time)}\n aria-valuetext={formatDuration(time * 1000)}\n className=\"aperture:relative aperture:h-9 aperture:min-w-0 aperture:flex-1 aperture:cursor-pointer aperture:touch-none aperture:outline-none\"\n onPointerDown={(event) => {\n onSeek(msAt(event.clientX) / 1000);\n // The drag goes on outside the track; a pointer that cannot be held still seeks.\n try {\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {\n // Followed while it is over the track.\n }\n }}\n onPointerMove={(event) => {\n setPointed(msAt(event.clientX));\n if (event.buttons === 1) {\n onSeek(msAt(event.clientX) / 1000);\n }\n }}\n onPointerLeave={() => setPointed(undefined)}\n >\n {moves.map((run, index) => (\n <span\n key={index}\n data-kept-run={run.label}\n className=\"aperture:absolute aperture:top-1.5 aperture:h-0.5 aperture:min-w-0.5 aperture:rounded-full aperture:bg-foreground/35\"\n style={{ left: share(run.start), width: `calc(${share(run.end)} - ${share(run.start)})` }}\n />\n ))}\n {calls.map((event, index) => (\n <span\n key={index}\n data-kept-call=\"\"\n className={cn(\n \"aperture:absolute aperture:top-2.5 aperture:h-1 aperture:min-w-1 aperture:rounded-full\",\n event.ok === false ? \"aperture:bg-destructive\" : \"aperture:bg-sky-500\",\n )}\n style={{\n left: share(span(event)[0]),\n width: `calc(${share(span(event)[1])} - ${share(span(event)[0])})`,\n }}\n />\n ))}\n <span className=\"aperture:absolute aperture:inset-x-0 aperture:top-5 aperture:h-1 aperture:overflow-hidden aperture:rounded-full aperture:bg-foreground/15\">\n {marked.map((one, index) => (\n <span\n key={index}\n className={cn(\n \"aperture:absolute aperture:inset-y-0\",\n one.cut ? \"aperture:bg-foreground/35\" : \"aperture:bg-amber-500/60\",\n )}\n style={{\n left: share(one.start),\n width: `calc(${share(one.end)} - ${share(one.start)})`,\n }}\n />\n ))}\n <span\n className=\"aperture:absolute aperture:inset-y-0 aperture:left-0 aperture:bg-primary/70\"\n style={{ width: share(time * 1000) }}\n />\n </span>\n {marks.map((event, index) => (\n <span\n key={index}\n data-kept-mark={event.kind}\n className={cn(\n \"aperture:absolute aperture:top-4.5 aperture:size-2 aperture:-translate-x-1/2 aperture:rounded-full aperture:ring-1 aperture:ring-background\",\n event.kind === \"caption\" ? \"aperture:bg-amber-500\" : \"aperture:bg-foreground/70\",\n )}\n style={{ left: share(span(event)[0]) }}\n />\n ))}\n <span\n className=\"aperture:absolute aperture:top-3.5 aperture:h-4 aperture:w-0.5 aperture:-translate-x-1/2 aperture:rounded-full aperture:bg-primary\"\n style={{ left: share(time * 1000) }}\n />\n {pointed === undefined ? null : (\n <span\n data-kept-track-tip=\"\"\n className=\"aperture:pointer-events-none aperture:absolute aperture:bottom-full aperture:z-10 aperture:mb-1 aperture:flex aperture:w-max aperture:max-w-64 aperture:-translate-x-1/2 aperture:flex-col aperture:gap-0.5 aperture:rounded-md aperture:bg-popover aperture:px-2 aperture:py-1 aperture:text-xs aperture:text-popover-foreground aperture:shadow-md aperture:ring-1 aperture:ring-foreground/10\"\n style={{ left: `clamp(4rem, ${share(pointed)}, calc(100% - 4rem))` }}\n >\n <span className=\"aperture:text-muted-foreground aperture:tabular-nums\">\n {formatDuration(pointed)}\n </span>\n {there.slice(0, 4).map((event, index) => (\n <span key={index} className=\"aperture:truncate\">\n {eventLabel(event)}\n {span(event)[1] - span(event)[0] >= 100 ? (\n <span className=\"aperture:text-muted-foreground\">\n {\" \"}\n · {((span(event)[1] - span(event)[0]) / 1000).toFixed(1)} s\n </span>\n ) : null}\n </span>\n ))}\n {there.length === 0\n ? moving.slice(0, 2).map((run, index) => <span key={index}>{run.label}</span>)\n : null}\n {stretch === undefined ? null : (\n <span className=\"aperture:text-muted-foreground\">{stretch.note}</span>\n )}\n </span>\n )}\n </div>\n );\n}\n\n/** Everything kept, as a panel over the picture's right side. */\nfunction KeptList({\n kept,\n viewed,\n onView,\n}: {\n kept: readonly Kept[];\n viewed: string | undefined;\n onView: (id: string) => void;\n}) {\n const session = useSession();\n\n return (\n <div\n data-kept-list=\"\"\n className=\"aperture:absolute aperture:top-9 aperture:right-0 aperture:bottom-0 aperture:z-20 aperture:flex aperture:w-72 aperture:max-w-full aperture:flex-col aperture:gap-0.5 aperture:overflow-y-auto aperture:border-l aperture:bg-popover aperture:p-1.5 aperture:shadow-lg aperture:animate-in aperture:slide-in-from-right-4 aperture:fade-in-0 aperture:duration-150\"\n >\n {kept.map((one) => (\n <button\n key={one.id}\n type=\"button\"\n aria-current={one.id === viewed}\n className={cn(\n \"aperture:flex aperture:items-center aperture:gap-2 aperture:rounded-md aperture:p-1.5 aperture:text-left aperture:text-sm aperture:outline-none aperture:hover:bg-muted aperture:focus-visible:bg-muted\",\n one.id === viewed && \"aperture:bg-muted\",\n )}\n onClick={() => onView(one.id)}\n >\n <Thumbnail src={keptPreview(one, session.fileUrl)}>\n {one.kind === \"recording\" ? <Film /> : <Camera />}\n </Thumbnail>\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:tabular-nums\">{formatStarted(one.at)}</span>\n <KeptFacts kept={one} />\n </span>\n </button>\n ))}\n </div>\n );\n}\n","import { useEffect, useRef, useState } from \"react\";\nimport { Plus, Smartphone, X } from \"lucide-react\";\nimport type { Presence, Session, Target } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Drawer,\n DrawerBody,\n DrawerContent,\n DrawerDescription,\n DrawerTitle,\n type DrawerSide,\n} from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useSession, useSessionSnapshot } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { TabFavicon, tabLabel } from \"./browser-tab-strip.tsx\";\nimport { automationName, MemberDot } from \"./session-presence.tsx\";\n\n/** How much of the window's height the sheet takes: as it opens, and dragged up. */\nconst HEIGHTS = [0.5, 1];\n\n/** How often the picture of a tab that is in view is asked for again. */\nconst PICTURE_EVERY_MS = 4000;\n\n/** The picture each tab was last shown with, which is there at once the next time. */\nconst lastPictures = new Map<string, { readonly tag: string | null; readonly url: string }>();\n\nexport interface TabSwitcherProps {\n /** The edge of the window it comes in from: a side's where the phone is held on its side. */\n readonly side?: DrawerSide;\n readonly open: boolean;\n readonly onOpenChange: (open: boolean) => void;\n}\n\n/**\n * The session's tabs as cards, each with a small picture of its page: the way from one tab\n * to another where there is no room for a row of them. It is a sheet over the window's\n * foot, half of the way up, that is dragged up for more of them and down to be rid of it;\n * a tab that is chosen and a press beside it are rid of it as well. At a side of the\n * window it is as tall as the window, with the cards two abreast, dragged to that side.\n */\nexport function TabSwitcher({ side = \"bottom\", open, onOpenChange }: TabSwitcherProps) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, targetFaviconUrl } = useWorkbench();\n const { changes } = useInputState();\n const snaps = side === \"bottom\";\n const { targets, presence } = snapshot;\n const [height, setHeight] = useState<number | string | null>(HEIGHTS[0] ?? null);\n // Each time it opens it is part of the way up again.\n useEffect(() => {\n if (open) {\n setHeight(HEIGHTS[0] ?? null);\n }\n }, [open]);\n\n return (\n <Drawer\n side={side}\n open={open}\n onOpenChange={onOpenChange}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: HEIGHTS } : {})}\n >\n <DrawerContent\n data-workbench-tab-switcher=\"\"\n data-height={!snaps || height === HEIGHTS[1] ? \"full\" : \"part\"}\n className={cn(\n snaps &&\n \"aperture:h-full aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\",\n )}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:gap-2 aperture:pr-3 aperture:pl-4 aperture:select-none\">\n <DrawerTitle className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {targets.length === 1 ? \"1 tab\" : `${targets.length} tabs`}\n </DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n The session's tabs. Choose one to watch it.\n </DrawerDescription>\n <Button\n type=\"button\"\n variant=\"secondary\"\n data-tab-switcher-new=\"\"\n disabled={!changes}\n onClick={() => {\n session.newTab();\n onOpenChange(false);\n }}\n >\n <Plus />\n New tab\n </Button>\n </div>\n <DrawerBody\n role=\"list\"\n className={cn(\n \"aperture:grid aperture:auto-rows-min aperture:gap-3 aperture:px-3 aperture:pt-1 aperture:pb-[max(1rem,env(safe-area-inset-bottom))]\",\n snaps\n ? \"aperture:grid-cols-[repeat(auto-fill,minmax(9.5rem,1fr))]\"\n : \"aperture:grid-cols-2\",\n )}\n >\n {targets.map((target) => (\n <TabCard\n key={target.tab}\n target={target}\n active={target.tab === snapshot.selected}\n presence={features.presence ? presence : undefined}\n faviconSrc={targetFaviconUrl(target)}\n wide={!snaps}\n closes={changes}\n onSelect={() => {\n session.select(target.tab);\n onOpenChange(false);\n }}\n onClose={() => session.closeTab(target.tab)}\n />\n ))}\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n\nfunction TabCard({\n target,\n active,\n presence,\n faviconSrc,\n wide,\n closes,\n onSelect,\n onClose,\n}: {\n target: Target;\n active: boolean;\n presence: Presence | undefined;\n faviconSrc: string | undefined;\n /** The picture is as a page on a phone held on its side: wider than tall. */\n wide: boolean;\n closes: boolean;\n onSelect: () => void;\n onClose: () => void;\n}) {\n const card = useRef<HTMLDivElement>(null);\n const inView = useInView(card);\n const label = tabLabel(target);\n const held = presence?.held.find((one) => one.tab === target.tab);\n const holder = presence?.members.find((member) => member.id === held?.holder);\n const watchers =\n presence?.members.filter((member) => member.tab === target.tab && member.id !== holder?.id) ??\n [];\n const holds =\n holder === undefined\n ? undefined\n : holder.id === presence?.you\n ? \"You\"\n : holder.agent\n ? automationName(holder)\n : holder.name;\n\n return (\n <div\n ref={card}\n role=\"listitem\"\n data-tab-card={target.tab}\n data-active={active ? \"\" : undefined}\n className={cn(\n \"aperture:relative aperture:flex aperture:min-w-0 aperture:flex-col aperture:overflow-hidden aperture:rounded-xl aperture:bg-card aperture:ring-1 aperture:ring-foreground/10\",\n active && \"aperture:ring-2 aperture:ring-primary\",\n )}\n >\n <button\n type=\"button\"\n aria-label={`Switch to ${label}`}\n aria-current={active ? \"true\" : undefined}\n className=\"aperture:absolute aperture:inset-0 aperture:z-10 aperture:rounded-xl aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\"\n onClick={onSelect}\n />\n <div className=\"aperture:flex aperture:h-10 aperture:shrink-0 aperture:items-center aperture:gap-1.5 aperture:pl-2.5\">\n <TabFavicon src={faviconSrc} />\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate aperture:text-xs aperture:font-medium\">\n {label}\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label={`Close ${label}`}\n data-tab-card-close=\"\"\n disabled={!closes}\n className=\"aperture:relative aperture:z-20 aperture:shrink-0 aperture:text-muted-foreground\"\n onClick={onClose}\n >\n <X />\n </Button>\n </div>\n <TabPicture target={target} asked={inView} wide={wide} />\n <div className=\"aperture:flex aperture:h-8 aperture:shrink-0 aperture:items-center aperture:gap-1.5 aperture:px-2.5 aperture:text-[0.6875rem] aperture:text-muted-foreground\">\n {target.mobile ? (\n <Smartphone\n aria-label=\"Shown as on a phone\"\n className=\"aperture:size-3 aperture:shrink-0\"\n />\n ) : null}\n <span className=\"aperture:min-w-0 aperture:flex-1 aperture:truncate\">\n {hostOf(target.url)}\n </span>\n {holder === undefined ? null : (\n <span\n data-tab-card-holder=\"\"\n className=\"aperture:flex aperture:max-w-[60%] aperture:shrink-0 aperture:items-center aperture:gap-1\"\n >\n <MemberDot member={holder} holds />\n <span className=\"aperture:truncate aperture:text-foreground\">{holds}</span>\n </span>\n )}\n {watchers.slice(0, 3).map((member) => (\n <MemberDot key={member.id} member={member} holds={false} />\n ))}\n </div>\n </div>\n );\n}\n\n/** What a tab's address says of where its page is from. */\nexport function hostOf(url: string): string {\n try {\n const parsed = new URL(url);\n return parsed.host === \"\"\n ? parsed.protocol.replace(/:$/u, \"\")\n : parsed.host.replace(/^www\\./u, \"\");\n } catch {\n return url;\n }\n}\n\nfunction TabPicture({ target, asked, wide }: { target: Target; asked: boolean; wide: boolean }) {\n const session = useSession();\n const src = useTabPicture(session, target, asked);\n return (\n <div\n className={cn(\n \"aperture:w-full aperture:overflow-hidden aperture:bg-muted\",\n wide ? \"aperture:aspect-[16/9]\" : \"aperture:aspect-[4/3]\",\n )}\n >\n {src === undefined ? null : (\n <img\n src={src}\n alt=\"\"\n data-tab-card-picture=\"\"\n className=\"aperture:size-full aperture:object-cover aperture:object-left-top\"\n />\n )}\n </div>\n );\n}\n\n/**\n * A tab's small picture, asked for again every while for as long as it is `asked` for.\n * The session makes one in a while and tells when it is the one this browser has already,\n * which then keeps the picture it shows.\n */\nfunction useTabPicture(session: Session, target: Target, asked: boolean): string | undefined {\n // By the target and not by the tab's number: another session's tab may have the number.\n const key = target.id;\n const [src, setSrc] = useState(() => lastPictures.get(key)?.url);\n const tab = target.tab;\n\n useEffect(() => {\n if (!asked) {\n return undefined;\n }\n let ended = false;\n const look = async () => {\n const answer = await fetch(session.previewUrl(tab), { cache: \"no-cache\" });\n if (!answer.ok || ended) {\n return;\n }\n const tag = answer.headers.get(\"etag\");\n const before = lastPictures.get(key);\n if (before !== undefined && tag !== null && before.tag === tag) {\n return;\n }\n const url = URL.createObjectURL(await answer.blob());\n if (ended) {\n URL.revokeObjectURL(url);\n return;\n }\n lastPictures.set(key, { tag, url });\n setSrc(url);\n if (before !== undefined) {\n // After the picture that replaces it is shown.\n setTimeout(() => URL.revokeObjectURL(before.url), 1000);\n }\n };\n // A picture that does not come leaves the one there is, or none.\n const again = () => void look().catch(() => undefined);\n again();\n const timer = setInterval(again, PICTURE_EVERY_MS);\n return () => {\n ended = true;\n clearInterval(timer);\n };\n }, [session, tab, key, asked]);\n\n return src;\n}\n\n/** Whether an element is where it can be seen. */\nfunction useInView(ref: React.RefObject<HTMLElement | null>): boolean {\n const [inView, setInView] = useState(false);\n useEffect(() => {\n const element = ref.current;\n if (element === null) {\n return undefined;\n }\n if (typeof IntersectionObserver === \"undefined\") {\n setInView(true);\n return undefined;\n }\n const seen = new IntersectionObserver((entries) => {\n setInView(entries.some((entry) => entry.isIntersecting));\n });\n seen.observe(element);\n return () => seen.disconnect();\n }, [ref]);\n return inView;\n}\n","import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { ArrowLeft, Pencil, Search, X } from \"lucide-react\";\nimport type { Member, Presence } from \"@aperture-browser/session-client\";\nimport { Button } from \"@aperture-browser/ui/components/button\";\nimport {\n Drawer,\n DrawerBody,\n DrawerContent,\n DrawerDescription,\n DrawerTitle,\n type DrawerSide,\n} from \"@aperture-browser/ui/components/drawer\";\nimport { cn } from \"@aperture-browser/ui/utils\";\nimport { useInputState } from \"../hooks/use-actions.ts\";\nimport { useAddress } from \"../hooks/use-address.ts\";\nimport { usePhoneOnSide, useRailSide } from \"../hooks/use-media.ts\";\nimport { useLease, useSession, useSessionSnapshot, useWatchedTarget } from \"../session.tsx\";\nimport { useWorkbench } from \"../workbench/context.tsx\";\nimport { WorkbenchSlot } from \"../workbench/slot.tsx\";\nimport { CompactContext } from \"./browser-toolbar.tsx\";\nimport { BrowserViewport } from \"./browser-viewport.tsx\";\nimport { KeptGallery } from \"./kept-gallery.tsx\";\nimport { PageMenu } from \"./page-menu.tsx\";\nimport { PhoneMenu, PhoneMenuContext, type PhoneMenuState } from \"./phone-menu.tsx\";\nimport { useSessionFiles } from \"./session-files.tsx\";\nimport { automationName, MemberAvatar, MemberDot } from \"./session-presence.tsx\";\nimport { hostOf, TabSwitcher } from \"./tab-switcher.tsx\";\n\n/** How long the on-screen keyboard takes to be gone once what was typed into is left. */\nconst KEYBOARD_LEAVES_MS = 400;\n\nconst ROLES = { view: \"may watch\", control: \"may give input\", admin: \"admin\" } as const;\n\n/** What is pressed in the bar: round, and as large as a finger needs. */\nconst PRESSED = \"aperture:size-10 aperture:shrink-0 aperture:rounded-full\";\n\n/** What the bar and what stands for it while it is away are made of: the page shows through. */\nconst GLASS =\n \"aperture:bg-background/75 aperture:shadow-lg aperture:ring-1 aperture:ring-foreground/10 aperture:backdrop-blur-xl aperture:backdrop-saturate-150\";\n\n/** How the bar comes and goes. */\nconst MOVES =\n \"aperture:transition-[translate,opacity,scale] aperture:duration-300 aperture:ease-[cubic-bezier(0.32,0.72,0,1)] aperture:motion-reduce:duration-0\";\n\n/**\n * Where the bar is laid: across the picture's `foot`, or as a rail along its `left` or\n * `right`, where the phone is held on its side and height is what there is least of.\n */\ntype BarLay = \"foot\" | \"left\" | \"right\";\n\n/** How much room beside the picture the rail needs to stand there and not over it. */\nconst RAIL_ROOM = 48;\n\n/** The picture as tall as it is with no keyboard over the window's foot. */\nconst UNDER_KEYBOARD = \"calc(100% + var(--keyboard-inset, 0px))\";\n\n/** How far down the page a finger moves it before the bar goes, and how far up before it is back. */\nconst HIDES_AFTER = 48;\nconst SHOWS_AFTER = 24;\n/** How long a finger rests before what it moved the page by counts anew. */\nconst DRAG_RESTS_MS = 400;\n/** How far a finger goes across the bar before it is a swipe and no press. */\nconst SWIPED_PX = 20;\nconst MARK_SWIPED_PX = 8;\n\n/** The page a tab shows, as far as another one brings the bar back: not what it scrolled to. */\nconst pageOf = (url: string) => {\n try {\n const parsed = new URL(url);\n return `${parsed.origin}${parsed.pathname}`;\n } catch {\n return url;\n }\n};\n\n/**\n * Where the bar is: `shown`; `away`, with a small mark standing for it at the picture's\n * foot; or `gone`, with nothing of it over the page at all.\n */\ntype BarPlace = \"shown\" | \"away\" | \"gone\";\n\n/**\n * Where the bar is, and the means to put it elsewhere.\n *\n * It goes when a finger moves the page down, and is back when one moves it up, however\n * little the page had left to go: it is the finger that is followed, not the page, so a\n * page that scrolls nowhere brings it back as well. Another page and another tab bring it\n * back, and it is shown for as long as `stays` holds.\n */\nfunction useBarPlace(stays: boolean) {\n const session = useSession();\n const watched = useWatchedTarget();\n const [place, setPlace] = useState<BarPlace>(\"shown\");\n const staying = useRef(stays);\n staying.current = stays;\n\n useEffect(() => {\n let moved = 0;\n let last = 0;\n return session.onDragged((by) => {\n // Along the page's width is no scrolling of it.\n if (Math.abs(by.y) <= Math.abs(by.x)) {\n return;\n }\n const now = performance.now();\n if (now - last > DRAG_RESTS_MS || Math.sign(by.y) !== Math.sign(moved)) {\n moved = 0;\n }\n last = now;\n moved += by.y;\n if (staying.current) {\n return;\n }\n if (moved > HIDES_AFTER) {\n // What was put out of the way altogether stays so.\n setPlace((before) => (before === \"shown\" ? \"away\" : before));\n } else if (moved < -SHOWS_AFTER) {\n setPlace(\"shown\");\n }\n });\n }, [session]);\n\n const page = watched === undefined ? undefined : `${watched.id} ${pageOf(watched.url)}`;\n useEffect(() => setPlace(\"shown\"), [page]);\n // What it was shown for leaves it shown, and what put it away meanwhile is done.\n useEffect(() => {\n if (stays) {\n setPlace(\"shown\");\n }\n }, [stays]);\n\n return [stays ? \"shown\" : place, setPlace] as const;\n}\n\n/**\n * Tells a swipe across the bar from a press: into the picture and out of it are what the\n * bar does with it, and the press that would follow a swipe is nobody's.\n */\nfunction useSwipe(lay: BarLay, swiped: (inward: boolean) => void, after = SWIPED_PX) {\n const from = useRef<{ x: number; y: number; done: boolean } | undefined>(undefined);\n return {\n onPointerDown: (event: React.PointerEvent) => {\n // What is pressed in a sheet opened from here is told here as well, and is no\n // swipe of this.\n const within = event.target instanceof Node && event.currentTarget.contains(event.target);\n from.current = within ? { x: event.clientX, y: event.clientY, done: false } : undefined;\n },\n onPointerMove: (event: React.PointerEvent) => {\n const began = from.current;\n if (began === undefined || began.done) {\n return;\n }\n const by = { x: event.clientX - began.x, y: event.clientY - began.y };\n const [across, along] = lay === \"foot\" ? [by.y, by.x] : [by.x, by.y];\n if (Math.abs(across) >= after && Math.abs(across) > Math.abs(along)) {\n began.done = true;\n swiped(lay === \"left\" ? across > 0 : across < 0);\n }\n },\n // A press that ended as none, as one whose finger left the bar, begins no swipe later.\n onPointerUp: () => {\n if (from.current?.done === false) {\n from.current = undefined;\n }\n },\n onPointerCancel: () => {\n from.current = undefined;\n },\n onClickCapture: (event: React.MouseEvent) => {\n if (from.current?.done === true) {\n event.preventDefault();\n event.stopPropagation();\n }\n from.current = undefined;\n },\n };\n}\n\n/**\n * How much room there is beside the workbench at a side of the window: what a screen's\n * cutout and corners keep the picture out of, where whoever shows the workbench leaves\n * that empty.\n */\nfunction useRoomBeside(root: React.RefObject<HTMLElement | null>, lay: BarLay): number {\n const [room, setRoom] = useState(0);\n useLayoutEffect(() => {\n const element = root.current;\n if (element === null || lay === \"foot\") {\n setRoom(0);\n return undefined;\n }\n const measure = () => {\n const box = element.getBoundingClientRect();\n const beside = lay === \"left\" ? box.left : window.innerWidth - box.right;\n setRoom(Math.max(0, Math.round(beside)));\n };\n measure();\n const resized = new ResizeObserver(measure);\n resized.observe(element);\n window.addEventListener(\"resize\", measure);\n return () => {\n resized.disconnect();\n window.removeEventListener(\"resize\", measure);\n };\n }, [root, lay]);\n return room;\n}\n\n/**\n * The workbench on a phone: the picture, and over it one bar with the way back, the\n * address, the tabs and a menu with all the rest.\n *\n * The bar is laid over the picture and takes none of its room: the page keeps its size\n * whether the bar is there or away, so nothing of it is drawn anew as the bar comes and\n * goes. It goes as the page is moved down, and a small mark stands for it, which is\n * swiped away where a page has something of its own under it; it is back as the page is\n * moved up or the mark is pressed.\n *\n * A phone held upright has the bar across the picture's foot. One held on its side has a\n * rail along a side of the picture in its place, since height is what there is least of:\n * the address is typed across the picture's head then, and what opens from the rail\n * comes in from its side. Where there is room beside the picture, as a screen's cutout\n * and corners leave, the rail stands there, over nothing, and stays.\n */\nexport function PhoneWorkbench() {\n const snapshot = useSessionSnapshot();\n const { features, drawing } = useWorkbench();\n const lease = useLease();\n const files = useSessionFiles({ sheet: true });\n const onSide = usePhoneOnSide();\n const railSide = useRailSide();\n const lay: BarLay = onSide ? railSide : \"foot\";\n const sheetSide = lay === \"foot\" ? \"bottom\" : lay;\n const root = useRef<HTMLDivElement>(null);\n const room = useRoomBeside(root, lay);\n const stands = room >= RAIL_ROOM;\n const stage = useRef<HTMLDivElement>(null);\n // The height the picture keeps while the address is typed: the keyboard that comes for\n // it covers the picture's foot, and is no reason to give the page another size.\n const [kept, setKept] = useState<number | string>();\n const leaving = useRef<ReturnType<typeof setTimeout>>(undefined);\n useEffect(() => () => clearTimeout(leaving.current), []);\n const [editing, setEditing] = useState(false);\n const [switching, setSwitching] = useState(false);\n const [people, setPeople] = useState(false);\n const [menu, setMenu] = useState(false);\n const typed = useRef<HTMLElement | null>(null);\n\n const watched = snapshot.targets.find((target) => target.tab === snapshot.selected);\n // The bar stays while it is used, while there is no page to move, and while someone\n // asks this member for the tab or a page asks for a file, which the bar tells of.\n const stays =\n stands ||\n editing ||\n switching ||\n people ||\n menu ||\n files.open ||\n files.request !== undefined ||\n drawing ||\n lease.state === \"asked-of-you\" ||\n snapshot.connection.state !== \"open\" ||\n watched === undefined;\n const [place, setPlace] = useBarPlace(stays);\n\n // A phone that is turned while the address is typed has another height to keep.\n const turned = useRef(lay);\n useEffect(() => {\n if (turned.current !== lay) {\n turned.current = lay;\n setKept((before) => (before === undefined ? undefined : UNDER_KEYBOARD));\n }\n }, [lay]);\n\n const edit = (now: boolean) => {\n clearTimeout(leaving.current);\n setEditing(now);\n if (now) {\n setKept(stage.current?.clientHeight);\n } else {\n leaving.current = setTimeout(() => setKept(undefined), KEYBOARD_LEAVES_MS);\n }\n };\n\n const shared = useMemo<PhoneMenuState>(\n () => ({ typed, hideBar: () => setPlace(\"away\"), files, side: sheetSide }),\n [files, sheetSide, setPlace],\n );\n\n return (\n <PhoneMenuContext.Provider value={shared}>\n <CompactContext.Provider value>\n <div\n ref={root}\n data-workbench-phone=\"\"\n data-bar={place}\n data-lay={lay}\n className=\"aperture:relative aperture:min-h-0 aperture:min-w-0 aperture:flex-1 aperture:overflow-hidden\"\n >\n <div\n ref={stage}\n className=\"aperture:absolute aperture:inset-x-0 aperture:top-0 aperture:flex aperture:flex-col aperture:overflow-hidden\"\n style={{ height: kept ?? \"100%\" }}\n >\n <BrowserViewport />\n </div>\n <PhoneBar\n lay={lay}\n beside={stands ? room : 0}\n away={place !== \"shown\"}\n editing={editing}\n menu={menu}\n onEdit={edit}\n onAway={() => setPlace(\"away\")}\n onSwitching={setSwitching}\n onPeople={setPeople}\n onMenu={setMenu}\n />\n <BarMark\n lay={lay}\n there={place === \"away\"}\n onShow={() => setPlace(\"shown\")}\n onGone={() => setPlace(\"gone\")}\n />\n {features.pageMenu ? <PageMenu /> : null}\n {features.recordings ? <KeptGallery /> : null}\n </div>\n {features.tabs ? (\n <TabSwitcher side={sheetSide} open={switching} onOpenChange={setSwitching} />\n ) : null}\n {features.presence ? (\n <PeopleSheet side={sheetSide} open={people} onOpenChange={setPeople} />\n ) : null}\n {features.files ? (\n <FilesSheet side={sheetSide} open={files.open} onOpenChange={files.setOpen}>\n {files.panel}\n </FilesSheet>\n ) : null}\n </CompactContext.Provider>\n </PhoneMenuContext.Provider>\n );\n}\n\nfunction PhoneBar({\n lay,\n beside,\n away,\n editing,\n menu,\n onEdit,\n onAway,\n onSwitching,\n onPeople,\n onMenu,\n}: {\n lay: BarLay;\n /** The room beside the picture a rail stands in, where it does not stand over it. */\n beside: number;\n away: boolean;\n editing: boolean;\n menu: boolean;\n onEdit: (editing: boolean) => void;\n onAway: () => void;\n onSwitching: (switching: boolean) => void;\n onPeople: (open: boolean) => void;\n onMenu: (open: boolean) => void;\n}) {\n const session = useSession();\n const snapshot = useSessionSnapshot();\n const { features, drawing, setDrawing } = useWorkbench();\n const input = useInputState();\n const watched = useWatchedTarget();\n const goes = input.changes && watched !== undefined;\n const open = snapshot.connection.state === \"open\";\n const rail = lay !== \"foot\" && !editing;\n // Into the picture for the tabs, out of it to put the bar away; neither while the\n // address is typed, nor the latter where the rail stays.\n const swipe = useSwipe(lay, (inward) => {\n if (editing) {\n return;\n }\n if (!inward) {\n if (beside === 0) {\n onAway();\n }\n } else if (features.tabs) {\n onSwitching(true);\n }\n });\n\n return (\n <div\n data-workbench-phone-bar=\"\"\n data-editing={editing ? \"\" : undefined}\n data-rail={rail ? lay : undefined}\n data-away={away ? \"\" : undefined}\n inert={away}\n className={cn(\n \"aperture:pointer-events-none aperture:z-30 aperture:flex aperture:justify-center\",\n // Beside the picture is outside of what the workbench is laid in, and may be\n // outside of what shows it as well: there the rail is laid by the window.\n rail && beside > 0 ? \"aperture:fixed\" : \"aperture:absolute\",\n MOVES,\n !rail &&\n (lay === \"foot\"\n ? \"aperture:inset-x-0 aperture:bottom-0 aperture:px-2 aperture:pb-1.5\"\n : // The keyboard is over the window's foot, so the address is typed at its head.\n \"aperture:inset-x-0 aperture:top-0 aperture:px-2 aperture:pt-1.5\"),\n rail && \"aperture:inset-y-0 aperture:items-center aperture:px-1\",\n rail && beside === 0 && (lay === \"left\" ? \"aperture:left-0\" : \"aperture:right-0\"),\n away &&\n (lay === \"foot\"\n ? \"aperture:translate-y-[calc(100%+0.5rem)] aperture:opacity-0\"\n : lay === \"left\"\n ? \"aperture:-translate-x-[calc(100%+0.5rem)] aperture:opacity-0\"\n : \"aperture:translate-x-[calc(100%+0.5rem)] aperture:opacity-0\"),\n )}\n style={rail && beside > 0 ? { [lay]: 0, width: beside, paddingInline: 0 } : undefined}\n >\n <div\n data-workbench-phone-pill=\"\"\n className={cn(\n \"aperture:pointer-events-auto aperture:relative aperture:flex aperture:min-w-0 aperture:touch-none aperture:items-center aperture:gap-0.5 aperture:rounded-full aperture:select-none\",\n rail\n ? \"aperture:max-h-full aperture:w-12 aperture:flex-col aperture:py-1\"\n : \"aperture:h-12 aperture:w-full aperture:px-1\",\n GLASS,\n )}\n {...swipe}\n >\n {editing ? (\n <AddressField onDone={() => onEdit(false)} />\n ) : (\n <>\n <WorkbenchSlot name=\"toolbar.start\" />\n {features.navigation ? (\n <BarButton\n label=\"Back\"\n className={PRESSED}\n disabled={!goes || watched?.goesBack !== true}\n onClick={() => session.go({ along: \"back\" })}\n >\n <ArrowLeft />\n </BarButton>\n ) : null}\n {features.addressBar ? (\n <AddressButton rail={rail} onEdit={() => onEdit(true)} />\n ) : (\n <div className=\"aperture:min-w-0 aperture:flex-1\" />\n )}\n {drawing ? (\n <BarButton\n label=\"Stop drawing\"\n variant=\"secondary\"\n aria-pressed\n className={PRESSED}\n onClick={() => setDrawing(false)}\n >\n <Pencil />\n </BarButton>\n ) : null}\n {features.presence && open ? (\n <PeopleButton rail={rail} onOpen={() => onPeople(true)} />\n ) : null}\n <WorkbenchSlot name=\"toolbar.end\" />\n {features.tabs ? (\n <BarButton\n label={`Tabs: ${snapshot.targets.length}`}\n data-workbench-tabs=\"\"\n className={PRESSED}\n onClick={() => onSwitching(true)}\n >\n <span className=\"aperture:flex aperture:size-5.5 aperture:items-center aperture:justify-center aperture:rounded-md aperture:border-[1.5px] aperture:border-current aperture:text-[0.6875rem] aperture:leading-none aperture:font-semibold aperture:tabular-nums\">\n {snapshot.targets.length > 99 ? \":)\" : snapshot.targets.length}\n </span>\n </BarButton>\n ) : null}\n {features.menus ? (\n <PhoneMenu open={menu} onOpenChange={onMenu} className={PRESSED} />\n ) : null}\n </>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * What stands for the bar while it is away: where the page is from and who else is here,\n * small, at the middle of the picture's foot; and for a rail a grip with who else is\n * here, at the middle of its side. Pressed or swiped into the picture, the bar is back;\n * swiped out of it, it is gone as well, for a page that has something of its own right\n * there.\n *\n * It is pressed where it is drawn and no further around it, smaller than a finger likes:\n * what it stands over is the page's, and the bar is back by moving the page up as well.\n */\nfunction BarMark({\n lay,\n there,\n onShow,\n onGone,\n}: {\n lay: BarLay;\n there: boolean;\n onShow: () => void;\n onGone: () => void;\n}) {\n const { features } = useWorkbench();\n const { presence, connection } = useSessionSnapshot();\n const watched = useWatchedTarget();\n // The window ends right beside it: a finger has little way to go out of it.\n const swipe = useSwipe(lay, (inward) => (inward ? onShow() : onGone()), MARK_SWIPED_PX);\n const others =\n features.presence && connection.state === \"open\"\n ? (presence?.members.filter((member) => member.id !== presence.you) ?? [])\n : [];\n const holds = (member: Member) =>\n presence?.held.some((held) => held.holder === member.id) ?? false;\n const host = watched === undefined ? \"\" : hostOf(watched.url);\n const foot = lay === \"foot\";\n\n return (\n <div\n inert={!there}\n className={cn(\n \"aperture:pointer-events-none aperture:absolute aperture:z-30 aperture:flex aperture:justify-center\",\n foot\n ? \"aperture:inset-x-0 aperture:bottom-0 aperture:pb-0.5\"\n : \"aperture:inset-y-0 aperture:items-center aperture:px-0.5\",\n lay === \"left\" && \"aperture:left-0\",\n lay === \"right\" && \"aperture:right-0\",\n MOVES,\n !there &&\n (foot\n ? \"aperture:translate-y-3 aperture:opacity-0\"\n : lay === \"left\"\n ? \"aperture:-translate-x-3 aperture:opacity-0\"\n : \"aperture:translate-x-3 aperture:opacity-0\"),\n )}\n >\n <button\n type=\"button\"\n data-workbench-phone-mark=\"\"\n aria-label=\"Show the bar\"\n className={cn(\n \"aperture:pointer-events-auto aperture:flex aperture:touch-none aperture:items-center aperture:justify-center aperture:gap-1 aperture:rounded-full aperture:text-[0.6875rem] aperture:leading-none aperture:font-medium aperture:outline-none aperture:select-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\",\n foot\n ? \"aperture:h-6 aperture:max-w-[60%] aperture:min-w-16 aperture:px-2.5\"\n : \"aperture:min-h-16 aperture:w-5 aperture:flex-col aperture:py-2.5\",\n GLASS,\n )}\n onClick={onShow}\n {...swipe}\n >\n {foot ? (\n <span className=\"aperture:truncate\">{host}</span>\n ) : (\n <span\n aria-hidden\n className=\"aperture:h-6 aperture:w-1 aperture:rounded-full aperture:bg-foreground/40\"\n />\n )}\n {others.slice(0, 3).map((member) => (\n <MemberDot key={member.id} member={member} holds={holds(member)} />\n ))}\n </button>\n </div>\n );\n}\n\nfunction BarButton({\n label,\n children,\n ...props\n}: { label: string; children: ReactNode } & Omit<\n React.ComponentProps<typeof Button>,\n \"children\" | \"aria-label\"\n>) {\n return (\n <Button type=\"button\" variant=\"ghost\" aria-label={label} {...props}>\n {children}\n </Button>\n );\n}\n\n/**\n * Where the watched tab's page is from, which is pressed to say where it is to go. A rail\n * has no room to say where the page is from: there it is the way to the address alone.\n */\nfunction AddressButton({ rail, onEdit }: { rail: boolean; onEdit: () => void }) {\n const address = useAddress();\n const watched = useWatchedTarget();\n const connecting = useSessionSnapshot().connection.state === \"connecting\";\n const shown = watched === undefined ? \"\" : hostOf(watched.url);\n\n return (\n <button\n type=\"button\"\n aria-label=\"Address\"\n title={rail ? shown : undefined}\n data-workbench-address-button=\"\"\n disabled={!address.navigates}\n className={cn(\n \"aperture:relative aperture:flex aperture:h-10 aperture:min-w-0 aperture:items-center aperture:justify-center aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50 aperture:disabled:opacity-50\",\n rail\n ? \"aperture:w-10 aperture:shrink-0 aperture:active:bg-accent aperture:[&_svg]:size-4\"\n : \"aperture:flex-1 aperture:bg-foreground/6 aperture:px-3 aperture:text-sm\",\n )}\n onClick={onEdit}\n >\n {rail ? (\n <Search />\n ) : (\n <span className=\"aperture:truncate\">\n {connecting ? \"Connecting…\" : shown === \"\" ? \"Search or type an address\" : shown}\n </span>\n )}\n </button>\n );\n}\n\n/** The address as a field, across the bar, for as long as it is typed into. */\nfunction AddressField({ onDone }: { onDone: () => void }) {\n const address = useAddress();\n const field = useRef<HTMLInputElement>(null);\n\n // Within the tap that asked for it: a phone's keyboard comes for nothing later.\n useEffect(() => {\n field.current?.focus();\n field.current?.select();\n }, []);\n\n const leave = () => {\n address.reset();\n onDone();\n };\n\n return (\n <>\n <input\n ref={field}\n data-workbench-address=\"\"\n aria-label=\"Address\"\n value={address.value}\n onChange={(event) => address.type(event.target.value)}\n onBlur={leave}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n if (address.submit(event.currentTarget.value)) {\n event.currentTarget.blur();\n }\n }\n if (event.key === \"Escape\") {\n event.currentTarget.blur();\n }\n }}\n placeholder=\"Search or type an address\"\n inputMode=\"url\"\n enterKeyHint=\"go\"\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n // A phone zooms into a field whose text is smaller than this.\n className=\"aperture:h-10 aperture:min-w-0 aperture:flex-1 aperture:rounded-full aperture:bg-foreground/6 aperture:px-4 aperture:text-base aperture:outline-none\"\n />\n <BarButton\n label=\"Cancel\"\n className={PRESSED}\n // Before the field is left, which the press would otherwise be too late for.\n onPointerDown={(event) => event.preventDefault()}\n onClick={() => field.current?.blur()}\n >\n <X />\n </BarButton>\n </>\n );\n}\n\n/** The others in the session, as far as there is room; pressed, everyone. */\nfunction PeopleButton({ rail, onOpen }: { rail: boolean; onOpen: () => void }) {\n const { presence } = useSessionSnapshot();\n const others = presence?.members.filter((member) => member.id !== presence.you) ?? [];\n if (presence === undefined || others.length === 0) {\n return null;\n }\n const holds = (member: Member) => presence.held.some((held) => held.holder === member.id);\n const first = others.toSorted((left, right) => Number(holds(right)) - Number(holds(left)));\n const [shown] = first;\n const more = others.length - 1;\n\n return (\n <button\n type=\"button\"\n data-session-presence=\"\"\n aria-label={`${others.length + 1} people in the session`}\n className={cn(\n \"aperture:relative aperture:flex aperture:shrink-0 aperture:items-center aperture:justify-center aperture:gap-0.5 aperture:rounded-full aperture:outline-none aperture:focus-visible:ring-3 aperture:focus-visible:ring-ring/50\",\n // Under the rail and not in it: the rail's buttons stay where they are as people\n // come and go, so a finger on its way to one does not land on another.\n rail\n ? cn(\n \"aperture:absolute aperture:top-full aperture:left-1/2 aperture:mt-1 aperture:min-h-12 aperture:w-12 aperture:-translate-x-1/2 aperture:flex-col aperture:py-1\",\n GLASS,\n )\n : \"aperture:h-10 aperture:min-w-10 aperture:px-1\",\n )}\n onClick={onOpen}\n >\n {shown === undefined ? null : <MemberAvatar member={shown} holds={holds(shown)} />}\n {more > 0 ? (\n <span className=\"aperture:text-xs aperture:font-medium aperture:text-muted-foreground aperture:tabular-nums\">\n +{more}\n </span>\n ) : null}\n </button>\n );\n}\n\n/** Everyone in the session: what each may do, watches and holds, and following them. */\nfunction PeopleSheet({\n side,\n open,\n onOpenChange,\n}: {\n side: DrawerSide;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}) {\n const session = useSession();\n const { presence } = useSessionSnapshot();\n // Who was there stays while the sheet closes.\n const last = useRef<Presence | undefined>(presence);\n if (presence !== undefined) {\n last.current = presence;\n }\n const told = presence ?? last.current;\n const you = told?.members.find((member) => member.id === told.you);\n const members = (told?.members ?? []).toSorted(\n (left, right) => Number(right.id === told?.you) - Number(left.id === told?.you),\n );\n\n return (\n <Drawer side={side} open={open} onOpenChange={onOpenChange}>\n <DrawerContent\n data-workbench-people=\"\"\n className={cn(\n \"aperture:pb-[max(0.5rem,env(safe-area-inset-bottom))]\",\n side === \"bottom\" &&\n \"aperture:max-h-[60%] aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\",\n )}\n >\n <div className=\"aperture:flex aperture:h-13 aperture:shrink-0 aperture:items-center aperture:px-4 aperture:select-none\">\n <DrawerTitle>In the session</DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n Who is in the session, and what each watches and holds.\n </DrawerDescription>\n </div>\n <DrawerBody render={<ul />} className=\"aperture:flex aperture:flex-col aperture:px-2\">\n {members.map((member) => {\n const held = told?.held.filter((one) => one.holder === member.id) ?? [];\n const followed = you?.follows === member.id;\n const said = [\n member.agent\n ? \"automation\"\n : member.role === undefined\n ? undefined\n : ROLES[member.role],\n member.tab === undefined ? undefined : `watches tab ${member.tab}`,\n held.length === 0 ? undefined : `holds tab ${held.map((one) => one.tab).join(\", \")}`,\n ].filter((part) => part !== undefined);\n return (\n <li\n key={member.id}\n data-member={member.id}\n className=\"aperture:flex aperture:min-h-14 aperture:items-center aperture:gap-3 aperture:px-2\"\n >\n <MemberAvatar member={member} holds={held.length > 0} />\n <span className=\"aperture:flex aperture:min-w-0 aperture:flex-1 aperture:flex-col\">\n <span className=\"aperture:truncate aperture:text-sm aperture:font-medium\">\n {member.agent ? automationName(member) : member.name}\n {member.id === told?.you ? \" (you)\" : \"\"}\n </span>\n <span className=\"aperture:truncate aperture:text-xs aperture:text-muted-foreground\">\n {said.join(\" · \")}\n </span>\n </span>\n {member.id === told?.you ? null : (\n <Button\n type=\"button\"\n variant={followed ? \"secondary\" : \"outline\"}\n aria-pressed={followed}\n data-member-follow={member.id}\n onClick={() => session.follow(followed ? undefined : member.id)}\n >\n {followed ? \"Following\" : \"Follow\"}\n </Button>\n )}\n </li>\n );\n })}\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n\n/** How much of the window's height the files take: as they open, and dragged up. */\nconst FILES_HEIGHTS = [0.5, 1];\n\n/** The session's files, as a sheet that is dragged like the others. */\nfunction FilesSheet({\n side,\n open,\n onOpenChange,\n children,\n}: {\n side: DrawerSide;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: ReactNode;\n}) {\n const [height, setHeight] = useState<number | string | null>(FILES_HEIGHTS[0] ?? null);\n // Each time it opens it is part of the way up again.\n useEffect(() => {\n if (open) {\n setHeight(FILES_HEIGHTS[0] ?? null);\n }\n }, [open]);\n const snaps = side === \"bottom\";\n\n return (\n <Drawer\n side={side}\n open={open}\n onOpenChange={onOpenChange}\n // Its height is this one's to say from the first, also while it has none to be at.\n snapPoint={height}\n onSnapPointChange={setHeight}\n {...(snaps ? { snapPoints: FILES_HEIGHTS } : {})}\n >\n <DrawerContent\n data-session-files=\"\"\n data-height={!snaps || height === FILES_HEIGHTS[1] ? \"full\" : \"part\"}\n className={cn(\n side === \"bottom\"\n ? \"aperture:h-full aperture:pr-[env(safe-area-inset-right)] aperture:pl-[env(safe-area-inset-left)]\"\n : \"aperture:pt-2\",\n )}\n >\n <DrawerTitle className=\"aperture:sr-only\">Files</DrawerTitle>\n <DrawerDescription className=\"aperture:sr-only\">\n What was put into the session, and what its browser downloaded.\n </DrawerDescription>\n <DrawerBody className=\"aperture:pb-[env(safe-area-inset-bottom)]\">{children}</DrawerBody>\n </DrawerContent>\n </Drawer>\n );\n}\n","import { useMemo, type ReactNode } from \"react\";\nimport { resolveContributions, type WorkbenchContributions } from \"../workbench/contributions.ts\";\nimport {\n useWorkbench,\n WorkbenchProvider,\n type WorkbenchProviderProps,\n} from \"../workbench/context.tsx\";\nimport { workbenchContributions } from \"../workbench/own.ts\";\nimport { WorkbenchTitlebar, WorkbenchToolbar } from \"./browser-toolbar.tsx\";\nimport { BrowserViewport } from \"./browser-viewport.tsx\";\nimport { KeptGallery } from \"./kept-gallery.tsx\";\nimport { PageMenu } from \"./page-menu.tsx\";\nimport { PhoneWorkbench } from \"./phone-bar.tsx\";\nimport { usePhone } from \"../hooks/use-media.ts\";\n\nexport interface SessionWorkbenchProps extends Omit<\n WorkbenchProviderProps,\n \"contributions\" | \"children\"\n> {\n /**\n * More for the workbench's slots, each in place of the workbench's own of the same id;\n * or a function of the workbench's own that gives all there are to be.\n */\n readonly contributions?: WorkbenchContributions | undefined;\n /**\n * Another arrangement of the workbench's parts, in place of the usual one: the title\n * bar, the toolbar, the picture and the page's menu.\n */\n readonly children?: ReactNode;\n}\n\n/**\n * One session as a browser to work in: the tab strip with the session's members, the\n * toolbar with its menus, the picture, and the menu of a right click in it.\n */\nexport function SessionWorkbench({ contributions, children, ...provider }: SessionWorkbenchProps) {\n const resolved = useMemo(\n () => resolveContributions(workbenchContributions, contributions),\n [contributions],\n );\n\n return (\n <WorkbenchProvider {...provider} contributions={resolved}>\n <WorkbenchFrame>{children ?? <WorkbenchParts />}</WorkbenchFrame>\n </WorkbenchProvider>\n );\n}\n\n/** The box the workbench's parts stand in, one below the other. */\nexport function WorkbenchFrame({ children }: { readonly children?: ReactNode }) {\n return (\n <div\n data-session-workbench=\"\"\n className=\"aperture:flex aperture:h-full aperture:min-h-0 aperture:min-w-0 aperture:flex-1 aperture:flex-col aperture:overflow-hidden aperture:bg-background\"\n >\n {children}\n </div>\n );\n}\n\nfunction WorkbenchParts() {\n const { features } = useWorkbench();\n const phone = usePhone();\n if (phone) {\n return <PhoneWorkbench />;\n }\n return (\n <>\n <WorkbenchTitlebar />\n <WorkbenchToolbar />\n <BrowserViewport />\n {features.pageMenu ? <PageMenu /> : null}\n {features.recordings ? <KeptGallery /> : null}\n </>\n );\n}\n","import { useEffect, useState, type ReactNode } from \"react\";\nimport { TooltipProvider } from \"@aperture-browser/ui/components/tooltip\";\nimport { PortalContainerProvider } from \"@aperture-browser/ui/portal\";\nimport { cn } from \"@aperture-browser/ui/utils\";\n\nexport type ApertureTheme = \"light\" | \"dark\" | \"system\";\n\nexport interface ApertureUIRootProps {\n readonly theme?: ApertureTheme;\n readonly className?: string;\n readonly children?: ReactNode;\n}\n\nexport function ApertureUIRoot({ theme = \"system\", className, children }: ApertureUIRootProps) {\n const [root, setRoot] = useState<HTMLDivElement | null>(null);\n const dark = useDarkTheme(theme);\n\n return (\n <div\n ref={setRoot}\n className={cn(\n \"aperture-root aperture:relative aperture:h-full aperture:w-full\",\n dark && \"aperture-dark\",\n className,\n )}\n >\n {root ? (\n <PortalContainerProvider container={root}>\n <TooltipProvider>{children}</TooltipProvider>\n </PortalContainerProvider>\n ) : null}\n </div>\n );\n}\n\nfunction useDarkTheme(theme: ApertureTheme): boolean {\n const [systemDark, setSystemDark] = useState(false);\n\n useEffect(() => {\n if (theme !== \"system\") {\n return;\n }\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const update = () => setSystemDark(query.matches);\n update();\n query.addEventListener(\"change\", update);\n return () => query.removeEventListener(\"change\", update);\n }, [theme]);\n\n return theme === \"dark\" || (theme === \"system\" && systemDark);\n}\n","import { useEffect } from \"react\";\nimport { Loader2 } from \"lucide-react\";\nimport type { ConnectOptions, Session } from \"@aperture-browser/session-client\";\nimport { Toaster } from \"@aperture-browser/ui/components/sonner\";\nimport { SessionWorkbench, type SessionWorkbenchProps } from \"./components/session-workbench.tsx\";\nimport type { ApertureSessionFeatures } from \"./features.ts\";\nimport { SessionProvider, useConnectedSession } from \"./session.tsx\";\nimport { ApertureUIRoot, type ApertureTheme } from \"./ui-root.tsx\";\n\nexport interface ApertureSessionProps\n extends ConnectOptions, Omit<SessionWorkbenchProps, \"features\" | \"appearance\" | \"children\"> {\n readonly features?: ApertureSessionFeatures | undefined;\n readonly theme?: ApertureTheme | undefined;\n /** With it, the browser menu offers to change the theme. */\n readonly onThemeChange?: ((theme: ApertureTheme) => void) | undefined;\n readonly className?: string | undefined;\n /** Hears of the session's client when there is one, and of none when it is closed. */\n readonly onSession?: ((session: Session | null) => void) | undefined;\n}\n\n/**\n * The workbench of one session: connects to it, shows it, and ends the connection when\n * unmounted. Needs `@aperture-browser/session-react/styles.css`.\n */\nexport function ApertureSession({\n url,\n token,\n name,\n pixels,\n features,\n theme = \"system\",\n onThemeChange,\n className,\n onSession,\n ...workbench\n}: ApertureSessionProps) {\n const { session, reconnect } = useConnectedSession({ url, token, name, pixels });\n\n useEffect(() => {\n if (session === null || onSession === undefined) {\n return undefined;\n }\n onSession(session);\n // Also when the component is unmounted, which no later render tells.\n return () => onSession(null);\n }, [onSession, session]);\n\n return (\n <ApertureUIRoot theme={theme} className={className}>\n {session === null ? (\n <div className=\"aperture:flex aperture:h-full aperture:flex-col aperture:items-center aperture:justify-center aperture:gap-2 aperture:bg-background aperture:text-sm aperture:text-muted-foreground\">\n <Loader2 className=\"aperture:size-5 aperture:animate-spin\" />\n Connecting to the session\n </div>\n ) : (\n <SessionProvider session={session} reconnect={reconnect}>\n <SessionWorkbench\n {...workbench}\n features={features}\n appearance={onThemeChange === undefined ? undefined : { theme, onThemeChange }}\n />\n </SessionProvider>\n )}\n {features?.toaster === false ? null : (\n <Toaster\n theme={theme}\n richColors\n closeButton\n position=\"bottom-center\"\n // Above the bar a phone's workbench has over its foot, and the keyboard.\n mobileOffset={{\n bottom: \"calc(var(--keyboard-inset, 0px) + env(safe-area-inset-bottom, 0px) + 4.5rem)\",\n }}\n />\n )}\n </ApertureUIRoot>\n );\n}\n","import { useCallback, useEffect, useSyncExternalStore } from \"react\";\n\n/**\n * Tells the styles what of the window the on-screen keyboard leaves to be seen, where the\n * browser lays the page out behind the keyboard and does not make the window shorter for\n * it: how much of the window's foot is covered, as `--keyboard-inset`, and how far down the\n * window what is seen begins, as `--keyboard-top`, which is more than nothing where the\n * browser moved the window up to show what is typed into. A sheet at the foot stands above\n * the keyboard then, and is no taller than what is left.\n */\nexport function useKeyboardInset() {\n useEffect(() => {\n const viewport = window.visualViewport;\n if (viewport === null) {\n return undefined;\n }\n const root = document.documentElement;\n let revealing = 0;\n const tell = () => {\n // A page that is zoomed into shows less of itself with no keyboard there.\n const whole = Math.abs(viewport.scale - 1) < 0.01;\n const top = whole ? Math.max(0, viewport.offsetTop) : 0;\n const covered = whole ? Math.max(0, window.innerHeight - viewport.height - top) : 0;\n root.style.setProperty(\"--keyboard-inset\", `${Math.round(covered)}px`);\n root.style.setProperty(\"--keyboard-top\", `${Math.round(top)}px`);\n // What is typed into in a dialog may be under where the dialog now ends: it is brought\n // back into what the dialog shows, once the dialog is as tall as it is to be.\n cancelAnimationFrame(revealing);\n revealing = requestAnimationFrame(() => {\n const typed = document.activeElement;\n if (\n typed instanceof HTMLElement &&\n typed.matches(\"input, textarea\") &&\n typed.closest('[data-slot=\"dialog-content\"]') !== null\n ) {\n typed.scrollIntoView({ block: \"nearest\" });\n }\n });\n };\n tell();\n viewport.addEventListener(\"resize\", tell);\n viewport.addEventListener(\"scroll\", tell);\n return () => {\n cancelAnimationFrame(revealing);\n viewport.removeEventListener(\"resize\", tell);\n viewport.removeEventListener(\"scroll\", tell);\n root.style.removeProperty(\"--keyboard-inset\");\n root.style.removeProperty(\"--keyboard-top\");\n };\n }, []);\n}\n\n/**\n * What of the window's top and foot is not seen, mostly for an on-screen keyboard: for what\n * is placed by a script, and stays clear of it.\n */\nexport function useKeyboardCovered() {\n const subscribe = useCallback((tell: () => void) => {\n const viewport = window.visualViewport;\n viewport?.addEventListener(\"resize\", tell);\n viewport?.addEventListener(\"scroll\", tell);\n return () => {\n viewport?.removeEventListener(\"resize\", tell);\n viewport?.removeEventListener(\"scroll\", tell);\n };\n }, []);\n // One string, so that what is told is the same until it changes.\n const told = useSyncExternalStore(\n subscribe,\n () => {\n const viewport = window.visualViewport;\n if (viewport === null || Math.abs(viewport.scale - 1) >= 0.01) {\n return \"0 0\";\n }\n const top = Math.max(0, Math.round(viewport.offsetTop));\n return `${top} ${Math.max(0, Math.round(window.innerHeight - viewport.height - top))}`;\n },\n () => \"0 0\",\n );\n const [top = 0, bottom = 0] = told.split(\" \").map(Number);\n return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