@trungtnm/agent-annotator 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +215 -2
- package/dist/index.d.ts +232 -0
- package/dist/index.js +4054 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/annotator.tsx","../src/redaction.ts","../src/serialize.ts","../src/context.ts","../src/fiber.ts","../src/selector.ts","../src/source-map.ts","../src/stack.ts","../src/capture.ts","../src/callouts.ts","../src/icons.tsx","../src/tooltip.tsx","../src/overlay-parts.tsx","../src/redaction-panel.tsx","../src/page-tools.ts","../src/prompt.ts","../src/flags.ts","../src/screenshot.ts","../src/screenshot-editor.tsx","../src/callout-tip.tsx","../src/screenshot-draw.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { captureElement, hoverLabel, type ElementCapture } from './capture';\nimport { layoutCallouts, type CalloutTarget } from './callouts';\nimport { AreaBox, boxOf, Callouts, Editor, Highlight, Hint, Panel, Pin, Toast, Toolbar, type ListEntry, type Notice } from './overlay-parts';\nimport { RedactionPanel } from './redaction-panel';\nimport { elementsInArea, OWN_SELECTOR, pauseMotion, type Rect } from './page-tools';\nimport { buildPrompt, type Annotation, type AnnotationKind } from './prompt';\nimport { truncate } from './serialize';\nimport { createRedactor, readRedaction, resolveRedaction, writeRedaction, type RedactionOptions, type RedactionSettings } from './redaction';\nimport { readFlag, writeFlag } from './flags';\nimport { CaptureCancelled, captureTab, shotFileName, type ScreenCapture } from './screenshot';\nimport { ScreenshotEditor } from './screenshot-editor';\nimport { createNextResolver, type FrameResolver } from './stack';\n\nexport interface DevAnnotatorProps {\n /** Names the app in the prompt and keys the saved comments (`web`, `admin`). */\n readonly appName: string;\n /** The app's directory from the repo root, so source paths in the prompt open as-is. */\n readonly appDir?: string;\n /**\n * Personal-data redaction for this app: on or off, which countries' phone and ID\n * formats to screen, and extra patterns. Each browser can change it from the toolbar's\n * redaction settings; these are the defaults it starts from and resets to.\n */\n readonly redaction?: RedactionOptions;\n /** Overrides how stack frames are mapped to source; tests pass one, apps never do. */\n readonly resolveFrames?: FrameResolver;\n /** Overrides how the tab is captured; tests pass one, apps never do. */\n readonly captureScreen?: ScreenCapture;\n}\n\ninterface Item {\n readonly annotation: Annotation;\n /** The elements commented on, while they are still in the document. */\n readonly elements: readonly Element[];\n}\n\ninterface Selection {\n readonly kind: AnnotationKind;\n readonly elements: readonly Element[];\n readonly label: string;\n readonly selectedText?: string;\n readonly area?: Rect;\n readonly areaInContainer?: Rect;\n}\n\ninterface Draft extends Selection {\n readonly captures: Promise<readonly ElementCapture[]>;\n readonly comment: string;\n /** Whether the captures were screened for personal data. */\n readonly redacted: boolean;\n /** Set when an existing comment is being edited. */\n readonly editingId: string | null;\n}\n\n/**\n * Events the page must not receive while a click means \"comment on this\". Propagation\n * stops; the default does NOT, so dragging still selects text. `click` is the one whose\n * default is prevented (a link must not navigate), in its own handler.\n */\nconst ISOLATED = ['pointerdown', 'pointerup', 'mousedown', 'mouseup', 'dblclick'] as const;\n/** How often pins follow layout changes that fire no scroll or resize event. */\nconst REFLOW_MS = 400;\n/** A drag shorter than this, either way, is a click. */\nconst MIN_AREA = 8;\n/** Shared by every app on the machine: someone who has learnt the shortcuts has learnt them everywhere. */\nconst HINT_HIDDEN_KEY = 'agent-annotator:hint-hidden';\nconst SHOW_COMMENTS_KEY = 'agent-annotator:show-comments';\nconst COLLAPSED_KEY = 'agent-annotator:toolbar-collapsed';\n/** How long a notice stays up. */\nconst NOTICE_MS = 5000;\n\nconst KIND_LABEL: Readonly<Record<AnnotationKind, (count: number) => string>> = {\n element: () => '',\n text: () => 'text',\n group: (count) => `${count} element`,\n area: () => 'area',\n};\n\n/**\n * Development-only overlay: a floating button switches on \"comment mode\". In it, a click\n * pins a comment to an element, a text selection to a passage, Cmd/Ctrl+click gathers\n * several elements under one comment and Shift+drag marks an area — and the page sees\n * none of it. \"Copy prompt\" puts every comment, with what the tool learned about its\n * elements, on the clipboard as one Markdown prompt for a coding agent.\n *\n * Comments survive client-side navigation (this component lives in the root layout) and\n * a full reload (sessionStorage), so one request can span several pages.\n */\nexport function DevAnnotator(props: DevAnnotatorProps): ReactNode {\n const { appName, appDir } = props;\n const storageKey = `agent-annotator:${appName}`;\n const redactionKey = `agent-annotator:redaction:${appName}`;\n const redactionDefaults = resolveRedaction(props.redaction);\n const [savedRedaction, setSavedRedaction] = useState<RedactionSettings | null>(() => readRedaction(redactionKey));\n const redaction = savedRedaction ?? redactionDefaults;\n const redactionJson = JSON.stringify(redaction);\n // Rebuilt only when a setting changes, not on every render of an inline `redaction` prop.\n const redactor = useMemo(() => createRedactor(JSON.parse(redactionJson) as RedactionSettings), [redactionJson]);\n const [settingsOpen, setSettingsOpen] = useState(false);\n const [resolveFrames] = useState<FrameResolver>(() => props.resolveFrames ?? createNextResolver());\n const [active, setActive] = useState(false);\n const [items, setItems] = useState<readonly Item[]>(() => restore(storageKey));\n const [includeData, setIncludeData] = useState(true);\n const [panelOpen, setPanelOpen] = useState(true);\n const [paused, setPaused] = useState(false);\n const [hintHidden, setHintHidden] = useState(() => readFlag(HINT_HIDDEN_KEY));\n const [hover, setHover] = useState<{ readonly element: Element; readonly label: string } | null>(null);\n const [group, setGroup] = useState<readonly Element[]>([]);\n const [dragBox, setDragBox] = useState<Rect | null>(null);\n const [draft, setDraft] = useState<Draft | null>(null);\n const [showComments, setShowComments] = useState(() => readFlag(SHOW_COMMENTS_KEY));\n const [collapsed, setCollapsed] = useState(() => readFlag(COLLAPSED_KEY));\n /** Between the capture permission and the grab: only the comments are on screen. */\n const [capturing, setCapturing] = useState(false);\n const [shot, setShot] = useState<{ readonly image: HTMLCanvasElement; readonly fileName: string } | null>(null);\n const [notice, setNotice] = useState<Notice | null>(null);\n const [, setFrame] = useState(0);\n\n useEffect(() => {\n persist(\n storageKey,\n items.map((item) => item.annotation),\n );\n }, [items, storageKey]);\n\n // Event listeners read live state through refs, so typing does not re-subscribe them.\n const draftRef = useRef<Draft | null>(null);\n const groupRef = useRef<readonly Element[]>([]);\n const shotOpenRef = useRef(false);\n useEffect(() => {\n draftRef.current = draft;\n groupRef.current = group;\n shotOpenRef.current = shot !== null || capturing;\n });\n\n const startDraft = useCallback(\n (selection: Selection) => {\n // Never throw away words already typed for something else.\n if (draftRef.current !== null && draftRef.current.comment.trim() !== '') return;\n const several = selection.elements.length > 1;\n const captures = Promise.all(\n selection.elements.map((element) =>\n captureElement(element, resolveFrames, { dataComponents: several ? 1 : 2, redactor }),\n ),\n );\n const screened =\n selection.selectedText === undefined ? {} : { selectedText: truncate(redactor.text(selection.selectedText), 500) };\n setDraft({ ...selection, ...screened, captures, comment: '', redacted: redactor.enabled, editingId: null });\n },\n [resolveFrames, redactor],\n );\n\n // Comment mode. Listeners sit on window in the CAPTURE phase, ahead of React's root\n // listeners. Alt held down lets an interaction through: open a menu, then comment in it.\n useEffect(() => {\n if (!active) return undefined;\n let dragStart: { readonly x: number; readonly y: number } | null = null;\n // The click that ends a text selection or an area drag is not also an element click.\n let swallowNextClick = false;\n\n const ignored = (event: Event): boolean =>\n (event as MouseEvent).altKey || (event.target instanceof Element && event.target.closest(OWN_SELECTOR) !== null);\n const isolate = (event: Event): void => {\n if (ignored(event)) return;\n event.stopPropagation();\n event.stopImmediatePropagation();\n };\n const onMouseDown = (event: MouseEvent): void => {\n if (ignored(event)) return;\n isolate(event);\n if (event.shiftKey) {\n event.preventDefault(); // no text selection while dragging an area\n dragStart = { x: event.clientX, y: event.clientY };\n setDragBox({ x: event.clientX, y: event.clientY, width: 0, height: 0 });\n }\n };\n const onMouseUp = (event: MouseEvent): void => {\n if (ignored(event)) return;\n isolate(event);\n if (dragStart !== null) {\n const area = rectBetween(dragStart, { x: event.clientX, y: event.clientY });\n dragStart = null;\n setDragBox(null);\n if (area.width >= MIN_AREA && area.height >= MIN_AREA) {\n swallowNextClick = true;\n const { container, inside } = elementsInArea(document, area);\n const origin = container.getBoundingClientRect();\n startDraft({\n kind: 'area',\n elements: [container, ...inside],\n label: `Area ${area.width}×${area.height}`,\n area,\n areaInContainer: { ...area, x: area.x - origin.left, y: area.y - origin.top },\n });\n }\n return;\n }\n const text = selectedText();\n if (text !== null) {\n swallowNextClick = true;\n startDraft({ kind: 'text', elements: [text.element], label: `Text · ${hoverLabel(text.element)}`, selectedText: text.text });\n }\n };\n const onClick = (event: MouseEvent): void => {\n if (ignored(event) || !(event.target instanceof Element)) return;\n event.preventDefault();\n isolate(event);\n if (swallowNextClick) {\n swallowNextClick = false;\n return;\n }\n const element = pickTarget(event.target);\n if (event.metaKey || event.ctrlKey) {\n setGroup((current) =>\n current.includes(element) ? current.filter((kept) => kept !== element) : [...current, element],\n );\n return;\n }\n startDraft({ kind: 'element', elements: [element], label: hoverLabel(element) });\n };\n // Releasing Cmd/Ctrl closes the group and opens one editor for all of it.\n const onKeyUp = (event: KeyboardEvent): void => {\n if (event.key !== 'Meta' && event.key !== 'Control') return;\n const elements = groupRef.current;\n if (elements.length === 0) return;\n setGroup([]);\n const [only] = elements;\n if (elements.length === 1 && only !== undefined) {\n startDraft({ kind: 'element', elements: [only], label: hoverLabel(only) });\n } else {\n startDraft({ kind: 'group', elements, label: `${elements.length} element` });\n }\n };\n const onMove = (event: PointerEvent): void => {\n if (dragStart !== null) {\n setDragBox(rectBetween(dragStart, { x: event.clientX, y: event.clientY }));\n return;\n }\n if (!(event.target instanceof Element) || event.target.closest(OWN_SELECTOR) !== null) {\n setHover(null);\n return;\n }\n const element = pickTarget(event.target);\n setHover((current) => (current?.element === element ? current : { element, label: hoverLabel(element) }));\n };\n\n for (const type of ISOLATED) {\n if (type !== 'mousedown' && type !== 'mouseup') window.addEventListener(type, isolate, true);\n }\n window.addEventListener('mousedown', onMouseDown, true);\n window.addEventListener('mouseup', onMouseUp, true);\n window.addEventListener('click', onClick, true);\n window.addEventListener('pointermove', onMove, true);\n window.addEventListener('keyup', onKeyUp, true);\n const root = document.documentElement;\n const previousCursor = root.style.cursor;\n root.style.cursor = 'crosshair';\n return () => {\n for (const type of ISOLATED) window.removeEventListener(type, isolate, true);\n window.removeEventListener('mousedown', onMouseDown, true);\n window.removeEventListener('mouseup', onMouseUp, true);\n window.removeEventListener('click', onClick, true);\n window.removeEventListener('pointermove', onMove, true);\n window.removeEventListener('keyup', onKeyUp, true);\n root.style.cursor = previousCursor;\n setHover(null);\n setGroup([]);\n setDragBox(null);\n };\n }, [active, startDraft]);\n\n // Alt+Shift+C toggles comment mode anywhere. Esc closes the editor, then drops a group\n // in progress, then leaves the mode. `code`, not `key`: on macOS Alt turns C into \"Ç\".\n useEffect(() => {\n const onKey = (event: KeyboardEvent): void => {\n // The screenshot editor owns the keyboard while it is open.\n if (shotOpenRef.current) return;\n if (event.altKey && event.shiftKey && event.code === 'KeyC') {\n event.preventDefault();\n setActive((value) => !value);\n } else if (event.key === 'Escape') {\n if (draftRef.current !== null) setDraft(null);\n else if (groupRef.current.length > 0) setGroup([]);\n else setActive(false);\n }\n };\n window.addEventListener('keydown', onKey, true);\n return () => window.removeEventListener('keydown', onKey, true);\n }, []);\n\n useEffect(() => (paused ? pauseMotion(document) : undefined), [paused]);\n\n useEffect(() => {\n if (notice === null) return undefined;\n const timer = window.setTimeout(() => setNotice(null), NOTICE_MS);\n return () => window.clearTimeout(timer);\n }, [notice]);\n\n // Keep highlights and pins on their elements through scrolling, resizing and layout\n // changes. Only while there is something on screen to keep in place.\n const tracking = active || draft !== null || items.length > 0;\n useEffect(() => {\n if (!tracking) return undefined;\n const bump = (): void => setFrame((frame) => frame + 1);\n window.addEventListener('scroll', bump, true);\n window.addEventListener('resize', bump);\n const timer = window.setInterval(bump, REFLOW_MS);\n return () => {\n window.removeEventListener('scroll', bump, true);\n window.removeEventListener('resize', bump);\n window.clearInterval(timer);\n };\n }, [tracking]);\n\n const saveDraft = async (): Promise<void> => {\n if (draft === null || draft.comment.trim() === '') return;\n const { comment, editingId } = draft;\n setDraft(null);\n window.getSelection()?.removeAllRanges();\n if (editingId !== null) {\n setItems((current) =>\n current.map((item) =>\n item.annotation.id === editingId ? { ...item, annotation: { ...item.annotation, comment } } : item,\n ),\n );\n return;\n }\n const targets = await draft.captures;\n const annotation: Annotation = {\n id: newId(),\n kind: draft.kind,\n comment,\n createdAt: new Date().toISOString(),\n targets,\n ...(draft.selectedText === undefined ? {} : { selectedText: draft.selectedText }),\n ...(draft.area === undefined ? {} : { area: draft.area }),\n ...(draft.areaInContainer === undefined ? {} : { areaInContainer: draft.areaInContainer }),\n ...(draft.redacted ? {} : { redacted: false }),\n };\n setItems((current) => [...current, { annotation, elements: draft.elements }]);\n setPanelOpen(true);\n };\n\n const editItem = (id: string): void => {\n const item = items.find((candidate) => candidate.annotation.id === id);\n if (item === undefined) return;\n const { annotation } = item;\n const first = annotation.targets[0];\n const element = liveElement(item);\n const area = element === null ? null : liveArea(item, element);\n setDraft({\n kind: annotation.kind,\n ...(area === null ? {} : { area }),\n elements: element === null ? [] : [element],\n label: first?.components[0]?.name ?? first?.element.tag ?? annotation.kind,\n ...(annotation.selectedText === undefined ? {} : { selectedText: annotation.selectedText }),\n captures: Promise.resolve(annotation.targets),\n comment: annotation.comment,\n redacted: annotation.redacted !== false,\n editingId: id,\n });\n };\n\n const copyPrompt = async (): Promise<void> => {\n const prompt = buildPrompt(\n items.map((item) => item.annotation),\n { appName, appDir, includeData, now: new Date() },\n );\n await writeClipboard(prompt);\n const count = items.length;\n setNotice({\n title: 'Prompt copied — ready for your coding agent',\n detail: `Paste it into Claude Code, Codex or Cursor. It gives the file, line and component behind ${count === 1 ? 'your comment' : `each of your ${count} comments`}.`,\n });\n };\n\n const takeScreenshot = async (): Promise<void> => {\n setDraft(null);\n setPanelOpen(false);\n setNotice(null);\n try {\n const image = await (props.captureScreen ?? captureTab)(async () => {\n setCapturing(true);\n // Two frames for React to commit and the browser to paint, then a beat for the\n // \"sharing this tab\" bar, which can resize the viewport, to settle.\n await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));\n await new Promise<void>((resolve) => window.setTimeout(resolve, 300));\n });\n setShot({ image, fileName: shotFileName(appName, window.location.pathname, new Date()) });\n } catch (error) {\n setNotice(\n error instanceof CaptureCancelled\n ? { title: 'Screenshot cancelled', detail: 'Choose \"This tab\" and Allow when the browser asks.', tone: 'error' }\n : { title: 'Could not take the screenshot', detail: error instanceof Error ? error.message : String(error), tone: 'error' },\n );\n } finally {\n setCapturing(false);\n }\n };\n\n const toggleComments = (): void => {\n setShowComments(!showComments);\n writeFlag(SHOW_COMMENTS_KEY, !showComments);\n };\n\n const entries: ListEntry[] = items.map((item, index) => {\n const { annotation } = item;\n const first = annotation.targets[0];\n const kind = KIND_LABEL[annotation.kind](annotation.targets.length);\n const component = first?.components[0]?.name;\n const what = kind || `${component ? `${component} · ` : ''}${first?.element.tag ?? ''}`;\n return {\n id: annotation.id,\n number: index + 1,\n comment: annotation.comment,\n where: `${first?.page.pathname ?? ''} · ${what}`,\n onThisPage: liveElement(item) !== null,\n };\n });\n\n const hideHint = (hidden: boolean): void => {\n setHintHidden(hidden);\n writeFlag(HINT_HIDDEN_KEY, hidden);\n };\n\n const draftElement = draft?.elements[0];\n const draftBox = draftElement?.isConnected ? boxOf(draftElement) : null;\n const onScreen = items.flatMap((item, index): CalloutTarget[] => {\n const element = liveElement(item);\n if (element === null) return [];\n const area = liveArea(item, element);\n return [\n area === null\n ? { number: index + 1, comment: item.annotation.comment, box: boxOf(element) }\n : { number: index + 1, comment: item.annotation.comment, box: areaBox(area), area: true },\n ];\n });\n const callouts =\n showComments || capturing ? layoutCallouts(onScreen, { width: window.innerWidth, height: window.innerHeight }) : null;\n const editNumber = (number: number): void => {\n const item = items[number - 1];\n if (item !== undefined) editItem(item.annotation.id);\n };\n\n // While capturing, the page shows the comments and nothing else of the tool.\n const overlay = capturing ? (\n <div data-dev-annotator=\"\">\n <Callouts callouts={callouts ?? []} onEdit={null} />\n </div>\n ) : (\n <div data-dev-annotator=\"\">\n {active && !hintHidden ? <Hint onDismiss={() => hideHint(true)} /> : null}\n {active && hover !== null && hover.element !== draftElement && dragBox === null ? (\n <Highlight box={boxOf(hover.element)} label={hover.label} strong={false} />\n ) : null}\n {group.map((element, index) => (\n <Highlight key={index} box={boxOf(element)} label={`#${index + 1}`} strong />\n ))}\n {dragBox !== null ? <AreaBox box={{ top: dragBox.y, left: dragBox.x, width: dragBox.width, height: dragBox.height }} /> : null}\n {draft?.area !== undefined ? (\n <AreaBox box={{ top: draft.area.y, left: draft.area.x, width: draft.area.width, height: draft.area.height }} />\n ) : null}\n {draft !== null && draft.kind !== 'area'\n ? draft.elements\n .filter((element) => element.isConnected)\n .map((element, index) => (\n <Highlight key={index} box={boxOf(element)} label={index === 0 ? draft.label : `#${index + 1}`} strong />\n ))\n : null}\n {callouts !== null ? (\n <Callouts callouts={callouts} onEdit={editNumber} />\n ) : (\n onScreen.map((target) => (\n <Pin key={target.number} box={target.box} number={target.number} onClick={() => editNumber(target.number)} />\n ))\n )}\n {draft !== null ? (\n <Editor\n anchor={draft.area === undefined ? draftBox : areaBox(draft.area)}\n title={draft.editingId === null ? draft.label : `Edit comment · ${draft.label}`}\n comment={draft.comment}\n editing={draft.editingId !== null}\n onChange={(comment) => setDraft((current) => (current === null ? null : { ...current, comment }))}\n onSave={() => void saveDraft()}\n onCancel={() => setDraft(null)}\n onDelete={() => {\n const id = draft.editingId;\n setDraft(null);\n setItems((current) => current.filter((item) => item.annotation.id !== id));\n }}\n />\n ) : null}\n {settingsOpen && !collapsed ? (\n <RedactionPanel\n settings={redaction}\n customised={savedRedaction !== null}\n onChange={(next) => {\n setSavedRedaction(next);\n writeRedaction(redactionKey, next);\n }}\n onReset={() => {\n setSavedRedaction(null);\n writeRedaction(redactionKey, null);\n }}\n onClose={() => setSettingsOpen(false)}\n />\n ) : null}\n {panelOpen && !settingsOpen && !collapsed && items.length > 0 ? (\n <Panel\n entries={entries}\n includeData={includeData}\n redactionOn={redaction.enabled}\n onIncludeData={setIncludeData}\n onEdit={editItem}\n onClear={() => {\n setDraft(null);\n setItems([]);\n }}\n onClose={() => setPanelOpen(false)}\n />\n ) : null}\n <Toolbar\n active={active}\n paused={paused}\n count={items.length}\n panelOpen={panelOpen}\n showComments={showComments}\n capturing={capturing}\n collapsed={collapsed}\n redactionOn={redaction.enabled}\n settingsOpen={settingsOpen}\n onToggleSettings={() => setSettingsOpen(!settingsOpen)}\n onToggleCollapsed={() => {\n setCollapsed(!collapsed);\n writeFlag(COLLAPSED_KEY, !collapsed);\n }}\n onShowHint={active && hintHidden ? () => hideHint(false) : null}\n onToggleActive={() => setActive((value) => !value)}\n onTogglePaused={() => setPaused((value) => !value)}\n onToggleComments={toggleComments}\n onScreenshot={() => void takeScreenshot()}\n onTogglePanel={() => setPanelOpen((value) => !value)}\n onCopy={() => void copyPrompt()}\n />\n {notice !== null ? <Toast notice={notice} onDismiss={() => setNotice(null)} /> : null}\n {shot !== null ? (\n <ScreenshotEditor image={shot.image} fileName={shot.fileName} onClose={() => setShot(null)} onNotice={setNotice} />\n ) : null}\n </div>\n );\n return createPortal(overlay, document.body);\n}\n\n/** Inside an inline SVG icon, the icon is the thing being pointed at, not one of its paths. */\nfunction pickTarget(target: Element): Element {\n if (target instanceof SVGElement && !(target instanceof SVGSVGElement)) return target.closest('svg') ?? target;\n return target;\n}\n\nfunction rectBetween(a: { readonly x: number; readonly y: number }, b: { readonly x: number; readonly y: number }): Rect {\n return { x: Math.min(a.x, b.x), y: Math.min(a.y, b.y), width: Math.abs(a.x - b.x), height: Math.abs(a.y - b.y) };\n}\n\nfunction areaBox(area: Rect): { top: number; left: number; width: number; height: number } {\n return { top: area.y, left: area.x, width: area.width, height: area.height };\n}\n\n/** The page's current text selection and the element holding it; `null` if none. Screened by `startDraft`. */\nfunction selectedText(): { readonly element: Element; readonly text: string } | null {\n const selection = window.getSelection();\n if (selection === null || selection.isCollapsed || selection.rangeCount === 0) return null;\n const text = selection.toString().replace(/\\s+/g, ' ').trim();\n if (text === '') return null;\n const node = selection.getRangeAt(0).commonAncestorContainer;\n const element = node instanceof Element ? node : node.parentElement;\n if (element === null || element.closest(OWN_SELECTOR) !== null) return null;\n return { element, text };\n}\n\n/** Where a dragged area is now, in viewport pixels: it rides on its container. */\nfunction liveArea(item: Item, container: Element): Rect | null {\n const offset = item.annotation.areaInContainer;\n if (item.annotation.kind !== 'area' || offset === undefined) return null;\n const origin = container.getBoundingClientRect();\n return { x: origin.left + offset.x, y: origin.top + offset.y, width: offset.width, height: offset.height };\n}\n\n/**\n * The first commented element if it is on screen now, and only on the page the comment\n * was made on: the one clicked while it stays mounted, else — after a reload or a\n * navigation back — the selector's match. An element that outlives the page (a layout's\n * `<main>`, a shared header) must not carry the comment onto the next one.\n */\nfunction liveElement(item: Item): Element | null {\n const first = item.annotation.targets[0];\n if (first === undefined || window.location.pathname !== first.page.pathname) return null;\n const [element] = item.elements;\n if (element?.isConnected) return element;\n try {\n return document.querySelector(first.element.selector);\n } catch {\n return null;\n }\n}\n\nfunction newId(): string {\n return typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n\n/**\n * sessionStorage can be absent or throw (private mode, blocked storage); comments then\n * live in memory. Entries of an older shape are dropped rather than half-read.\n */\nfunction restore(key: string): Item[] {\n try {\n const raw = window.sessionStorage.getItem(key);\n const parsed: unknown = raw === null ? [] : JSON.parse(raw);\n if (!Array.isArray(parsed)) return [];\n return (parsed as Annotation[])\n .filter((annotation) => Array.isArray(annotation?.targets) && annotation.targets.length > 0)\n .map((annotation) => ({ annotation, elements: [] }));\n } catch {\n return [];\n }\n}\n\nfunction persist(key: string, annotations: readonly Annotation[]): void {\n try {\n if (annotations.length === 0) window.sessionStorage.removeItem(key);\n else window.sessionStorage.setItem(key, JSON.stringify(annotations));\n } catch {\n // Memory only; nothing to report.\n }\n}\n\nasync function writeClipboard(text: string): Promise<void> {\n try {\n await navigator.clipboard.writeText(text);\n return;\n } catch {\n // Not a secure context, or permission refused: fall back to the selection API.\n }\n const area = document.createElement('textarea');\n area.value = text;\n area.setAttribute('data-dev-annotator', '');\n area.style.position = 'fixed';\n area.style.opacity = '0';\n document.body.appendChild(area);\n area.select();\n document.execCommand('copy');\n area.remove();\n}\n","/**\n * What counts as personal data, and the switch that turns screening off. The prompt is\n * pasted into an AI agent, so whatever gets through leaves the machine: a dev database can\n * still hold a copy of real customer data.\n *\n * Two independent screens:\n * - by KEY: a property whose name says it holds personal data or a secret is replaced\n * whole, whatever its value;\n * - by VALUE: inside every string, an e-mail address, the number formats of the selected\n * countries and the user's own patterns are replaced where they stand, so text that\n * merely mentions one (an element's label, a free-text note) is screened too.\n *\n * Amounts survive on purpose: they are what a UI bug is usually about. Every built-in\n * number pattern needs a shape no money figure has (a leading 0 or country code, a\n * separator, letters around the digits).\n */\n\nexport const REDACTED = '[redacted]';\n\nexport type RedactionCountry = 'vn' | 'us' | 'sg';\n\nexport interface RedactionSettings {\n /** Off: props, state and page text go into the prompt as they are. */\n readonly enabled: boolean;\n /** Whose phone and ID formats are screened by value; e-mail addresses always are. */\n readonly countries: readonly RedactionCountry[];\n /**\n * Extra value patterns, as regular expression sources (`INV-\\d{6}`) or literals with\n * flags (`/acct[0-9]+/i`). Every match is replaced; blank and invalid lines are skipped.\n */\n readonly patterns: readonly string[];\n}\n\n/** What `DevAnnotator`'s `redaction` prop takes: any field left out keeps its default. */\nexport interface RedactionOptions {\n readonly enabled?: boolean;\n readonly countries?: readonly RedactionCountry[];\n readonly patterns?: ReadonlyArray<string | RegExp>;\n}\n\ninterface CountryRules {\n readonly label: string;\n /** What the country's patterns catch, for the settings panel. */\n readonly covers: string;\n /** Extra key fragments, matched like the shared ones. */\n readonly keys: readonly RegExp[];\n readonly values: readonly RegExp[];\n}\n\nexport const COUNTRY_RULES: Readonly<Record<RedactionCountry, CountryRules>> = {\n vn: {\n label: 'Vietnam',\n covers: 'phone numbers, 12-digit citizen IDs (CCCD)',\n keys: [/cccd|cmnd|zalo/],\n values: [\n // +84 or 0, then 9–10 digits, optionally grouped by spaces or dots.\n /(?<!\\d)(?:\\+?84|0)(?:[\\s.]?\\d){9,10}(?!\\d)/g,\n // CCCD: 12 digits, starting with the 0 of a province code.\n /(?<!\\d)0\\d{11}(?!\\d)/g,\n ],\n },\n us: {\n label: 'United States',\n covers: 'phone numbers, Social Security numbers written with dashes',\n // `ssn` only at either end of the key: in the middle it is \"claSSName\".\n keys: [/^ssn|ssn$|socialsecurity/],\n values: [\n // SSN with its dashes, minus the ranges never issued.\n /(?<!\\d)(?!000|666|9\\d\\d)\\d{3}-(?!00)\\d{2}-(?!0000)\\d{4}(?!\\d)/g,\n // NANP: optional +1, area code and exchange each starting 2–9, then 4 digits.\n /(?<![\\d+])(?:\\+1[\\s.-]?)?(?:\\([2-9]\\d{2}\\)\\s?|[2-9]\\d{2}[\\s.-]?)[2-9]\\d{2}[\\s.-]?\\d{4}(?!\\d)/g,\n ],\n },\n sg: {\n label: 'Singapore',\n covers: 'phone numbers with +65 or a space or dash, NRIC/FIN numbers',\n keys: [/nric/],\n values: [\n /\\b[STFGM]\\d{7}[A-Z]\\b/g,\n // 8 digits starting 3, 6, 8 or 9: with +65, or split 4-4, so a bare amount survives.\n /(?<!\\d)(?:\\+65[\\s-]?[3689]\\d{3}[\\s-]?\\d{4}|[3689]\\d{3}[\\s-]\\d{4})(?!\\d)/g,\n ],\n },\n};\n\nexport const COUNTRIES = Object.keys(COUNTRY_RULES) as RedactionCountry[];\n\nexport const DEFAULT_REDACTION: RedactionSettings = { enabled: true, countries: ['vn'], patterns: [] };\n\n/** Matched against the key lower-cased with `_`, `-` and spaces removed. */\nconst SHARED_KEY =\n /(nationalid|citizenid|identitynumber|idnumber|idcard|passport|phone|mobile|msisdn|email|fullname|(debtor|borrower|customer|guarantor|contact|person|holder|relative|spouse|recipient|payer)name|address|dob|dateofbirth|birthday|birthdate|bankaccount|accountnumber|cardnumber|password|passwd|secret|token|otp|apikey|authorization|cookie|signature)/;\n\nconst EMAIL = /[^\\s@<>()[\\]\"']+@[^\\s@<>()[\\]\"']+\\.[a-z]{2,}/gi;\n\n/** Screens one capture: applied to every key and string the prompt will carry. */\nexport interface Redactor {\n readonly enabled: boolean;\n /** Whether a property of this name is replaced whole. */\n readonly isPiiKey: (key: string) => boolean;\n /** The text with every personal-data match replaced. */\n readonly text: (text: string) => string;\n}\n\nexport function createRedactor(settings: RedactionSettings): Redactor {\n if (!settings.enabled) return { enabled: false, isPiiKey: () => false, text: (text) => text };\n const rules = settings.countries.map((country) => COUNTRY_RULES[country]);\n const keys = [SHARED_KEY, ...rules.flatMap((rule) => rule.keys)];\n const values = [\n EMAIL,\n ...rules.flatMap((rule) => rule.values),\n ...settings.patterns\n .filter((source) => source.trim() !== '')\n .map((source) => compilePattern(source))\n .filter((pattern) => pattern instanceof RegExp),\n ];\n return {\n enabled: true,\n isPiiKey: (key) => {\n const normalised = key.toLowerCase().replace(/[\\s_-]/g, '');\n return keys.some((pattern) => pattern.test(normalised));\n },\n text: (text) => values.reduce((out, pattern) => out.replace(pattern, REDACTED), text),\n };\n}\n\nexport const DEFAULT_REDACTOR = createRedactor(DEFAULT_REDACTION);\n\n/**\n * A user pattern as a global RegExp, or the reason it cannot be one. `/source/flags`\n * keeps its flags; anything else is a bare source. A pattern that matches the empty\n * string would put `[redacted]` between every character, so it is refused.\n */\nexport function compilePattern(source: string): RegExp | string {\n const literal = /^\\/(.+)\\/([a-z]*)$/s.exec(source);\n const body = literal?.[1] ?? source;\n const flags = new Set(literal?.[2] ?? '');\n flags.add('g');\n let pattern: RegExp;\n try {\n pattern = new RegExp(body, [...flags].join(''));\n } catch (error) {\n return error instanceof Error ? error.message : 'Invalid pattern';\n }\n if (pattern.test('')) return 'Matches empty text';\n pattern.lastIndex = 0;\n return pattern;\n}\n\n/** Defaults filled in, RegExps turned into the `/source/flags` text the panel edits. */\nexport function resolveRedaction(options: RedactionOptions | undefined): RedactionSettings {\n return {\n enabled: options?.enabled ?? DEFAULT_REDACTION.enabled,\n countries: (options?.countries ?? DEFAULT_REDACTION.countries).filter((country) => country in COUNTRY_RULES),\n patterns: (options?.patterns ?? DEFAULT_REDACTION.patterns).map((pattern) =>\n typeof pattern === 'string' ? pattern : `/${pattern.source}/${pattern.flags.replace('g', '')}`,\n ),\n };\n}\n\n/** Settings saved in this browser, or `null` when there are none or they are unreadable. */\nexport function readRedaction(key: string): RedactionSettings | null {\n try {\n const raw = window.localStorage.getItem(key);\n if (raw === null) return null;\n const value = JSON.parse(raw) as Partial<Record<keyof RedactionSettings, unknown>>;\n if (typeof value.enabled !== 'boolean' || !Array.isArray(value.countries) || !Array.isArray(value.patterns)) return null;\n return {\n enabled: value.enabled,\n countries: value.countries.filter((country): country is RedactionCountry => typeof country === 'string' && country in COUNTRY_RULES),\n patterns: value.patterns.filter((pattern): pattern is string => typeof pattern === 'string'),\n };\n } catch {\n return null;\n }\n}\n\n/** `null` forgets the saved settings, so the app's defaults apply again. */\nexport function writeRedaction(key: string, settings: RedactionSettings | null): void {\n try {\n if (settings === null) window.localStorage.removeItem(key);\n else window.localStorage.setItem(key, JSON.stringify(settings));\n } catch {\n // The settings last until reload; nothing to report.\n }\n}\n","import { DEFAULT_REDACTOR, REDACTED, type Redactor } from './redaction';\n\n/**\n * Turns live React props and state into a small JSON-safe value for the prompt, screened\n * for personal data by the given `Redactor` (see `redaction.ts`).\n */\n\nexport interface SerializeLimits {\n /** Nesting levels below the root before an object collapses to a summary. */\n readonly depth: number;\n /** Properties kept per object. */\n readonly keys: number;\n /** Items kept per array, Map or Set. */\n readonly items: number;\n /** Characters kept per string. */\n readonly string: number;\n}\n\nexport const DEFAULT_LIMITS: SerializeLimits = { depth: 4, keys: 25, items: 5, string: 160 };\n\n/** Props React adds or that only repeat the tree; noise in a prompt. */\nconst SKIPPED_KEYS = new Set(['children', 'ref', 'key', '$$typeof', '_owner', '_store']);\n\nconst REACT_ELEMENT_TYPES = new Set([Symbol.for('react.transitional.element'), Symbol.for('react.element')]);\n\nexport type Snapshot = null | boolean | number | string | readonly Snapshot[] | { readonly [key: string]: Snapshot };\n\nexport function toSnapshot(\n value: unknown,\n limits: SerializeLimits = DEFAULT_LIMITS,\n redactor: Redactor = DEFAULT_REDACTOR,\n): Snapshot {\n return walk(value, 0, { limits, redactor }, new Set());\n}\n\ninterface Walk {\n readonly limits: SerializeLimits;\n readonly redactor: Redactor;\n}\n\nfunction walk(value: unknown, depth: number, walker: Walk, path: Set<object>): Snapshot {\n const { limits, redactor } = walker;\n switch (typeof value) {\n case 'undefined':\n return '<undefined>';\n case 'boolean':\n return value;\n case 'number':\n return Number.isFinite(value) ? value : String(value);\n case 'bigint':\n return `${value}n`;\n case 'string':\n return truncate(redactor.text(value), limits.string);\n case 'symbol':\n return value.toString();\n case 'function':\n return `ƒ ${value.name || 'anonymous'}()`;\n default:\n break;\n }\n if (value === null) return null;\n const object = value as object;\n if (path.has(object)) return '<circular>';\n const summary = summarise(object, redactor);\n if (summary !== null) return summary;\n\n path.add(object);\n try {\n if (Array.isArray(object)) return walkList(object, object.length, depth, walker, path);\n if (object instanceof Set) return { '<Set>': walkList([...object], object.size, depth, walker, path) };\n if (object instanceof Map) {\n if (depth >= limits.depth) return `<Map(${object.size})>`;\n const entries: Record<string, Snapshot> = {};\n let kept = 0;\n for (const [key, entry] of object) {\n if (kept === limits.items) {\n entries['…'] = `+${object.size - kept}`;\n break;\n }\n const name = typeof key === 'string' ? key : String(walk(key, limits.depth, walker, path));\n entries[name] = redactor.isPiiKey(name) ? redactWhole(entry) : walk(entry, depth + 1, walker, path);\n kept += 1;\n }\n return { '<Map>': entries };\n }\n return walkObject(object as Record<string, unknown>, depth, walker, path);\n } finally {\n path.delete(object);\n }\n}\n\nfunction walkList(\n items: readonly unknown[],\n size: number,\n depth: number,\n walker: Walk,\n path: Set<object>,\n): Snapshot {\n const { limits } = walker;\n if (depth >= limits.depth) return `<Array(${size})>`;\n const kept = items.slice(0, limits.items).map((item) => walk(item, depth + 1, walker, path));\n return size > limits.items ? [...kept, `… +${size - limits.items}`] : kept;\n}\n\nfunction walkObject(\n object: Record<string, unknown>,\n depth: number,\n walker: Walk,\n path: Set<object>,\n): Snapshot {\n const { limits, redactor } = walker;\n const keys = Object.keys(object).filter((key) => !SKIPPED_KEYS.has(key) && !key.startsWith('__react'));\n if (depth >= limits.depth) return keys.length === 0 ? {} : `{…${keys.length} keys}`;\n const out: Record<string, Snapshot> = {};\n for (const key of keys.slice(0, limits.keys)) {\n let entry: unknown;\n try {\n entry = object[key];\n } catch {\n out[key] = '<getter threw>';\n continue;\n }\n out[key] = redactor.isPiiKey(key) ? redactWhole(entry) : walk(entry, depth + 1, walker, path);\n }\n if (keys.length > limits.keys) out['…'] = `+${keys.length - limits.keys} keys`;\n return out;\n}\n\n/**\n * A PII key's value is replaced whole, except an EMPTY one: \"the phone is missing\" is a\n * fact worth seeing when the bug is a blank field, and it discloses nothing.\n */\nfunction redactWhole(value: unknown): Snapshot {\n if (value === null) return null;\n if (value === undefined) return '<undefined>';\n if (value === '') return '';\n return REDACTED;\n}\n\n/** A one-line stand-in for values whose insides would only be noise, or `null` to walk it. */\nfunction summarise(object: object, redactor: Redactor): string | null {\n if (REACT_ELEMENT_TYPES.has((object as { $$typeof?: symbol }).$$typeof as symbol)) {\n return `<${typeName((object as { type?: unknown }).type)} />`;\n }\n if (object instanceof Date) return Number.isNaN(object.getTime()) ? '<Invalid Date>' : object.toISOString();\n if (object instanceof Error) return `<${object.name}: ${truncate(redactor.text(object.message), 120)}>`;\n if (object instanceof RegExp) return object.toString();\n if (typeof Node !== 'undefined' && object instanceof Node) return `<${nodeLabel(object)}>`;\n if (typeof (object as { then?: unknown }).then === 'function') return '<Promise>';\n if (ArrayBuffer.isView(object)) return `<${object.constructor.name}(${object.byteLength} bytes)>`;\n if (object instanceof ArrayBuffer) return `<ArrayBuffer(${object.byteLength} bytes)>`;\n if (Array.isArray(object) || object instanceof Map || object instanceof Set) return null;\n // A class instance (a query observer, an editor, a client) is machinery, not data:\n // name it and stop. Plain objects — what an API returns — are walked.\n const proto: unknown = Object.getPrototypeOf(object);\n if (proto !== null && proto !== Object.prototype) {\n const name = (object.constructor as { name?: string } | undefined)?.name;\n return `<${name || 'object'}>`;\n }\n return null;\n}\n\nfunction nodeLabel(node: Node): string {\n if (typeof Element !== 'undefined' && node instanceof Element) {\n const id = node.id ? `#${node.id}` : '';\n return `${node.tagName.toLowerCase()}${id}`;\n }\n return node.nodeName.toLowerCase();\n}\n\nexport function typeName(type: unknown): string {\n if (typeof type === 'string') return type;\n if (typeof type === 'function') {\n const fn = type as { displayName?: string; name?: string };\n return fn.displayName || fn.name || 'Anonymous';\n }\n if (typeof type === 'object' && type !== null) {\n const wrapper = type as { displayName?: string; render?: unknown; type?: unknown };\n if (wrapper.displayName) return wrapper.displayName;\n if (wrapper.render !== undefined) return typeName(wrapper.render);\n if (wrapper.type !== undefined) return typeName(wrapper.type);\n }\n return 'Anonymous';\n}\n\nexport function truncate(text: string, max: number): string {\n return text.length <= max ? text : `${text.slice(0, max)}… (+${text.length - max} chars)`;\n}\n","import { DEFAULT_REDACTOR, type Redactor } from './redaction';\nimport { truncate } from './serialize';\n\n/**\n * What an element is to a user, and where on the page it sits, in words an agent can\n * search the source for: the accessible role and name (\"button Save\"), and the labels of\n * the sections enclosing it (\"Debt batches › New batch\"). A selector says WHERE in the DOM; this\n * says which part of the SCREEN, which is how the source is organised.\n */\n\nconst IMPLICIT_ROLES: Readonly<Record<string, string>> = {\n a: 'link',\n article: 'article',\n aside: 'complementary',\n button: 'button',\n dialog: 'dialog',\n form: 'form',\n h1: 'heading',\n h2: 'heading',\n h3: 'heading',\n h4: 'heading',\n h5: 'heading',\n h6: 'heading',\n img: 'img',\n li: 'listitem',\n main: 'main',\n nav: 'navigation',\n ol: 'list',\n option: 'option',\n select: 'combobox',\n table: 'table',\n td: 'cell',\n textarea: 'textbox',\n th: 'columnheader',\n tr: 'row',\n ul: 'list',\n};\n\nconst INPUT_ROLES: Readonly<Record<string, string>> = {\n checkbox: 'checkbox',\n radio: 'radio',\n range: 'slider',\n search: 'searchbox',\n submit: 'button',\n button: 'button',\n number: 'spinbutton',\n};\n\nconst STATES = ['aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-current', 'aria-invalid', 'aria-busy'];\n\nfunction roleOf(element: Element): string | null {\n const explicit = element.getAttribute('role');\n if (explicit) return explicit;\n const tag = element.tagName.toLowerCase();\n if (tag === 'input') return INPUT_ROLES[(element as HTMLInputElement).type] ?? 'textbox';\n if (tag === 'a' && !element.hasAttribute('href')) return null;\n return IMPLICIT_ROLES[tag] ?? null;\n}\n\nfunction textOfIds(element: Element, ids: string): string {\n return ids\n .split(/\\s+/)\n .map((id) => visibleText(element.ownerDocument.getElementById(id)))\n .join(' ');\n}\n\nfunction accessibleName(element: Element): string {\n const label = element.getAttribute('aria-label');\n if (label) return label;\n const labelledBy = element.getAttribute('aria-labelledby');\n if (labelledBy) return textOfIds(element, labelledBy);\n const labels = (element as HTMLInputElement).labels;\n if (labels && labels.length > 0) return Array.from(labels, (node) => visibleText(node)).join(' ');\n return element.getAttribute('alt') ?? element.getAttribute('title') ?? visibleText(element);\n}\n\nfunction clean(text: string, max: number, redactor: Redactor): string {\n return truncate(redactor.text(text.replace(/\\s+/g, ' ').trim()), max);\n}\n\n/** `button \"Save\" (disabled, aria-expanded=false)`, or `null` for an element with no role. */\nexport function describeAccessibility(element: Element, redactor: Redactor = DEFAULT_REDACTOR): string | null {\n const role = roleOf(element);\n if (role === null) return null;\n const name = clean(accessibleName(element), 80, redactor);\n const states: string[] = [];\n if ((element as HTMLButtonElement).disabled === true || element.getAttribute('aria-disabled') === 'true') {\n states.push('disabled');\n }\n for (const state of STATES) {\n const value = element.getAttribute(state);\n if (value !== null) states.push(`${state}=${value}`);\n }\n return `${role}${name ? ` \"${name}\"` : ''}${states.length > 0 ? ` (${states.join(', ')})` : ''}`;\n}\n\nconst SECTIONS = 'section, form, fieldset, dialog, [role=\"dialog\"], table, article, aside, nav, [aria-label], [aria-labelledby]';\nconst SECTION_TITLE = ':scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > legend, :scope > caption, :scope > header h1, :scope > header h2, :scope > header h3, :scope > div > h1, :scope > div > h2, :scope > div > h3';\nconst MAX_SECTIONS = 3;\n\nfunction sectionLabel(section: Element): string | null {\n const label = section.getAttribute('aria-label');\n if (label) return label;\n const labelledBy = section.getAttribute('aria-labelledby');\n if (labelledBy) return textOfIds(section, labelledBy);\n const title = section.querySelector(SECTION_TITLE);\n return title === null ? null : visibleText(title);\n}\n\n/**\n * The page heading, then the labels of up to three enclosing sections, outermost first:\n * `Debt batches › New batch › Source file`. `null` when nothing on the way up is labelled.\n */\nexport function sectionPath(element: Element, redactor: Redactor = DEFAULT_REDACTOR): string | null {\n const labels: string[] = [];\n for (let current = element.parentElement?.closest(SECTIONS) ?? null; current !== null && labels.length < MAX_SECTIONS; current = current.parentElement?.closest(SECTIONS) ?? null) {\n const label = sectionLabel(current);\n if (label) labels.unshift(clean(label, 50, redactor));\n }\n const pageHeading = element.ownerDocument.querySelector('h1');\n if (pageHeading && !pageHeading.contains(element)) {\n const heading = clean(visibleText(pageHeading), 50, redactor);\n if (heading && labels[0] !== heading) labels.unshift(heading);\n }\n const path = labels.filter((label) => label !== '');\n return path.length === 0 ? null : path.join(' › ');\n}\n\n/** The text just before and after the element, which tells two identical buttons apart. */\nexport function nearbyText(element: Element, redactor: Redactor = DEFAULT_REDACTOR): string | null {\n const before = visibleText(element.previousElementSibling);\n const after = visibleText(element.nextElementSibling);\n const parts = [clean(before, 60, redactor), clean(after, 60, redactor)];\n if (parts[0] === '' && parts[1] === '') return null;\n return `before: \"${parts[0]}\" · after: \"${parts[1]}\"`;\n}\n\n/**\n * Text as the page shows it: `innerText` keeps the breaks between blocks (\"Title\" + \"Body\",\n * not \"TitleBody\"); `textContent` is the fallback where there is no layout (tests).\n */\nfunction visibleText(node: Element | null | undefined): string {\n if (node === null || node === undefined) return '';\n const raw = node instanceof HTMLElement && typeof node.innerText === 'string' ? node.innerText : node.textContent;\n return (raw ?? '').replace(/\\s+/g, ' ').trim();\n}\n","import { typeName } from './serialize';\n\n/**\n * Reading React's internal fiber tree from a DOM node. None of this is public API; it is\n * the same walk React DevTools does, kept to the fields that have been stable across\n * React 18 and 19. Development builds only: `_debugStack` does not exist in production.\n */\n\nexport interface Fiber {\n readonly tag: number;\n readonly type: unknown;\n readonly elementType: unknown;\n readonly return: Fiber | null;\n readonly memoizedProps: unknown;\n readonly memoizedState: unknown;\n readonly stateNode: unknown;\n readonly _debugStack?: unknown;\n}\n\n/** Fiber tags (react-reconciler `ReactWorkTags`) for things that are components. */\nconst FUNCTION_COMPONENT = 0;\nconst CLASS_COMPONENT = 1;\nconst FORWARD_REF = 11;\nconst MEMO_COMPONENT = 14;\nconst SIMPLE_MEMO_COMPONENT = 15;\nconst COMPONENT_TAGS = new Set([FUNCTION_COMPONENT, CLASS_COMPONENT, FORWARD_REF, MEMO_COMPONENT, SIMPLE_MEMO_COMPONENT]);\n\n/**\n * Framework plumbing between a page and the root. Naming it in the prompt only buries\n * the components the request is about.\n */\nconst FRAMEWORK_COMPONENTS = new Set([\n 'AppDevOverlay',\n 'AppDevOverlayErrorBoundary',\n 'AppRouter',\n 'ClientPageRoot',\n 'ClientSegmentRoot',\n 'DevRootHTTPAccessFallbackBoundary',\n 'ErrorBoundary',\n 'ErrorBoundaryHandler',\n 'GlobalError',\n 'HTTPAccessFallbackBoundary',\n 'HTTPAccessFallbackErrorBoundary',\n 'HandleRedirect',\n 'Head',\n 'HistoryUpdater',\n 'HotReload',\n 'InnerLayoutRouter',\n 'InnerScrollAndFocusHandler',\n 'LayoutRouter',\n 'LoadingBoundary',\n 'MetadataBoundary',\n 'MetadataOutlet',\n 'OuterLayoutRouter',\n 'OutletBoundary',\n 'RedirectBoundary',\n 'RedirectErrorBoundary',\n 'RenderFromTemplateContext',\n 'ReplaySsrOnlyErrors',\n 'Root',\n 'RootErrorBoundary',\n 'Router',\n 'RuntimeStyles',\n 'ScrollAndFocusHandler',\n 'SegmentStateProvider',\n 'SegmentViewNode',\n 'ServerRoot',\n 'ViewportBoundary',\n 'DevAnnotator',\n]);\n\n/** The fiber React attached to this node, or to its nearest ancestor that has one. */\nexport function fiberOf(node: Node): Fiber | null {\n let current: Node | null = node;\n while (current !== null) {\n for (const key of Object.keys(current)) {\n if (key.startsWith('__reactFiber$')) return (current as unknown as Record<string, Fiber>)[key] ?? null;\n }\n current = current.parentNode;\n }\n return null;\n}\n\nexport function isComponent(fiber: Fiber): boolean {\n return COMPONENT_TAGS.has(fiber.tag);\n}\n\nexport function componentName(fiber: Fiber): string {\n return typeName(fiber.elementType ?? fiber.type);\n}\n\n/**\n * The components enclosing the fiber, nearest first, without framework plumbing and\n * without a memo/forwardRef wrapper repeating the component it wraps.\n */\nexport function componentAncestors(fiber: Fiber, limit = 12): Fiber[] {\n const out: Fiber[] = [];\n let previousName: string | null = null;\n for (let current: Fiber | null = fiber; current !== null && out.length < limit; current = current.return) {\n if (!isComponent(current)) continue;\n const name = componentName(current);\n if (FRAMEWORK_COMPONENTS.has(name) || name.startsWith('__next') || name === 'Anonymous' || name === previousName) {\n continue;\n }\n out.push(current);\n previousName = name;\n }\n return out;\n}\n\ninterface HookNode {\n readonly memoizedState: unknown;\n readonly queue: unknown;\n readonly next: HookNode | null;\n}\n\n/**\n * The values of a component's stateful hooks — `useState`, `useReducer`,\n * `useSyncExternalStore` (which is how React Query hands a component its `data`) — in\n * call order. React keeps no hook NAMES; the order matches the order the hooks are\n * called in the component's source. A class component's `this.state` comes back whole.\n */\nexport function componentState(fiber: Fiber): unknown[] {\n if (fiber.tag === CLASS_COMPONENT) {\n return fiber.memoizedState === null || fiber.memoizedState === undefined ? [] : [fiber.memoizedState];\n }\n const values: unknown[] = [];\n let hook = fiber.memoizedState as HookNode | null;\n // A hook list node always carries `next`; anything else is not a hook list.\n while (hook !== null && typeof hook === 'object' && 'next' in hook) {\n if (hook.queue !== null && hook.queue !== undefined) values.push(hook.memoizedState);\n hook = hook.next;\n }\n return values;\n}\n\n/** The stack React captured when this fiber's element was created, if this is a dev build. */\nexport function debugStackOf(fiber: Fiber): string | null {\n const stack = fiber._debugStack;\n if (stack instanceof Error) return stack.stack ?? null;\n return typeof stack === 'string' ? stack : null;\n}\n","import { DEFAULT_REDACTOR, REDACTED, type Redactor } from './redaction';\nimport { truncate } from './serialize';\n\n/** Ancestors climbed before the selector settles for what it has. */\nconst MAX_DEPTH = 6;\n\nconst TEST_ID_ATTRIBUTES = ['data-testid', 'data-test', 'data-qa', 'data-cy', 'data-component'] as const;\n\n/**\n * A CSS selector an agent can paste into `document.querySelector`, or grep for. It\n * anchors on the nearest unique id or test id, which survives a re-render, and falls\n * back to `tag:nth-of-type` steps. Classes are left out on purpose: with Tailwind they\n * are layout, not identity, and change with the very edit being asked for.\n */\nexport function cssSelector(element: Element): string {\n const doc = element.ownerDocument;\n const steps: string[] = [];\n let current: Element | null = element;\n while (current !== null && current !== doc.documentElement && steps.length < MAX_DEPTH) {\n const anchor = uniqueAnchor(current, doc);\n if (anchor !== null) {\n steps.unshift(anchor);\n return steps.join(' > ');\n }\n steps.unshift(positionalStep(current));\n current = current.parentElement;\n }\n return steps.join(' > ');\n}\n\nfunction uniqueAnchor(element: Element, doc: Document): string | null {\n // React `useId` ids (`«r1»`, `:r1:`) change between renders and builds; skip them.\n if (element.id && !/[«:]/.test(element.id)) {\n const selector = `#${escapeCss(element.id)}`;\n if (doc.querySelectorAll(selector).length === 1) return selector;\n }\n for (const attribute of TEST_ID_ATTRIBUTES) {\n const value = element.getAttribute(attribute);\n if (value) {\n const selector = `[${attribute}=\"${value.replace(/\"/g, '\\\\\"')}\"]`;\n if (doc.querySelectorAll(selector).length === 1) return selector;\n }\n }\n return null;\n}\n\nfunction positionalStep(element: Element): string {\n const tag = element.tagName.toLowerCase();\n const parent = element.parentElement;\n if (parent === null) return tag;\n const sameTag = Array.from(parent.children).filter((sibling) => sibling.tagName === element.tagName);\n return sameTag.length === 1 ? tag : `${tag}:nth-of-type(${sameTag.indexOf(element) + 1})`;\n}\n\nfunction escapeCss(value: string): string {\n const native = (globalThis as { CSS?: { escape?: (value: string) => string } }).CSS?.escape;\n return native ? native(value) : value.replace(/([^\\w-])/g, '\\\\$1');\n}\n\n/** The attributes that tell an agent what an element IS, in the order worth reading. */\nconst DESCRIBED_ATTRIBUTES = [\n 'id',\n 'role',\n 'type',\n 'name',\n 'href',\n 'aria-label',\n 'placeholder',\n 'title',\n 'alt',\n ...TEST_ID_ATTRIBUTES,\n] as const;\n\n/** `<button type=\"submit\" aria-label=\"Save\" class=\"…\">`: the opening tag, abridged and screened. */\nexport function describeElement(element: Element, redactor: Redactor = DEFAULT_REDACTOR): string {\n const parts = [element.tagName.toLowerCase()];\n for (const attribute of DESCRIBED_ATTRIBUTES) {\n const value = element.getAttribute(attribute);\n if (value) parts.push(`${attribute}=\"${truncate(redactor.text(value), 60)}\"`);\n }\n const className = element.getAttribute('class');\n if (className) parts.push(`class=\"${truncate(className.trim().replace(/\\s+/g, ' '), 120)}\"`);\n return `<${parts.join(' ')}>`;\n}\n\n/** The element's visible text, whitespace collapsed, screened, cut to `max`. */\nexport function elementText(element: Element, max = 120, redactor: Redactor = DEFAULT_REDACTOR): string {\n // innerText keeps the breaks between blocks (\"Title\" + \"Body\", not \"TitleBody\");\n // textContent is the fallback where there is no layout (tests).\n const raw = element instanceof HTMLElement && typeof element.innerText === 'string' ? element.innerText : element.textContent;\n const text = (raw ?? '').replace(/\\s+/g, ' ').trim();\n return truncate(redactor.text(text), max);\n}\n\n/** The current value of a form control, which `textContent` never shows. */\nexport function controlValue(element: Element, redactor: Redactor = DEFAULT_REDACTOR): string | null {\n if (element instanceof HTMLInputElement) {\n if (element.type === 'password') return REDACTED;\n if (element.type === 'checkbox' || element.type === 'radio') return element.checked ? 'checked' : 'unchecked';\n return truncate(redactor.text(element.value), 120);\n }\n if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {\n return truncate(redactor.text(element.value), 120);\n }\n return null;\n}\n","/**\n * Maps a bundled position back to the source through the chunk's own source map, in the\n * browser. Needed under Turbopack: its dev server traces a client frame only from a\n * `file://` chunk path, and a browser stack holds `http://…/_next/static/chunks/x.js`, so\n * `/__nextjs_original-stack-frames` rejects every client frame. Turbopack serves each\n * chunk's map beside it (`x.js.map`) as an index map — `sections`, each a plain v3 map at an\n * offset — so the lookup is a fetch and a VLQ walk, no dependency.\n */\n\nimport type { RawFrame, SourceLocation } from './stack';\n\ninterface PlainMap {\n readonly sources: readonly string[];\n readonly mappings: string;\n}\n\ninterface Section {\n readonly offset: { readonly line: number; readonly column: number };\n readonly map: PlainMap;\n}\n\ntype SourceMapJson = PlainMap | { readonly sections: readonly Section[] };\n\n/** A position in the original file: 0-based line and column, as source maps store them. */\ninterface Original {\n readonly source: string;\n readonly line: number;\n readonly column: number;\n}\n\nconst BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst DIGIT = new Map([...BASE64].map((char, index) => [char, index]));\n\nfunction decodeVlq(segment: string): number[] {\n const values: number[] = [];\n let value = 0;\n let shift = 0;\n for (const char of segment) {\n const digit = DIGIT.get(char);\n if (digit === undefined) return values;\n value += (digit & 31) << shift;\n if (digit & 32) {\n shift += 5;\n continue;\n }\n values.push(value & 1 ? -(value >> 1) : value >> 1);\n value = 0;\n shift = 0;\n }\n return values;\n}\n\n/** The mapping at or left of `column` on generated `line` (both 0-based). */\nfunction lookupPlain(map: PlainMap, line: number, column: number): Original | null {\n // Source index, line and column carry over from line to line; the generated column does not.\n let source = 0;\n let sourceLine = 0;\n let sourceColumn = 0;\n const lines = map.mappings.split(';');\n for (let current = 0; current <= line && current < lines.length; current++) {\n let generated = 0;\n let best: Original | null = null;\n for (const segment of (lines[current] ?? '').split(',')) {\n if (segment === '') continue;\n const fields = decodeVlq(segment);\n generated += fields[0] ?? 0;\n if (fields.length < 4) continue;\n source += fields[1] ?? 0;\n sourceLine += fields[2] ?? 0;\n sourceColumn += fields[3] ?? 0;\n const name = map.sources[source];\n if (current === line && generated <= column && name !== undefined) {\n best = { source: name, line: sourceLine, column: sourceColumn };\n }\n }\n if (current === line) return best;\n }\n return null;\n}\n\nexport function originalPosition(map: SourceMapJson, line1: number, column1: number): Original | null {\n const line = line1 - 1;\n const column = column1 - 1;\n if (!('sections' in map)) return lookupPlain(map, line, column);\n let hit: Section | undefined;\n for (const section of map.sections) {\n const { offset } = section;\n if (offset.line < line || (offset.line === line && offset.column <= column)) hit = section;\n else break;\n }\n if (hit === undefined) return null;\n const inLine = line - hit.offset.line;\n return lookupPlain(hit.map, inLine, inLine === 0 ? column - hit.offset.column : column);\n}\n\n/** `file:///repo/apps/x/src/a.tsx` → `/repo/apps/x/src/a.tsx`; Turbopack internals → null. */\nfunction sourcePath(source: string): string | null {\n if (source.startsWith('file://')) return decodeURIComponent(source.slice('file://'.length));\n // Served by the dev server: the URL path is the path from the app's root (Vite), or an\n // absolute file outside it behind `/@fs/`.\n if (/^https?:\\/\\//.test(source)) {\n const path = decodeURIComponent(new URL(source).pathname);\n return path.startsWith('/@fs/') ? path.slice('/@fs'.length) : path.replace(/^\\//, '');\n }\n if (/^turbopack:\\/\\/\\/\\[turbopack\\]/.test(source)) return null;\n return source;\n}\n\nconst TIMEOUT_MS = 3000;\n\n/**\n * Resolves frames of scripts served over http(s) by the dev server; anything else, or any\n * failure, is `null` so the caller keeps its own fallback. The map is looked for beside\n * the script (`<url>.map`, Next.js/Turbopack), then through the script's own\n * `sourceMappingURL` (an inline `data:` map in Vite, a relative URL elsewhere). Each\n * script's map is loaded once.\n */\nexport function createSourceMapLookup(\n fetchImpl: typeof fetch,\n): (frame: RawFrame) => Promise<SourceLocation | null> {\n const maps = new Map<string, Promise<SourceMapJson | null>>();\n const load = (url: string): Promise<SourceMapJson | null> => {\n let pending = maps.get(url);\n if (pending === undefined) {\n pending = fetchMap(fetchImpl, `${url.replace(/[?#].*$/, '')}.map`).then(\n (beside) => beside ?? mapFromScript(fetchImpl, url),\n );\n maps.set(url, pending);\n }\n return pending;\n };\n\n return async (frame) => {\n if (!/^https?:\\/\\//.test(frame.file)) return null;\n const map = await load(frame.file.replace(/#.*$/, ''));\n if (map === null) return null;\n const original = originalPosition(map, frame.line1, frame.column1);\n const file = original === null ? null : sourcePath(original.source);\n if (original === null || file === null) return null;\n return {\n file,\n line: original.line + 1,\n column: original.column + 1,\n mapped: true,\n ...(/(?:^|\\/)node_modules\\//.test(file) ? { ignored: true } : {}),\n };\n };\n}\n\nconst MAPPING_URL = /\\/\\/[#@] sourceMappingURL=(\\S+)\\s*$/;\n\n/** The map a script names in its last `sourceMappingURL` comment. */\nasync function mapFromScript(fetchImpl: typeof fetch, url: string): Promise<SourceMapJson | null> {\n const script = await fetchText(fetchImpl, url);\n const tail = script?.slice(-200_000).trimEnd();\n const reference = tail === undefined ? undefined : MAPPING_URL.exec(tail)?.[1];\n if (reference === undefined) return null;\n const inline = /^data:application\\/json(?:;charset=[^;,]+)?;base64,(.*)$/i.exec(reference);\n if (inline?.[1] !== undefined) {\n try {\n const bytes = Uint8Array.from(atob(inline[1]), (char) => char.charCodeAt(0));\n return asSourceMap(JSON.parse(new TextDecoder().decode(bytes)), url);\n } catch {\n return null;\n }\n }\n try {\n return await fetchMap(fetchImpl, new URL(reference, url).href);\n } catch {\n return null;\n }\n}\n\nasync function fetchText(fetchImpl: typeof fetch, url: string): Promise<string | null> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);\n try {\n const response = await fetchImpl(url, { signal: controller.signal });\n return response.ok ? await response.text() : null;\n } catch {\n return null;\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * A plain map's sources, resolved the way consumers do: against its `sourceRoot`, then a\n * still-relative one against the map's own URL (Vite writes `Header.tsx` for\n * `/src/components/Header.tsx`).\n */\nfunction asSourceMap(body: unknown, base?: string): SourceMapJson | null {\n if (typeof body !== 'object' || body === null) return null;\n if ('sections' in body && Array.isArray(body.sections)) return body as SourceMapJson;\n if (!('mappings' in body) || !('sources' in body) || !Array.isArray(body.sources)) return null;\n const root = 'sourceRoot' in body && typeof body.sourceRoot === 'string' ? body.sourceRoot : '';\n const prefix = root === '' || root.endsWith('/') ? root : `${root}/`;\n const relative = (source: string): boolean => !/^[a-z]+:|^\\//i.test(source);\n const sources = (body.sources as unknown[]).map((source) => {\n if (typeof source !== 'string') return source;\n const rooted = relative(source) ? `${prefix}${source}` : source;\n if (base === undefined || !relative(rooted)) return rooted;\n try {\n return new URL(rooted, base).href;\n } catch {\n return rooted;\n }\n });\n return { ...(body as object), sources } as unknown as SourceMapJson;\n}\n\nasync function fetchMap(fetchImpl: typeof fetch, url: string): Promise<SourceMapJson | null> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);\n try {\n const response = await fetchImpl(url, { signal: controller.signal });\n if (!response.ok) return null;\n return asSourceMap(await response.json(), url);\n } catch {\n return null;\n } finally {\n clearTimeout(timer);\n }\n}\n","/**\n * Where in the source an element's JSX is written.\n *\n * React 19 dropped `fiber._debugSource` (the file:line a Babel plugin used to stamp on\n * every element). What it keeps, in development, is `fiber._debugStack`: an Error created\n * when the element was created, so its stack names the render function — and the line —\n * that wrote the JSX. Those frames point at bundled code (`webpack-internal:///…`), so\n * they are sent to the dev server's own `/__nextjs_original-stack-frames`, the endpoint\n * Next's error overlay uses to map frames back through the source maps. Under Turbopack\n * that endpoint rejects browser chunk URLs, so those frames go through the chunk's own\n * source map instead (`source-map.ts`).\n *\n * That endpoint is Next internals, not an API. Everything here degrades instead of\n * failing: no answer means the frame's own file and bundled line, flagged as such.\n */\n\nimport { createSourceMapLookup } from './source-map';\n\nexport interface RawFrame {\n readonly file: string;\n readonly line1: number;\n readonly column1: number;\n readonly methodName: string;\n}\n\nexport interface SourceLocation {\n /**\n * Relative to the app's directory when Next mapped it (webpack), absolute when the chunk's\n * source map did (Turbopack), else the bundled URL or path.\n */\n readonly file: string;\n readonly line: number;\n readonly column: number | null;\n /** True when the line is the ORIGINAL source line, false when it is the bundled one. */\n readonly mapped: boolean;\n /** Next flagged the frame as framework or library code: not where an edit belongs. */\n readonly ignored?: boolean;\n}\n\nconst CHROME_FRAME = /^\\s*at (?:(.+?) \\()?(.+?):(\\d+):(\\d+)\\)?\\s*$/;\nconst FIREFOX_FRAME = /^\\s*(.*?)@(.+?):(\\d+):(\\d+)\\s*$/;\n\nexport function parseStack(stack: string): RawFrame[] {\n const frames: RawFrame[] = [];\n for (const line of stack.split('\\n')) {\n const match = CHROME_FRAME.exec(line) ?? FIREFOX_FRAME.exec(line);\n if (match === null) continue;\n const [, methodName, file, line1, column1] = match;\n if (file === undefined || line1 === undefined || column1 === undefined) continue;\n frames.push({ file, line1: Number(line1), column1: Number(column1), methodName: methodName ?? '' });\n }\n return frames;\n}\n\n/** React's own frames, and the JSX factory it calls through, sit above the call site. */\nconst REACT_FRAME =\n /(?:^|[/\\\\])(?:react|react-dom|scheduler)(?:[/\\\\]|@)|react-jsx-(?:dev-)?runtime|react\\.development|react-dom[^/\\\\]*\\.development|next[/\\\\]dist[/\\\\]compiled[/\\\\]react/;\nconst REACT_METHOD = /^(?:exports\\.)?(?:jsxDEV|jsxs?|createElement|react-stack-top-frame)$|^Object\\.(?:jsxDEV|jsxs?)$/;\n\n/**\n * The frame that wrote the JSX: the first one below React's own. `null` when the stack\n * holds nothing else, which is the case in a production build.\n */\nexport function callSiteFrame(stack: string): RawFrame | null {\n for (const frame of parseStack(stack)) {\n if (REACT_METHOD.test(frame.methodName) || REACT_FRAME.test(frame.file)) continue;\n return frame;\n }\n return null;\n}\n\n/** `webpack-internal:///(app-pages-browser)/./src/x.tsx` → `src/x.tsx`. */\nexport function bundledPath(file: string): string {\n const internal = /^webpack-internal:\\/\\/\\/(?:\\([^)]*\\)\\/)?(?:\\.\\/)?(.*)$/.exec(file);\n if (internal?.[1]) return internal[1];\n if (file.startsWith('file://')) return decodeURIComponent(file.slice('file://'.length));\n return file;\n}\n\nfunction unmapped(frame: RawFrame): SourceLocation {\n return { file: bundledPath(frame.file), line: frame.line1, column: frame.column1, mapped: false };\n}\n\ninterface OriginalFrameResponse {\n readonly status?: string;\n readonly value?: {\n readonly originalStackFrame?: {\n readonly file?: string | null;\n readonly line1?: number | null;\n readonly column1?: number | null;\n readonly ignored?: boolean;\n } | null;\n } | null;\n}\n\nexport type FrameResolver = (frames: readonly RawFrame[]) => Promise<SourceLocation[]>;\n\nconst NEXT_ENDPOINT = '/__nextjs_original-stack-frames';\nconst TIMEOUT_MS = 3000;\n\n/**\n * Maps frames through Next's dev server in ONE request. Always resolves, one location per\n * frame, in order: a frame Next could not map, or any failure of the request, falls back\n * to the frame as bundled.\n */\nexport function createNextResolver(fetchImpl: typeof fetch = (...args) => fetch(...args)): FrameResolver {\n const cache = new Map<string, SourceLocation>();\n const keyOf = (frame: RawFrame): string => `${frame.file}:${frame.line1}:${frame.column1}`;\n const viaSourceMap = createSourceMapLookup(fetchImpl);\n\n return async (frames) => {\n const pending = frames.filter((frame) => !cache.has(keyOf(frame)));\n if (pending.length > 0) {\n const fromNext = await requestOriginalFrames(fetchImpl, pending);\n // Turbopack's endpoint cannot map a browser chunk URL; its `.map` beside the chunk can.\n const mapped = await Promise.all(\n pending.map(async (frame, index) => fromNext[index] ?? (await viaSourceMap(frame))),\n );\n pending.forEach((frame, index) => cache.set(keyOf(frame), mapped[index] ?? unmapped(frame)));\n }\n return frames.map((frame) => cache.get(keyOf(frame)) ?? unmapped(frame));\n };\n}\n\nasync function requestOriginalFrames(\n fetchImpl: typeof fetch,\n frames: readonly RawFrame[],\n): Promise<Array<SourceLocation | null>> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);\n try {\n const response = await fetchImpl(NEXT_ENDPOINT, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n frames: frames.map((frame) => ({ ...frame, arguments: [] })),\n isServer: false,\n isEdgeServer: false,\n isAppDirectory: true,\n }),\n signal: controller.signal,\n });\n if (!response.ok) return frames.map(() => null);\n const body: unknown = await response.json();\n if (!Array.isArray(body)) return frames.map(() => null);\n return frames.map((_, index) => toLocation(body[index] as OriginalFrameResponse | undefined));\n } catch {\n return frames.map(() => null);\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction toLocation(entry: OriginalFrameResponse | undefined): SourceLocation | null {\n const original = entry?.status === 'fulfilled' ? entry.value?.originalStackFrame : null;\n if (!original?.file || typeof original.line1 !== 'number') return null;\n // Next answers a frame it could NOT map with the input echoed back; a bundled URL is\n // not an original location.\n if (/^(?:webpack-internal|https?):/.test(original.file)) return null;\n return {\n file: original.file,\n line: original.line1,\n column: original.column1 ?? null,\n mapped: true,\n ...(original.ignored === true || /(?:^|\\/)node_modules\\//.test(original.file) ? { ignored: true } : {}),\n };\n}\n","import { describeAccessibility, nearbyText, sectionPath } from './context';\nimport { componentAncestors, componentName, componentState, debugStackOf, fiberOf, type Fiber } from './fiber';\nimport { cssSelector, controlValue, describeElement, elementText } from './selector';\nimport { DEFAULT_REDACTOR, type Redactor } from './redaction';\nimport { DEFAULT_LIMITS, toSnapshot, type Snapshot } from './serialize';\nimport { callSiteFrame, type FrameResolver, type RawFrame, type SourceLocation } from './stack';\n\n/**\n * Everything one comment records about its element, taken at the moment of the click.\n * \"The current value of the data\" is the value the developer was LOOKING at when they\n * noticed the problem, so it is captured then, not when the prompt is copied — by which\n * time they may have navigated away and back.\n */\nexport interface ElementCapture {\n readonly page: {\n readonly url: string;\n readonly pathname: string;\n readonly search: string;\n readonly title: string;\n };\n readonly element: {\n readonly tag: string;\n readonly opening: string;\n readonly selector: string;\n readonly text: string;\n readonly value: string | null;\n readonly rect: { readonly x: number; readonly y: number; readonly width: number; readonly height: number };\n readonly styles: Readonly<Record<string, string>>;\n /** Role, accessible name and ARIA states: `button \"Save\" (disabled)`. */\n readonly accessibility: string | null;\n /** Page heading and enclosing section labels: `Debt batches › New batch`. */\n readonly section: string | null;\n /** The text of the siblings either side, to tell identical elements apart. */\n readonly nearby: string | null;\n };\n readonly viewport: { readonly width: number; readonly height: number; readonly devicePixelRatio: number };\n /** Where the element's own JSX is written: usually the line to edit. */\n readonly jsx: SourceLocation | null;\n /** Enclosing components, nearest first, each with where IT was rendered from. */\n readonly components: ReadonlyArray<{ readonly name: string; readonly renderedAt: SourceLocation | null }>;\n /** Props and stateful hooks of the nearest components, personal data redacted unless redaction is off. */\n readonly data: ReadonlyArray<{ readonly component: string; readonly props: Snapshot; readonly state: Snapshot }>;\n}\n\n/** Computed styles worth quoting when the request is about how something looks. */\nconst STYLE_PROPERTIES = [\n 'display',\n 'position',\n 'width',\n 'height',\n 'margin',\n 'padding',\n 'gap',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'line-height',\n 'color',\n 'background-color',\n 'border',\n 'border-radius',\n 'opacity',\n 'overflow',\n 'white-space',\n] as const;\n\n/** Styles whose value means \"nothing set\", left out to keep the list readable. */\nconst DEFAULT_STYLE_VALUES = new Set(['none', 'normal', 'auto', '0px', 'rgba(0, 0, 0, 0)', 'visible', 'static', '1']);\n\nexport interface CaptureOptions {\n /** Components whose props and state are snapshotted; further ones are only named. */\n readonly dataComponents?: number;\n /** Screens text and data for personal data; the built-in defaults when left out. */\n readonly redactor?: Redactor;\n}\n\nconst DATA_COMPONENTS = 2;\n/** Components whose render site is resolved to a source location. */\nconst LOCATED_COMPONENTS = 4;\n\nexport async function captureElement(\n element: Element,\n resolve: FrameResolver,\n options: CaptureOptions = {},\n): Promise<ElementCapture> {\n const win = element.ownerDocument.defaultView ?? window;\n const redactor = options.redactor ?? DEFAULT_REDACTOR;\n const fiber = fiberOf(element);\n const components = fiber === null ? [] : componentAncestors(fiber);\n\n // One request maps every frame: the element's own JSX site, then each component's.\n const sites: Array<RawFrame | null> = [fiber, ...components.slice(0, LOCATED_COMPONENTS)].map((f) =>\n f === null ? null : siteOf(f),\n );\n const wanted = sites.filter((site): site is RawFrame => site !== null);\n const resolved = wanted.length > 0 ? await resolve(wanted) : [];\n const locations = new Map<RawFrame, SourceLocation | undefined>(wanted.map((site, index) => [site, resolved[index]]));\n // A frame inside the framework says only that Next rendered the component: drop it.\n const locate = (site: RawFrame | null | undefined): SourceLocation | null => {\n const location = site ? locations.get(site) : undefined;\n return location === undefined || location.ignored === true ? null : location;\n };\n\n const rect = element.getBoundingClientRect();\n return {\n page: {\n url: win.location.href,\n pathname: win.location.pathname,\n search: win.location.search,\n title: element.ownerDocument.title,\n },\n element: {\n tag: element.tagName.toLowerCase(),\n opening: describeElement(element, redactor),\n selector: cssSelector(element),\n text: elementText(element, undefined, redactor),\n value: controlValue(element, redactor),\n rect: { x: Math.round(rect.x), y: Math.round(rect.y), width: Math.round(rect.width), height: Math.round(rect.height) },\n styles: notableStyles(win.getComputedStyle(element)),\n accessibility: describeAccessibility(element, redactor),\n section: sectionPath(element, redactor),\n nearby: nearbyText(element, redactor),\n },\n viewport: { width: win.innerWidth, height: win.innerHeight, devicePixelRatio: win.devicePixelRatio },\n jsx: locate(sites[0]),\n components: components.map((component, index) => ({\n name: componentName(component),\n renderedAt: locate(sites[index + 1]),\n })),\n data: components.slice(0, options.dataComponents ?? DATA_COMPONENTS).map((component) => ({\n component: componentName(component),\n props: toSnapshot(component.memoizedProps, DEFAULT_LIMITS, redactor),\n state: toSnapshot(componentState(component), DEFAULT_LIMITS, redactor),\n })),\n };\n}\n\nfunction siteOf(fiber: Fiber): RawFrame | null {\n const stack = debugStackOf(fiber);\n return stack === null ? null : callSiteFrame(stack);\n}\n\nfunction notableStyles(style: CSSStyleDeclaration): Record<string, string> {\n const out: Record<string, string> = {};\n for (const property of STYLE_PROPERTIES) {\n const value = style.getPropertyValue(property).trim();\n if (value && !DEFAULT_STYLE_VALUES.has(value)) out[property] = value;\n }\n return out;\n}\n\n/** The label shown while hovering: the nearest component and the tag, without any I/O. */\nexport function hoverLabel(element: Element): string {\n const fiber = fiberOf(element);\n const nearest = fiber === null ? undefined : componentAncestors(fiber, 1)[0];\n const tag = element.tagName.toLowerCase();\n return nearest === undefined ? tag : `${componentName(nearest)} · ${tag}`;\n}\n","import type { Box } from './overlay-parts';\n\n/**\n * Where each comment's card goes when comments are shown in full: above its element when\n * there is room, else below, never off screen, and pushed down past any card already placed\n * so no two cover each other. Pure geometry, in viewport pixels.\n */\n\nexport interface CalloutTarget {\n readonly number: number;\n readonly comment: string;\n readonly box: Box;\n /** The comment is on a dragged area, drawn dashed as it was marked. */\n readonly area?: boolean;\n}\n\nexport interface PlacedCallout extends CalloutTarget {\n readonly card: Box;\n}\n\nexport const CARD_WIDTH = 260;\nconst LINE_HEIGHT = 18;\nconst PADDING = 16;\nconst GAP = 6;\nconst MARGIN = 4;\n/** A card shows at most this many lines; the rest of the comment is cut with an ellipsis. */\nexport const CARD_LINES = 4;\n/** Average glyph width at 13px, enough to guess how many lines a comment wraps to. */\nconst CHARS_PER_LINE = 36;\n\nexport function cardHeight(comment: string): number {\n const lines = comment\n .split('\\n')\n .reduce((total, line) => total + Math.max(1, Math.ceil(line.length / CHARS_PER_LINE)), 0);\n return PADDING + LINE_HEIGHT * Math.min(CARD_LINES, Math.max(1, lines));\n}\n\nfunction overlaps(a: Box, b: Box): boolean {\n return a.left < b.left + b.width && b.left < a.left + a.width && a.top < b.top + b.height && b.top < a.top + a.height;\n}\n\nexport function layoutCallouts(\n targets: readonly CalloutTarget[],\n viewport: { readonly width: number; readonly height: number },\n): PlacedCallout[] {\n const placed: PlacedCallout[] = [];\n const width = Math.min(CARD_WIDTH, viewport.width - 2 * MARGIN);\n // Top to bottom, so a card pushed down moves away from the cards already placed.\n const ordered = [...targets].sort((a, b) => a.box.top - b.box.top || a.box.left - b.box.left);\n for (const target of ordered) {\n const height = cardHeight(target.comment);\n const above = target.box.top - height - GAP;\n let top = above >= MARGIN ? above : target.box.top + target.box.height + GAP;\n const left = Math.min(Math.max(MARGIN, target.box.left), viewport.width - width - MARGIN);\n let card: Box = { top, left, width, height };\n for (let moved = true; moved; ) {\n moved = false;\n for (const other of placed) {\n if (overlaps(card, other.card)) {\n top = other.card.top + other.card.height + GAP;\n card = { top, left, width, height };\n moved = true;\n }\n }\n }\n placed.push({ ...target, card: { ...card, top: Math.min(card.top, viewport.height - height - MARGIN) } });\n }\n return placed.sort((a, b) => a.number - b.number);\n}\n","import type { ReactNode } from 'react';\n\n/** Stroke icons on a 24-unit grid, inline so the overlay ships no asset and needs no CSP entry. */\nconst PATHS = {\n comment: ['M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z', 'M12 7v6M9 10h6'],\n pause: ['M8 5v14M16 5v14'],\n play: ['M7 4l13 8-13 8z'],\n eye: ['M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z', 'M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z'],\n camera: ['M4 8h3l2-3h6l2 3h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z', 'M12 9.5a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7z'],\n list: ['M9 6h12M9 12h12M9 18h12M4 6h.01M4 12h.01M4 18h.01'],\n copy: ['M10 9h10a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10a1 1 0 0 1-1-1V10a1 1 0 0 1 1-1z', 'M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1'],\n help: ['M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18z', 'M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3M12 17h.01'],\n arrow: ['M5 19L19 5', 'M10 5h9v9'],\n rect: ['M5 5h14a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z'],\n highlight: ['M9 11l-6 6v3h9l3-3', 'M22 12l-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4'],\n pen: ['M12 20h9', 'M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'],\n text: ['M4 7V4h16v3', 'M9 20h6', 'M12 4v16'],\n pixelate: ['M3 3h6v6H3z', 'M15 3h6v6h-6z', 'M9 9h6v6H9z', 'M3 15h6v6H3z', 'M15 15h6v6h-6z'],\n undo: ['M9 14L4 9l5-5', 'M4 9h10.5a5.5 5.5 0 0 1 0 11H11'],\n trash: ['M3 6h18', 'M8 6V4h8v2', 'M19 6l-1 14H6L5 6'],\n download: ['M12 3v12', 'M7 10l5 5 5-5', 'M5 21h14'],\n close: ['M18 6L6 18', 'M6 6l12 12'],\n select: ['M4 3l7 17 2.5-7.5L21 10z'],\n redo: ['M15 14l5-5-5-5', 'M20 9H9.5a5.5 5.5 0 0 0 0 11H13'],\n zoomIn: ['M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z', 'M20 20l-4-4', 'M11 8v6M8 11h6'],\n zoomOut: ['M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14z', 'M20 20l-4-4', 'M8 11h6'],\n fit: ['M4 9V4h5', 'M20 9V4h-5', 'M4 15v5h5', 'M20 15v5h-5'],\n eraser: ['M7 21h10', 'M5 15l9-9 5 5-9 9H8z'],\n crop: ['M6 2v14a2 2 0 0 0 2 2h14', 'M18 22V8a2 2 0 0 0-2-2H2'],\n cropOff: ['M6 2v14a2 2 0 0 0 2 2h14', 'M18 22V8a2 2 0 0 0-2-2H2', 'M3 3l18 18'],\n collapse: ['M9 6l6 6-6 6'],\n shield: ['M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z', 'M9 12l2 2 4-4'],\n shieldOff: ['M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z', 'M3 3l18 18'],\n ruler: ['M3 17L17 3l4 4L7 21z', 'M7 13l2 2', 'M10 10l2 2', 'M13 7l2 2'],\n} as const;\n\nexport type IconName = keyof typeof PATHS;\n\nexport function Icon(props: { readonly name: IconName; readonly size?: number }): ReactNode {\n const size = props.size ?? 18;\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n style={{ display: 'block', flex: 'none' }}\n >\n {PATHS[props.name].map((d) => (\n <path key={d} d={d} />\n ))}\n </svg>\n );\n}\n","import { useEffect, useId, useLayoutEffect, useRef, useState, type ReactElement, type ReactNode } from 'react';\n\nconst FONT = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\n/** Long enough that sweeping the pointer across a bar does not flash every tip. */\nconst DELAY_MS = 350;\nconst EDGE = 8;\n\n/** The command key as the platform names it. */\nexport const MOD_KEY =\n typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? '⌘' : 'Ctrl';\n\n/**\n * A styled tip for an icon button: the name, an optional one-line explanation and the\n * shortcut as key caps. Shows on hover after a short delay and at once on keyboard focus;\n * it never takes the pointer, and it shifts sideways to stay inside the viewport.\n *\n * `children` renders the trigger and receives the id to put in `aria-describedby`.\n */\nexport function Tooltip(props: {\n readonly label: string;\n readonly detail?: string;\n readonly shortcut?: readonly string[];\n readonly placement: 'above' | 'below';\n readonly children: (describedBy: string | undefined) => ReactElement;\n}): ReactNode {\n const id = useId();\n const [open, setOpen] = useState(false);\n const [shift, setShift] = useState(0);\n const timer = useRef<number | null>(null);\n const bubble = useRef<HTMLSpanElement | null>(null);\n\n const clear = (): void => {\n if (timer.current !== null) window.clearTimeout(timer.current);\n timer.current = null;\n };\n const show = (delay: number): void => {\n clear();\n timer.current = window.setTimeout(() => setOpen(true), delay);\n };\n const hide = (): void => {\n clear();\n setOpen(false);\n setShift(0);\n };\n useEffect(() => clear, []);\n\n useLayoutEffect(() => {\n if (!open || bubble.current === null) return;\n const rect = bubble.current.getBoundingClientRect();\n if (rect.width === 0) return;\n if (rect.right > window.innerWidth - EDGE) setShift(window.innerWidth - EDGE - rect.right);\n else if (rect.left < EDGE) setShift(EDGE - rect.left);\n }, [open]);\n\n return (\n <span\n style={{ position: 'relative', display: 'inline-flex' }}\n onPointerEnter={() => show(DELAY_MS)}\n onPointerLeave={hide}\n onPointerDown={hide}\n onFocus={(event) => {\n if (focusVisible(event.target)) show(0);\n }}\n onBlur={hide}\n >\n {props.children(open ? id : undefined)}\n {open ? (\n <span\n ref={bubble}\n id={id}\n role=\"tooltip\"\n style={{\n position: 'absolute',\n left: '50%',\n [props.placement === 'above' ? 'bottom' : 'top']: 'calc(100% + 8px)',\n transform: `translateX(calc(-50% + ${shift}px))`,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n width: 'max-content',\n maxWidth: 260,\n padding: '6px 9px',\n borderRadius: 7,\n background: '#0E0E0E',\n border: '1px solid rgba(255,255,255,0.14)',\n boxShadow: '0 6px 18px rgba(0,0,0,0.35)',\n color: '#FFFFFF',\n font: `500 12px/1.35 ${FONT}`,\n letterSpacing: 'normal',\n textAlign: 'left',\n textTransform: 'none',\n whiteSpace: 'normal',\n pointerEvents: 'none',\n zIndex: 1,\n }}\n >\n <span style={{ display: 'flex', alignItems: 'center', gap: 8, whiteSpace: 'nowrap' }}>\n <span style={{ fontWeight: 600 }}>{props.label}</span>\n {props.shortcut === undefined || props.shortcut.length === 0 ? null : (\n <span style={{ display: 'inline-flex', gap: 3, marginLeft: 'auto' }}>\n {props.shortcut.map((key) => (\n <kbd\n key={key}\n style={{\n font: `600 11px/16px ${FONT}`,\n minWidth: 16,\n padding: '0 4px',\n textAlign: 'center',\n borderRadius: 4,\n background: 'rgba(255,255,255,0.14)',\n color: '#FFFFFF',\n }}\n >\n {key}\n </kbd>\n ))}\n </span>\n )}\n </span>\n {props.detail === undefined ? null : <span style={{ color: '#B9B5AE' }}>{props.detail}</span>}\n </span>\n ) : null}\n </span>\n );\n}\n\n/** Keyboard focus, not the focus a click leaves behind. */\nfunction focusVisible(target: EventTarget): boolean {\n try {\n return target instanceof HTMLElement && target.matches(':focus-visible');\n } catch {\n return false;\n }\n}\n","import type { CSSProperties, ReactNode } from 'react';\n\nimport { CARD_LINES, type PlacedCallout } from './callouts';\nimport { Icon, type IconName } from './icons';\nimport { MOD_KEY, Tooltip } from './tooltip';\n\n/**\n * The overlay's presentational pieces. Inline styles only: a strict CSP allows style\n * attributes but not an unnonced <style> element, and Tailwind's preflight would restyle\n * a bare <button> otherwise. Every piece sets its own font so the host page's cannot leak in.\n */\n\nexport const ACCENT = '#D97757';\nexport const INK = '#1F1E1D';\nexport const MUTED = '#6B6862';\nexport const LINE = '#E5E2DC';\nexport const Z = 2147483000;\n\nexport const FONT: CSSProperties = {\n fontFamily: 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif',\n fontSize: 13,\n lineHeight: 1.45,\n color: INK,\n letterSpacing: 'normal',\n textTransform: 'none',\n};\n\nexport const BUTTON: CSSProperties = {\n ...FONT,\n appearance: 'none',\n border: `1px solid ${LINE}`,\n background: '#FFFFFF',\n borderRadius: 6,\n padding: '5px 10px',\n cursor: 'pointer',\n fontWeight: 500,\n};\n\nexport const PRIMARY: CSSProperties = { ...BUTTON, background: ACCENT, borderColor: ACCENT, color: '#FFFFFF' };\n\nexport interface Box {\n readonly top: number;\n readonly left: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport function boxOf(element: Element): Box {\n const rect = element.getBoundingClientRect();\n return { top: rect.top, left: rect.left, width: rect.width, height: rect.height };\n}\n\nexport function Highlight(props: { readonly box: Box; readonly label: string; readonly strong: boolean }): ReactNode {\n const { box } = props;\n const labelAbove = box.top > 24;\n return (\n <>\n <div\n style={{\n position: 'fixed',\n top: box.top,\n left: box.left,\n width: box.width,\n height: box.height,\n border: `2px solid ${ACCENT}`,\n background: props.strong ? 'rgba(217, 119, 87, 0.18)' : 'rgba(217, 119, 87, 0.08)',\n borderRadius: 3,\n pointerEvents: 'none',\n zIndex: Z,\n boxSizing: 'border-box',\n }}\n />\n <div\n style={{\n ...FONT,\n position: 'fixed',\n top: labelAbove ? box.top - 22 : box.top + box.height + 2,\n left: Math.max(0, box.left),\n background: ACCENT,\n color: '#FFFFFF',\n fontSize: 11,\n fontWeight: 600,\n padding: '2px 6px',\n borderRadius: 3,\n pointerEvents: 'none',\n zIndex: Z,\n whiteSpace: 'nowrap',\n }}\n >\n {props.label}\n </div>\n </>\n );\n}\n\nexport function AreaBox(props: { readonly box: Box }): ReactNode {\n return (\n <div\n style={{\n position: 'fixed',\n top: props.box.top,\n left: props.box.left,\n width: props.box.width,\n height: props.box.height,\n border: `2px dashed ${ACCENT}`,\n background: 'rgba(217, 119, 87, 0.08)',\n pointerEvents: 'none',\n zIndex: Z,\n boxSizing: 'border-box',\n }}\n />\n );\n}\n\nexport function Pin(props: { readonly box: Box; readonly number: number; readonly onClick: () => void }): ReactNode {\n const top = Math.min(Math.max(props.box.top - 10, 4), window.innerHeight - 26);\n const left = Math.min(Math.max(props.box.left - 10, 4), window.innerWidth - 26);\n return (\n <button\n type=\"button\"\n onClick={props.onClick}\n aria-label={`Comment ${props.number}`}\n style={{\n ...FONT,\n position: 'fixed',\n top,\n left,\n width: 22,\n height: 22,\n borderRadius: '50% 50% 50% 4px',\n border: '2px solid #FFFFFF',\n background: ACCENT,\n color: '#FFFFFF',\n fontSize: 11,\n fontWeight: 700,\n padding: 0,\n cursor: 'pointer',\n boxShadow: '0 1px 4px rgba(0,0,0,0.3)',\n zIndex: Z + 1,\n }}\n >\n {props.number}\n </button>\n );\n}\n\nexport function Hint(props: { readonly onDismiss: () => void }): ReactNode {\n return (\n <div\n role=\"status\"\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 10,\n ...FONT,\n position: 'fixed',\n top: 8,\n left: '50%',\n transform: 'translateX(-50%)',\n background: INK,\n color: '#FFFFFF',\n fontSize: 12,\n padding: '6px 12px',\n borderRadius: 999,\n zIndex: Z + 2,\n maxWidth: 'calc(100vw - 32px)',\n textAlign: 'center',\n boxShadow: '0 2px 8px rgba(0,0,0,0.25)',\n }}\n >\n <span style={{ ...FONT, fontSize: 12, color: '#FFFFFF' }}>\n Comment mode. Click: comment on an element · Select text: comment on a passage · ⌘/Ctrl+click: pick several ·\n Shift+drag: mark an area · Alt+click: interact normally · Esc: exit\n </span>\n <Tooltip label=\"Hide this hint\" detail=\"The ? button in the toolbar brings it back.\" placement=\"below\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onDismiss}\n aria-label=\"Hide hint\"\n aria-describedby={describedBy}\n style={{ ...FONT, appearance: 'none', background: 'none', border: 0, padding: '0 2px', color: '#FFFFFF', fontSize: 16, lineHeight: 1, cursor: 'pointer' }}\n >\n ×\n </button>\n )}\n </Tooltip>\n </div>\n );\n}\n\nexport function Editor(props: {\n readonly anchor: Box | null;\n readonly title: string;\n readonly comment: string;\n readonly editing: boolean;\n readonly onChange: (comment: string) => void;\n readonly onSave: () => void;\n readonly onCancel: () => void;\n readonly onDelete: () => void;\n}): ReactNode {\n const width = 320;\n const height = 170;\n const { anchor } = props;\n let top = window.innerHeight - height - 80;\n let left = window.innerWidth - width - 16;\n if (anchor !== null) {\n const below = anchor.top + anchor.height + 8;\n top = below + height < window.innerHeight ? below : Math.max(8, anchor.top - height - 8);\n left = Math.min(Math.max(8, anchor.left), window.innerWidth - width - 8);\n }\n const canSave = props.comment.trim().length > 0;\n return (\n <div\n role=\"dialog\"\n aria-label=\"Comment on element\"\n style={{\n ...FONT,\n position: 'fixed',\n top,\n left,\n width,\n background: '#FFFFFF',\n border: `1px solid ${LINE}`,\n borderRadius: 10,\n boxShadow: '0 8px 24px rgba(0,0,0,0.18)',\n padding: 10,\n zIndex: Z + 3,\n boxSizing: 'border-box',\n }}\n >\n <div style={{ ...FONT, fontSize: 11, color: MUTED, marginBottom: 6, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {props.title}\n </div>\n <textarea\n // The editor exists only after a deliberate click, so taking focus is expected.\n autoFocus\n value={props.comment}\n placeholder=\"What should change here?\"\n onChange={(event) => props.onChange(event.target.value)}\n onKeyDown={(event) => {\n event.stopPropagation();\n if (event.key === 'Escape') props.onCancel();\n if (event.key === 'Enter' && (event.metaKey || event.ctrlKey) && canSave) props.onSave();\n }}\n style={{\n ...FONT,\n width: '100%',\n height: 84,\n resize: 'vertical',\n border: `1px solid ${LINE}`,\n borderRadius: 6,\n padding: 8,\n boxSizing: 'border-box',\n outline: 'none',\n background: '#FFFFFF',\n }}\n />\n <div style={{ display: 'flex', gap: 6, justifyContent: 'flex-end', marginTop: 8 }}>\n {props.editing ? (\n <button type=\"button\" onClick={props.onDelete} style={{ ...BUTTON, marginRight: 'auto', color: '#B42318' }}>\n Delete\n </button>\n ) : null}\n <button type=\"button\" onClick={props.onCancel} style={BUTTON}>\n Cancel\n </button>\n <button type=\"button\" onClick={props.onSave} disabled={!canSave} style={{ ...PRIMARY, opacity: canSave ? 1 : 0.5 }}>\n Save (⌘↵)\n </button>\n </div>\n </div>\n );\n}\n\nexport interface ListEntry {\n readonly id: string;\n readonly number: number;\n readonly comment: string;\n readonly where: string;\n readonly onThisPage: boolean;\n}\n\nexport function Panel(props: {\n readonly entries: readonly ListEntry[];\n readonly includeData: boolean;\n /** Whether new comments are screened for personal data, for the checkbox's label. */\n readonly redactionOn: boolean;\n readonly onIncludeData: (value: boolean) => void;\n readonly onEdit: (id: string) => void;\n readonly onClear: () => void;\n readonly onClose: () => void;\n}): ReactNode {\n return (\n <div\n aria-label=\"Comment list\"\n style={{\n ...FONT,\n position: 'fixed',\n right: 16,\n bottom: 72,\n width: 340,\n maxHeight: '60vh',\n display: 'flex',\n flexDirection: 'column',\n background: '#FFFFFF',\n border: `1px solid ${LINE}`,\n borderRadius: 10,\n boxShadow: '0 8px 24px rgba(0,0,0,0.18)',\n zIndex: Z + 2,\n boxSizing: 'border-box',\n }}\n >\n <div style={{ display: 'flex', alignItems: 'center', padding: '8px 10px', borderBottom: `1px solid ${LINE}` }}>\n <strong style={{ ...FONT, fontWeight: 600 }}>Comments ({props.entries.length})</strong>\n <button type=\"button\" onClick={props.onClose} aria-label=\"Hide list\" style={{ ...BUTTON, marginLeft: 'auto', padding: '2px 8px' }}>\n Hide\n </button>\n </div>\n <ol style={{ ...FONT, listStyle: 'none', margin: 0, padding: 0, overflowY: 'auto', flex: 1 }}>\n {props.entries.map((entry) => (\n <li key={entry.id} style={{ borderBottom: `1px solid ${LINE}` }}>\n <button\n type=\"button\"\n onClick={() => props.onEdit(entry.id)}\n style={{ ...FONT, display: 'flex', gap: 8, width: '100%', textAlign: 'left', background: 'none', border: 0, padding: '8px 10px', cursor: 'pointer' }}\n >\n <span style={{ ...FONT, color: ACCENT, fontWeight: 700, minWidth: 16 }}>{entry.number}</span>\n <span style={{ ...FONT, flex: 1, minWidth: 0 }}>\n <span style={{ ...FONT, display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {entry.comment}\n </span>\n <span style={{ ...FONT, display: 'block', fontSize: 11, color: MUTED, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {entry.where}\n {entry.onThisPage ? '' : ' · other page'}\n </span>\n </span>\n </button>\n </li>\n ))}\n </ol>\n <div style={{ padding: 10, display: 'flex', alignItems: 'center', gap: 8 }}>\n <label style={{ ...FONT, display: 'flex', gap: 6, alignItems: 'center', fontSize: 12, color: MUTED, cursor: 'pointer', flex: 1 }}>\n <input type=\"checkbox\" checked={props.includeData} onChange={(event) => props.onIncludeData(event.target.checked)} />\n Include props/state ({props.redactionOn ? 'personal data redacted' : 'redaction off'})\n </label>\n <button type=\"button\" onClick={props.onClear} style={{ ...BUTTON, color: '#B42318' }}>\n Clear all\n </button>\n </div>\n </div>\n );\n}\n\n/** Each comment drawn in full beside its element: what the page shows in a screenshot. */\nexport function Callouts(props: {\n readonly callouts: readonly PlacedCallout[];\n readonly onEdit: ((number: number) => void) | null;\n}): ReactNode {\n return (\n <>\n {props.callouts.map((callout) => (\n <div key={callout.number}>\n <div\n style={{\n position: 'fixed',\n top: callout.box.top,\n left: callout.box.left,\n width: callout.box.width,\n height: callout.box.height,\n border: `2px ${callout.area === true ? 'dashed' : 'solid'} ${ACCENT}`,\n background: callout.area === true ? 'rgba(217, 119, 87, 0.08)' : 'transparent',\n borderRadius: 3,\n pointerEvents: 'none',\n zIndex: Z,\n boxSizing: 'border-box',\n }}\n />\n <button\n type=\"button\"\n aria-label={`Comment ${callout.number}: ${callout.comment}`}\n onClick={props.onEdit === null ? undefined : () => props.onEdit?.(callout.number)}\n style={{\n ...FONT,\n position: 'fixed',\n top: callout.card.top,\n left: callout.card.left,\n width: callout.card.width,\n maxHeight: callout.card.height,\n display: 'flex',\n gap: 8,\n alignItems: 'flex-start',\n textAlign: 'left',\n padding: '7px 10px',\n background: '#FFFFFF',\n border: `1.5px solid ${ACCENT}`,\n borderRadius: 8,\n boxShadow: '0 4px 14px rgba(0,0,0,0.18)',\n cursor: props.onEdit === null ? 'default' : 'pointer',\n zIndex: Z + 1,\n boxSizing: 'border-box',\n overflow: 'hidden',\n }}\n >\n <span\n style={{\n ...FONT,\n flex: 'none',\n minWidth: 18,\n height: 18,\n borderRadius: 9,\n background: ACCENT,\n color: '#FFFFFF',\n fontSize: 11,\n fontWeight: 700,\n lineHeight: '18px',\n textAlign: 'center',\n }}\n >\n {callout.number}\n </span>\n <span\n style={{\n ...FONT,\n lineHeight: '18px',\n whiteSpace: 'pre-wrap',\n overflowWrap: 'anywhere',\n display: '-webkit-box',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: CARD_LINES,\n overflow: 'hidden',\n }}\n >\n {callout.comment}\n </span>\n </button>\n </div>\n ))}\n </>\n );\n}\n\nexport interface Notice {\n readonly title: string;\n readonly detail?: string;\n readonly tone?: 'success' | 'error';\n}\n\nexport function Toast(props: { readonly notice: Notice; readonly onDismiss: () => void }): ReactNode {\n const error = props.notice.tone === 'error';\n return (\n <div\n role=\"status\"\n aria-live=\"polite\"\n onClick={props.onDismiss}\n style={{\n ...FONT,\n position: 'fixed',\n left: '50%',\n bottom: 24,\n transform: 'translateX(-50%)',\n width: 'max-content',\n maxWidth: 'min(420px, calc(100vw - 32px))',\n display: 'flex',\n gap: 10,\n alignItems: 'flex-start',\n padding: '10px 14px',\n background: INK,\n color: '#FFFFFF',\n borderRadius: 10,\n boxShadow: '0 8px 24px rgba(0,0,0,0.3)',\n // Above the screenshot editor, which reports through it.\n zIndex: Z + 6,\n cursor: 'pointer',\n }}\n >\n <span style={{ ...FONT, color: error ? '#FF8A80' : '#7EE2A8', fontWeight: 700 }}>{error ? '!' : '✓'}</span>\n <span style={{ ...FONT, color: '#FFFFFF' }}>\n <strong style={{ ...FONT, display: 'block', color: '#FFFFFF', fontWeight: 600 }}>{props.notice.title}</strong>\n {props.notice.detail === undefined ? null : (\n <span style={{ ...FONT, display: 'block', color: '#D6D3CE', fontSize: 12 }}>{props.notice.detail}</span>\n )}\n </span>\n </div>\n );\n}\n\nexport interface ToolbarProps {\n readonly active: boolean;\n readonly paused: boolean;\n readonly count: number;\n readonly panelOpen: boolean;\n readonly showComments: boolean;\n readonly capturing: boolean;\n /** Folded down to one button, out of the page's way. */\n readonly collapsed: boolean;\n readonly onToggleCollapsed: () => void;\n /** Whether personal-data redaction is on: the settings button warns when it is off. */\n readonly redactionOn: boolean;\n readonly settingsOpen: boolean;\n readonly onToggleSettings: () => void;\n /** Present while comment mode is on and its hint has been hidden: shows it again. */\n readonly onShowHint: (() => void) | null;\n readonly onToggleActive: () => void;\n readonly onTogglePaused: () => void;\n readonly onToggleComments: () => void;\n readonly onScreenshot: () => void;\n readonly onTogglePanel: () => void;\n readonly onCopy: () => void;\n}\n\n/** Every control of the tool in one bar, bottom right, grouped by what it acts on. */\nexport function Toolbar(props: ToolbarProps): ReactNode {\n const none = props.count === 0;\n if (props.collapsed) return <CollapsedToolbar {...props} />;\n return (\n <div\n role=\"toolbar\"\n aria-label=\"Dev annotator\"\n style={{\n ...FONT,\n position: 'fixed',\n right: 16,\n bottom: 16,\n display: 'flex',\n alignItems: 'center',\n gap: 2,\n padding: 4,\n background: INK,\n borderRadius: 12,\n boxShadow: '0 6px 20px rgba(0,0,0,0.28)',\n zIndex: Z + 2,\n }}\n >\n <ToolButton\n icon=\"comment\"\n label={props.active ? 'Turn off comment mode' : 'Turn on comment mode'}\n hint=\"Click an element, select text, ⌘/Ctrl+click several or Shift+drag an area to comment on it.\"\n shortcut={props.active ? 'Esc' : 'Alt+Shift+C'}\n pressed={props.active}\n accent\n onClick={props.onToggleActive}\n />\n <ToolButton\n icon={props.paused ? 'play' : 'pause'}\n label={props.paused ? 'Resume animations' : 'Pause animations'}\n hint={props.paused ? 'Resume animations and videos' : 'Pause animations and videos to comment on the current frame'}\n pressed={props.paused}\n onClick={props.onTogglePaused}\n />\n <ToolButton\n icon=\"eye\"\n label={props.showComments ? 'Show comments as numbers' : 'Show comments in full'}\n hint={props.showComments ? 'Collapse comments back to numbered pins' : 'Show every comment beside its element'}\n pressed={props.showComments}\n disabled={none}\n onClick={props.onToggleComments}\n />\n <ToolButton\n icon=\"camera\"\n label=\"Screenshot\"\n hint=\"Capture this tab with every comment shown, then mark it up\"\n disabled={props.capturing}\n onClick={props.onScreenshot}\n />\n <ToolButton\n icon={props.redactionOn ? 'shield' : 'shieldOff'}\n label=\"Redaction settings\"\n hint={\n props.redactionOn\n ? 'Personal data is redacted from the prompt. Choose countries or add your own patterns.'\n : 'Redaction is OFF: new comments carry personal data as the page shows it.'\n }\n pressed={props.settingsOpen}\n onClick={props.onToggleSettings}\n />\n <Divider />\n <Tooltip\n label={props.panelOpen && !none ? 'Hide comment list' : 'Comment list'}\n detail={none ? 'No comments yet.' : 'Every comment, on this page and others; click one to edit it.'}\n placement=\"above\"\n >\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onTogglePanel}\n disabled={none}\n aria-pressed={props.panelOpen && !none}\n aria-label={`Comment list (${props.count})`}\n aria-describedby={describedBy}\n style={{ ...barButton(props.panelOpen && !none, false, none), gap: 6, padding: '0 10px' }}\n >\n <Icon name=\"list\" />\n <span style={{ ...FONT, color: 'inherit', fontWeight: 600 }}>{props.count}</span>\n </button>\n )}\n </Tooltip>\n <Tooltip\n label=\"Copy prompt\"\n detail={none ? 'Add a comment first.' : 'Every comment as one Markdown prompt for your coding agent.'}\n placement=\"above\"\n >\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onCopy}\n disabled={none}\n aria-describedby={describedBy}\n style={{\n ...barButton(false, false, none),\n gap: 6,\n padding: '0 12px',\n background: none ? 'transparent' : ACCENT,\n color: '#FFFFFF',\n }}\n >\n <Icon name=\"copy\" size={16} />\n <span style={{ ...FONT, color: 'inherit', fontWeight: 600 }}>Copy prompt</span>\n </button>\n )}\n </Tooltip>\n {props.onShowHint === null ? null : (\n <>\n <Divider />\n <ToolButton icon=\"help\" label=\"Show hint\" hint=\"Show the comment-mode shortcuts\" onClick={props.onShowHint} />\n </>\n )}\n <Divider />\n <ToolButton icon=\"collapse\" label=\"Collapse toolbar\" hint=\"Fold the toolbar into one button. Alt+Shift+C still works.\" onClick={props.onToggleCollapsed} />\n </div>\n );\n}\n\n/**\n * The toolbar folded away: one round button that opens it again, still showing how many\n * comments there are and, with an accent ring, that comment mode is on.\n */\nfunction CollapsedToolbar(props: ToolbarProps): ReactNode {\n const detail = [\n props.count === 0 ? 'No comments yet.' : `${props.count} comment${props.count === 1 ? '' : 's'}.`,\n props.active ? 'Comment mode is on.' : null,\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div role=\"toolbar\" aria-label=\"Dev annotator\" style={{ position: 'fixed', right: 16, bottom: 16, zIndex: Z + 2 }}>\n <Tooltip label=\"Expand toolbar\" detail={detail} placement=\"above\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onToggleCollapsed}\n aria-label=\"Expand toolbar\"\n aria-describedby={describedBy}\n style={{\n ...barButton(false, false, false),\n position: 'relative',\n width: 44,\n height: 44,\n borderRadius: 22,\n background: INK,\n boxShadow: props.active ? `0 0 0 2px ${ACCENT}, 0 6px 20px rgba(0,0,0,0.28)` : '0 6px 20px rgba(0,0,0,0.28)',\n }}\n >\n <Icon name=\"comment\" />\n {props.count === 0 ? null : (\n <span\n aria-hidden=\"true\"\n style={{\n ...FONT,\n position: 'absolute',\n top: -4,\n right: -4,\n minWidth: 18,\n height: 18,\n padding: '0 5px',\n borderRadius: 9,\n background: ACCENT,\n color: '#FFFFFF',\n fontSize: 11,\n fontWeight: 700,\n lineHeight: '18px',\n textAlign: 'center',\n boxSizing: 'border-box',\n }}\n >\n {props.count}\n </span>\n )}\n </button>\n )}\n </Tooltip>\n </div>\n );\n}\n\nfunction Divider(): ReactNode {\n return <span aria-hidden=\"true\" style={{ width: 1, height: 20, margin: '0 4px', background: 'rgba(255,255,255,0.18)' }} />;\n}\n\nfunction barButton(pressed: boolean, accent: boolean, disabled: boolean): CSSProperties {\n return {\n ...FONT,\n appearance: 'none',\n height: 36,\n minWidth: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: 0,\n border: 0,\n borderRadius: 8,\n cursor: disabled ? 'default' : 'pointer',\n opacity: disabled ? 0.4 : 1,\n color: '#FFFFFF',\n background: pressed ? (accent ? ACCENT : 'rgba(255,255,255,0.18)') : 'transparent',\n };\n}\n\nfunction ToolButton(props: {\n readonly icon: IconName;\n readonly label: string;\n readonly hint?: string;\n readonly shortcut?: string;\n readonly pressed?: boolean;\n readonly accent?: boolean;\n readonly disabled?: boolean;\n readonly onClick: () => void;\n}): ReactNode {\n return (\n <Tooltip\n label={props.label}\n {...(props.hint === undefined ? {} : { detail: props.hint })}\n {...(props.shortcut === undefined ? {} : { shortcut: keyCaps(props.shortcut) })}\n placement=\"above\"\n >\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onClick}\n disabled={props.disabled}\n aria-label={props.label}\n aria-describedby={describedBy}\n {...(props.pressed === undefined ? {} : { 'aria-pressed': props.pressed })}\n {...(props.shortcut === undefined ? {} : { 'aria-keyshortcuts': props.shortcut === 'Esc' ? 'Escape' : props.shortcut })}\n style={barButton(props.pressed === true, props.accent === true, props.disabled === true)}\n >\n <Icon name={props.icon} />\n </button>\n )}\n </Tooltip>\n );\n}\n\n/** `Alt+Shift+C` → ⌥ ⇧ C on a Mac, Alt Shift C elsewhere. */\nfunction keyCaps(shortcut: string): string[] {\n const mac = MOD_KEY === '⌘';\n const names: Readonly<Record<string, string>> = mac ? { Alt: '⌥', Shift: '⇧', Ctrl: '⌃', Meta: '⌘' } : {};\n return shortcut.split('+').map((key) => names[key] ?? key);\n}\n","import type { ReactNode } from 'react';\n\nimport { ACCENT, BUTTON, FONT, LINE, MUTED, Z } from './overlay-parts';\nimport { COUNTRIES, COUNTRY_RULES, compilePattern, type RedactionCountry, type RedactionSettings } from './redaction';\n\nconst LABEL = { ...FONT, display: 'flex', gap: 8, alignItems: 'flex-start', cursor: 'pointer' } as const;\n\n/**\n * The toolbar's redaction settings: the on/off switch, the countries whose phone and ID\n * formats are screened, and the user's own patterns, one per line. Changes apply to\n * comments made from now on; a comment already made keeps what was captured.\n */\nexport function RedactionPanel(props: {\n readonly settings: RedactionSettings;\n /** This browser has its own settings, not the app's defaults. */\n readonly customised: boolean;\n readonly onChange: (settings: RedactionSettings) => void;\n readonly onReset: () => void;\n readonly onClose: () => void;\n}): ReactNode {\n const { settings } = props;\n const off = !settings.enabled;\n const update = (patch: Partial<RedactionSettings>): void => props.onChange({ ...settings, ...patch });\n const toggleCountry = (country: RedactionCountry, on: boolean): void =>\n update({ countries: COUNTRIES.filter((each) => (each === country ? on : settings.countries.includes(each))) });\n const errors = settings.patterns.flatMap((source, index) => {\n if (source.trim() === '') return [];\n const compiled = compilePattern(source);\n return typeof compiled === 'string' ? [`Line ${index + 1}: ${compiled}`] : [];\n });\n\n return (\n <div\n role=\"dialog\"\n aria-label=\"Redaction settings\"\n style={{\n ...FONT,\n position: 'fixed',\n right: 16,\n bottom: 72,\n width: 340,\n maxHeight: '70vh',\n overflowY: 'auto',\n background: '#FFFFFF',\n border: `1px solid ${LINE}`,\n borderRadius: 10,\n boxShadow: '0 8px 24px rgba(0,0,0,0.18)',\n zIndex: Z + 2,\n boxSizing: 'border-box',\n }}\n >\n <div style={{ display: 'flex', alignItems: 'center', padding: '8px 10px', borderBottom: `1px solid ${LINE}` }}>\n <strong style={{ ...FONT, fontWeight: 600 }}>Personal data redaction</strong>\n <button type=\"button\" onClick={props.onClose} aria-label=\"Close redaction settings\" style={{ ...BUTTON, marginLeft: 'auto', padding: '2px 8px' }}>\n Close\n </button>\n </div>\n <div style={{ ...FONT, padding: 10, display: 'flex', flexDirection: 'column', gap: 12 }}>\n <label style={{ ...LABEL, alignItems: 'center' }}>\n <input\n type=\"checkbox\"\n role=\"switch\"\n checked={settings.enabled}\n aria-checked={settings.enabled}\n onChange={(event) => update({ enabled: event.target.checked })}\n />\n <span style={{ ...FONT, fontWeight: 600 }}>Redact personal data</span>\n </label>\n <p style={{ ...FONT, margin: 0, fontSize: 12, color: off ? '#B42318' : MUTED }}>\n {off\n ? 'Off: new comments carry props, state and page text exactly as the page shows them. Password fields stay hidden.'\n : 'Values under keys like phone, email, name, address, ID, password or token, and every e-mail address, become [redacted].'}\n </p>\n\n <fieldset disabled={off} style={{ ...FONT, margin: 0, padding: 0, border: 0, opacity: off ? 0.5 : 1 }}>\n <legend style={{ ...FONT, padding: 0, marginBottom: 6, fontWeight: 600 }}>Number formats</legend>\n <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>\n {COUNTRIES.map((country) => (\n <label key={country} style={LABEL}>\n <input\n type=\"checkbox\"\n checked={settings.countries.includes(country)}\n onChange={(event) => toggleCountry(country, event.target.checked)}\n style={{ marginTop: 3 }}\n />\n <span style={FONT}>\n {COUNTRY_RULES[country].label}\n <span style={{ ...FONT, display: 'block', fontSize: 11, color: MUTED }}>{COUNTRY_RULES[country].covers}</span>\n </span>\n </label>\n ))}\n </div>\n </fieldset>\n\n <fieldset disabled={off} style={{ ...FONT, margin: 0, padding: 0, border: 0, opacity: off ? 0.5 : 1 }}>\n <legend style={{ ...FONT, padding: 0, marginBottom: 4, fontWeight: 600 }}>Your own patterns</legend>\n <label htmlFor=\"agent-annotator-patterns\" style={{ ...FONT, display: 'block', fontSize: 11, color: MUTED, marginBottom: 4 }}>\n One regular expression per line, e.g. <code>INV-\\d{'{6}'}</code> or <code>/acct[0-9]+/i</code>.\n </label>\n <textarea\n id=\"agent-annotator-patterns\"\n value={settings.patterns.join('\\n')}\n onChange={(event) => update({ patterns: event.target.value === '' ? [] : event.target.value.split('\\n') })}\n rows={3}\n spellCheck={false}\n aria-invalid={errors.length > 0}\n style={{\n ...FONT,\n width: '100%',\n boxSizing: 'border-box',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: 12,\n padding: 6,\n border: `1px solid ${errors.length > 0 ? '#B42318' : LINE}`,\n borderRadius: 6,\n resize: 'vertical',\n }}\n />\n {errors.length > 0 ? (\n <ul role=\"alert\" style={{ ...FONT, margin: '4px 0 0', paddingLeft: 16, fontSize: 11, color: '#B42318' }}>\n {errors.map((error) => (\n <li key={error}>{error} — skipped</li>\n ))}\n </ul>\n ) : null}\n </fieldset>\n\n <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>\n <span style={{ ...FONT, flex: 1, fontSize: 11, color: MUTED }}>\n Applies to comments made from now on. Saved in this browser.\n </span>\n <button\n type=\"button\"\n onClick={props.onReset}\n disabled={!props.customised}\n style={{ ...BUTTON, color: props.customised ? ACCENT : MUTED, cursor: props.customised ? 'pointer' : 'default' }}\n >\n Use app defaults\n </button>\n </div>\n </div>\n </div>\n );\n}\n","/** The overlay's own DOM, which is never a thing to comment on. */\nexport const OWN_SELECTOR = '[data-dev-annotator]';\n\nexport interface Rect {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Elements picked by one area selection; more says nothing an agent can act on. */\nconst MAX_AREA_ELEMENTS = 8;\n\nfunction contains(outer: Rect, inner: DOMRect): boolean {\n return (\n inner.left >= outer.x &&\n inner.top >= outer.y &&\n inner.right <= outer.x + outer.width &&\n inner.bottom <= outer.y + outer.height\n );\n}\n\nfunction holds(rect: DOMRect, area: Rect): boolean {\n return rect.left <= area.x && rect.top <= area.y && rect.right >= area.x + area.width && rect.bottom >= area.y + area.height;\n}\n\n/**\n * Whether an element is page content worth naming: not the overlay's own, not decoration\n * hidden from assistive tech, not a shape inside an SVG (the <svg> stands for its parts).\n */\nfunction isContent(element: Element): boolean {\n if (element.closest(OWN_SELECTOR) !== null) return false;\n if (element.closest('[aria-hidden=\"true\"]') !== null) return false;\n return !(element instanceof SVGElement) || element instanceof SVGSVGElement;\n}\n\nfunction commonAncestor(elements: readonly Element[]): Element | null {\n const [first, ...rest] = elements;\n let node: Element | null = first ?? null;\n while (node !== null && !rest.every((element) => node?.contains(element))) node = node.parentElement;\n return node;\n}\n\n/** `start`, or its nearest ancestor, that covers the whole area; `body` at worst. */\nfunction coveringAncestor(start: Element | null, area: Rect, body: Element): Element {\n let node = start;\n while (node !== null && node !== body && !holds(node.getBoundingClientRect(), area)) node = node.parentElement;\n return node ?? body;\n}\n\n/**\n * What a dragged area covers, in viewport coordinates: the OUTERMOST content elements lying\n * wholly inside it, in document order, and the container of the area. The container is\n * where the content lives — the nearest common ancestor of what is inside, widened until\n * it covers the area — never merely the smallest box around it: a background pattern or\n * an overlay laid across the section covers the area too, and is not what was pointed at.\n * An empty area takes the content element under its centre instead.\n */\nexport function elementsInArea(doc: Document, area: Rect): { container: Element; inside: Element[] } {\n const inside: Element[] = [];\n for (const element of Array.from(doc.body.querySelectorAll('*'))) {\n if (!isContent(element)) continue;\n const rect = element.getBoundingClientRect();\n if (rect.width === 0 || rect.height === 0) continue;\n if (contains(area, rect) && !inside.some((kept) => kept.contains(element))) inside.push(element);\n }\n\n let start: Element | null;\n if (inside.length > 0) {\n const common = commonAncestor(inside);\n start = inside.length === 1 ? (common?.parentElement ?? null) : common;\n } else {\n const centre = { x: area.x + area.width / 2, y: area.y + area.height / 2 };\n const under = typeof doc.elementsFromPoint === 'function' ? doc.elementsFromPoint(centre.x, centre.y) : [];\n start = under.find(isContent) ?? null;\n }\n return { container: coveringAncestor(start, area, doc.body), inside: inside.slice(0, MAX_AREA_ELEMENTS) };\n}\n\n/**\n * Freezes what is moving, so a toast, a spinner or a transition can be commented on in\n * the state it shows for a second. Returns the resume function, which restarts only what\n * this call paused.\n */\nexport function pauseMotion(doc: Document): () => void {\n const animations =\n typeof doc.getAnimations === 'function'\n ? doc.getAnimations().filter((animation) => animation.playState === 'running')\n : [];\n const videos = Array.from(doc.querySelectorAll('video')).filter((video) => !video.paused);\n for (const animation of animations) animation.pause();\n for (const video of videos) video.pause();\n return () => {\n for (const animation of animations) animation.play();\n for (const video of videos) void video.play().catch(() => undefined);\n };\n}\n","import type { ElementCapture } from './capture';\nimport { REDACTED } from './redaction';\nimport type { Rect } from './page-tools';\nimport type { SourceLocation } from './stack';\n\n/**\n * What one comment is about:\n * - `element`: one clicked element;\n * - `text`: a passage selected inside an element (the element is the target);\n * - `group`: several elements picked with Cmd/Ctrl+click, one request for all of them;\n * - `area`: a dragged region — the first target is the element holding the region, the\n * rest are the elements wholly inside it (none, for a comment on empty space).\n */\nexport type AnnotationKind = 'element' | 'text' | 'group' | 'area';\n\nexport interface Annotation {\n readonly id: string;\n readonly kind: AnnotationKind;\n readonly comment: string;\n readonly createdAt: string;\n readonly targets: readonly ElementCapture[];\n /** `text` only: the selected passage, screened for personal data. */\n readonly selectedText?: string;\n /** `area` only: the dragged region in viewport pixels at the time of the comment. */\n readonly area?: Rect;\n /**\n * `area` only: the same region relative to the container's top-left corner, so it can be\n * drawn back over the page after scrolling or a reload. Not part of the prompt.\n */\n readonly areaInContainer?: Rect;\n /**\n * `false` when the comment was made with redaction switched off, so its captures hold\n * the page's data as it was. Comments saved before the setting existed were screened.\n */\n readonly redacted?: boolean;\n}\n\nexport interface PromptOptions {\n /** Shown in the heading: which app the comments are about. */\n readonly appName: string;\n /** The app's directory from the repo root (`apps/web`); prefixes every source path. */\n readonly appDir?: string | undefined;\n /** Include the props/state snapshots. */\n readonly includeData: boolean;\n readonly now: Date;\n}\n\n/** Past this, a component's data block is printed compact, then cut. */\nconst DATA_BLOCK_MAX = 3000;\n\n/**\n * The Markdown handed to the coding agent. It is written FOR the agent: what to do comes\n * first, then one section per comment with the facts it needs to find the code without\n * searching — the source line before the selector, the selector before the text.\n */\nexport function buildPrompt(annotations: readonly Annotation[], options: PromptOptions): string {\n const first = annotations[0]?.targets[0]?.page;\n const origin = first === undefined ? '' : new URL(first.url).origin;\n const lines: string[] = [\n `# Change requests: ${options.appName} (${annotations.length} ${annotations.length === 1 ? 'comment' : 'comments'})`,\n '',\n `Dev environment ${origin}, recorded ${formatTime(options.now)}.` +\n (options.appDir ? ` The app lives in \\`${options.appDir}\\`; file paths are from the repo root.` : ''),\n '',\n 'Work through the comments below one by one. Each names the selected element, where its JSX is in the source, ' +\n 'the components around it' +\n (options.includeData ? ', and their props/state when the comment was made' : '') +\n '. The element\\'s JSX location is exact; a component\\'s \"rendered at\" location may point at an earlier render ' +\n 'branch when React reused the component, so check it against the code. ' +\n 'Open the source file before editing. If the line numbers have drifted, search by selector, element text and component name. ' +\n redactionNote(annotations) +\n 'When done, summarise the changes by comment number.',\n ];\n annotations.forEach((annotation, index) => {\n lines.push('', '---', '', ...section(annotation, index + 1, options));\n });\n return `${lines.join('\\n')}\\n`;\n}\n\n/** Claims only what is true: comments made with redaction off are named as such. */\nfunction redactionNote(annotations: readonly Annotation[]): string {\n const raw = annotations.flatMap((annotation, index) => (annotation.redacted === false ? [index + 1] : []));\n if (raw.length === annotations.length && raw.length > 0) return '';\n const except = raw.length === 0 ? '' : ` (except in comment${raw.length === 1 ? '' : 's'} ${raw.join(', ')}, recorded with redaction off)`;\n return `Personal data has been replaced with \\`${REDACTED}\\`${except}; never treat it as a real value. `;\n}\n\nconst KIND_NOTE: Readonly<Record<AnnotationKind, string | null>> = {\n element: null,\n text: null,\n group: 'The comment applies to ALL of the elements below.',\n area: 'A comment on an area of the screen: the first element contains the area, the others lie wholly inside it.',\n};\n\nfunction section(annotation: Annotation, number: number, options: PromptOptions): string[] {\n const page = annotation.targets[0]?.page;\n const out: string[] = [\n `## ${number}. ${headline(annotation.comment)}`,\n '',\n ...annotation.comment.split('\\n').map((line) => `> ${line}`),\n '',\n ];\n if (page !== undefined) {\n out.push(`- **Page:** \\`${page.pathname}${page.search}\\`${page.title ? `, title \"${page.title}\"` : ''}`);\n }\n const note = KIND_NOTE[annotation.kind];\n if (note !== null) out.push(`- **Kind:** ${note}`);\n if (annotation.selectedText !== undefined) out.push(`- **Selected text:** \"${annotation.selectedText}\"`);\n if (annotation.area !== undefined) {\n const { area } = annotation;\n out.push(`- **Area:** ${area.width}×${area.height} at (${area.x}, ${area.y}) in the viewport`);\n }\n\n if (annotation.kind !== 'area' && annotation.targets.length === 1 && annotation.targets[0] !== undefined) {\n out.push(...targetLines(annotation.targets[0], options));\n out.push(...dataBlocks(annotation.targets[0], options));\n return out;\n }\n annotation.targets.forEach((target, index) => {\n const label = annotation.kind !== 'area' ? `Element ${index + 1}` : index === 0 ? 'Container' : `Inside the area ${index}`;\n out.push('', `### ${number}.${index + 1} ${label}`, '', ...targetLines(target, options));\n out.push(...dataBlocks(target, options));\n });\n if (annotation.kind === 'area' && annotation.targets.length === 1) {\n out.push('', '_No element lies wholly inside the area: it is empty space within the container._');\n }\n return out;\n}\n\nfunction targetLines(capture: ElementCapture, options: PromptOptions): string[] {\n const { element } = capture;\n const out: string[] = [`- **Element:** \\`${element.opening}\\`${element.text ? `, text \"${element.text}\"` : ''}`];\n if (element.accessibility !== null) out.push(`- **Role (a11y):** ${element.accessibility}`);\n if (element.section !== null) out.push(`- **Section:** ${element.section}`);\n if (element.nearby !== null) out.push(`- **Nearby:** ${element.nearby}`);\n if (element.value !== null) out.push(`- **Current input value:** \"${element.value}\"`);\n out.push(`- **Selector:** \\`${element.selector}\\``);\n out.push(`- **Element JSX:** ${capture.jsx === null ? 'could not be located' : location(capture.jsx, options.appDir)}`);\n if (capture.components.length > 0) {\n const chain = capture.components.map((component) =>\n component.renderedAt === null\n ? `\\`${component.name}\\``\n : `\\`${component.name}\\` (rendered at ${location(component.renderedAt, options.appDir)})`,\n );\n out.push(`- **Components, nearest first:** ${chain.join(' ← ')}`);\n }\n out.push(\n `- **Position:** ${element.rect.width}×${element.rect.height} at (${element.rect.x}, ${element.rect.y}); ` +\n `viewport ${capture.viewport.width}×${capture.viewport.height} @${capture.viewport.devicePixelRatio}x`,\n );\n const styles = Object.entries(element.styles);\n if (styles.length > 0) out.push(`- **Current style:** ${styles.map(([key, value]) => `${key}: ${value}`).join('; ')}`);\n return out;\n}\n\nfunction dataBlocks(capture: ElementCapture, options: PromptOptions): string[] {\n if (!options.includeData) return [];\n // A component with no props and no state has nothing to tell the agent.\n const telling = capture.data.filter((block) => !isEmpty(block.props) || !isEmpty(block.state));\n return telling.flatMap((block) => [\n '',\n `**Data of \\`${block.component}\\`** (state in hook call order):`,\n '',\n '```json',\n dataJson(block),\n '```',\n ]);\n}\n\nfunction dataJson(block: ElementCapture['data'][number]): string {\n const value = { props: block.props, state: block.state };\n const pretty = JSON.stringify(value, null, 2);\n if (pretty.length <= DATA_BLOCK_MAX) return pretty;\n const compact = JSON.stringify(value);\n return compact.length <= DATA_BLOCK_MAX ? compact : `${compact.slice(0, DATA_BLOCK_MAX)} … (truncated)`;\n}\n\nfunction location(source: SourceLocation, appDir: string | undefined): string {\n const file = repoPath(source.file, appDir);\n const position = source.column === null ? `${source.line}` : `${source.line}:${source.column}`;\n return `\\`${file}:${position}\\`${source.mapped ? '' : ' (line in the bundled output, approximate)'}`;\n}\n\n/**\n * `src/x.tsx` with `apps/web` → `apps/web/src/x.tsx`; `../../node_modules/…`\n * collapses; an absolute path (Turbopack) is cut back to the repo root at the app directory.\n */\nexport function repoPath(file: string, appDir: string | undefined): string {\n if (!appDir || /^[a-z]+:/i.test(file)) return file;\n if (file.startsWith('/')) {\n const at = file.lastIndexOf(`/${appDir}/`);\n return at === -1 ? file : file.slice(at + 1);\n }\n const parts: string[] = [];\n for (const part of `${appDir}/${file}`.split('/')) {\n if (part === '' || part === '.') continue;\n if (part === '..') parts.pop();\n else parts.push(part);\n }\n return parts.join('/');\n}\n\nfunction headline(comment: string): string {\n const first = comment.trim().split('\\n')[0] ?? '';\n return first.length <= 70 ? first : `${first.slice(0, 70)}…`;\n}\n\nfunction formatTime(date: Date): string {\n const pad = (n: number): string => String(n).padStart(2, '0');\n return (\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +\n `${pad(date.getHours())}:${pad(date.getMinutes())}`\n );\n}\n\nfunction isEmpty(snapshot: ElementCapture['data'][number]['props']): boolean {\n if (snapshot === null) return true;\n if (Array.isArray(snapshot)) return snapshot.length === 0;\n return typeof snapshot === 'object' && Object.keys(snapshot).length === 0;\n}\n","/**\n * Per-browser preferences of the tool (a hidden hint, a tip already learned), in\n * localStorage. Storage can be absent or throw (private mode, blocked site data): reads\n * then give the default and writes last until the page reloads.\n */\n\nexport function readFlag(key: string): boolean {\n try {\n return window.localStorage.getItem(key) === '1';\n } catch {\n return false;\n }\n}\n\nexport function writeFlag(key: string, value: boolean): void {\n try {\n if (value) window.localStorage.setItem(key, '1');\n else window.localStorage.removeItem(key);\n } catch {\n // The preference lasts until reload; nothing to report.\n }\n}\n","/**\n * Taking the screenshot, and getting it out of the browser.\n *\n * The capture is the tab itself, through the Screen Capture API: the browser asks once\n * (\"share this tab?\") and hands back real pixels — canvases, videos, cross-origin images\n * and fonts exactly as rendered, which a DOM-to-image library can only approximate. Between\n * the permission and the grab, `prepare` gets the page ready: the tool's own controls away,\n * every comment shown in full.\n */\n\nexport type ScreenCapture = (prepare: () => Promise<void>) => Promise<HTMLCanvasElement>;\n\n/** The browser asked, and the person said no (or closed the picker). */\nexport class CaptureCancelled extends Error {\n constructor() {\n super('Screen capture was cancelled');\n this.name = 'CaptureCancelled';\n }\n}\n\nexport const captureTab: ScreenCapture = async (prepare) => {\n const media = typeof navigator === 'undefined' ? undefined : navigator.mediaDevices;\n if (media?.getDisplayMedia === undefined) {\n throw new Error('This browser cannot capture the tab (it needs the Screen Capture API, on localhost or https).');\n }\n const ratio = window.devicePixelRatio || 1;\n let stream: MediaStream;\n try {\n stream = await media.getDisplayMedia({\n video: {\n displaySurface: 'browser',\n width: { ideal: Math.round(window.innerWidth * ratio) },\n height: { ideal: Math.round(window.innerHeight * ratio) },\n // Not part of the DOM lib yet; Chrome honours it.\n ...{ cursor: 'never' },\n },\n audio: false,\n // Chrome: offer this tab first, as a one-click \"Allow\".\n ...{ preferCurrentTab: true, selfBrowserSurface: 'include', surfaceSwitching: 'exclude', monitorTypeSurfaces: 'exclude' },\n } as DisplayMediaStreamOptions);\n } catch (error) {\n if (error instanceof DOMException && error.name === 'NotAllowedError') throw new CaptureCancelled();\n throw error;\n }\n const video = document.createElement('video');\n try {\n video.muted = true;\n video.playsInline = true;\n video.srcObject = stream;\n await video.play();\n await prepare();\n await freshFrame(video);\n const canvas = document.createElement('canvas');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n canvas.getContext('2d')?.drawImage(video, 0, 0, canvas.width, canvas.height);\n return canvas;\n } finally {\n for (const track of stream.getTracks()) track.stop();\n video.srcObject = null;\n }\n};\n\n/** Waits until the stream shows what the page looks like NOW, not before `prepare`. */\nasync function freshFrame(video: HTMLVideoElement): Promise<void> {\n if (typeof video.requestVideoFrameCallback === 'function') {\n for (let frame = 0; frame < 3; frame++) {\n await Promise.race([\n new Promise<void>((resolve) => video.requestVideoFrameCallback(() => resolve())),\n // A static page may produce no new frame at all; then the current one is current.\n new Promise<void>((resolve) => window.setTimeout(resolve, 250)),\n ]);\n }\n return;\n }\n await new Promise<void>((resolve) => window.setTimeout(resolve, 400));\n}\n\nexport function canvasBlob(canvas: HTMLCanvasElement): Promise<Blob> {\n return new Promise((resolve, reject) => {\n canvas.toBlob((blob) => (blob === null ? reject(new Error('The image could not be encoded')) : resolve(blob)), 'image/png');\n });\n}\n\nexport async function copyImage(canvas: HTMLCanvasElement): Promise<void> {\n if (typeof ClipboardItem === 'undefined' || navigator.clipboard?.write === undefined) {\n throw new Error('This browser cannot put an image on the clipboard; use Save instead.');\n }\n // The promise form keeps the user activation alive while the PNG encodes (Safari needs it).\n await navigator.clipboard.write([new ClipboardItem({ 'image/png': canvasBlob(canvas) })]);\n}\n\nexport async function saveImage(canvas: HTMLCanvasElement, fileName: string): Promise<void> {\n const url = URL.createObjectURL(await canvasBlob(canvas));\n const link = document.createElement('a');\n link.href = url;\n link.download = fileName;\n link.setAttribute('data-dev-annotator', '');\n document.body.appendChild(link);\n link.click();\n link.remove();\n window.setTimeout(() => URL.revokeObjectURL(url), 1000);\n}\n\n/** `web-orders-7-2026-11-20-2350.png`: the app, the page and the minute. */\nexport function shotFileName(appName: string, pathname: string, now: Date): string {\n const pad = (n: number): string => String(n).padStart(2, '0');\n const page = pathname\n .split('/')\n .filter(Boolean)\n .join('-')\n .replace(/[^a-z0-9-]+/gi, '')\n .slice(0, 40);\n const stamp = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}`;\n return `${[appName, page || 'home', stamp].join('-')}.png`;\n}\n","import {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n} from 'react';\n\nimport { CalloutTip } from './callout-tip';\nimport { readFlag, writeFlag } from './flags';\nimport { Icon, type IconName } from './icons';\nimport { ACCENT, FONT, INK, Z, type Notice } from './overlay-parts';\nimport {\n calloutLayout,\n canvasMeasure,\n COLORS,\n edgeColor,\n expand,\n outputFrame,\n union,\n hitTest,\n isTrivial,\n paint,\n tailHandleRadius,\n textColorOn,\n translate,\n normalized,\n type Bounds,\n type Mark,\n type Measure,\n type Point,\n type Tool,\n type Weight,\n} from './screenshot-draw';\nimport { copyImage, saveImage } from './screenshot';\nimport { MOD_KEY, Tooltip } from './tooltip';\n\ntype EditorTool = Tool | 'select' | 'crop';\n\nconst TOOLS: ReadonlyArray<{\n readonly tool: EditorTool;\n readonly icon: IconName;\n readonly label: string;\n readonly key: string;\n readonly detail: string;\n}> = [\n { tool: 'select', icon: 'select', label: 'Select & move', key: 'V', detail: 'Click a mark to select it, drag to move it, Delete to remove it. Double-click text to edit it.' },\n { tool: 'arrow', icon: 'arrow', label: 'Arrow', key: 'A', detail: 'Hold Shift to snap to 45°.' },\n { tool: 'rect', icon: 'rect', label: 'Rectangle', key: 'R', detail: 'Hold Shift for a square.' },\n { tool: 'highlight', icon: 'highlight', label: 'Highlight', key: 'H', detail: 'A translucent marker over an area.' },\n { tool: 'pen', icon: 'pen', label: 'Pen', key: 'P', detail: 'Draw freehand.' },\n {\n tool: 'text',\n icon: 'text',\n label: 'Callout',\n key: 'T',\n detail: 'Drag from what you point at to where the text goes: one box with a tail. A click gives a box without one. Enter places it, Shift+Enter adds a line.',\n },\n { tool: 'ruler', icon: 'ruler', label: 'Ruler', key: 'M', detail: 'Measure in the page’s own pixels. Hold Shift to keep it straight.' },\n { tool: 'crop', icon: 'crop', label: 'Crop', key: 'C', detail: 'Drag the part to keep. Undo, or Reset crop, brings the rest back.' },\n { tool: 'pixelate', icon: 'pixelate', label: 'Pixelate', key: 'B', detail: 'Hide personal data before the image leaves this machine.' },\n];\n\nconst WEIGHTS: ReadonlyArray<{ readonly weight: Weight; readonly label: string; readonly dot: number }> = [\n { weight: 1, label: 'Thin', dot: 4 },\n { weight: 2, label: 'Medium', dot: 7 },\n { weight: 3, label: 'Thick', dot: 10 },\n];\n\n/** Zoom stops, as a fraction of the page's own size (100% = as it looked in the tab). */\nconst ZOOM_STOPS = [0.1, 0.25, 0.33, 0.5, 0.67, 0.75, 1, 1.25, 1.5, 2, 3, 4, 6, 8] as const;\nconst MIN_ZOOM = 0.1;\nconst MAX_ZOOM = 8;\n/** Room around the image inside the scroll area, in CSS pixels. */\nconst PAD = 24;\n/** How near, in CSS pixels, a click must land to pick a mark. */\nconst PICK_SLACK = 6;\nconst NO_MARKS: readonly Mark[] = [];\n/** Set once the callout drag is learned: the tip under the Callout button stops showing. */\nconst CALLOUT_TIP_KEY = 'agent-annotator:callout-tip-done';\n\n/** What undo steps through: the marks, and the crop (`null` = the whole capture). */\ninterface Doc {\n readonly marks: readonly Mark[];\n readonly crop: Bounds | null;\n}\nconst EMPTY_DOC: Doc = { marks: NO_MARKS, crop: null };\n\nlet measureContext: CanvasRenderingContext2D | null | undefined;\n/** Text measuring on a context of its own, so rendering never reads the visible canvas. */\nfunction textMeasure(): Measure {\n if (measureContext === undefined) {\n measureContext = typeof document === 'undefined' ? null : document.createElement('canvas').getContext('2d');\n }\n return canvasMeasure(measureContext ?? null);\n}\n\ninterface History {\n readonly past: readonly Doc[];\n readonly present: Doc;\n readonly future: readonly Doc[];\n}\n\ninterface TextDraft {\n /** The centre of the callout box, in image pixels. */\n readonly at: Point;\n /** What the callout points at, if it has a tail. */\n readonly tail?: Point;\n readonly value: string;\n readonly color: string;\n readonly weight: Weight;\n /** The text mark being edited; `null` for new text. */\n readonly editing: number | null;\n}\n\ninterface CropDraft {\n readonly from: Point;\n readonly to: Point;\n}\n\ninterface Drag {\n /** `tail` drags only a callout's tail tip; `move` drags the mark (a callout's box). */\n readonly mode: 'move' | 'tail';\n readonly index: number;\n readonly origin: Point;\n readonly original: Mark;\n readonly moved: Mark;\n}\n\n/**\n * Marks up a screenshot, Shottr-style: arrows, boxes, highlights, freehand, text, and\n * pixelation to hide what must not leave the machine; every mark can be selected, moved,\n * recoloured, restyled or deleted afterwards. Zoom with the bar, ⌘± or ⌘+scroll; hold Space\n * and drag to pan. Copy puts the PNG on the clipboard, Save downloads it. Only the Close\n * button closes, and it asks first when there are marks not yet copied or saved.\n */\nexport function ScreenshotEditor(props: {\n readonly image: HTMLCanvasElement;\n readonly fileName: string;\n readonly onClose: () => void;\n readonly onNotice: (notice: Notice) => void;\n}): ReactNode {\n const { image, fileName, onClose, onNotice } = props;\n const ratio = typeof window === 'undefined' ? 1 : window.devicePixelRatio || 1;\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const areaRef = useRef<HTMLDivElement | null>(null);\n const customColorRef = useRef<HTMLInputElement | null>(null);\n\n const [history, setHistory] = useState<History>({ past: [], present: EMPTY_DOC, future: [] });\n const marks = history.present.marks;\n const crop = history.present.crop;\n const view: Bounds = crop ?? { x: 0, y: 0, width: image.width, height: image.height };\n const [saved, setSaved] = useState<Doc>(EMPTY_DOC);\n const [cropDraft, setCropDraftState] = useState<CropDraft | null>(null);\n const [tool, setTool] = useState<EditorTool>('arrow');\n const [color, setColor] = useState<string>(COLORS[0]);\n const [weight, setWeight] = useState<Weight>(2);\n const [selectedRaw, setSelected] = useState<number | null>(null);\n const selected = selectedRaw !== null && selectedRaw < marks.length ? selectedRaw : null;\n const [drawing, setDrawingState] = useState<Mark | null>(null);\n const [drag, setDragState] = useState<Drag | null>(null);\n // A gesture lives in refs as well as state. Pointer events can arrive faster than React\n // renders, and a handler reading state would then see the gesture as it was a frame ago —\n // a quick drag would end as a click. Handlers read the refs; rendering reads the state.\n const drawingRef = useRef<Mark | null>(null);\n const dragRef = useRef<Drag | null>(null);\n const cropRef = useRef<CropDraft | null>(null);\n const setDrawing = (next: Mark | null): void => {\n drawingRef.current = next;\n setDrawingState(next);\n };\n const setDrag = (next: Drag | null): void => {\n dragRef.current = next;\n setDragState(next);\n };\n const setCropDraft = (next: CropDraft | null): void => {\n cropRef.current = next;\n setCropDraftState(next);\n };\n const [text, setText] = useState<TextDraft | null>(null);\n const [hovering, setHovering] = useState(false);\n const [spaceHeld, setSpaceHeld] = useState(false);\n const [panning, setPanning] = useState(false);\n const panRef = useRef<{ x: number; y: number; left: number; top: number } | null>(null);\n const [confirmClose, setConfirmClose] = useState(false);\n const dialogRef = useRef<HTMLDivElement | null>(null);\n const [tipDone, setTipDone] = useState(() => readFlag(CALLOUT_TIP_KEY));\n const [tipNudge, setTipNudge] = useState(false);\n const [tipAt, setTipAt] = useState<{ left: number; top: number } | null>(null);\n const learnCallout = (): void => {\n setTipDone(true);\n writeFlag(CALLOUT_TIP_KEY, true);\n };\n const showTip = tool === 'text' && !tipDone;\n // The tip hangs under the Callout button, wherever the bar has wrapped it to.\n useLayoutEffect(() => {\n if (!showTip) return;\n const dialog = dialogRef.current;\n const button = dialog?.querySelector('[aria-label=\"Callout\"]');\n if (dialog === null || dialog === undefined || button === null || button === undefined) return;\n const box = button.getBoundingClientRect();\n const frame = dialog.getBoundingClientRect();\n setTipAt({ left: Math.max(8, box.left - frame.left + box.width / 2 - 23), top: box.bottom - frame.top + 10 });\n }, [showTip]);\n\n // Zoom: `null` follows the window (\"fit\"); a number is CSS pixels per image pixel.\n const [zoom, setZoom] = useState<number | null>(null);\n // The scroll area's size, for \"fit\" and for a board that fills it.\n const [areaSize, setAreaSize] = useState<{ readonly width: number; readonly height: number }>({ width: 0, height: 0 });\n /** What Copy and Save will produce, from the marks already placed. */\n const frame = outputFrame(view, marks, image.width, textMeasure());\n const fitScale =\n areaSize.width > 2 * PAD && areaSize.height > 2 * PAD\n ? // Never blow a capture up past the size it had on the page.\n Math.min((areaSize.width - 2 * PAD) / frame.width, (areaSize.height - 2 * PAD) / frame.height, 1 / ratio)\n : 1 / ratio;\n const scale = zoom ?? fitScale;\n /**\n * The board: the whole canvas, in image pixels. It fills the scroll area, centred on the\n * frame, so marks can go anywhere around the picture; it grows past the area only when\n * the frame does. Sized from placed marks only, so it never shifts under a drag.\n */\n const board = boardAround(expand(frame, 12 / scale), view, areaSize, scale);\n /** The colour the frame is filled with where the capture does not reach. */\n const [background] = useState(() => edgeColor(image));\n const anchorRef = useRef<{ image: Point; client: Point } | null>(null);\n\n const dirty = history.present !== saved && (marks.length > 0 || crop !== null);\n\n // ---- history ----------------------------------------------------------------------\n const commitDoc = (change: (doc: Doc) => Doc): void =>\n setHistory((current) => ({ past: [...current.past, current.present], present: change(current.present), future: [] }));\n const commit = (next: readonly Mark[]): void => commitDoc((doc) => ({ ...doc, marks: next }));\n const commitCrop = (next: Bounds | null): void => {\n commitDoc((doc) => ({ ...doc, crop: next }));\n setZoom(null);\n };\n const undo = (): void =>\n setHistory((current) =>\n current.past.length === 0\n ? current\n : { past: current.past.slice(0, -1), present: current.past[current.past.length - 1] ?? EMPTY_DOC, future: [current.present, ...current.future] },\n );\n const redo = (): void =>\n setHistory((current) =>\n current.future.length === 0\n ? current\n : { past: [...current.past, current.present], present: current.future[0] ?? EMPTY_DOC, future: current.future.slice(1) },\n );\n const replaceAt = (index: number, mark: Mark | null): void =>\n commit(mark === null ? marks.filter((_, at) => at !== index) : marks.map((kept, at) => (at === index ? mark : kept)));\n\n // ---- painting -----------------------------------------------------------------------\n let visible = drag === null ? marks : marks.map((mark, at) => (at === drag.index ? drag.moved : mark));\n // Text being typed is painted live on the canvas; the input over it only carries the caret.\n if (text !== null) {\n const live: Mark = {\n tool: 'text',\n at: text.at,\n text: text.value,\n color: text.color,\n weight: text.weight,\n ...(text.tail === undefined ? {} : { tail: text.tail }),\n };\n visible = text.editing === null ? [...visible, live] : visible.map((mark, at) => (at === text.editing ? live : mark));\n }\n if (drawing !== null) visible = [...visible, drawing];\n const outline = text === null && drawing === null ? selected : null;\n // The frame follows the marks live, so a mark drawn past the edge shows the picture grow.\n const liveFrame = outputFrame(view, visible, image.width, textMeasure());\n const paintBase = { view: board, image: view, frame: liveFrame, background, backdrop: '#0E0E0E', pixelRatio: ratio };\n const cropBox = cropDraft === null ? null : clampTo(normalized(cropDraft.from, cropDraft.to), view);\n useEffect(() => {\n const canvas = canvasRef.current;\n if (canvas !== null) paint(canvas, image, visible, { ...paintBase, selected: outline, accent: '#0091FF', cropPreview: cropBox });\n });\n\n // ---- zoom -----------------------------------------------------------------------------\n useEffect(() => {\n const area = areaRef.current;\n if (area === null) return undefined;\n const measure = (): void => setAreaSize({ width: area.clientWidth, height: area.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') {\n window.addEventListener('resize', measure);\n return () => window.removeEventListener('resize', measure);\n }\n const observer = new ResizeObserver(measure);\n observer.observe(area);\n return () => observer.disconnect();\n }, []);\n\n // Keep the image point that was under the cursor (or the centre) under it after zooming.\n useLayoutEffect(() => {\n const anchor = anchorRef.current;\n anchorRef.current = null;\n const canvas = canvasRef.current;\n const area = areaRef.current;\n if (anchor === null || canvas === null || area === null) return;\n const rect = canvas.getBoundingClientRect();\n area.scrollLeft += rect.left + (anchor.image.x - board.x) * scale - anchor.client.x;\n area.scrollTop += rect.top + (anchor.image.y - board.y) * scale - anchor.client.y;\n }, [scale, board.x, board.y]);\n\n const zoomTo = (nextScale: number | null, client?: Point): void => {\n const canvas = canvasRef.current;\n const area = areaRef.current;\n if (canvas !== null && area !== null) {\n const rect = canvas.getBoundingClientRect();\n const box = area.getBoundingClientRect();\n const at = client ?? { x: box.left + box.width / 2, y: box.top + box.height / 2 };\n if (scale > 0) anchorRef.current = { image: { x: board.x + (at.x - rect.left) / scale, y: board.y + (at.y - rect.top) / scale }, client: at };\n }\n setZoom(nextScale === null ? null : Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, nextScale * ratio)) / ratio);\n };\n const percent = scale * ratio;\n const zoomStep = (direction: 1 | -1): void => {\n const next =\n direction === 1\n ? ZOOM_STOPS.find((stop) => stop > percent * 1.01)\n : [...ZOOM_STOPS].reverse().find((stop) => stop < percent * 0.99);\n if (next !== undefined) zoomTo(next / ratio);\n };\n\n // ⌘/Ctrl + wheel (and trackpad pinch, which arrives as one) zooms at the cursor; a plain\n // wheel scrolls. Registered by hand: React's wheel listener is passive and cannot cancel.\n const wheelRef = useRef<(event: WheelEvent) => void>(() => undefined);\n const onWheel = (event: WheelEvent): void => {\n if (!event.ctrlKey && !event.metaKey) return;\n event.preventDefault();\n zoomTo(scale * Math.exp(-event.deltaY * 0.01), { x: event.clientX, y: event.clientY });\n };\n useEffect(() => {\n const area = areaRef.current;\n if (area === null) return undefined;\n const onWheel = (event: WheelEvent): void => wheelRef.current(event);\n area.addEventListener('wheel', onWheel, { passive: false });\n return () => area.removeEventListener('wheel', onWheel);\n }, []);\n\n // ---- pointer ----------------------------------------------------------------------------\n const measureText = textMeasure;\n const pick = (point: Point, only?: Mark['tool']): number | null => {\n const index = hitTest(marks, point, image.width, measureText(), PICK_SLACK / scale);\n return index !== null && (only === undefined || marks[index]?.tool === only) ? index : null;\n };\n const imagePoint = (event: { clientX: number; clientY: number }): Point => {\n const rect = canvasRef.current?.getBoundingClientRect();\n if (rect === undefined || scale <= 0) return { x: 0, y: 0 };\n return { x: board.x + (event.clientX - rect.left) / scale, y: board.y + (event.clientY - rect.top) / scale };\n };\n\n const commitText = (): void => {\n if (text === null) return;\n const value = text.value.replace(/\\s+$/, '');\n if (text.editing !== null) {\n const original = marks[text.editing];\n if (original?.tool === 'text') replaceAt(text.editing, value.trim() === '' ? null : { ...original, text: value });\n } else if (value.trim() !== '') {\n commit([\n ...marks,\n { tool: 'text', at: text.at, text: value, color: text.color, weight: text.weight, ...(text.tail === undefined ? {} : { tail: text.tail }) },\n ]);\n }\n setText(null);\n };\n const editText = (index: number): void => {\n const mark = marks[index];\n if (mark?.tool !== 'text') return;\n setSelected(null);\n setText({ at: mark.at, value: mark.text, color: mark.color, weight: mark.weight, editing: index, ...(mark.tail === undefined ? {} : { tail: mark.tail }) });\n };\n\n const onPointerDown = (event: ReactPointerEvent<HTMLCanvasElement>): void => {\n if (event.button === 1 || (event.button === 0 && spaceHeld)) {\n const area = areaRef.current;\n if (area === null) return;\n event.preventDefault();\n event.currentTarget.setPointerCapture(event.pointerId);\n panRef.current = { x: event.clientX, y: event.clientY, left: area.scrollLeft, top: area.scrollTop };\n setPanning(true);\n return;\n }\n if (event.button !== 0) return;\n const point = imagePoint(event);\n if (tool === 'select') {\n // The tail tip of the selected callout is a grip of its own.\n const current = selected === null ? undefined : marks[selected];\n if (selected !== null && current?.tool === 'text' && current.tail !== undefined) {\n const grip = tailHandleRadius(image.width) + PICK_SLACK / scale;\n if (Math.hypot(point.x - current.tail.x, point.y - current.tail.y) <= grip) {\n event.currentTarget.setPointerCapture(event.pointerId);\n setDrag({ mode: 'tail', index: selected, origin: point, original: current, moved: current });\n return;\n }\n }\n const index = pick(point);\n select(index);\n const mark = index === null ? undefined : marks[index];\n if (index !== null && mark !== undefined) {\n event.currentTarget.setPointerCapture(event.pointerId);\n setDrag({ mode: 'move', index, origin: point, original: mark, moved: mark });\n }\n return;\n }\n if (tool === 'crop') {\n event.currentTarget.setPointerCapture(event.pointerId);\n setSelected(null);\n setCropDraft({ from: point, to: point });\n return;\n }\n if (tool === 'text') {\n commitText();\n const existing = pick(point, 'text');\n if (existing !== null) {\n editText(existing);\n return;\n }\n // Pressed on what the callout points at; the box follows the pointer until release.\n event.currentTarget.setPointerCapture(event.pointerId);\n setSelected(null);\n setDrawing({ tool: 'text', at: point, text: '', tail: point, color, weight });\n return;\n }\n setSelected(null);\n event.currentTarget.setPointerCapture(event.pointerId);\n setDrawing(tool === 'pen' ? { tool, points: [point], color, weight } : { tool, from: point, to: point, color, weight });\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLCanvasElement>): void => {\n const pan = panRef.current;\n if (pan !== null) {\n const area = areaRef.current;\n if (area !== null) {\n area.scrollLeft = pan.left - (event.clientX - pan.x);\n area.scrollTop = pan.top - (event.clientY - pan.y);\n }\n return;\n }\n const point = imagePoint(event);\n const cropDraft = cropRef.current;\n const drag = dragRef.current;\n const drawing = drawingRef.current;\n if (cropDraft !== null) {\n setCropDraft({ ...cropDraft, to: point });\n return;\n }\n if (drag !== null) {\n let dx = point.x - drag.origin.x;\n let dy = point.y - drag.origin.y;\n // Shift keeps the move on one axis.\n if (event.shiftKey) {\n if (Math.abs(dx) > Math.abs(dy)) dy = 0;\n else dx = 0;\n }\n setDrag({\n ...drag,\n moved:\n drag.mode === 'tail' && drag.original.tool === 'text'\n ? { ...drag.original, tail: point }\n : translate(drag.original, dx, dy),\n });\n return;\n }\n if (drawing !== null) {\n setDrawing(\n drawing.tool === 'pen'\n ? { ...drawing, points: [...drawing.points, point] }\n : drawing.tool === 'text'\n ? { ...drawing, at: point }\n : { ...drawing, to: event.shiftKey ? straighten(drawing.from, point, drawing.tool) : point },\n );\n return;\n }\n if (tool === 'select') setHovering(pick(point) !== null);\n };\n\n const onPointerUp = (): void => {\n if (panRef.current !== null) {\n panRef.current = null;\n setPanning(false);\n return;\n }\n const cropDraft = cropRef.current;\n const drag = dragRef.current;\n const drawing = drawingRef.current;\n if (cropDraft !== null) {\n // Applied on release, like Shottr; undo or Reset crop gives the rest back.\n const cropBox = clampTo(normalized(cropDraft.from, cropDraft.to), view);\n if (cropBox.width * scale >= 8 && cropBox.height * scale >= 8) {\n commitCrop({ x: Math.round(cropBox.x), y: Math.round(cropBox.y), width: Math.round(cropBox.width), height: Math.round(cropBox.height) });\n }\n setCropDraft(null);\n return;\n }\n if (drag !== null) {\n if (drag.moved !== drag.original) replaceAt(drag.index, drag.moved);\n setDrag(null);\n return;\n }\n if (drawing !== null) {\n if (drawing.tool === 'text') {\n // A click is a plain label; a drag is a callout pointing where it started.\n const tip = drawing.tail ?? drawing.at;\n const dragged = Math.hypot(drawing.at.x - tip.x, drawing.at.y - tip.y) * scale >= 12;\n if (dragged) learnCallout();\n else if (!tipDone) setTipNudge(true);\n setText({ at: drawing.at, value: '', color: drawing.color, weight: drawing.weight, editing: null, ...(dragged ? { tail: tip } : {}) });\n } else if (!isTrivial(drawing)) {\n commit([...marks, drawing]);\n }\n setDrawing(null);\n }\n };\n\n // ---- style changes apply to the selected mark too -----------------------------------------\n const pickColor = (next: string): void => {\n setColor(next);\n const mark = selected === null ? undefined : marks[selected];\n if (selected !== null && mark !== undefined && mark.color !== next) replaceAt(selected, { ...mark, color: next });\n };\n const pickWeight = (next: Weight): void => {\n setWeight(next);\n const mark = selected === null ? undefined : marks[selected];\n if (selected !== null && mark !== undefined && mark.weight !== next) replaceAt(selected, { ...mark, weight: next });\n };\n const chooseTool = (next: EditorTool): void => {\n commitText();\n setTool(next);\n if (next !== 'select') setSelected(null);\n };\n // Selecting a mark shows its style in the bar.\n const select = (index: number | null): void => {\n setSelected(index);\n const mark = index === null ? undefined : marks[index];\n if (mark !== undefined) {\n setColor(mark.color);\n setWeight(mark.weight);\n }\n };\n\n // The native colour picker reports its final pick through `change`; `input` (React's\n // onChange) fires while it is open, which only previews the colour.\n const pickColorRef = useRef(pickColor);\n useEffect(() => {\n const input = customColorRef.current;\n if (input === null) return undefined;\n const onChange = (): void => pickColorRef.current(input.value);\n input.addEventListener('change', onChange);\n return () => input.removeEventListener('change', onChange);\n }, []);\n\n // ---- output ---------------------------------------------------------------------------------\n const run = async (action: 'copy' | 'save'): Promise<void> => {\n commitText();\n // Rendered apart from the board: only the frame, no selection, no backdrop.\n const canvas = document.createElement('canvas');\n canvas.width = frame.width;\n canvas.height = frame.height;\n paint(canvas, image, marks, { view: frame, image: view, frame, background, pixelRatio: ratio });\n try {\n if (action === 'copy') {\n await copyImage(canvas);\n onNotice({ title: 'Screenshot copied', detail: 'Paste it into your coding agent, a ticket or a chat.' });\n } else {\n await saveImage(canvas, fileName);\n onNotice({ title: 'Screenshot saved', detail: fileName });\n }\n setSaved(history.present);\n } catch (error) {\n onNotice({\n title: action === 'copy' ? 'Could not copy the screenshot' : 'Could not save the screenshot',\n detail: error instanceof Error ? error.message : String(error),\n tone: 'error',\n });\n }\n };\n\n const requestClose = (): void => {\n if (dirty && !confirmClose) {\n setConfirmClose(true);\n return;\n }\n onClose();\n };\n useEffect(() => {\n if (!confirmClose) return undefined;\n const timer = window.setTimeout(() => setConfirmClose(false), 3000);\n return () => window.clearTimeout(timer);\n }, [confirmClose]);\n\n // ---- keyboard ---------------------------------------------------------------------------------\n // The listener is registered once and calls the latest render's handlers.\n const keyRef = useRef<(event: KeyboardEvent) => boolean>(() => false);\n const onKey = (event: KeyboardEvent): boolean => {\n const command = event.metaKey || event.ctrlKey;\n const key = event.key.toLowerCase();\n if (event.key === 'Escape') {\n // Esc backs out of what is in progress; it never closes the editor.\n if (cropRef.current !== null) setCropDraft(null);\n else if (drawingRef.current !== null) setDrawing(null);\n else if (dragRef.current !== null) setDrag(null);\n else select(null);\n return true;\n }\n if (command) {\n if (key === 'z') (event.shiftKey ? redo : undo)();\n else if (key === 'y') redo();\n else if (key === 'c') void run('copy');\n else if (key === 's') void run('save');\n else if (key === '=' || key === '+') zoomStep(1);\n else if (key === '-') zoomStep(-1);\n else if (key === '0') zoomTo(null);\n else if (key === '1') zoomTo(1 / ratio);\n else return false;\n return true;\n }\n if (event.altKey) return false;\n if ((event.key === 'Delete' || event.key === 'Backspace') && selected !== null) {\n replaceAt(selected, null);\n setSelected(null);\n return true;\n }\n const nudge = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[event.key];\n const mark = selected === null ? undefined : marks[selected];\n if (nudge !== undefined && selected !== null && mark !== undefined) {\n const step = (event.shiftKey ? 10 : 1) / scale;\n replaceAt(selected, translate(mark, (nudge[0] ?? 0) * step, (nudge[1] ?? 0) * step));\n return true;\n }\n const weightKey = WEIGHTS.find((entry) => String(entry.weight) === event.key);\n if (weightKey !== undefined) {\n pickWeight(weightKey.weight);\n return true;\n }\n const toolKey = TOOLS.find((entry) => entry.key === event.key.toUpperCase());\n if (toolKey !== undefined) {\n chooseTool(toolKey.tool);\n return true;\n }\n return false;\n };\n // Listeners registered once call the latest render's handlers through these refs.\n useLayoutEffect(() => {\n keyRef.current = onKey;\n wheelRef.current = onWheel;\n pickColorRef.current = pickColor;\n });\n useEffect(() => {\n const typing = (target: EventTarget | null): boolean =>\n target instanceof HTMLTextAreaElement || (target instanceof HTMLInputElement && target.type !== 'color');\n const onKeyDown = (event: KeyboardEvent): void => {\n if (typing(event.target)) return;\n if (event.key === ' ') {\n event.preventDefault();\n setSpaceHeld(true);\n return;\n }\n if (keyRef.current(event)) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n const onKeyUp = (event: KeyboardEvent): void => {\n if (event.key === ' ') setSpaceHeld(false);\n };\n window.addEventListener('keydown', onKeyDown, true);\n window.addEventListener('keyup', onKeyUp, true);\n return () => {\n window.removeEventListener('keydown', onKeyDown, true);\n window.removeEventListener('keyup', onKeyUp, true);\n };\n }, []);\n\n // ---- render -------------------------------------------------------------------------------------\n const cursor = panning\n ? 'grabbing'\n : spaceHeld\n ? 'grab'\n : tool === 'select'\n ? drag !== null\n ? 'grabbing'\n : hovering\n ? 'move'\n : 'default'\n : 'crosshair';\n const custom = !(COLORS as readonly string[]).includes(color.toUpperCase());\n const textLayout = text === null ? null : calloutLayout({ at: text.at, text: text.value, weight: text.weight }, image.width, measureText());\n\n return (\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Screenshot editor\"\n style={{ ...FONT, position: 'fixed', inset: 0, display: 'flex', flexDirection: 'column', background: '#0E0E0E', zIndex: Z + 5 }}\n >\n <div\n role=\"toolbar\"\n aria-label=\"Markup tools\"\n style={{ display: 'flex', alignItems: 'center', gap: 2, padding: '8px 12px', background: INK, borderBottom: '1px solid rgba(255,255,255,0.12)', flexWrap: 'wrap', rowGap: 6 }}\n >\n {TOOLS.map((entry) => (\n <BarButton\n key={entry.tool}\n icon={entry.icon}\n label={entry.label}\n detail={entry.detail}\n shortcut={[entry.key]}\n pressed={tool === entry.tool}\n onClick={() => chooseTool(entry.tool)}\n />\n ))}\n <Divider />\n {COLORS.map((swatch) => (\n <Tooltip key={swatch} label={COLOR_NAMES[swatch] ?? swatch} placement=\"below\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={() => pickColor(swatch)}\n aria-label={`Colour ${COLOR_NAMES[swatch] ?? swatch}`}\n aria-describedby={describedBy}\n aria-pressed={color.toUpperCase() === swatch}\n style={swatchStyle(swatch, color.toUpperCase() === swatch)}\n />\n )}\n </Tooltip>\n ))}\n <Tooltip label=\"Custom colour\" detail=\"Pick any colour.\" placement=\"below\">\n {(describedBy) => (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n <span\n aria-hidden=\"true\"\n style={{\n ...swatchStyle(custom ? color : '#FFFFFF', custom),\n background: custom\n ? `radial-gradient(circle, ${color} 0 45%, transparent 47%), conic-gradient(#E5484D, #F5A524, #30A46C, #0091FF, #8E4EC6, #E5484D)`\n : 'conic-gradient(#E5484D, #F5A524, #30A46C, #0091FF, #8E4EC6, #E5484D)',\n }}\n />\n <input\n ref={customColorRef}\n type=\"color\"\n aria-label=\"Custom colour\"\n aria-describedby={describedBy}\n value={/^#[0-9a-f]{6}$/i.test(color) ? color : '#000000'}\n onChange={(event) => setColor(event.target.value)}\n style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', opacity: 0, cursor: 'pointer', padding: 0, border: 0 }}\n />\n </span>\n )}\n </Tooltip>\n <Divider />\n {WEIGHTS.map((entry) => (\n <Tooltip key={entry.weight} label={`${entry.label} stroke`} shortcut={[String(entry.weight)]} placement=\"below\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={() => pickWeight(entry.weight)}\n aria-label={`${entry.label} stroke`}\n aria-describedby={describedBy}\n aria-pressed={weight === entry.weight}\n style={{ ...iconButton(weight === entry.weight), width: 30, minWidth: 30 }}\n >\n <span aria-hidden=\"true\" style={{ width: entry.dot, height: entry.dot, borderRadius: entry.dot, background: '#FFFFFF' }} />\n </button>\n )}\n </Tooltip>\n ))}\n <Divider />\n <BarButton icon=\"undo\" label=\"Undo\" shortcut={[MOD_KEY, 'Z']} disabled={history.past.length === 0} onClick={undo} />\n <BarButton icon=\"redo\" label=\"Redo\" shortcut={[MOD_KEY, '⇧', 'Z']} disabled={history.future.length === 0} onClick={redo} />\n <BarButton\n icon=\"eraser\"\n label=\"Delete selected\"\n detail=\"Select a mark with V first.\"\n shortcut={['⌫']}\n disabled={selected === null}\n onClick={() => {\n if (selected === null) return;\n replaceAt(selected, null);\n setSelected(null);\n }}\n />\n <BarButton icon=\"trash\" label=\"Clear all marks\" disabled={marks.length === 0} onClick={() => commit(NO_MARKS)} />\n <BarButton\n icon=\"cropOff\"\n label=\"Reset crop\"\n detail={crop === null ? 'The image is not cropped.' : 'Show the whole capture again.'}\n disabled={crop === null}\n onClick={() => commitCrop(null)}\n />\n <span style={{ flex: 1, minWidth: 8 }} />\n <BarButton icon=\"zoomOut\" label=\"Zoom out\" shortcut={[MOD_KEY, '−']} disabled={percent <= MIN_ZOOM * 1.01} onClick={() => zoomStep(-1)} />\n <Tooltip label={zoom === null ? 'Actual size' : 'Fit to window'} shortcut={zoom === null ? [MOD_KEY, '1'] : [MOD_KEY, '0']} placement=\"below\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={() => zoomTo(zoom === null ? 1 / ratio : null)}\n aria-label={`Zoom ${Math.round(percent * 100)}%`}\n aria-describedby={describedBy}\n style={{ ...iconButton(false), minWidth: 54, padding: '0 6px', fontVariantNumeric: 'tabular-nums' }}\n >\n <span style={{ ...FONT, color: 'inherit', fontWeight: 600, fontSize: 12 }}>{Math.round(percent * 100)}%</span>\n </button>\n )}\n </Tooltip>\n <BarButton icon=\"zoomIn\" label=\"Zoom in\" shortcut={[MOD_KEY, '+']} disabled={percent >= MAX_ZOOM * 0.99} onClick={() => zoomStep(1)} />\n <BarButton icon=\"fit\" label=\"Fit to window\" shortcut={[MOD_KEY, '0']} pressed={zoom === null} onClick={() => zoomTo(null)} />\n <Divider />\n <BarButton icon=\"copy\" label=\"Copy image\" shortcut={[MOD_KEY, 'C']} text=\"Copy\" primary onClick={() => void run('copy')} />\n <BarButton icon=\"download\" label=\"Save as PNG\" detail={fileName} shortcut={[MOD_KEY, 'S']} text=\"Save\" onClick={() => void run('save')} />\n <BarButton\n icon=\"close\"\n label={confirmClose ? 'Discard marks and close' : 'Close'}\n detail={confirmClose ? 'Click again to close without copying or saving.' : dirty ? 'Your marks are not copied or saved yet.' : undefined}\n text={confirmClose ? 'Discard?' : undefined}\n danger={confirmClose}\n onClick={requestClose}\n />\n </div>\n {showTip && tipAt !== null ? <CalloutTip left={tipAt.left} top={tipAt.top} nudge={tipNudge} onDismiss={learnCallout} /> : null}\n <div ref={areaRef} style={{ position: 'relative', flex: 1, minHeight: 0, overflow: 'auto' }}>\n <div style={{ display: 'flex', minWidth: '100%', minHeight: '100%', width: 'max-content', height: 'max-content' }}>\n <div style={{ position: 'relative', margin: 'auto', width: board.width * scale, height: board.height * scale, flex: 'none' }}>\n <canvas\n ref={canvasRef}\n width={board.width}\n height={board.height}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n onPointerLeave={() => setHovering(false)}\n onDoubleClick={(event) => {\n const index = pick(imagePoint(event), 'text');\n if (index !== null) editText(index);\n }}\n style={{\n display: 'block',\n width: '100%',\n height: '100%',\n cursor,\n touchAction: 'none',\n }}\n />\n {text === null || textLayout === null ? null : (\n <textarea\n aria-label=\"Callout text\"\n // Opened by a deliberate click or drag with the callout tool, or a double-click.\n autoFocus\n spellCheck={false}\n rows={textLayout.lines.length}\n value={text.value}\n onChange={(event) => setText({ ...text, value: event.target.value })}\n onBlur={commitText}\n onKeyDown={(event) => {\n event.stopPropagation();\n if (event.key === 'Escape') setText(null);\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n commitText();\n }\n }}\n style={{\n position: 'absolute',\n left: (textLayout.box.x - board.x) * scale,\n top: (textLayout.box.y - board.y) * scale,\n width: textLayout.box.width * scale,\n height: textLayout.box.height * scale,\n margin: 0,\n padding: `${textLayout.padY * scale}px ${textLayout.padX * scale}px`,\n boxSizing: 'border-box',\n border: 0,\n borderRadius: textLayout.radius * scale,\n outline: '1.5px dashed rgba(255,255,255,0.85)',\n outlineOffset: 3,\n resize: 'none',\n overflow: 'hidden',\n whiteSpace: 'pre',\n textAlign: 'center',\n background: 'transparent',\n // The canvas paints the text; this only shows the caret and the selection.\n color: 'transparent',\n caretColor: textColorOn(text.color),\n font: `600 ${textLayout.size * scale}px/${textLayout.lineHeight * scale}px ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif`,\n }}\n />\n )}\n </div>\n </div>\n </div>\n <div\n aria-hidden=\"true\"\n style={{ ...FONT, padding: '6px 12px', fontSize: 12, color: '#9C978F', background: INK, borderTop: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}\n >\n {tool === 'select'\n ? 'Drag a mark to move it (Shift keeps one axis) · drag a callout’s round grip to re-aim its tail · arrow keys nudge · ⌫ deletes · double-click text to edit'\n : tool === 'text'\n ? 'Drag from what you point at to where the text goes · click for a box without a tail · Enter places it, Shift+Enter adds a line'\n : `Hold Space and drag to pan · ${MOD_KEY} + scroll to zoom · V to select and move marks · Esc cancels`}\n </div>\n </div>\n );\n}\n\nconst COLOR_NAMES: Readonly<Record<string, string>> = {\n '#E5484D': 'Red',\n '#F5A524': 'Amber',\n '#30A46C': 'Green',\n '#0091FF': 'Blue',\n '#8E4EC6': 'Purple',\n '#1F1E1D': 'Black',\n};\n\nfunction swatchStyle(fill: string, active: boolean): CSSProperties {\n return {\n appearance: 'none',\n display: 'block',\n width: 22,\n height: 22,\n margin: '0 3px',\n padding: 0,\n borderRadius: 11,\n background: fill,\n border: active ? '2px solid #FFFFFF' : '2px solid rgba(255,255,255,0.25)',\n boxShadow: active ? `0 0 0 2px ${fill === '#FFFFFF' ? ACCENT : fill}` : 'none',\n cursor: 'pointer',\n boxSizing: 'border-box',\n };\n}\n\nfunction iconButton(pressed: boolean): CSSProperties {\n return {\n ...FONT,\n appearance: 'none',\n height: 34,\n minWidth: 34,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n padding: 0,\n border: 0,\n borderRadius: 8,\n cursor: 'pointer',\n color: '#FFFFFF',\n background: pressed ? 'rgba(255,255,255,0.2)' : 'transparent',\n };\n}\n\nfunction Divider(): ReactNode {\n return <span aria-hidden=\"true\" style={{ width: 1, height: 20, margin: '0 6px', background: 'rgba(255,255,255,0.18)' }} />;\n}\n\nfunction BarButton(props: {\n readonly icon: IconName;\n readonly label: string;\n readonly detail?: string | undefined;\n readonly shortcut?: readonly string[];\n readonly text?: string | undefined;\n readonly pressed?: boolean;\n readonly primary?: boolean;\n readonly danger?: boolean;\n readonly disabled?: boolean;\n readonly onClick: () => void;\n}): ReactNode {\n return (\n <Tooltip label={props.label} {...(props.detail === undefined ? {} : { detail: props.detail })} {...(props.shortcut === undefined ? {} : { shortcut: props.shortcut })} placement=\"below\">\n {(describedBy) => (\n <button\n type=\"button\"\n onClick={props.onClick}\n disabled={props.disabled}\n aria-label={props.label}\n aria-describedby={describedBy}\n {...(props.pressed === undefined ? {} : { 'aria-pressed': props.pressed })}\n style={{\n ...iconButton(props.pressed === true),\n padding: props.text === undefined ? 0 : '0 12px',\n cursor: props.disabled ? 'default' : 'pointer',\n opacity: props.disabled ? 0.35 : 1,\n background: props.danger ? '#B42318' : props.primary ? ACCENT : props.pressed ? 'rgba(255,255,255,0.2)' : 'transparent',\n }}\n >\n <Icon name={props.icon} />\n {props.text === undefined ? null : <span style={{ ...FONT, color: 'inherit', fontWeight: 600 }}>{props.text}</span>}\n </button>\n )}\n </Tooltip>\n );\n}\n\n/** Shift held: arrows snap to 45°, boxes become squares. */\nfunction straighten(from: Point, to: Point, tool: Tool): Point {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n if (tool === 'arrow' || tool === 'ruler') {\n const angle = Math.round(Math.atan2(dy, dx) / (Math.PI / 4)) * (Math.PI / 4);\n const length = Math.hypot(dx, dy);\n return { x: from.x + length * Math.cos(angle), y: from.y + length * Math.sin(angle) };\n }\n const side = Math.max(Math.abs(dx), Math.abs(dy));\n return { x: from.x + Math.sign(dx || 1) * side, y: from.y + Math.sign(dy || 1) * side };\n}\n\n/** `box` cut down to what lies inside `within`. */\nfunction clampTo(box: Bounds, within: Bounds): Bounds {\n const x = Math.max(box.x, within.x);\n const y = Math.max(box.y, within.y);\n return {\n x,\n y,\n width: Math.max(0, Math.min(box.x + box.width, within.x + within.width) - x),\n height: Math.max(0, Math.min(box.y + box.height, within.y + within.height) - y),\n };\n}\n\n/**\n * At least the scroll area's size (minus a pixel of slack against scrollbars), centred on\n * the IMAGE so the picture stays put while marks are added around it, and never smaller\n * than `content`; whole image pixels.\n */\nfunction boardAround(content: Bounds, image: Bounds, area: { readonly width: number; readonly height: number }, scale: number): Bounds {\n const width = Math.max(0, area.width - 2) / scale;\n const height = Math.max(0, area.height - 2) / scale;\n const centre = { x: image.x + image.width / 2, y: image.y + image.height / 2 };\n const box = union(content, { x: centre.x - width / 2, y: centre.y - height / 2, width, height });\n const x = Math.floor(box.x);\n const y = Math.floor(box.y);\n // Floor the far edge too when the area set the size, so the canvas never overflows it.\n const right = box.width > content.width + 1 ? Math.floor(box.x + box.width) : Math.ceil(box.x + box.width);\n const bottom = box.height > content.height + 1 ? Math.floor(box.y + box.height) : Math.ceil(box.y + box.height);\n return { x, y, width: right - x, height: bottom - y };\n}\n","import type { ReactNode } from 'react';\n\nconst FONT = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\nconst RED = '#E5484D';\n/** One loop of the demo: press on the target, drag, release, the callout shows, repeat. */\nconst LOOP = '3.2s';\nconst KEY_TIMES = '0;0.12;0.55;0.85;1';\n\n/**\n * The coach mark that teaches the callout drag. People who know \"click, then type\" never\n * read a tooltip, so this shows where they are already looking — under the Callout button\n * the moment the tool is picked — and SHOWS the gesture in a looping picture before saying\n * it. After a plain click it turns into a nudge. It goes for good once a callout is dragged\n * or \"Got it\" is pressed.\n *\n * The picture is SVG animated with SMIL, not CSS: a strict CSP (no unnonced <style>) must not break it.\n */\nexport function CalloutTip(props: {\n readonly left: number;\n readonly top: number;\n /** The person just clicked instead of dragging. */\n readonly nudge: boolean;\n readonly onDismiss: () => void;\n}): ReactNode {\n return (\n <div\n role=\"note\"\n aria-label=\"Callout tip\"\n style={{\n position: 'absolute',\n left: props.left,\n top: props.top,\n width: 264,\n padding: 12,\n borderRadius: 10,\n background: '#0E0E0E',\n border: '1px solid rgba(255,255,255,0.16)',\n boxShadow: '0 12px 32px rgba(0,0,0,0.45)',\n color: '#FFFFFF',\n font: `500 12px/1.4 ${FONT}`,\n zIndex: 2,\n }}\n >\n {/* The notch pointing up at the Callout button. */}\n <span\n aria-hidden=\"true\"\n style={{\n position: 'absolute',\n top: -6,\n left: 18,\n width: 10,\n height: 10,\n background: '#0E0E0E',\n borderLeft: '1px solid rgba(255,255,255,0.16)',\n borderTop: '1px solid rgba(255,255,255,0.16)',\n transform: 'rotate(45deg)',\n }}\n />\n <Demo />\n <strong style={{ display: 'block', marginTop: 10, font: `600 13px/1.35 ${FONT}`, color: '#FFFFFF' }}>\n {props.nudge ? 'Tip: drag instead of clicking' : 'Drag to point at something'}\n </strong>\n <span style={{ display: 'block', marginTop: 4, color: '#C9C5BE' }}>\n {props.nudge\n ? 'Press on what you mean and drag to where the text goes: the box gets a tail pointing there.'\n : 'Press on what you mean, drag to where the text goes, then type. A plain click makes a box without a tail.'}\n </span>\n <button\n type=\"button\"\n onClick={props.onDismiss}\n style={{\n appearance: 'none',\n marginTop: 10,\n padding: '5px 12px',\n border: 0,\n borderRadius: 6,\n background: 'rgba(255,255,255,0.14)',\n color: '#FFFFFF',\n font: `600 12px/1.2 ${FONT}`,\n cursor: 'pointer',\n }}\n >\n Got it\n </button>\n </div>\n );\n}\n\nfunction Demo(): ReactNode {\n const x = '52;52;172;172;52';\n const y = '70;70;27;27;70';\n return (\n <svg width=\"240\" height=\"96\" viewBox=\"0 0 240 96\" aria-hidden=\"true\" style={{ display: 'block', borderRadius: 6, background: '#F6F3EE' }}>\n {/* The thing being pointed at. */}\n <rect x=\"16\" y=\"56\" width=\"74\" height=\"28\" rx=\"4\" fill=\"#E6E0D6\" />\n <rect x=\"24\" y=\"64\" width=\"40\" height=\"5\" rx=\"2\" fill=\"#B9B2A6\" />\n <rect x=\"24\" y=\"73\" width=\"56\" height=\"4\" rx=\"2\" fill=\"#CFC8BC\" />\n {/* The tail follows the pointer from the press. */}\n <line x1=\"52\" y1=\"70\" x2=\"52\" y2=\"70\" stroke={RED} strokeWidth=\"3\" strokeLinecap=\"round\">\n <animate attributeName=\"x2\" values={x} keyTimes={KEY_TIMES} dur={LOOP} repeatCount=\"indefinite\" />\n <animate attributeName=\"y2\" values={y} keyTimes={KEY_TIMES} dur={LOOP} repeatCount=\"indefinite\" />\n <animate attributeName=\"opacity\" values=\"0;1;1;1;0\" keyTimes={KEY_TIMES} dur={LOOP} calcMode=\"discrete\" repeatCount=\"indefinite\" />\n </line>\n {/* The callout, on release. */}\n <g opacity=\"0\">\n <rect x=\"128\" y=\"13\" width=\"92\" height=\"28\" rx=\"5\" fill={RED} />\n <text x=\"174\" y=\"31.5\" textAnchor=\"middle\" fill=\"#FFFFFF\" style={{ font: `600 12px ${FONT}` }}>\n Too tight\n </text>\n <animate attributeName=\"opacity\" values=\"0;0;1;0;0\" keyTimes={KEY_TIMES} dur={LOOP} calcMode=\"discrete\" repeatCount=\"indefinite\" />\n </g>\n {/* The press ring, then the pointer. */}\n <circle cx=\"52\" cy=\"70\" r=\"0\" fill=\"none\" stroke=\"#1F1E1D\" strokeWidth=\"1.5\">\n <animate attributeName=\"r\" values=\"0;11;0;0;0\" keyTimes={KEY_TIMES} dur={LOOP} repeatCount=\"indefinite\" />\n </circle>\n <g>\n <path d=\"M0 0 L0 15 L4 11 L7 18 L10 17 L7 10 L12 10 Z\" fill=\"#FFFFFF\" stroke=\"#1F1E1D\" strokeWidth=\"1.2\" strokeLinejoin=\"round\" />\n <animateTransform attributeName=\"transform\" type=\"translate\" values=\"52 70;52 70;172 27;172 27;52 70\" keyTimes={KEY_TIMES} dur={LOOP} repeatCount=\"indefinite\" />\n </g>\n </svg>\n );\n}\n","/**\n * The marks drawn on a screenshot, in image pixels, and how they are painted, found and\n * moved. Every mark is kept as data and the whole image is repainted from the untouched\n * capture on each change, so undo is restoring a list and pixelation always samples the\n * original pixels.\n */\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\nexport interface Bounds {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport type Tool = 'arrow' | 'rect' | 'highlight' | 'pen' | 'text' | 'pixelate' | 'ruler';\n\n/** Thin, medium, thick: scales the stroke, the arrowhead and the text together. */\nexport type Weight = 1 | 2 | 3;\nconst WEIGHT_FACTOR: Readonly<Record<Weight, number>> = { 1: 0.6, 2: 1, 3: 1.7 };\n\ninterface Style {\n readonly color: string;\n readonly weight: Weight;\n}\n\nexport type Mark = Style &\n (\n | { readonly tool: 'arrow' | 'rect' | 'highlight' | 'pixelate' | 'ruler'; readonly from: Point; readonly to: Point }\n | { readonly tool: 'pen'; readonly points: readonly Point[] }\n /**\n * A callout: a filled, rounded box CENTRED on `at` (so it grows both ways as it is\n * typed), with an optional tail whose tip is `tail` — one mark for \"this, here\".\n */\n | { readonly tool: 'text'; readonly at: Point; readonly text: string; readonly tail?: Point }\n );\n\nexport const COLORS = ['#E5484D', '#F5A524', '#30A46C', '#0091FF', '#8E4EC6', '#1F1E1D'] as const;\n\nconst FONT_FAMILY = 'ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\nconst LINE_HEIGHT = 1.25;\n\n/** Stroke width that reads the same on a laptop capture and on a 4K one. */\nexport function strokeWidth(imageWidth: number, weight: Weight = 2): number {\n return Math.max(2, Math.round((imageWidth / 400) * WEIGHT_FACTOR[weight]));\n}\n\nexport function fontSize(imageWidth: number, weight: Weight = 2): number {\n return Math.max(14, Math.round((imageWidth / 48) * WEIGHT_FACTOR[weight]));\n}\n\nexport function textFont(imageWidth: number, weight: Weight): string {\n return `600 ${fontSize(imageWidth, weight)}px ${FONT_FAMILY}`;\n}\n\n/** Head length and half-width for a stroke width, shrunk on an arrow too short for them. */\nfunction headSize(from: Point, to: Point, width: number): { length: number; half: number } {\n const span = Math.hypot(to.x - from.x, to.y - from.y);\n const length = Math.min(width * 6, span * 0.5);\n return { length, half: length * 0.52 };\n}\n\n/** The two barbs of an arrowhead pointing at `to`, sized from the stroke width. */\nexport function arrowHead(from: Point, to: Point, width: number): readonly [Point, Point] {\n const { length, half } = headSize(from, to, width);\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const base = { x: to.x - length * Math.cos(angle), y: to.y - length * Math.sin(angle) };\n const normal = { x: -Math.sin(angle), y: Math.cos(angle) };\n return [\n { x: base.x + normal.x * half, y: base.y + normal.y * half },\n { x: base.x - normal.x * half, y: base.y - normal.y * half },\n ];\n}\n\n/**\n * The whole arrow as ONE filled outline: a shaft that tapers from a thin tail to the head,\n * then a sharp head whose tip is exactly `to`. Filled, not stroked, so no line cap pokes\n * past the tip.\n */\nexport function arrowOutline(from: Point, to: Point, width: number): Point[] {\n const { length, half } = headSize(from, to, width);\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const along = { x: Math.cos(angle), y: Math.sin(angle) };\n const normal = { x: -along.y, y: along.x };\n const base = { x: to.x - along.x * length, y: to.y - along.y * length };\n const at = (point: Point, offset: number): Point => ({ x: point.x + normal.x * offset, y: point.y + normal.y * offset });\n const tail = width * 0.35;\n const neck = width * 0.85;\n return [at(from, tail), at(base, neck), at(base, half), to, at(base, -half), at(base, -neck), at(from, -tail)];\n}\n\n/** How a callout is laid out, in image pixels. */\nexport interface CalloutLayout {\n readonly box: Bounds;\n readonly size: number;\n readonly padX: number;\n readonly padY: number;\n readonly lineHeight: number;\n readonly lines: readonly string[];\n readonly radius: number;\n}\n\nexport function calloutLayout(mark: { readonly at: Point; readonly text: string; readonly weight: Weight }, imageWidth: number, measure: Measure): CalloutLayout {\n const size = fontSize(imageWidth, mark.weight);\n const lines = mark.text.split('\\n');\n const font = textFont(imageWidth, mark.weight);\n const padX = size * 0.5;\n const padY = size * 0.3;\n const lineHeight = size * LINE_HEIGHT;\n // An empty box still shows where the text will go.\n const textWidth = Math.max(size * 1.5, ...lines.map((line) => measure(line, font)));\n const width = textWidth + 2 * padX;\n const height = lines.length * lineHeight + 2 * padY;\n return {\n box: { x: mark.at.x - width / 2, y: mark.at.y - height / 2, width, height },\n size,\n padX,\n padY,\n lineHeight,\n lines,\n radius: size * 0.22,\n };\n}\n\n/**\n * Where a callout's tail leaves its box: two points on the side facing the tip, `null`\n * when the tip is inside the box. The base sits just inside the edge so box and tail\n * fill as one shape.\n */\nexport function tailBase(layout: CalloutLayout, tip: Point): readonly [Point, Point] | null {\n const { box, size, radius } = layout;\n const cx = box.x + box.width / 2;\n const cy = box.y + box.height / 2;\n const dx = tip.x - cx;\n const dy = tip.y - cy;\n if (Math.abs(dx) <= box.width / 2 && Math.abs(dy) <= box.height / 2) return null;\n const inset = 1;\n // Which side the line from the centre crosses first.\n if (Math.abs(dy) * (box.width / 2) >= Math.abs(dx) * (box.height / 2)) {\n const half = Math.min(size * 0.32, (box.width - 2 * radius) / 3);\n const y = dy > 0 ? box.y + box.height - inset : box.y + inset;\n const reach = dy === 0 ? 0 : (box.height / 2 / Math.abs(dy)) * dx;\n const x = Math.min(Math.max(cx + reach, box.x + radius + half), box.x + box.width - radius - half);\n return [{ x: x - half, y }, { x: x + half, y }];\n }\n const half = Math.min(size * 0.32, (box.height - 2 * radius) / 3);\n const x = dx > 0 ? box.x + box.width - inset : box.x + inset;\n const reach = dx === 0 ? 0 : (box.width / 2 / Math.abs(dx)) * dy;\n const y = Math.min(Math.max(cy + reach, box.y + radius + half), box.y + box.height - radius - half);\n return [{ x, y: y - half }, { x, y: y + half }];\n}\n\n/** Dark text on a light fill, white on anything else. */\nexport function textColorOn(fill: string): string {\n const hex = /^#?([0-9a-f]{6})$/i.exec(fill)?.[1];\n if (hex === undefined) return '#FFFFFF';\n const [r, g, b] = [0, 2, 4].map((at) => Number.parseInt(hex.slice(at, at + 2), 16) / 255);\n const luminance = 0.2126 * (r ?? 0) + 0.7152 * (g ?? 0) + 0.0722 * (b ?? 0);\n return luminance > 0.6 ? '#1F1E1D' : '#FFFFFF';\n}\n\nexport function normalized(from: Point, to: Point): Bounds {\n return {\n x: Math.min(from.x, to.x),\n y: Math.min(from.y, to.y),\n width: Math.abs(to.x - from.x),\n height: Math.abs(to.y - from.y),\n };\n}\n\n/** Too small to be meant: a click with a drawing tool draws nothing. */\nexport function isTrivial(mark: Mark): boolean {\n if (mark.tool === 'text') return mark.text.trim() === '';\n if (mark.tool === 'pen') return mark.points.length < 2;\n const box = normalized(mark.from, mark.to);\n return box.width < 4 && box.height < 4;\n}\n\n/** Measures a line of text; without a 2D context (tests), an average glyph width. */\nexport type Measure = (text: string, font: string) => number;\n\nexport function canvasMeasure(context: CanvasRenderingContext2D | null): Measure {\n return (text, font) => {\n if (context === null) return text.length * Number.parseFloat(font.split(' ')[1] ?? '16') * 0.56;\n context.save();\n context.font = font;\n const width = context.measureText(text).width;\n context.restore();\n return width;\n };\n}\n\n/** The box a mark covers, in image pixels, stroke included. */\nexport function markBounds(mark: Mark, imageWidth: number, measure: Measure): Bounds {\n const pad = strokeWidth(imageWidth, mark.weight) / 2;\n switch (mark.tool) {\n case 'text':\n return calloutLayout(mark, imageWidth, measure).box;\n case 'pen': {\n const xs = mark.points.map((point) => point.x);\n const ys = mark.points.map((point) => point.y);\n const x = Math.min(...xs);\n const y = Math.min(...ys);\n return { x: x - pad, y: y - pad, width: Math.max(...xs) - x + 2 * pad, height: Math.max(...ys) - y + 2 * pad };\n }\n case 'arrow': {\n const points = arrowOutline(mark.from, mark.to, strokeWidth(imageWidth, mark.weight));\n const xs = points.map((point) => point.x);\n const ys = points.map((point) => point.y);\n const x = Math.min(...xs);\n const y = Math.min(...ys);\n return { x: x - pad, y: y - pad, width: Math.max(...xs) - x + 2 * pad, height: Math.max(...ys) - y + 2 * pad };\n }\n default: {\n const box = normalized(mark.from, mark.to);\n return { x: box.x - pad, y: box.y - pad, width: box.width + 2 * pad, height: box.height + 2 * pad };\n }\n }\n}\n\nfunction distanceToSegment(point: Point, a: Point, b: Point): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const lengthSquared = dx * dx + dy * dy;\n const t = lengthSquared === 0 ? 0 : Math.max(0, Math.min(1, ((point.x - a.x) * dx + (point.y - a.y) * dy) / lengthSquared));\n return Math.hypot(point.x - (a.x + t * dx), point.y - (a.y + t * dy));\n}\n\nfunction inside(point: Point, box: Bounds, slack: number): boolean {\n return (\n point.x >= box.x - slack &&\n point.x <= box.x + box.width + slack &&\n point.y >= box.y - slack &&\n point.y <= box.y + box.height + slack\n );\n}\n\n/**\n * The topmost mark under `point`, or `null`. Lines are hit near their stroke, shapes and\n * text anywhere inside: easy to grab, since nothing else lives on the canvas.\n */\nexport function hitTest(marks: readonly Mark[], point: Point, imageWidth: number, measure: Measure, slack: number): number | null {\n for (let index = marks.length - 1; index >= 0; index--) {\n const mark = marks[index];\n if (mark === undefined) continue;\n const tolerance = slack + strokeWidth(imageWidth, mark.weight);\n if ((mark.tool === 'arrow' || mark.tool === 'ruler') && distanceToSegment(point, mark.from, mark.to) <= tolerance) return index;\n if (mark.tool === 'pen') {\n for (let at = 1; at < mark.points.length; at++) {\n const a = mark.points[at - 1];\n const b = mark.points[at];\n if (a !== undefined && b !== undefined && distanceToSegment(point, a, b) <= tolerance) return index;\n }\n }\n if (mark.tool === 'text' && mark.tail !== undefined) {\n const layout = calloutLayout(mark, imageWidth, measure);\n const base = tailBase(layout, mark.tail);\n if (base !== null) {\n const mid = { x: (base[0].x + base[1].x) / 2, y: (base[0].y + base[1].y) / 2 };\n if (distanceToSegment(point, mid, mark.tail) <= tolerance) return index;\n }\n }\n if (mark.tool !== 'arrow' && mark.tool !== 'ruler' && mark.tool !== 'pen' && inside(point, markBounds(mark, imageWidth, measure), slack)) return index;\n }\n return null;\n}\n\n/**\n * Moves a mark as dragging it does. A callout moves its BOX: the tail stays on what it\n * points at, which is the reason it was drawn.\n */\nexport function translate(mark: Mark, dx: number, dy: number): Mark {\n const move = (point: Point): Point => ({ x: point.x + dx, y: point.y + dy });\n switch (mark.tool) {\n case 'text':\n return { ...mark, at: move(mark.at) };\n case 'pen':\n return { ...mark, points: mark.points.map(move) };\n default:\n return { ...mark, from: move(mark.from), to: move(mark.to) };\n }\n}\n\nexport function union(a: Bounds, b: Bounds): Bounds {\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };\n}\n\nexport function expand(box: Bounds, by: number): Bounds {\n return { x: box.x - by, y: box.y - by, width: box.width + 2 * by, height: box.height + 2 * by };\n}\n\n/**\n * What Copy and Save produce: the image (or its crop), grown to hold every mark that lies\n * outside it, with a margin so nothing touches the edge. Marks inside leave it unchanged.\n */\nexport function outputFrame(image: Bounds, marks: readonly Mark[], imageWidth: number, measure: Measure): Bounds {\n let frame = image;\n const margin = Math.max(16, Math.round(Math.max(image.width, image.height) / 50));\n for (const mark of marks) {\n const box = expand(markBounds(mark, imageWidth, measure), margin);\n const outside = box.x < image.x || box.y < image.y || box.x + box.width > image.x + image.width || box.y + box.height > image.y + image.height;\n if (outside) frame = union(frame, box);\n }\n return {\n x: Math.floor(frame.x),\n y: Math.floor(frame.y),\n width: Math.ceil(frame.x + frame.width) - Math.floor(frame.x),\n height: Math.ceil(frame.y + frame.height) - Math.floor(frame.y),\n };\n}\n\n/**\n * The colour around the capture's edge, for the background added when marks reach past it:\n * a page screenshot almost always has one, and the extension then reads as more page. The\n * MOST COMMON colour on the outermost rows and columns, not their average — a dark tab or\n * a sidebar touching one edge would drag an average to grey.\n */\nexport function edgeColor(image: HTMLCanvasElement): string {\n try {\n const context = image.getContext('2d', { willReadFrequently: true });\n if (context === null || image.width === 0 || image.height === 0) return '#FFFFFF';\n const strips = [\n context.getImageData(0, 0, image.width, 1),\n context.getImageData(0, image.height - 1, image.width, 1),\n context.getImageData(0, 0, 1, image.height),\n context.getImageData(image.width - 1, 0, 1, image.height),\n ];\n // Near-identical shades (anti-aliasing, JPEG-ish noise) count as one colour.\n const tally = new Map<number, { count: number; red: number; green: number; blue: number }>();\n for (const { data } of strips) {\n for (let at = 0; at < data.length; at += 4) {\n const red = data[at] ?? 0;\n const green = data[at + 1] ?? 0;\n const blue = data[at + 2] ?? 0;\n const key = ((red >> 3) << 10) | ((green >> 3) << 5) | (blue >> 3);\n const entry = tally.get(key) ?? { count: 0, red: 0, green: 0, blue: 0 };\n entry.count++;\n entry.red += red;\n entry.green += green;\n entry.blue += blue;\n tally.set(key, entry);\n }\n }\n let best: { count: number; red: number; green: number; blue: number } | undefined;\n for (const entry of tally.values()) if (best === undefined || entry.count > best.count) best = entry;\n if (best === undefined) return '#FFFFFF';\n const { count } = best;\n const hex = (sum: number): string => Math.round(sum / count).toString(16).padStart(2, '0');\n return `#${hex(best.red)}${hex(best.green)}${hex(best.blue)}`;\n } catch {\n return '#FFFFFF';\n }\n}\n\nexport interface PaintOptions {\n /** Index of the mark to outline as selected. */\n readonly selected?: number | null;\n /** Colour of the selection outline. */\n readonly accent?: string;\n /** The region the canvas covers, in image pixels; the image area when absent. */\n readonly view?: Bounds;\n /** The part of the capture shown (the crop); the whole capture when absent. */\n readonly image?: Bounds;\n /** The output frame: filled with `background` wherever the image does not reach. */\n readonly frame?: Bounds;\n readonly background?: string;\n /** Fills the canvas outside the frame, which marks the frame as the picture's edge. */\n readonly backdrop?: string;\n /** Device pixels per CSS pixel at capture: rulers measure in the page's own pixels. */\n readonly pixelRatio?: number;\n /** A crop being dragged out, shown with everything outside it dimmed. */\n readonly cropPreview?: Bounds | null;\n}\n\n/**\n * Paints the capture and the marks. Coordinates are always the FULL image's: a crop only\n * moves the canvas window over it, so marks never need rewriting and a crop can be undone.\n */\nexport function paint(canvas: HTMLCanvasElement, base: HTMLCanvasElement, marks: readonly Mark[], options: PaintOptions = {}): void {\n const context = canvas.getContext('2d');\n if (context === null) return;\n const imageWidth = base.width;\n const image = options.image ?? { x: 0, y: 0, width: base.width, height: base.height };\n const frame = options.frame ?? image;\n const view = options.view ?? frame;\n context.save();\n context.clearRect(0, 0, canvas.width, canvas.height);\n context.translate(-view.x, -view.y);\n if (options.backdrop !== undefined) {\n context.fillStyle = options.backdrop;\n context.fillRect(view.x, view.y, view.width, view.height);\n }\n context.save();\n if (options.backdrop !== undefined) {\n // The picture's edge, lifted off the board.\n context.shadowColor = 'rgba(0, 0, 0, 0.5)';\n context.shadowBlur = Math.max(12, imageWidth / 80);\n context.shadowOffsetY = Math.max(4, imageWidth / 300);\n }\n context.fillStyle = options.background ?? '#FFFFFF';\n context.fillRect(frame.x, frame.y, frame.width, frame.height);\n context.restore();\n context.drawImage(base, image.x, image.y, image.width, image.height, image.x, image.y, image.width, image.height);\n for (const mark of marks) {\n context.save();\n const width = strokeWidth(imageWidth, mark.weight);\n context.lineCap = 'round';\n context.lineJoin = 'round';\n context.lineWidth = width;\n context.strokeStyle = mark.color;\n context.fillStyle = mark.color;\n drawMark(context, base, mark, width, imageWidth, options.pixelRatio ?? 1);\n context.restore();\n }\n const chosen = options.selected === null || options.selected === undefined ? undefined : marks[options.selected];\n if (chosen !== undefined) {\n const accent = options.accent ?? '#0091FF';\n drawSelection(context, markBounds(chosen, imageWidth, canvasMeasure(context)), imageWidth, accent);\n if (chosen.tool === 'text' && chosen.tail !== undefined) drawHandle(context, chosen.tail, tailHandleRadius(imageWidth), accent);\n }\n if (options.cropPreview !== undefined && options.cropPreview !== null) drawCropPreview(context, image, options.cropPreview, imageWidth, options.pixelRatio ?? 1);\n context.restore();\n}\n\nfunction drawCropPreview(context: CanvasRenderingContext2D, view: Bounds, crop: Bounds, imageWidth: number, ratio: number): void {\n context.save();\n context.beginPath();\n context.rect(view.x, view.y, view.width, view.height);\n context.rect(crop.x, crop.y, crop.width, crop.height);\n context.fillStyle = 'rgba(0, 0, 0, 0.55)';\n context.fill('evenodd');\n const line = Math.max(1.5, imageWidth / 900);\n context.lineWidth = line;\n context.strokeStyle = '#FFFFFF';\n context.setLineDash([line * 5, line * 4]);\n context.strokeRect(crop.x, crop.y, crop.width, crop.height);\n context.setLineDash([]);\n pill(context, `${Math.round(crop.width / ratio)} × ${Math.round(crop.height / ratio)}`, { x: crop.x + crop.width / 2, y: crop.y + crop.height / 2 }, fontSize(imageWidth, 1), 'rgba(0,0,0,0.75)', '#FFFFFF');\n context.restore();\n}\n\n/** A rounded label centred on `at`. */\nfunction pill(context: CanvasRenderingContext2D, label: string, at: Point, size: number, fill: string, ink: string): void {\n context.save();\n context.font = `600 ${size}px ${FONT_FAMILY}`;\n const width = context.measureText(label).width + size;\n const height = size * 1.5;\n context.beginPath();\n context.roundRect(at.x - width / 2, at.y - height / 2, width, height, height / 2);\n context.fillStyle = fill;\n context.fill();\n context.fillStyle = ink;\n context.textAlign = 'center';\n context.textBaseline = 'middle';\n context.fillText(label, at.x, at.y + size * 0.05);\n context.restore();\n}\n\n/** `240 px`, or `250 px · 240 × 70` when the ruler is not straight; in the page's pixels. */\nexport function rulerLabel(from: Point, to: Point, ratio: number): string {\n const dx = Math.round(Math.abs(to.x - from.x) / ratio);\n const dy = Math.round(Math.abs(to.y - from.y) / ratio);\n const length = Math.round(Math.hypot(to.x - from.x, to.y - from.y) / ratio);\n return dx === 0 || dy === 0 ? `${length} px` : `${length} px · ${dx} × ${dy}`;\n}\n\n/** The grip on a selected callout's tail tip, in image pixels. */\nexport function tailHandleRadius(imageWidth: number): number {\n return Math.max(5, imageWidth / 220);\n}\n\nfunction drawHandle(context: CanvasRenderingContext2D, at: Point, radius: number, accent: string): void {\n context.save();\n context.beginPath();\n context.arc(at.x, at.y, radius, 0, Math.PI * 2);\n context.fillStyle = '#FFFFFF';\n context.fill();\n context.lineWidth = Math.max(1.5, radius / 3);\n context.strokeStyle = accent;\n context.stroke();\n context.restore();\n}\n\nfunction drawSelection(context: CanvasRenderingContext2D, box: Bounds, imageWidth: number, accent: string): void {\n const line = Math.max(1.5, imageWidth / 1000);\n const gap = line * 4;\n const x = box.x - gap;\n const y = box.y - gap;\n const width = box.width + 2 * gap;\n const height = box.height + 2 * gap;\n context.save();\n context.lineWidth = line;\n context.strokeStyle = accent;\n context.setLineDash([line * 4, line * 3]);\n context.strokeRect(x, y, width, height);\n context.setLineDash([]);\n context.fillStyle = '#FFFFFF';\n const handle = line * 5;\n for (const [hx, hy] of [\n [x, y],\n [x + width, y],\n [x, y + height],\n [x + width, y + height],\n ] as const) {\n context.fillRect(hx - handle / 2, hy - handle / 2, handle, handle);\n context.strokeRect(hx - handle / 2, hy - handle / 2, handle, handle);\n }\n context.restore();\n}\n\nfunction drawMark(\n context: CanvasRenderingContext2D,\n base: CanvasImageSource,\n mark: Mark,\n width: number,\n imageWidth: number,\n pixelRatio: number,\n): void {\n switch (mark.tool) {\n case 'ruler': {\n const line = Math.max(1.5, width * 0.45);\n const angle = Math.atan2(mark.to.y - mark.from.y, mark.to.x - mark.from.x);\n const normal = { x: -Math.sin(angle), y: Math.cos(angle) };\n const tick = line * 6;\n context.lineWidth = line;\n context.lineCap = 'butt';\n context.beginPath();\n context.moveTo(mark.from.x, mark.from.y);\n context.lineTo(mark.to.x, mark.to.y);\n for (const end of [mark.from, mark.to]) {\n context.moveTo(end.x + normal.x * tick, end.y + normal.y * tick);\n context.lineTo(end.x - normal.x * tick, end.y - normal.y * tick);\n }\n context.stroke();\n const size = fontSize(imageWidth, 1);\n // The label sits beside the middle of the line, on its upper side.\n const side = normal.y > 0 ? -1 : 1;\n const mid = { x: (mark.from.x + mark.to.x) / 2 + normal.x * side * size * 1.3, y: (mark.from.y + mark.to.y) / 2 + normal.y * side * size * 1.3 };\n pill(context, rulerLabel(mark.from, mark.to, pixelRatio), mid, size, mark.color, textColorOn(mark.color));\n return;\n }\n case 'arrow': {\n const [first, ...rest] = arrowOutline(mark.from, mark.to, width);\n if (first === undefined) return;\n context.beginPath();\n context.moveTo(first.x, first.y);\n for (const point of rest) context.lineTo(point.x, point.y);\n context.closePath();\n context.shadowColor = 'rgba(0, 0, 0, 0.25)';\n context.shadowBlur = width * 1.2;\n context.shadowOffsetY = width * 0.3;\n context.fill();\n return;\n }\n case 'rect': {\n const box = normalized(mark.from, mark.to);\n context.beginPath();\n context.roundRect(box.x, box.y, box.width, box.height, width * 1.5);\n context.stroke();\n return;\n }\n case 'highlight': {\n const box = normalized(mark.from, mark.to);\n context.globalAlpha = 0.3;\n context.fillRect(box.x, box.y, box.width, box.height);\n return;\n }\n case 'pixelate': {\n const box = normalized(mark.from, mark.to);\n if (box.width < 1 || box.height < 1) return;\n // Shrink the ORIGINAL pixels to a few blocks, then blow them back up unsmoothed.\n const block = Math.max(8, Math.round(imageWidth / 120) * (mark.weight === 3 ? 2 : 1));\n const small = document.createElement('canvas');\n small.width = Math.max(1, Math.round(box.width / block));\n small.height = Math.max(1, Math.round(box.height / block));\n small.getContext('2d')?.drawImage(base, box.x, box.y, box.width, box.height, 0, 0, small.width, small.height);\n context.imageSmoothingEnabled = false;\n context.drawImage(small, 0, 0, small.width, small.height, box.x, box.y, box.width, box.height);\n return;\n }\n case 'pen': {\n const [first, ...rest] = mark.points;\n if (first === undefined) return;\n context.beginPath();\n context.moveTo(first.x, first.y);\n for (const point of rest) context.lineTo(point.x, point.y);\n context.stroke();\n return;\n }\n case 'text': {\n const layout = calloutLayout(mark, imageWidth, canvasMeasure(context));\n const { box, size, padY, lineHeight, lines, radius } = layout;\n context.beginPath();\n context.roundRect(box.x, box.y, box.width, box.height, radius);\n const base = mark.tail === undefined ? null : tailBase(layout, mark.tail);\n if (base !== null && mark.tail !== undefined) {\n // Wound the same way as roundRect (clockwise on screen), so where the two overlap\n // the fill adds up instead of cancelling into a seam.\n const tip = mark.tail;\n const [a, c] = base;\n const turn = a.x * tip.y - tip.x * a.y + tip.x * c.y - c.x * tip.y + c.x * a.y - a.x * c.y;\n const [first, last] = turn >= 0 ? [a, c] : [c, a];\n context.moveTo(first.x, first.y);\n context.lineTo(tip.x, tip.y);\n context.lineTo(last.x, last.y);\n context.closePath();\n }\n context.shadowColor = 'rgba(0, 0, 0, 0.28)';\n context.shadowBlur = size * 0.5;\n context.shadowOffsetY = size * 0.12;\n context.fill('nonzero');\n context.shadowColor = 'transparent';\n context.fillStyle = textColorOn(mark.color);\n context.font = textFont(imageWidth, mark.weight);\n context.textAlign = 'center';\n context.textBaseline = 'middle';\n lines.forEach((line, index) => {\n context.fillText(line, box.x + box.width / 2, box.y + padY + index * lineHeight + lineHeight / 2);\n });\n return;\n }\n }\n}\n"],"mappings":";;;AAEA,SAAS,aAAa,aAAAA,YAAW,SAAS,UAAAC,SAAQ,YAAAC,iBAAgC;AAClF,SAAS,oBAAoB;;;ACctB,IAAM,WAAW;AAgCjB,IAAM,gBAAkE;AAAA,EAC7E,IAAI;AAAA,IACF,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM,CAAC,gBAAgB;AAAA,IACvB,QAAQ;AAAA;AAAA,MAEN;AAAA;AAAA,MAEA;AAAA,IACF;AAAA,EACF;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,QAAQ;AAAA;AAAA,IAER,MAAM,CAAC,0BAA0B;AAAA,IACjC,QAAQ;AAAA;AAAA,MAEN;AAAA;AAAA,MAEA;AAAA,IACF;AAAA,EACF;AAAA,EACA,IAAI;AAAA,IACF,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM,CAAC,MAAM;AAAA,IACb,QAAQ;AAAA,MACN;AAAA;AAAA,MAEA;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,YAAY,OAAO,KAAK,aAAa;AAE3C,IAAM,oBAAuC,EAAE,SAAS,MAAM,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE;AAGrG,IAAM,aACJ;AAEF,IAAM,QAAQ;AAWP,SAAS,eAAe,UAAuC;AACpE,MAAI,CAAC,SAAS,QAAS,QAAO,EAAE,SAAS,OAAO,UAAU,MAAM,OAAO,MAAM,CAAC,SAAS,KAAK;AAC5F,QAAM,QAAQ,S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AK,MAAM,UAAU;AACrB,WAAS,KAAK,YAAY,IAAI;AAC9B,OAAK,OAAO;AACZ,WAAS,YAAY,MAAM;AAC3B,OAAK,OAAO;AACd;","names":["useEffect","useRef","useState","section","section","TIMEOUT_MS","location","jsx","jsx","jsxs","FONT","jsx","jsxs","FONT","inside","useEffect","useLayoutEffect","useRef","useState","jsx","jsxs","FONT","LINE_HEIGHT","LINE_HEIGHT","half","y","reach","x","base","jsx","jsxs","useRef","useState","useLayoutEffect","frame","useEffect","onWheel","cropDraft","drag","drawing","cropBox","FONT","Divider","jsx","jsxs","useState","useEffect","useRef","inside"]}
|