@orkestrel/test 0.0.7 → 0.0.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/browser/constants.ts","../../../src/browser/helpers.ts","../../../src/browser/factories.ts"],"sourcesContent":["/**\n * The interactive ARIA roles a bare accessible name is searched across.\n *\n * @remarks\n * A person names a control, not a role, so the one-argument resolver searches every role a control\n * can compute. The two-argument form searches exactly the role it is given, which is how a name\n * shared by a tab and its panel is disambiguated.\n */\nexport const ACCESSIBLE_ROLES: readonly string[] = Object.freeze([\n\t'button',\n\t'checkbox',\n\t'combobox',\n\t'link',\n\t'listbox',\n\t'menuitem',\n\t'option',\n\t'radio',\n\t'searchbox',\n\t'slider',\n\t'spinbutton',\n\t'switch',\n\t'tab',\n\t'tabpanel',\n\t'textbox',\n\t'treeitem',\n])\n","import type { CaptureVariant } from './types.js'\nimport { page, userEvent } from 'vitest/browser'\nimport { ACCESSIBLE_ROLES } from './constants.js'\n\n/**\n * Determines whether a rectangle lies wholly outside the browser viewport.\n *\n * @param rectangle - The measured client rectangle to inspect.\n * @returns `true` when no part of the rectangle intersects the viewport.\n *\n * @example\n * ```ts\n * isOutsideViewport(element.getBoundingClientRect())\n * ```\n */\nexport function isOutsideViewport(rectangle: DOMRectReadOnly): boolean {\n\treturn (\n\t\trectangle.bottom <= 0 ||\n\t\trectangle.right <= 0 ||\n\t\trectangle.top >= window.innerHeight ||\n\t\trectangle.left >= window.innerWidth\n\t)\n}\n\n/**\n * Resolves one rendered, focus-reachable interactive element without requiring it to intersect the\n * viewport yet.\n *\n * @param first - The accessible name, or the exact ARIA role when `second` is present.\n * @param second - The accessible name when `first` supplies the role.\n * @returns The one rendered element carrying that name and optional role.\n * @throws When no matching element exists, every match is hidden or unreachable, or several\n * rendered matches make the name ambiguous.\n *\n * @remarks\n * This is the resolver the acting verbs use, so a click does not fail on a target the act itself\n * scrolls into view. Use {@link resolveAccessible} wherever the target must already be on screen.\n *\n * @example\n * ```ts\n * resolveRendered('tab', 'Drafts')\n * ```\n */\nexport function resolveRendered(first: string, second?: string): HTMLElement {\n\tconst name = second ?? first\n\tconst roles = second === undefined ? ACCESSIBLE_ROLES : [first]\n\tconst matches: HTMLElement[] = []\n\tfor (const role of roles) {\n\t\tfor (const element of page\n\t\t\t.getByRole(role, { name, exact: true, includeHidden: true })\n\t\t\t.elements()) {\n\t\t\tif (element instanceof HTMLElement && !matches.includes(element)) matches.push(element)\n\t\t}\n\t}\n\tif (matches.length === 0) {\n\t\tthrow new Error(`No interactive element has the accessible name \"${name}\"`)\n\t}\n\tconst reachable = matches.filter((element) => {\n\t\tconst rectangle = element.getBoundingClientRect()\n\t\treturn (\n\t\t\telement.isConnected &&\n\t\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\t\trectangle.width > 0 &&\n\t\t\trectangle.height > 0 &&\n\t\t\telement.tabIndex >= 0 &&\n\t\t\t!element.matches(':disabled, [aria-disabled=\"true\"]') &&\n\t\t\telement.closest('[inert]') === null\n\t\t)\n\t})\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Interactive target \"${name}\" is not visible and focus-reachable`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(`Interactive target \"${name}\" is ambiguous across ${reachable.length} elements`)\n\t}\n\tconst [target] = reachable\n\tif (target === undefined) throw new Error(`Interactive target \"${name}\" could not be resolved`)\n\treturn target\n}\n\n/**\n * Resolves one visible, focus-reachable interactive element by its exact accessible name. A\n * wholly-off-viewport target is scrolled into view before reachability is measured.\n *\n * @param name - The accessible name rendered for the target.\n * @returns The one reachable element carrying that name.\n * @throws When no matching element exists; every match is disconnected, hidden, zero-sized, still\n * outside the viewport after being scrolled into view, removed from sequential focus, disabled, or\n * inside an inert subtree; or several reachable matches make the name ambiguous.\n *\n * @example\n * ```ts\n * resolveAccessible('Save changes')\n * ```\n */\nexport function resolveAccessible(name: string): HTMLElement\n/**\n * Resolves one visible, focus-reachable interactive element by its exact ARIA role and accessible\n * name, disambiguating a bare name that answers for more than one rendered element. A\n * wholly-off-viewport target is scrolled into view before reachability is measured.\n *\n * @param role - The element's exact ARIA role.\n * @param name - The accessible name rendered for the target.\n * @returns The one reachable element carrying that role and name.\n * @throws When no matching element exists; every match is disconnected, hidden, zero-sized, still\n * outside the viewport after being scrolled into view, removed from sequential focus, disabled, or\n * inside an inert subtree; or several reachable matches make the role/name pair ambiguous.\n *\n * @example\n * ```ts\n * resolveAccessible('tab', 'Drafts')\n * ```\n */\nexport function resolveAccessible(role: string, name: string): HTMLElement\nexport function resolveAccessible(first: string, second?: string): HTMLElement {\n\tconst target = resolveRendered(first, second)\n\tlet rectangle = target.getBoundingClientRect()\n\tif (isOutsideViewport(rectangle)) {\n\t\ttarget.scrollIntoView({ block: 'nearest', behavior: 'instant' })\n\t\trectangle = target.getBoundingClientRect()\n\t}\n\tif (isOutsideViewport(rectangle)) {\n\t\tthrow new Error(`Interactive target \"${second ?? first}\" is unreachable after scrolling`)\n\t}\n\treturn target\n}\n\n/**\n * Clicks one visible, focus-reachable control by its accessible name through the browser provider.\n *\n * @param name - The target's exact accessible name.\n * @returns A promise resolving after trusted activation completes.\n *\n * @example\n * ```ts\n * await clickAccessible('Apply')\n * ```\n */\nexport async function clickAccessible(name: string): Promise<void>\n/**\n * Clicks one visible, focus-reachable control by its exact ARIA role and accessible name,\n * disambiguating a bare name that answers for more than one rendered element.\n *\n * @param role - The control's exact ARIA role.\n * @param name - The target's exact accessible name.\n * @returns A promise resolving after trusted activation completes.\n *\n * @example\n * ```ts\n * await clickAccessible('tab', 'Drafts')\n * ```\n */\nexport async function clickAccessible(role: string, name: string): Promise<void>\nexport async function clickAccessible(first: string, second?: string): Promise<void> {\n\tconst target = resolveRendered(first, second)\n\tawait userEvent.click(target)\n}\n\n/**\n * Clicks one human-reachable control by role and accessible-name text inside a named region.\n *\n * @param region - The containing region's exact accessible name.\n * @param role - The control's exact ARIA role.\n * @param name - The rendered accessible-name text that identifies the control in that region.\n * @returns A promise resolving after trusted activation completes.\n * @throws When the named control is absent, unreachable, or ambiguous inside the region.\n *\n * @remarks\n * Use this form when repeated short verbs such as `Add`, or a line whose status completes its\n * accessible name, need the same region context a person uses to disambiguate them.\n *\n * @example\n * ```ts\n * await clickAccessibleWithin('Ledger', 'button', 'Monthly income')\n * ```\n */\nexport async function clickAccessibleWithin(\n\tregion: string,\n\trole: string,\n\tname: string,\n): Promise<void> {\n\tconst matches = page\n\t\t.getByRole('region', { name: region, exact: true })\n\t\t.getByRole(role, { name, exact: false, includeHidden: true })\n\t\t.elements()\n\tconst reachable = matches.filter((element) => {\n\t\tif (!(element instanceof HTMLElement)) return false\n\t\tconst rectangle = element.getBoundingClientRect()\n\t\treturn (\n\t\t\telement.isConnected &&\n\t\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\t\trectangle.width > 0 &&\n\t\t\trectangle.height > 0 &&\n\t\t\telement.tabIndex >= 0 &&\n\t\t\t!element.matches(':disabled, [aria-disabled=\"true\"]') &&\n\t\t\telement.closest('[inert]') === null\n\t\t)\n\t})\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Interactive target \"${name}\" is not reachable inside \"${region}\"`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(\n\t\t\t`Interactive target \"${name}\" is ambiguous across ${reachable.length} elements inside \"${region}\"`,\n\t\t)\n\t}\n\tconst [target] = reachable\n\tif (!(target instanceof HTMLElement)) {\n\t\tthrow new Error(`Interactive target \"${name}\" could not be resolved inside \"${region}\"`)\n\t}\n\tawait userEvent.click(target)\n}\n\n/**\n * Opens or closes one native details disclosure by its rendered summary.\n *\n * @param name - The summary text a person reads.\n * @returns A promise resolving after trusted activation completes.\n * @throws When no visible, focus-reachable native summary has that rendered name, or several do.\n *\n * @remarks\n * Chromium exposes `<summary>` as a native disclosure rather than through an ARIA role accepted by\n * `getByRole`, so this resolver names the platform element and its rendered text directly.\n *\n * @example\n * ```ts\n * await clickDisclosure('Advanced')\n * ```\n */\nexport async function clickDisclosure(name: string): Promise<void> {\n\tconst matches = [...document.querySelectorAll('summary')].filter(\n\t\t(element) => element.innerText.replaceAll(/\\s+/g, ' ').trim() === name,\n\t)\n\tconst reachable = matches.filter((element) => {\n\t\tconst rectangle = element.getBoundingClientRect()\n\t\treturn (\n\t\t\telement.isConnected &&\n\t\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\t\trectangle.width > 0 &&\n\t\t\trectangle.height > 0 &&\n\t\t\telement.tabIndex >= 0 &&\n\t\t\telement.closest('[inert]') === null\n\t\t)\n\t})\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Native disclosure \"${name}\" is not visible and focus-reachable`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(`Native disclosure \"${name}\" is ambiguous across ${reachable.length} elements`)\n\t}\n\tconst [target] = reachable\n\tif (target === undefined) throw new Error(`Native disclosure \"${name}\" could not be resolved`)\n\tawait userEvent.click(target)\n}\n\n/**\n * Replaces a named field's value through focus, select-all, deletion, and real keystrokes.\n *\n * @param name - The field's exact accessible name.\n * @param text - The text to type.\n * @returns A promise resolving after every keystroke completes.\n *\n * @example\n * ```ts\n * await typeAccessible('Runs', '3')\n * ```\n */\nexport async function typeAccessible(name: string, text: string): Promise<void> {\n\tawait userEvent.click(resolveRendered(name))\n\tawait userEvent.keyboard('{Control>}a{/Control}{Backspace}')\n\tif (text === '') return\n\tawait userEvent.keyboard(text.replaceAll('{', '{{').replaceAll('[', '[['))\n}\n\n/**\n * Replaces a named field's value in one operation, for text too long to type key by key.\n *\n * @param name - The field's exact accessible name.\n * @param text - The text to place in the field.\n * @returns A promise resolving after the browser commits the value.\n *\n * @remarks\n * The provider drives the real element, so the field publishes the same input event a person's\n * typing publishes. Use {@link typeAccessible} wherever the keystrokes themselves are the subject.\n *\n * @example\n * ```ts\n * await fillAccessible('Payload', '{\"status\":\"ready\"}')\n * ```\n */\nexport async function fillAccessible(name: string, text: string): Promise<void> {\n\tawait userEvent.fill(resolveRendered(name), text)\n}\n\n/**\n * Presses a browser-keyboard sequence using Vitest's installed user-event syntax.\n *\n * @param keys - The keys or key descriptors to press.\n * @returns A promise resolving after the sequence completes.\n *\n * @example\n * ```ts\n * await pressKeys('{ArrowRight}{Enter}')\n * ```\n */\nexport async function pressKeys(keys: string): Promise<void> {\n\tawait userEvent.keyboard(keys)\n}\n\n/**\n * Reaches a named control only through natural forward Tab traversal from the current focus.\n *\n * @param name - The target's exact accessible name.\n * @returns The target after the browser moves focus to it.\n * @throws When one complete traversal cannot reach the target.\n *\n * @example\n * ```ts\n * await traverseAccessible('Evaluate')\n * ```\n */\nexport async function traverseAccessible(name: string): Promise<HTMLElement> {\n\tresolveRendered(name)\n\t// Two facts shape the loop. A Tab pressed before the page has real input focus moves nothing,\n\t// so a step counts only when focus actually lands somewhere; the traversal is over when focus\n\t// revisits an element, because that is one full cycle of the tab order. And the target is\n\t// re-resolved on every step, because a framework may replace the node between resolution and\n\t// focus arrival: the person's target is the role and name, never one node.\n\tconst cap =\n\t\tdocument.querySelectorAll<HTMLElement>('a[href], button, input, select, textarea, [tabindex]')\n\t\t\t.length *\n\t\t\t3 +\n\t\t10\n\tconst visited = new Set<Element>()\n\tconst trail: string[] = []\n\tfor (let attempt = 0; attempt < cap; attempt += 1) {\n\t\tawait userEvent.tab()\n\t\tconst focused = document.activeElement\n\t\tif (!(focused instanceof HTMLElement) || focused === document.body) continue\n\t\tlet current: HTMLElement | undefined\n\t\ttry {\n\t\t\tcurrent = resolveRendered(name)\n\t\t} catch {\n\t\t\tcontinue\n\t\t}\n\t\tif (focused === current) return current\n\t\tif (visited.has(focused)) break\n\t\tvisited.add(focused)\n\t\ttrail.push(`${focused.tagName}:${focused.innerText.slice(0, 20)}`)\n\t}\n\tthrow new Error(\n\t\t`Interactive target \"${name}\" is not reachable through forward Tab traversal: ${trail.join(' > ')}`,\n\t)\n}\n\n/**\n * Reads the normalized visible text of one named region, dialog, table, tab panel, or alert.\n *\n * @param name - The region's exact accessible name.\n * @returns The text a screen reader can perceive in the visible region, including descendant\n * visually-hidden content.\n * @throws When the named region is absent, hidden, or ambiguous.\n *\n * @example\n * ```ts\n * readPerception('Run')\n * ```\n */\nexport function readPerception(name: string): string {\n\tconst matches: HTMLElement[] = []\n\tfor (const role of ['alert', 'alertdialog', 'dialog', 'region', 'status', 'table', 'tabpanel']) {\n\t\tfor (const element of page\n\t\t\t.getByRole(role, { name, exact: true, includeHidden: true })\n\t\t\t.elements()) {\n\t\t\tif (element instanceof HTMLElement && !matches.includes(element)) matches.push(element)\n\t\t}\n\t}\n\tconst visible = matches.filter((element) => {\n\t\tconst rectangle = element.getBoundingClientRect()\n\t\treturn (\n\t\t\telement.isConnected &&\n\t\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\t\trectangle.width > 0 &&\n\t\t\trectangle.height > 0\n\t\t)\n\t})\n\tif (visible.length === 0) throw new Error(`Named region \"${name}\" is not visible`)\n\tif (visible.length > 1) {\n\t\tthrow new Error(`Named region \"${name}\" is ambiguous across ${visible.length} elements`)\n\t}\n\tconst [region] = visible\n\tif (region === undefined) throw new Error(`Named region \"${name}\" could not be resolved`)\n\treturn region.innerText.replaceAll(/\\s+/g, ' ').trim()\n}\n\n/**\n * Reads the normalized visible text of the whole page.\n *\n * @returns Every rendered word in the document body, its whitespace runs collapsed and trimmed.\n *\n * @remarks\n * This is the reader for a sentence that spans two regions and for a vocabulary sweep over the\n * words an interface uses. Reach for {@link readPerception} wherever one named region is the\n * subject, because that one throws when the region is missing and this one returns whatever is\n * there.\n *\n * @example\n * ```ts\n * readPage().includes('No cases yet')\n * ```\n */\nexport function readPage(): string {\n\treturn document.body.innerText.replaceAll(/\\s+/g, ' ').trim()\n}\n\n/**\n * Reads the rendered text of the element that currently holds focus.\n *\n * @returns The focused HTML element's trimmed rendered text, including an empty string, or\n * `undefined` when focus rests on a non-HTML element. When nothing holds focus, the browser\n * reports the document body as active, so the whole page's rendered text returns.\n *\n * @example\n * ```ts\n * await traverseAccessible('Evaluate')\n * readFocus() // 'Evaluate'\n * ```\n */\nexport function readFocus(): string | undefined {\n\tconst focused = document.activeElement\n\treturn focused instanceof HTMLElement ? focused.innerText.trim() : undefined\n}\n\n/**\n * Reads the value a resolved control renders.\n *\n * @param role - The control's exact ARIA role.\n * @param name - The control's exact accessible name.\n * @returns The control's current value.\n * @throws When the target does not resolve, or resolves to an element that carries no value.\n *\n * @remarks\n * A control's value is a rendered fact a person can read, not internal state, so it is read from\n * the resolved element rather than from the component that produced it.\n *\n * @example\n * ```ts\n * readValue('spinbutton', 'Runs') // '3'\n * ```\n */\nexport function readValue(role: string, name: string): string {\n\tconst control = resolveAccessible(role, name)\n\tif (\n\t\t!(control instanceof HTMLInputElement) &&\n\t\t!(control instanceof HTMLTextAreaElement) &&\n\t\t!(control instanceof HTMLSelectElement)\n\t) {\n\t\tthrow new Error(`Interactive target \"${name}\" does not carry a value`)\n\t}\n\treturn control.value\n}\n\n/**\n * Waits for one animation frame to settle pending browser paint work.\n *\n * @returns A promise resolving after one `requestAnimationFrame`.\n *\n * @example\n * ```ts\n * await waitForFrame()\n * ```\n */\nexport function waitForFrame(): Promise<void> {\n\treturn new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))\n}\n\n/**\n * Renders trusted fixture markup into a container attached to the document.\n *\n * @param markup - The fixture markup to render.\n * @returns The attached container.\n *\n * @example\n * ```ts\n * const container = render('<button type=\"button\">Save</button>')\n * container.remove()\n * ```\n */\nexport function render(markup: string): HTMLDivElement {\n\tconst container = document.createElement('div')\n\tcontainer.innerHTML = markup\n\tdocument.body.append(container)\n\treturn container\n}\n\n/**\n * Measures the WCAG 2.x contrast ratio between an element's computed text and background colors.\n *\n * @param element - The element whose rendered text contrast to measure.\n * @returns The relative-luminance contrast ratio.\n * @throws When the browser does not expose parseable computed colors.\n *\n * @remarks\n * A transparent or translucent background resolves through the element's ancestors: every painted\n * layer from the element up to the first opaque one composites top-over-bottom onto that opaque\n * base, so a 3% surface tint reads as a tint over what shows through it rather than as a\n * full-strength paint. A translucent foreground then resolves against that effective background\n * before luminance is measured.\n *\n * Every element from the target upwards must be reachable, and at least one of them must paint:\n * the measurement throws rather than assuming a white canvas when nothing in the chain declares a\n * background color. The element itself must expose a computed foreground color — a detached\n * element exposes none, and the measurement throws rather than guessing one.\n *\n * @example\n * ```ts\n * const container = render('<p style=\"background: #000; color: #fff\">Ready</p>')\n * contrast(requireValue(container.firstElementChild)) // 21\n * ```\n */\nexport function contrast(element: Element): number {\n\tconst foreground = getComputedStyle(element).color.match(/\\d+(?:\\.\\d+)?/g)\n\tif (foreground === null || foreground.length < 3) {\n\t\tthrow new Error('Computed foreground color is unavailable')\n\t}\n\tconst layers: number[][] = []\n\tlet current: Element | null = element\n\tlet opaque = false\n\twhile (current !== null) {\n\t\tconst channels = getComputedStyle(current).backgroundColor.match(/\\d+(?:\\.\\d+)?/g)\n\t\tif (channels !== null && channels.length >= 3) {\n\t\t\tconst layerAlpha = channels[3] === undefined ? 1 : Number(channels[3])\n\t\t\tif (layerAlpha > 0) {\n\t\t\t\tlayers.push([...channels.slice(0, 3).map(Number), layerAlpha])\n\t\t\t}\n\t\t\tif (layerAlpha >= 1) {\n\t\t\t\topaque = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tcurrent = current.parentElement\n\t}\n\tif (layers.length === 0) throw new Error('Computed background color is unavailable')\n\tconst base = layers[layers.length - 1]\n\tif (base === undefined) throw new Error('Computed background color is unavailable')\n\tlet composed = base.slice(0, 3).map((channel) => channel / 255)\n\tif (!opaque) composed = [1, 1, 1]\n\tconst start = opaque ? layers.length - 2 : layers.length - 1\n\tfor (let index = start; index >= 0; index -= 1) {\n\t\tconst layer = layers[index]\n\t\tif (layer === undefined) continue\n\t\tconst layerAlpha = layer[3] ?? 1\n\t\tcomposed = composed.map((channel, position) => {\n\t\t\tconst top = (layer[position] ?? 0) / 255\n\t\t\treturn top * layerAlpha + channel * (1 - layerAlpha)\n\t\t})\n\t}\n\n\tconst alpha = foreground[3] === undefined ? 1 : Number(foreground[3])\n\tconst backgroundChannels = composed\n\tconst foregroundChannels = foreground.slice(0, 3).map((channel, index) => {\n\t\tconst behind = backgroundChannels[index]\n\t\tif (behind === undefined) throw new Error('Computed background channel is unavailable')\n\t\treturn (Number(channel) / 255) * alpha + behind * (1 - alpha)\n\t})\n\tconst foregroundLinear = foregroundChannels.map((channel) =>\n\t\tchannel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4,\n\t)\n\tconst backgroundLinear = backgroundChannels.map((channel) =>\n\t\tchannel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4,\n\t)\n\tconst foregroundLuminance =\n\t\t0.2126 * (foregroundLinear[0] ?? 0) +\n\t\t0.7152 * (foregroundLinear[1] ?? 0) +\n\t\t0.0722 * (foregroundLinear[2] ?? 0)\n\tconst backgroundLuminance =\n\t\t0.2126 * (backgroundLinear[0] ?? 0) +\n\t\t0.7152 * (backgroundLinear[1] ?? 0) +\n\t\t0.0722 * (backgroundLinear[2] ?? 0)\n\tconst lighter = Math.max(foregroundLuminance, backgroundLuminance)\n\tconst darker = Math.min(foregroundLuminance, backgroundLuminance)\n\treturn (lighter + 0.05) / (darker + 0.05)\n}\n\n/**\n * Collects every class token the stylesheets loaded into this document actually define.\n *\n * @returns The set of class names reachable in the shipped cascade.\n *\n * @remarks\n * The set is what an authored-class conformance check measures against, so a class no loaded\n * stylesheet defines — an invented utility, a misspelled framework name — is absent from it.\n *\n * @example\n * ```ts\n * readCascade().has('card')\n * ```\n */\nexport function readCascade(): ReadonlySet<string> {\n\tconst known = new Set<string>()\n\tconst rules: CSSRule[] = []\n\tfor (const sheet of document.styleSheets) rules.push(...sheet.cssRules)\n\twhile (rules.length > 0) {\n\t\tconst rule = rules.pop()\n\t\tif (rule instanceof CSSGroupingRule) rules.push(...rule.cssRules)\n\t\tif (!(rule instanceof CSSStyleRule)) continue\n\t\tfor (const match of rule.selectorText.matchAll(/\\.([a-zA-Z][\\w-]*)/g)) {\n\t\t\tknown.add(String(match[1]))\n\t\t}\n\t}\n\treturn known\n}\n\n/**\n * Reads the normalized visible text of every element a selector matches, in document order.\n *\n * @param root - The subtree to search.\n * @param selector - The CSS selector naming the rows.\n * @returns One line per matched element, its text runs collapsed and single-space joined.\n *\n * @remarks\n * The line is built from the row's text nodes rather than from `textContent`, because adjacent\n * inline elements carry no whitespace between them in compiled template output and would otherwise\n * read as one run-together word.\n *\n * @example\n * ```ts\n * readRows(container, 'li')\n * ```\n */\nexport function readRows(root: ParentNode, selector: string): readonly string[] {\n\tconst rows: string[] = []\n\tfor (const row of root.querySelectorAll(selector)) {\n\t\tconst parts: string[] = []\n\t\tconst walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT)\n\t\twhile (walker.nextNode() !== null) {\n\t\t\tconst text = (walker.currentNode.textContent ?? '').replaceAll(/\\s+/g, ' ').trim()\n\t\t\tif (text !== '') parts.push(text)\n\t\t}\n\t\trows.push(parts.join(' '))\n\t}\n\treturn rows\n}\n\n/**\n * Reads one resolved CSS property from a real browser element.\n *\n * @param element - The element whose resolved style to inspect.\n * @param property - The CSS property name.\n * @returns The browser's resolved property value.\n *\n * @example\n * ```ts\n * style(button, 'padding-left')\n * ```\n */\nexport function style(element: Element, property: string): string {\n\treturn getComputedStyle(element).getPropertyValue(property)\n}\n\n/**\n * Expands a capture registry across every variant into the filenames a complete portfolio holds.\n *\n * @param states - The registered state names.\n * @param variants - The variants the portfolio is rendered in.\n * @returns One `<state>--<variant>.png` name per pair, each state's variants together, in registry\n * order.\n *\n * @remarks\n * The expansion is the portfolio's own definition of complete, so a duplicate in it is a registry\n * defect a proof reads directly rather than a collision discovered on disk.\n *\n * @example\n * ```ts\n * expandCaptures(['start'], [{ name: 'dark-390', width: 390, height: 844 }])\n * // ['start--dark-390.png']\n * ```\n */\nexport function expandCaptures(\n\tstates: readonly string[],\n\tvariants: readonly CaptureVariant[],\n): readonly string[] {\n\tconst files: string[] = []\n\tfor (const state of states) {\n\t\tfor (const variant of variants) files.push(`${state}--${variant.name}.png`)\n\t}\n\treturn files\n}\n","import type { PortfolioInterface, PortfolioOptions } from './types.js'\nimport { page } from 'vitest/browser'\nimport { expandCaptures } from './helpers.js'\n\n/**\n * Creates the capture portfolio one run places its screenshots through.\n *\n * @param options - The state registry, the variant matrix, the variant this run renders, the\n * directory it writes into, and whether it writes at all.\n * @returns The portfolio: its registry expansion, what it has placed, and `place`.\n * @throws When no registered variant carries the name `variant` names.\n *\n * @remarks\n * A disabled portfolio is the ordinary run. `place` then resizes nothing, writes nothing, and\n * records nothing, so a journey calls it unconditionally and a suite with the flag unset pays for\n * none of it. The portfolio refuses an unregistered variant at creation. An enabled run refuses an\n * unregistered state name and a second placement of one state.\n *\n * @example\n * ```ts\n * const portfolio = createPortfolio({\n * \tstates: ['start-empty'],\n * \tvariants: [{ name: 'dark-390', width: 390, height: 844 }],\n * \tvariant: 'dark-390',\n * \tdirectory: '../../tmp/capture/states',\n * })\n * await portfolio.place('start-empty')\n * ```\n */\nexport function createPortfolio(options: PortfolioOptions): PortfolioInterface {\n\tconst selected = options.variants.find((candidate) => candidate.name === options.variant)\n\tif (selected === undefined) {\n\t\tthrow new Error(`Capture variant \"${options.variant}\" is not registered`)\n\t}\n\tconst registry = [...options.states]\n\tconst files = expandCaptures(registry, options.variants)\n\tconst enabled = options.enabled ?? false\n\tconst placed: string[] = []\n\tconst paths: string[] = []\n\treturn {\n\t\tvariant: options.variant,\n\t\tfiles,\n\t\tget states() {\n\t\t\treturn [...placed]\n\t\t},\n\t\tget paths() {\n\t\t\treturn [...paths]\n\t\t},\n\t\tasync place(state) {\n\t\t\tif (!enabled) return undefined\n\t\t\tif (!registry.includes(state)) {\n\t\t\t\tthrow new Error(`Capture state \"${state}\" is not registered`)\n\t\t\t}\n\t\t\tif (placed.includes(state)) {\n\t\t\t\tthrow new Error(`Capture state \"${state}\" is already placed`)\n\t\t\t}\n\t\t\tconst file = `${state}--${options.variant}.png`\n\t\t\tselected.apply?.()\n\t\t\tif (window.innerWidth !== selected.width || window.innerHeight !== selected.height) {\n\t\t\t\tawait page.viewport(selected.width, selected.height)\n\t\t\t}\n\t\t\tconst written = await page.screenshot({ path: `${options.directory}/${file}` })\n\t\t\tplaced.push(state)\n\t\t\tpaths.push(written)\n\t\t\treturn written\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAa,mBAAsC,OAAO,OAAO;CAChE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;;;;;ACVD,SAAgB,kBAAkB,WAAqC;CACtE,OACC,UAAU,UAAU,KACpB,UAAU,SAAS,KACnB,UAAU,OAAO,OAAO,eACxB,UAAU,QAAQ,OAAO;AAE3B;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,gBAAgB,OAAe,QAA8B;CAC5E,MAAM,OAAO,UAAU;CACvB,MAAM,QAAQ,WAAW,KAAA,IAAY,mBAAmB,CAAC,KAAK;CAC9D,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,QAAQ,OAClB,KAAK,MAAM,WAAW,KACpB,UAAU,MAAM;EAAE;EAAM,OAAO;EAAM,eAAe;CAAK,CAAC,CAAC,CAC3D,SAAS,GACV,IAAI,mBAAmB,eAAe,CAAC,QAAQ,SAAS,OAAO,GAAG,QAAQ,KAAK,OAAO;CAGxF,IAAI,QAAQ,WAAW,GACtB,MAAM,IAAI,MAAM,mDAAmD,KAAK,EAAE;CAE3E,MAAM,YAAY,QAAQ,QAAQ,YAAY;EAC7C,MAAM,YAAY,QAAQ,sBAAsB;EAChD,OACC,QAAQ,eACR,QAAQ,gBAAgB;GAAE,cAAc;GAAM,oBAAoB;EAAK,CAAC,KACxE,UAAU,QAAQ,KAClB,UAAU,SAAS,KACnB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nC,MAAM,SAAmB,CAAC;CAC1B,MAAM,QAAkB,CAAC;CACzB,OAAO;EACN,SAAS,QAAQ;EACjB;EACA,IAAI,SAAS;GACZ,OAAO,CAAC,GAAG,MAAM;EAClB;EACA,IAAI,QAAQ;GACX,OAAO,CAAC,GAAG,KAAK;EACjB;EACA,MAAM,MAAM,OAAO;GAClB,IAAI,CAAC,SAAS,OAAO,KAAA;GACrB,IAAI,CAAC,SAAS,SAAS,KAAK,GAC3B,MAAM,IAAI,MAAM,kBAAkB,MAAM,oBAAoB;GAE7D,IAAI,OAAO,SAAS,KAAK,GACxB,MAAM,IAAI,MAAM,kBAAkB,MAAM,oBAAoB;GAE7D,MAAM,OAAO,GAAG,MAAM,IAAI,QAAQ,QAAQ;GAC1C,SAAS,QAAQ;GACjB,IAAI,OAAO,eAAe,SAAS,SAAS,OAAO,gBAAgB,SAAS,QAC3E,MAAM,KAAK,SAAS,SAAS,OAAO,SAAS,MAAM;GAEpD,MAAM,UAAU,MAAM,KAAK,WAAW,EAAE,MAAM,GAAG,QAAQ,UAAU,GAAG,OAAO,CAAC;GAC9E,OAAO,KAAK,KAAK;GACjB,MAAM,KAAK,OAAO;GAClB,OAAO;EACR;CACD;AACD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/browser/constants.ts","../../../src/browser/helpers.ts","../../../src/browser/factories.ts"],"sourcesContent":["import type { Color } from './types.js'\n\n/**\n * The interactive ARIA roles a bare accessible name is searched across.\n *\n * @remarks\n * A person names a control, not a role, so the one-argument resolver searches every role a control\n * can compute. The two-argument form searches exactly the role it is given, which is how a name\n * shared by a tab and its panel is disambiguated.\n */\nexport const ACCESSIBLE_ROLES: readonly string[] = Object.freeze([\n\t'button',\n\t'checkbox',\n\t'combobox',\n\t'link',\n\t'listbox',\n\t'menuitem',\n\t'option',\n\t'radio',\n\t'searchbox',\n\t'slider',\n\t'spinbutton',\n\t'switch',\n\t'tab',\n\t'tabpanel',\n\t'textbox',\n\t'treeitem',\n])\n\n/**\n * The page a browser paints an unstyled document onto.\n *\n * @remarks\n * This is the floor a backdrop walk ends on wherever the caller wants the browser's own canvas\n * assumed. `readBackdrop` takes its floor as an argument rather than reaching for this one, so a\n * measurement over a surface the canvas never shows through names the color it actually sits on.\n */\nexport const CANVAS_COLOR: Color = Object.freeze([255, 255, 255, 1])\n\n/**\n * The attribute marking the runner's tester pane, and the rule that sizes it, while a frame is\n * staged.\n *\n * @remarks\n * `stagePane` writes it onto the pane and onto the stylesheet it appends, and `releasePane` finds\n * both by it. Nothing else reads it, so a document carrying it after a capture returned is a pane\n * that was never released.\n */\nexport const CAPTURE_PANE = 'data-capture-pane'\n\n/**\n * The roles whose accessible name is the text a reader can see inside them.\n *\n * @remarks\n * `readName` reads an element in this list from its own rendered text, after every `aria-hidden`\n * descendant is dropped, and falls through to `title` for every other role.\n */\nexport const CONTENT_ROLES: readonly string[] = Object.freeze([\n\t'button',\n\t'cell',\n\t'columnheader',\n\t'heading',\n\t'link',\n\t'listitem',\n\t'option',\n\t'row',\n\t'rowheader',\n\t'tab',\n])\n\n/**\n * The role each `input` type carries.\n *\n * @remarks\n * Membership is the contract. The map answers for `button`, `checkbox`, `email`, `number`,\n * `password`, `radio`, `range`, `reset`, `search`, `submit`, `tel`, `text`, and `url`. A type the\n * map omits — `color`, `date`, `file`, `hidden`, and the rest — exposes no role of its own, so\n * `readRole` returns `undefined` for it and `describeTree` writes no line for it.\n */\nexport const FIELD_ROLES: Readonly<Record<string, string>> = Object.freeze({\n\tbutton: 'button',\n\tcheckbox: 'checkbox',\n\temail: 'textbox',\n\tnumber: 'spinbutton',\n\tpassword: 'textbox',\n\tradio: 'radio',\n\trange: 'slider',\n\treset: 'button',\n\tsearch: 'searchbox',\n\tsubmit: 'button',\n\ttel: 'textbox',\n\ttext: 'textbox',\n\turl: 'textbox',\n})\n\n/**\n * What sequential keyboard navigation can reach, before disabled and unrendered elements go.\n *\n * @remarks\n * `describeFocus` queries this selector and then drops what a browser drops: an element the\n * accessibility tree does not present, a disabled control, and one removed from the sequence by\n * `tabindex=\"-1\"`. `traverseAccessible` counts the same population to bound its walk, so this is\n * the one list either one reads.\n */\nexport const FOCUSABLE_SELECTOR =\n\t'a[href], area[href], button, input, select, summary, textarea, [tabindex]'\n\n/**\n * The role a `th` carries for the header axis its `scope` names.\n *\n * @remarks\n * A header cell heads a column or a row, and this map answers for the `col` and `row` scopes that\n * say which. A `th` declaring no scope keeps {@link IMPLICIT_ROLES}' `columnheader` rather than the\n * ARIA computation that infers the axis from the table's shape.\n */\nexport const HEADER_ROLES: Readonly<Record<string, string>> = Object.freeze({\n\tcol: 'columnheader',\n\trow: 'rowheader',\n})\n\n/**\n * The role each listed tag carries in the accessibility tree when it declares none of its own.\n *\n * @remarks\n * Membership is the contract. The map answers for the sectioning elements `ARTICLE`, `ASIDE`,\n * `FOOTER`, `HEADER`, `MAIN`, `NAV`, `SEARCH`, and `SECTION`; the headings `H1` through `H6`; the\n * grouping and list elements `FIELDSET`, `FORM`, `HR`, `LI`, `OL`, and `UL`; the table elements\n * `TABLE`, `TBODY`, `THEAD`, `TR`, `TD`, and `TH`; and the widgets `BUTTON`, `DIALOG`, `IMG`,\n * `OPTION`, `OUTPUT`, `PROGRESS`, `SUMMARY`, and `TEXTAREA`.\n *\n * A tag the map omits carries no implicit role, so `readRole` returns `undefined` for it,\n * `describeTree` writes no line for it, and the walk continues straight into its children at the\n * depth the omitted element sat at. `A`, `INPUT`, and `SELECT` are absent deliberately: each takes\n * its role from an attribute rather than from its tag, and `readRole` answers for them from their\n * own anatomy.\n *\n * `SECTION` maps to `region`, which `readRole` withholds from an unnamed one, because an unnamed\n * section is not a landmark. `TH` maps to `columnheader`, which {@link HEADER_ROLES} replaces when\n * the cell declares a `scope`.\n */\nexport const IMPLICIT_ROLES: Readonly<Record<string, string>> = Object.freeze({\n\tARTICLE: 'article',\n\tASIDE: 'complementary',\n\tBUTTON: 'button',\n\tDIALOG: 'dialog',\n\tFIELDSET: 'group',\n\tFOOTER: 'contentinfo',\n\tFORM: 'form',\n\tH1: 'heading',\n\tH2: 'heading',\n\tH3: 'heading',\n\tH4: 'heading',\n\tH5: 'heading',\n\tH6: 'heading',\n\tHEADER: 'banner',\n\tHR: 'separator',\n\tIMG: 'img',\n\tLI: 'listitem',\n\tMAIN: 'main',\n\tNAV: 'navigation',\n\tOL: 'list',\n\tOPTION: 'option',\n\tOUTPUT: 'status',\n\tPROGRESS: 'progressbar',\n\tSEARCH: 'search',\n\tSECTION: 'region',\n\tSUMMARY: 'button',\n\tTABLE: 'table',\n\tTBODY: 'rowgroup',\n\tTD: 'cell',\n\tTEXTAREA: 'textbox',\n\tTH: 'columnheader',\n\tTHEAD: 'rowgroup',\n\tTR: 'row',\n\tUL: 'list',\n})\n","import type { CaptureVariant, Color, ElementOptions, FrameOptions } from './types.js'\nimport { commands, page, userEvent } from 'vitest/browser'\nimport {\n\tACCESSIBLE_ROLES,\n\tCANVAS_COLOR,\n\tCAPTURE_PANE,\n\tCONTENT_ROLES,\n\tFIELD_ROLES,\n\tFOCUSABLE_SELECTOR,\n\tHEADER_ROLES,\n\tIMPLICIT_ROLES,\n} from './constants.js'\n\n/**\n * Determines whether a rectangle lies wholly outside the browser viewport.\n *\n * @param rectangle - The measured client rectangle to inspect.\n * @returns `true` when no part of the rectangle intersects the viewport.\n *\n * @example\n * ```ts\n * isOutsideViewport(element.getBoundingClientRect())\n * ```\n */\nexport function isOutsideViewport(rectangle: DOMRectReadOnly): boolean {\n\treturn (\n\t\trectangle.bottom <= 0 ||\n\t\trectangle.right <= 0 ||\n\t\trectangle.top >= window.innerHeight ||\n\t\trectangle.left >= window.innerWidth\n\t)\n}\n\n/**\n * Determines whether a person can click one element where it currently sits.\n *\n * @param element - The element to judge.\n * @returns `true` when the element is connected, visible, laid out with a non-zero box, in the\n * sequential focus order, neither disabled nor marked `aria-disabled=\"true\"`, and outside every\n * `[inert]` subtree; `false` otherwise.\n *\n * @remarks\n * This is the one reachability filter the layer applies. `resolveRendered`, `clickAccessibleWithin`,\n * and `clickDisclosure` each narrow their own candidates and then keep the ones this accepts, so a\n * journey meets one rule rather than three near-copies of it.\n *\n * It measures geometry, which is what separates it from {@link isRendered}. A control clipped to a\n * zero-size rectangle is announced and is not clickable, so `isRendered` accepts it and this\n * refuses it. Nothing here asks about the viewport: `resolveAccessible` scrolls a wholly\n * off-viewport target into view and measures that separately with {@link isOutsideViewport}.\n *\n * @example\n * ```ts\n * isReachable(requireValue(container.querySelector('button')))\n * ```\n */\nexport function isReachable(element: Element): boolean {\n\tif (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false\n\tconst rectangle = element.getBoundingClientRect()\n\treturn (\n\t\telement.isConnected &&\n\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\trectangle.width > 0 &&\n\t\trectangle.height > 0 &&\n\t\telement.tabIndex >= 0 &&\n\t\t!element.matches(':disabled, [aria-disabled=\"true\"]') &&\n\t\telement.closest('[inert]') === null\n\t)\n}\n\n/**\n * Determines whether the accessibility tree presents one element at all.\n *\n * @param element - The element to judge.\n * @returns `false` when the element is hidden from assistive technology, from sight, or from both;\n * `true` otherwise.\n *\n * @remarks\n * A control clipped to a zero-size rectangle is still announced, which is the whole point of that\n * idiom, so nothing here reads geometry: only the removals a browser honours — `aria-hidden`\n * anywhere above it, the `hidden` attribute, a hidden input, and a `display` or `visibility` that\n * takes it off the page. {@link isReachable} is the clickable half of the pair and does read\n * geometry.\n *\n * The last two are asked about the element's ancestors as well as itself, which reading a computed\n * `display` cannot do: the computed value of a child of a `display: none` container is the child's\n * own, so a control inside a closed drawer reports itself as laid out. `checkVisibility` answers\n * for the box tree, and `visibility` inherits, so between them an ancestor cannot hide a control\n * from a reader and leave it standing in a description.\n *\n * @example\n * ```ts\n * isRendered(requireValue(container.querySelector('[aria-hidden=\"true\"] button'))) // false\n * ```\n */\nexport function isRendered(element: Element): boolean {\n\tif (element.closest('[aria-hidden=\"true\"]') !== null) return false\n\tif (element instanceof HTMLElement && element.hidden) return false\n\tif (element instanceof HTMLInputElement && element.type === 'hidden') return false\n\tif (!element.checkVisibility()) return false\n\treturn getComputedStyle(element).visibility !== 'hidden'\n}\n\n/**\n * Resolves one rendered, focus-reachable interactive element without requiring it to intersect the\n * viewport yet.\n *\n * @param first - The accessible name, or the exact ARIA role when `second` is present.\n * @param second - The accessible name when `first` supplies the role.\n * @returns The one rendered element carrying that name and optional role.\n * @throws When no matching element exists, every match is hidden or unreachable, or several\n * rendered matches make the name ambiguous.\n *\n * @remarks\n * This is the resolver the acting verbs use, so a click does not fail on a target the act itself\n * scrolls into view. Use {@link resolveAccessible} wherever the target must already be on screen.\n *\n * @example\n * ```ts\n * resolveRendered('tab', 'Drafts')\n * ```\n */\nexport function resolveRendered(first: string, second?: string): HTMLElement {\n\tconst name = second ?? first\n\tconst roles = second === undefined ? ACCESSIBLE_ROLES : [first]\n\tconst matches: HTMLElement[] = []\n\tfor (const role of roles) {\n\t\tfor (const element of page\n\t\t\t.getByRole(role, { name, exact: true, includeHidden: true })\n\t\t\t.elements()) {\n\t\t\tif (element instanceof HTMLElement && !matches.includes(element)) matches.push(element)\n\t\t}\n\t}\n\tif (matches.length === 0) {\n\t\tthrow new Error(`No interactive element has the accessible name \"${name}\"`)\n\t}\n\tconst reachable = matches.filter((element) => isReachable(element))\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Interactive target \"${name}\" is not visible and focus-reachable`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(`Interactive target \"${name}\" is ambiguous across ${reachable.length} elements`)\n\t}\n\tconst [target] = reachable\n\tif (target === undefined) throw new Error(`Interactive target \"${name}\" could not be resolved`)\n\treturn target\n}\n\n/**\n * Resolves one visible, focus-reachable interactive element by its exact accessible name. A\n * wholly-off-viewport target is scrolled into view before reachability is measured.\n *\n * @param name - The accessible name rendered for the target.\n * @returns The one reachable element carrying that name.\n * @throws When no matching element exists; every match is disconnected, hidden, zero-sized, still\n * outside the viewport after being scrolled into view, removed from sequential focus, disabled, or\n * inside an inert subtree; or several reachable matches make the name ambiguous.\n *\n * @example\n * ```ts\n * resolveAccessible('Save changes')\n * ```\n */\nexport function resolveAccessible(name: string): HTMLElement\n/**\n * Resolves one visible, focus-reachable interactive element by its exact ARIA role and accessible\n * name, disambiguating a bare name that answers for more than one rendered element. A\n * wholly-off-viewport target is scrolled into view before reachability is measured.\n *\n * @param role - The element's exact ARIA role.\n * @param name - The accessible name rendered for the target.\n * @returns The one reachable element carrying that role and name.\n * @throws When no matching element exists; every match is disconnected, hidden, zero-sized, still\n * outside the viewport after being scrolled into view, removed from sequential focus, disabled, or\n * inside an inert subtree; or several reachable matches make the role/name pair ambiguous.\n *\n * @example\n * ```ts\n * resolveAccessible('tab', 'Drafts')\n * ```\n */\nexport function resolveAccessible(role: string, name: string): HTMLElement\nexport function resolveAccessible(first: string, second?: string): HTMLElement {\n\tconst target = resolveRendered(first, second)\n\tlet rectangle = target.getBoundingClientRect()\n\tif (isOutsideViewport(rectangle)) {\n\t\ttarget.scrollIntoView({ block: 'nearest', behavior: 'instant' })\n\t\trectangle = target.getBoundingClientRect()\n\t}\n\tif (isOutsideViewport(rectangle)) {\n\t\tthrow new Error(`Interactive target \"${second ?? first}\" is unreachable after scrolling`)\n\t}\n\treturn target\n}\n\n/**\n * Clicks one visible, focus-reachable control by its accessible name through the browser provider.\n *\n * @param name - The target's exact accessible name.\n * @returns A promise resolving after trusted activation completes.\n *\n * @example\n * ```ts\n * await clickAccessible('Apply')\n * ```\n */\nexport async function clickAccessible(name: string): Promise<void>\n/**\n * Clicks one visible, focus-reachable control by its exact ARIA role and accessible name,\n * disambiguating a bare name that answers for more than one rendered element.\n *\n * @param role - The control's exact ARIA role.\n * @param name - The target's exact accessible name.\n * @returns A promise resolving after trusted activation completes.\n *\n * @example\n * ```ts\n * await clickAccessible('tab', 'Drafts')\n * ```\n */\nexport async function clickAccessible(role: string, name: string): Promise<void>\nexport async function clickAccessible(first: string, second?: string): Promise<void> {\n\tconst target = resolveRendered(first, second)\n\tawait userEvent.click(target)\n}\n\n/**\n * Clicks one human-reachable control by role and accessible-name text inside a named region.\n *\n * @param region - The containing region's exact accessible name.\n * @param role - The control's exact ARIA role.\n * @param name - The rendered accessible-name text that identifies the control in that region.\n * @returns A promise resolving after trusted activation completes.\n * @throws When the named control is absent, unreachable, or ambiguous inside the region.\n *\n * @remarks\n * Use this form when repeated short verbs such as `Add`, or a line whose status completes its\n * accessible name, need the same region context a person uses to disambiguate them.\n *\n * @example\n * ```ts\n * await clickAccessibleWithin('Ledger', 'button', 'Monthly income')\n * ```\n */\nexport async function clickAccessibleWithin(\n\tregion: string,\n\trole: string,\n\tname: string,\n): Promise<void> {\n\tconst matches = page\n\t\t.getByRole('region', { name: region, exact: true })\n\t\t.getByRole(role, { name, exact: false, includeHidden: true })\n\t\t.elements()\n\tconst reachable = matches.filter(\n\t\t(element) => element instanceof HTMLElement && isReachable(element),\n\t)\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Interactive target \"${name}\" is not reachable inside \"${region}\"`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(\n\t\t\t`Interactive target \"${name}\" is ambiguous across ${reachable.length} elements inside \"${region}\"`,\n\t\t)\n\t}\n\tconst [target] = reachable\n\tif (!(target instanceof HTMLElement)) {\n\t\tthrow new Error(`Interactive target \"${name}\" could not be resolved inside \"${region}\"`)\n\t}\n\tawait userEvent.click(target)\n}\n\n/**\n * Opens or closes one native details disclosure by its rendered summary.\n *\n * @param name - The summary text a person reads.\n * @returns A promise resolving after trusted activation completes.\n * @throws When no native summary with that rendered name passes {@link isReachable}, or several do.\n *\n * @remarks\n * Chromium exposes `<summary>` as a native disclosure rather than through an ARIA role accepted by\n * `getByRole`, so this resolver names the platform element and its rendered text directly.\n *\n * It applies the same {@link isReachable} filter the other acting verbs apply, so a summary marked\n * `aria-disabled=\"true\"` is refused here exactly as a button marked that way is refused there.\n *\n * @example\n * ```ts\n * await clickDisclosure('Advanced')\n * ```\n */\nexport async function clickDisclosure(name: string): Promise<void> {\n\tconst matches = [...document.querySelectorAll('summary')].filter(\n\t\t(element) => element.innerText.replaceAll(/\\s+/g, ' ').trim() === name,\n\t)\n\tconst reachable = matches.filter((element) => isReachable(element))\n\tif (reachable.length === 0) {\n\t\tthrow new Error(`Native disclosure \"${name}\" is not visible and focus-reachable`)\n\t}\n\tif (reachable.length > 1) {\n\t\tthrow new Error(`Native disclosure \"${name}\" is ambiguous across ${reachable.length} elements`)\n\t}\n\tconst [target] = reachable\n\tif (target === undefined) throw new Error(`Native disclosure \"${name}\" could not be resolved`)\n\tawait userEvent.click(target)\n}\n\n/**\n * Replaces a named field's value through focus, select-all, deletion, and real keystrokes.\n *\n * @param name - The field's exact accessible name.\n * @param text - The text to type.\n * @returns A promise resolving after every keystroke completes.\n *\n * @example\n * ```ts\n * await typeAccessible('Runs', '3')\n * ```\n */\nexport async function typeAccessible(name: string, text: string): Promise<void> {\n\tawait userEvent.click(resolveRendered(name))\n\tawait userEvent.keyboard('{Control>}a{/Control}{Backspace}')\n\tif (text === '') return\n\tawait userEvent.keyboard(text.replaceAll('{', '{{').replaceAll('[', '[['))\n}\n\n/**\n * Replaces a named field's value in one operation, for text too long to type key by key.\n *\n * @param name - The field's exact accessible name.\n * @param text - The text to place in the field.\n * @returns A promise resolving after the browser commits the value.\n *\n * @remarks\n * The provider drives the real element, so the field publishes the same input event a person's\n * typing publishes. Use {@link typeAccessible} wherever the keystrokes themselves are the subject.\n *\n * @example\n * ```ts\n * await fillAccessible('Payload', '{\"status\":\"ready\"}')\n * ```\n */\nexport async function fillAccessible(name: string, text: string): Promise<void> {\n\tawait userEvent.fill(resolveRendered(name), text)\n}\n\n/**\n * Presses a browser-keyboard sequence using Vitest's installed user-event syntax.\n *\n * @param keys - The keys or key descriptors to press.\n * @returns A promise resolving after the sequence completes.\n *\n * @example\n * ```ts\n * await pressKeys('{ArrowRight}{Enter}')\n * ```\n */\nexport async function pressKeys(keys: string): Promise<void> {\n\tawait userEvent.keyboard(keys)\n}\n\n/**\n * Reaches a named control only through natural forward Tab traversal from the current focus.\n *\n * @param name - The target's exact accessible name.\n * @returns The target after the browser moves focus to it.\n * @throws When one complete traversal cannot reach the target.\n *\n * @example\n * ```ts\n * await traverseAccessible('Evaluate')\n * ```\n */\nexport async function traverseAccessible(name: string): Promise<HTMLElement> {\n\tresolveRendered(name)\n\t// Two facts shape the loop. A Tab pressed before the page has real input focus moves nothing,\n\t// so a step counts only when focus actually lands somewhere; the traversal is over when focus\n\t// revisits an element, because that is one full cycle of the tab order. And the target is\n\t// re-resolved on every step, because a framework may replace the node between resolution and\n\t// focus arrival: the person's target is the role and name, never one node.\n\t// The bound is counted off `FOCUSABLE_SELECTOR`, the one population this environment reads\n\t// sequential navigation from, so a tag the selector gains is a tag this traversal budgets for.\n\tconst cap = document.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR).length * 3 + 10\n\tconst visited = new Set<Element>()\n\tconst trail: string[] = []\n\tfor (let attempt = 0; attempt < cap; attempt += 1) {\n\t\tawait userEvent.tab()\n\t\tconst focused = document.activeElement\n\t\tif (!(focused instanceof HTMLElement) || focused === document.body) continue\n\t\tlet current: HTMLElement | undefined\n\t\ttry {\n\t\t\tcurrent = resolveRendered(name)\n\t\t} catch {\n\t\t\tcontinue\n\t\t}\n\t\tif (focused === current) return current\n\t\tif (visited.has(focused)) break\n\t\tvisited.add(focused)\n\t\ttrail.push(`${focused.tagName}:${focused.innerText.slice(0, 20)}`)\n\t}\n\tthrow new Error(\n\t\t`Interactive target \"${name}\" is not reachable through forward Tab traversal: ${trail.join(' > ')}`,\n\t)\n}\n\n/**\n * Reads the normalized visible text of one named region, dialog, table, tab panel, or alert.\n *\n * @param name - The region's exact accessible name.\n * @returns The text a screen reader can perceive in the visible region, including descendant\n * visually-hidden content.\n * @throws When the named region is absent, hidden, or ambiguous.\n *\n * @example\n * ```ts\n * readPerception('Run')\n * ```\n */\nexport function readPerception(name: string): string {\n\tconst matches: HTMLElement[] = []\n\tfor (const role of ['alert', 'alertdialog', 'dialog', 'region', 'status', 'table', 'tabpanel']) {\n\t\tfor (const element of page\n\t\t\t.getByRole(role, { name, exact: true, includeHidden: true })\n\t\t\t.elements()) {\n\t\t\tif (element instanceof HTMLElement && !matches.includes(element)) matches.push(element)\n\t\t}\n\t}\n\tconst visible = matches.filter((element) => {\n\t\tconst rectangle = element.getBoundingClientRect()\n\t\treturn (\n\t\t\telement.isConnected &&\n\t\t\telement.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&\n\t\t\trectangle.width > 0 &&\n\t\t\trectangle.height > 0\n\t\t)\n\t})\n\tif (visible.length === 0) throw new Error(`Named region \"${name}\" is not visible`)\n\tif (visible.length > 1) {\n\t\tthrow new Error(`Named region \"${name}\" is ambiguous across ${visible.length} elements`)\n\t}\n\tconst [region] = visible\n\tif (region === undefined) throw new Error(`Named region \"${name}\" could not be resolved`)\n\treturn region.innerText.replaceAll(/\\s+/g, ' ').trim()\n}\n\n/**\n * Reads the normalized visible text of the whole page.\n *\n * @returns Every rendered word in the document body, its whitespace runs collapsed and trimmed.\n *\n * @remarks\n * This is the reader for a sentence that spans two regions and for a vocabulary sweep over the\n * words an interface uses. Reach for {@link readPerception} wherever one named region is the\n * subject, because that one throws when the region is missing and this one returns whatever is\n * there.\n *\n * @example\n * ```ts\n * readPage().includes('No cases yet')\n * ```\n */\nexport function readPage(): string {\n\treturn document.body.innerText.replaceAll(/\\s+/g, ' ').trim()\n}\n\n/**\n * Reads the rendered text of the element that currently holds focus.\n *\n * @returns The focused HTML element's trimmed rendered text, including an empty string, or\n * `undefined` when focus rests on a non-HTML element. When nothing holds focus, the browser\n * reports the document body as active, so the whole page's rendered text returns.\n *\n * @example\n * ```ts\n * await traverseAccessible('Evaluate')\n * readFocus() // 'Evaluate'\n * ```\n */\nexport function readFocus(): string | undefined {\n\tconst focused = document.activeElement\n\treturn focused instanceof HTMLElement ? focused.innerText.trim() : undefined\n}\n\n/**\n * Reads the value a resolved control renders.\n *\n * @param role - The control's exact ARIA role.\n * @param name - The control's exact accessible name.\n * @returns The control's current value.\n * @throws When the target does not resolve, or resolves to an element that carries no value.\n *\n * @remarks\n * A control's value is a rendered fact a person can read, not internal state, so it is read from\n * the resolved element rather than from the component that produced it.\n *\n * @example\n * ```ts\n * readValue('spinbutton', 'Runs') // '3'\n * ```\n */\nexport function readValue(role: string, name: string): string {\n\tconst control = resolveAccessible(role, name)\n\tif (\n\t\t!(control instanceof HTMLInputElement) &&\n\t\t!(control instanceof HTMLTextAreaElement) &&\n\t\t!(control instanceof HTMLSelectElement)\n\t) {\n\t\tthrow new Error(`Interactive target \"${name}\" does not carry a value`)\n\t}\n\treturn control.value\n}\n\n/**\n * Reads one element's rendered text the way a name computation reads it.\n *\n * @param element - The element whose announced words are wanted.\n * @returns The text with every `aria-hidden` descendant dropped and whitespace runs collapsed.\n *\n * @remarks\n * A glyph marked `aria-hidden` contributes nothing to a name, so a control captioned by an icon\n * plus a word reads as the word alone — which is what a reader hears, and what a verdict citing a\n * description has to compare against the copy a template writes. Reach for `readRows` wherever the\n * subject is what the page paints rather than what it announces: that one keeps the glyph.\n *\n * @example\n * ```ts\n * readText(requireValue(container.querySelector('button'))) // 'Save'\n * ```\n */\nexport function readText(element: Element): string {\n\tconst parts: string[] = []\n\tconst walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT)\n\tfor (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {\n\t\tconst owner = node.parentElement\n\t\tif (owner === null || owner.closest('[aria-hidden=\"true\"]') !== null) continue\n\t\tparts.push(node.textContent ?? '')\n\t}\n\treturn parts.join(' ').replaceAll(/\\s+/g, ' ').trim()\n}\n\n/**\n * Reads the role one element carries in the accessibility tree.\n *\n * @param element - The element to classify.\n * @returns The declared role, the implicit one, or `undefined` when the element carries none.\n *\n * @remarks\n * A declared `role` wins outright, and its first token is the answer when several are listed.\n * Otherwise the element's own anatomy decides: an anchor is a link only while it holds an `href`,\n * an `input` takes the role {@link FIELD_ROLES} gives its type, a `select` is a combobox until it\n * offers several rows at once, a `section` is a region only once something names it, and a `th`\n * heads whichever axis its `scope` names. Every other tag answers from {@link IMPLICIT_ROLES},\n * whose membership is the contract for what this can answer at all.\n *\n * @example\n * ```ts\n * readRole(requireValue(container.querySelector('a[href]'))) // 'link'\n * ```\n */\nexport function readRole(element: Element): string | undefined {\n\tconst declared = element.getAttribute('role')?.trim()\n\tif (declared !== undefined && declared.length > 0) return declared.split(/\\s+/)[0]\n\tif (element instanceof HTMLAnchorElement) return element.href.length > 0 ? 'link' : undefined\n\tif (element instanceof HTMLInputElement) return FIELD_ROLES[element.type]\n\tif (element instanceof HTMLSelectElement) {\n\t\treturn element.multiple || element.size > 1 ? 'listbox' : 'combobox'\n\t}\n\tconst implicit = IMPLICIT_ROLES[element.tagName]\n\tconst scope = element.tagName === 'TH' ? element.getAttribute('scope')?.trim() : undefined\n\tif (scope !== undefined) return HEADER_ROLES[scope] ?? implicit\n\tif (\n\t\timplicit === 'region' &&\n\t\t!element.hasAttribute('aria-label') &&\n\t\t!element.hasAttribute('aria-labelledby')\n\t) {\n\t\treturn undefined\n\t}\n\treturn implicit\n}\n\n/**\n * Reads the accessible name one element is announced under.\n *\n * @param element - The element to name.\n * @returns The computed name, or an empty string when the element carries none.\n *\n * @remarks\n * The order is the one a browser follows: `aria-labelledby`, then `aria-label`, then a form\n * control's own labels, then an image's `alt`, then the text inside a role {@link CONTENT_ROLES}\n * names, then `title`. A submit, reset, or button input is named by its value, because it renders\n * no text to read. An `aria-labelledby` naming several ids joins their texts in the order the\n * attribute lists them, and an id nothing answers for is skipped rather than fatal.\n *\n * Each step answers only when it has something to say, so a step that carries nothing hands the\n * element to the next one. An image whose `alt` is absent or blank is the case that shows it:\n * `<img title=\"Chart\">` is named `Chart` rather than the empty string its own `alt` step would\n * have returned, and an image carrying both keeps answering `alt`.\n *\n * @example\n * ```ts\n * readName(requireValue(container.querySelector('button'))) // 'Save changes'\n * ```\n */\nexport function readName(element: Element): string {\n\tconst referenced = element.getAttribute('aria-labelledby')\n\tif (referenced !== null) {\n\t\tconst named = referenced\n\t\t\t.split(/\\s+/)\n\t\t\t.map((id) => element.ownerDocument.getElementById(id))\n\t\t\t.filter((node) => node !== null)\n\t\t\t.map((node) => readText(node))\n\t\t\t.filter((text) => text.length > 0)\n\t\tif (named.length > 0) return named.join(' ')\n\t}\n\tconst labelled = element.getAttribute('aria-label')?.trim()\n\tif (labelled !== undefined && labelled.length > 0) return labelled\n\tif (\n\t\telement instanceof HTMLInputElement ||\n\t\telement instanceof HTMLSelectElement ||\n\t\telement instanceof HTMLTextAreaElement\n\t) {\n\t\tconst labels = [...(element.labels ?? [])]\n\t\t\t.map((label) => readText(label))\n\t\t\t.filter((text) => text.length > 0)\n\t\tif (labels.length > 0) return labels.join(' ')\n\t\tif (element instanceof HTMLInputElement && element.value.length > 0) {\n\t\t\tif (FIELD_ROLES[element.type] === 'button') return element.value\n\t\t}\n\t}\n\tif (element instanceof HTMLImageElement) {\n\t\tconst alternative = element.alt.trim()\n\t\tif (alternative.length > 0) return alternative\n\t}\n\tconst role = readRole(element)\n\tif (role !== undefined && CONTENT_ROLES.includes(role)) {\n\t\tconst text = readText(element)\n\t\tif (text.length > 0) return text\n\t}\n\treturn element.getAttribute('title')?.trim() ?? ''\n}\n\n/**\n * Reads the states one element is announced in.\n *\n * @param element - The element to read.\n * @returns Every state the element declares, in one fixed order.\n *\n * @remarks\n * A state a reader is told about is one this records: what is unavailable, disclosed, pressed,\n * current, refused, chosen, announcing itself, demanded, uneditable, described, or busy. The order\n * is fixed, so two descriptions of the same surface are comparable line for line.\n *\n * A native disclosure states its expansion on the parent `details` element's own `open` rather than\n * on an ARIA attribute, so a summary that declares no `aria-expanded` is read from the platform's\n * one copy of that fact.\n *\n * @example\n * ```ts\n * readStates(requireValue(container.querySelector('summary'))) // ['collapsed']\n * ```\n */\nexport function readStates(element: Element): readonly string[] {\n\tconst states: string[] = []\n\tif (element.matches(':disabled') || element.getAttribute('aria-disabled') === 'true') {\n\t\tstates.push('disabled')\n\t}\n\tconst expanded = element.getAttribute('aria-expanded')\n\tif (expanded === 'true') states.push('expanded')\n\tif (expanded === 'false') states.push('collapsed')\n\tif (\n\t\texpanded === null &&\n\t\telement.tagName === 'SUMMARY' &&\n\t\telement.parentElement instanceof HTMLDetailsElement\n\t) {\n\t\tstates.push(element.parentElement.open ? 'expanded' : 'collapsed')\n\t}\n\tconst pressed = element.getAttribute('aria-pressed')\n\tif (pressed !== null) states.push(`pressed=${pressed}`)\n\tconst current = element.getAttribute('aria-current')\n\tif (current !== null && current !== 'false') states.push('current')\n\tif (element.getAttribute('aria-invalid') === 'true') states.push('invalid')\n\tconst checked =\n\t\telement instanceof HTMLInputElement\n\t\t\t? element.checked\n\t\t\t: element.getAttribute('aria-checked') === 'true'\n\tif (checked) states.push('checked')\n\tconst selected = element.getAttribute('aria-selected')\n\tif (selected !== null) states.push(`selected=${selected}`)\n\tconst live = element.getAttribute('aria-live')\n\tif (live !== null) states.push(`live=${live}`)\n\tif (element.matches(':required')) states.push('required')\n\tif (element instanceof HTMLInputElement && element.readOnly) states.push('readonly')\n\tif (element.hasAttribute('aria-describedby')) states.push('described')\n\tif (element.getAttribute('aria-busy') === 'true') states.push('busy')\n\treturn Object.freeze(states)\n}\n\n/**\n * Describes the accessible tree one rendered element presents.\n *\n * @param element - The host to walk, which is described first when it carries a role of its own.\n * @returns One indented line per element carrying a role, naming its role, its name, and its\n * states, in document order; an empty string when nothing in the subtree carries one.\n *\n * @remarks\n * The walk is over the real rendered DOM, so what it reports is the tree the shipped markup and the\n * shipped cascade produce together — a landmark lost to a hidden ancestor is missing here exactly as\n * it is missing for a reader. An element {@link isRendered} refuses is dropped with its whole\n * subtree.\n *\n * Depth follows the roles rather than the elements, so the indentation reads as the structure a\n * screen reader announces instead of as the markup's nesting. An element {@link readRole} answers\n * `undefined` for writes no line and adds no depth, so its children sit where it sat. That is how\n * a wrapper `div` disappears, and it is also how an element {@link IMPLICIT_ROLES} does not answer\n * for disappears — visibly, because its roled children stay at the depth it occupied.\n *\n * @example\n * ```ts\n * describeTree(container)\n * // main \"Board\"\n * // heading \"Totals\"\n * ```\n */\nexport function describeTree(element: Element): string {\n\tconst lines: string[] = []\n\tconst pending: Array<{ readonly node: Element; readonly depth: number }> = [\n\t\t{ node: element, depth: 0 },\n\t]\n\twhile (pending.length > 0) {\n\t\tconst entry = pending.pop()\n\t\tif (entry === undefined) break\n\t\tif (!isRendered(entry.node)) continue\n\t\tconst role = readRole(entry.node)\n\t\tlet depth = entry.depth\n\t\tif (role !== undefined) {\n\t\t\tconst name = readName(entry.node)\n\t\t\tconst states = readStates(entry.node)\n\t\t\tlines.push(\n\t\t\t\t`${' '.repeat(depth)}${role}${name.length > 0 ? ` \"${name}\"` : ''}${\n\t\t\t\t\tstates.length > 0 ? ` [${states.join(', ')}]` : ''\n\t\t\t\t}`,\n\t\t\t)\n\t\t\tdepth += 1\n\t\t}\n\t\tfor (let index = entry.node.children.length - 1; index >= 0; index -= 1) {\n\t\t\tconst child = entry.node.children[index]\n\t\t\tif (child !== undefined) pending.push({ node: child, depth })\n\t\t}\n\t}\n\treturn lines.join('\\n')\n}\n\n/**\n * Describes the order sequential keyboard navigation visits one element's controls in.\n *\n * @param element - The host to walk; its own controls are described, and it is not itself one.\n * @returns One numbered line per reachable control, naming its role and its name.\n *\n * @remarks\n * A positive `tabindex` is honoured, because a browser honours it: those controls come first in\n * ascending order and everything else follows in document order. A control removed from the\n * sequence by `tabindex=\"-1\"`, by being disabled, or by not being rendered at all is absent here,\n * which is the fact a focus-order verdict is about. A control {@link readRole} answers `undefined`\n * for is named by its lowercased tag, so it is still counted rather than silently dropped.\n *\n * @example\n * ```ts\n * describeFocus(container)\n * // 1. button \"Save\"\n * // 2. link \"Cancel\"\n * ```\n */\nexport function describeFocus(element: Element): string {\n\treturn [...element.querySelectorAll(FOCUSABLE_SELECTOR)]\n\t\t.filter(\n\t\t\t(node) =>\n\t\t\t\tisRendered(node) && !node.matches(':disabled') && node.getAttribute('tabindex') !== '-1',\n\t\t)\n\t\t.sort((first, second) => {\n\t\t\tconst left = Number.parseInt(first.getAttribute('tabindex') ?? '0', 10)\n\t\t\tconst right = Number.parseInt(second.getAttribute('tabindex') ?? '0', 10)\n\t\t\tif (left > 0 && right > 0) return left - right\n\t\t\tif (left > 0) return -1\n\t\t\tif (right > 0) return 1\n\t\t\treturn 0\n\t\t})\n\t\t.map((node, index) => {\n\t\t\tconst role = readRole(node) ?? node.tagName.toLowerCase()\n\t\t\tconst name = readName(node)\n\t\t\treturn `${String(index + 1)}. ${role}${name.length > 0 ? ` \"${name}\"` : ''}`\n\t\t})\n\t\t.join('\\n')\n}\n\n/**\n * Waits for one animation frame to settle pending browser paint work.\n *\n * @returns A promise resolving after one `requestAnimationFrame`.\n *\n * @example\n * ```ts\n * await waitForFrame()\n * ```\n */\nexport function waitForFrame(): Promise<void> {\n\treturn new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))\n}\n\n/**\n * Builds one unmounted element of a known tag, wearing the classes, text, and attributes asked for.\n *\n * @param tag - The HTML tag name, which fixes the returned element's exact type.\n * @param options - The class list, the text, and the attributes to apply.\n * @returns The built element, not yet in any document.\n *\n * @remarks\n * The element is unmounted on purpose, so a fixture is assembled before the page ever sees it and a\n * test decides where it goes. Nothing here resolves against the cascade: a built element computes no\n * style and lays out no box until {@link mount} puts it in the document.\n *\n * The text is set as text rather than parsed as markup, so a `<` in it stays a `<`. Use\n * {@link render} where the fixture is markup.\n *\n * @example\n * ```ts\n * const button = build('button', { classes: 'primary', text: 'Save', attributes: { type: 'button' } })\n * ```\n */\nexport function build<K extends keyof HTMLElementTagNameMap>(\n\ttag: K,\n\toptions?: ElementOptions,\n): HTMLElementTagNameMap[K] {\n\tconst element = document.createElement(tag)\n\tif (options?.classes !== undefined) element.className = options.classes\n\tif (options?.text !== undefined) element.textContent = options.text\n\tfor (const [name, value] of Object.entries(options?.attributes ?? {})) {\n\t\telement.setAttribute(name, value)\n\t}\n\treturn element\n}\n\n/**\n * Puts one element into the document and hands it straight back.\n *\n * @param element - The element to attach.\n * @returns The same element, now appended to `document.body`.\n *\n * @remarks\n * What this buys is the composition, not the attachment: the `append` method returns `void`, and\n * this hands the element back, so it fits where an expression is expected. The {@link render} helper\n * returns its fixture through it, and the {@link rgba} helper probes through `mount(build('span'))`.\n * A bare `append` call breaks each of those call sites.\n *\n * Being connected is what the attachment then buys: `getComputedStyle` resolves against the shipped\n * cascade, custom properties inherit from `:root`, and the element lays out a real box. A detached\n * element answers each of those questions with the initial value instead, which reads as a styling\n * defect rather than as a detached node.\n *\n * Taking it back out belongs to the consumer's teardown, because this records nothing: a browser\n * test file shares one page, so a fixture left behind is the next test's resolver ambiguity. Build a\n * recorded container in a setup module and remove it from an `afterEach` hook.\n *\n * @example\n * ```ts\n * const panel = mount(build('div', { classes: 'surface' }))\n * panel.remove()\n * ```\n */\nexport function mount<T extends Element>(element: T): T {\n\tdocument.body.append(element)\n\treturn element\n}\n\n/**\n * Renders one fixture into the document, from trusted markup or from a tag and its classes.\n *\n * @param first - The fixture markup, or the HTML tag name when `second` is present.\n * @param second - The class list when `first` supplies the tag name.\n * @returns The attached container for the markup form, and the attached element itself for the tag\n * form.\n *\n * @remarks\n * The class list is required in the tag form, which is what keeps the two forms apart: a\n * one-argument call is always markup. A tag with no classes is `mount(build(tag))`.\n *\n * The markup form parses `first` into a fresh container and returns that container, so the fixture's\n * own nodes are its children. The tag form returns the element itself, typed as exactly that tag.\n * Both attach to `document.body` and neither records anything, so removal is the caller's, exactly\n * as it is for {@link mount}.\n *\n * @example\n * ```ts\n * const container = render('<button type=\"button\">Save</button>')\n * const panel = render('section', 'surface muted')\n * container.remove()\n * panel.remove()\n * ```\n */\nexport function render(markup: string): HTMLDivElement\nexport function render<K extends keyof HTMLElementTagNameMap>(\n\ttag: K,\n\tclasses: string,\n): HTMLElementTagNameMap[K]\nexport function render(first: string, second?: string): HTMLElement {\n\tif (second === undefined) {\n\t\tconst container = build('div')\n\t\tcontainer.innerHTML = first\n\t\treturn mount(container)\n\t}\n\t// `build` is generic over the known tag names and this signature carries a plain string, so the\n\t// tag branch cannot route through it without an assertion. It applies the class list the one way\n\t// `build` applies it, so the two forms stay one behaviour.\n\tconst element = document.createElement(first)\n\telement.className = second\n\treturn mount(element)\n}\n\n/**\n * Sets one field's value and announces it the way typing into the field does.\n *\n * @param element - The input or textarea to write into.\n * @param text - The value to set.\n *\n * @remarks\n * This is the synthetic pair of {@link typeAccessible}, for a component that listens for `input` and\n * a test that has the element already. It sets the value in one write and dispatches one bubbling\n * `input` event, so a delegated listener on an ancestor hears it. It sends no keystrokes, so a\n * component reading `key`, composition, or selection sees nothing. The dispatched event is a plain\n * `Event`, never an `InputEvent`, so a component reading `inputType` or testing\n * `instanceof InputEvent` sees neither. Drive a component that reads any of those through\n * `typeAccessible` instead.\n *\n * No `change` event follows. Use {@link commitInput} where the component waits for the field to be\n * committed.\n *\n * @example\n * ```ts\n * typeInput(requireValue(container.querySelector('input')), 'Ada')\n * ```\n */\nexport function typeInput(element: HTMLInputElement | HTMLTextAreaElement, text: string): void {\n\telement.value = text\n\telement.dispatchEvent(new Event('input', { bubbles: true }))\n}\n\n/**\n * Sets one field's value and commits it, the way typing and then leaving the field does.\n *\n * @param element - The input or textarea to write into.\n * @param text - The value to set.\n *\n * @remarks\n * The order is the browser's: {@link typeInput} first, so `input` is dispatched with the value\n * already set, and one bubbling `change` after it. A component that reads the value from either\n * event therefore reads `text` from both.\n *\n * @example\n * ```ts\n * commitInput(requireValue(container.querySelector('input')), 'Ada')\n * ```\n */\nexport function commitInput(element: HTMLInputElement | HTMLTextAreaElement, text: string): void {\n\ttypeInput(element, text)\n\telement.dispatchEvent(new Event('change', { bubbles: true }))\n}\n\n/**\n * Clears both browser storage surfaces.\n *\n * @remarks\n * A browser test file shares one page, so a key written by one test is read by the next one that\n * looks for it. Call this from an `afterEach` hook, which runs after a failed test as well as a\n * passing one, rather than at the end of each test that happens to write a key.\n *\n * @example\n * ```ts\n * afterEach(clearStorage)\n * ```\n */\nexport function clearStorage(): void {\n\tlocalStorage.clear()\n\tsessionStorage.clear()\n}\n\n/**\n * Deletes one IndexedDB database and reports what the request actually did.\n *\n * @param name - The database name to delete.\n * @returns A promise resolving after the deletion completes.\n * @throws Thrown when the request errors, and when an open connection blocks it.\n *\n * @remarks\n * Deleting a database that was never created succeeds, so this is safe to call from a teardown hook\n * that runs whether or not the test reached the code that opens one.\n *\n * A block is a rejection rather than a wait. `blocked` fires when another connection is still open,\n * and a suite that swallowed it would leave the next test reading the previous test's records\n * through a database that reports itself deleted. The connection holding it open is the caller's to\n * close, so the block is handed back rather than absorbed.\n *\n * @example\n * ```ts\n * afterEach(() => removeDatabase('ledger'))\n * ```\n */\nexport function removeDatabase(name: string): Promise<void> {\n\treturn new Promise<void>((resolve, reject) => {\n\t\tconst request = globalThis.indexedDB.deleteDatabase(name)\n\t\trequest.addEventListener('success', () => resolve())\n\t\trequest.addEventListener('error', () =>\n\t\t\treject(new Error(`IndexedDB database \"${name}\" could not be deleted`)),\n\t\t)\n\t\trequest.addEventListener('blocked', () =>\n\t\t\treject(new Error(`IndexedDB database \"${name}\" is blocked by an open connection`)),\n\t\t)\n\t})\n}\n\n/**\n * Parses one computed CSS color value into straight sRGB channels.\n *\n * @param value - A computed `rgb()`, `rgba()`, or `color(srgb …)` value.\n * @returns The color's channels, or `undefined` when the value names no color this reader speaks.\n *\n * @remarks\n * A computed color resolves to `rgb()` or `rgba()` for every legacy source, and a `color-mix()`\n * declaration resolves to `color(srgb r g b [/ a])` with channels on the 0–1 scale. Both forms are\n * read here and nothing else is: a keyword, a hex triple, an empty string from a detached element,\n * and a color space the cascade never hands back all return `undefined`. Absence is the answer\n * rather than a transparent color, so a caller decides what an unreadable value means instead of\n * measuring a black it never saw.\n *\n * @example\n * ```ts\n * parseColor('rgba(255, 255, 255, 0.5)') // [255, 255, 255, 0.5]\n * parseColor('rebeccapurple') // undefined\n * ```\n */\nexport function parseColor(value: string): Color | undefined {\n\tconst modern =\n\t\t/^color\\(srgb\\s+(?<red>[\\d.]+)\\s+(?<green>[\\d.]+)\\s+(?<blue>[\\d.]+)(?:\\s*\\/\\s*(?<alpha>[\\d.]+))?\\)$/u.exec(\n\t\t\tvalue,\n\t\t)\n\tconst legacy = /^rgba?\\((?<channels>[^)]*)\\)$/u.exec(value)\n\tconst parts =\n\t\tmodern?.groups === undefined\n\t\t\t? (legacy?.groups?.channels ?? '')\n\t\t\t\t\t.split(/[\\s,/]+/u)\n\t\t\t\t\t.filter((part) => part.length > 0)\n\t\t\t\t\t.map((part) => Number.parseFloat(part))\n\t\t\t: [\n\t\t\t\t\tNumber.parseFloat(modern.groups.red ?? '') * 255,\n\t\t\t\t\tNumber.parseFloat(modern.groups.green ?? '') * 255,\n\t\t\t\t\tNumber.parseFloat(modern.groups.blue ?? '') * 255,\n\t\t\t\t\tmodern.groups.alpha === undefined ? 1 : Number.parseFloat(modern.groups.alpha),\n\t\t\t\t]\n\tconst [red, green, blue, alpha = 1] = parts\n\tif (red === undefined || green === undefined || blue === undefined) return undefined\n\tif (![red, green, blue, alpha].every((channel) => Number.isFinite(channel))) return undefined\n\treturn Object.freeze([red, green, blue, alpha])\n}\n\n/**\n * Resolves any CSS color expression to straight sRGB channels, by asking the browser.\n *\n * @param value - Any value the `color` property accepts: a keyword, a hex triple, a `var()`\n * reference, a `color-mix()`, or an already-computed `rgb()`.\n * @returns The resolved color's channels, or `undefined` when the CSSOM refuses the value or the\n * computed result names no color {@link parseColor} speaks.\n *\n * @remarks\n * This is the live half of the pair {@link parseColor} opens. `parseColor` reads text and speaks\n * only the computed syntaxes a cascade hands back; this stages a probe element, hands it to the real\n * cascade, and reads back what the engine computed — which is the only way a keyword, a hex triple,\n * or a `var()` reference becomes channels at all. The read itself goes through `parseColor`, so both\n * halves agree on what a computed value means.\n *\n * The probe is mounted, because an unmounted element inherits nothing and a `var()` reference to a\n * token declared on `:root` would resolve to the initial value instead. It is removed in a `finally`,\n * so a value that throws on the way through leaves no node behind.\n *\n * Refusal is the CSSOM's: an expression it will not parse leaves the probe's inline `color` empty\n * and this returns `undefined`. A `var()` naming an undeclared custom property is not refused,\n * because the cascade accepts it and computes the inherited color, so a test that means to catch a\n * missing token asserts on {@link token} rather than on this.\n *\n * @example\n * ```ts\n * rgba('rebeccapurple') // [102, 51, 153, 1]\n * rgba('not-a-color') // undefined\n * ```\n */\nexport function rgba(value: string): Color | undefined {\n\tconst probe = mount(build('span'))\n\ttry {\n\t\tprobe.style.color = value\n\t\tif (probe.style.color === '') return undefined\n\t\treturn parseColor(style(probe, 'color'))\n\t} finally {\n\t\tprobe.remove()\n\t}\n}\n\n/**\n * Determines whether two colors render the same, within the rounding a browser does.\n *\n * @param first - A CSS color expression or an already-parsed color.\n * @param second - A CSS color expression or an already-parsed color.\n * @returns `true` when every channel and the alpha agree within the tolerance; `false` otherwise,\n * including when either side names no readable color.\n *\n * @remarks\n * Each string side is resolved through {@link rgba}, so a keyword, a token reference, and the\n * `rgb()` the engine computes for either of them compare equal without a test converting anything\n * first. A side that resolves to nothing makes the answer `false` rather than a throw, because this\n * is a predicate.\n *\n * The tolerance is half a channel step on the 0–255 scale, and the alpha is scaled onto that same\n * range before it is compared, so one number covers both. Half a step is what a composite of\n * translucent layers and a `color-mix()` round trip actually drift by; anything a reader could see\n * is further than that and reports unequal.\n *\n * @example\n * ```ts\n * colorEqual('rebeccapurple', 'rgb(102, 51, 153)') // true\n * colorEqual('red', [0, 0, 255, 1]) // false\n * ```\n */\nexport function colorEqual(first: string | Color, second: string | Color): boolean {\n\tconst left = typeof first === 'string' ? rgba(first) : first\n\tconst right = typeof second === 'string' ? rgba(second) : second\n\tif (left === undefined || right === undefined) return false\n\tconst tolerance = 0.5\n\tconst [leftRed, leftGreen, leftBlue, leftAlpha] = left\n\tconst [rightRed, rightGreen, rightBlue, rightAlpha] = right\n\treturn (\n\t\tMath.abs(leftRed - rightRed) <= tolerance &&\n\t\tMath.abs(leftGreen - rightGreen) <= tolerance &&\n\t\tMath.abs(leftBlue - rightBlue) <= tolerance &&\n\t\tMath.abs(leftAlpha - rightAlpha) * 255 <= tolerance\n\t)\n}\n\n/**\n * Composites one color over another.\n *\n * @param front - The color painted on top.\n * @param back - The color already on the surface.\n * @returns The opaque result a reader sees, its alpha always `1`.\n *\n * @example\n * ```ts\n * blendColor([255, 255, 255, 0.5], [0, 0, 0, 1]) // [127.5, 127.5, 127.5, 1]\n * ```\n */\nexport function blendColor(front: Color, back: Color): Color {\n\tconst [red, green, blue, alpha] = front\n\tconst [under, over, beneath] = back\n\treturn Object.freeze([\n\t\tred * alpha + under * (1 - alpha),\n\t\tgreen * alpha + over * (1 - alpha),\n\t\tblue * alpha + beneath * (1 - alpha),\n\t\t1,\n\t])\n}\n\n/**\n * Measures one opaque color's WCAG relative luminance.\n *\n * @param color - The color to weigh. Its alpha is ignored, so composite before calling.\n * @returns The relative luminance, from `0` for black to `1` for white.\n *\n * @example\n * ```ts\n * measureLuminance([255, 255, 255, 1]) // 1\n * ```\n */\nexport function measureLuminance(color: Color): number {\n\tconst [red, green, blue] = color\n\tconst [first = 0, second = 0, third = 0] = [red, green, blue].map((channel) => {\n\t\tconst part = channel / 255\n\t\treturn part <= 0.040_45 ? part / 12.92 : ((part + 0.055) / 1.055) ** 2.4\n\t})\n\treturn 0.2126 * first + 0.7152 * second + 0.0722 * third\n}\n\n/**\n * Measures the WCAG 2.x contrast ratio between two opaque colors.\n *\n * @param front - The foreground color, already composited.\n * @param back - The opaque backdrop.\n * @returns The ratio, from `1` for two identical colors to `21` for black against white.\n *\n * @remarks\n * The ratio is symmetric: the brighter of the two luminances is always the numerator, so swapping\n * the arguments returns the same number.\n *\n * @example\n * ```ts\n * measureContrast([0, 0, 0, 1], [255, 255, 255, 1]) // 21\n * ```\n */\nexport function measureContrast(front: Color, back: Color): number {\n\tconst bright = Math.max(measureLuminance(front), measureLuminance(back))\n\tconst dark = Math.min(measureLuminance(front), measureLuminance(back))\n\treturn (bright + 0.05) / (dark + 0.05)\n}\n\n/**\n * Collects the painted layers standing between one element and the surface it sits on.\n *\n * @param element - The element to walk up from.\n * @returns Every layer the walk paints, the element's own first and the deepest last.\n *\n * @remarks\n * A surface token paints one ancestor while every element between it and the text paints nothing,\n * so a backdrop is found by walking up rather than by reading the element's own `background-color`,\n * which is almost always transparent. A fully transparent layer paints nothing and is left out, and\n * the walk stops at the first fully opaque layer, because nothing above that layer is visible.\n *\n * The stack is what tells a resolved backdrop from an assumed one: the walk reached an opaque\n * surface exactly when its last layer's alpha is `1`. {@link contrast} refuses on that reading,\n * which no comparison of composited colors can replace — 64 half-transparent layers composite to\n * the same channels over opposite floors, because the floor's remaining share falls below the last\n * bit a channel carries.\n *\n * @example\n * ```ts\n * readLayers(requireValue(container.querySelector('p')))\n * ```\n */\nexport function readLayers(element: Element): readonly Color[] {\n\tconst layers: Color[] = []\n\tfor (let node: Element | null = element; node !== null; node = node.parentElement) {\n\t\tconst layer = parseColor(getComputedStyle(node).backgroundColor)\n\t\tif (layer === undefined || layer[3] === 0) continue\n\t\tlayers.push(layer)\n\t\tif (layer[3] >= 1) break\n\t}\n\treturn Object.freeze(layers)\n}\n\n/**\n * Resolves the opaque color standing behind one element.\n *\n * @param element - The element whose backdrop to resolve.\n * @param floor - The opaque color the walk ends on when nothing above it paints.\n * @returns The composited color a reader sees behind the element.\n *\n * @remarks\n * The layers {@link readLayers} collects composite top-over-bottom onto the floor, so a 3% surface\n * tint reads as a tint over what shows through it rather than as a full-strength paint.\n *\n * The floor is required, because this leaf never guesses what a document sits on. Pass\n * {@link CANVAS_COLOR} for the page a browser paints behind an unstyled document, or the color of\n * the surface a fragment is really rendered into. When no layer paints, the floor is returned by\n * identity.\n *\n * The composite alone never says whether the floor is part of the answer. A caller that must know\n * reads the stack instead.\n *\n * @example\n * ```ts\n * readBackdrop(requireValue(container.querySelector('p')), CANVAS_COLOR)\n * ```\n */\nexport function readBackdrop(element: Element, floor: Color): Color {\n\treturn readLayers(element).reduceRight((back, front) => blendColor(front, back), floor)\n}\n\n/**\n * Measures the WCAG 2.x contrast ratio between an element's computed text and background colors.\n *\n * @param element - The element whose rendered text contrast to measure.\n * @param floor - The opaque color the backdrop walk ends on. Omit it to refuse a stack the floor\n * would show through instead of assuming one.\n * @returns The relative-luminance contrast ratio.\n * @throws Thrown when the element exposes no computed foreground color, and — with `floor` omitted\n * — when the walk from the element upwards reaches no opaque layer.\n *\n * @remarks\n * A transparent or translucent background resolves through the element's ancestors: every painted\n * layer from the element up to the first opaque one composites top-over-bottom onto that opaque\n * base, so a 3% surface tint reads as a tint over what shows through it rather than as a\n * full-strength paint. A translucent foreground then resolves against that effective background\n * before luminance is measured.\n *\n * With `floor` omitted, the walk from the target upwards must reach a fully opaque layer: the\n * measurement throws rather than assuming a white canvas wherever that canvas would still be part\n * of the answer. The refusal reads the alpha of the deepest layer {@link readLayers} collected, so\n * a chain that declares no background color at all, a chain painting only translucent layers, and a\n * chain deep enough for its composite to round to the canvas's own channels are refused alike,\n * because the number any of them produces is as much a report of the assumption as of the page.\n * Supply a floor wherever the caller knows what the stack sits on — a fragment mounted into a\n * painted host, or a document whose canvas is {@link CANVAS_COLOR} — and the composite is taken\n * over it rather than refused.\n *\n * The element itself must expose a computed foreground color either way. A detached element exposes\n * none, and the measurement throws rather than guessing one.\n *\n * @example\n * ```ts\n * const container = render('<p style=\"background: #000; color: #fff\">Ready</p>')\n * contrast(requireValue(container.firstElementChild)) // 21\n * contrast(requireValue(container.firstElementChild), CANVAS_COLOR) // 21, and never refuses\n * ```\n */\nexport function contrast(element: Element, floor?: Color): number {\n\tconst foreground = parseColor(getComputedStyle(element).color)\n\tif (foreground === undefined) throw new Error('Computed foreground color is unavailable')\n\tconst layers = readLayers(element)\n\tconst deepest = layers.at(-1)\n\t// The walk reached a real surface exactly when its deepest layer is fully opaque. An empty stack\n\t// paints nothing, and a stack ending translucent leaves the floor showing through whatever the\n\t// composite reports: 64 half-transparent layers round to identical channels over opposite floors,\n\t// so comparing two composited readings admits the stack this refusal exists for.\n\tif (floor === undefined && (deepest === undefined || deepest[3] < 1)) {\n\t\tthrow new Error('Computed background color is unavailable')\n\t}\n\tconst backdrop = layers.reduceRight(\n\t\t(back, front) => blendColor(front, back),\n\t\tfloor ?? CANVAS_COLOR,\n\t)\n\treturn measureContrast(blendColor(foreground, backdrop), backdrop)\n}\n\n/**\n * Measures the contrast the focus chrome painted on one control reaches against its own backdrop.\n *\n * @param control - The control that holds the focus.\n * @param worn - The element the control's focus chrome is painted onto. Default: `control`.\n * @returns The strongest ratio the painted focus chrome reaches, or `undefined` when the control is\n * not showing `:focus-visible` or the cascade paints no chrome of its own.\n *\n * @remarks\n * This reads and never acts. Focus arrives through the published verbs — `traverseAccessible`,\n * `pressKeys`, a real click — and this measures what the browser painted once it landed. A control\n * that is not matching `:focus-visible` when the call is made reports nothing, because no\n * measurement taken then would be about focus.\n *\n * Some controls are two elements: one that takes the focus and one a reader can see. A hidden radio\n * beside the label that carries every pixel of its chrome is the case `worn` exists for, so a\n * measurement is not taken on a rectangle nobody is looking at. The focus state is still read off\n * `control`, because that is what holds it.\n *\n * The backdrop is the surface behind the element the chrome is worn on, resolved from that element's\n * parent through {@link readBackdrop} onto {@link CANVAS_COLOR}. A control whose ancestry paints\n * nothing is therefore measured against the browser's own canvas, which is what a reader looking at\n * an unstyled document sees.\n *\n * Only chrome the cascade paints is measured — an `outline` with a real style and width, and the\n * first color in a `box-shadow`. A control left the browser's own `outline-style: auto` ring reports\n * `undefined`, because that ring's two tones are guaranteed against any backdrop and its computed\n * color names neither. A focus style that only changes the control's own fill reports `undefined`\n * too: the resting fill is gone by the time focus is on the control, and this never moves focus to\n * go and read it.\n *\n * @example\n * ```ts\n * await traverseAccessible('Evaluate')\n * readRing(resolveRendered('Evaluate')) // the ratio the painted ring reaches\n * ```\n */\nexport function readRing(control: Element, worn?: Element): number | undefined {\n\tif (!control.matches(':focus-visible')) return undefined\n\tconst target = worn ?? control\n\tconst declared = getComputedStyle(target)\n\tconst backdrop = readBackdrop(target.parentElement ?? target, CANVAS_COLOR)\n\tconst outline =\n\t\tdeclared.outlineStyle === 'none' ||\n\t\tdeclared.outlineStyle === 'auto' ||\n\t\tNumber.parseFloat(declared.outlineWidth) === 0\n\t\t\t? undefined\n\t\t\t: parseColor(declared.outlineColor)\n\tconst shadow = parseColor(/(?:rgba?|color)\\([^)]*\\)/u.exec(declared.boxShadow)?.[0] ?? '')\n\tconst ratios: number[] = []\n\tfor (const painted of [outline, shadow]) {\n\t\tif (painted === undefined) continue\n\t\tratios.push(measureContrast(blendColor(painted, backdrop), backdrop))\n\t}\n\treturn ratios.length === 0 ? undefined : Math.max(...ratios)\n}\n\n/**\n * Collects every class token the stylesheets loaded into this document actually define.\n *\n * @returns The set of class names reachable in the shipped cascade, in {@link readRules} order.\n *\n * @remarks\n * The set is what an authored-class conformance check measures against, so a class no loaded\n * stylesheet defines — an invented utility, a misspelled framework name — is absent from it.\n *\n * The tokens come from the {@link readRules} walk, which decides both the membership and the\n * insertion order this reader reports, and each answer is a deliberate difference from 0.0.8. A\n * class declared inside a grouping rule — a media query, a supports block, a layer, a nested style\n * rule — counts as defined, because a class the cascade defines under a condition is still one the\n * cascade defines; 0.0.8 read the top-level rules alone. Insertion order is breadth-first, so a\n * top-level class lands before a class declared inside an earlier grouping rule; 0.0.8 popped a\n * stack and inserted the deepest rule first. Iterate the set where the order is the subject, and\n * read `has` where membership is.\n *\n * `@keyframes` children are outside that walk, so an animation's own rules define no token here.\n * Reach the animation itself through {@link findKeyframes}.\n *\n * @example\n * ```ts\n * readCascade().has('card')\n * ```\n */\nexport function readCascade(): ReadonlySet<string> {\n\tconst known = new Set<string>()\n\tfor (const rule of readRules()) {\n\t\tif (!(rule instanceof CSSStyleRule)) continue\n\t\tfor (const match of rule.selectorText.matchAll(/\\.([a-zA-Z][\\w-]*)/g)) {\n\t\t\tknown.add(String(match[1]))\n\t\t}\n\t}\n\treturn known\n}\n\n/**\n * Collects every rule the stylesheets loaded into this document hold, nested grouping rules\n * included.\n *\n * @returns Every rule reachable in the shipped cascade: each sheet's own rules in sheet order, then\n * the rules nested inside them, level by level.\n *\n * @remarks\n * The walk is iterative and reads the list it is still appending to, which is what expands a media\n * query, a supports block, a layer, and a nested style rule without recursion. Expanding by level\n * rather than by depth is why a top-level rule is always met before a rule nested inside an earlier\n * one; {@link findRule} returns the first match in exactly this order.\n *\n * The descent reaches a `CSSGroupingRule` and nothing else, and a `@keyframes` rule is not one. The\n * `@keyframes` rule itself is collected wherever it sits, and the keyframe rules inside it are not;\n * {@link findKeyframes} is the door to those.\n *\n * A stylesheet the document cannot read — a cross-origin sheet with no CORS grant — throws from its\n * own `cssRules` getter, and that sheet is skipped rather than ending the walk. What a page loaded\n * from another origin declares is unreadable to every caller here, so the alternative is a helper\n * that works until a test page adds a font or an analytics stylesheet.\n *\n * @example\n * ```ts\n * readRules().filter((rule) => rule instanceof CSSKeyframesRule)\n * ```\n */\nexport function readRules(): readonly CSSRule[] {\n\tconst rules: CSSRule[] = []\n\tfor (const sheet of document.styleSheets) {\n\t\ttry {\n\t\t\trules.push(...sheet.cssRules)\n\t\t} catch {\n\t\t\tcontinue\n\t\t}\n\t}\n\tfor (let index = 0; index < rules.length; index += 1) {\n\t\tconst rule = rules[index]\n\t\tif (rule instanceof CSSGroupingRule) rules.push(...rule.cssRules)\n\t}\n\treturn rules\n}\n\n/**\n * Finds the first style rule in the cascade whose selector carries a fragment.\n *\n * @param selector - The selector fragment to look for, matched as a substring of the whole selector\n * text.\n * @returns The first matching rule in {@link readRules} order, or `undefined` when no rule carries\n * the fragment.\n *\n * @remarks\n * This proves a declaration exists in the cascade at all, which is a different question from what an\n * element resolves to: {@link style} reads the winner, and a rule this finds may be overridden by\n * another. Assert on this where the subject is the stylesheet, and on `style` where the subject is\n * the rendered result.\n *\n * The match is a substring, so `findRule('.card')` finds `.card`, `.card:hover`, and\n * `.panel > .card` alike. Pass more of the selector to narrow it.\n *\n * @example\n * ```ts\n * findRule('.card')?.style.getPropertyValue('padding')\n * ```\n */\nexport function findRule(selector: string): CSSStyleRule | undefined {\n\tfor (const rule of readRules()) {\n\t\tif (rule instanceof CSSStyleRule && rule.selectorText.includes(selector)) return rule\n\t}\n\treturn undefined\n}\n\n/**\n * Finds the animation the cascade declares under one name.\n *\n * @param name - The exact `@keyframes` name.\n * @returns The first matching rule in {@link readRules} order, or `undefined` when the cascade\n * declares no animation under that name.\n *\n * @remarks\n * The name is matched exactly, which is where this parts from {@link findRule}: a selector is\n * compound and a fragment of one is a useful question, and an animation name is one atom that either\n * is or is not the one an `animation` declaration references.\n *\n * @example\n * ```ts\n * findKeyframes('fade')?.cssRules.length\n * ```\n */\nexport function findKeyframes(name: string): CSSKeyframesRule | undefined {\n\tfor (const rule of readRules()) {\n\t\tif (rule instanceof CSSKeyframesRule && rule.name === name) return rule\n\t}\n\treturn undefined\n}\n\n/**\n * Reads the normalized visible text of every element a selector matches, in document order.\n *\n * @param root - The subtree to search.\n * @param selector - The CSS selector naming the rows.\n * @returns One line per matched element, its text runs collapsed and single-space joined.\n *\n * @remarks\n * The line is built from the row's text nodes rather than from `textContent`, because adjacent\n * inline elements carry no whitespace between them in compiled template output and would otherwise\n * read as one run-together word.\n *\n * @example\n * ```ts\n * readRows(container, 'li')\n * ```\n */\nexport function readRows(root: ParentNode, selector: string): readonly string[] {\n\tconst rows: string[] = []\n\tfor (const row of root.querySelectorAll(selector)) {\n\t\tconst parts: string[] = []\n\t\tconst walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT)\n\t\twhile (walker.nextNode() !== null) {\n\t\t\tconst text = (walker.currentNode.textContent ?? '').replaceAll(/\\s+/g, ' ').trim()\n\t\t\tif (text !== '') parts.push(text)\n\t\t}\n\t\trows.push(parts.join(' '))\n\t}\n\treturn rows\n}\n\n/**\n * Collects every element carrying a component class rendered outside the container it belongs to.\n *\n * @param root - The subtree to sweep.\n * @param child - The component class whose anatomy requires a container, such as `list-group-item`.\n * @param parent - The container class that child class must render inside, such as `list-group`.\n * @returns The markup of every element carrying `child` with no `parent` above it, in document\n * order; an empty list when every one of them is nested correctly.\n *\n * @remarks\n * A component keeps its padding, borders, and radii on the container, so a child class rendered\n * outside one is an unstyled box wearing a component's name, and the interface has to hand-roll the\n * chrome back. The search for the container starts at the element's parent, so an element can never\n * answer the invariant by carrying both classes itself.\n *\n * The class names are arguments, so the check belongs to no framework: name the pair your own\n * cascade defines.\n *\n * @example\n * ```ts\n * extractOrphans(container, 'list-group-item', 'list-group') // []\n * ```\n */\nexport function extractOrphans(root: ParentNode, child: string, parent: string): readonly string[] {\n\treturn [...root.querySelectorAll(`.${child}`)]\n\t\t.filter((node) => (node.parentElement?.closest(`.${parent}`) ?? null) === null)\n\t\t.map((node) => node.outerHTML)\n}\n\n/**\n * Reads one resolved CSS property from a real browser element.\n *\n * @param element - The element whose resolved style to inspect.\n * @param property - The CSS property name, registered or custom.\n * @returns The browser's resolved property value, trimmed; an empty string when the element resolves\n * none.\n *\n * @remarks\n * The value is trimmed, so what comes back is the value and never the whitespace around it. Internal\n * whitespace is kept: `--shadow: 0 0 2px` reads back with its spaces.\n *\n * @example\n * ```ts\n * style(button, 'padding-left')\n * ```\n */\nexport function style(element: Element, property: string): string {\n\treturn getComputedStyle(element).getPropertyValue(property).trim()\n}\n\n/**\n * Reads one custom property from an element's resolved style.\n *\n * @param element - The element whose resolved style to inspect.\n * @param name - The custom property name, with or without its leading dashes.\n * @returns The resolved value, trimmed; an empty string when the element inherits no such property.\n *\n * @remarks\n * The dashes are optional because a token is spoken about both ways — `--surface` in a stylesheet\n * and `surface` in prose — and a reader that accepted only one spelling would turn that into a silent\n * empty string. An absent token reads as `''`, which is what the CSSOM returns and is\n * indistinguishable from a token declared empty; assert on the value you expect rather than on\n * presence.\n *\n * Resolution is inheritance, so a token declared on `:root` reads from any mounted descendant and\n * from an unmounted element reads as `''`. Use {@link rootToken} where the declaration is the\n * document's.\n *\n * @example\n * ```ts\n * token(panel, 'surface') // '#ffffff'\n * token(panel, '--surface') // '#ffffff'\n * ```\n */\nexport function token(element: Element, name: string): string {\n\treturn style(element, name.startsWith('--') ? name : `--${name}`)\n}\n\n/**\n * Reads one custom property from the document element.\n *\n * @param name - The custom property name, with or without its leading dashes.\n * @returns The resolved value, trimmed; an empty string when the document declares no such property.\n *\n * @remarks\n * This is {@link token} against `document.documentElement`, which is where a theme declares its\n * tokens and where a `[data-theme]` switch retunes them. It exists as its own name because that\n * element is the one a token question is nearly always about, and naming it at every call site\n * buries the question.\n *\n * @example\n * ```ts\n * rootToken('surface')\n * ```\n */\nexport function rootToken(name: string): string {\n\treturn token(document.documentElement, name)\n}\n\n/**\n * Reads one resolved CSS length as a number of pixels.\n *\n * @param element - The element whose resolved style to inspect.\n * @param property - The CSS property name, registered or custom.\n * @returns The leading numeric part of the resolved value, and `0` when it carries none.\n *\n * @remarks\n * A resolved length is text with a unit — `'12px'` — so this reads the number in front of the unit\n * and discards the rest. The unit is not checked: the resolved value of a length is in pixels in\n * every case a browser hands back, and a property that resolves to something else is the caller's\n * mistake rather than this reader's.\n *\n * An unparsable value reads as `0` rather than as absence, because every caller of this is measuring\n * and `'auto'`, `'none'`, and `''` each contribute no pixels to what a reader sees. Where the\n * distinction matters, read the text with {@link style} instead.\n *\n * @example\n * ```ts\n * pixels(button, 'padding-left') // 12\n * pixels(button, 'width') // 0 when the width resolves to `auto`\n * ```\n */\nexport function pixels(element: Element, property: string): number {\n\tconst measured = Number.parseFloat(style(element, property))\n\treturn Number.isFinite(measured) ? measured : 0\n}\n\n/**\n * Sets the tester's viewport and renders the runner's pane at the size that viewport claims.\n *\n * @param width - The viewport width in CSS pixels.\n * @param height - The viewport height in CSS pixels.\n * @returns A promise resolving after the resized pane has been painted.\n * @throws Thrown when the tester sits inside no pane a capture can size, and when the staged pane\n * does not render at the viewport it was given.\n *\n * @remarks\n * This depends on the runner's own tester layout, and that dependency is contract rather than an\n * accident: `vitest@4.1.11` lays its tester out inside a smaller page, fits it by scaling the pane\n * the tester sits in, and clips whatever overflows that pane. Layout inside the tester is\n * unaffected — the tester reports the viewport it was given and every breakpoint answers to it —\n * but a screenshot is taken off the page the runner painted, so a frame shot through that scale is\n * a thumbnail of the surface and a frame shot after only unscaling it is a sliver. The tester is\n * therefore unscaled and lifted to the window's own origin for the shot. The `iframe[data-vitest]`\n * selector and the `--tester-transform`, `--tester-margin-left`, `--viewport-width`, and\n * `--viewport-height` custom properties are the runner's, so a Vitest release that renames any of\n * them reddens the size check below rather than writing a wrong frame.\n *\n * Hand the pane straight back with {@link releasePane}. A tester pinned at a viewport taller than\n * the window puts its lower half beyond what a pointer can reach, so an ordinary press then fails\n * as a control outside the viewport, in a test that took no picture at all.\n *\n * The rule is declared rather than written inline, because the runner writes its own scale onto the\n * pane as inline custom properties and rewrites them whenever the tester resizes. A declared rule\n * marked important outranks an inline value and survives every rewrite. It finds the pane by the\n * tester it contains as well as by {@link CAPTURE_PANE}, because a re-render between the staging and\n * the shot replaces the node and takes any attribute of ours with it.\n *\n * The wait is two frames rather than a delay: the first carries the resize into layout and the\n * second is the paint a screenshot reads.\n *\n * @example\n * ```ts\n * await stagePane(390, 844)\n * ```\n */\nexport async function stagePane(width: number, height: number): Promise<void> {\n\tawait page.viewport(width, height)\n\tconst frame = window.frameElement\n\tconst pane = frame?.parentElement\n\tconst owner = pane?.ownerDocument\n\tif (frame === null || pane === null || pane === undefined || owner === undefined) {\n\t\tthrow new Error('Tester pane is unavailable for a capture')\n\t}\n\tpane.setAttribute(CAPTURE_PANE, '')\n\tif (owner.querySelector(`style[${CAPTURE_PANE}]`) === null) {\n\t\tconst rule = owner.createElement('style')\n\t\trule.setAttribute(CAPTURE_PANE, '')\n\t\trule.textContent = [\n\t\t\t`[${CAPTURE_PANE}],:has(>iframe[data-vitest])`,\n\t\t\t'{--tester-transform:none !important;--tester-margin-left:0px !important}',\n\t\t\t'iframe[data-vitest]',\n\t\t\t'{position:fixed !important;left:0 !important;top:0 !important;right:auto !important;',\n\t\t\t'bottom:auto !important;width:var(--viewport-width) !important;',\n\t\t\t'height:var(--viewport-height) !important;z-index:2147483647 !important}',\n\t\t].join('')\n\t\towner.head.append(rule)\n\t}\n\tawait waitForFrame()\n\tawait waitForFrame()\n\tconst box = frame.getBoundingClientRect()\n\tif (Math.round(box.width) !== width || Math.round(box.height) !== height) {\n\t\tthrow new Error(\n\t\t\t`Tester pane rendered ${String(Math.round(box.width))}x${String(Math.round(box.height))} for a ${String(width)}x${String(height)} viewport`,\n\t\t)\n\t}\n}\n\n/**\n * Hands the tester pane back to the runner's own layout.\n *\n * @remarks\n * A staged pane is the runner's fitting scale suppressed, so a pane left staged outlives the capture\n * that needed it and every later act in the file happens on a surface the runner is no longer\n * fitting to its window. What that costs is not a wrong picture: it is a control whose page\n * coordinates fall outside the pane, which the runner's own layout then intercepts, so an ordinary\n * press fails with the voice of a control that is covered. Calling this on an unstaged pane does\n * nothing.\n *\n * @example\n * ```ts\n * releasePane()\n * ```\n */\nexport function releasePane(): void {\n\tconst pane = window.frameElement?.parentElement\n\tpane?.removeAttribute(CAPTURE_PANE)\n\tpane?.ownerDocument.querySelector(`style[${CAPTURE_PANE}]`)?.remove()\n}\n\n/**\n * Shoots one frame at one viewport size and proves the file on disk holds this run's bytes.\n *\n * @param options - The path to write, the viewport to shoot at, and the element to shoot.\n * @returns The absolute path of the written frame, after it has been read back and matched.\n * @throws Thrown when the pane cannot be staged, when the provider wrote the frame somewhere else,\n * and when the bytes on disk are not the ones this shot produced.\n *\n * @remarks\n * The path a screenshot call returns is the path it meant to write, so it is not evidence a file\n * exists. The file is read back through the runner's built-in `readFile` command and compared with\n * the shot itself, which is what separates a frame this run wrote from one an earlier run left\n * behind. The provider resolves `options.path` against the calling test file and returns an absolute\n * path, so the two are compared by the segments that survive resolving `.` and `..` lexically — the\n * refusal is what a provider resolving that path against a different base would trip.\n *\n * Omit `options.element` to shoot the whole page. The pane is staged for the frame and released\n * before this returns, on the failing path as well as the passing one.\n *\n * @example\n * ```ts\n * await captureFrame({ path: '../../tmp/capture/start.png', width: 390, height: 844 })\n * ```\n */\nexport async function captureFrame(options: FrameOptions): Promise<string> {\n\ttry {\n\t\tawait stagePane(options.width, options.height)\n\t\tconst shot =\n\t\t\toptions.element === undefined\n\t\t\t\t? await page.screenshot({ path: options.path, base64: true })\n\t\t\t\t: await page.screenshot({ element: options.element, path: options.path, base64: true })\n\t\tconst segments: string[] = []\n\t\tfor (const segment of options.path.replaceAll('\\\\', '/').split('/')) {\n\t\t\tif (segment === '' || segment === '.') continue\n\t\t\tif (segment === '..') segments.pop()\n\t\t\telse segments.push(segment)\n\t\t}\n\t\tif (!shot.path.replaceAll('\\\\', '/').endsWith(segments.join('/'))) {\n\t\t\tthrow new Error(\n\t\t\t\t`Capture frame was written to ${shot.path} where ${options.path} was asked for`,\n\t\t\t)\n\t\t}\n\t\tif ((await commands.readFile(shot.path, 'base64')) !== shot.base64) {\n\t\t\tthrow new Error(`Capture frame at ${options.path} is not the one this run shot`)\n\t\t}\n\t\treturn shot.path\n\t} finally {\n\t\treleasePane()\n\t}\n}\n\n/**\n * Expands a capture registry across every variant into the filenames a complete portfolio holds.\n *\n * @param states - The registered state names.\n * @param variants - The variants the portfolio is rendered in.\n * @returns One `<state>--<variant>.png` name per pair, each state's variants together, in registry\n * order.\n *\n * @remarks\n * The expansion is the portfolio's own definition of complete, so a duplicate in it is a registry\n * defect a proof reads directly rather than a collision discovered on disk.\n *\n * @example\n * ```ts\n * expandCaptures(['start'], [{ name: 'dark-390', width: 390, height: 844 }])\n * // ['start--dark-390.png']\n * ```\n */\nexport function expandCaptures(\n\tstates: readonly string[],\n\tvariants: readonly CaptureVariant[],\n): readonly string[] {\n\tconst files: string[] = []\n\tfor (const state of states) {\n\t\tfor (const variant of variants) files.push(`${state}--${variant.name}.png`)\n\t}\n\treturn files\n}\n","import type {\n\tJournalInterface,\n\tJournalStep,\n\tPortfolioInterface,\n\tPortfolioOptions,\n} from './types.js'\nimport { captureFrame, expandCaptures } from './helpers.js'\n\n/**\n * Creates one real pointer event, ready to dispatch.\n *\n * @param name - The event type, such as `pointerdown`.\n * @param options - Any `PointerEventInit` member, each one overriding the default beneath it.\n * @returns A real `PointerEvent` of that type.\n *\n * @remarks\n * The defaults are what a browser's own pointer event carries and a hand-built one does not:\n * `bubbles` and `cancelable` are set, so a delegated listener hears it and a handler can prevent it,\n * and `pointerId`, `pointerType`, and `isPrimary` describe a single primary mouse, so a component\n * that branches on the pointer kind takes the branch a mouse takes. Override any of them by naming\n * it; a touch is `{ pointerType: 'touch' }` and nothing else has to be restated.\n *\n * The event is real rather than a shaped object, so `instanceof PointerEvent` holds and the\n * coordinate and modifier members a handler reads are the ones the platform defines.\n *\n * @example\n * ```ts\n * element.dispatchEvent(createPointerEvent('pointerdown', { clientX: 10, clientY: 20 }))\n * ```\n */\nexport function createPointerEvent(name: string, options?: PointerEventInit): PointerEvent {\n\treturn new PointerEvent(name, {\n\t\tbubbles: true,\n\t\tcancelable: true,\n\t\tpointerId: 1,\n\t\tpointerType: 'mouse',\n\t\tisPrimary: true,\n\t\t...options,\n\t})\n}\n\n/**\n * Creates one real drag event carrying a live data transfer, ready to dispatch.\n *\n * @param name - The event type, such as `dragstart`.\n * @param options - Any `DragEventInit` member, each one overriding the default beneath it.\n * @returns A real `DragEvent` of that type.\n *\n * @remarks\n * A drag event with no `dataTransfer` is the shape that makes a drop handler fail in a test and work\n * in a browser, so one is allocated. Pass your own to seed it: a `dataTransfer` given in `options`\n * replaces the allocated one, which is how a drop is driven with the payload the drag was supposed\n * to carry.\n *\n * The platform declares the `dataTransfer` member on the constructed event as nullable, so calling\n * code still narrows it even though this always supplies one.\n *\n * `bubbles` and `cancelable` are set, because a drop handler that never prevents the default event\n * is a drop the browser handles itself.\n *\n * @example\n * ```ts\n * const started = createDragEvent('dragstart')\n * started.dataTransfer?.setData('text/plain', 'row-3')\n * element.dispatchEvent(started)\n * ```\n */\nexport function createDragEvent(name: string, options?: DragEventInit): DragEvent {\n\treturn new DragEvent(name, {\n\t\tbubbles: true,\n\t\tcancelable: true,\n\t\tdataTransfer: new DataTransfer(),\n\t\t...options,\n\t})\n}\n\n/**\n * Creates the capture portfolio one run places its screenshots through.\n *\n * @param options - The state registry, the variant matrix, the variant this run renders, the\n * directory it writes into, and whether it writes at all.\n * @returns The portfolio: its registry expansion, what it has placed, and `place`.\n * @throws When no registered variant carries the name `variant` names.\n *\n * @remarks\n * A disabled portfolio is the ordinary run. `place` then resizes nothing, writes nothing, and\n * records nothing, so a journey calls it unconditionally and a suite with the flag unset pays for\n * none of it. The portfolio refuses an unregistered variant at creation. An enabled run refuses an\n * unregistered state name and a second placement of one state.\n *\n * An enabled `place` writes through `captureFrame`, so a placed state carries that helper's staged\n * pane and its byte readback: a path is recorded only after the file on disk has been proved to hold\n * this run's own frame.\n *\n * @example\n * ```ts\n * const portfolio = createPortfolio({\n * \tstates: ['start-empty'],\n * \tvariants: [{ name: 'dark-390', width: 390, height: 844 }],\n * \tvariant: 'dark-390',\n * \tdirectory: '../../tmp/capture/states',\n * })\n * await portfolio.place('start-empty')\n * ```\n */\nexport function createPortfolio(options: PortfolioOptions): PortfolioInterface {\n\tconst selected = options.variants.find((candidate) => candidate.name === options.variant)\n\tif (selected === undefined) {\n\t\tthrow new Error(`Capture variant \"${options.variant}\" is not registered`)\n\t}\n\tconst registry = [...options.states]\n\tconst files = expandCaptures(registry, options.variants)\n\tconst enabled = options.enabled ?? false\n\tconst placed: string[] = []\n\tconst paths: string[] = []\n\treturn {\n\t\tvariant: options.variant,\n\t\tfiles,\n\t\tget states() {\n\t\t\treturn [...placed]\n\t\t},\n\t\tget paths() {\n\t\t\treturn [...paths]\n\t\t},\n\t\tasync place(state, element) {\n\t\t\tif (!enabled) return undefined\n\t\t\tif (!registry.includes(state)) {\n\t\t\t\tthrow new Error(`Capture state \"${state}\" is not registered`)\n\t\t\t}\n\t\t\tif (placed.includes(state)) {\n\t\t\t\tthrow new Error(`Capture state \"${state}\" is already placed`)\n\t\t\t}\n\t\t\tconst file = `${state}--${options.variant}.png`\n\t\t\tselected.apply?.()\n\t\t\tconst written = await captureFrame({\n\t\t\t\tpath: `${options.directory}/${file}`,\n\t\t\t\twidth: selected.width,\n\t\t\t\theight: selected.height,\n\t\t\t\telement,\n\t\t\t})\n\t\t\tplaced.push(state)\n\t\t\tpaths.push(written)\n\t\t\treturn written\n\t\t},\n\t}\n}\n\n/**\n * Creates one console channel that records every call it receives and hands that call on unchanged.\n *\n * @param name - The channel's name, which prefixes each line it records.\n * @param output - The list each call is recorded into, appended to in place.\n * @param forward - The channel every call is passed on to after it is recorded.\n * @returns A channel carrying the console's own call signature.\n *\n * @remarks\n * One call becomes one line. Every argument of that call is put through `String` and joined with a\n * space, so a call carrying several values reads as the one line the page printed rather than as\n * several entries.\n *\n * Nothing is swallowed. The record happens first and `forward` receives the arguments it would have\n * received, so a page recorded through this prints exactly what it printed without it. The list\n * belongs to the caller, so a channel writes into whatever it was handed and holds no state of its\n * own. {@link createJournal} builds one channel per console method over one list.\n *\n * @example\n * ```ts\n * const output: string[] = []\n * console.log = createChannel('log', output, console.log)\n * ```\n */\nexport function createChannel(\n\tname: string,\n\toutput: string[],\n\tforward: (...data: unknown[]) => void,\n): (...data: unknown[]) => void {\n\treturn (...data) => {\n\t\toutput.push(`${name}: ${data.map((value) => String(value)).join(' ')}`)\n\t\tforward(...data)\n\t}\n}\n\n/**\n * Creates the journal one scenario records its steps and the page's own output into.\n *\n * @returns A journal that records nothing until it is started.\n *\n * @remarks\n * The console is recorded rather than replaced: every intercepted call is forwarded to the channel\n * that was there when the journal started, so a run under a journal prints exactly what it printed\n * without one. `stop` puts those same function references back by identity.\n *\n * Uncaught errors and unhandled rejections are recorded too, through listeners the journal drops\n * when it stops. `steps` and `output` hand out snapshots, so a list read mid-scenario stays what it\n * was. Each journal owns its own recording, so a file that needs one per scenario creates one per\n * scenario.\n *\n * @example\n * ```ts\n * const journal = createJournal()\n * journal.start()\n * journal.record('click', 'Evaluate', 'alerts=0')\n * journal.stop()\n * journal.steps // [{ action: 'click', trigger: 'Evaluate', result: 'alerts=0' }]\n * ```\n */\nexport function createJournal(): JournalInterface {\n\tconst steps: JournalStep[] = []\n\tconst output: string[] = []\n\t// The channels the page was writing to when the journal started. Their presence is what \"started\"\n\t// means, so no second flag can disagree with it. The listeners are dropped through one signal,\n\t// which is why no handler reference has to be kept to take them off again.\n\tlet intercepted: Pick<Console, 'debug' | 'error' | 'info' | 'log' | 'warn'> | undefined\n\tlet listeners: AbortController | undefined\n\treturn {\n\t\tget steps() {\n\t\t\treturn [...steps]\n\t\t},\n\t\tget output() {\n\t\t\treturn [...output]\n\t\t},\n\t\tstart() {\n\t\t\tsteps.length = 0\n\t\t\toutput.length = 0\n\t\t\tif (intercepted !== undefined) return\n\t\t\tconst forwarded = {\n\t\t\t\tdebug: console.debug,\n\t\t\t\terror: console.error,\n\t\t\t\tinfo: console.info,\n\t\t\t\tlog: console.log,\n\t\t\t\twarn: console.warn,\n\t\t\t}\n\t\t\tintercepted = forwarded\n\t\t\tfor (const channel of ['debug', 'error', 'info', 'log', 'warn'] as const) {\n\t\t\t\tconsole[channel] = createChannel(channel, output, forwarded[channel])\n\t\t\t}\n\t\t\tconst dropped = new AbortController()\n\t\t\tlisteners = dropped\n\t\t\twindow.addEventListener(\n\t\t\t\t'error',\n\t\t\t\t(event) => {\n\t\t\t\t\toutput.push(`error: ${event.message}`)\n\t\t\t\t},\n\t\t\t\t{ signal: dropped.signal },\n\t\t\t)\n\t\t\twindow.addEventListener(\n\t\t\t\t'unhandledrejection',\n\t\t\t\t(event) => {\n\t\t\t\t\toutput.push(`rejection: ${String(event.reason)}`)\n\t\t\t\t},\n\t\t\t\t{ signal: dropped.signal },\n\t\t\t)\n\t\t},\n\t\tstop() {\n\t\t\tif (intercepted === undefined) return\n\t\t\tObject.assign(console, intercepted)\n\t\t\tintercepted = undefined\n\t\t\tlisteners?.abort()\n\t\t\tlisteners = undefined\n\t\t},\n\t\trecord(action, trigger, result) {\n\t\t\tif (intercepted === undefined) return\n\t\t\tsteps.push(Object.freeze({ action, trigger, result }))\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,mBAAsC,OAAO,OAAO;CAChE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;AAUD,IAAa,eAAsB,OAAO,OAAO;CAAC;CAAK;CAAK;CAAK;AAAC,CAAC;;;;;;;;;;AAWnE,IAAa,eAAe;;;;;;;;AAS5B,IAAa,gBAAmC,OAAO,OAAO;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;AAWD,IAAa,cAAgD,OAAO,OAAO;CAC1E,QAAQ;CACR,UAAU;CACV,OAAO;CACP,QAAQ;CACR,UAAU;CACV,OAAO;CACP,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,KAAK;CACL,MAAM;CACN,KAAK;AACN,CAAC;;;;;;;;;;AAWD,IAAa,qBACZ;;;;;;;;;AAUD,IAAa,eAAiD,OAAO,OAAO;CAC3E,KAAK;CACL,KAAK;AACN,CAAC;;;;;;;;;;;;;;;;;;;;;AAsBD,IAAa,iBAAmD,OAAO,OAAO;CAC7E,SAAS;CACT,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,QAAQ;CACR,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,MAAM;CACN,KAAK;CACL,IAAI;CACJ,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;CACP,OAAO;CACP,IAAI;CACJ,UAAU;CACV,IAAI;CACJ,OAAO;CACP,IAAI;CACJ,IAAI;AACL,CAAC;;;;;;;;;;;;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