effect-browser 0.2.0-beta.9 → 0.3.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +707 -1184
- package/dist/Browser-B5AV7zPS.mjs +437 -0
- package/dist/Browser-B5AV7zPS.mjs.map +1 -0
- package/dist/Browser.d.mts +115 -3
- package/dist/Browser.mjs +2 -22
- package/dist/BrowserError-DXXIA6Rk.d.mts +135 -0
- package/dist/BrowserError.d.mts +2 -0
- package/dist/BrowserError.mjs +202 -0
- package/dist/BrowserError.mjs.map +1 -0
- package/dist/BrowserEvent-DzdNdvoh.d.mts +277 -0
- package/dist/BrowserEvent.d.mts +2 -0
- package/dist/BrowserEvent.mjs +295 -0
- package/dist/BrowserEvent.mjs.map +1 -0
- package/dist/Cdp.d.mts +32 -0
- package/dist/Cdp.mjs +61 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change-DNvztNLu.mjs +138 -0
- package/dist/Change-DNvztNLu.mjs.map +1 -0
- package/dist/Change-DVP2IJWm.d.mts +71 -0
- package/dist/Change.d.mts +2 -0
- package/dist/Change.mjs +2 -0
- package/dist/Chromium.d.mts +29 -81
- package/dist/Chromium.mjs +57 -392
- package/dist/Chromium.mjs.map +1 -1
- package/dist/Expect.d.mts +62 -0
- package/dist/Expect.mjs +114 -0
- package/dist/Expect.mjs.map +1 -0
- package/dist/Frame-BERmf_gM.d.mts +117 -0
- package/dist/Frame.d.mts +2 -0
- package/dist/Frame.mjs +123 -0
- package/dist/Frame.mjs.map +1 -0
- package/dist/Moment.d.mts +2 -0
- package/dist/Moment.mjs +288 -0
- package/dist/Moment.mjs.map +1 -0
- package/dist/Motion.d.mts +40 -0
- package/dist/Motion.mjs +122 -0
- package/dist/Motion.mjs.map +1 -0
- package/dist/Page-D4281dIi.mjs +618 -0
- package/dist/Page-D4281dIi.mjs.map +1 -0
- package/dist/Page-DYTdVhYa.d.mts +593 -0
- package/dist/Page.d.mts +2 -0
- package/dist/Page.mjs +2 -0
- package/dist/Plan-5MdsRzE5.mjs +314 -0
- package/dist/Plan-5MdsRzE5.mjs.map +1 -0
- package/dist/Plan-CNNOU1Tx.d.mts +112 -0
- package/dist/Plan.d.mts +2 -3
- package/dist/Plan.mjs +2 -2
- package/dist/Policy.d.mts +76 -0
- package/dist/Policy.mjs +237 -0
- package/dist/Policy.mjs.map +1 -0
- package/dist/Presentation.d.mts +48 -0
- package/dist/Presentation.mjs +117 -0
- package/dist/Presentation.mjs.map +1 -0
- package/dist/Snapshot-B34hZ4Jl.d.mts +68 -0
- package/dist/Snapshot.d.mts +2 -0
- package/dist/Snapshot.mjs +79 -0
- package/dist/Snapshot.mjs.map +1 -0
- package/dist/Stage.d.mts +54 -0
- package/dist/Stage.mjs +133 -0
- package/dist/Stage.mjs.map +1 -0
- package/dist/Supervisor-BtEG93gR.mjs +420 -0
- package/dist/Supervisor-BtEG93gR.mjs.map +1 -0
- package/dist/Supervisor-Im6-wbg5.d.mts +230 -0
- package/dist/Supervisor.d.mts +2 -0
- package/dist/Supervisor.mjs +2 -0
- package/dist/context-DAYjATgC.mjs +137 -0
- package/dist/context-DAYjATgC.mjs.map +1 -0
- package/dist/index.d.mts +17 -14
- package/dist/index.mjs +18 -13
- package/dist/match.inpage-xOe9LNO0.mjs +48 -0
- package/dist/match.inpage-xOe9LNO0.mjs.map +1 -0
- package/dist/page-BkRcLCWZ.mjs +5097 -0
- package/dist/page-BkRcLCWZ.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/url-CcL0K7S0.mjs +262 -0
- package/dist/url-CcL0K7S0.mjs.map +1 -0
- package/package.json +96 -61
- package/src/Browser.ts +625 -0
- package/src/BrowserError.ts +225 -0
- package/src/BrowserEvent.ts +294 -0
- package/src/Cdp.ts +101 -0
- package/src/Change.ts +88 -0
- package/src/Chromium.ts +102 -0
- package/src/Expect.ts +180 -0
- package/src/Frame.ts +130 -0
- package/src/Moment.ts +479 -0
- package/src/Motion.ts +166 -0
- package/src/Page.ts +520 -0
- package/src/Plan.ts +354 -0
- package/src/Policy.ts +325 -0
- package/src/Presentation.ts +195 -0
- package/src/Snapshot.ts +89 -0
- package/src/Stage.ts +223 -0
- package/src/Supervisor.ts +353 -0
- package/src/index.ts +20 -0
- package/src/internal/input/actions.ts +610 -0
- package/src/internal/input/dispatch.ts +161 -0
- package/src/internal/input/edit.inpage.ts +162 -0
- package/src/internal/input/evidence.inpage.ts +164 -0
- package/src/internal/input/guard.inpage.ts +605 -0
- package/src/internal/input/guard.ts +183 -0
- package/src/internal/input/keyboard.ts +112 -0
- package/src/internal/input/keys.ts +127 -0
- package/src/internal/input/perform.ts +322 -0
- package/src/internal/input/pointer.ts +153 -0
- package/src/internal/input/replies.ts +159 -0
- package/src/internal/input/settle.ts +50 -0
- package/src/internal/input/style.ts +186 -0
- package/src/internal/input/targets.inpage.ts +293 -0
- package/src/internal/input/targets.ts +148 -0
- package/src/internal/page/bridge.ts +386 -0
- package/src/internal/page/context.ts +302 -0
- package/src/internal/page/lane.ts +301 -0
- package/src/internal/page/navigation.ts +183 -0
- package/src/internal/page/openings.ts +87 -0
- package/src/internal/page/page.ts +137 -0
- package/src/internal/page/url.ts +100 -0
- package/src/internal/page/viewport.ts +43 -0
- package/src/internal/pictures/capture.ts +778 -0
- package/src/internal/pictures/clock.ts +141 -0
- package/src/internal/pictures/pictures.ts +520 -0
- package/src/internal/pictures/transport.ts +242 -0
- package/src/internal/reading/choose.ts +100 -0
- package/src/internal/reading/context.inpage.ts +201 -0
- package/src/internal/reading/controls.inpage.ts +158 -0
- package/src/internal/reading/expect.inpage.ts +70 -0
- package/src/internal/reading/match.inpage.ts +92 -0
- package/src/internal/reading/names.inpage.ts +306 -0
- package/src/internal/reading/outline.inpage.ts +260 -0
- package/src/internal/reading/reading.ts +223 -0
- package/src/internal/reading/ready.inpage.ts +154 -0
- package/src/internal/reading/ready.ts +105 -0
- package/src/internal/reading/subjects.inpage.ts +188 -0
- package/src/internal/reading/text.inpage.ts +135 -0
- package/src/internal/reading/walk.inpage.ts +220 -0
- package/src/internal/supervisor/lifecycle.ts +265 -0
- package/src/internal/timeline/changes.inpage.ts +216 -0
- package/src/internal/timeline/changes.ts +100 -0
- package/src/internal/timeline/events.ts +93 -0
- package/src/internal/timeline/fold.inpage.ts +123 -0
- package/src/internal/timeline/history.inpage.ts +229 -0
- package/src/internal/timeline/marks.inpage.ts +207 -0
- package/src/internal/timeline/record.inpage.ts +133 -0
- package/src/internal/timeline/sight.inpage.ts +122 -0
- package/src/internal/timeline/window.ts +96 -0
- package/src/internal/timeline/words.ts +65 -0
- package/dist/Bootstrap-B9UUXsvF.d.mts +0 -183
- package/dist/Bootstrap-CeQOWBy6.mjs +0 -189
- package/dist/Bootstrap-CeQOWBy6.mjs.map +0 -1
- package/dist/Bootstrap.d.mts +0 -3
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-BF9_sORP.d.mts +0 -388
- package/dist/Browser.mjs.map +0 -1
- package/dist/BrowserData-CPIIIHol.d.mts +0 -585
- package/dist/BrowserData.d.mts +0 -3
- package/dist/BrowserData.mjs +0 -695
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/BrowserRuntime-B6nT1G4X.d.mts +0 -148
- package/dist/BrowserRuntime-C1r2aSRK.mjs +0 -6820
- package/dist/BrowserRuntime-C1r2aSRK.mjs.map +0 -1
- package/dist/BrowserRuntime.d.mts +0 -3
- package/dist/BrowserRuntime.mjs +0 -3
- package/dist/Capture.d.mts +0 -56
- package/dist/Capture.mjs +0 -678
- package/dist/Capture.mjs.map +0 -1
- package/dist/CaptureData-CYriZHX1.mjs +0 -201
- package/dist/CaptureData-CYriZHX1.mjs.map +0 -1
- package/dist/CaptureData.d.mts +0 -219
- package/dist/CaptureData.mjs +0 -2
- package/dist/Errors.d.mts +0 -158
- package/dist/Errors.mjs +0 -207
- package/dist/Errors.mjs.map +0 -1
- package/dist/Images-yCG9BmRU.mjs +0 -76
- package/dist/Images-yCG9BmRU.mjs.map +0 -1
- package/dist/OperationOptions-DAeRS6O9.mjs +0 -55
- package/dist/OperationOptions-DAeRS6O9.mjs.map +0 -1
- package/dist/PageControl.d.mts +0 -15
- package/dist/PageControl.mjs +0 -34
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageRegistry-B3q9DS3g.mjs +0 -164
- package/dist/PageRegistry-B3q9DS3g.mjs.map +0 -1
- package/dist/Plan-Dyxu2q8C.mjs +0 -543
- package/dist/Plan-Dyxu2q8C.mjs.map +0 -1
- package/dist/PlanData-B668RxbQ.d.mts +0 -4831
- package/dist/PlanData.d.mts +0 -3
- package/dist/PlanData.mjs +0 -268
- package/dist/PlanData.mjs.map +0 -1
- package/dist/PlanInput-BJcPPncs.mjs +0 -75
- package/dist/PlanInput-BJcPPncs.mjs.map +0 -1
- package/dist/PublicSession-DCSMMqOj.mjs +0 -5602
- package/dist/PublicSession-DCSMMqOj.mjs.map +0 -1
- package/dist/Testing.d.mts +0 -479
- package/dist/Testing.mjs +0 -2147
- package/dist/Testing.mjs.map +0 -1
- package/dist/Timeline-fV22Xk-S.d.mts +0 -29
- package/dist/Timeline.d.mts +0 -4
- package/dist/Timeline.mjs +0 -20
- package/dist/Timeline.mjs.map +0 -1
- package/dist/TimelineData-BsOn-YGZ.d.mts +0 -3818
- package/dist/TimelineData.d.mts +0 -3
- package/dist/TimelineData.mjs +0 -482
- package/dist/TimelineData.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-BkRcLCWZ.mjs","names":["Url.addresses","Url.redact","make","make","BrowserClock.toBrowserSeconds","make","Script.PreparedInputResultSchema","Url.redact","Script.ValidatedInputResultSchema","named","make","description","Keys.description","make","Keys.description","description","deadline","make","Replies.make","make","Motion.Plan","settling","make","make","Script.PointResultSchema","Script.ScrollPlanSchema","Dispatch.make","Pointer.make","Guard.make","Settle.make","Perform.make","Targets.make","Keyboard.make","parts","Keys.parts","Script.TypeableResultSchema","Script.FocusResultSchema","Guard.editFailure","Script.EditResultSchema","make","make","BrowserClock.estimate","make","Capture.make","Transport.own","Transport.apart","Capture.countsKept","make","Url.redact","make","make","BrowserClock.toHostTime","make","make","Url.redact","Url.parse","make","Context.make","Bridge.make","Viewport.make","Actions.make","Pictures.make","Reading.make","Navigation.make","Changes.make","Url.redact","Window.make","Ready.make"],"sources":["../src/internal/input/edit.inpage.ts","../src/internal/input/targets.inpage.ts","../src/internal/reading/context.inpage.ts","../src/internal/reading/controls.inpage.ts","../src/internal/reading/expect.inpage.ts","../src/internal/reading/names.inpage.ts","../src/internal/reading/outline.inpage.ts","../src/internal/reading/ready.inpage.ts","../src/internal/reading/subjects.inpage.ts","../src/internal/reading/text.inpage.ts","../src/internal/reading/walk.inpage.ts","../src/internal/timeline/changes.inpage.ts","../src/internal/timeline/fold.inpage.ts","../src/internal/timeline/history.inpage.ts","../src/internal/timeline/marks.inpage.ts","../src/internal/timeline/record.inpage.ts","../src/internal/timeline/sight.inpage.ts","../src/internal/page/bridge.ts","../src/internal/pictures/clock.ts","../src/internal/input/dispatch.ts","../src/internal/input/guard.ts","../src/internal/input/keys.ts","../src/internal/input/keyboard.ts","../src/internal/input/replies.ts","../src/internal/input/style.ts","../src/internal/input/perform.ts","../src/internal/input/pointer.ts","../src/internal/input/settle.ts","../src/internal/input/targets.ts","../src/internal/input/actions.ts","../src/internal/pictures/capture.ts","../src/internal/pictures/transport.ts","../src/internal/pictures/pictures.ts","../src/internal/reading/reading.ts","../src/internal/reading/ready.ts","../src/internal/timeline/changes.ts","../src/internal/timeline/window.ts","../src/internal/page/navigation.ts","../src/internal/page/viewport.ts","../src/internal/page/page.ts"],"sourcesContent":["/**\n * In the page: editing a field. It refuses text that a focused control could act on, focuses a\n * field and chooses a select's options. See `reading/names.inpage.ts` for what a page-side part\n * may use.\n */\nimport { Schema } from \"effect\";\n\nimport { Subject } from \"../../BrowserEvent.ts\";\nimport type { ContextReader } from \"../reading/context.inpage.ts\";\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Guard } from \"./guard.inpage.ts\";\n\nexport type EditResult =\n | { readonly ok: true; readonly detail: string }\n | { readonly error: string; readonly stale?: boolean };\n\n/** A focused field, and whether it is secret. */\nexport type FocusResult =\n | { readonly ok: true; readonly detail: string; readonly secret: boolean }\n | { readonly error: string; readonly stale?: boolean };\n\n/**\n * Whether text may be typed, and whether its field is secret. Typing into focus also names the\n * focused field, when it is one, so the action records what it typed into.\n */\nexport type TypeableResult =\n | { readonly ok: true; readonly secret: boolean; readonly subject?: typeof Subject.Encoded }\n | { readonly error: \"stale\" | \"untypeable\"; readonly detail: string };\n\nexport const edit = (names: Names, guard: Guard, placing: ContextReader) => {\n const {\n activeElement,\n clean,\n describe,\n isDisabled,\n isHtml,\n isInput,\n isSecret,\n isSelect,\n isTextArea,\n lookup,\n nameOf,\n roleOf,\n } = names;\n\n const { textEntry, typingRefusal } = guard;\n\n /** Whether text may be typed into a ref or focus, and, for a `secret`, only into a secret field. */\n const typeable = (ref: string | null, secret: boolean): TypeableResult => {\n const element = ref === null ? activeElement() : lookup(ref);\n\n if (element === undefined)\n return {\n error: \"stale\",\n detail: `${ref ?? \"the focused element\"} is not on the page any more`,\n };\n\n const refusal =\n element === null\n ? secret\n ? \"nothing has focus to type a secret into\"\n : undefined\n : (typingRefusal(element, ref !== null) ??\n (secret && !isSecret(element)\n ? `${describe(element)} is not a secret field`\n : undefined));\n\n if (refusal !== undefined) return { error: \"untypeable\", detail: refusal };\n if (element === null || ref !== null || !textEntry(element))\n return { ok: true, secret: element !== null && isSecret(element) };\n const role = roleOf(element);\n const tag = element.tagName.toLowerCase();\n\n return {\n ok: true,\n secret: isSecret(element),\n subject: { role, name: nameOf(element, role), tag, context: placing.contextOf(element) },\n };\n };\n\n const focus = (ref: string, replace: boolean): FocusResult => {\n const element = lookup(ref);\n\n if (element === undefined) return { error: `${ref} is not on the page any more`, stale: true };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (!textEntry(element)) return { error: `${ref} is ${describe(element)}, not a text field` };\n if (isHtml(element)) element.focus();\n if (replace) {\n if (isInput(element) || isTextArea(element)) element.select();\n else element.ownerDocument.getSelection()?.selectAllChildren(element);\n }\n\n // Decided after focusing: a focus handler can mark the field secret.\n return { ok: true, detail: describe(element), secret: isSecret(element) };\n };\n\n /** Focus any element that takes focus, such as a link or a button, for a key pressed on it. */\n const focusOn = (ref: string): EditResult => {\n const element = lookup(ref);\n\n if (element === undefined) return { error: `${ref} is not on the page any more`, stale: true };\n if (isDisabled(element)) return { error: `${ref} is disabled` };\n if (isHtml(element)) element.focus();\n\n return activeElement() === element\n ? { ok: true, detail: describe(element) }\n : { error: `${ref} is ${describe(element)}, which does not take focus` };\n };\n\n const select = (ref: string, values: ReadonlyArray<string>): EditResult => {\n const element = lookup(ref);\n\n if (element === undefined) return { error: `${ref} is not on the page any more`, stale: true };\n if (!isSelect(element))\n return {\n error: `${ref} is ${describe(element)}, not a <select>; click it and pick an option`,\n };\n const wanted = values.map((value) => value.trim().toLowerCase());\n const options = Array.from(element.options);\n\n const chosen = options.filter(\n (option) =>\n wanted.includes(option.value.toLowerCase()) ||\n wanted.includes(clean(option.text).toLowerCase()),\n );\n\n if (chosen.length === 0)\n return {\n error: `no option matches; the options are ${options.map((option) => JSON.stringify(clean(option.text, 40))).join(\", \")}`,\n };\n for (const option of options) option.selected = chosen.includes(option);\n element.dispatchEvent(new Event(\"input\", { bubbles: true }));\n element.dispatchEvent(new Event(\"change\", { bubbles: true }));\n\n return { ok: true, detail: chosen.map((option) => clean(option.text, 40)).join(\", \") };\n };\n\n return { focus, focusOn, select, typeable };\n};\n\nexport type Edit = ReturnType<typeof edit>;\n\nexport const TypeableResultSchema = Schema.Union([\n Schema.Struct({\n ok: Schema.Literal(true),\n secret: Schema.Boolean,\n subject: Schema.optional(Subject),\n }),\n Schema.Struct({ error: Schema.Literals([\"stale\", \"untypeable\"]), detail: Schema.String }),\n]);\n\nconst EditFailure = Schema.Struct({ error: Schema.String, stale: Schema.optional(Schema.Boolean) });\n\nexport const FocusResultSchema = Schema.Union([\n Schema.Struct({ ok: Schema.Literal(true), detail: Schema.String, secret: Schema.Boolean }),\n EditFailure,\n]);\n\nexport const EditResultSchema = Schema.Union([\n Schema.Struct({ ok: Schema.Literal(true), detail: Schema.String }),\n EditFailure,\n]);\n","/**\n * In the page: where input lands. It resolves a ref or a point to the control under it, in\n * top-document viewport pixels, with the subject's context, and plans a wheel scroll that brings a\n * ref into view. See `reading/names.inpage.ts` for what a page-side part may use.\n */\nimport { Schema } from \"effect\";\n\nimport { Box, SubjectContext } from \"../../BrowserEvent.ts\";\nimport type { ContextReader } from \"../reading/context.inpage.ts\";\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Walk } from \"../reading/walk.inpage.ts\";\n\nexport type ResolvedPoint = typeof ResolvedPointSchema.Type;\nexport type PointResult = typeof PointResultSchema.Type;\n\nexport const targets = (names: Names, walked: Walk, placing: ContextReader) => {\n const { describe, isDisabled, lookup, nameOf, parentOf, roleOf } = names;\n const { boxOf, controlOf, hitAt } = walked;\n const { contextOf } = placing;\n\n /** Whether `node` is `ancestor` or inside it, across shadow roots and same-origin frames. */\n const within = (ancestor: Element, node: Element): boolean => {\n for (let current: Element | null = node; current !== null;) {\n if (current === ancestor) return true;\n current = parentOf(current) ?? current.ownerDocument.defaultView?.frameElement ?? null;\n }\n\n return false;\n };\n\n // A press at a point reaches the element when the top-document hit is the element, inside it,\n // or one of its containers (whose activation the element's own facts already cover).\n const receives = (element: Element, hit: Element): boolean =>\n within(element, hit) || within(hit, element);\n\n // HTML links, SVG links and image-map areas all navigate; SVG keeps lowercase tag names.\n const hrefAttribute = (element: Element): string | null =>\n element.localName === \"a\" || element.localName === \"area\"\n ? (element.getAttribute(\"href\") ??\n element.getAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\"))\n : null;\n\n const linkOf = (element: Element): Element | undefined => {\n for (let node: Element | null = element; node !== null; node = parentOf(node))\n if (hrefAttribute(node) !== null) return node;\n\n return undefined;\n };\n\n const details = (\n element: Element,\n hit: Element,\n x: number,\n y: number,\n ): Omit<ResolvedPoint, \"context\"> => {\n const link = linkOf(element);\n let href: string | undefined;\n\n if (link !== undefined) {\n try {\n href = new URL(hrefAttribute(link) ?? \"\", link.ownerDocument.baseURI).href;\n } catch {\n href = undefined;\n }\n }\n const role = roleOf(element);\n const view = hit.ownerDocument.defaultView ?? window;\n\n return {\n x,\n y,\n element: describe(element),\n tag: element.tagName.toLowerCase(),\n role,\n name: nameOf(element, role),\n cursor: view.getComputedStyle(hit).cursor,\n ...(href === undefined ? {} : { href }),\n };\n };\n\n const point = (\n target: string | { readonly x: number; readonly y: number },\n scroll = true,\n ): PointResult => {\n if (typeof target !== \"string\") {\n const { x, y } = target;\n\n if (\n !Number.isFinite(x) ||\n !Number.isFinite(y) ||\n x < 0 ||\n y < 0 ||\n x >= window.innerWidth ||\n y >= window.innerHeight\n )\n return { error: \"outside\", detail: `(${x}, ${y}) is outside the viewport` };\n const hit = hitAt(document, x, y);\n\n if (hit === null) return { error: \"offscreen\", detail: `nothing is painted at (${x}, ${y})` };\n const control = controlOf(hit);\n\n return { ...details(control, hit, x, y), context: contextOf(control), box: boxOf(control) };\n }\n const ref = target;\n const element = lookup(ref);\n\n if (element === undefined)\n return { error: \"stale\", detail: `${ref} is not on the page any more` };\n if (isDisabled(element)) return { error: \"disabled\", detail: `${ref} is disabled` };\n const rect = element.getBoundingClientRect();\n\n if (rect.width === 0 && rect.height === 0)\n return { error: \"hidden\", detail: `${ref} has no size on the page` };\n\n // Input arrives in top-document viewport pixels, so geometry and occlusion are measured\n // there: a frame's own viewport cannot say whether the frame is scrolled away or covered.\n let box = { left: rect.left, top: rect.top, right: rect.right, bottom: rect.bottom };\n let visible = { ...box };\n let outside = false;\n\n for (let inner: Element = element; ;) {\n const view = inner.ownerDocument.defaultView ?? window;\n\n outside ||=\n box.left < 0 || box.top < 0 || box.right > view.innerWidth || box.bottom > view.innerHeight;\n visible = {\n left: Math.max(visible.left, 0),\n top: Math.max(visible.top, 0),\n right: Math.min(visible.right, view.innerWidth),\n bottom: Math.min(visible.bottom, view.innerHeight),\n };\n\n // A field can be inside the viewport and still clipped by a nested scrolling panel.\n for (let ancestor = parentOf(inner); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = view.getComputedStyle(ancestor);\n const clip = ancestor.getBoundingClientRect();\n\n if (/(auto|scroll|hidden|clip)/.test(style.overflowX)) {\n visible.left = Math.max(visible.left, clip.left + ancestor.clientLeft);\n visible.right = Math.min(\n visible.right,\n clip.left + ancestor.clientLeft + ancestor.clientWidth,\n );\n }\n if (/(auto|scroll|hidden|clip)/.test(style.overflowY)) {\n visible.top = Math.max(visible.top, clip.top + ancestor.clientTop);\n visible.bottom = Math.min(\n visible.bottom,\n clip.top + ancestor.clientTop + ancestor.clientHeight,\n );\n }\n }\n\n const frame = view.frameElement;\n\n if (frame === null) break;\n const frameBox = frame.getBoundingClientRect();\n const dx = frameBox.left + frame.clientLeft;\n const dy = frameBox.top + frame.clientTop;\n\n box = {\n left: box.left + dx,\n top: box.top + dy,\n right: box.right + dx,\n bottom: box.bottom + dy,\n };\n visible = {\n left: Math.max(visible.left + dx, dx),\n top: Math.max(visible.top + dy, dy),\n right: Math.min(visible.right + dx, dx + frame.clientWidth),\n bottom: Math.min(visible.bottom + dy, dy + frame.clientHeight),\n };\n inner = frame;\n }\n\n if (outside || visible.right <= visible.left || visible.bottom <= visible.top) {\n if (scroll) {\n element.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" });\n\n return point(target, false);\n }\n\n return {\n error: \"offscreen\",\n detail: outside\n ? ref + \" is outside the viewport\"\n : `${ref} could not be scrolled into view`,\n };\n }\n const x = (visible.left + visible.right) / 2;\n const y = (visible.top + visible.bottom) / 2;\n const hit = hitAt(document, x, y);\n\n if (hit !== null && !receives(element, hit))\n return { error: \"covered\", detail: `${ref} is covered by ${describe(hit)}` };\n\n return {\n ...details(element, hit ?? element, Math.round(x), Math.round(y)),\n context: contextOf(element),\n };\n };\n\n // Suggest one visible wheel origin. Unsupported frame geometry and fully clipped panels use\n // the bounded instant fallback; guessing their coordinates could scroll an unrelated control.\n const scrollPlan = (ref: string) => {\n const element = lookup(ref);\n\n if (element === undefined || element.ownerDocument !== document) return null;\n const target = element.getBoundingClientRect();\n const centerX = (target.left + target.right) / 2;\n const centerY = (target.top + target.bottom) / 2;\n\n for (let ancestor = parentOf(element); ancestor !== null; ancestor = parentOf(ancestor)) {\n const style = window.getComputedStyle(ancestor);\n\n const horizontal =\n /^(auto|scroll)$/.test(style.overflowX) && ancestor.scrollWidth > ancestor.clientWidth;\n\n const vertical =\n /^(auto|scroll)$/.test(style.overflowY) && ancestor.scrollHeight > ancestor.clientHeight;\n\n if (!horizontal && !vertical) continue;\n const box = ancestor.getBoundingClientRect();\n const left = Math.max(0, box.left + ancestor.clientLeft);\n const top = Math.max(0, box.top + ancestor.clientTop);\n\n const right = Math.min(\n window.innerWidth,\n box.left + ancestor.clientLeft + ancestor.clientWidth,\n );\n\n const bottom = Math.min(\n window.innerHeight,\n box.top + ancestor.clientTop + ancestor.clientHeight,\n );\n\n if (right <= left || bottom <= top) continue;\n const x = (left + right) / 2;\n const y = (top + bottom) / 2;\n const dx = horizontal && (target.left < left || target.right > right) ? centerX - x : 0;\n const dy = vertical && (target.top < top || target.bottom > bottom) ? centerY - y : 0;\n\n if (dx === 0 && dy === 0) continue;\n const hit = hitAt(document, x, y);\n\n if (hit !== null && (hit === ancestor || ancestor.contains(hit))) return { x, y, dx, dy };\n }\n\n const dx =\n target.left < 0 || target.right > window.innerWidth ? centerX - window.innerWidth / 2 : 0;\n\n const dy =\n target.top < 0 || target.bottom > window.innerHeight ? centerY - window.innerHeight / 2 : 0;\n\n return dx === 0 && dy === 0\n ? null\n : { x: window.innerWidth / 2, y: window.innerHeight / 2, dx, dy };\n };\n\n return { controlOf, details, hitAt, hrefAttribute, linkOf, point, receives, scrollPlan, within };\n};\n\nexport type Targets = ReturnType<typeof targets>;\n\nconst ResolvedPointSchema = Schema.Struct({\n x: Schema.Finite,\n y: Schema.Finite,\n element: Schema.String,\n tag: Schema.String,\n role: Schema.NullOr(Schema.String),\n name: Schema.String,\n context: SubjectContext,\n box: Schema.optional(Box),\n cursor: Schema.String,\n href: Schema.optional(Schema.String),\n});\n\nexport const PointResultSchema = Schema.Union([\n ResolvedPointSchema,\n Schema.Struct({\n error: Schema.Literals([\"stale\", \"hidden\", \"offscreen\", \"disabled\", \"covered\", \"outside\"]),\n detail: Schema.String,\n }),\n]);\n\nexport const ScrollPlanSchema = Schema.NullOr(\n Schema.Struct({\n x: Schema.Finite,\n y: Schema.Finite,\n dx: Schema.Finite,\n dy: Schema.Finite,\n }),\n);\n","/**\n * In the page: an element's context, the words around it that say which one it is:\n *\n * - in a table, its row, named by the row's header or else its first cell with letters, so a rank\n * or a price never names it, and its column, named by the header over it, so a value is never\n * read under the wrong header;\n * - elsewhere, the words just before it in its row, item, group or block;\n * - the heading above it, unless it is pinned to the viewport, where the markup says nothing.\n *\n * See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { SubjectContext } from \"../../BrowserEvent.ts\";\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\n/** What one read has learnt of the page: each table's header row and each tree's headings. */\nexport interface Known {\n readonly headers: Map<Element, Element | null>;\n readonly headings: Map<Node, ReadonlyArray<Element>>;\n}\n\nexport const context = (names: Names, walked: Walk) => {\n const { clean, isButton, isDocument, isHtml, isInput, isRoot } = names;\n const { isSelect, isTextArea, roleOf, textOf } = names;\n const { visible } = walked;\n\n const known = (): Known => ({ headers: new Map(), headings: new Map() });\n\n // Text in these says what a control is called, not what the page says around it.\n const unspoken =\n \"button,select,textarea,option,script,style,noscript,template,[role=button],[role=menuitem],[role=option],[role=tab],[role=switch],[role=checkbox],[role=radio],[aria-hidden=true]\";\n\n // Containers whose text usually describes the controls in them: a row, an item, a group or a form.\n const groups =\n \"tr,li,article,fieldset,form,section,dialog,[role=row],[role=listitem],[role=group],[role=region],[role=dialog],[role=alertdialog]\";\n\n /** The visible text just before (or after) a target within `scope`, nearest kept, ≤120 characters. */\n const textBeside = (target: Element, scope: Node, backwards: boolean): string => {\n const walker = target.ownerDocument.createTreeWalker(scope, NodeFilter.SHOW_TEXT);\n\n const labels =\n isInput(target) || isTextArea(target) || isSelect(target) || isButton(target)\n ? Array.from(target.labels ?? [])\n : [];\n\n let text = \"\";\n\n walker.currentNode = target;\n for (let steps = 0; steps < 400 && text.replace(/\\s+/g, \"\").length < 120; steps++) {\n const node = backwards ? walker.previousNode() : walker.nextNode();\n\n if (node === null) break;\n const parent = node.parentElement;\n\n if (\n parent === null ||\n target.contains(parent) ||\n parent.closest(unspoken) !== null ||\n (isHtml(parent) && parent.isContentEditable) ||\n labels.some((label) => label.contains(parent)) ||\n !visible(parent)\n )\n continue;\n text = backwards ? `${node.textContent ?? \"\"} ${text}` : `${text} ${node.textContent ?? \"\"}`;\n }\n const words = text.replace(/\\s+/g, \" \").trim();\n\n return words.length <= 120\n ? words\n : backwards\n ? `…${words.slice(-119).trimStart()}`\n : `${words.slice(0, 119).trimEnd()}…`;\n };\n\n /** The nearest visible heading before `target` in tree order, within `scope`. */\n const headingBefore = (\n target: Element,\n scope: ParentNode,\n read = known(),\n ): string | undefined => {\n let headings = read.headings.get(scope);\n\n if (headings === undefined) {\n headings = Array.from(scope.querySelectorAll(\"h1,h2,h3,h4,h5,h6,[role=heading]\")).filter(\n (element) => roleOf(element) === \"heading\",\n );\n read.headings.set(scope, headings);\n }\n // Headings are in tree order, so the nearest before the target is the last one before it.\n for (const heading of headings.toReversed()) {\n if ((heading.compareDocumentPosition(target) & Node.DOCUMENT_POSITION_FOLLOWING) === 0)\n continue;\n const text = visible(heading) ? clean(textOf(heading), 120) : \"\";\n\n if (text !== \"\") return text;\n }\n\n return undefined;\n };\n\n /** Whether an element is pinned to the viewport, where the markup around it says nothing. */\n const pinned = (element: Element): boolean => {\n if (!isHtml(element)) return false;\n let top: HTMLElement = element;\n\n while (top.offsetParent !== null && isHtml(top.offsetParent)) top = top.offsetParent;\n\n return (\n top !== element.ownerDocument.body &&\n top !== element.ownerDocument.documentElement &&\n getComputedStyle(top).position === \"fixed\"\n );\n };\n\n const span = (cell: Element): number => Math.max(1, Number(cell.getAttribute(\"colspan\")) || 1);\n const tables = \"table,[role=table],[role=grid],[role=treegrid]\";\n\n /** A cell's row and column names, or nothing when it is not in a table with either. */\n const tableContext = (cell: Element, read: Known): SubjectContext => {\n const row = cell.closest(\"tr,[role=row]\");\n const table = row?.closest(tables);\n\n if (row === null || row === undefined || table === null || table === undefined) return {};\n let header = read.headers.get(table);\n\n if (header === undefined) {\n const first = table.querySelector(\n \"thead tr, tr:has(> th), [role=row]:has(> [role=columnheader])\",\n );\n\n header = first?.closest(tables) === table ? first : null;\n read.headers.set(table, header);\n }\n if (row === header) return {};\n const cells = Array.from(row.children);\n const index = cells.indexOf(cell);\n // A rank, a checkbox, a star or a price says where a row is, not which one it is.\n const lettered = (other: Element) => /\\p{L}/u.test(textOf(other));\n\n const named =\n cells.find((other) => other.matches(\"th,[role=rowheader]\") && lettered(other)) ??\n cells.find((other) => other !== cell && lettered(other));\n\n // Columns count spanned cells, so a cell after one spanning two is under the third header.\n let left = cells.slice(0, index).reduce((sum, other) => sum + span(other), 0);\n\n const over =\n index === -1 || header === null\n ? undefined\n : Array.from(header.children).find((candidate) => (left -= span(candidate)) < 0);\n\n return {\n row:\n named === undefined || named === cell ? undefined : clean(textOf(named), 60) || undefined,\n column: over === undefined ? undefined : clean(textOf(over), 60) || undefined,\n };\n };\n\n /** Where text around an element is read: its dialog, else its own tree, never across a shadow root. */\n const treeOf = (element: Element): ParentNode => {\n const root = element.getRootNode();\n\n return (\n element.closest(\"dialog,[role=dialog],[role=alertdialog]\") ??\n (isDocument(root) ? (root.body ?? root) : isRoot(root) ? root : element.ownerDocument)\n );\n };\n\n /** The words around an element that say which one it is. */\n const contextOf = (element: Element, read = known()): SubjectContext => {\n const cell = element.closest(\n \"td,th,[role=cell],[role=gridcell],[role=rowheader],[role=columnheader]\",\n );\n\n const table = cell === null ? {} : tableContext(cell, read);\n const parent = element.parentElement;\n\n const scope =\n element.closest(groups) ??\n (parent === null || parent === element.ownerDocument.body || parent.tagName === \"HTML\"\n ? undefined\n : parent);\n\n const beside =\n table.row !== undefined || table.column !== undefined || scope === undefined\n ? \"\"\n : textBeside(element, scope, true);\n\n const heading = pinned(element) ? undefined : headingBefore(element, treeOf(element), read);\n\n return {\n ...table,\n label: beside.length > 40 ? `…${beside.slice(-39).trimStart()}` : beside || undefined,\n heading: heading === undefined ? undefined : clean(heading, 60),\n };\n };\n\n return { contextOf, groups, headingBefore, known, textBeside, treeOf };\n};\n\nexport type ContextReader = ReturnType<typeof context>;\n","/**\n * In the page: a control's states and value as the outline shows them, and as a value; the elements a CSS selector scopes a\n * read to; and a condition `Page.waitFor` waits for. See `names.inpage.ts` for what a page-side part\n * may use.\n */\nimport type { Control } from \"../../Snapshot.ts\";\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Subjects } from \"./subjects.inpage.ts\";\nimport type { Texts } from \"./text.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\n/** What `waitUntil` waits for, as `Page.waitFor` asks it. */\nexport interface ConditionRequest {\n readonly selector: string | null;\n readonly text: string | null;\n readonly state: \"visible\" | \"hidden\" | \"enabled\";\n}\n\n/** Whether the condition held by the deadline, or why the selector is not CSS. */\nexport type ConditionResult = { readonly met: boolean } | { readonly invalid: string };\n\nexport const controls = (names: Names, walked: Walk, subjects: Subjects, texts: Texts) => {\n const { clean, isDisabled, isHtml, isInput, isSelect, isTextArea, refFor, textOf } = names;\n const { visible } = walked;\n const { stateOf } = subjects;\n const { shown } = texts;\n\n // The states that hold, in the order `stateOf` gives them, after a heading's level.\n const states = (element: Element, role: string | null): string => {\n const { level, ...flags } = stateOf(element, role);\n const held = Object.entries(flags).flatMap(([name, value]) => (value === true ? [name] : []));\n\n return [...(level === undefined ? [] : [`level=${level}`]), ...held]\n .map((name) => ` [${name}]`)\n .join(\"\");\n };\n\n const valueOf = (element: Element): string => {\n if (isSelect(element)) {\n const selected = Array.from(element.selectedOptions, (option) => clean(option.text, 40));\n\n const options = Array.from(element.options)\n .slice(0, 12)\n .map((option) => clean(option.text, 40));\n\n const more = element.options.length > 12 ? ` +${element.options.length - 12} more` : \"\";\n\n return ` value=${JSON.stringify(selected.join(\", \"))} options=${JSON.stringify(options.join(\" | \") + more)}`;\n }\n // The model sees what it typed, but never what a secret field holds.\n const value = isInput(element) || isTextArea(element) ? shown(element, true) : undefined;\n\n return value === undefined || value === \"\" ? \"\" : ` value=${JSON.stringify(clean(value, 80))}`;\n };\n\n // Inputs that take no typed text.\n const untyped = [\"button\", \"reset\", \"submit\", \"image\", \"checkbox\", \"radio\", \"file\", \"range\"];\n\n /** A control as a value, as its outline line shows it. */\n const controlOf = (element: Element, role: string | null, kind: string, name: string) => {\n const { disabled, checked } = stateOf(element, role);\n const select = isSelect(element) ? element : undefined;\n\n const value =\n select !== undefined\n ? Array.from(select.selectedOptions, (option) => clean(option.text, 80)).join(\", \")\n : isInput(element) || isTextArea(element)\n ? clean(shown(element, true), 200)\n : \"\";\n\n const editable =\n isTextArea(element) ||\n (isInput(element) && !untyped.includes(element.type)) ||\n (isHtml(element) && element.isContentEditable);\n\n const control: typeof Control.Encoded = {\n ref: refFor(element),\n kind,\n name,\n value,\n ...(select === undefined\n ? {}\n : {\n options: Array.from(select.options)\n .slice(0, 64)\n .map((option) => clean(option.text, 80)),\n optionCount: select.options.length,\n }),\n ...(disabled ? { disabled } : {}),\n ...(checked === undefined ? {} : { checked }),\n ...(editable ? { editable } : {}),\n };\n\n return control;\n };\n\n /**\n * The elements a selector matches, each read whole, so one inside another that matched is left\n * to it; or why the selector is not CSS.\n */\n const rootsOf = (selector: string): ReadonlyArray<Element> | { readonly invalid: string } => {\n let matched: ReadonlyArray<Element>;\n\n try {\n matched = Array.from(document.querySelectorAll(selector));\n } catch {\n return { invalid: `${JSON.stringify(selector)} is not a CSS selector` };\n }\n\n return matched.filter(\n (root) => !matched.some((other) => other !== root && other.contains(root)),\n );\n };\n\n // Whether the condition holds now: what the selector matches, or the body, and shows, with the\n // text when one is asked, case and all. A document has no body until its parser reaches one.\n const holds = (request: ConditionRequest): ConditionResult => {\n const roots =\n request.selector === null ? [document.body].filter(Boolean) : rootsOf(request.selector);\n\n if (\"invalid\" in roots) return roots;\n const text = request.text === null ? null : clean(request.text, Infinity);\n\n const showing = roots.filter(\n (element) =>\n visible(element) && (text === null || clean(textOf(element), Infinity).includes(text)),\n );\n\n return {\n met:\n request.state === \"hidden\"\n ? showing.length === 0\n : request.state === \"enabled\"\n ? showing.some((element) => !isDisabled(element))\n : showing.length > 0,\n };\n };\n\n // Looks every 100 ms until the condition holds or the deadline passes.\n const waitUntil = async (request: ConditionRequest, millis: number) => {\n const until = performance.now() + millis;\n\n for (;;) {\n const result = holds(request);\n const left = until - performance.now();\n\n if (\"invalid\" in result || result.met || left <= 0) return result;\n const { promise, resolve } = Promise.withResolvers<void>();\n\n setTimeout(resolve, Math.min(100, left));\n await promise;\n }\n };\n\n return { controlOf, rootsOf, states, valueOf, waitUntil };\n};\n\nexport type Controls = ReturnType<typeof controls>;\n","/**\n * In the page: the wait an expectation takes on what `find` matches, and the mark that stands for\n * what the matches show. See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { FindRequest } from \"./match.inpage.ts\";\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Subjects } from \"./subjects.inpage.ts\";\n\n/**\n * What an expectation waits for of a query's matches: some, none, or a mark other than one `until`\n * gave before.\n */\nexport type Want = \"some\" | \"none\" | { readonly other: string };\n\nexport const expectations = (names: Names, subjected: Subjects) => {\n const { isInput, isSelect, isTextArea, roleOf, textOf } = names;\n const { elementsOf, stateOf } = subjected;\n\n // What matched elements show, their text, values and states but focus, as a mark that carries\n // none of it: a count and FNV-1a over each in turn.\n const markOf = (elements: ReadonlyArray<Element>) => {\n let hash = 0x811c9dc5;\n\n for (const element of elements) {\n const { focused: _focused, ...state } = stateOf(element, roleOf(element));\n\n const value =\n isInput(element) || isSelect(element) || isTextArea(element) ? element.value : \"\";\n\n const shown = `${textOf(element)}\\u0000${value}\\u0000${JSON.stringify(state)}\\u0001`;\n\n for (let index = 0; index < shown.length; index++)\n hash = Math.imul(hash ^ shown.charCodeAt(index), 0x01000193);\n }\n\n return `${elements.length}:${(hash >>> 0).toString(16)}`;\n };\n\n /**\n * What `find` matches, looked at every 100 ms until `want` holds of it or `millis` have passed,\n * with its mark then. It gives no refs.\n */\n const until = async (request: FindRequest, want: Want, millis: number) => {\n const deadline = performance.now() + millis;\n\n for (;;) {\n const elements = elementsOf(request);\n const mark = markOf(elements);\n\n const met =\n want === \"some\"\n ? elements.length > 0\n : want === \"none\"\n ? elements.length === 0\n : mark !== want.other;\n\n const left = deadline - performance.now();\n\n if (met || left <= 0) return { met, mark };\n const { promise, resolve } = Promise.withResolvers<void>();\n\n setTimeout(resolve, Math.min(100, left));\n await promise;\n }\n };\n\n return { until };\n};\n\nexport type Expectations = ReturnType<typeof expectations>;\n","/**\n * In the page: the foundation the other parts build on. It gives elements refs and reads the\n * roles, names and states that the outline and the input checks report.\n *\n * Every `*.inpage.ts` part runs inside the page. The page receives it as source text, so it must\n * stay self-contained: it uses only its parameters, the DOM and what it defines itself.\n */\n\nexport const names = () => {\n const byElement = new WeakMap<Element, string>();\n const byRef = new Map<string, WeakRef<Element>>();\n const refs = { next: 1 };\n\n const interactiveRoles = new Set(\n \"button link checkbox radio tab menuitem menuitemcheckbox menuitemradio option switch slider combobox listbox textbox searchbox spinbutton treeitem\".split(\n \" \",\n ),\n );\n\n const containers: Record<string, string> = {\n HEADER: \"banner\",\n NAV: \"navigation\",\n MAIN: \"main\",\n ASIDE: \"complementary\",\n FOOTER: \"contentinfo\",\n FORM: \"form\",\n DIALOG: \"dialog\",\n };\n\n // Elements of a same-origin frame come from another realm, so tag names decide, not instanceof.\n const isInput = (element: Element): element is HTMLInputElement => element.tagName === \"INPUT\";\n\n const isTextArea = (element: Element): element is HTMLTextAreaElement =>\n element.tagName === \"TEXTAREA\";\n\n const isSelect = (element: Element): element is HTMLSelectElement => element.tagName === \"SELECT\";\n const isFrame = (element: Element): element is HTMLIFrameElement => element.tagName === \"IFRAME\";\n const isHtml = (element: Element): element is HTMLElement => \"innerText\" in element;\n\n const isButton = (element: Element): element is HTMLButtonElement => element.tagName === \"BUTTON\";\n\n const isLabel = (element: Element): element is HTMLLabelElement => element.tagName === \"LABEL\";\n\n const textOf = (element: Element): string =>\n isHtml(element) ? element.innerText : (element.textContent ?? \"\");\n\n const isElement = (node: Node): node is Element => node.nodeType === Node.ELEMENT_NODE;\n const isDocument = (node: Node): node is Document => node.nodeType === Node.DOCUMENT_NODE;\n\n // Controls whose text is a value or a choice, not words of a label around them.\n const valueRoles = new Set(\n \"combobox listbox option textbox searchbox spinbutton slider\".split(\" \"),\n );\n\n /**\n * A label's own words, without the options or values of the controls inside it, native or\n * scripted, such as the custom select Browserbase puts in place of a native one.\n */\n const labelText = (label: Element): string => {\n let text = \"\";\n\n const collect = (node: Node): void => {\n for (const child of Array.from(node.childNodes)) {\n if (child.nodeType === Node.TEXT_NODE) text += child.textContent ?? \"\";\n else if (\n isElement(child) &&\n ![\"SELECT\", \"TEXTAREA\", \"INPUT\", \"SCRIPT\", \"STYLE\"].includes(child.tagName) &&\n !valueRoles.has(roleOf(child) ?? \"\")\n )\n collect(child);\n }\n };\n\n collect(label);\n\n return text;\n };\n\n const clean = (value: string | null | undefined, max = 160): string => {\n const text = (value ?? \"\").replace(/\\s+/g, \" \").trim();\n\n return text.length > max ? `${text.slice(0, max - 1)}…` : text;\n };\n\n const roleOf = (element: Element): string | null => {\n const explicit = element.getAttribute(\"role\");\n\n if (explicit !== null && explicit.trim() !== \"\") return explicit.trim().split(/\\s+/)[0] ?? null;\n const tag = element.tagName;\n\n if (tag === \"A\") return element.hasAttribute(\"href\") ? \"link\" : null;\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return \"button\";\n if (isSelect(element)) return element.multiple ? \"listbox\" : \"combobox\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (isInput(element)) {\n const type = element.type;\n\n if (type === \"hidden\") return null;\n if (type === \"checkbox\" || type === \"radio\") return type;\n if (type === \"range\") return \"slider\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"search\") return \"searchbox\";\n if (type === \"button\" || type === \"submit\" || type === \"reset\" || type === \"image\")\n return \"button\";\n\n return \"textbox\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"IMG\") return \"img\";\n if (tag === \"CANVAS\") return \"canvas\";\n if (tag === \"IFRAME\") return \"iframe\";\n if (element.getAttribute(\"contenteditable\") === \"true\") return \"textbox\";\n\n return containers[tag] ?? null;\n };\n\n const nameOf = (element: Element, role: string | null): string => {\n const label = element.getAttribute(\"aria-label\");\n\n if (label !== null && clean(label) !== \"\") return clean(label);\n const labelledBy = element.getAttribute(\"aria-labelledby\");\n\n if (labelledBy !== null) {\n const text = labelledBy\n .split(/\\s+/)\n .map((id) => {\n const labelling = element.ownerDocument.getElementById(id);\n\n return labelling === null ? \"\" : labelText(labelling);\n })\n .join(\" \");\n\n if (clean(text) !== \"\") return clean(text);\n }\n if (isInput(element) || isTextArea(element) || isSelect(element)) {\n const labels = element.labels === null ? \"\" : Array.from(element.labels, labelText).join(\" \");\n\n if (clean(labels) !== \"\") return clean(labels);\n if (\n isInput(element) &&\n (element.type === \"button\" || element.type === \"submit\" || element.type === \"reset\")\n )\n return clean(element.value);\n\n return clean(\n element.getAttribute(\"placeholder\") ??\n element.getAttribute(\"title\") ??\n element.getAttribute(\"name\"),\n );\n }\n if (role === \"img\") return clean(element.getAttribute(\"alt\") ?? element.getAttribute(\"title\"));\n if (role === \"iframe\")\n return clean(element.getAttribute(\"title\") ?? element.getAttribute(\"name\"));\n if (role === null || interactiveRoles.has(role) || role === \"heading\") {\n // An editable secret field's text is what was typed into it.\n const text = isSecret(element) ? \"\" : clean(textOf(element), 120);\n\n if (text !== \"\") return text;\n const titled = element.querySelector(\"[title],img[alt],svg title\");\n\n const fallback =\n titled === null\n ? null\n : titled.tagName === \"IMG\"\n ? titled.getAttribute(\"alt\")\n : titled.tagName.toLowerCase() === \"title\"\n ? titled.textContent\n : titled.getAttribute(\"title\");\n\n return clean(element.getAttribute(\"title\") ?? fallback);\n }\n\n return \"\";\n };\n\n const isDisabled = (element: Element): boolean =>\n (\"disabled\" in element && element.disabled === true) ||\n element.getAttribute(\"aria-disabled\") === \"true\";\n\n const refFor = (element: Element): string => {\n const known = byElement.get(element);\n\n if (known !== undefined && byRef.get(known)?.deref() === element) return known;\n const ref = `e${refs.next++}`;\n\n byElement.set(element, ref);\n byRef.set(ref, new WeakRef(element));\n\n return ref;\n };\n\n // A ref names an element of the current documents only: nodes of a navigated frame can stay\n // connected to their old document, and must not be measured or typed into.\n const lookup = (ref: string): Element | undefined => {\n const element = byRef.get(ref)?.deref();\n\n return element !== undefined && element.isConnected && inCurrentDocument(element)\n ? element\n : undefined;\n };\n\n const describe = (element: Element): string => {\n const id = element.id === \"\" ? \"\" : `#${element.id}`;\n const name = clean(nameOf(element, roleOf(element)), 40);\n\n return `<${element.tagName.toLowerCase()}${id}>${name === \"\" ? \"\" : ` \"${name}\"`}`;\n };\n\n const isRoot = (node: Node): node is Document | ShadowRoot =>\n node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;\n\n const parentOf = (element: Element): Element | null => {\n const root = element.getRootNode();\n\n return element.parentElement ?? (isRoot(root) && \"host\" in root ? root.host : null);\n };\n\n const activeElement = (): Element | null => {\n let active = document.activeElement;\n\n while (active !== null) {\n const inner =\n active.shadowRoot?.activeElement ??\n (isFrame(active) ? active.contentDocument?.activeElement : null);\n\n if (inner === null || inner === undefined || inner === active) return active;\n active = inner;\n }\n\n return null;\n };\n\n const inCurrentDocument = (element: Element): boolean => {\n let owner = element.ownerDocument;\n\n // Nodes in a navigated iframe can remain connected to their old Document. Approval\n // requires the current frame chain as well as the ref's weakly held node identity.\n while (owner !== document) {\n const frame = owner.defaultView?.frameElement;\n\n if (\n frame === null ||\n frame === undefined ||\n !frame.isConnected ||\n (isFrame(frame) && frame.contentDocument !== owner)\n )\n return false;\n owner = frame.ownerDocument;\n }\n\n return true;\n };\n\n // Autocomplete tokens for a password, a one-time code, or a payment card's number, code or expiry.\n const secretToken =\n /(?:^|\\s)(?:current-password|new-password|one-time-code|cc-number|cc-csc|cc-exp(?:-month|-year)?)(?=\\s|$)/i;\n\n // A field once secret stays secret, such as a password its page lets the user reveal.\n const secrets = new WeakSet<Element>();\n\n /**\n * A field the DOM marks as secret, now or before: by its type, its autocomplete tokens, or a\n * style that shows dots for what it holds, as a PIN field may.\n */\n const isSecret = (element: Element): boolean => {\n if (\n (isInput(element) && element.type === \"password\") ||\n secretToken.test(element.getAttribute(\"autocomplete\") ?? \"\") ||\n ((isInput(element) || isTextArea(element)) &&\n !/^(none)?$/.test(getComputedStyle(element).getPropertyValue(\"-webkit-text-security\")))\n )\n secrets.add(element);\n\n return secrets.has(element);\n };\n\n return {\n activeElement,\n clean,\n containers,\n describe,\n inCurrentDocument,\n interactiveRoles,\n isButton,\n isDisabled,\n isDocument,\n isElement,\n isFrame,\n isHtml,\n isInput,\n isLabel,\n isRoot,\n isSecret,\n isSelect,\n isTextArea,\n lookup,\n nameOf,\n parentOf,\n refFor,\n refs,\n roleOf,\n textOf,\n };\n};\n\nexport type Names = ReturnType<typeof names>;\n","/**\n * In the page: the outline a model reads, with a ref for each control. See `names.inpage.ts` for\n * what a page-side part may use.\n */\nimport { Schema } from \"effect\";\n\nimport type { Control, Snapshot } from \"../../Snapshot.ts\";\nimport type { addresses } from \"../page/url.ts\";\nimport type { Controls } from \"./controls.inpage.ts\";\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Subjects } from \"./subjects.inpage.ts\";\nimport type { Texts } from \"./text.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\nexport interface SnapshotRequest {\n readonly full: boolean;\n readonly query: string | null;\n /** A CSS selector: only what is inside the elements it matches is read. */\n readonly within: string | null;\n readonly maxChars: number;\n readonly firstRef: number;\n}\n\n/**\n * The outline as a `Snapshot` reads it, and the next ref the page may give, or why `within` is not\n * a selector.\n */\nexport type SnapshotResult =\n | { readonly snapshot: typeof Snapshot.Encoded; readonly nextRef: number }\n | { readonly invalid: string };\n\n/** The rule every address the library reports goes by, which a link's address goes by too. */\ntype Url = ReturnType<typeof addresses>;\n\nexport const outline = (\n names: Names,\n walked: Walk,\n subjects: Subjects,\n texts: Texts,\n controlling: Controls,\n url: Url,\n) => {\n const { clean, containers, isFrame, nameOf, refFor, refs, roleOf, textOf } = names;\n const { visit } = walked;\n const { isControl } = subjects;\n const { cut } = texts;\n\n const textBlocks =\n /^(?:P|LI|TD|TH|DT|DD|LABEL|SPAN|BLOCKQUOTE|FIGCAPTION|CAPTION|PRE|STRONG|EM|B|I|SMALL|TIME|CODE|LEGEND)$/;\n\n const nested =\n \"a[href],button,input,select,textarea,summary,[role],[onclick],[tabindex],[contenteditable],canvas,iframe\";\n\n const noise = /^[\\s|•·\\-–—,.:;()[\\]{}\"'/\\\\]*$/;\n\n /** Text inside a control's label is already that control's name. */\n const inControlLabel = (element: Element): boolean => {\n const label = element.closest(\"label\");\n\n return label !== null && label.control !== null;\n };\n\n const hrefOf = (element: Element): string => {\n if (element.tagName !== \"A\") return \"\";\n const raw = element.getAttribute(\"href\") ?? \"\";\n\n if (raw === \"\" || raw.startsWith(\"javascript:\")) return \"\";\n try {\n const { origin, href } = new URL(raw, element.ownerDocument.baseURI);\n // Reported as every address is, before it is shortened, so no part of a credential shows.\n const reported = url.redact(href);\n const own = origin === location.origin && reported.startsWith(origin);\n\n return ` -> ${clean(own ? reported.slice(origin.length) : reported, 80)}`;\n } catch {\n return \"\";\n }\n };\n\n interface Place {\n readonly depth: number;\n readonly insidePointer: boolean;\n /** Inside a control, only the controls in it are read. */\n readonly controls: boolean;\n }\n\n const snapshot = (request: SnapshotRequest): SnapshotResult => {\n const roots = request.within === null ? [null] : controlling.rootsOf(request.within);\n\n if (\"invalid\" in roots) return roots;\n if (refs.next < request.firstRef) refs.next = request.firstRef;\n const width = window.innerWidth;\n const height = window.innerHeight;\n const query = request.query === null ? null : request.query.toLowerCase();\n const lines: Array<string> = [];\n const controls: Array<typeof Control.Encoded> = [];\n let above = 0;\n let below = 0;\n\n const placement = (rect: DOMRect): \"in\" | \"above\" | \"below\" | \"aside\" => {\n if (request.full) return \"in\";\n if (rect.bottom <= 0) return \"above\";\n if (rect.top >= height) return \"below\";\n if (rect.right <= 0 || rect.left >= width) return \"aside\";\n\n return \"in\";\n };\n\n const count = (rect: DOMRect) => {\n const where = placement(rect);\n\n if (where === \"above\") above++;\n if (where === \"below\") below++;\n\n return where;\n };\n\n const emit = (depth: number, line: string, rect: DOMRect): boolean => {\n if (count(rect) !== \"in\") return false;\n if (query !== null && !line.toLowerCase().includes(query)) return false;\n lines.push(`${\" \".repeat(Math.min(depth, 8))}- ${line}`);\n\n return true;\n };\n\n const control = (element: Element, rect: DOMRect, role: string | null, depth: number) => {\n const name = nameOf(element, role);\n const kind = role ?? \"clickable\";\n\n const box =\n role === \"canvas\" || role === \"iframe\"\n ? ` ${Math.round(rect.width)}x${Math.round(rect.height)} at (${Math.round(rect.x)},${Math.round(rect.y)})`\n : \"\";\n\n const line =\n placement(rect) === \"in\"\n ? `${kind}${name === \"\" ? \"\" : ` ${JSON.stringify(name)}`} [ref=${refFor(element)}]${controlling.states(element, role)}${controlling.valueOf(element)}${hrefOf(element)}${box}`\n : kind;\n\n if (emit(depth, line, rect)) controls.push(controlling.controlOf(element, role, kind, name));\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n\n if ((body === null || body === undefined) && placement(rect) === \"in\")\n lines.push(\n `${\" \".repeat(Math.min(depth + 1, 8))}- (another site's frame: use a screenshot and coordinates)`,\n );\n\n return { depth: depth + 1, insidePointer: false, controls: false };\n }\n if ([\"INPUT\", \"SELECT\", \"TEXTAREA\", \"CANVAS\", \"IMG\"].includes(element.tagName))\n return undefined;\n\n return { depth: depth + 1, insidePointer: true, controls: true };\n };\n\n const enter = (\n element: Element,\n style: CSSStyleDeclaration,\n rect: DOMRect,\n { depth, insidePointer }: Place,\n ): Place | undefined => {\n const role = roleOf(element);\n\n if (isControl(element, role, style, rect, insidePointer))\n return control(element, rect, role, depth);\n if (role === \"heading\") {\n emit(\n depth,\n `heading ${JSON.stringify(nameOf(element, role))}${controlling.states(element, role)}`,\n rect,\n );\n\n return undefined;\n }\n if (role === \"img\") {\n const alt = nameOf(element, role);\n\n if (alt !== \"\") emit(depth, `img ${JSON.stringify(alt)}`, rect);\n\n return undefined;\n }\n let inner = depth;\n\n if (role !== null && (containers[element.tagName] !== undefined || role === \"dialog\")) {\n const label = element.getAttribute(\"aria-label\");\n\n if (\n emit(depth, `${role}${label === null ? \"\" : ` ${JSON.stringify(clean(label))}`}:`, rect)\n )\n inner = depth + 1;\n }\n\n if (textBlocks.test(element.tagName) && element.querySelector(nested) === null) {\n if (inControlLabel(element)) return undefined;\n const text = clean(textOf(element), 300);\n\n if (text !== \"\" && !noise.test(text)) emit(inner, `text: ${text}`, rect);\n\n return undefined;\n }\n\n let own = \"\";\n\n for (const node of Array.from(element.childNodes))\n if (node.nodeType === Node.TEXT_NODE) own += node.textContent ?? \"\";\n own = clean(own, 300);\n if (own !== \"\" && !noise.test(own) && !inControlLabel(element))\n emit(inner, `text: ${own}`, rect);\n\n return {\n depth: inner,\n insidePointer: insidePointer || style.cursor === \"pointer\",\n controls: false,\n };\n };\n\n const visitor = {\n enter,\n admit: (child: Element, place: Place) =>\n !place.controls || child.matches(nested) || child.querySelector(nested) !== null,\n outside: count,\n };\n\n // Inside the viewport, a subtree out of view is skipped whole and counted as one part.\n for (const root of roots)\n visit(root, !request.full, { depth: 0, insidePointer: false, controls: false }, visitor);\n\n const outlined = cut(lines.join(\"\\n\"), request.maxChars);\n\n return {\n snapshot: {\n ...outlined,\n url: location.href,\n title: document.title,\n above,\n below,\n viewport: { width, height },\n scroll: {\n y: Math.round(window.scrollY),\n height: Math.round(document.documentElement.scrollHeight),\n },\n // Only the controls whose lines were kept.\n controls: controls.filter((control) => outlined.text.includes(`[ref=${control.ref}]`)),\n },\n nextRef: refs.next,\n };\n };\n\n const viewport = () => ({ width: window.innerWidth, height: window.innerHeight });\n\n return { snapshot, viewport };\n};\n\nexport type Outline = ReturnType<typeof outline>;\n\nexport const ViewportResultSchema = Schema.Struct({\n width: Schema.Finite,\n height: Schema.Finite,\n});\n","/**\n * In the page: whether it is ready to be shown, checked until it is or until a deadline. Its\n * document is parsed and has painted since, nothing that ends is animating in view, its fonts and\n * the images in view have loaded, nothing in view is marked busy (`aria-busy`), and the viewport\n * shows something: text, a canvas drawn on, a picture or drawing larger than an icon, a video or a\n * frame. So a canvas mounted blank, or a spinner alone, is still loading. A screen that only says\n * \"Loading…\" in words reads as ready, and a WebGL canvas drawn once, without keeping its drawing,\n * reads as blank. Asked for a quiet spell, where the page's changes are recorded, nothing in view\n * may have changed for that long either. After input, it waits a task and a frame. See\n * `names.inpage.ts` for what a page-side part may use.\n */\nimport { Schema } from \"effect\";\n\nimport type { History } from \"../timeline/history.inpage.ts\";\nimport type { Texts } from \"./text.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\n/** What the page is still waiting for; none when it is ready. */\nexport const ReadinessSchema = Schema.Array(\n Schema.Literals([\n \"load\",\n \"paint\",\n \"animations\",\n \"images\",\n \"fonts\",\n \"busy\",\n \"content\",\n \"changing\",\n ]),\n);\n\nexport type Readiness = typeof ReadinessSchema.Type;\n\nexport const ready = (walked: Walk, texts: Texts, kept: History) => {\n const { inView, visible } = walked;\n // A canvas is read through a small copy: reading it directly would give it a context of ours.\n let copy: OffscreenCanvasRenderingContext2D | null | undefined;\n\n const boxed = (element: Element): boolean => {\n const rect = element.getBoundingClientRect();\n\n return rect.width * rect.height > 0 && inView(rect);\n };\n\n const showing = <E extends Element>(elements: Iterable<E>): Array<E> =>\n Array.from(elements).filter((element) => boxed(element) && visible(element));\n\n // A canvas mounted blank is transparent all over.\n const drawn = (canvas: HTMLCanvasElement): boolean => {\n copy ??= new OffscreenCanvas(32, 32).getContext(\"2d\", { willReadFrequently: true });\n if (copy === null) return true;\n try {\n copy.clearRect(0, 0, 32, 32);\n copy.imageSmoothingQuality = \"high\";\n copy.drawImage(canvas, 0, 0, 32, 32);\n\n return new Uint32Array(copy.getImageData(0, 0, 32, 32).data.buffer).some(\n (pixel) => pixel !== 0,\n );\n } catch {\n // Another site's pictures in it keep it from being read, and it has drawn them.\n return true;\n }\n };\n\n // A picture the size of an icon, such as a spinner, says nothing has come yet. Text costs a\n // walk of the viewport, and a canvas a copy of it, so each is read only if needed.\n const content = (): boolean =>\n showing(document.querySelectorAll(\"video, iframe, embed, object\")).length > 0 ||\n showing(document.querySelectorAll(\"img, svg\")).some((picture) => {\n const { width, height } = picture.getBoundingClientRect();\n\n return width > 64 && height > 64;\n }) ||\n (texts.read({ ref: null, maxChars: 1, unmask: false })?.text ?? \"\") !== \"\" ||\n showing(document.querySelectorAll(\"canvas\")).some(drawn);\n\n // A hidden document paints no frames, so it is not ready to be shown.\n const painted = (): Promise<boolean> => {\n const { promise, resolve } = Promise.withResolvers<boolean>();\n\n if (document.visibilityState === \"hidden\") resolve(false);\n else requestAnimationFrame(() => resolve(true));\n\n return promise;\n };\n\n // In a frame, before it is drawn: a canvas drawn every frame still holds its drawing then.\n const check = (quietMillis: number): Promise<Readiness> =>\n painted().then((paints) => {\n const waiting: Array<Readiness[number]> = [];\n\n if (document.readyState === \"loading\") waiting.push(\"load\");\n if (!paints) waiting.push(\"paint\");\n // An endless animation, such as a pulsing dot, never ends, so only those that end count.\n if (\n document.getAnimations().some((animation) => {\n const effect = animation.effect;\n\n return (\n animation.playState === \"running\" &&\n effect !== null &&\n Number.isFinite(effect.getComputedTiming().endTime) &&\n \"target\" in effect &&\n effect.target instanceof Element &&\n boxed(effect.target)\n );\n })\n )\n waiting.push(\"animations\");\n if (Array.from(document.images).some((image) => !image.complete && boxed(image)))\n waiting.push(\"images\");\n if (document.fonts.status !== \"loaded\") waiting.push(\"fonts\");\n if (showing(document.querySelectorAll(\"[aria-busy=true]\")).length > 0) waiting.push(\"busy\");\n if (!content()) waiting.push(\"content\");\n if (kept.changing() > performance.timeOrigin + performance.now() - quietMillis)\n waiting.push(\"changing\");\n\n return waiting;\n });\n\n /**\n * Check until the page is ready, or for `millis`, and say what it is still waiting for; with\n * `quietMillis`, until nothing the record saw in view has changed for that long, too.\n */\n const wait = async (millis: number, quietMillis = 0): Promise<Readiness> => {\n const until = performance.now() + millis;\n\n for (;;) {\n const waiting = await check(quietMillis);\n\n if (waiting.length === 0 || performance.now() >= until) return waiting;\n const { promise, resolve } = Promise.withResolvers<void>();\n\n setTimeout(resolve, Math.min(50, until - performance.now()));\n await promise;\n }\n };\n\n /**\n * One task, then a frame: what the page's handlers for input did at once has run, a navigation\n * one of them started in a timer has been asked for, and their effect has painted. Says whether\n * the page painted, which a hidden one does not.\n */\n const settle = (): Promise<boolean> => {\n const { promise, resolve } = Promise.withResolvers<void>();\n\n setTimeout(resolve, 0);\n\n return promise.then(painted);\n };\n\n return { wait, settle };\n};\n","/**\n * In the page: subjects, and `find`. A subject is what an action acts on and what `find` finds:\n * an element's role, name and tag, plus its context (see `context.inpage.ts`). Its state is read\n * beside it. See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { SubjectContext } from \"../../BrowserEvent.ts\";\nimport type { ContextReader } from \"./context.inpage.ts\";\nimport type { FindRequest, Match } from \"./match.inpage.ts\";\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\nexport const subjects = (names: Names, walked: Walk, matching: Match, placing: ContextReader) => {\n const { isDisabled, isInput, nameOf, refFor, refs, roleOf, textOf } = names;\n const { acts, boxOf, controlOf, hitAt, inView } = walked;\n const { contextOf, known } = placing;\n\n /** What the outline lists as a control, with a ref: something a person would act on. */\n const isControl = (\n element: Element,\n role: string | null,\n style: CSSStyleDeclaration,\n rect: DOMRect,\n insidePointer: boolean,\n ): boolean =>\n acts(element, role) ||\n (style.cursor === \"pointer\" && !insidePointer && rect.width > 0 && rect.height > 0);\n\n const stateOf = (element: Element, role: string | null) => {\n // A state the page gives either way, or none.\n const given = (attribute: string) => {\n const value = element.getAttribute(attribute);\n\n return value === \"true\" || (value === \"false\" ? false : undefined);\n };\n\n const checkable =\n element.hasAttribute(\"aria-checked\") ||\n [\"checkbox\", \"radio\", \"switch\", \"menuitemcheckbox\", \"menuitemradio\"].includes(role ?? \"\");\n\n // In the order the outline shows them.\n return {\n disabled: isDisabled(element),\n checked: checkable\n ? (isInput(element) && element.checked) || element.getAttribute(\"aria-checked\") === \"true\"\n : undefined,\n expanded: given(\"aria-expanded\"),\n selected: given(\"aria-selected\"),\n pressed: given(\"aria-pressed\"),\n focused: element.ownerDocument.activeElement === element,\n level:\n role === \"heading\"\n ? Number(element.getAttribute(\"aria-level\")) ||\n Number(/^H([1-6])$/.exec(element.tagName)?.[1]) ||\n 2\n : undefined,\n };\n };\n\n /**\n * The elements in scope that match a query, in tree order. Without text, an element matches\n * when it has a role or is a control. With text, any element can, but text inside a control or\n * heading is that control's or heading's, and an element is left out when one inside it\n * matches too: the smallest element showing the text is found, not each one around it.\n */\n const matched = (request: FindRequest) => {\n const { at } = request;\n const matches = matching.compile(request);\n const byText = request.text !== null;\n const viewport = request.scope === \"viewport\";\n const read = known();\n\n interface Entry {\n readonly element: Element;\n readonly rect: DOMRect;\n readonly role: string | null;\n name?: string;\n context?: SubjectContext;\n matched: boolean;\n }\n\n // An element the walk is inside: its entry if it may match, whether text flows into it\n // without a break, the text read in it so far, and whether something in it matched.\n interface Open {\n readonly entry: Entry | undefined;\n readonly inline: boolean;\n readonly parts: Array<string>;\n inside: boolean;\n }\n\n const entries: Array<Entry> = [];\n const open: Array<Open> = [];\n\n const named = (entry: Entry) => (entry.name ??= nameOf(entry.element, entry.role));\n const placed = (entry: Entry) => (entry.context ??= contextOf(entry.element, read));\n\n const judge = (entry: Entry, text: () => string) =>\n matches({ role: entry.role, name: () => named(entry), text, context: () => placed(entry) });\n\n // At a point, the one element a point action there would reach, if it meets the other rules.\n const hit = at === null ? null : hitAt(document, at.x, at.y);\n\n if (hit !== null) {\n const element = controlOf(hit);\n const { x, y, width, height } = boxOf(element);\n const rect = new DOMRect(x, y, width, height);\n const entry: Entry = { element, rect, role: roleOf(element), matched: false };\n\n entry.matched = judge(entry, () => textOf(element));\n entries.push(entry);\n }\n if (at === null)\n walked.visit(\n null,\n viewport,\n { pointer: false, owned: false },\n {\n enter: (element, style, rect, state) => {\n const role = roleOf(element);\n const control = isControl(element, role, style, rect, state.pointer);\n const unit = control || role === \"heading\";\n const candidate = byText ? unit || !state.owned : role !== null || control;\n\n const entry =\n candidate && (!viewport || inView(rect))\n ? { element, rect, role, matched: false }\n : undefined;\n\n if (entry !== undefined) entries.push(entry);\n open.push({ entry, inline: style.display === \"inline\", parts: [], inside: false });\n\n return {\n pointer: state.pointer || style.cursor === \"pointer\",\n owned: state.owned || unit,\n };\n },\n text: byText ? (node) => open.at(-1)?.parts.push(node.textContent ?? \"\") : undefined,\n leave: () => {\n const closed = open.pop();\n const parent = open.at(-1);\n\n if (closed === undefined) return;\n const { entry } = closed;\n const text = closed.parts.join(\"\");\n\n if (parent !== undefined) parent.parts.push(closed.inline ? text : ` ${text} `);\n if (entry !== undefined && !(byText && closed.inside))\n entry.matched = judge(entry, () => text);\n if (parent !== undefined) parent.inside ||= closed.inside || entry?.matched === true;\n },\n },\n );\n\n return { entries: entries.filter((entry) => entry.matched), named, placed };\n };\n\n const find = (request: FindRequest) => {\n if (refs.next < request.firstRef) refs.next = request.firstRef;\n const { entries, named, placed } = matched(request);\n\n const found = entries.map((entry) => ({\n ref: refFor(entry.element),\n subject: {\n role: entry.role,\n name: named(entry),\n tag: entry.element.tagName.toLowerCase(),\n context: placed(entry),\n },\n box: {\n x: Math.round(entry.rect.x),\n y: Math.round(entry.rect.y),\n width: Math.round(entry.rect.width),\n height: Math.round(entry.rect.height),\n },\n inViewport: inView(entry.rect),\n state: stateOf(entry.element, entry.role),\n }));\n\n return { found, nextRef: refs.next };\n };\n\n /** The elements `find` would find, in tree order, with no refs given. */\n const elementsOf = (request: FindRequest) =>\n matched(request).entries.map((entry) => entry.element);\n\n return { find, elementsOf, isControl, stateOf };\n};\n\nexport type Subjects = ReturnType<typeof subjects>;\n","/**\n * In the page: the text a page shows, and the one rule for what a field shows. A field's value\n * reads `••••` unless a caller unmasks it, and a secret field's always does, including a field\n * that was secret when the library saw it, such as a password its page now reveals. Text, and the\n * outline, are cut at a line. See `names.inpage.ts` for what a page-side part may use.\n */\nimport { Schema } from \"effect\";\n\nimport type { Names } from \"./names.inpage.ts\";\nimport type { Walk } from \"./walk.inpage.ts\";\n\nexport interface TextRequest {\n /** An element to read whole, or null for what the viewport shows. */\n readonly ref: string | null;\n readonly maxChars: number;\n readonly unmask: boolean;\n}\n\n/** What `read` sends back, or null when its ref no longer names an element. */\nexport const TextResultSchema = Schema.NullOr(\n Schema.Struct({\n text: Schema.String,\n truncated: Schema.Boolean,\n url: Schema.String,\n title: Schema.String,\n }),\n);\n\nexport type TextResult = typeof TextResultSchema.Type;\n\nexport const text = (names: Names, walked: Walk) => {\n const { isHtml, isInput, isSecret, isSelect, isTextArea, lookup } = names;\n\n // Input types whose value is a label or a choice rather than something entered.\n const valueless = [\"checkbox\", \"radio\", \"button\", \"submit\", \"reset\", \"image\", \"file\"];\n\n /** What a field holds, or undefined for an element that holds nothing entered. */\n const valueOf = (element: Element): string | undefined => {\n if (isInput(element)) return valueless.includes(element.type) ? undefined : element.value;\n if (isTextArea(element)) return element.value;\n if (isSelect(element))\n return Array.from(element.selectedOptions, (option) => option.text).join(\", \");\n const parent = element.parentElement;\n\n // An editable region's own root holds what was typed into it.\n return isHtml(element) &&\n element.isContentEditable &&\n !(parent !== null && isHtml(parent) && parent.isContentEditable)\n ? element.innerText\n : undefined;\n };\n\n /** What a field shows: `••••` unless `unmask`, and always for a secret field; \"\" when empty. */\n const shown = (element: Element, unmask: boolean): string | undefined => {\n const value = valueOf(element);\n\n if (value === undefined || value.trim() === \"\") return value === undefined ? undefined : \"\";\n\n return unmask && !isSecret(element) ? value : \"••••\";\n };\n\n /** Lines cut after the last whole line within `max` characters, or at `max` when none is. */\n const cut = (lines: string, max: number) => {\n if (lines.length <= max) return { text: lines, truncated: false };\n const end = lines.lastIndexOf(\"\\n\", max);\n\n return { text: lines.slice(0, end > 0 ? end : max), truncated: true };\n };\n\n /**\n * What the viewport, or one element whole, shows as text: a line per block, table cells apart by\n * a tab, and each field as `shown` gives it.\n */\n const lines = (root: Element | null, unmask: boolean): string => {\n const lines: Array<string> = [];\n let line = \"\";\n\n const end = () => {\n const words = line\n .replace(/[^\\S\\t]+/g, \" \")\n .replace(/ ?\\t ?/g, \"\\t\")\n .trim();\n\n if (words !== \"\") lines.push(words);\n line = \"\";\n };\n\n walked.visit(root, root === null, false, {\n enter: (element, style) => {\n const { display } = style;\n const value = shown(element, unmask);\n\n const block =\n !display.startsWith(\"inline\") && display !== \"contents\" && display !== \"table-cell\";\n\n if (display === \"table-cell\") line += \"\\t\";\n if (block || element.tagName === \"BR\") end();\n if (value === undefined && !(isInput(element) && valueless.includes(element.type)))\n return block;\n // A button's value is its label; a box or a choice shows no text of its own.\n const label = isInput(element) && /^(button|submit|reset)$/.test(element.type);\n\n line += ` ${value ?? (label ? element.value : \"\")} `;\n if (block) end();\n\n return undefined;\n },\n text: (node) => {\n line += node.textContent ?? \"\";\n },\n leave: (_, block) => {\n if (block) end();\n },\n });\n end();\n\n return lines.join(\"\\n\");\n };\n\n const read = (request: TextRequest): TextResult => {\n const root = request.ref === null ? null : lookup(request.ref);\n\n return root === undefined\n ? null\n : {\n ...cut(lines(root, request.unmask), request.maxChars),\n url: location.href,\n title: document.title,\n };\n };\n\n return { cut, lines, read, shown };\n};\n\nexport type Texts = ReturnType<typeof text>;\n","/**\n * In the page: the walk every read shares, what is in view and shows, and what is painted at a\n * point. The walk visits visible elements in tree order, into shadow roots and same-origin frames.\n * Reading the viewport, it skips a subtree whose box lies outside the viewport before it styles\n * anything in it, which spares a long table all but its rows in view. A box says nothing of what\n * is positioned out of it, so a subtree is kept when its box is empty, such as a wrapper of a\n * pinned dialog, when it holds what is painted at the viewport's edges, corners or middle, under\n * any transparent layer too, or in its top layer, or when it holds what its style attribute pins\n * in view. Something a stylesheet pins inside a subtree out of view, away from those points or\n * ignoring the pointer, is missed. See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { Names } from \"./names.inpage.ts\";\n\nexport interface Visitor<S> {\n /** The state for the element's children, or undefined to leave them out. */\n readonly enter: (\n element: Element,\n style: CSSStyleDeclaration,\n rect: DOMRect,\n state: S,\n ) => S | undefined;\n /** Whether to visit a child of an element entered with `state`; all by default. */\n readonly admit?: ((child: Element, state: S) => boolean) | undefined;\n /** Each text node of an entered element, in order among its children. */\n readonly text?: ((node: Node, state: S) => void) | undefined;\n /** After the children of an element `enter` went into, with the state it returned. */\n readonly leave?: ((element: Element, state: S) => void) | undefined;\n /** A subtree left out because its box lies outside the viewport, in top-document pixels. */\n readonly outside?: ((rect: DOMRect) => void) | undefined;\n}\n\nexport const walk = (names: Names) => {\n const { interactiveRoles, isElement, isFrame, parentOf, roleOf } = names;\n\n const skipped = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE HEAD META LINK SVG\".split(\" \"));\n\n /** Whether a box, in top-document pixels, meets the viewport. */\n const inView = (rect: DOMRect, width = innerWidth, height = innerHeight): boolean =>\n rect.right > 0 && rect.bottom > 0 && rect.left < width && rect.top < height;\n\n /** Whether an element reached on its own shows, by the walk's rule and its ancestors'. */\n const visible = (element: Element): boolean =>\n element.checkVisibility({ opacityProperty: true, visibilityProperty: true }) &&\n element.closest(\"[aria-hidden=true]\") === null;\n\n const isVisible = (element: Element, style: CSSStyleDeclaration, rect: DOMRect): boolean =>\n style.display !== \"none\" &&\n style.visibility === \"visible\" &&\n style.opacity !== \"0\" &&\n element.getAttribute(\"aria-hidden\") !== \"true\" &&\n (rect.width > 0 || rect.height > 0 || style.display === \"contents\");\n\n // Coordinate subtraction is valid only for an untransformed frame. Report the frame itself\n // otherwise: the real pixel input still works, and its receipt must not name a guessed child.\n const untransformed = (frame: HTMLIFrameElement, rect: DOMRect): boolean => {\n if (rect.width !== frame.offsetWidth || rect.height !== frame.offsetHeight) return false;\n let ancestor: Element | null = frame;\n\n while (ancestor !== null) {\n const view = ancestor.ownerDocument.defaultView ?? window;\n const style = view.getComputedStyle(ancestor);\n\n if (\n style.transform !== \"none\" ||\n style.scale !== \"none\" ||\n style.rotate !== \"none\" ||\n style.perspective !== \"none\" ||\n style.zoom !== \"1\"\n )\n return false;\n ancestor = parentOf(ancestor);\n }\n\n return true;\n };\n\n /** The element painted at a point, inside shadow roots and same-origin frames. */\n const hitAt = (root: Document | ShadowRoot, x: number, y: number): Element | null => {\n let hit = root.elementFromPoint(x, y);\n\n while (hit?.shadowRoot !== null && hit?.shadowRoot !== undefined) {\n const inner = hit.shadowRoot.elementFromPoint(x, y);\n\n if (inner === null || inner === hit) break;\n hit = inner;\n }\n if (hit !== null && isFrame(hit)) {\n const document = hit.contentDocument;\n\n if (document !== null) {\n const rect = hit.getBoundingClientRect();\n\n if (untransformed(hit, rect))\n return (\n hitAt(document, x - rect.left - hit.clientLeft, y - rect.top - hit.clientTop) ?? hit\n );\n }\n }\n\n return hit;\n };\n\n /** Whether its role or a click handler makes an element a control. */\n const acts = (element: Element, role: string | null): boolean =>\n (role !== null && (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\")) ||\n element.hasAttribute(\"onclick\");\n\n // A painted child of a control still activates the control; keep its name without moving the point.\n const controlOf = (hit: Element): Element => {\n let element: Element | null = hit;\n\n while (element !== null) {\n if (acts(element, roleOf(element))) return element;\n element = parentOf(element);\n }\n\n return hit;\n };\n\n /** An element's box in top-document viewport pixels, through the frames around it. */\n const boxOf = (element: Element): { x: number; y: number; width: number; height: number } => {\n const { x, y, width, height } = element.getBoundingClientRect();\n const frame = element.ownerDocument.defaultView?.frameElement ?? null;\n\n if (frame === null) return { x, y, width, height };\n const outer = boxOf(frame);\n\n return { x: x + outer.x + frame.clientLeft, y: y + outer.y + frame.clientTop, width, height };\n };\n\n /** What is painted where pinned things sit, what is pinned in view, and every element holding it. */\n const painted = (width: number, height: number): Set<Element> => {\n const keep = new Set<Element>();\n\n const hold = (element: Element | null) => {\n for (\n let node = element;\n node !== null && !keep.has(node);\n node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null\n )\n keep.add(node);\n };\n\n for (const y of [8, 48, height / 2, height - 48, height - 8])\n for (const x of [8, 48, width / 4, width / 2, (width * 3) / 4, width - 48, width - 8])\n if (x >= 0 && y >= 0 && x < width && y < height) {\n hold(hitAt(document, x, y));\n // What a transparent layer, such as one over a video player, covers.\n for (const beneath of document.elementsFromPoint(x, y)) hold(beneath);\n }\n for (const element of Array.from(document.querySelectorAll(\":modal, :popover-open\")))\n hold(element);\n // What a style attribute pins, wherever it sits; a stylesheet's pins only at the points.\n for (const element of Array.from(document.querySelectorAll('[style*=\"fixed\" i]')))\n if (inView(element.getBoundingClientRect(), width, height)) hold(element);\n\n return keep;\n };\n\n /**\n * Visit `root` and what it holds, or the whole document when `root` is null. With `viewport`,\n * a subtree outside the viewport is skipped, as described above.\n */\n const visit = <S>(root: Element | null, viewport: boolean, state: S, visitor: Visitor<S>) => {\n const width = window.innerWidth;\n const height = window.innerHeight;\n let keep: Set<Element> | undefined;\n\n const children = (parent: ParentNode, inner: S, dx: number, dy: number) => {\n // Text nodes are touched only for a visitor that reads them.\n const nodes = visitor.text === undefined ? parent.children : parent.childNodes;\n\n for (const node of Array.from<Node>(nodes)) {\n if (node.nodeType === Node.TEXT_NODE) visitor.text?.(node, inner);\n else if (isElement(node) && (visitor.admit === undefined || visitor.admit(node, inner)))\n one(node, inner, dx, dy);\n }\n };\n\n const one = (element: Element, outer: S, dx: number, dy: number): void => {\n if (skipped.has(element.tagName.toUpperCase())) return;\n const local = element.getBoundingClientRect();\n const rect = new DOMRect(local.x + dx, local.y + dy, local.width, local.height);\n\n if (\n viewport &&\n local.width > 0 &&\n local.height > 0 &&\n !inView(rect, width, height) &&\n !(keep ??= painted(width, height)).has(element)\n ) {\n visitor.outside?.(rect);\n\n return;\n }\n const style = getComputedStyle(element);\n\n if (!isVisible(element, style, local)) return;\n const inner = visitor.enter(element, style, rect, outer);\n\n if (inner === undefined) return;\n if (isFrame(element)) {\n const body = element.contentDocument?.body;\n\n if (body !== null && body !== undefined) children(body, inner, rect.x, rect.y);\n } else {\n if (element.shadowRoot !== null) children(element.shadowRoot, inner, dx, dy);\n children(element, inner, dx, dy);\n }\n visitor.leave?.(element, inner);\n };\n\n if (root === null) children(document, state, 0, 0);\n else one(root, state, 0, 0);\n };\n\n return { acts, boxOf, controlOf, hitAt, inView, visible, visit };\n};\n\nexport type Walk = ReturnType<typeof walk>;\n","/**\n * In the page: what changed after `since`, up to `until`, as a read returns it. A read starts the\n * record if it has not, and keeps it going. What waited for the page to render is judged first, as\n * it stands; then each element's history is folded over the window (`history.inpage.ts`), and only\n * now named: its role, its name when something else names it, its tag, and its context, where it\n * is or, for what was removed, where it was. A field's value reads `••••` unless the read unmasks\n * it, and a secret field's always does. A change names the input it followed only where it was\n * the input's own doing, by `Change.cause`'s rule. See `names.inpage.ts` for what a page-side part\n * may use.\n */\nimport { Schema } from \"effect\";\n\nimport { Change } from \"../../Change.ts\";\nimport type { Known, ContextReader } from \"../reading/context.inpage.ts\";\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Folded } from \"./fold.inpage.ts\";\nimport type { History } from \"./history.inpage.ts\";\nimport type { Marks } from \"./marks.inpage.ts\";\nimport type { Recorder } from \"./record.inpage.ts\";\nimport type { Sight } from \"./sight.inpage.ts\";\n\n/** A window on the page's own clock: epoch milliseconds, or the record's start and now. */\nexport interface ChangesRequest {\n readonly since: number | null;\n readonly until: number | null;\n readonly unmask: boolean;\n}\n\n/**\n * What a read sends back: its window and the record's state, and each change as `Change` encodes\n * it, all on the page's clock.\n */\nexport const ChangesResultSchema = Schema.Struct({\n until: Schema.Finite,\n from: Schema.Finite,\n dropped: Schema.Int,\n records: Schema.Array(Change),\n});\n\nexport type ChangesResult = typeof ChangesResultSchema.Encoded;\n\nexport const changes = (\n names: Names,\n placing: ContextReader,\n kept: History,\n seeing: Sight,\n marking: Marks,\n recorder: Recorder,\n) => {\n const { clean, isInput, roleOf, nameOf } = names;\n const groups = \"tr,[role=row],form,dialog,[role=dialog],[role=alertdialog]\";\n\n /** Whether `element` lies in what an input on `target` acted on, its group, or what it controls. */\n const local = (target: Element, element: Element): boolean => {\n const controls = target.closest(\"[aria-controls]\")?.getAttribute(\"aria-controls\") ?? \"\";\n const group = target.closest(groups);\n\n return (\n target.contains(element) ||\n group?.contains(element) === true ||\n controls\n .split(/\\s+/)\n .some((id) => id !== \"\" && document.getElementById(id)?.contains(element) === true)\n );\n };\n\n /** What an element sits in, or sat in as it went. */\n const parentOf = (key: object): Element | null =>\n key instanceof Element\n ? key.isConnected\n ? key.parentElement\n : (marking.placeOf(key) ?? null)\n : null;\n\n // What changed in the 10 s before an input is in flux at it, and a change in the 2 s before says\n // the page was not still.\n const fluxMillis = 10_000;\n const stillMillis = 2000;\n\n /**\n * Each input a change may follow, with what the page did before it: what changed in the 10 s\n * before, the parents that gained or lost a child then, and whether nothing changed, and nothing\n * was let go, in the 2 s before. What holds the input's target, as a menu holds its item, came\n * with it, so it counts only as changing itself.\n */\n const before = () => {\n const inputs = recorder.inputs();\n\n if (inputs.length === 0) return [];\n const { tracks, losses } = kept.recent();\n\n return inputs.map(({ at, target }) => {\n const changed = new Set<object>();\n const moved = new Set<Element | null>();\n let still = losses.every((lost) => lost >= at || lost < at - stillMillis);\n\n for (const { key, kind, initial, samples } of tracks) {\n // Whether each change in the 10 s before came or went: it, or what it followed, showed\n // nothing. A field's own edits are the input's, not the page's.\n const prior = samples.flatMap(({ at: when, shown }, index) =>\n kind === \"value\" || when >= at || when < at - fluxMillis\n ? []\n : [shown === null || (index === 0 ? initial : samples[index - 1]?.shown) === null],\n );\n\n if (prior.length > 0) changed.add(key);\n if (prior.length === 0 || (key instanceof Element && key.contains(target))) continue;\n if (prior.includes(true)) moved.add(parentOf(key));\n if (samples.some(({ at: when }) => when < at && when >= at - stillMillis)) still = false;\n }\n\n return { at, target, changed, moved, still };\n });\n };\n\n /** The input a change followed, on the page's clock, where `Change.cause`'s rule names one. */\n const causeOf = (\n one: Folded,\n element: Element,\n inputs: ReturnType<typeof before>,\n ): number | undefined => {\n const parent = parentOf(one.track.key);\n\n for (const input of inputs.toReversed()) {\n const after = one.startedAt - input.at;\n\n // A change in the input's own tick followed it, as when a busy page runs a press and its\n // release back to back.\n if (after < 0) continue;\n if (after > 3000) break;\n\n // In flux: it changed, or another came into or left what it sits in, in the 10 s before.\n const changing =\n one.track.known >= input.at - fluxMillis ||\n input.changed.has(one.track.key) ||\n (parent !== null && input.moved.has(parent));\n\n if (!changing && (local(input.target, element) || (after <= 500 && input.still)))\n return input.at;\n }\n\n return undefined;\n };\n\n const describe = (\n one: Folded,\n known: Known,\n unmask: boolean,\n inputs: ReturnType<typeof before>,\n ): typeof Change.Encoded => {\n const { track, kind, before, after, lowest, highest, ...times } = one;\n const element = track.key instanceof Element ? track.key : null;\n const where = element?.isConnected === true ? element : (marking.placeOf(track.key) ?? null);\n const role = element === null ? null : roleOf(element);\n const field = kind === \"value\";\n\n const checkable =\n element !== null && isInput(element) && /^(checkbox|radio)$/.test(element.type);\n\n // A field's value is masked unless asked, empty or a box's state; a secret one never kept more.\n const masked = (value: string | undefined) =>\n value === undefined || !field || unmask || checkable || value === \"\" ? value : \"••••\";\n\n return {\n ...times,\n kind,\n subject: {\n role,\n // An element's own words are what changed, so it is named only by what else names it.\n name:\n element === null\n ? \"\"\n : field\n ? nameOf(element, role)\n : clean(element.getAttribute(\"aria-label\"), 120),\n tag: element === null ? \"title\" : element.tagName.toLowerCase(),\n context: kind === \"title\" || where === null ? {} : placing.contextOf(where, known),\n },\n before: masked(before),\n after: masked(after),\n lowest: field ? undefined : lowest,\n highest: field ? undefined : highest,\n // A field's own edit needs no cause.\n cause: field || where === null ? undefined : causeOf(one, where, inputs),\n };\n };\n\n /** What changed after `since`, up to `until`, and no later than now. */\n const read = (request: ChangesRequest): ChangesResult => {\n const now = performance.timeOrigin + performance.now();\n\n recorder.start();\n seeing.settle();\n const until = Math.min(request.until ?? now, now);\n\n const { from, dropped, folded } = kept.read(\n request.since ?? Number.NEGATIVE_INFINITY,\n until,\n now,\n );\n\n const known = placing.known();\n const inputs = before();\n\n return {\n until,\n from,\n dropped,\n records: folded.map((one) => describe(one, known, request.unmask, inputs)),\n };\n };\n\n return { read };\n};\n\nexport type Changes = ReturnType<typeof changes>;\n","/**\n * In the page: one element's history in the change record, and its fold over a window. A fold gives\n * what the element showed at the window's start and at its end, how often that changed between,\n * the lowest and highest of a number that changed more than once, and when it last changed before\n * the window. Only what was seen in view as it changed is told. It touches no DOM, so it also runs\n * outside a page. See `names.inpage.ts` for what a page-side part may use.\n */\n\n/** What an element shows: its words, `null` while it shows nothing, `undefined` until judged. */\nexport type Shown = string | null | undefined;\n\nexport interface Sample {\n readonly at: number;\n shown: Shown;\n /** Whether it was in view as the page rendered it; undefined until then. */\n seen: boolean | undefined;\n}\n\n/** One element's history, oldest change first. */\nexport interface Track {\n key: object;\n readonly kind: \"content\" | \"value\" | \"title\";\n /** What it showed before its oldest kept change; undefined when that is unknown. */\n initial: Shown;\n /** Before this, the record let some of its changes go. */\n known: number;\n readonly samples: Array<Sample>;\n}\n\nexport type Kind = \"text\" | \"appeared\" | \"disappeared\" | \"brief\" | \"value\" | \"title\";\n\n/** One element's changes over a window, before the page names the element. */\nexport interface Folded {\n readonly track: Track;\n readonly kind: Kind;\n readonly startedAt: number;\n readonly at: number;\n readonly before: string | undefined;\n readonly after: string | undefined;\n readonly count: number;\n readonly lowest: string | undefined;\n readonly highest: string | undefined;\n readonly earlier: number | undefined;\n}\n\nexport const fold = () => {\n /** The one number some words show, such as 61240 in \"$61,240\"; none for none or several. */\n const number = (words: string): ReadonlyArray<number> => {\n const found = words.match(/[-+−]?\\d[\\d,]*(?:\\.\\d+)?/g);\n\n const value = Number(\n found?.length === 1 ? found[0]?.replaceAll(\",\", \"\").replace(\"−\", \"-\") : \"\",\n );\n\n return found?.length === 1 && Number.isFinite(value) ? [value] : [];\n };\n\n /** A track's changes after `since`, up to `until`, if one was seen in view. */\n const over = (track: Track, since: number, until: number): Folded | undefined => {\n const inside = track.samples.filter((sample) => sample.at > since && sample.at <= until);\n const first = inside[0];\n const last = inside.at(-1);\n\n if (first === undefined || last === undefined || !inside.some((sample) => sample.seen === true))\n return undefined;\n const prior = track.samples[track.samples.indexOf(first) - 1];\n // What it showed at `since` is lost when the record let go of changes after it.\n const lost = track.known <= since ? track.known : undefined;\n\n const start =\n prior === undefined ? (lost === undefined ? undefined : track.initial) : prior.shown;\n\n const words = [start, ...inside.map((sample) => sample.shown)].filter(\n (each) => typeof each === \"string\",\n );\n\n const numbers = words.flatMap(number);\n const ranged = inside.length > 1 && numbers.length === words.length;\n\n const kind: Kind =\n track.kind !== \"content\"\n ? track.kind\n : last.shown === null\n ? start === null\n ? \"brief\"\n : \"disappeared\"\n : start === null\n ? \"appeared\"\n : \"text\";\n\n return {\n track,\n kind,\n startedAt: first.at,\n at: last.at,\n before: kind === \"disappeared\" ? words.at(-1) : (start ?? undefined),\n after: kind === \"brief\" ? words.at(-1) : (last.shown ?? undefined),\n count: inside.length,\n lowest: ranged ? words[numbers.indexOf(Math.min(...numbers))] : undefined,\n highest: ranged ? words[numbers.indexOf(Math.max(...numbers))] : undefined,\n earlier: prior?.at ?? (lost === Number.NEGATIVE_INFINITY ? undefined : lost),\n };\n };\n\n /**\n * How readily a track gives way when the record is full: one that holds no change first, then\n * one that keeps changing, one never seen in view and one that has gone; news never does.\n */\n const rank = ({ samples: [only, ...more] }: Track): number =>\n only === undefined\n ? 4\n : more.length > 0\n ? 3\n : only.seen === false\n ? 2\n : only.shown === null\n ? 1\n : 0;\n\n return { number, over, rank };\n};\n\nexport type Fold = ReturnType<typeof fold>;\n","/**\n * In the page: a document's record of what changed, element by element, within fixed bounds. It\n * touches no DOM, so it also runs outside a page.\n *\n * - **A change** is a new state: other words, or presence gained or lost. Within one batch of\n * mutations the latest state stands, so an element moved in one step has not changed.\n * - **Bounds.** 256 elements, each with its latest 32 changes, kept a minute. On a busier page an\n * element that keeps changing gives way first, then one never seen in view, then one that has\n * gone, so news stays. What gives way, and what finds no room, is counted, and the record says it\n * is whole only after the latest such loss.\n *\n * Each element's history is folded over a window by `fold.inpage.ts`. See `names.inpage.ts` for\n * what a page-side part may use.\n */\nimport type { Fold, Sample, Shown, Track } from \"./fold.inpage.ts\";\n\n/** How much the record keeps: elements, changes of each, and for how long. */\nexport interface Bounds {\n readonly tracks: number;\n readonly samples: number;\n readonly retention: number;\n}\n\nexport const history = (\n folding: Fold,\n bounds: Bounds = { tracks: 256, samples: 32, retention: 60_000 },\n) => {\n const { tracks: maxTracks, samples: maxSamples, retention } = bounds;\n const tracks = new Map<object, Track>();\n // Keys that gave way or found no room: their later changes are counted, not kept.\n let refused = new WeakSet<object>();\n // When the record let changes go, and how many, and the latest such time; keys whose tracks went.\n let losses: Array<[number, number]> = [];\n let lastLoss = Number.NEGATIVE_INFINITY;\n const gone: Array<object> = [];\n let begun: number | undefined;\n\n // Losses at one time count together. Beyond 256 times the first noted go, so a count falls short\n // rather than over.\n const lose = (at: number, count: number) => {\n const last = losses.at(-1);\n\n if (count <= 0) return;\n lastLoss = Math.max(lastLoss, at);\n if (last?.[0] === at) last[1] += count;\n else losses.push([at, count]);\n if (losses.length > 256) losses.shift();\n };\n\n const latest = (track: Track) => track.samples.at(-1)?.at ?? Number.NEGATIVE_INFINITY;\n\n const drop = (track: Track) => {\n tracks.delete(track.key);\n gone.push(track.key);\n };\n\n // How often the tracks' samples have changed, and when a search found none to give way, which\n // holds until they change again, so a burst of newcomers pays for one search.\n let version = 0;\n let barren = -1;\n\n /** What gives way for a newcomer: one that holds no change, then one that keeps changing. */\n const victim = (): Track | undefined => {\n let chosen: Track | undefined;\n let rank = 0;\n\n for (const track of barren === version ? [] : tracks.values()) {\n const next = folding.rank(track);\n\n if (next > rank) [chosen, rank] = [track, next];\n if (rank === 4) break;\n }\n if (chosen === undefined) barren = version;\n\n return chosen;\n };\n\n const evict = (track: Track) => {\n drop(track);\n if (track.samples.length > 0) refused.add(track.key);\n for (const sample of track.samples) lose(sample.at, 1);\n };\n\n /** A key the record cannot keep: its change is counted. */\n const refuse = (key: object, at: number): undefined => {\n refused.add(key);\n lose(at, 1);\n\n return undefined;\n };\n\n /**\n * A new state for `key` at `at`: its sample, or none when it is no change or finds no room.\n * `initial` says what a key not yet kept showed before.\n */\n const note = (\n key: object,\n kind: Track[\"kind\"],\n at: number,\n shown: Shown,\n initial: () => Shown,\n ): Sample | undefined => {\n let track = tracks.get(key);\n\n if (track === undefined) {\n const full = !refused.has(key) && tracks.size >= maxTracks;\n const out = full ? victim() : undefined;\n\n if (refused.has(key) || (full && out === undefined)) return refuse(key, at);\n const before = initial();\n\n if (shown !== undefined && shown === before) return undefined;\n if (out !== undefined) evict(out);\n track = { key, kind, initial: before, known: Number.NEGATIVE_INFINITY, samples: [] };\n tracks.set(key, track);\n }\n const { samples } = track;\n\n version++;\n\n if (samples.at(-1)?.at === at) samples.pop();\n const previous = samples.length === 0 ? track.initial : samples.at(-1)?.shown;\n\n if (shown !== undefined && shown === previous) return undefined;\n const oldest = samples.length >= maxSamples ? samples.shift() : undefined;\n\n if (oldest !== undefined) {\n track.initial = oldest.shown;\n track.known = oldest.at;\n lose(oldest.at, 1);\n }\n const sample: Sample = { at, shown, seen: undefined };\n\n samples.push(sample);\n\n return sample;\n };\n\n /** Judge a sample as the page rendered it; a state that repeats the one before is no change. */\n const settle = (key: object, sample: Sample, shown: Shown, seen: boolean) => {\n const track = tracks.get(key);\n\n // `null` is a state, what shows nothing, so only `undefined` is unjudged.\n version++;\n if (sample.shown === undefined) sample.shown = shown;\n if (sample.seen === undefined) sample.seen = seen;\n if (track === undefined) return;\n let previous = track.initial;\n\n const changes = track.samples.filter((each) => {\n const same = each.shown !== undefined && each.shown === previous;\n\n if (!same) previous = each.shown;\n\n return !same;\n });\n\n track.samples.splice(0, track.samples.length, ...changes);\n };\n\n /**\n * The window after `since`, up to `until`: where the record is whole, how many changes in it the\n * record let go, and each element's changes, oldest first by when they began.\n */\n const read = (since: number, until: number, now: number) => {\n for (const track of tracks.values()) if (latest(track) < now - retention) drop(track);\n\n return {\n from: Math.min(until, Math.max(begun ?? now, now - retention, lastLoss)),\n dropped: losses.reduce(\n (sum, [at, count]) => (at > since && at <= until ? sum + count : sum),\n 0,\n ),\n folded: [...tracks.values()]\n .flatMap((track) => folding.over(track, since, until) ?? [])\n .toSorted((left, right) => left.startedAt - right.startedAt),\n };\n };\n\n /** When something in view last changed, or something not yet judged; for a wait for stillness. */\n const changing = (): number =>\n Math.max(\n Number.NEGATIVE_INFINITY,\n ...Array.from(\n tracks.values(),\n (track) =>\n track.samples.findLast((sample) => sample.seen !== false)?.at ?? Number.NEGATIVE_INFINITY,\n ),\n );\n\n return {\n begin: (at: number) => {\n begun = at;\n },\n begun: () => begun !== undefined,\n clear: () => {\n for (const track of tracks.values()) drop(track);\n refused = new WeakSet();\n losses = [];\n lastLoss = Number.NEGATIVE_INFINITY;\n begun = undefined;\n },\n changing,\n /** Keys whose tracks went since this was last asked, for the recorder to stop watching. */\n forgotten: (): ReadonlyArray<object> => gone.splice(0),\n has: (key: object) => tracks.has(key),\n /** Whether the record has let `key` go: its later changes are counted, never kept. */\n refuses: (key: object) => refused.has(key),\n lose,\n note,\n read,\n /** Each element's history, and when the record let changes go, for a read to judge causes. */\n recent: () => ({ tracks: [...tracks.values()], losses: losses.map(([at]) => at) }),\n /** A track moves to the element that took its key's place, as a re-rendered price does. */\n rekey: (from: object, to: object): boolean => {\n const track = tracks.get(from);\n\n if (track === undefined || tracks.has(to)) return false;\n tracks.delete(from);\n track.key = to;\n tracks.set(to, track);\n\n return true;\n },\n settle,\n };\n};\n\nexport type History = ReturnType<typeof history>;\n","/**\n * In the page: what one batch of mutations changed, marked for the record as cheaply as it can be.\n *\n * - **An element whose own text changed.** One that holds only text, as most prices and labels do,\n * is read whole at once, since that text is all it shows, and the batch is undone to say what it\n * said before; any other is read as it renders. Once followed, a text-only element's changes are\n * taken as its text's, with no look at the nodes that came and went.\n * - **An element added** is read as it renders; one that moved in the same batch did not arrive.\n * What came with text its parent gained is part of the parent's change, and what takes a removed\n * element's place, as a re-rendered price does, takes its history. **An element removed** is\n * noted only if the record follows it, so a removal it never saw is not told.\n * - **`hidden`, `open`, `aria-hidden`, `class` or `style`** may show or hide an element. The old\n * value says whether it was hidden before, except for a class, where only the element's state as\n * the record last saw it can: what it follows, what alerts, status lines, dialogs and popovers\n * showed when it started, and what an earlier class change showed. A style that neither hid it\n * nor hides it, such as a transform, shows nothing new.\n * - **The document's title.**\n *\n * See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Shown } from \"./fold.inpage.ts\";\nimport type { History } from \"./history.inpage.ts\";\nimport type { Sight } from \"./sight.inpage.ts\";\n\ninterface Batch {\n readonly at: number;\n readonly owners: Set<Element>;\n readonly arrived: Set<Node>;\n readonly left: Set<Node>;\n}\n\nexport const marks = (names: Names, kept: History, seeing: Sight) => {\n const { clean, isElement, isHtml } = names;\n const unwritten = new Set(\"SCRIPT STYLE NOSCRIPT TEMPLATE TITLE\".split(\" \"));\n const hiding = /display\\s*:\\s*none|visibility\\s*:\\s*hidden|opacity\\s*:\\s*0(?![.\\d])/i;\n // Where removed elements were, which gives their context, and the title as last seen.\n let places = new WeakMap<object, Element>();\n let title = \"\";\n\n const words = (text: string | null | undefined): Shown => clean(text, 200) || null;\n\n const content = (element: Element, at: number, shown: Shown, initial: () => Shown) => {\n const sample = kept.note(element, \"content\", at, shown, initial);\n\n if (sample !== undefined) seeing.look(element, sample);\n };\n\n /** What a text-only element said before this batch: its text with the batch undone. */\n const before = (leaf: Element, records: ReadonlyArray<MutationRecord>): Shown => {\n let nodes: Array<Node> = Array.from(leaf.childNodes);\n const old = new Map<Node, string>();\n\n for (const record of records.toReversed())\n if (record.type === \"characterData\") old.set(record.target, record.oldValue ?? \"\");\n else {\n const added = new Set(Array.from(record.addedNodes));\n\n nodes = nodes.filter((node) => !added.has(node));\n const next = record.nextSibling === null ? -1 : nodes.indexOf(record.nextSibling);\n\n nodes.splice(next === -1 ? nodes.length : next, 0, ...Array.from(record.removedNodes));\n }\n\n return words(nodes.map((node) => old.get(node) ?? node.textContent).join(\"\"));\n };\n\n const attribute = (\n element: Element,\n { attributeName: name, oldValue: old }: MutationRecord,\n at: number,\n ) => {\n // Whether the old value hid it; a class can say only through the page's style.\n const was =\n name === \"hidden\"\n ? old !== null\n : name === \"aria-hidden\"\n ? old === \"true\"\n : name === \"open\"\n ? element.tagName === \"DIALOG\" && old === null\n : name === \"style\" && hiding.test(old ?? \"\");\n\n if (name === \"style\" && !was && !hiding.test(element.getAttribute(\"style\") ?? \"\")) return;\n const state = seeing.state(element);\n\n if (!kept.has(element) && !was && state === undefined && name !== \"open\")\n return seeing.glance(element);\n content(element, at, undefined, () =>\n was || state === false\n ? null\n : name === \"open\" && old === null\n ? words(element.querySelector(\":scope > summary\")?.textContent)\n : words(element.textContent),\n );\n };\n\n /** What one mutation added to and removed from `target`. */\n const nodes = (change: MutationRecord, target: Element, batch: Batch) => {\n const added = Array.from(change.addedNodes).slice(0, 64);\n const removed = Array.from(change.removedNodes).slice(0, 64);\n\n const text = [...added, ...removed].some(\n (node) => !isElement(node) && /\\S/.test(node.textContent ?? \"\"),\n );\n\n kept.lose(batch.at, Math.max(change.addedNodes.length, change.removedNodes.length) - 64);\n if (text) batch.owners.add(target);\n removed.forEach((gone, index) => {\n const node = added[index];\n\n if (!isElement(gone)) return;\n batch.left.add(gone);\n if (node !== undefined && isElement(node) && kept.rekey(gone, node)) seeing.unwatch(gone);\n else if (kept.has(gone)) {\n places.set(gone, target);\n const sample = kept.note(gone, \"content\", batch.at, null, () => undefined);\n\n if (sample !== undefined) sample.seen = seeing.viewed(gone);\n seeing.unwatch(gone);\n }\n });\n for (const node of added)\n if (\n isElement(node) &&\n isHtml(node) &&\n !unwritten.has(node.tagName) &&\n !node.isContentEditable\n )\n if (kept.has(node) || (!text && !batch.left.has(node))) {\n batch.arrived.add(node);\n content(node, batch.at, undefined, () => null);\n }\n };\n\n /** Whether `element` is inside something this batch added, which tells it with its own words. */\n const inside = (element: Element, arrived: ReadonlySet<Node>): boolean => {\n for (let up = element.parentElement; arrived.size > 0 && up !== null; up = up.parentElement)\n if (arrived.has(up)) return true;\n\n return false;\n };\n\n const ownerOf = (change: MutationRecord): Node | null =>\n change.type === \"characterData\" ? change.target.parentElement : change.target;\n\n /** Mark what one batch of mutations changed, at `at`. */\n const mark = (records: ReadonlyArray<MutationRecord>, at: number) => {\n const batch: Batch = { at, owners: new Set(), arrived: new Set(), left: new Set() };\n let byOwner: Map<Node | null, Array<MutationRecord>> | undefined;\n\n for (const change of records) {\n const target = ownerOf(change);\n\n if (target === null || !isElement(target) || inside(target, batch.arrived)) continue;\n // A text-only element the record follows, or has let go, changes only its text, as a\n // ticking price does, so its nodes need no look: each would cost this world a wrapper.\n const known = kept.has(target) || kept.refuses(target);\n\n if (change.type !== \"attributes\")\n if (change.type === \"characterData\" || (target.childElementCount === 0 && known))\n batch.owners.add(target);\n else nodes(change, target, batch);\n else if (isHtml(target) && target !== document.body && target !== document.documentElement)\n attribute(target, change, at);\n }\n for (const owner of batch.owners) {\n const leaf = owner.childElementCount === 0;\n\n // What the record let go is counted, with no word of it read.\n if (kept.refuses(owner)) kept.lose(at, 1);\n if (kept.refuses(owner) || !isHtml(owner) || unwritten.has(owner.tagName)) continue;\n // What is typed into an editable region is a field's value, told masked as one.\n if (owner === document.body || owner.isContentEditable) continue;\n if (batch.arrived.has(owner) || inside(owner, batch.arrived)) continue;\n content(owner, at, leaf ? words(owner.textContent) : undefined, () => {\n byOwner ??= Map.groupBy(records, ownerOf);\n\n return leaf ? before(owner, byOwner.get(owner) ?? []) : undefined;\n });\n }\n if (document.title === title) return;\n const previous = words(title);\n\n const sample = kept.note(\n document,\n \"title\",\n at,\n words((title = document.title)),\n () => previous,\n );\n\n if (sample !== undefined) sample.seen = true;\n };\n\n return {\n mark,\n /** Where a removed element was, which gives its context. */\n placeOf: (key: object): Element | undefined => places.get(key),\n /** Start afresh, from the document's title now. */\n reset: () => {\n places = new WeakMap();\n title = document.title;\n },\n };\n};\n\nexport type Marks = ReturnType<typeof marks>;\n","/**\n * In the page: the change recorder. It starts at a read of the page's changes, and from then on at\n * the start of each document the page loads, once that document is parsed; it stops in a document\n * nobody has read for two minutes. While it runs, a MutationObserver hands each batch to\n * `marks.inpage.ts`, and an IntersectionObserver judges as the page renders whether what was marked\n * was in view (`sight.inpage.ts`). A field reports its value as it is edited, a secret one only as\n * `••••`, and trusted pointer and key input is kept, for a read to name causes by. Nothing unmarked\n * is read: no walk, no words, no layout. See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Texts } from \"../reading/text.inpage.ts\";\nimport type { History } from \"./history.inpage.ts\";\nimport type { Marks } from \"./marks.inpage.ts\";\nimport type { Sight } from \"./sight.inpage.ts\";\n\nexport const record = (\n names: Names,\n texts: Texts,\n kept: History,\n seeing: Sight,\n marking: Marks,\n) => {\n const { isElement, isInput } = names;\n const epoch = () => performance.timeOrigin + performance.now();\n\n const declared =\n \"[role=alert],[role=status],[role=log],[role=dialog],[role=alertdialog],[aria-live],dialog,[popover]\";\n\n let running = false;\n let lastRead = 0;\n // What fields held as they took focus, and the latest trusted input, newest last.\n let focused = new WeakMap<Element, string>();\n const inputs: Array<{ readonly at: number; readonly target: Element }> = [];\n\n const targetOf = (event: Event): Element | undefined => {\n const target = event.composedPath()[0];\n\n return target instanceof Node && isElement(target) ? target : undefined;\n };\n\n /** A field's value as the record keeps it: a secret one's as `••••`, a box's checked or not. */\n const valueOf = (field: Element): string | undefined =>\n isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\")\n ? field.checked\n ? \"checked\"\n : \"not checked\"\n : texts.shown(field, true);\n\n const onFocus = (event: Event) => {\n const field = targetOf(event);\n const value = field === undefined ? undefined : valueOf(field);\n\n if (field !== undefined && value !== undefined) focused.set(field, value);\n };\n\n const onValue = (event: Event) => {\n const field = targetOf(event);\n const value = field === undefined ? undefined : valueOf(field);\n\n if (field === undefined || value === undefined) return;\n const sample = kept.note(field, \"value\", epoch(), value, () => focused.get(field) ?? null);\n\n if (sample !== undefined) seeing.look(field, sample);\n };\n\n const onInput = (event: Event) => {\n const target = targetOf(event);\n\n if (!event.isTrusted || target === undefined) return;\n inputs.push({ at: performance.timeOrigin + event.timeStamp, target });\n if (inputs.length > 8) inputs.shift();\n };\n\n const listeners = [\n [\"focusin\", onFocus],\n [\"input\", onValue],\n [\"change\", onValue],\n [\"pointerdown\", onInput],\n [\"keydown\", onInput],\n ] as const;\n\n const options = { capture: true, passive: true };\n\n const stop = () => {\n running = false;\n observer.disconnect();\n for (const [type, listener] of listeners) document.removeEventListener(type, listener, options);\n seeing.clear();\n kept.clear();\n kept.forgotten();\n inputs.length = 0;\n focused = new WeakMap();\n };\n\n const observer = new MutationObserver((records) => {\n const at = epoch();\n\n if (at - lastRead > 120_000) stop();\n else marking.mark(records, at);\n });\n\n const begin = () => {\n if (!running || kept.begun()) return;\n observer.observe(document, {\n subtree: true,\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributeFilter: [\"hidden\", \"open\", \"aria-hidden\", \"class\", \"style\"],\n attributeOldValue: true,\n });\n for (const [type, listener] of listeners) document.addEventListener(type, listener, options);\n marking.reset();\n for (const element of Array.from(document.querySelectorAll(declared)).slice(0, 64))\n seeing.glance(element, true);\n kept.begin(epoch());\n };\n\n return {\n /** Record from now, once the document is parsed; each read keeps the record going. */\n start: () => {\n lastRead = epoch();\n if (running) return;\n running = true;\n if (document.readyState === \"loading\")\n document.addEventListener(\"DOMContentLoaded\", begin, { once: true });\n else begin();\n },\n inputs: (): ReadonlyArray<{ readonly at: number; readonly target: Element }> => inputs,\n };\n};\n\nexport type Recorder = ReturnType<typeof record>;\n","/**\n * In the page: whether what the recorder marked was in view, and what it showed, judged as the page\n * renders it. An IntersectionObserver watches each element the record follows: it reports as the\n * page renders, forces no layout, and leaves a removed element the state it last reported. What\n * changed counts as seen when it was in the viewport and its style showed it; what went counts as\n * seen when it was in view before it went. Words that need the page's layout are read on render\n * too, as `text` reads an element, by the walk's one rule for what shows and with fields masked.\n * An element whose state alone the record wants, as for a class change on something it does not\n * follow, is looked at once. See `names.inpage.ts` for what a page-side part may use.\n */\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport type { Texts } from \"../reading/text.inpage.ts\";\nimport type { Walk } from \"../reading/walk.inpage.ts\";\nimport type { Sample, Shown } from \"./fold.inpage.ts\";\nimport type { History } from \"./history.inpage.ts\";\n\nexport const sight = (names: Names, walked: Walk, texts: Texts, kept: History) => {\n const { clean } = names;\n const { visible } = walked;\n // Whether each watched element was in view as the page last rendered it, and whether the style\n // of one looked at once showed it.\n let viewed = new WeakMap<Element, boolean>();\n let watching = new WeakSet<Element>();\n let states = new WeakMap<Element, boolean>();\n const waiting = new Map<Element, Array<Sample>>();\n\n /** What an element shows: its words, if its style shows it. */\n const shownBy = (element: Element): Shown =>\n element.isConnected && visible(element)\n ? clean(texts.lines(element, false), 200) || null\n : null;\n\n /** Settle what waited on an element; its words are read once, if one of them needs them. */\n const judge = (element: Element, pending: ReadonlyArray<Sample>, seen: boolean, was: boolean) => {\n const shown = pending.some((sample) => sample.shown === undefined)\n ? shownBy(element)\n : undefined;\n\n for (const sample of pending) {\n const now = sample.shown === undefined ? shown : sample.shown;\n\n kept.settle(element, sample, now, now === null ? was : seen);\n }\n };\n\n const observer = new IntersectionObserver((entries) => {\n for (const { target, isIntersecting } of entries) {\n const was = viewed.get(target) ?? false;\n const seen = isIntersecting && visible(target);\n const pending = waiting.get(target);\n\n viewed.set(target, seen);\n waiting.delete(target);\n if (pending !== undefined) judge(target, pending, seen, was);\n if (!kept.has(target)) {\n states.set(target, visible(target));\n unwatch(target);\n }\n }\n });\n\n /** Watch an element, asking for a fresh report even if it is watched already. */\n const watch = (element: Element) => {\n watching.add(element);\n observer.unobserve(element);\n observer.observe(element);\n };\n\n const unwatch = (element: Element) => {\n watching.delete(element);\n observer.unobserve(element);\n };\n\n return {\n /** Judge a sample at once if what it shows and whether it is in view are known, else on render. */\n look: (element: Element, sample: Sample) => {\n const view = viewed.get(element);\n\n if (sample.shown !== undefined && view !== undefined && watching.has(element)) {\n sample.seen = view;\n\n return;\n }\n waiting.set(element, [...(waiting.get(element) ?? []), sample]);\n watch(element);\n },\n /**\n * Look at an element once, for its state when it next changes: as it renders, or `now`, by its\n * style, as for the few the record looks at as it starts.\n */\n glance: (element: Element, now = false) => {\n if (now) states.set(element, visible(element));\n if (!watching.has(element)) watch(element);\n },\n /** Whether the style of an element looked at once showed it, if it was. */\n state: (element: Element): boolean | undefined => states.get(element),\n /** Whether a watched element was in view as the page last rendered it. */\n viewed: (element: Element): boolean => viewed.get(element) ?? false,\n unwatch,\n /** Judge now what the page has not rendered since it changed, as a hidden tab never does. */\n settle: () => {\n for (const [element, pending] of waiting) {\n const seen =\n element.isConnected && walked.inView(element.getBoundingClientRect()) && visible(element);\n\n judge(element, pending, seen, viewed.get(element) ?? false);\n viewed.set(element, seen);\n }\n waiting.clear();\n for (const key of kept.forgotten()) if (key instanceof Element) unwatch(key);\n },\n clear: () => {\n observer.disconnect();\n waiting.clear();\n viewed = new WeakMap();\n watching = new WeakSet();\n states = new WeakMap();\n },\n };\n};\n\nexport type Sight = ReturnType<typeof sight>;\n","/**\n * The bridge to the page script, and the page's documents as its own session sees them commit and\n * load, so a load follows its commit. At the library's first read of a page, its own protocol\n * session registers the script, so every later document runs it in an isolated world from its\n * start; calls go to the current document's world. The script is composed from the domains'\n * page-side parts, the `*.inpage.ts` modules, in the order they depend on one another. At the first\n * read of a page's changes, its session registers the recorder too, so every later document\n * records from its start.\n */\nimport { Effect, Schema, SynchronizedRef } from \"effect\";\n\nimport { type BrowserError, Failed } from \"../../BrowserError.ts\";\nimport { Navigated, PageLoaded } from \"../../BrowserEvent.ts\";\nimport { edit, type Edit } from \"../input/edit.inpage.ts\";\nimport { evidence } from \"../input/evidence.inpage.ts\";\nimport { guard, type Guard } from \"../input/guard.inpage.ts\";\nimport { targets, type Targets } from \"../input/targets.inpage.ts\";\nimport { context } from \"../reading/context.inpage.ts\";\nimport { controls, type Controls } from \"../reading/controls.inpage.ts\";\nimport { expectations, type Expectations } from \"../reading/expect.inpage.ts\";\nimport { match } from \"../reading/match.inpage.ts\";\nimport { names } from \"../reading/names.inpage.ts\";\nimport { outline, type Outline } from \"../reading/outline.inpage.ts\";\nimport { ready } from \"../reading/ready.inpage.ts\";\nimport { subjects, type Subjects } from \"../reading/subjects.inpage.ts\";\nimport { text, type Texts } from \"../reading/text.inpage.ts\";\nimport { walk } from \"../reading/walk.inpage.ts\";\nimport { changes, type Changes } from \"../timeline/changes.inpage.ts\";\nimport { fold } from \"../timeline/fold.inpage.ts\";\nimport { history } from \"../timeline/history.inpage.ts\";\nimport { marks } from \"../timeline/marks.inpage.ts\";\nimport { record, type Recorder } from \"../timeline/record.inpage.ts\";\nimport { sight } from \"../timeline/sight.inpage.ts\";\nimport { contextGone, failWith, type PageContext, undispatched } from \"./context.ts\";\nimport * as Url from \"./url.ts\";\n\n/** What the script installs: a version, and a function of one of its parts for each call. */\nexport interface PageApi {\n readonly version: number;\n snapshot: Outline[\"snapshot\"];\n find: Subjects[\"find\"];\n until: Expectations[\"until\"];\n waitUntil: Controls[\"waitUntil\"];\n text: Texts[\"read\"];\n record: Recorder[\"start\"];\n changes: Changes[\"read\"];\n ready: ReturnType<typeof ready>[\"wait\"];\n settle: ReturnType<typeof ready>[\"settle\"];\n point: Targets[\"point\"];\n scrollPlan: Targets[\"scrollPlan\"];\n viewport: Outline[\"viewport\"];\n /** The screen as the page reads it, which another session may emulate. */\n screenSize: () => { readonly width: number; readonly height: number };\n prepareInput: Guard[\"prepareInput\"];\n validateInput: Guard[\"validateInput\"];\n typeable: Edit[\"typeable\"];\n focus: Edit[\"focus\"];\n focusOn: Edit[\"focusOn\"];\n select: Edit[\"select\"];\n}\n\ndeclare global {\n // The API this script installs, which exists only inside the library's isolated world.\n var __effectBrowser: PageApi | undefined;\n}\n\n// Like the parts it receives, this is evaluated from its source text.\nconst install = (\n makeNames: typeof names,\n makeWalk: typeof walk,\n makeMatch: typeof match,\n makeContext: typeof context,\n makeSubjects: typeof subjects,\n makeExpectations: typeof expectations,\n makeText: typeof text,\n makeControls: typeof controls,\n makeFold: typeof fold,\n makeHistory: typeof history,\n makeSight: typeof sight,\n makeMarks: typeof marks,\n makeRecord: typeof record,\n makeChanges: typeof changes,\n makeReady: typeof ready,\n makeOutline: typeof outline,\n makeTargets: typeof targets,\n makeEvidence: typeof evidence,\n makeGuard: typeof guard,\n makeEdit: typeof edit,\n makeAddresses: typeof Url.addresses,\n): PageApi => {\n const installed = globalThis.__effectBrowser;\n\n if (installed !== undefined && installed.version === 18) return installed;\n const named = makeNames();\n const walked = makeWalk(named);\n const placing = makeContext(named, walked);\n const subjected = makeSubjects(named, walked, makeMatch(), placing);\n const texts = makeText(named, walked);\n const controlled = makeControls(named, walked, subjected, texts);\n const kept = makeHistory(makeFold());\n const seeing = makeSight(named, walked, texts, kept);\n const marking = makeMarks(named, kept, seeing);\n const recorder = makeRecord(named, texts, kept, seeing, marking);\n const read = makeOutline(named, walked, subjected, texts, controlled, makeAddresses());\n const located = makeTargets(named, walked, placing);\n const guarded = makeGuard(named, located, makeEvidence(named, placing));\n const edited = makeEdit(named, guarded, placing);\n const readiness = makeReady(walked, texts, kept);\n\n const api: PageApi = {\n version: 18,\n snapshot: read.snapshot,\n find: subjected.find,\n until: makeExpectations(named, subjected).until,\n waitUntil: controlled.waitUntil,\n text: texts.read,\n record: recorder.start,\n changes: makeChanges(named, placing, kept, seeing, marking, recorder).read,\n ready: readiness.wait,\n settle: readiness.settle,\n point: located.point,\n scrollPlan: located.scrollPlan,\n viewport: read.viewport,\n screenSize: () => ({ width: screen.width, height: screen.height }),\n prepareInput: guarded.prepareInput,\n validateInput: guarded.validateInput,\n typeable: edited.typeable,\n focus: edited.focus,\n focusOn: edited.focusOn,\n select: edited.select,\n };\n\n globalThis.__effectBrowser = api;\n\n return api;\n};\n\n/** The expression that installs the script and evaluates to its API. */\nexport const installSource = `(${install.toString()})(${[names, walk, match, context, subjects, expectations, text, controls, fold, history, sight, marks, record, changes, ready, outline, targets, evidence, guard, edit, Url.addresses].join(\", \")})`;\n\nconst worldName = \"effect-browser\";\n\n// What starts the recorder in each new document, after the script installed itself there.\nconst recorderSource = `if (globalThis === globalThis.top) globalThis.__effectBrowser?.record();`;\n\n// What a call reads in a world without the script's API. A context id can name another world once\n// the page has moved to a new process, so a cached id that reads this is not the library's world.\nconst missing = \"effect-browser: no __effectBrowser in this world\";\n\nconst isMissing = (error: BrowserError) =>\n error.reason._tag === \"Failed\" && error.reason.detail === missing;\n\n/** A frame as a page session reports its commit. */\nexport const Commit = Schema.Struct({\n parentId: Schema.optionalKey(Schema.String),\n loaderId: Schema.String,\n url: Schema.String,\n urlFragment: Schema.optionalKey(Schema.String),\n});\n\n/** `Page.frameNavigated` or `Page.navigatedWithinDocument`, as far as `mainFrame` reads them. */\nexport const MainFrameEvent = Schema.Union([\n Schema.Struct({ frame: Commit }),\n Schema.Struct({ frameId: Schema.String, url: Schema.String }),\n]);\n\n/** A commit's loader and its address, redacted. */\nexport const commitOf = ({ loaderId, url, urlFragment = \"\" }: typeof Commit.Type) => ({\n loader: loaderId,\n url: Url.redact(url + urlFragment),\n});\n\n/**\n * What a page session's commit or move says of `page`'s main frame: a new document's `loader` and\n * its address, or a move's address; nothing for another frame. Only a commit is a new document:\n * `frameStartedLoading` also fires on `pushState`, a move within the document.\n */\nexport const mainFrame = (page: string, event: typeof MainFrameEvent.Type) =>\n \"frame\" in event\n ? event.frame.parentId === undefined\n ? commitOf(event.frame)\n : undefined\n : event.frameId === page\n ? { loader: undefined, url: Url.redact(event.url) }\n : undefined;\n\n/** A call to the page script, its arguments quoted as JavaScript literals. */\nexport const scriptCall = (name: string, ...args: ReadonlyArray<unknown>): string =>\n `${name}(${args.map((arg) => JSON.stringify(arg)).join(\", \")})`;\n\nexport const make = Effect.fnUntraced(function* (page: PageContext) {\n const { id, cdp, native, span, publish, now } = page;\n const { send } = page.protocol;\n // How far this session has registered: the script, then the recorder, which the first read of\n // changes asks for. One caller takes each step, once, while the others wait.\n const registration = yield* SynchronizedRef.make<\"none\" | \"script\" | \"recorder\">(\"none\");\n // The current document's world, forgotten when the main frame commits another document; the\n // commits this session has seen, the latest marked on the page; the page's address; and how far\n // the current document has loaded.\n let world: number | undefined;\n let documents = 0;\n let url = Url.redact(page.url);\n let loaded: PageLoaded | undefined;\n // The latest commits' loaders and the documents they began, newest last: a capture connection\n // sees the same commits, and numbers its frames by them.\n const loaders = new Map<string, number>();\n\n const onMainFrame = (event: typeof MainFrameEvent.Type) => {\n const seen = mainFrame(id, event);\n\n if (seen === undefined) return;\n if (seen.loader !== undefined) {\n documents++;\n loaders.delete(seen.loader);\n loaders.set(seen.loader, documents);\n const [oldest] = loaders.keys();\n\n if (loaders.size > 8 && oldest !== undefined) loaders.delete(oldest);\n page.activity.documentAt = now();\n world = undefined;\n loaded = undefined;\n }\n url = seen.url;\n const sameDocument = seen.loader === undefined;\n\n publish(new Navigated({ at: now(), page: id, url, document: documents, sameDocument }));\n };\n\n // The session tells these of the main frame alone.\n const onLoaded = (state: PageLoaded[\"state\"]) => () => {\n loaded = new PageLoaded({ at: now(), page: id, state });\n publish(loaded);\n };\n\n cdp.on(\"Page.frameNavigated\", onMainFrame);\n cdp.on(\"Page.navigatedWithinDocument\", onMainFrame);\n cdp.on(\"Page.domContentEventFired\", onLoaded(\"domcontentloaded\"));\n cdp.on(\"Page.loadEventFired\", onLoaded(\"load\"));\n\n /**\n * The main-frame commits seen so far, once the Page domain, which registration turned on, has\n * answered, so that every later one counts. A commit within about one round trip of the count\n * can still be missed.\n */\n const currentDocument = (operation: string) =>\n page.paging(operation).pipe(Effect.map(() => documents));\n\n /** What a frame that arrives now shows: its session, the page's current document and address. */\n const frameTag = () => ({ session: page.session, document: documents, url });\n\n /** The document the main frame's latest commit of `loader` began, if this session counted it. */\n const documentOf = (loader: string) => loaders.get(loader);\n\n // The registration belongs to this session and the world to the page, so a session that attaches\n // later, as after a reconnect, registers again and finds the script already installed. With the\n // Page domain enabled, a source runs in each new document, in the order registered;\n // `runImmediately` runs it now.\n const addScript = (operation: string, source: string) =>\n native(operation, () =>\n send(\"Page.addScriptToEvaluateOnNewDocument\", { source, worldName, runImmediately: true }),\n );\n\n const register = (operation: string) =>\n Effect.all(\n [\n page.paging(operation),\n addScript(operation, `if (globalThis === globalThis.top) ${installSource};`),\n ],\n { concurrency: \"unbounded\" },\n ).pipe(span(\"Page.register\", {}, \"Debug\"));\n\n /** Take registration from `from` to `to` by `step`, unless it is past `from` already. */\n const advance = (\n from: \"none\" | \"script\",\n to: \"script\" | \"recorder\",\n step: Effect.Effect<unknown, BrowserError>,\n ) =>\n SynchronizedRef.updateEffect(registration, (state) =>\n state === from ? Effect.as(step, to) : Effect.succeed(state),\n );\n\n /** Register the script once, and the recorder after it once a read of changes asks for it. */\n const ensure = (operation: string, recorder: boolean) =>\n Effect.andThen(\n advance(\"none\", \"script\", register(operation)),\n recorder ? advance(\"script\", \"recorder\", addScript(operation, recorderSource)) : Effect.void,\n );\n\n const createWorld = (operation: string) =>\n Effect.gen(function* () {\n yield* ensure(operation, false);\n const document = documents;\n\n // The main frame's id is the page's target id.\n const created = yield* native(operation, () =>\n send(\"Page.createIsolatedWorld\", { frameId: id, worldName }),\n );\n\n // A world the page replaced while it was being looked up serves this call, not later ones.\n if (document === documents) world = created.executionContextId;\n\n return created.executionContextId;\n }).pipe(span(\"Page.createWorld\", {}, \"Debug\"));\n\n /** The current document's world, created if it has none yet. */\n const current = (operation: string) =>\n Effect.suspend(() => (world === undefined ? createWorld(operation) : Effect.succeed(world)));\n\n /** A world of the current document without the page script, as the clock probe needs. */\n const bareWorld = (operation: string) =>\n native(operation, () =>\n send(\"Page.createIsolatedWorld\", { frameId: id, worldName: `${worldName}-clock` }),\n ).pipe(Effect.map((created) => created.executionContextId));\n\n const run = (operation: string, expression: string, contextId: number) =>\n native(operation, () =>\n send(\"Runtime.evaluate\", { contextId, expression, returnByValue: true, awaitPromise: true }),\n ).pipe(\n Effect.flatMap(({ result, exceptionDetails: thrown }) =>\n thrown === undefined\n ? Effect.succeed<unknown>(result.value)\n : failWith(\n operation,\n new Failed({ detail: thrown.exception?.description ?? thrown.text }),\n ),\n ),\n );\n\n const evaluateIn = (operation: string, call: string, contextId: number) =>\n run(\n operation,\n `globalThis.__effectBrowser === undefined ? ${JSON.stringify(missing)} : globalThis.__effectBrowser.${call}`,\n contextId,\n ).pipe(\n Effect.filterOrFail(\n (value) => value !== missing,\n () => undispatched(operation, new Failed({ detail: missing })),\n ),\n // One round trip to the page. Its arguments can hold typed text, so only the call is named.\n span(\"Page.evaluate\", { function: call.split(\"(\")[0] }, \"Trace\"),\n );\n\n // Ordinary reads can recreate a document's world. Approval validation deliberately cannot. A\n // world found by its name that lacks the script, in a document the registration missed, gets it.\n const evaluateWithContext = (operation: string, call: string) => {\n const attempt = (contextId: number) =>\n evaluateIn(operation, call, contextId).pipe(Effect.map((value) => ({ contextId, value })));\n\n const again = createWorld(operation).pipe(\n Effect.flatMap((contextId) =>\n attempt(contextId).pipe(\n Effect.catchIf(isMissing, () =>\n run(operation, `${installSource}.version`, contextId).pipe(\n Effect.andThen(attempt(contextId)),\n ),\n ),\n ),\n ),\n );\n\n return current(operation).pipe(\n Effect.flatMap(attempt),\n Effect.catchIf(contextGone, () => again),\n );\n };\n\n const evaluate = (operation: string, call: string) =>\n evaluateWithContext(operation, call).pipe(Effect.map(({ value }) => value));\n\n return {\n current,\n bareWorld,\n evaluate,\n evaluateIn,\n evaluateWithContext,\n currentDocument,\n frameTag,\n documentOf,\n /** How far the current document has loaded, as this session heard; nothing until parsed. */\n loaded: () => loaded,\n /** Register the recorder, so every later document records from its start. */\n registerRecorder: (operation: string) => ensure(operation, true),\n };\n});\n\nexport type Bridge = Effect.Success<ReturnType<typeof make>>;\n","/**\n * The browser's clock read on the owner's: estimates of their offset from timed probes, how an\n * estimate ages, and the one mapping a browser's pages share. `pictures.ts` takes the probes.\n */\nimport { Duration, Effect, Option } from \"effect\";\n\nexport interface Probe {\n readonly hostStart: number;\n readonly hostEnd: number;\n readonly browserTime: number;\n}\n\nexport interface Estimate {\n /** Browser epoch milliseconds minus the owner's host monotonic milliseconds. */\n readonly offsetMillis: number;\n /** Either transport direction can own the entire round trip; symmetry is not assumed. */\n readonly uncertaintyMillis: number;\n readonly roundTripMillis: number;\n readonly sampledAt: number;\n}\n\n/** The fastest complete probe limits uncertainty without mistaking transit delay for clock offset. */\nexport const estimate = (probes: ReadonlyArray<Probe>): Option.Option<Estimate> => {\n let best: Estimate | undefined;\n\n for (const probe of probes) {\n const roundTripMillis = probe.hostEnd - probe.hostStart;\n\n if (\n !Number.isFinite(probe.hostStart) ||\n !Number.isFinite(probe.hostEnd) ||\n !Number.isFinite(probe.browserTime) ||\n !Number.isFinite(roundTripMillis) ||\n roundTripMillis < 0\n )\n continue;\n const sampledAt = probe.hostStart + roundTripMillis / 2;\n const offsetMillis = probe.browserTime - sampledAt;\n\n if (\n !Number.isFinite(offsetMillis) ||\n !Number.isFinite(probe.browserTime - probe.hostStart) ||\n !Number.isFinite(probe.browserTime - probe.hostEnd)\n )\n continue;\n if (best === undefined || roundTripMillis < best.roundTripMillis)\n best = {\n offsetMillis,\n uncertaintyMillis: roundTripMillis / 2,\n roundTripMillis,\n sampledAt,\n };\n }\n\n return Option.fromUndefinedOr(best);\n};\n\n// Two machines' clocks drift apart by up to about 100 parts per million, so an estimate says this\n// much less about the offset for each millisecond of its age.\nconst driftPerMillis = 1e-4;\n\n/** An estimate's uncertainty at `hostTime`, wider the further that is from when it was sampled. */\nexport const uncertaintyAt = (estimate: Estimate, hostTime: number): number =>\n estimate.uncertaintyMillis + Math.abs(hostTime - estimate.sampledAt) * driftPerMillis;\n\n// Ten seconds widen an estimate by a millisecond, far less than a remote round trip, so it is\n// measured again no more often than this.\nconst renewAfter = Duration.seconds(10);\n\n/**\n * The browser's one epoch mapping, shared by its pages, input runs and capture generations. It is\n * measured on first need, by the first capture, never ahead of it.\n */\nexport interface Mapping {\n /** The latest estimate, without measuring: input uses it, and never waits for one. */\n readonly latest: () => Estimate | undefined;\n /** The latest estimate, measured through `measure` only while the browser has none. */\n readonly current: <E>(measure: Effect.Effect<Estimate, E>) => Effect.Effect<Estimate, E>;\n /**\n * Measure again once ten seconds have passed since the latest measurement began. A failed\n * measurement keeps the estimate, which keeps widening with its age.\n */\n readonly renew: <E>(measure: Effect.Effect<Estimate, E>) => Effect.Effect<void>;\n}\n\n/**\n * Whether a new measurement should replace the current estimate. Each interval contains the true\n * offset, so overlapping intervals agree and the narrower one is kept, the current one widened by\n * its age: a probe delayed behind a busy page cannot widen every tab's stamps. A disjoint\n * measurement means the clocks moved (a wall clock step, or drift between a remote browser and\n * this host), so the newer evidence wins.\n */\nexport const supersedes = (next: Estimate, current: Estimate): boolean => {\n const aged = uncertaintyAt(current, next.sampledAt);\n\n return (\n next.uncertaintyMillis <= aged ||\n Math.abs(next.offsetMillis - current.offsetMillis) > next.uncertaintyMillis + aged\n );\n};\n\n/**\n * Every renderer of a browser reads the same host wall clock, so the offset belongs to the\n * browser rather than a page. A busy page cannot fail work that an earlier estimate can serve.\n */\nexport const mapping = (now: () => number): Mapping => {\n let latest: Estimate | undefined;\n let measuredAt = Number.NEGATIVE_INFINITY;\n\n // Called where a measurement is decided, so no other can be decided before this one begins.\n const adopt = <E>(measure: Effect.Effect<Estimate, E>) => {\n measuredAt = now();\n\n return measure.pipe(\n Effect.map((estimate) => {\n if (latest === undefined || supersedes(estimate, latest)) latest = estimate;\n\n return latest;\n }),\n );\n };\n\n return {\n latest: () => latest,\n current: (measure) =>\n Effect.suspend(() => (latest === undefined ? adopt(measure) : Effect.succeed(latest))),\n renew: (measure) =>\n Effect.suspend(() =>\n latest === undefined || now() - measuredAt < Duration.toMillis(renewAfter)\n ? Effect.void\n : Effect.ignore(adopt(measure)),\n ),\n };\n};\n\nexport const toHostTime = (calibration: Estimate, browserEpochMillis: number): number =>\n browserEpochMillis - calibration.offsetMillis;\n\n/** CDP input timestamps use seconds, unlike browser frame timestamps and the owner's clock. */\nexport const toBrowserSeconds = (calibration: Estimate, hostMillis: number): number =>\n (hostMillis + calibration.offsetMillis) / 1000;\n","/**\n * Sending input to the browser. Each mouse event, key and inserted text goes out on the page's\n * protocol session, stamped with the browser's clock when its run has a mapping, and is published\n * as it is submitted.\n */\nimport { Effect, MutableRef, Option } from \"effect\";\n\nimport {\n KeyChanged,\n PointerPressed,\n PointerReleased,\n TextInserted,\n WheelScrolled,\n} from \"../../BrowserEvent.ts\";\nimport { type PageContext, reasonOf, undispatched } from \"../page/context.ts\";\nimport * as BrowserClock from \"../pictures/clock.ts\";\nimport type * as Replies from \"./replies.ts\";\n\nexport type MouseEvent = {\n readonly type: \"mouseMoved\" | \"mousePressed\" | \"mouseReleased\" | \"mouseWheel\";\n readonly x: number;\n readonly y: number;\n readonly button?: \"none\" | \"left\" | \"right\" | \"middle\";\n readonly buttons?: number;\n readonly clickCount?: number;\n readonly deltaX?: number;\n readonly deltaY?: number;\n};\n\nexport const make = (page: PageContext) => {\n const { id, pointer, publish, now, noteInput, closedBy } = page;\n const { send } = page.protocol;\n // Each run's clock mapping, recorded when it begins.\n const inputClocks = new WeakMap<Replies.Run, BrowserClock.Estimate>();\n\n // Every run records its mapping when it begins; a missing one leaves Chromium's own receipt time.\n const stamp = (estimate: BrowserClock.Estimate | undefined, at: number) =>\n estimate === undefined ? {} : { timestamp: BrowserClock.toBrowserSeconds(estimate, at) };\n\n const inputCall = <A>(operation: string, effect: Effect.Effect<A, Replies.InputFailure>) =>\n effect.pipe(\n Effect.mapError((error) =>\n undispatched(operation, reasonOf(error.cause, undefined, closedBy())),\n ),\n );\n\n const dispatchMouse = (\n event: MouseEvent,\n estimate: BrowserClock.Estimate | undefined,\n submitted?: () => void,\n ): Promise<unknown> => {\n const at = now();\n const point = { x: event.x, y: event.y };\n const button = event.button ?? \"left\";\n\n // Construct boundary data before dispatch: validation must never abandon the native reply.\n const ButtonEvent = event.type === \"mousePressed\" ? PointerPressed : PointerReleased;\n\n const track =\n (event.type === \"mousePressed\" || event.type === \"mouseReleased\") && button !== \"none\"\n ? new ButtonEvent({ at, page: id, ...point, button, clickCount: event.clickCount ?? 1 })\n : event.type === \"mouseWheel\"\n ? new WheelScrolled({\n at,\n page: id,\n ...point,\n dx: event.deltaX ?? 0,\n dy: event.deltaY ?? 0,\n })\n : undefined;\n\n const response = send(\"Input.dispatchMouseEvent\", { ...event, ...stamp(estimate, at) });\n\n noteInput();\n if (event.type === \"mouseMoved\") MutableRef.set(pointer, Option.some(point));\n if (track !== undefined) publish(track);\n submitted?.();\n\n return response;\n };\n\n const sendMouse = (\n operation: string,\n run: Replies.Run,\n event: MouseEvent,\n submitted?: () => void,\n ) =>\n inputCall(\n operation,\n Effect.gen(function* () {\n const held = `mouse:${event.button ?? \"left\"}`;\n const estimate = inputClocks.get(run);\n\n if (event.type === \"mouseReleased\") return yield* run.up(held);\n if (event.type === \"mousePressed\") {\n yield* run.reserve(2);\n yield* run.down(\n held,\n () => dispatchMouse(event, estimate, submitted),\n () =>\n dispatchMouse(\n {\n type: \"mouseReleased\",\n ...Option.getOrElse(MutableRef.get(pointer), () => ({ x: event.x, y: event.y })),\n button: event.button ?? \"left\",\n buttons: 0,\n clickCount: event.clickCount ?? 1,\n },\n estimate,\n ),\n );\n } else {\n yield* run.reserve(1);\n yield* run.send(() => dispatchMouse(event, estimate, submitted));\n }\n }),\n );\n\n // Keys and text bound for a secret field are recorded without their content.\n const dispatchKey = (\n key: string,\n phase: \"down\" | \"up\",\n command: (at: number, estimate: BrowserClock.Estimate | undefined) => Promise<unknown>,\n run: Replies.Run,\n secret = false,\n ) => {\n const at = now();\n const event = new KeyChanged({ at, page: id, key: secret ? \"Unidentified\" : key, phase });\n const response = command(at, inputClocks.get(run));\n\n noteInput();\n publish(event);\n\n return response;\n };\n\n const dispatchText = (text: string, secret: boolean): Promise<unknown> => {\n const track = new TextInserted({ at: now(), page: id, text: secret ? \"•\" : text });\n const response = send(\"Input.insertText\", { text });\n\n noteInput();\n publish(track);\n\n return response;\n };\n\n const flush = (operation: string, run: Replies.Run) => inputCall(operation, run.drain);\n\n return {\n inputClocks,\n stamp,\n inputCall,\n dispatchMouse,\n sendMouse,\n dispatchKey,\n dispatchText,\n flush,\n };\n};\n\nexport type Dispatch = ReturnType<typeof make>;\n","/**\n * The input guard's host side. It asks the page what an action would touch, builds the request a\n * policy decides on, binds an approval to the document and targets it saw, and runs the page\n * script's changes in the approved document only.\n */\nimport { Effect } from \"effect\";\n\nimport { type BrowserError, InvalidRequest, NotActionable, StaleRef } from \"../../BrowserError.ts\";\nimport { InputRequest, redacted } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { contextGone, decodeWith, failWith, type PageContext } from \"../page/context.ts\";\nimport * as Url from \"../page/url.ts\";\nimport * as Script from \"./guard.inpage.ts\";\n\nexport interface Approval {\n readonly contextId: number;\n readonly check: (options?: Script.ValidationOptions) => Effect.Effect<void, BrowserError>;\n}\n\nexport interface PolicyPlan {\n readonly request: InputRequest;\n readonly validate: Effect.Effect<Approval, BrowserError>;\n}\n\n// A ref that names nothing is stale on every path, named by the target that failed.\nexport const inputFailure = (\n operation: string,\n targets: Script.InputPlan[\"targets\"],\n failure: Script.InputFailure,\n) => {\n const target = failure.index === undefined ? undefined : targets[failure.index];\n\n return failWith(\n operation,\n failure.error === \"outside\"\n ? new InvalidRequest({ detail: failure.detail })\n : failure.error === \"stale\" && typeof target === \"string\"\n ? new StaleRef({ ref: target })\n : new NotActionable({ detail: failure.detail }),\n );\n};\n\nexport const editFailure = (\n operation: string,\n ref: string,\n failure: { readonly error: string; readonly stale?: boolean | undefined },\n) =>\n failWith(\n operation,\n failure.stale === true ? new StaleRef({ ref }) : new NotActionable({ detail: failure.error }),\n );\n\nexport const make = (page: PageContext, bridge: Bridge) => {\n const { id } = page;\n const { current, evaluateIn, evaluateWithContext } = bridge;\n\n const preparePolicy = (\n action: string,\n info: { readonly target?: string | undefined; readonly text?: string | undefined },\n targets: Script.InputPlan[\"targets\"],\n flags: {\n readonly submit?: boolean;\n readonly keys?: string;\n readonly destination?: string;\n } = {},\n ): Effect.Effect<PolicyPlan, BrowserError> =>\n Effect.gen(function* () {\n for (const target of targets) {\n if (typeof target === \"string\" && !/^e\\d+$/.test(target))\n return yield* failWith(\n action,\n new InvalidRequest({ detail: `\"${target}\" is not a ref; refs look like e12` }),\n );\n if (\n target !== null &&\n typeof target !== \"string\" &&\n (!Number.isFinite(target.x) || !Number.isFinite(target.y))\n )\n return yield* failWith(\n action,\n new InvalidRequest({ detail: \"point coordinates must be finite\" }),\n );\n }\n\n const input: Script.InputPlan = {\n action,\n targets,\n submit: flags.submit ?? false,\n keys: flags.keys ?? null,\n destination: flags.destination ?? null,\n };\n\n const { contextId, value } = yield* evaluateWithContext(\n action,\n scriptCall(\"prepareInput\", input),\n );\n\n const prepared = yield* decodeWith(action, Script.PreparedInputResultSchema)(value);\n\n if (\"error\" in prepared) return yield* inputFailure(action, targets, prepared);\n const first = prepared.targets[0];\n const target = targets[0];\n const { title, description, dialog, heading, nearby, form } = prepared.evidence;\n\n // A guard may hand the request to a judge's model, so its addresses keep no secrets.\n const request = new InputRequest({\n page: id,\n url: Url.redact(prepared.url),\n title,\n action,\n target: info.target,\n text:\n info.text !== undefined && action === \"type\" && first?.secret === true\n ? redacted\n : info.text,\n element: first?.element,\n role: first?.role,\n name: first?.name,\n description,\n href: first?.href === undefined ? undefined : Url.redact(first.href),\n point: target !== null && typeof target === \"object\" ? target : undefined,\n destination:\n prepared.destination === undefined ? undefined : Url.redact(prepared.destination),\n facts: prepared.facts,\n context: { dialog, heading, nearby },\n form,\n });\n\n const check = (options: Script.ValidationOptions = {}) =>\n evaluateIn(action, scriptCall(\"validateInput\", input, prepared, options), contextId).pipe(\n Effect.catchIf(contextGone, () =>\n failWith(\n action,\n new NotActionable({ detail: \"the page changed while input policy was pending\" }),\n ),\n ),\n Effect.flatMap(decodeWith(action, Script.ValidatedInputResultSchema)),\n Effect.flatMap((result) =>\n \"error\" in result ? inputFailure(action, targets, result) : Effect.void,\n ),\n );\n\n const validate = check().pipe(\n Effect.as<Approval>({\n contextId,\n check,\n }),\n );\n\n return { request, validate };\n });\n\n // `mayHaveRun` hears of a failure the script may have started before: without its context or\n // the library's API in it, the call never ran.\n const mutate = (\n operation: string,\n call: string,\n approval: Approval | undefined,\n mayHaveRun: Effect.Effect<void> = Effect.void,\n ) =>\n (approval === undefined ? current(operation) : Effect.succeed(approval.contextId)).pipe(\n Effect.flatMap((contextId) =>\n evaluateIn(operation, call, contextId).pipe(\n Effect.tapError((error) =>\n error.reason._tag === \"Failed\" &&\n /Cannot find context|__effectBrowser/i.test(error.reason.detail)\n ? Effect.void\n : mayHaveRun,\n ),\n ),\n ),\n Effect.catchIf(contextGone, () =>\n failWith(\n operation,\n new NotActionable({ detail: \"the page changed before the approved input could run\" }),\n ),\n ),\n );\n\n return { preparePolicy, mutate };\n};\n\nexport type Guard = ReturnType<typeof make>;\n","/**\n * Key aliases for Playwright and printable US key descriptions for pipelined Chromium typing.\n */\n\nconst aliases: Record<string, string> = {\n ctrl: \"Control\",\n control: \"Control\",\n cmd: \"Meta\",\n command: \"Meta\",\n meta: \"Meta\",\n win: \"Meta\",\n super: \"Meta\",\n mod: \"ControlOrMeta\",\n alt: \"Alt\",\n option: \"Alt\",\n shift: \"Shift\",\n enter: \"Enter\",\n return: \"Enter\",\n esc: \"Escape\",\n escape: \"Escape\",\n tab: \"Tab\",\n space: \"Space\",\n spacebar: \"Space\",\n \" \": \"Space\",\n backspace: \"Backspace\",\n delete: \"Delete\",\n del: \"Delete\",\n insert: \"Insert\",\n home: \"Home\",\n end: \"End\",\n pageup: \"PageUp\",\n pagedown: \"PageDown\",\n up: \"ArrowUp\",\n down: \"ArrowDown\",\n left: \"ArrowLeft\",\n right: \"ArrowRight\",\n arrowup: \"ArrowUp\",\n arrowdown: \"ArrowDown\",\n arrowleft: \"ArrowLeft\",\n arrowright: \"ArrowRight\",\n};\n\nconst named = new Set(Object.values(aliases));\n\n/** Parse and validate the whole chord before sending any down events. */\nexport const parts = (keys: string): ReadonlyArray<string> | undefined => {\n const tokens: Array<string> = [];\n let building = \"\";\n\n // Like Playwright, a plus without a preceding token is the literal plus key: Control++.\n for (const character of keys) {\n if (character === \"+\" && building.trim() !== \"\") {\n tokens.push(building);\n building = \"\";\n } else building += character;\n }\n tokens.push(building);\n if (tokens.length > 4) return undefined;\n const out: Array<string> = [];\n\n for (const token of tokens) {\n const part = token === \" \" ? \"Space\" : token.trim();\n const lower = part.toLowerCase();\n const alias = Object.hasOwn(aliases, lower) ? aliases[lower] : undefined;\n\n if (alias !== undefined) out.push(alias);\n else if (\n named.has(part) ||\n /^F([1-9]|1[0-2])$/.test(part) ||\n /^(Key[A-Z]|Digit[0-9]|Numpad[0-9])$/.test(part) ||\n description(part) !== undefined\n )\n out.push(part);\n else return undefined;\n }\n\n return out;\n};\n\ninterface Description {\n readonly code: string;\n readonly keyCode: number;\n readonly key: string;\n readonly text: string;\n}\n\nconst punctuation: ReadonlyArray<readonly [string, string, number]> = [\n [\"`~\", \"Backquote\", 192],\n [\"-_\", \"Minus\", 189],\n [\"=+\", \"Equal\", 187],\n [\"\\\\|\", \"Backslash\", 220],\n [\"[{\", \"BracketLeft\", 219],\n [\"]}\", \"BracketRight\", 221],\n [\";:\", \"Semicolon\", 186],\n [\"'\\\"\", \"Quote\", 222],\n [\",<\", \"Comma\", 188],\n [\".>\", \"Period\", 190],\n [\"/?\", \"Slash\", 191],\n [\" \", \"Space\", 32],\n];\n\n/**\n * Match Playwright's pinned US layout for literal typing. Uppercase and shifted punctuation\n * carry their literal text without synthesizing Shift. Newlines also use insertText so a text\n * payload cannot submit a form; only an explicit Enter or submit option may do that.\n */\nexport const description = (character: string): Description | undefined => {\n // Prose correction uses the same raw key path so its deletion has a matched release.\n if (character === \"Backspace\")\n return { code: \"Backspace\", keyCode: 8, key: \"Backspace\", text: \"\" };\n if (character.length !== 1) return undefined;\n if (/^[A-Za-z]$/.test(character)) {\n const upper = character.toUpperCase();\n\n return { code: `Key${upper}`, keyCode: upper.charCodeAt(0), key: character, text: character };\n }\n const digit = \"0123456789\".indexOf(character);\n const number = digit === -1 ? \")!@#$%^&*(\".indexOf(character) : digit;\n\n if (number !== -1)\n return { code: `Digit${number}`, keyCode: 48 + number, key: character, text: character };\n const symbol = punctuation.find(([characters]) => characters.includes(character));\n\n return symbol === undefined\n ? undefined\n : { code: symbol[1], keyCode: symbol[2], key: character, text: character };\n};\n","/**\n * Keys and typing: a key chord held and released, each typed event, and the document a run of\n * keys must stay in.\n */\nimport { Duration, Effect } from \"effect\";\n\nimport { NotActionable } from \"../../BrowserError.ts\";\nimport type { Bridge } from \"../page/bridge.ts\";\nimport { failWith, type PageContext } from \"../page/context.ts\";\nimport type { Dispatch } from \"./dispatch.ts\";\nimport * as Keys from \"./keys.ts\";\nimport type * as Replies from \"./replies.ts\";\n\nexport const make = (page: PageContext, bridge: Bridge, dispatch: Dispatch) => {\n const { playwright } = page;\n const { send } = page.protocol;\n const { currentDocument } = bridge;\n const { stamp, inputCall, dispatchKey, dispatchText } = dispatch;\n\n // A multi-key action stops before its next key once the page has moved to another document. The\n // page's own session counts main-frame commits as the browser reports them, so a key sent within\n // about one protocol round trip of a commit can still reach the new document.\n const sameDocument = (operation: string, since: number) =>\n currentDocument(operation).pipe(\n Effect.flatMap((now) =>\n now === since\n ? Effect.void\n : failWith(\n operation,\n new NotActionable({\n detail: \"the page moved to another document, so the remaining keys were not sent\",\n }),\n ),\n ),\n );\n\n const keyStroke = (\n operation: string,\n run: Replies.Run,\n parts: ReadonlyArray<string>,\n holdMillis = 0,\n ) =>\n Effect.gen(function* () {\n yield* inputCall(operation, run.reserve(parts.length * 2));\n for (const part of parts)\n yield* inputCall(\n operation,\n run.down(\n `playwright:${part}`,\n () => dispatchKey(part, \"down\", () => playwright.keyboard.down(part), run),\n () => dispatchKey(part, \"up\", () => playwright.keyboard.up(part), run),\n ),\n );\n if (holdMillis > 0) yield* Effect.sleep(Duration.millis(holdMillis));\n for (const part of parts.toReversed())\n yield* inputCall(operation, run.up(`playwright:${part}`));\n });\n\n const typeEvent = (\n run: Replies.Run,\n event: { readonly phase: \"down\" | \"up\" | \"insert\"; readonly key: string },\n secret: boolean,\n ) =>\n inputCall(\n \"type\",\n Effect.gen(function* () {\n if (event.phase === \"insert\") {\n yield* run.reserve(1);\n yield* run.send(() => dispatchText(event.key, secret));\n\n return;\n }\n\n const description = Keys.description(event.key);\n\n if (description === undefined) return yield* Effect.die(\"invalid planned key\");\n const { key, code, keyCode, text } = description;\n const held = \"raw:\" + code;\n\n if (event.phase === \"up\") return yield* run.up(held);\n\n // The key going down carries its text; going up, only the key.\n const keyEvent = (phase: \"down\" | \"up\") => () =>\n dispatchKey(\n key,\n phase,\n (at, estimate) =>\n send(\"Input.dispatchKeyEvent\", {\n type: phase === \"down\" ? \"keyDown\" : \"keyUp\",\n ...stamp(estimate, at),\n modifiers: 0,\n windowsVirtualKeyCode: keyCode,\n code,\n key,\n location: 0,\n ...(phase === \"down\"\n ? { commands: [], text, unmodifiedText: text, autoRepeat: false, isKeypad: false }\n : {}),\n }),\n run,\n secret,\n );\n\n yield* run.reserve(2);\n yield* run.down(held, keyEvent(\"down\"), keyEvent(\"up\"));\n }),\n );\n\n return { currentDocument, sameDocument, keyStroke, typeEvent };\n};\n\nexport type Keyboard = ReturnType<typeof make>;\n","/**\n * Bounded input replies owned by the page, including after an action is interrupted.\n * Canceling a caller cannot cancel a protocol command already sent. The next action waits for\n * those replies, while a stopped run releases only held keys or buttons whose release was never submitted.\n */\nimport { Data, Effect } from \"effect\";\n\nimport { maximumSamples } from \"../../Motion.ts\";\n\nexport const capacity = 64;\n\nexport class InputFailure extends Data.TaggedError(\"InputFailure\")<{\n readonly cause: unknown;\n}> {}\n\nexport interface Run {\n /** Reserve a complete stroke, including its releases, before sending its first event. */\n readonly reserve: (commands: number) => Effect.Effect<void, InputFailure>;\n /** Admit every sample before a motion starts its published clock; ordinary input stays bounded separately. */\n readonly reserveMotion: (commands: number) => Effect.Effect<void, InputFailure>;\n readonly send: (command: () => Promise<unknown>) => Effect.Effect<void, InputFailure>;\n readonly down: (\n key: string,\n press: () => Promise<unknown>,\n release: () => Promise<unknown>,\n ) => Effect.Effect<void, InputFailure>;\n readonly up: (key: string) => Effect.Effect<void, InputFailure>;\n readonly drain: Effect.Effect<void, InputFailure>;\n /** Stop future input and submit missing releases without waiting indefinitely for replies. */\n readonly close: Effect.Effect<void>;\n}\n\nexport const make = () => {\n const outstanding = new Set<Promise<void>>();\n\n // A timed-out action keeps capacity until its real replies arrive. Waiting for them sends\n // nothing, so cancellation here cannot leave a detached continuation that later types.\n const idle = Effect.gen(function* () {\n while (outstanding.size > 0) yield* Effect.promise(() => Promise.all(outstanding));\n });\n\n const begin = Effect.gen(function* () {\n yield* idle;\n const pending = new Set<Promise<void>>();\n const held: Array<{ readonly key: string; readonly release: () => Promise<unknown> }> = [];\n let failure: InputFailure | undefined;\n let reserved = 0;\n let closed = false;\n\n const requireOpen = Effect.suspend(() =>\n closed\n ? Effect.fail(new InputFailure({ cause: new Error(\"the input run has stopped\") }))\n : Effect.void,\n );\n\n const requireSuccess = Effect.suspend(() =>\n failure === undefined ? Effect.void : Effect.fail(failure),\n );\n\n const submit = (command: () => Promise<unknown>) => {\n if (reserved < 1) throw new Error(\"input must reserve capacity before dispatch\");\n reserved--;\n let response: Promise<unknown>;\n\n try {\n response = command();\n } catch (cause) {\n failure ??= new InputFailure({ cause });\n\n return;\n }\n\n // Every rejection is observed immediately; a failure does not abandon later replies.\n const reply = response.then(\n () => {\n pending.delete(reply);\n outstanding.delete(reply);\n },\n (cause: unknown) => {\n failure ??= new InputFailure({ cause });\n pending.delete(reply);\n outstanding.delete(reply);\n },\n );\n\n pending.add(reply);\n outstanding.add(reply);\n };\n\n const reserve = (commands: number, maximum: number, limit: number) =>\n Effect.gen(function* () {\n yield* requireOpen;\n yield* requireSuccess;\n if (!Number.isInteger(commands) || commands < 1 || commands > maximum)\n return yield* Effect.die(new Error(\"invalid input reservation\"));\n while (outstanding.size + reserved + commands > limit) {\n yield* Effect.promise(() => Promise.race(outstanding));\n yield* requireOpen;\n yield* requireSuccess;\n }\n reserved += commands;\n });\n\n const run: Run = {\n reserve: (commands) => reserve(commands, capacity, capacity),\n // A dense stroke cannot wait for replies midway without changing its published timing.\n // Its finite reservation also leaves room for the ordinary pool's already-owned releases.\n reserveMotion: (commands) => reserve(commands, maximumSamples, capacity + maximumSamples),\n send: (command) =>\n Effect.gen(function* () {\n yield* requireOpen;\n yield* requireSuccess;\n yield* Effect.sync(() => submit(command));\n yield* requireSuccess;\n }),\n down: (key, press, release) =>\n Effect.gen(function* () {\n yield* requireOpen;\n yield* requireSuccess;\n yield* Effect.sync(() => {\n held.push({ key, release });\n submit(press);\n });\n yield* requireSuccess;\n }),\n up: (key) =>\n Effect.gen(function* () {\n yield* requireOpen;\n yield* Effect.sync(() => {\n const index = held.findLastIndex((entry) => entry.key === key);\n const entry = held[index];\n\n if (entry === undefined) return;\n // Submission owns the release, even if its reply fails. Retrying an uncertain\n // release could run page handlers twice, so cleanup never sends it again.\n held.splice(index, 1);\n submit(entry.release);\n });\n yield* requireSuccess;\n }),\n drain: Effect.gen(function* () {\n while (pending.size > 0) yield* Effect.promise(() => Promise.all(pending));\n yield* requireSuccess;\n }),\n close: Effect.sync(() => {\n if (closed) return;\n closed = true;\n for (const entry of held.toReversed()) submit(entry.release);\n held.length = 0;\n reserved = 0;\n }),\n };\n\n return run;\n });\n\n /** `idle` lets an action wait, in its page's turn, for the page's earlier replies. */\n return { idle, begin };\n};\n","/**\n * How input is sent: plainly, as fast as the page takes it, or performed for viewers, with a\n * pointer that glides, keys typed at a person's pace, held buttons and wheels in bursts. A page's\n * actions take one, and the input reaches the same controls either way; only its timing, and\n * what viewers see of it, differ. A presenter builds the performed one.\n */\nimport { Effect, type MutableRef, type Option, Random } from \"effect\";\n\nimport type * as Motion from \"../../Motion.ts\";\nimport type { Point } from \"../../Page.ts\";\nimport * as Keys from \"./keys.ts\";\n\nexport interface TypingEvent {\n /** From the start of the typing. */\n readonly afterMillis: number;\n readonly phase: \"down\" | \"up\" | \"insert\";\n readonly key: string;\n}\n\nexport interface WheelStep {\n readonly dx: number;\n readonly dy: number;\n /** From the first step. */\n readonly afterMillis: number;\n}\n\nexport interface Style {\n /**\n * Whether viewers watch the input: then the pointer clicks into a field before typing, finds\n * what lies under it as it scrolls, and scrolls to a target out of view with the wheel.\n */\n readonly shown: boolean;\n /** Where viewers last saw the pointer, which the next glide starts from; else the page's own. */\n readonly pointer: MutableRef.MutableRef<Option.Option<Point>> | undefined;\n /** The pointer's path to `to`, ending exactly there. */\n readonly glide: (\n from: Point,\n to: Point,\n dragging: boolean,\n ) => Effect.Effect<ReadonlyArray<Motion.Sample>>;\n /** How long a button stays down when a click does not say. */\n readonly hold: Effect.Effect<number>;\n /** The key events that type `text`, or one insertion of it under a guard, timed from the start. */\n readonly typing: (text: string, guarded: boolean) => Effect.Effect<ReadonlyArray<TypingEvent>>;\n /** The pause between repeated presses of the same keys. */\n readonly keyGap: Effect.Effect<number>;\n /** A wheel scroll as the wheel turns: in one step, or in notches and bursts. */\n readonly wheel: (dx: number, dy: number) => Effect.Effect<ReadonlyArray<WheelStep>>;\n}\n\n/** Each key as it comes, with no pause; a drag moves in eight short steps so its target sees it. */\nexport const plain: Style = {\n shown: false,\n pointer: undefined,\n glide: (from, to, dragging) =>\n Effect.succeed(\n dragging\n ? Array.from({ length: 8 }, (_, index) => ({\n x: index === 7 ? to.x : from.x + ((to.x - from.x) * (index + 1)) / 8,\n y: index === 7 ? to.y : from.y + ((to.y - from.y) * (index + 1)) / 8,\n afterMillis: (index + 1) * 8,\n }))\n : [{ ...to, afterMillis: 0 }],\n ),\n hold: Effect.succeed(0),\n typing: (text, guarded) =>\n Effect.succeed(\n guarded && text !== \"\"\n ? [{ afterMillis: 0, phase: \"insert\", key: text }]\n : [...text].flatMap((key): ReadonlyArray<TypingEvent> =>\n Keys.description(key) === undefined\n ? [{ afterMillis: 0, phase: \"insert\", key }]\n : [\n { afterMillis: 0, phase: \"down\", key },\n { afterMillis: 0, phase: \"up\", key },\n ],\n ),\n ),\n keyGap: Effect.succeed(0),\n wheel: (dx, dy) => Effect.succeed([{ dx, dy, afterMillis: 0 }]),\n};\n\n// A right-skewed draw, clamped so that cleanup and deadlines stay predictable; 1 - U keeps the\n// logarithm defined when Random returns zero.\nconst lognormal = Effect.fnUntraced(function* (\n median: number,\n sigma: number,\n minimum: number,\n maximum: number,\n) {\n const radius = Math.sqrt(-2 * Math.log(1 - (yield* Random.next)));\n const normal = radius * Math.cos(2 * Math.PI * (yield* Random.next));\n\n return Math.max(minimum, Math.min(maximum, median * Math.exp(sigma * normal)));\n});\n\n/** A pause around `median`, as the research measured reactions: at most four times it. */\nexport const pause = (median: number, sigma: number) =>\n median <= 0 ? Effect.succeed(0) : lognormal(median, sigma, 0, median * 4);\n\n// A mouse press about 80 ms long on average, a key about 110 ms, each now and then longer: their\n// medians are the means times exp(-sigma^2 / 2).\nconst pressHold = lognormal(75.2, 0.35, 35, 200);\nconst keyHold = lognormal(107.8, 0.2, 60, 220);\nconst eventOrder = { up: 0, insert: 1, down: 2 };\n\n/**\n * Plan the whole text before any key goes, so holds overlap without waiting on the network. A\n * physical key is never held twice, as with A and a, or ! and 1. The first key waits for the hand\n * to reach the keys, each later one follows the last by a gap drawn around `gap`, and a word's\n * first key comes 60 ms later.\n */\nconst typing = Effect.fnUntraced(function* (\n text: string,\n gap: number,\n): Effect.fn.Return<ReadonlyArray<TypingEvent>> {\n const events: Array<TypingEvent> = [];\n const releases = new Map<string, number>();\n let due = text === \"\" ? 0 : yield* Random.nextBetween(150, 400);\n let previous = \"\";\n\n for (const character of text) {\n if (/\\s/u.test(previous) && /[\\p{L}\\p{N}]/u.test(character)) due += 60;\n const description = Keys.description(character);\n\n if (description === undefined)\n events.push({ afterMillis: due, phase: \"insert\", key: character });\n else {\n due = Math.max(due, (releases.get(description.code) ?? -1) + 1);\n const released = due + (yield* keyHold);\n\n events.push(\n { afterMillis: due, phase: \"down\", key: character },\n { afterMillis: released, phase: \"up\", key: character },\n );\n releases.set(description.code, released);\n }\n due += yield* Random.nextBetween(gap / 2, (gap * 3) / 2);\n previous = character;\n }\n\n return events.toSorted(\n (left, right) =>\n left.afterMillis - right.afterMillis || eventOrder[left.phase] - eventOrder[right.phase],\n );\n});\n\n/** A word is five characters; the gap leaves room for each word's later start. */\nexport const keyGap = (wordsPerMinute: number) => 12_000 / wordsPerMinute - 10;\n\n/**\n * The wheel in 100 px notches, 30 to 140 ms apart, in bursts of at most nine, with 0.6 to 2.6 s\n * between bursts, as people scroll.\n */\nconst bursts = Effect.fnUntraced(function* (dx: number, dy: number) {\n const notches = Math.max(1, Math.ceil(Math.hypot(dx, dy) / 100));\n const steps: Array<WheelStep> = [];\n let due = 0;\n\n for (let index = 0; index < notches; index++) {\n if (index > 0)\n due += yield* index % 9 === 0 ? Random.nextBetween(600, 2600) : Random.nextBetween(30, 140);\n steps.push({ dx: dx / notches, dy: dy / notches, afterMillis: due });\n }\n\n return steps;\n});\n\n/** Input performed for viewers, with this pointer and pace. */\nexport const performed = (options: {\n readonly pointer: MutableRef.MutableRef<Option.Option<Point>>;\n readonly motion: Motion.Service;\n readonly wordsPerMinute: number;\n}): Style => {\n const gap = keyGap(options.wordsPerMinute);\n\n return {\n shown: true,\n pointer: options.pointer,\n glide: (from, to) => options.motion.plan(from, to),\n hold: pressHold,\n typing: (text) => typing(text, gap),\n keyGap: Random.nextBetween(gap / 2, (gap * 3) / 2),\n wheel: bursts,\n };\n};\n","/**\n * Performing one action: its turn on the page, the input guard's step, the input run that owns its\n * replies, and the action's record. Its deadline leaves out the time its style takes to show it.\n */\nimport { Duration, Effect, Exit, Option, Ref } from \"effect\";\n\nimport { BrowserError, PolicyTimeout, Timeout } from \"../../BrowserError.ts\";\nimport { Action, type ActionOptions, Subject } from \"../../BrowserEvent.ts\";\nimport { type Point, redacted, type ResolvedTarget } from \"../../Page.ts\";\nimport { failWith, type PageContext, undispatched } from \"../page/context.ts\";\nimport { Correlation } from \"../page/lane.ts\";\nimport type * as BrowserClock from \"../pictures/clock.ts\";\nimport type { Dispatch } from \"./dispatch.ts\";\nimport type { Approval, PolicyPlan } from \"./guard.ts\";\nimport * as Replies from \"./replies.ts\";\nimport { plain, type Style } from \"./style.ts\";\n\nexport interface InputMarks {\n /** How the action's input is sent: plainly, or performed for viewers. */\n readonly style: Style;\n /**\n * Time the style spends showing the input, such as a glide or typing at a person's pace, planned\n * from now: the deadline moves back by as much, so presentation has a budget of its own.\n */\n readonly present: (millis: number) => Effect.Effect<void>;\n /** The action's own input, such as a press, key or wheel, has reached the page. */\n readonly sent: Effect.Effect<void>;\n /** Preparatory input, such as the pointer travelling to a target, has reached the page. */\n readonly touched: Effect.Effect<void>;\n readonly at: (point: Point) => Effect.Effect<void>;\n /** What the input acts on, and for a drag where it ends, as the page names them now. */\n readonly on: (subject: Named, to?: Named) => Effect.Effect<void>;\n /** The action's text is not bound for a secret field, so its record may keep it. */\n readonly reveal: Effect.Effect<void>;\n readonly input: Replies.Run;\n}\n\n/** What the page names a target: a resolved one, or the field that has focus. */\ntype Named = Pick<ResolvedTarget, \"role\" | \"name\" | \"tag\" | \"context\" | \"box\">;\n\nconst subjectOf = (target: Named) =>\n new Subject({ role: target.role, name: target.name, tag: target.tag, context: target.context });\n\n/** What an action records of what it acted on: subjects, and a point target's box. */\nconst actedOn = (subject: Named, to?: Named) => ({\n subject: subjectOf(subject),\n box: subject.box,\n ...(to === undefined ? {} : { to: subjectOf(to) }),\n});\n\n/** A subject as span attributes under `prefix`, without a role it does not have. */\nconst subjectAttributes = (prefix: string, subject: Subject | undefined) =>\n subject === undefined\n ? {}\n : {\n ...(subject.role === null ? {} : { [`${prefix}.role`]: subject.role }),\n [`${prefix}.name`]: subject.name,\n [`${prefix}.tag`]: subject.tag,\n };\n\n/** What an action's record keeps of its call. */\nexport interface Call {\n readonly target?: string | undefined;\n /** The rest of what the caller asked, recorded so a plan can ask it again. */\n readonly options?: ActionOptions | undefined;\n readonly text?: string | undefined;\n /** The text may be a secret: it is recorded only once the action reveals that it is not. */\n readonly secret?: boolean | undefined;\n /** False for navigation, which sends no input. */\n readonly input?: boolean | undefined;\n /** False for the pointer's travel ahead of an action, which is no action of its own. */\n readonly recorded?: boolean | undefined;\n}\n\nconst timedOut = (operation: string, timeout: Duration.Duration) =>\n failWith(operation, new Timeout({ millis: Duration.toMillis(timeout) }));\n\n/**\n * Fail `effect` with `Timeout` once `timeout` has passed, and as much later again as `presented`\n * says presentation has planned meanwhile.\n */\nconst deadline =\n (operation: string, timeout: Duration.Duration, now: () => number, presented: () => number) =>\n <A>(effect: Effect.Effect<A, BrowserError>) =>\n Effect.suspend(() => {\n const due = now() + Duration.toMillis(timeout);\n\n const expiry: Effect.Effect<never, BrowserError> = Effect.suspend(() => {\n const left = due + presented() - now();\n\n return left <= 0\n ? timedOut(operation, timeout)\n : Effect.sleep(Duration.millis(left)).pipe(Effect.andThen(expiry));\n });\n\n return Effect.raceFirst(effect, expiry);\n });\n\nexport const make = (page: PageContext, sender: Dispatch) => {\n const { id, settings, mapping, lane, publish, now, noteInput, span, owned } = page;\n const { inputClocks, flush } = sender;\n const input = Replies.make();\n\n // Record the whole operation, but never hold the page's turn or spend its action timeout while\n // a policy is waiting. Validation binds approval to the document and targets it saw.\n const perform = <A>(\n name: string,\n info: Call,\n timeout: Duration.Duration,\n prepare: Effect.Effect<PolicyPlan, BrowserError>,\n body: (marks: InputMarks, approval: Approval | undefined) => Effect.Effect<A, BrowserError>,\n style: Style = plain,\n ): Effect.Effect<A, BrowserError> =>\n Effect.gen(function* () {\n const startedAt = now();\n const sent = yield* Ref.make(false);\n const at = yield* Ref.make(Option.none<Point>());\n const acted = yield* Ref.make<Pick<Action, \"subject\" | \"to\" | \"box\">>({});\n\n // The page may react to preparatory input, as to script changes such as a selection, so\n // paint from before either is not current; only the action's own input can have given it\n // effect.\n const touch = Effect.sync(noteInput);\n\n // A failure before the action checks its field, a denial included, records no text.\n let revealed = info.secret !== true;\n // The time the style has planned to show the input, which the deadline leaves out.\n let presented = 0;\n\n const marks = {\n style,\n present: (millis: number) =>\n Effect.sync(() => {\n presented += Math.max(0, millis);\n }),\n sent: Ref.set(sent, true).pipe(Effect.andThen(touch)),\n touched: touch,\n at: (point: Point) => Ref.set(at, Option.some(point)),\n on: (subject: Named, to?: Named) => Ref.set(acted, actedOn(subject, to)),\n reveal: Effect.sync(() => {\n revealed = true;\n }),\n };\n\n // Admission waits only on this page's own unresolved replies, in its turn, so a stalled page\n // cannot delay input on other pages. Input never waits for the clock mapping: until a\n // capture has measured one, it keeps Chromium's own receipt time.\n let estimate: BrowserClock.Estimate | undefined;\n\n const admit = input.idle.pipe(\n Effect.tap(() =>\n Effect.sync(() => {\n estimate = (info.input ?? true) ? mapping.latest() : undefined;\n }),\n ),\n );\n\n const useInput = <Value>(action: (run: Replies.Run) => Effect.Effect<Value, BrowserError>) =>\n input.begin.pipe(\n // A capture can recalibrate while input is running. One run, including delayed cleanup\n // releases, keeps one mapping so epoch stamps cannot jump backwards during a stroke.\n Effect.tap((run) =>\n Effect.sync(() => {\n if (estimate !== undefined) inputClocks.set(run, estimate);\n }),\n ),\n Effect.flatMap((run) =>\n action(run).pipe(\n Effect.matchEffect({\n onFailure: (error) =>\n run.close.pipe(\n Effect.andThen(flush(name, run).pipe(Effect.ignore)),\n Effect.andThen(Effect.fail(error)),\n ),\n onSuccess: (value) =>\n run.close.pipe(Effect.andThen(flush(name, run)), Effect.as(value)),\n }),\n // The finalizer only submits missing releases. It cannot wait forever for a\n // disconnected peer; the page retains those replies and gates its next action.\n Effect.ensuring(run.close.pipe(Effect.andThen(page.openings.clear))),\n ),\n ),\n );\n\n // How long its turn and the page's replies kept the action waiting, once it had both.\n let queuedMillis: number | undefined;\n\n // The page's turn and its earlier input's replies are waited for within the action's\n // deadline, undispatched: a turn not given by then is `Busy`, and replies not answered by\n // then a `Timeout`. The turn starts a full deadline of its own, so a wait never truncates\n // input under way.\n const dispatch = <Value>(action: Effect.Effect<Value, BrowserError>) =>\n Effect.suspend(() => {\n const asked = now();\n\n return lane.write(\n name,\n timeout,\n )(\n Effect.suspend(() =>\n admit.pipe(\n Effect.timeoutOrElse({\n duration: Duration.millis(\n Math.max(0, Duration.toMillis(timeout) - (now() - asked)),\n ),\n orElse: () => timedOut(name, timeout),\n }),\n ),\n ).pipe(\n Effect.tap(() =>\n Effect.sync(() => {\n queuedMillis = Math.round(now() - asked);\n }),\n ),\n Effect.andThen(deadline(name, timeout, now, () => presented)(action)),\n ),\n );\n });\n\n const guard = settings.guard;\n\n // Only an approval needs binding: without a guard, input goes straight to the page.\n const run =\n guard === undefined\n ? dispatch(useInput((run) => body({ ...marks, input: run }, undefined)))\n : Effect.gen(function* () {\n const plan = yield* lane\n .read(name)(deadline(name, settings.actionTimeout, now, () => 0)(prepare))\n .pipe(span(\"Page.prepare\", {}, \"Debug\"));\n\n // A hold lasts as long as this span; a judge's model call is its child.\n yield* guard(plan.request).pipe(\n Effect.mapError((reason) => undispatched(name, reason)),\n Effect.timeoutOrElse({\n duration: settings.policyTimeout,\n orElse: () =>\n failWith(\n name,\n new PolicyTimeout({ millis: Duration.toMillis(settings.policyTimeout) }),\n ),\n }),\n span(\"Page.guard\"),\n );\n\n return yield* dispatch(\n useInput((run) =>\n plan.validate.pipe(\n Effect.flatMap((approval) => body({ ...marks, input: run }, approval)),\n ),\n ),\n );\n });\n\n const record = info.recorded === false ? () => 0 : publish;\n\n // Record the outcome even when the caller interrupts: its input may already be in the page.\n return yield* Effect.uninterruptibleMask((restore) =>\n Effect.gen(function* () {\n const exit = yield* Effect.exit(restore(run));\n const dispatched = yield* Ref.get(sent);\n const point = yield* Ref.get(at);\n const { subject, to, box } = yield* Ref.get(acted);\n const failure = Exit.isFailure(exit) ? Exit.findErrorOption(exit) : Option.none();\n\n // What the Action records, less its text: only a revealed text's length.\n yield* Effect.annotateCurrentSpan({\n dispatched,\n ...(queuedMillis === undefined ? {} : { queuedMillis }),\n ...(info.text !== undefined && revealed ? { chars: info.text.length } : {}),\n ...subjectAttributes(\"subject\", subject),\n ...subjectAttributes(\"to\", to),\n ...Option.match(failure, {\n onNone: () => ({}),\n onSome: (error) => ({ \"error.type\": error.reason._tag }),\n }),\n });\n\n record(\n new Action({\n at: now(),\n startedAt,\n page: id,\n name,\n correlation: yield* Correlation,\n target: info.target,\n options: Exit.isSuccess(exit) ? info.options : undefined,\n subject,\n to,\n box,\n text:\n info.text === undefined ? undefined : revealed ? info.text.slice(0, 200) : redacted,\n x: Option.getOrUndefined(Option.map(point, (p) => p.x)),\n y: Option.getOrUndefined(Option.map(point, (p) => p.y)),\n ok: Exit.isSuccess(exit),\n dispatched,\n error: Option.match(failure, {\n onNone: () => (Exit.hasInterrupts(exit) ? \"interrupted\" : undefined),\n onSome: (error) => error.message,\n }),\n }),\n );\n if (Exit.isSuccess(exit)) return exit.value;\n if (dispatched)\n return yield* Exit.mapError(exit, (error) =>\n error.dispatched\n ? error\n : new BrowserError({\n operation: error.operation,\n reason: error.reason,\n dispatched: true,\n }),\n );\n\n return yield* exit;\n }),\n );\n }).pipe(span(`Page.${name}`, info.target === undefined ? {} : { target: info.target }), owned);\n\n return perform;\n};\n\nexport type Perform = ReturnType<typeof make>;\n","/**\n * The pointer's travel and the wheel, as the action's style sends them. Travel follows a motion\n * plan, published before its first move, from where viewers last saw the pointer when it is\n * shown, and a wheel scroll goes in the style's steps.\n */\nimport { Duration, Effect, MutableRef, Option, Schema } from \"effect\";\n\nimport { InvalidRequest } from \"../../BrowserError.ts\";\nimport { CursorChanged, TrackPerformed, TrackPlanned } from \"../../BrowserEvent.ts\";\nimport * as Motion from \"../../Motion.ts\";\nimport type { Point } from \"../../Page.ts\";\nimport { failWith, type PageContext } from \"../page/context.ts\";\nimport type { Viewport } from \"../page/viewport.ts\";\nimport type { Dispatch } from \"./dispatch.ts\";\nimport type { InputMarks } from \"./perform.ts\";\n\nexport const make = (page: PageContext, dispatch: Dispatch, viewport: Viewport) => {\n const { id, pointer, publish, now, span } = page;\n const { inputClocks, inputCall, dispatchMouse, sendMouse } = dispatch;\n\n // Travel toward a press only prepares the action; a hover is its travel, and a drag holds the\n // button it has already pressed.\n const moveTo = (\n operation: string,\n marks: InputMarks,\n to: Point,\n cursor?: string,\n travel: \"approach\" | \"hover\" | \"drag\" = \"approach\",\n ) =>\n Effect.gen(function* () {\n const dragging = travel === \"drag\";\n const { style } = marks;\n const drawn = style.pointer ?? pointer;\n const size = yield* viewport.viewportFor(operation);\n\n const previous = Option.getOrElse(MutableRef.get(drawn), () => ({\n x: Math.round(size.width / 2),\n y: Math.round(size.height / 2),\n }));\n\n const from = {\n x: Math.max(0, Math.min(size.width - 1, previous.x)),\n y: Math.max(0, Math.min(size.height - 1, previous.y)),\n };\n\n const planned = yield* style.glide(from, to, dragging);\n\n // A custom planner is a boundary. Decoding reads each sample once into a fresh copy and\n // checks that copy, so neither accessors nor later mutation can change what is admitted.\n const invalid = failWith(\n operation,\n new InvalidRequest({\n detail: \"motion must be a bounded, ordered schedule ending at the target\",\n }),\n );\n\n const samples = yield* Schema.decodeEffect(Motion.Plan)(planned).pipe(\n Effect.catch(() => invalid),\n );\n\n if (samples.at(-1)?.x !== to.x || samples.at(-1)?.y !== to.y) return yield* invalid;\n yield* Effect.annotateCurrentSpan(\"samples\", samples.length);\n yield* marks.present(samples.at(-1)?.afterMillis ?? 0);\n const run = marks.input;\n\n // Admit the whole motion before starting its clock. Dense original samples must not be\n // stretched by per-sample reply backpressure; unsent reservations belong to this run.\n yield* inputCall(operation, run.reserveMotion(samples.length));\n MutableRef.set(pointer, Option.some(from));\n const estimate = inputClocks.get(run);\n const at = now();\n let dispatched = 0;\n let last = from;\n\n // The complete plan exists before its first move. A canceled performer always clips\n // that future to the prefix it actually submitted, including interruption during sleep.\n yield* Effect.acquireUseRelease(\n Effect.sync(() => publish(new TrackPlanned({ at, page: id, from, samples }))),\n () =>\n Effect.gen(function* () {\n for (const sample of samples) {\n const remaining = at + sample.afterMillis - now();\n\n if (remaining > 0) yield* Effect.sleep(Duration.millis(remaining));\n yield* travel === \"approach\" ? marks.touched : marks.sent;\n yield* inputCall(\n operation,\n run.send(() =>\n dispatchMouse(\n {\n type: \"mouseMoved\",\n x: sample.x,\n y: sample.y,\n button: dragging ? \"left\" : \"none\",\n ...(dragging ? { buttons: 1 } : {}),\n },\n estimate,\n () => {\n dispatched++;\n last = { x: sample.x, y: sample.y };\n MutableRef.set(drawn, Option.some(last));\n if (dispatched === samples.length && cursor !== undefined)\n publish(new CursorChanged({ at: now(), page: id, cursor }));\n },\n ),\n ),\n );\n }\n }),\n (plan) =>\n Effect.sync(() =>\n publish(\n new TrackPerformed({\n at: now(),\n page: id,\n plan,\n dispatched,\n ...last,\n complete: dispatched === samples.length,\n }),\n ),\n ),\n );\n }).pipe(span(\"Page.move\", {}, \"Debug\"));\n\n const wheel = Effect.fnUntraced(function* (\n operation: string,\n marks: InputMarks,\n point: Point,\n dx: number,\n dy: number,\n ) {\n const steps = yield* marks.style.wheel(dx, dy);\n const at = now();\n\n yield* marks.present(steps.at(-1)?.afterMillis ?? 0);\n for (const step of steps) {\n const remaining = at + step.afterMillis - now();\n\n if (remaining > 0) yield* Effect.sleep(Duration.millis(remaining));\n yield* sendMouse(operation, marks.input, {\n type: \"mouseWheel\",\n ...point,\n deltaX: step.dx,\n deltaY: step.dy,\n });\n }\n });\n\n return { moveTo, wheel };\n};\n\nexport type Pointer = ReturnType<typeof make>;\n","/**\n * The wait after input: one task and one frame in the page, in one call, then a document only if\n * one committed meanwhile, until it is parsed. Chromium answers a call to a page that a link, a form\n * or a script's timer has asked to navigate only once the new document commits, or the navigation\n * stops without one, as on a 204, so the call spans the navigation the input asked for. A\n * `pushState` asks for no document, and a navigation a handler starts after a fetch answers is the\n * next look's to see. A tab the input opened waits for the browser's registration too.\n */\nimport { Deferred, Duration, Effect, Exit } from \"effect\";\n\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { contextGone, type PageContext } from \"../page/context.ts\";\n\n// A document still loading after this, or a closed page, is the next look's to show.\nconst settling = Duration.seconds(5);\n\nexport const make = (page: PageContext, bridge: Bridge) => {\n const document = () => bridge.frameTag().document;\n // The latest document whose DOMContentLoaded came, and what wakes a wait for the next.\n let parsed = -1;\n let changed = Deferred.makeUnsafe<void>();\n\n page.cdp.on(\"Page.domContentEventFired\", () => {\n parsed = document();\n Deferred.doneUnsafe(changed, Exit.void);\n changed = Deferred.makeUnsafe<void>();\n });\n\n /** The page's document before input, which `settle` measures from. */\n const mark = () => ({ document: document(), openings: page.openings.mark() });\n\n /** Wait for the page to settle after input sent since `before`. */\n const settle = (operation: string, before: ReturnType<typeof mark>) =>\n Effect.gen(function* () {\n // A commit ends the call's world; the loop then waits for that document.\n yield* bridge\n .evaluate(operation, scriptCall(\"settle\"))\n .pipe(Effect.catchIf(contextGone, () => Effect.void));\n while (document() > before.document && parsed < document()) yield* Deferred.await(changed);\n }).pipe(\n Effect.timeoutOrElse({ duration: settling, orElse: () => Effect.fail(\"unsettled\") }),\n Effect.catch(() => Effect.annotateCurrentSpan(\"settled\", false)),\n Effect.andThen(page.openings.settle(before.openings)),\n page.span(\"Page.settle\", {}, \"Debug\"),\n );\n\n return { mark, settle };\n};\n\nexport type Settle = ReturnType<typeof make>;\n","/**\n * Where an action's input goes: a ref or a point resolved to a control and a viewport point,\n * scrolled into view first when it is outside the viewport: at once, or with the wheel where\n * viewers watch.\n */\nimport { Effect } from \"effect\";\n\nimport { InvalidRequest, NotActionable, StaleRef } from \"../../BrowserError.ts\";\nimport { ResolvedTarget, type Target } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { decodeWith, failWith } from \"../page/context.ts\";\nimport type { Viewport } from \"../page/viewport.ts\";\nimport type { Dispatch } from \"./dispatch.ts\";\nimport type { Approval, Guard } from \"./guard.ts\";\nimport type { InputMarks } from \"./perform.ts\";\nimport type { Pointer } from \"./pointer.ts\";\nimport type { Settle } from \"./settle.ts\";\nimport * as Script from \"./targets.inpage.ts\";\n\nconst pointFailure = (\n operation: string,\n target: Target,\n result: Extract<Script.PointResult, { readonly error: string }>,\n) =>\n failWith(\n operation,\n result.error === \"stale\" && typeof target === \"string\"\n ? new StaleRef({ ref: target })\n : result.error === \"outside\"\n ? new InvalidRequest({ detail: result.detail })\n : new NotActionable({ detail: result.detail }),\n );\n\nconst resolvedTarget = (result: Script.ResolvedPoint): ResolvedTarget =>\n new ResolvedTarget({\n point: { x: result.x, y: result.y },\n element: result.element,\n tag: result.tag,\n role: result.role,\n name: result.name,\n context: result.context,\n box: result.box,\n cursor: result.cursor,\n ...(result.href === undefined ? {} : { href: result.href }),\n });\n\nexport const make = (\n bridge: Bridge,\n viewport: Viewport,\n guard: Guard,\n pointer: Pointer,\n dispatch: Dispatch,\n settling: Settle,\n) => {\n const { evaluate } = bridge;\n const { mutate } = guard;\n const { moveTo, wheel } = pointer;\n const { flush } = dispatch;\n\n const readPoint = (\n operation: string,\n target: Target,\n approval: Approval | undefined,\n scroll: boolean,\n ) =>\n (approval === undefined\n ? evaluate(operation, scriptCall(\"point\", target, scroll))\n : mutate(operation, scriptCall(\"point\", target, scroll), approval)\n ).pipe(Effect.flatMap(decodeWith(operation, Script.PointResultSchema)));\n\n const resolve = (operation: string, target: Target, approval?: Approval, scroll = true) => {\n if (typeof target === \"string\" && !/^e\\d+$/.test(target))\n return failWith(\n operation,\n new InvalidRequest({ detail: target + \" is not a ref; refs look like e12\" }),\n );\n if (typeof target !== \"string\" && (!Number.isFinite(target.x) || !Number.isFinite(target.y)))\n return failWith(\n operation,\n new InvalidRequest({ detail: \"point coordinates must be finite\" }),\n );\n\n return readPoint(operation, target, approval, scroll).pipe(\n Effect.flatMap((result) =>\n \"error\" in result\n ? pointFailure(operation, target, result)\n : Effect.succeed(resolvedTarget(result)),\n ),\n );\n };\n\n const targetFor = Effect.fnUntraced(function* (\n operation: string,\n target: Target,\n approval: Approval | undefined,\n marks: InputMarks,\n ) {\n if (!marks.style.shown || typeof target !== \"string\")\n return yield* resolve(operation, target, approval);\n\n // Inspection and policy approval happen before this point. Every retry is geometry only;\n // scrolling never obtains a fresh approval or silently follows a replacement document.\n for (let attempt = 0; attempt < 3; attempt++) {\n const result = yield* readPoint(operation, target, approval, false);\n\n if (!(\"error\" in result)) return resolvedTarget(result);\n if (result.error !== \"offscreen\") return yield* pointFailure(operation, target, result);\n\n const plan = yield* mutate(operation, scriptCall(\"scrollPlan\", target), approval).pipe(\n Effect.flatMap(decodeWith(operation, Script.ScrollPlanSchema)),\n );\n\n if (plan === null) break;\n const size = yield* viewport.viewportFor(operation);\n const point = { x: plan.x, y: plan.y };\n\n yield* marks.at(point);\n yield* moveTo(operation, marks, point);\n const before = settling.mark();\n\n yield* wheel(\n operation,\n marks,\n point,\n Math.max(-size.width * 0.9, Math.min(size.width * 0.9, plan.dx)),\n Math.max(-size.height * 0.9, Math.min(size.height * 0.9, plan.dy)),\n );\n yield* flush(operation, marks.input);\n yield* settling.settle(operation, before);\n if (approval !== undefined) yield* approval.check();\n }\n\n // Wheels may be prevented or the target may need unsupported nested/frame geometry. One\n // explicit fallback preserves reachability without a distance-dependent protocol loop.\n yield* marks.touched;\n const before = settling.mark();\n\n yield* resolve(operation, target, approval);\n yield* settling.settle(operation, before);\n if (approval !== undefined) yield* approval.check();\n\n return yield* resolve(operation, target, approval, false);\n });\n\n return { resolve, targetFor };\n};\n\nexport type Targets = ReturnType<typeof make>;\n","/**\n * The page's actions: click, hover, drag, type, press, scroll and select, each sent in a style,\n * plainly or performed for viewers, and the aim a performed click starts early. Each runs through\n * `perform`, which admits it, puts it to the input guard and records it. A click, a key or a scroll\n * then waits for the page to settle: a task and a frame, and a document if the input asked for one.\n */\nimport { Duration, Effect } from \"effect\";\n\nimport { InvalidRequest, NotActionable, StaleRef } from \"../../BrowserError.ts\";\nimport type { ClickOptions, PressOptions, ScrollOptions, Target, TypeOptions } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { decodeWith, failWith, type PageContext } from \"../page/context.ts\";\nimport type { Viewport } from \"../page/viewport.ts\";\nimport * as Dispatch from \"./dispatch.ts\";\nimport * as Script from \"./edit.inpage.ts\";\nimport * as Guard from \"./guard.ts\";\nimport * as Keyboard from \"./keyboard.ts\";\nimport * as Keys from \"./keys.ts\";\nimport * as Perform from \"./perform.ts\";\nimport * as Pointer from \"./pointer.ts\";\nimport * as Settle from \"./settle.ts\";\nimport { plain, type Style } from \"./style.ts\";\nimport * as Targets from \"./targets.ts\";\n\nconst buttonMask = { none: 0, left: 1, right: 2, middle: 4 } as const;\n\nconst partsOf = (page: PageContext, bridge: Bridge, viewport: Viewport) => {\n const dispatch = Dispatch.make(page);\n const pointer = Pointer.make(page, dispatch, viewport);\n const guard = Guard.make(page, bridge);\n const settling = Settle.make(page, bridge);\n\n return {\n page,\n bridge,\n ...settling,\n viewportFor: viewport.viewportFor,\n perform: Perform.make(page, dispatch),\n ...guard,\n ...Targets.make(bridge, viewport, guard, pointer, dispatch, settling),\n ...pointer,\n ...Keyboard.make(page, bridge, dispatch),\n sendMouse: dispatch.sendMouse,\n flush: dispatch.flush,\n };\n};\n\ntype Parts = ReturnType<typeof partsOf>;\n\n/** Whether every number given is finite; a number left out is. */\nconst finite = (...values: ReadonlyArray<number | undefined>) =>\n values.every((value) => value === undefined || Number.isFinite(value));\n\nconst named = (target: Target) => (typeof target === \"string\" ? target : `${target.x},${target.y}`);\n\n/** A click's options, once its counts are finite. */\nconst clickable = (options: ClickOptions) =>\n finite(options.clickCount, options.holdMillis)\n ? Effect.void\n : failWith(\"click\", new InvalidRequest({ detail: \"clickCount and holdMillis must be finite\" }));\n\n/** The keys a press sends, once they and its options are valid. */\nconst pressed = (keys: string, options: PressOptions) => {\n const parts = Keys.parts(keys);\n\n if (!finite(options.times, options.holdMillis))\n return failWith(\"press\", new InvalidRequest({ detail: \"times and holdMillis must be finite\" }));\n if (parts === undefined)\n return failWith(\n \"press\",\n new InvalidRequest({\n detail: `\"${keys}\" is not a key; try Enter, Space, ArrowLeft or Control+A`,\n }),\n );\n\n return Effect.succeed(parts);\n};\n\nconst click = (input: Parts) => {\n const { settings } = input.page;\n const { perform, preparePolicy, targetFor, moveTo, sendMouse, flush, mark, settle } = input;\n\n return (target: Target, clickOptions: ClickOptions = {}, style: Style = plain) =>\n perform(\n \"click\",\n {\n target: named(target),\n options: {\n button: clickOptions.button,\n clickCount: clickOptions.clickCount,\n holdMillis: clickOptions.holdMillis,\n },\n },\n settings.actionTimeout,\n Effect.suspend(() => clickable(clickOptions)).pipe(\n Effect.andThen(\n preparePolicy(\"click\", { target: typeof target === \"string\" ? target : undefined }, [\n target,\n ]),\n ),\n ),\n (marks, approval) =>\n Effect.gen(function* () {\n yield* clickable(clickOptions);\n const resolved = yield* targetFor(\"click\", target, approval, marks);\n const { point } = resolved;\n const button = clickOptions.button ?? \"left\";\n const count = Math.max(1, Math.min(3, clickOptions.clickCount ?? 1));\n\n yield* marks.at(point);\n yield* marks.on(resolved);\n yield* moveTo(\"click\", marks, point, resolved.cursor);\n if (approval !== undefined) yield* approval.check({ presses: [{ index: 0, ...point }] });\n const before = mark();\n\n yield* marks.sent;\n for (let index = 1; index <= count; index++) {\n // An earlier click of a multi-click can replace the approved control under the\n // pointer. Under a guard, its handlers run before the next press is checked and sent.\n if (approval !== undefined && index > 1) {\n yield* flush(\"click\", marks.input);\n yield* approval.check({ presses: [{ index: 0, ...point }] }).pipe(\n Effect.catchIf(\n (error) => error.reason._tag === \"StaleRef\",\n () =>\n failWith(\n \"click\",\n new NotActionable({\n detail:\n \"an earlier click removed the approved target, so no further press was sent\",\n }),\n ),\n ),\n );\n }\n yield* sendMouse(\"click\", marks.input, {\n type: \"mousePressed\",\n ...point,\n button,\n buttons: buttonMask[button],\n clickCount: index,\n });\n\n // A hold the caller asks for is the click's own; the style's is presentation.\n const hold = clickOptions.holdMillis ?? (yield* marks.style.hold);\n\n if (clickOptions.holdMillis === undefined) yield* marks.present(hold);\n if (hold > 0) yield* Effect.sleep(Duration.millis(hold));\n yield* sendMouse(\"click\", marks.input, {\n type: \"mouseReleased\",\n ...point,\n button,\n buttons: 0,\n clickCount: index,\n });\n }\n yield* flush(\"click\", marks.input);\n yield* settle(\"click\", before);\n\n return resolved;\n }),\n style,\n );\n};\n\nconst hover = (input: Parts) => {\n const { settings } = input.page;\n const { perform, preparePolicy, targetFor, moveTo, flush } = input;\n\n return (target: Target, style: Style = plain) =>\n perform(\n \"hover\",\n { target: named(target) },\n settings.actionTimeout,\n preparePolicy(\"hover\", { target: typeof target === \"string\" ? target : undefined }, [target]),\n (marks, approval) =>\n Effect.gen(function* () {\n const resolved = yield* targetFor(\"hover\", target, approval, marks);\n const { point } = resolved;\n\n yield* marks.at(point);\n yield* marks.on(resolved);\n yield* moveTo(\"hover\", marks, point, resolved.cursor, \"hover\");\n yield* flush(\"hover\", marks.input);\n }),\n style,\n );\n};\n\n/**\n * The pointer's travel to a target, before its action is asked: no guard holds it, no action is\n * recorded, and nothing is pressed. A guarded page aims nothing, as its input waits for approval.\n */\nconst aim = (input: Parts) => {\n const { settings } = input.page;\n const { perform, targetFor, moveTo, flush } = input;\n\n return (target: Target, style: Style) =>\n settings.guard === undefined\n ? perform(\n \"aim\",\n { target: named(target), recorded: false },\n settings.actionTimeout,\n Effect.die(\"an aim is never put to a guard\"),\n (marks) =>\n targetFor(\"aim\", target, undefined, marks).pipe(\n Effect.flatMap(({ point, cursor }) => moveTo(\"aim\", marks, point, cursor)),\n Effect.andThen(flush(\"aim\", marks.input)),\n ),\n style,\n )\n : Effect.void;\n};\n\nconst drag = (input: Parts) => {\n const { settings } = input.page;\n const { perform, preparePolicy, targetFor, resolve, moveTo, sendMouse, flush } = input;\n\n return (from: Target, to: Target, style: Style = plain) =>\n perform(\n \"drag\",\n { target: `${JSON.stringify(from)} -> ${JSON.stringify(to)}` },\n settings.actionTimeout,\n preparePolicy(\"drag\", {}, [from, to]),\n (marks, approval) =>\n Effect.gen(function* () {\n yield* targetFor(\"drag\", from, approval, marks);\n yield* targetFor(\"drag\", to, approval, marks);\n // Bringing the second endpoint into view may move the first. Both must still be\n // actionable in the final viewport before the first button press.\n const start = yield* resolve(\"drag\", from, approval, false);\n const end = yield* resolve(\"drag\", to, approval, false);\n\n yield* marks.at(end.point);\n yield* marks.on(start, end);\n yield* moveTo(\"drag\", marks, start.point, start.cursor);\n // Both ends are checked before the button goes down: once it is down, a release cannot\n // be withheld, and a dragged element under the pointer would hide the drop target.\n if (approval !== undefined)\n yield* approval.check({\n presses: [\n { index: 0, ...start.point },\n { index: 1, ...end.point },\n ],\n });\n yield* marks.sent;\n yield* sendMouse(\"drag\", marks.input, {\n type: \"mousePressed\",\n ...start.point,\n button: \"left\",\n buttons: 1,\n clickCount: 1,\n });\n yield* moveTo(\"drag\", marks, end.point, end.cursor, \"drag\");\n yield* sendMouse(\"drag\", marks.input, {\n type: \"mouseReleased\",\n ...end.point,\n button: \"left\",\n buttons: 0,\n clickCount: 1,\n });\n yield* flush(\"drag\", marks.input);\n }),\n style,\n );\n};\n\nconst typeText = (input: Parts) => {\n const { settings, now } = input.page;\n const { perform, preparePolicy, mutate, targetFor, moveTo, sendMouse, flush, bridge } = input;\n const { currentDocument, sameDocument, keyStroke, typeEvent, mark, settle } = input;\n\n return (text: string, typeOptions: TypeOptions = {}, style: Style = plain) =>\n perform(\n \"type\",\n {\n target: typeOptions.into,\n options: {\n replace: typeOptions.into === undefined ? false : typeOptions.replace,\n submit: typeOptions.submit,\n },\n text,\n secret: true,\n },\n settings.actionTimeout,\n preparePolicy(\"type\", { target: typeOptions.into, text }, [typeOptions.into ?? null], {\n submit: typeOptions.submit ?? false,\n }),\n (marks, approval) =>\n Effect.gen(function* () {\n const replace = typeOptions.replace ?? true;\n const into = typeOptions.into;\n\n if (into !== undefined && !/^e\\d+$/.test(into))\n return yield* failWith(\n \"type\",\n new InvalidRequest({ detail: `\"${into}\" is not a ref; refs look like e12` }),\n );\n\n // A typed space or letter can press a focused button or change a control. Refuse\n // those before any input, on every path.\n const asked = scriptCall(\"typeable\", into ?? null, typeOptions.secret === true);\n\n const typeable = yield* (\n approval === undefined\n ? bridge.evaluate(\"type\", asked)\n : mutate(\"type\", asked, approval)\n ).pipe(Effect.flatMap(decodeWith(\"type\", Script.TypeableResultSchema)));\n\n if (\"error\" in typeable)\n return yield* failWith(\n \"type\",\n typeable.error === \"stale\" && into !== undefined\n ? new StaleRef({ ref: into })\n : new NotActionable({ detail: typeable.detail }),\n );\n if (typeable.subject !== undefined) yield* marks.on(typeable.subject);\n\n const since = yield* currentDocument(\"type\");\n let secret = typeable.secret;\n\n if (into !== undefined) {\n const target = yield* targetFor(\"type\", into, approval, marks);\n\n yield* marks.at(target.point);\n yield* marks.on(target);\n // Viewers see the pointer click into the field.\n if (marks.style.shown) {\n yield* moveTo(\"type\", marks, target.point, target.cursor);\n if (approval !== undefined)\n yield* approval.check({ presses: [{ index: 0, ...target.point }] });\n yield* marks.sent;\n for (const type of [\"mousePressed\", \"mouseReleased\"] as const)\n yield* sendMouse(\"type\", marks.input, {\n type,\n ...target.point,\n button: \"left\",\n buttons: type === \"mousePressed\" ? 1 : 0,\n clickCount: 1,\n });\n yield* flush(\"type\", marks.input);\n }\n\n // Focusing can run page handlers, including navigation, before the script returns.\n yield* marks.sent;\n\n const focused = yield* mutate(\n \"type\",\n scriptCall(\"focus\", into, replace),\n approval,\n ).pipe(Effect.flatMap(decodeWith(\"type\", Script.FocusResultSchema)));\n\n if (\"error\" in focused) return yield* Guard.editFailure(\"type\", into, focused);\n secret ||= focused.secret;\n }\n if (!secret) yield* marks.reveal;\n if (approval !== undefined) yield* approval.check({ focused: true });\n yield* marks.sent;\n\n // A key's handlers can move focus, and later keys then reach a control nobody approved.\n // Under a guard, the field is approved once: plain text goes in one insertion, which no\n // handler can split, and keys typed one at a time check that the field still has focus,\n // once the keys before are answered, before each space, which could press a button, and\n // after the last key.\n const focusHeld =\n approval === undefined\n ? Effect.void\n : flush(\"type\", marks.input).pipe(Effect.andThen(approval.check({ focused: true })));\n\n if (text === \"\" && replace && into !== undefined) {\n yield* sameDocument(\"type\", since);\n yield* keyStroke(\"type\", marks.input, [\"Delete\"]);\n } else {\n const events = yield* marks.style.typing(text, approval !== undefined);\n const keyed = events.some((event) => event.phase === \"down\");\n\n const checks =\n approval !== undefined && keyed ? (text.match(/\\s/gu)?.length ?? 0) + 1 : 0;\n\n // Each check is about two round trips, which only keys typed one at a time need.\n const started = now();\n\n yield* marks.present((events.at(-1)?.afterMillis ?? 0) + checks * 250);\n for (const event of events) {\n const remaining = started + event.afterMillis - now();\n\n if (remaining > 0) yield* Effect.sleep(Duration.millis(remaining));\n if (event.phase === \"down\" && /\\s/u.test(event.key)) yield* focusHeld;\n if (event.phase !== \"up\") yield* sameDocument(\"type\", since);\n yield* typeEvent(marks.input, event, secret);\n }\n if (keyed) yield* focusHeld;\n }\n // Public Playwright keys preserve platform editing commands. Drain the raw text\n // session before Enter uses Playwright's session, so submit cannot overtake typing.\n yield* flush(\"type\", marks.input);\n if (typeOptions.submit === true) {\n // Typing can move focus or change the form; Enter goes only to the approved field.\n if (approval !== undefined) yield* approval.check({ focused: true });\n yield* sameDocument(\"type\", since);\n const before = mark();\n\n yield* keyStroke(\"type\", marks.input, [\"Enter\"]);\n yield* flush(\"type\", marks.input);\n yield* settle(\"type\", before);\n }\n }),\n style,\n );\n};\n\nconst press = (input: Parts) => {\n const { settings, now } = input.page;\n const { perform, preparePolicy, currentDocument, sameDocument, keyStroke, flush } = input;\n const { mark, settle, targetFor, mutate } = input;\n\n return (keys: string, pressOptions: PressOptions = {}, style: Style = plain) =>\n perform(\n \"press\",\n { target: keys, options: { times: pressOptions.times, holdMillis: pressOptions.holdMillis } },\n settings.actionTimeout,\n Effect.suspend(() => pressed(keys, pressOptions)).pipe(\n Effect.flatMap((parts) =>\n preparePolicy(\n \"press\",\n { target: pressOptions.on, text: parts.join(\"+\") },\n [pressOptions.on ?? null],\n { keys: parts.join(\"+\") },\n ),\n ),\n ),\n (marks, approval) =>\n Effect.gen(function* () {\n const parts = yield* pressed(keys, pressOptions);\n const times = Math.max(1, Math.min(50, pressOptions.times ?? 1));\n const hold = pressOptions.holdMillis ?? 0;\n const activates = parts.at(-1) === \"Enter\" || parts.at(-1) === \"Space\";\n const since = yield* currentDocument(\"press\");\n const on = pressOptions.on;\n\n // The keys go to the element asked for, which must hold focus before the first.\n if (on !== undefined) {\n yield* marks.on(yield* targetFor(\"press\", on, approval, marks));\n\n const focused = yield* mutate(\"press\", scriptCall(\"focusOn\", on), approval).pipe(\n Effect.flatMap(decodeWith(\"press\", Script.EditResultSchema)),\n );\n\n if (\"error\" in focused) return yield* Guard.editFailure(\"press\", on, focused);\n if (approval !== undefined) yield* approval.check({ focused: true });\n }\n const before = mark();\n let due = now();\n\n yield* marks.sent;\n for (let index = 0; index < times; index++) {\n // A repeated key stays in the document it began in. Under a guard, a repeated Enter\n // or Space must also reach the approved element after the previous press settled.\n if (index > 0 && approval !== undefined && activates) {\n yield* flush(\"press\", marks.input);\n yield* approval.check({ focused: true });\n }\n yield* sameDocument(\"press\", since);\n yield* keyStroke(\"press\", marks.input, parts, hold);\n if (index + 1 < times) {\n const gap = yield* marks.style.keyGap;\n\n yield* marks.present(gap);\n due += hold + gap;\n if (due > now()) yield* Effect.sleep(Duration.millis(due - now()));\n }\n }\n yield* flush(\"press\", marks.input);\n yield* settle(\"press\", before);\n }),\n style,\n );\n};\n\nconst scroll = (input: Parts) => {\n const { settings } = input.page;\n const { perform, preparePolicy, viewportFor, targetFor, resolve, moveTo, wheel, flush } = input;\n const { mark, settle } = input;\n\n return (scrollOptions: ScrollOptions = {}, style: Style = plain) => {\n const target = scrollOptions.at;\n\n const valid =\n Number.isFinite(scrollOptions.dx ?? 0) && Number.isFinite(scrollOptions.dy ?? 0)\n ? Effect.void\n : failWith(\"scroll\", new InvalidRequest({ detail: \"scroll deltas must be finite\" }));\n\n return perform(\n \"scroll\",\n {\n target: target === undefined ? undefined : named(target),\n options: { dx: scrollOptions.dx, dy: scrollOptions.dy },\n },\n settings.actionTimeout,\n valid.pipe(\n Effect.andThen(\n // Scrolling the page has no target: whatever sits mid-viewport is not what is scrolled.\n preparePolicy(\n \"scroll\",\n { target: typeof target === \"string\" ? target : undefined },\n target === undefined ? [] : [target],\n ),\n ),\n ),\n (marks, approval) =>\n Effect.gen(function* () {\n yield* valid;\n // Over CDP the page reports its own viewport, so the read shares the action's deadline.\n const viewport = yield* viewportFor(\"scroll\");\n\n const middle = {\n x: Math.round(viewport.width / 2),\n y: Math.round(viewport.height / 2),\n };\n\n const dx = scrollOptions.dx ?? 0;\n\n const dy =\n scrollOptions.dy ??\n (scrollOptions.dx === undefined ? Math.round(viewport.height * 0.8) : 0);\n\n // A page scroll has no target, but viewers still see the cursor it lands on.\n const resolved =\n target !== undefined\n ? yield* targetFor(\"scroll\", target, approval, marks)\n : marks.style.shown\n ? yield* resolve(\"scroll\", middle, approval).pipe(\n Effect.orElseSucceed(() => undefined),\n )\n : undefined;\n\n const point = resolved?.point ?? middle;\n\n yield* marks.at(point);\n if (target !== undefined && resolved !== undefined) yield* marks.on(resolved);\n yield* moveTo(\"scroll\", marks, point, resolved?.cursor);\n const before = mark();\n\n yield* marks.sent;\n yield* wheel(\"scroll\", marks, point, dx, dy);\n yield* flush(\"scroll\", marks.input);\n yield* settle(\"scroll\", before);\n }),\n style,\n );\n };\n};\n\nconst select = (input: Parts) => {\n const { settings } = input.page;\n const { perform, preparePolicy, targetFor, mutate } = input;\n\n return (ref: string, values: ReadonlyArray<string>) =>\n perform(\n \"select\",\n { target: ref, options: { values }, text: values.join(\", \") },\n settings.actionTimeout,\n preparePolicy(\"select\", { target: ref, text: values.join(\", \") }, [ref]),\n (marks, approval) =>\n Effect.gen(function* () {\n yield* marks.on(yield* targetFor(\"select\", ref, approval, marks));\n\n // The script refuses before it changes anything. Only a choice it made, or a script\n // that may have run without an intact answer, may have reached the page.\n const result = yield* mutate(\n \"select\",\n scriptCall(\"select\", ref, values),\n approval,\n marks.sent,\n ).pipe(\n Effect.flatMap((value) =>\n decodeWith(\n \"select\",\n Script.EditResultSchema,\n )(value).pipe(Effect.tapError(() => marks.sent)),\n ),\n );\n\n if (\"error\" in result) return yield* Guard.editFailure(\"select\", ref, result);\n yield* marks.sent;\n\n return result.detail;\n }),\n );\n};\n\nexport const make = (page: PageContext, bridge: Bridge, viewport: Viewport) => {\n const parts = partsOf(page, bridge, viewport);\n\n return {\n perform: parts.perform,\n preparePolicy: parts.preparePolicy,\n click: click(parts),\n hover: hover(parts),\n aim: aim(parts),\n drag: drag(parts),\n type: typeText(parts),\n press: press(parts),\n scroll: scroll(parts),\n select: select(parts),\n };\n};\n\n/** A page's input, each action in any style. */\nexport type Input = ReturnType<typeof make>;\n","/**\n * One CDP screencast per page, with bounded transport replies and per-reader loss accounting.\n * Native callbacks own synchronous bookkeeping; the page scope owns startup and teardown.\n */\nimport { Clock, Deferred, Duration, Effect, Exit, Option, Queue, Semaphore, Stream } from \"effect\";\n\nimport { type BrowserError, InvalidRequest } from \"../../BrowserError.ts\";\nimport { BrowserPaint, CaptureStats, Frame, type ScreencastOptions } from \"../../Frame.ts\";\nimport { undispatched } from \"../page/context.ts\";\nimport { type Estimate, toHostTime, uncertaintyAt } from \"./clock.ts\";\nimport type { NativeFrame, Transport } from \"./transport.ts\";\n\nexport interface Size {\n readonly width: number;\n readonly height: number;\n}\n\ninterface Options {\n readonly id: string;\n /** Where each capture's screencast runs, found as it starts. */\n readonly transport: Effect.Effect<Transport, BrowserError>;\n readonly clock: Clock.Clock;\n /** The estimate a capture starts with, once the page can be captured. */\n readonly calibrate: Effect.Effect<Estimate, BrowserError>;\n /** The browser's newest estimate, which times each frame. */\n readonly latest: () => Estimate | undefined;\n /** Measure the clock again if it is due, while frames flow. */\n readonly renew: Effect.Effect<void>;\n /** What the page needs from its own session while frames flow, sent as a capture starts. */\n readonly watch: Effect.Effect<unknown, BrowserError>;\n /** How long frames are kept, measured back from the newest. */\n readonly frameHistory: Duration.Duration;\n /** The viewport in CSS pixels; a capture is scaled to fit it, as screenshots are. */\n readonly viewport: Effect.Effect<Size, BrowserError>;\n readonly imageSize: (data: Uint8Array) => Size | undefined;\n readonly error: (cause: unknown) => BrowserError;\n}\n\ntype Envelope =\n | { readonly _tag: \"Frame\"; readonly sequence: number; readonly frame: Frame }\n | { readonly _tag: \"Failure\"; readonly error: BrowserError };\n\ninterface Held {\n readonly frame: Frame;\n readonly timestamp: number;\n}\n\n/** Consecutive frames of one device size other than the expected one, oldest first. */\ninterface Run {\n readonly device: Size;\n /** When its first frame arrived, on the owner's monotonic clock. */\n readonly since: number;\n readonly frames: Array<Held>;\n}\n\ninterface Generation {\n readonly subscribers: Set<Queue.Queue<Envelope>>;\n readonly transport: Transport;\n /** Stops handing the transport's frames to this generation. */\n unlisten: () => void;\n readonly calibration: Estimate;\n /** The native capture's settings; every reader of this generation shares them. */\n readonly quality: number;\n readonly size: Size | null;\n readonly onFrame: (frame: NativeFrame) => void;\n accepting: boolean;\n predecessor: number | undefined;\n failure: BrowserError | undefined;\n stopReply: Promise<void> | undefined;\n}\n\nexport interface Controller {\n readonly stream: (options?: ScreencastOptions) => Stream.Stream<Frame, BrowserError>;\n readonly latest: Effect.Effect<Option.Option<Frame>>;\n readonly recent: Effect.Effect<ReadonlyArray<Frame>>;\n /** Lifetime counts, or those of the latest `windowMillis`, at most `countsKept`. */\n readonly stats: (windowMillis?: number) => Effect.Effect<CaptureStats>;\n readonly active: Effect.Effect<boolean>;\n /** Once every frame the running capture's connection sent before now has arrived. */\n readonly sync: Effect.Effect<void, BrowserError>;\n /** Run a clipped or scaled picture of the page, keeping what it draws out of the capture. */\n readonly excluding: <A, E, R>(\n picture: Effect.Effect<A, E, R>,\n resized?: boolean,\n ) => Effect.Effect<A, E, R>;\n}\n\n/** When the library took a clipped picture: from its call to its reply, in host milliseconds. */\ninterface Excluded {\n readonly from: number;\n until: number;\n readonly resized: boolean;\n}\n\nconst replyCapacity = 32;\nconst subscriberCapacity = 16;\nconst deadline = Duration.seconds(2);\n\n// Device sizes can be fractional at some scale factors; the page reports whole pixels.\nconst sameSize = (left: Size, right: Size) =>\n Math.abs(left.width - right.width) < 1 && Math.abs(left.height - right.height) < 1;\n\n// A frame is its device scaled to fit, so it keeps the device's shape to within a pixel a side.\nconst sameShape = (image: Size, device: Size) =>\n Math.abs(image.width * device.height - image.height * device.width) <\n device.width + device.height;\n\n// Paint-time gaps between consecutive delivered frames.\nconst paintGaps = () => {\n let count = 0;\n let totalMillis = 0;\n let minMillis: number | null = null;\n let maxMillis: number | null = null;\n let lastMillis: number | null = null;\n\n return {\n add: (gap: number) => {\n count++;\n totalMillis += gap;\n minMillis = minMillis === null ? gap : Math.min(minMillis, gap);\n maxMillis = maxMillis === null ? gap : Math.max(maxMillis, gap);\n lastMillis = gap;\n },\n snapshot: () => ({ count, totalMillis, minMillis, maxMillis, lastMillis }),\n };\n};\n\nconst none = () => ({\n received: 0,\n accepted: 0,\n late: 0,\n missingTimestamp: 0,\n foreignSize: 0,\n duringPictures: 0,\n lost: 0,\n});\n\ntype Counted = keyof ReturnType<typeof none>;\n\n/** How far back a window of capture counts can reach. */\nexport const countsKept = Duration.minutes(1);\n\n/**\n * A capture's counts and paint gaps over its page's life, and each with when it happened on the\n * owner's clock for the latest minute, so a window of them can be read.\n */\nconst tally = (now: () => number) => {\n const totals = none();\n const gaps = paintGaps();\n\n let recent: Array<{\n readonly at: number;\n readonly counted: Counted | \"gap\";\n readonly n: number;\n }> = [];\n\n let oldest = 0;\n\n const note = (counted: Counted | \"gap\", n: number) => {\n const at = now();\n\n recent.push({ at, counted, n });\n while ((recent[oldest]?.at ?? at) < at - Duration.toMillis(countsKept)) oldest++;\n // Shed what is out of reach once it is half the log.\n if (oldest > recent.length / 2) {\n recent = recent.slice(oldest);\n oldest = 0;\n }\n };\n\n return {\n count: (counted: Counted, n = 1) => {\n totals[counted] += n;\n note(counted, n);\n },\n gap: (millis: number) => {\n gaps.add(millis);\n note(\"gap\", millis);\n },\n /** Lifetime counts, or those of the latest `windowMillis`, at most a minute. */\n read: (windowMillis?: number) => {\n if (windowMillis === undefined) return { ...totals, gaps: gaps.snapshot() };\n const counts = none();\n const windowed = paintGaps();\n const since = now() - windowMillis;\n\n for (const { at, counted, n } of recent.slice(oldest)) {\n if (at < since) continue;\n if (counted === \"gap\") windowed.add(n);\n else counts[counted] += n;\n }\n\n return { ...counts, gaps: windowed.snapshot() };\n },\n };\n};\n\n// Another capture's frames last only as long as it does; a run of frames that lasts longer is\n// the page's own.\nconst outlasting = Duration.seconds(1);\n\n// No frame painted during a picture arrives this long after it.\nconst excludedFor = Duration.seconds(10);\n\n// Every frame of a crop is painted before Chromium answers the picture, yet each test of it can\n// land past the reply: its stamp, because Chromium stamps frames on another clock than the one the\n// calibration reads (2 to 3 ms late on an idle machine here), and its arrival, because a frame is\n// encoded after it is painted (3 to 6 ms). A frame is kept only when both land this long after.\nconst settling = Duration.millis(50);\n\n/**\n * Chromium draws the library's own clipped pictures into the running screencast. Where Playwright\n * emulates the viewport they keep the page's device size, and its shape when the crop has the\n * viewport's proportions, so nothing in a frame tells them apart: a frame painted, or arriving,\n * while one is taken is left out, the page's own included. A crop on the page's own session is\n * drawn at the crop's size, so there only a frame of another size than the page's is left out.\n */\nconst pictureWindows = (now: () => number) => {\n let windows: ReadonlyArray<Excluded> = [];\n\n return {\n drawn: ({ hostTime, timing, receivedAt }: Frame, foreign: boolean) =>\n windows.some((window) => {\n const until = window.until + Duration.toMillis(settling);\n\n return (\n (foreign || !window.resized) &&\n ((hostTime + timing.uncertaintyMillis >= window.from &&\n hostTime - timing.uncertaintyMillis <= until) ||\n (receivedAt >= window.from && receivedAt <= until))\n );\n }),\n excluding: <A, E, R>(picture: Effect.Effect<A, E, R>, resized = false) =>\n Effect.acquireUseRelease(\n Effect.sync(() => {\n const window = { from: now(), until: Number.POSITIVE_INFINITY, resized };\n const since = window.from - Duration.toMillis(excludedFor);\n\n windows = [...windows.filter((kept) => kept.until > since), window];\n\n return window;\n }),\n () => picture,\n (window) =>\n Effect.sync(() => {\n window.until = now();\n }),\n ),\n };\n};\n\n/**\n * A native frame as readers get it: its picture's size, else the capture's or its device's, and\n * its paint mapped by the browser's newest estimate, which may be older than the frame and says\n * less about later paint.\n */\nconst timed = (\n options: Options,\n native: NativeFrame,\n timestamp: number,\n generation: Pick<Generation, \"calibration\" | \"size\" | \"transport\">,\n) => {\n const data = Buffer.from(native.data, \"base64\");\n const image = options.imageSize(data);\n const device = { width: native.metadata.deviceWidth, height: native.metadata.deviceHeight };\n const size = image ?? generation.size ?? device;\n const estimate = options.latest() ?? generation.calibration;\n const hostTime = toHostTime(estimate, timestamp);\n\n const frame = new Frame({\n page: options.id,\n data,\n timing: new BrowserPaint({\n timestamp,\n hostTime,\n uncertaintyMillis: uncertaintyAt(estimate, hostTime),\n }),\n receivedAt: Number(options.clock.monotonicTimeNanosUnsafe()) / 1e6,\n width: size.width,\n height: size.height,\n ...generation.transport.frameTag(),\n });\n\n return { frame, image, device };\n};\n\n// A page too busy to report its viewport in time reads as null.\nconst readViewport = (options: Options) =>\n options.viewport.pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({ duration: deadline, orElse: () => Effect.succeed(null) }),\n Effect.orElseSucceed(() => null),\n Effect.provideService(Clock.Clock, options.clock),\n );\n\n/**\n * What a new capture starts with: where it runs, the clock's estimate, and the viewport unless\n * the reader gave a size. A capture connection attaches while the page's own session maps the\n * clock, and a page too busy to report its viewport is still captured, at device size.\n */\nconst prepare = (options: Options, screencast: ScreencastOptions) =>\n Effect.all(\n [\n options.transport.pipe(Effect.interruptible),\n Effect.gen(function* () {\n const calibration = yield* options.calibrate.pipe(Effect.interruptible);\n const viewport = screencast.size === undefined ? yield* readViewport(options) : null;\n\n return { calibration, viewport };\n }),\n ],\n { concurrency: 2 },\n );\n\n/**\n * Keeps other captures' frames from readers. A clipped or scaled screenshot of the page, taken\n * from any session, draws frames into its running screencast without resizing the page, until\n * Chromium returns to the page's size. Either their picture has another shape than their device,\n * and they are dropped, or their device has another size than the page's frames.\n *\n * A frame of the expected device size goes to readers at once and drops any run of frames of\n * another size before it, as another capture's. A run waits, in order, until the page reports a\n * viewport of its size or until it outlasts any capture: then it was a real resize, so it goes to\n * readers and its size is expected. The page's report only shortens the wait, so a page too busy\n * to answer, or one measuring in other units as under browser zoom, never stalls the stream.\n */\nconst sizeFilter = (\n options: Options,\n deliver: (frame: Frame, timestamp: number) => void,\n drop: (frames: number) => void,\n) =>\n Effect.gen(function* () {\n // Until a capture reads its viewport or delivers a frame, its first frame stands in.\n let expected: Size | null = null;\n let run: Run | undefined;\n // Wakes the decider for a new run or an ended one; wakes while it is busy coalesce.\n const wake = yield* Queue.sliding<void>(1);\n\n const end = () => {\n if (run === undefined) return;\n drop(run.frames.length);\n run = undefined;\n Queue.offerUnsafe(wake, undefined);\n };\n\n const now = () => Number(options.clock.monotonicTimeNanosUnsafe()) / 1e6;\n\n const adopt = (adopted: Run) => {\n run = undefined;\n expected = adopted.device;\n for (const held of adopted.frames) deliver(held.frame, held.timestamp);\n };\n\n const decide: Effect.Effect<void> = Effect.suspend(() => {\n const deciding = run;\n\n if (deciding === undefined) return Effect.void;\n\n return readViewport(options).pipe(\n Effect.flatMap((viewport) => {\n if (run !== deciding) return decide;\n if (viewport !== null && sameSize(viewport, deciding.device))\n return Effect.sync(() => adopt(deciding));\n\n return outlast(deciding);\n }),\n );\n });\n\n // Waits until the run outlasts any capture, unless a newer frame decides it first.\n const outlast = (waiting: Run): Effect.Effect<void> =>\n Effect.suspend(() => {\n if (run !== waiting) return decide;\n const remaining = waiting.since + Duration.toMillis(outlasting) - now();\n\n if (remaining <= 0) return Effect.sync(() => adopt(waiting));\n\n return Effect.sleep(Duration.millis(remaining)).pipe(\n Effect.provideService(Clock.Clock, options.clock),\n Effect.race(Queue.take(wake)),\n Effect.andThen(outlast(waiting)),\n );\n });\n\n yield* Queue.take(wake).pipe(Effect.andThen(decide), Effect.forever, Effect.forkScoped);\n\n return {\n /** Drops the frames still waiting; their capture has stopped. */\n end,\n /** A new capture expects the viewport it read, if any. */\n restart: (viewport: Size | null) => {\n end();\n expected = viewport;\n },\n /** Whether a frame of this device size shows the page, as far as the capture knows. */\n expects: (device: Size) => expected !== null && sameSize(device, expected),\n offer: (frame: Frame, timestamp: number, image: Size | undefined, device: Size) => {\n if (image !== undefined && !sameShape(image, device)) {\n drop(1);\n\n return;\n }\n expected ??= device;\n if (sameSize(device, expected)) {\n end();\n deliver(frame, timestamp);\n\n return;\n }\n if (run !== undefined && !sameSize(run.device, device)) end();\n if (run === undefined) {\n run = { device, since: now(), frames: [] };\n Queue.offerUnsafe(wake, undefined);\n }\n run.frames.push({ frame, timestamp });\n if (run.frames.length > subscriberCapacity) {\n run.frames.shift();\n drop(1);\n }\n },\n };\n });\n\n/**\n * A running capture's failure, told once its page's fate is known. A capture can fail before the\n * page's own session hears why: a capture connection hears the browser's end before the connection\n * that drives the page does, and an acknowledgement can be refused before the browser's loss is\n * known. So the failure waits for the page's scope to close, `closed`, and is then the page's own\n * end or its browser's loss, as `gone` reads it; or, if the page still stands after `deadline`,\n * the capture's own.\n */\nconst told =\n (closed: Deferred.Deferred<void>, gone: () => BrowserError, clock: Clock.Clock) =>\n (failure: BrowserError) =>\n Deferred.await(closed).pipe(\n Effect.map(gone),\n Effect.timeoutOrElse({ duration: deadline, orElse: () => Effect.succeed(failure) }),\n Effect.provideService(Clock.Clock, clock),\n Effect.flatMap(Effect.fail),\n );\n\n/**\n * Once every frame the running capture's transport sent before now has arrived; a capture that\n * has failed, or whose round trip fails, fails as `why` tells it.\n */\nconst synced = (\n current: Generation | undefined,\n why: (failure: BrowserError) => Effect.Effect<never, BrowserError>,\n error: (cause: unknown) => BrowserError,\n): Effect.Effect<void, BrowserError> => {\n if (current === undefined) return Effect.void;\n if (current.failure !== undefined) return why(current.failure);\n\n return Effect.tryPromise({ try: () => current.transport.sync(), catch: error }).pipe(\n Effect.catch(why),\n Effect.asVoid,\n );\n};\n\nexport const make = (options: Options) =>\n Effect.gen(function* () {\n const lock = yield* Semaphore.make(1);\n const replies = new Set<Promise<void>>();\n let generation: Generation | undefined;\n // Done as the page's scope closes, once the page has gone and its browser's loss, if any, is\n // known.\n const closed = yield* Deferred.make<void>();\n // The latest stop whose reply has not settled. A new capture waits for it rather than\n // assuming it was lost; it is never submitted again.\n let unsettledStop: Promise<void> | undefined;\n let latest = Option.none<Frame>();\n let history: ReadonlyArray<Frame> = [];\n const keepMillis = Duration.toMillis(options.frameHistory);\n const now = () => Number(options.clock.monotonicTimeNanosUnsafe()) / 1e6;\n const counts = tally(now);\n // Frames delivered, which number them so that a reader can tell what it missed.\n let delivered = 0;\n const pictures = pictureWindows(now);\n\n // Frames that show the page go to the running capture's readers.\n const deliver = (frame: Frame, timestamp: number) => {\n const current = generation;\n\n if (current === undefined) return;\n // Held frames are checked again: frames encoded out of order are dropped, never reordered.\n if (current.predecessor !== undefined && timestamp <= current.predecessor)\n return counts.count(\"late\");\n if (current.predecessor !== undefined) counts.gap(timestamp - current.predecessor);\n current.predecessor = timestamp;\n delivered++;\n counts.count(\"accepted\");\n latest = Option.some(frame);\n history = [...history.filter((kept) => kept.hostTime >= frame.hostTime - keepMillis), frame];\n for (const subscriber of current.subscribers)\n Queue.offerUnsafe(subscriber, { _tag: \"Frame\", sequence: delivered, frame });\n };\n\n const sizes = yield* sizeFilter(options, deliver, (frames) =>\n counts.count(\"foreignSize\", frames),\n );\n\n // On air a capture runs for hours, and its frames are timed by the browser's newest estimate,\n // so arriving frames renew it: a check at most each second, a measurement once it is due.\n const renewing = yield* Queue.sliding<void>(1);\n\n yield* Queue.take(renewing).pipe(\n Effect.andThen(options.renew),\n Effect.andThen(Effect.sleep(Duration.seconds(1))),\n Effect.provideService(Clock.Clock, options.clock),\n Effect.forever,\n Effect.forkScoped,\n );\n\n const notifyFailure = (current: Generation, failure: BrowserError) => {\n if (current.failure !== undefined) return;\n current.failure = failure;\n for (const subscriber of current.subscribers)\n Queue.offerUnsafe(subscriber, { _tag: \"Failure\", error: failure });\n };\n\n const stop = (current: Generation) => {\n if (!current.accepting) return;\n current.accepting = false;\n sizes.end();\n current.unlisten();\n\n // Attach both handlers in the callback turn. Even a caller that leaves immediately never\n // abandons a rejected native reply, and an uncertain stop is never submitted twice.\n const reply = current.transport.stop().then(\n () => undefined,\n (cause: unknown) => {\n notifyFailure(current, options.error(cause));\n },\n );\n\n current.stopReply = reply;\n unsettledStop = reply;\n void reply.then(() => {\n if (unsettledStop === reply) unsettledStop = undefined;\n });\n };\n\n const fail = (current: Generation, failure: BrowserError) => {\n notifyFailure(current, failure);\n stop(current);\n };\n\n const gone = () => options.error(new Error(\"Target page has been closed\"));\n const stopDeadline = () => options.error(new Error(\"screencast stop exceeded its deadline\"));\n const why = told(closed, gone, options.clock);\n\n // A stop's reply, awaited for at most `deadline`; `late` is what a stop past it means.\n const settled = <E>(reply: () => Promise<void> | undefined, late: Effect.Effect<void, E>) =>\n Effect.suspend(() => {\n const pending = reply();\n\n return pending === undefined\n ? Effect.void\n : Effect.promise(() => pending).pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({ duration: deadline, orElse: () => late }),\n );\n }).pipe(Effect.provideService(Clock.Clock, options.clock));\n\n const awaitStop = (current: Generation) =>\n settled(\n () => current.stopReply,\n Effect.sync(() => notifyFailure(current, stopDeadline())),\n );\n\n // A late stop only delays the next capture; once its reply settles, capture can start again.\n const awaitPreviousStop = settled(() => unsettledStop, Effect.fail(stopDeadline()));\n\n // A reader leaves; the last one stops its generation.\n const leave = (current: Generation, subscription: Queue.Queue<Envelope>) =>\n Effect.gen(function* () {\n current.subscribers.delete(subscription);\n yield* Queue.shutdown(subscription);\n if (current.subscribers.size !== 0) return;\n yield* Effect.sync(() => stop(current));\n yield* awaitStop(current);\n if (generation === current) generation = undefined;\n });\n\n const acquire = (screencast: ScreencastOptions) =>\n lock.withPermits(1)(\n Effect.gen(function* () {\n if (Deferred.isDoneUnsafe(closed)) return yield* gone();\n let current = generation;\n const starting = current === undefined;\n\n if (current === undefined) {\n yield* awaitPreviousStop;\n const [transport, { calibration, viewport }] = yield* prepare(options, screencast);\n const size = screencast.size ?? viewport;\n\n if (Deferred.isDoneUnsafe(closed)) return yield* gone();\n\n const created: Generation = {\n subscribers: new Set(),\n transport,\n unlisten: () => undefined,\n calibration,\n quality: screencast.quality ?? 80,\n size,\n accepting: true,\n predecessor: undefined,\n failure: undefined,\n stopReply: undefined,\n onFrame: (native) => {\n if (!created.accepting) return;\n counts.count(\"received\");\n if (replies.size >= replyCapacity) {\n fail(\n created,\n options.error(new Error(\"screencast acknowledgement capacity exceeded\")),\n );\n\n return;\n }\n\n const reply = created.transport.acknowledge(native.sessionId).then(\n () => {\n replies.delete(reply);\n },\n (cause: unknown) => {\n replies.delete(reply);\n if (created.accepting) fail(created, options.error(cause));\n },\n );\n\n replies.add(reply);\n const browserSeconds = native.metadata.timestamp;\n const timestamp = browserSeconds === undefined ? Number.NaN : browserSeconds * 1000;\n\n if (!Number.isFinite(timestamp)) return counts.count(\"missingTimestamp\");\n if (created.predecessor !== undefined && timestamp <= created.predecessor)\n return counts.count(\"late\");\n Queue.offerUnsafe(renewing, undefined);\n const { frame, image, device } = timed(options, native, timestamp, created);\n\n if (pictures.drawn(frame, !sizes.expects(device)))\n return counts.count(\"duringPictures\");\n sizes.offer(frame, timestamp, image, device);\n },\n };\n\n current = created;\n generation = current;\n latest = Option.none();\n sizes.restart(viewport);\n } else if (\n (screencast.quality !== undefined && screencast.quality !== current.quality) ||\n (screencast.size !== undefined &&\n (screencast.size.width !== current.size?.width ||\n screencast.size.height !== current.size.height))\n )\n // One native capture serves every reader; silently giving a reader other settings\n // than it asked for would misstate its frames.\n return yield* undispatched(\n \"screencast\",\n new InvalidRequest({\n detail: `a screencast with quality ${current.quality}${\n current.size === null\n ? \"\"\n : ` and size ${current.size.width}x${current.size.height}`\n } is already running on this page; read it without options or with the same ones`,\n }),\n );\n // The callback API must apply sliding synchronously; PubSub.publishUnsafe skips it.\n const subscription = yield* Queue.sliding<Envelope>(subscriberCapacity);\n\n current.subscribers.add(subscription);\n // A reader that joins a capture that has failed is told as its other readers are.\n if (current.failure !== undefined)\n Queue.offerUnsafe(subscription, { _tag: \"Failure\", error: current.failure });\n const baseline = delivered;\n\n if (starting) {\n const { transport, quality, size } = current;\n const listening = current;\n\n current.unlisten = transport.listen({\n frame: current.onFrame,\n lost: (error) => fail(listening, error),\n });\n\n const screencast = Effect.tryPromise({\n try: () =>\n transport.start({\n format: \"jpeg\",\n quality,\n ...(size === null ? {} : { maxWidth: size.width, maxHeight: size.height }),\n }),\n catch: options.error,\n });\n\n const started = yield* Effect.all([options.watch, screencast], {\n concurrency: 2,\n }).pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({\n duration: deadline,\n orElse: () =>\n Effect.fail(options.error(new Error(\"screencast start exceeded its deadline\"))),\n }),\n Effect.provideService(Clock.Clock, options.clock),\n Effect.exit,\n );\n\n if (Exit.isFailure(started)) {\n yield* leave(current, subscription);\n\n return yield* Effect.failCause(started.cause);\n }\n }\n\n return { current, subscription, baseline };\n }),\n );\n\n const stream: Controller[\"stream\"] = (screencast = {}) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const lease = yield* Effect.acquireRelease(\n acquire(screencast),\n ({ current, subscription }) => lock.withPermits(1)(leave(current, subscription)),\n );\n\n let previous = lease.baseline;\n\n // Pull one envelope at a time so taking a stream chunk cannot hide a slow reader's loss.\n return Stream.fromEffectRepeat(\n Queue.take(lease.subscription).pipe(\n Effect.flatMap((envelope) => {\n if (envelope._tag === \"Failure\") return why(envelope.error);\n\n return Effect.sync(() => {\n if (envelope.sequence > previous + 1)\n counts.count(\"lost\", envelope.sequence - previous - 1);\n previous = envelope.sequence;\n\n return envelope.frame;\n });\n }),\n ),\n );\n }),\n );\n\n // The page's scope closes once the page has gone, when its browser's loss, if any, is known.\n yield* Effect.addFinalizer(() =>\n lock.withPermits(1)(\n Effect.suspend(() => {\n const current = generation;\n\n Deferred.doneUnsafe(closed, Exit.void);\n if (current === undefined) return Effect.void;\n fail(current, gone());\n\n return awaitStop(current);\n }),\n ),\n );\n\n return {\n stream,\n latest: Effect.sync(() => latest),\n recent: Effect.sync(() => history),\n active: Effect.sync(() => generation?.accepting === true),\n sync: Effect.suspend(() => synced(generation, why, options.error)),\n excluding: pictures.excluding,\n stats: (windowMillis?: number) =>\n Effect.sync(\n () => new CaptureStats({ ...counts.read(windowMillis), ackBacklog: replies.size }),\n ),\n } satisfies Controller;\n });\n","/**\n * Where a page's screencast runs: on the page's own session, or on a capture connection that the\n * provider supplies, where frames and their acknowledgements never wait behind a large message on\n * the connection that drives the page. There the page's session attaches as its first capture\n * starts, with the Page domain on, and stays until the page closes or the session ends; the next\n * capture then attaches again.\n *\n * Frames take their document from the commits their own session reports, in the order the browser\n * sent them, so a frame never shows a document after the one it carries, as on the page's own\n * session. They are numbered as the page's own session counts documents: a commit it has counted\n * keeps its number, and one the capture connection sees first takes the next, until it is counted.\n */\nimport { Effect, Exit, Option, Schema, Scope } from \"effect\";\n\nimport type { CaptureSource } from \"../../Browser.ts\";\nimport { type BrowserError, Failed } from \"../../BrowserError.ts\";\nimport { type Bridge, Commit, commitOf, mainFrame, MainFrameEvent } from \"../page/bridge.ts\";\nimport { type PageContext, undispatched } from \"../page/context.ts\";\n\n/** Where a capture's screencast runs. Its calls never throw: a failure rejects. */\nexport interface Transport {\n readonly start: (settings: {\n readonly format: \"jpeg\";\n readonly quality: number;\n readonly maxWidth?: number;\n readonly maxHeight?: number;\n }) => Promise<unknown>;\n readonly acknowledge: (frame: number) => Promise<unknown>;\n readonly stop: () => Promise<unknown>;\n /**\n * A round trip whose answer comes behind every frame sent before it. On the page's own session,\n * the page's own calls are such round trips already, so it sends nothing.\n */\n readonly sync: () => Promise<unknown>;\n /**\n * Hand its frames to `on.frame` as they arrive, and its end to `on.lost` should it end, until\n * the returned function is called.\n */\n readonly listen: (on: {\n readonly frame: (frame: NativeFrame) => void;\n readonly lost: (error: BrowserError) => void;\n }) => () => void;\n /** What a frame arriving now shows: its session, the document it followed and the address then. */\n readonly frameTag: () => {\n readonly session: string;\n readonly document: number;\n readonly url: string;\n };\n}\n\n/** The page's own session. */\nexport const own = (page: PageContext, bridge: Bridge): Transport => {\n const { send } = page.protocol;\n\n return {\n start: (settings) => send(\"Page.startScreencast\", settings),\n acknowledge: (frame) => send(\"Page.screencastFrameAck\", { sessionId: frame }),\n stop: () => send(\"Page.stopScreencast\"),\n sync: () => Promise.resolve(),\n listen: ({ frame }) => {\n page.cdp.on(\"Page.screencastFrame\", frame);\n\n return () => {\n page.cdp.off(\"Page.screencastFrame\", frame);\n };\n },\n frameTag: bridge.frameTag,\n };\n};\n\nconst FrameTree = Schema.Struct({ frameTree: Schema.Struct({ frame: Commit }) });\n\n/** A native screencast frame, as Chromium sends it. */\nconst ScreencastFrame = Schema.Struct({\n data: Schema.String,\n sessionId: Schema.Int,\n metadata: Schema.Struct({\n timestamp: Schema.optionalKey(Schema.Finite),\n deviceWidth: Schema.Finite,\n deviceHeight: Schema.Finite,\n }),\n});\n\nexport type NativeFrame = typeof ScreencastFrame.Type;\n\n/**\n * The document and address a capture connection's frames show, from the commits its session\n * reports after `first`, the main frame's document as the session began.\n */\nconst documents = (bridge: Bridge, first: ReturnType<typeof commitOf>) => {\n // The number the page's own session gave the latest commit of `loader`, if it has counted one.\n const counted = (loader: string) => bridge.documentOf(loader) ?? -1;\n const latest = bridge.frameTag().document;\n\n // A loader the page's own session hasn't counted began the document it had from the start, or\n // a commit still on its way to it.\n const shown = {\n ...first,\n document: counted(first.loader) >= 0 ? counted(first.loader) : latest === 0 ? 0 : latest + 1,\n };\n\n return {\n /** A commit or a move the session reported, in the order the browser sent them. */\n see: (seen: ReturnType<typeof mainFrame>) => {\n if (seen?.loader !== undefined) {\n shown.document = Math.max(shown.document + 1, counted(seen.loader));\n shown.loader = seen.loader;\n }\n if (seen !== undefined) shown.url = seen.url;\n },\n tag: () => {\n shown.document = Math.max(shown.document, counted(shown.loader));\n\n return { document: shown.document, url: shown.url };\n },\n };\n};\n\ntype State =\n | { readonly _tag: \"Detached\" }\n | { readonly _tag: \"Attaching\"; readonly scope: Scope.Closeable }\n | { readonly _tag: \"Attached\"; readonly scope: Scope.Closeable; readonly transport: Transport }\n | { readonly _tag: \"Ended\"; readonly scope: Scope.Closeable; readonly error: BrowserError };\n\n/**\n * The page's session on the capture connection, attached when a capture asks for it and kept for\n * the page's scope. Its state changes only here: attaching, attached, or ended by the session's\n * end, which also ends the capture listening to it.\n */\nexport const apart = (\n page: PageContext,\n bridge: Bridge,\n source: CaptureSource,\n error: (cause: unknown) => BrowserError,\n pageScope: Scope.Scope,\n): Effect.Effect<Transport, BrowserError> => {\n let state: State = { _tag: \"Detached\" };\n let listening: Parameters<Transport[\"listen\"]>[0] | undefined;\n const latest = (): State => state;\n\n const end = (scope: Scope.Closeable, ended: BrowserError) => {\n if ((state._tag !== \"Attaching\" && state._tag !== \"Attached\") || state.scope !== scope) return;\n const attached = state._tag === \"Attached\";\n\n state = { _tag: \"Ended\", scope, error: ended };\n if (attached) listening?.lost(ended);\n };\n\n const unreadable = undispatched(\n \"screencast\",\n new Failed({ detail: \"the capture connection sent an event it could not read\" }),\n );\n\n const attach = (scope: Scope.Closeable) =>\n Effect.gen(function* () {\n let shown: ReturnType<typeof documents> | undefined;\n\n // Commits before the frame tree's answer are in it already.\n const event = (method: string, params: unknown) => {\n const decoded = <A>(schema: Schema.Codec<A, unknown>, act: (value: A) => void) =>\n Option.match(Schema.decodeUnknownOption(schema)(params), {\n onNone: () => end(scope, unreadable),\n onSome: act,\n });\n\n if (method === \"Page.screencastFrame\")\n decoded(ScreencastFrame, (frame: NativeFrame) => listening?.frame(frame));\n else if (method === \"Page.frameNavigated\" || method === \"Page.navigatedWithinDocument\")\n decoded(MainFrameEvent, (event) => shown?.see(mainFrame(page.id, event)));\n else if (method === \"Target.detachedFromTarget\")\n end(scope, error(new Error(\"Target page has been closed\")));\n };\n\n const send = yield* source.attach(page.id, { event, lost: (lost) => end(scope, lost) });\n\n // Tracked from the frame tree's answer on, set as it arrives so that no commit after it is\n // missed.\n const tracked = yield* Effect.tryPromise({\n try: () =>\n Promise.all([send(\"Page.enable\"), send(\"Page.getFrameTree\")]).then(([, tree]) =>\n Option.match(Schema.decodeUnknownOption(FrameTree)(tree), {\n onNone: () => Promise.reject(unreadable),\n onSome: ({ frameTree }) => (shown = documents(bridge, commitOf(frameTree.frame))),\n }),\n ),\n catch: error,\n });\n\n return {\n start: (settings) => send(\"Page.startScreencast\", settings),\n acknowledge: (frame) => send(\"Page.screencastFrameAck\", { sessionId: frame }),\n stop: () => send(\"Page.stopScreencast\"),\n sync: () => send(\"Page.getFrameTree\"),\n listen: (on) => {\n listening = on;\n\n return () => {\n if (listening === on) listening = undefined;\n };\n },\n frameTag: () => ({ session: page.session, ...tracked.tag() }),\n } satisfies Transport;\n }).pipe(Scope.provide(scope));\n\n const current: Effect.Effect<Transport, BrowserError> = Effect.suspend(() => {\n switch (state._tag) {\n case \"Attached\":\n return Effect.succeed(state.transport);\n case \"Ended\": {\n const { scope } = state;\n\n state = { _tag: \"Detached\" };\n\n return Scope.close(scope, Exit.void).pipe(Effect.andThen(current));\n }\n case \"Detached\":\n case \"Attaching\":\n return Effect.gen(function* () {\n const scope = yield* Scope.fork(pageScope);\n\n state = { _tag: \"Attaching\", scope };\n const attached = yield* Effect.exit(attach(scope).pipe(page.within(\"screencast\")));\n // `end` may have changed it meanwhile.\n const settled = latest();\n\n // A session that ended as it attached is never handed out.\n if (Exit.isSuccess(attached) && settled._tag === \"Attaching\" && settled.scope === scope) {\n state = { _tag: \"Attached\", scope, transport: attached.value };\n\n return attached.value;\n }\n state = { _tag: \"Detached\" };\n yield* Scope.close(scope, Exit.void);\n if (Exit.isFailure(attached)) return yield* attached;\n\n return yield* settled._tag === \"Ended\" ? settled.error : unreadable;\n });\n }\n });\n\n return current;\n};\n","/**\n * Pictures of a page: screenshots, frames of a stated age, zooms, and its screencast with the clock\n * that times its frames. A new picture is taken on the page's own protocol session, one at a time:\n * one call where a device pixel is a CSS pixel and nothing is cropped, and two otherwise, unless\n * Playwright emulates the viewport. The page's first clipped picture also holds the screen it reads.\n */\nimport { Duration, Effect, Option, Schedule, Schema, Semaphore } from \"effect\";\n\nimport { BrowserError, Failed, InvalidRequest } from \"../../BrowserError.ts\";\nimport { Frame, Image, Screenshot } from \"../../Frame.ts\";\nimport { type FrameOptions, Region, type ScreenshotOptions, Zoom } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { decodeWith, failWith, type PageContext, reasonOf, undispatched } from \"../page/context.ts\";\nimport type { Viewport } from \"../page/viewport.ts\";\nimport * as Capture from \"./capture.ts\";\nimport * as BrowserClock from \"./clock.ts\";\nimport * as Transport from \"./transport.ts\";\n\n/** Read a JPEG's dimensions from its start-of-frame marker. */\nexport const jpegSize = (bytes: Uint8Array): Capture.Size | undefined => {\n let offset = 2;\n\n while (offset + 9 < bytes.length) {\n if (bytes[offset] !== 0xff) return undefined;\n const marker = bytes[offset + 1] ?? 0;\n const length = ((bytes[offset + 2] ?? 0) << 8) | (bytes[offset + 3] ?? 0);\n\n if (marker >= 0xc0 && marker <= 0xc3)\n return {\n height: ((bytes[offset + 5] ?? 0) << 8) | (bytes[offset + 6] ?? 0),\n width: ((bytes[offset + 7] ?? 0) << 8) | (bytes[offset + 8] ?? 0),\n };\n offset += 2 + length;\n }\n\n return undefined;\n};\n\n/** Read a PNG's dimensions from its header chunk. */\nexport const pngSize = (bytes: Uint8Array): Capture.Size | undefined => {\n if (bytes.length < 24 || bytes[1] !== 0x50 || bytes[2] !== 0x4e || bytes[3] !== 0x47)\n return undefined;\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n return { width: view.getUint32(16), height: view.getUint32(20) };\n};\n\n/** The format a new picture is taken in. */\nexport type Format = \"jpeg\" | \"png\";\n\n// The part of `Page.getLayoutMetrics` a clip needs: the visual viewport's place in the document and\n// its pinch scale, and the content's size in device and CSS pixels, whose ratio is the device's.\nconst LayoutMetrics = Schema.Struct({\n cssVisualViewport: Schema.Struct({\n pageX: Schema.Finite,\n pageY: Schema.Finite,\n scale: Schema.Finite.check(Schema.isGreaterThan(0)),\n }),\n contentSize: Schema.Struct({ width: Schema.Finite }),\n cssContentSize: Schema.Struct({ width: Schema.Finite }),\n});\n\n// A screencast frame shows the page as it was when it was painted, and a new picture costs a round\n// trip, so by default a frame painted this recently is reused.\nconst defaultMaxAge = Duration.millis(250);\n\n// Chromium answers this while the page has no surface to copy yet, as just after a navigation. The\n// page has one from its first frame, so the picture is taken again a frame later, within the\n// picture's own deadline.\nconst surfaceless = (error: BrowserError) =>\n error.reason._tag === \"Failed\" && error.reason.detail.includes(\"Unable to capture screenshot\");\n\nconst untilPainted = <A, R>(capture: Effect.Effect<A, BrowserError, R>) =>\n capture.pipe(Effect.retry({ while: surfaceless, schedule: Schedule.spaced(\"16 millis\") }));\n\n/**\n * Measure this page's clock against the browser's, in a world without the page script: no DOM\n * markers, input, navigation or extra tabs. Each of three probes reads the browser's time between\n * two stamps of the owner's clock, and the fastest bounds the offset best. A busy page answers each\n * probe late, behind its own work, so the probes that answered within two seconds serve, and the\n * measurement fails only if none did: a wide estimate keeps a capture going, and a renewal while\n * its frames flow narrows it.\n */\nconst calibrator = (page: PageContext, bridge: Bridge) => {\n const { native, now, within } = page;\n const { send } = page.protocol;\n\n // A round trip to the page like any other read, so traced as one.\n const probe = (contextId: number) =>\n Effect.gen(function* () {\n const hostStart = now();\n\n const { result, exceptionDetails } = yield* native(\"calibrate\", () =>\n send(\"Runtime.evaluate\", {\n contextId,\n expression: \"performance.timeOrigin + performance.now()\",\n returnByValue: true,\n }),\n ).pipe(page.span(\"Page.evaluate\", { function: \"clock\" }, \"Trace\"));\n\n const hostEnd = now();\n const browserTime: unknown = result.value;\n\n if (exceptionDetails !== undefined || typeof browserTime !== \"number\")\n return yield* failWith(\n \"calibrate\",\n new Failed({ detail: \"the browser clock probe did not return a timestamp\" }),\n );\n\n return { hostStart, hostEnd, browserTime };\n });\n\n const answered = (contextId: number) =>\n Effect.gen(function* () {\n const probes: Array<BrowserClock.Probe> = [];\n\n yield* Effect.forEach(\n [1, 2, 3],\n () => Effect.map(probe(contextId), (one) => probes.push(one)),\n {\n discard: true,\n },\n ).pipe(\n within(\"calibrate\", Duration.seconds(2)),\n Effect.catch((error) => (probes.length === 0 ? Effect.fail(error) : Effect.void)),\n );\n\n return probes;\n });\n\n return bridge.bareWorld(\"calibrate\").pipe(\n Effect.flatMap(answered),\n Effect.flatMap((probes) =>\n Option.match(BrowserClock.estimate(probes), {\n onNone: () =>\n failWith(\n \"calibrate\",\n new Failed({ detail: \"the browser clock probes did not define a finite interval\" }),\n ),\n onSome: Effect.succeed,\n }),\n ),\n within(\"calibrate\", Duration.seconds(4)),\n // The fastest probe's round trip: the transport's, plus a trivial script.\n Effect.tap((estimate) =>\n Effect.annotateCurrentSpan(\"roundTripMillis\", Math.round(estimate.roundTripMillis * 10) / 10),\n ),\n page.span(\"Page.calibrateClock\", {}, \"Debug\"),\n page.owned,\n );\n};\n\n// The screen as the page reads it.\nconst ScreenSize = Schema.Struct({ width: Schema.Int, height: Schema.Int });\n\n// A new picture in CSS pixels. Where a device pixel is not a CSS pixel, or for a crop, it is\n// Playwright's clip over fresh layout metrics: document coordinates from the visual viewport's\n// place, and its pinch scale divided by the device's. Chromium draws such a capture into a\n// running screencast, so the capture leaves out what is painted meanwhile.\n//\n// Chromium takes a clipped picture through the device emulation of the session that asks for it,\n// then restores the view's size and what that session emulated. The page's own session emulated\n// nothing, so its crops cleared a screen another session emulates, as Browserbase's own does: so\n// before its first clipped picture, it holds a copy of the screen the page reads, which every later\n// picture restores. And a picture taken during another would restore the other's clip, so they go\n// one at a time.\nconst camera = (\n page: PageContext,\n bridge: Bridge,\n viewport: Viewport,\n capture: Capture.Controller,\n) => {\n const { playwright, settings, native, within } = page;\n const { send } = page.protocol;\n const actionMillis = Duration.toMillis(settings.actionTimeout);\n // Device pixels per CSS pixel, as the page's layout metrics last gave it. A picture taken in one\n // call is checked by its size, so a page whose ratio changes is measured again.\n let ratio = 1;\n const alone = Semaphore.makeUnsafe(1).withPermits(1);\n let screenHeld = false;\n\n // The copy has the screen alone: the view keeps its own size, and the device its pixel ratio.\n const holdScreen = (operation: string) =>\n Effect.suspend(() =>\n screenHeld\n ? Effect.void\n : bridge.evaluate(operation, scriptCall(\"screenSize\")).pipe(\n Effect.flatMap(decodeWith(operation, ScreenSize)),\n Effect.flatMap(({ width, height }) =>\n native(operation, () =>\n send(\"Emulation.setDeviceMetricsOverride\", {\n width: 0,\n height: 0,\n deviceScaleFactor: 0,\n mobile: false,\n screenWidth: width,\n screenHeight: height,\n }),\n ).pipe(alone),\n ),\n Effect.andThen(\n Effect.sync(() => {\n screenHeld = true;\n }),\n ),\n ),\n );\n\n const decoded = (operation: string, data: Uint8Array, format: Format) => {\n const size = format === \"png\" ? pngSize(data) : jpegSize(data);\n\n return size === undefined\n ? failWith(\n operation,\n new Failed({ detail: `the browser's picture is not a ${format.toUpperCase()}` }),\n )\n : Effect.succeed(new Image({ data, mediaType: `image/${format}`, ...size }));\n };\n\n const shot = (\n operation: string,\n format: Format,\n quality: number,\n clip?: Capture.Size & { readonly x: number; readonly y: number; readonly scale: number },\n ) =>\n native(operation, () =>\n send(\"Page.captureScreenshot\", {\n format,\n ...(format === \"jpeg\" ? { quality } : {}),\n ...(clip === undefined ? {} : { clip }),\n }),\n ).pipe(\n alone,\n untilPainted,\n Effect.flatMap(({ data }) => decoded(operation, Buffer.from(data, \"base64\"), format)),\n );\n\n // Playwright's own picture, taken on the session where it emulates the viewport.\n const emulatedShot = (operation: string, format: Format, quality: number, crop?: Region) =>\n native(\n operation,\n () =>\n playwright.screenshot({\n type: format,\n ...(format === \"jpeg\" ? { quality } : {}),\n scale: \"css\",\n timeout: actionMillis,\n ...(crop === undefined ? {} : { clip: crop }),\n }),\n actionMillis,\n ).pipe(\n alone,\n untilPainted,\n Effect.flatMap((data) => decoded(operation, data, format)),\n );\n\n return (operation: string, quality: number, crop?: Region, format: Format = \"jpeg\") =>\n Effect.gen(function* () {\n const known = viewport.knownViewport();\n let whole: Image | undefined;\n\n if (crop === undefined && ratio === 1) {\n whole = yield* shot(operation, format, quality);\n if (whole.width === known?.width && whole.height === known.height) return whole;\n }\n // Where Playwright emulates the viewport, on its own session, its own picture restores it.\n const emulated = playwright.viewportSize();\n\n if (emulated !== null) {\n if (whole !== undefined) ratio = whole.width / emulated.width;\n\n return yield* capture.excluding(emulatedShot(operation, format, quality, crop));\n }\n\n const [metrics] = yield* Effect.all(\n [\n native(operation, () => send(\"Page.getLayoutMetrics\")).pipe(\n Effect.flatMap(decodeWith(operation, LayoutMetrics)),\n ),\n crop === undefined ? Effect.void : holdScreen(operation),\n ],\n { concurrency: 2 },\n );\n\n const measured = metrics.contentSize.width / metrics.cssContentSize.width;\n\n ratio = Number.isFinite(measured) && measured > 0 ? measured : 1;\n if (crop === undefined && ratio === 1) {\n const image = whole ?? (yield* shot(operation, format, quality));\n\n viewport.remember(image);\n\n return image;\n }\n const rect = crop ?? { x: 0, y: 0, ...(known ?? (yield* viewport.viewportFor(operation))) };\n const { pageX, pageY, scale } = metrics.cssVisualViewport;\n\n yield* holdScreen(operation);\n\n // A crop on this session draws its frames at the crop's own size, so only those leave the\n // capture, and the page's own keep flowing.\n return yield* capture.excluding(\n shot(operation, format, quality, {\n x: pageX + rect.x,\n y: pageY + rect.y,\n width: Math.floor(rect.width / scale + 1e-3),\n height: Math.floor(rect.height / scale + 1e-3),\n scale: scale / ratio,\n }),\n crop !== undefined,\n );\n }).pipe(within(operation));\n};\n\n// A duration in milliseconds, or NaN for an input that is no duration.\nconst millisOf = (input: Duration.Input) =>\n Option.match(Duration.fromInput(input), { onNone: () => Number.NaN, onSome: Duration.toMillis });\n\n// The newest screencast frame, if it shows the page as the caller asked: painted at most `maxAge`\n// ago at the earliest its timing allows, after the current document began, and with\n// `after: \"input\"` after the page's latest input, which a read asks in its turn, once the action\n// in flight has ended. It must have the viewport's size, as a new picture would. A screencast sends\n// only changes and can miss a final paint, so a frame is only ever as current as its age, and a\n// page that keeps painting while the next document loads leaves its own frames newest when the\n// navigation returns.\nconst reuse =\n (page: PageContext, viewport: Viewport, capture: Capture.Controller) =>\n (operation: string, options: FrameOptions) =>\n Effect.gen(function* () {\n const maxAge = millisOf(options.maxAge ?? defaultMaxAge);\n\n if (!(maxAge >= 0))\n return yield* failWith(\n operation,\n new InvalidRequest({ detail: \"maxAge must be a duration of zero or more\" }),\n );\n const latest = yield* capture.latest;\n const known = viewport.knownViewport();\n const { activity } = page;\n\n return Option.filter(latest, (frame) => {\n const earliest = frame.hostTime - frame.timing.uncertaintyMillis;\n\n return (\n page.now() - earliest <= maxAge &&\n earliest > activity.documentAt &&\n (options.after !== \"input\" || earliest > activity.inputAt) &&\n frame.width === known?.width &&\n frame.height === known.height\n );\n });\n });\n\n/** Where a picture came from: a frame the screencast had delivered, or a new screenshot. */\nconst sourceOf = (reused: Option.Option<Frame>) => (Option.isSome(reused) ? \"frame\" : \"screenshot\");\n\nexport const make = Effect.fnUntraced(function* (\n page: PageContext,\n bridge: Bridge,\n viewport: Viewport,\n) {\n const { id, clock, settings, mapping, now, span, owned, lane, within } = page;\n const calibrateClock = calibrator(page, bridge);\n\n // A failure from a capture connection is already the capture's own.\n const error = (cause: unknown) =>\n Schema.is(BrowserError)(cause)\n ? cause\n : undispatched(\"screencast\", reasonOf(cause, undefined, page.closedBy()));\n\n // Input and capture share the owner's monotonic clock; caller-provided clocks cannot move it.\n // Registration measures nothing: a page that is busy while it opens, such as a popup running\n // its first script, must still be tracked. The browser's mapping serves every other page, so\n // only a browser with no estimate yet needs this page's renderer to answer.\n const capture = yield* Capture.make({\n id,\n transport:\n page.capture === undefined\n ? Effect.succeed(Transport.own(page, bridge))\n : Transport.apart(page, bridge, page.capture, error, yield* Effect.scope),\n clock,\n // A capture starts once the page's own session keeps it painting behind other tabs, which a\n // renderer stuck in a script never confirms, and with the browser's clock mapped. Only a\n // browser's first capture waits for a measurement; every frame takes the newest estimate.\n calibrate: page.focused.pipe(within(\"focus\"), Effect.andThen(mapping.current(calibrateClock))),\n latest: mapping.latest,\n // Once the estimate is ten seconds old, the page measures again while its frames flow. A\n // failure there shows in its `Page.calibrateClock` span, and the estimate stays.\n renew: mapping.renew(calibrateClock),\n // Frames are reused only after the current document began, which the page's own session sees\n // only with the Page domain on: a read turns it on, and so does a capture as it starts.\n watch: bridge.currentDocument(\"screencast\"),\n frameHistory: settings.frameHistory,\n viewport: Effect.suspend(() => viewport.viewportFor(\"screencast\")),\n imageSize: jpegSize,\n error,\n });\n\n const picture = camera(page, bridge, viewport, capture);\n const reusable = reuse(page, viewport, capture);\n // Pictures in flight are shared, never kept: their callers say how old one may be.\n const screenshots = lane.shared<Image>(\"screenshot\", false);\n const frames = lane.shared<Frame>(\"frame\", false);\n\n // A caller that acts and then looks must see what its action did, so a screenshot waits for the\n // action in flight and reuses only a frame painted after the page's latest input.\n const screenshot = (options: ScreenshotOptions = {}) =>\n screenshots(\n JSON.stringify([\n millisOf(options.maxAge ?? defaultMaxAge),\n options.clip,\n options.quality,\n options.format,\n ]),\n Effect.gen(function* () {\n // Screencast frames are JPEGs, so a PNG is always new.\n const reused =\n options.clip === undefined && options.format !== \"png\"\n ? yield* reusable(\"screenshot\", { maxAge: options.maxAge, after: \"input\" })\n : Option.none<Frame>();\n\n const image = Option.isSome(reused)\n ? reused.value.image\n : yield* picture(\"screenshot\", options.quality ?? 80, options.clip, options.format);\n\n yield* Effect.annotateCurrentSpan({ source: sourceOf(reused), bytes: image.data.length });\n\n return image;\n }),\n ).pipe(span(\"Page.screenshot\"), owned);\n\n // A new screenshot has no paint time, only the host interval in which it was taken.\n const taken = (options: FrameOptions) =>\n Effect.gen(function* () {\n const reused = yield* reusable(\"frame\", options);\n\n yield* Effect.annotateCurrentSpan(\"source\", sourceOf(reused));\n if (Option.isSome(reused)) return reused.value;\n const startedAt = now();\n const image = yield* picture(\"frame\", 80);\n const finishedAt = now();\n\n return new Frame({\n page: id,\n data: image.data,\n timing: new Screenshot({\n hostTime: startedAt + (finishedAt - startedAt) / 2,\n uncertaintyMillis: (finishedAt - startedAt) / 2,\n }),\n receivedAt: finishedAt,\n width: image.width,\n height: image.height,\n ...bridge.frameTag(),\n });\n });\n\n // A frame of a stated age that the screencast has costs nothing and waits for no action; one\n // that must follow the latest input, or a new screenshot, waits for the action in flight.\n const frame = (options: FrameOptions = {}) =>\n (options.after === \"input\"\n ? Effect.succeed(Option.none<Frame>())\n : reusable(\"frame\", options)\n ).pipe(\n Effect.flatMap(\n Option.match({\n onSome: (reused) => Effect.as(Effect.annotateCurrentSpan(\"source\", \"frame\"), reused),\n onNone: () =>\n frames(\n JSON.stringify([millisOf(options.maxAge ?? defaultMaxAge), options.after]),\n taken(options),\n ),\n }),\n ),\n span(\"Page.frame\"),\n owned,\n );\n\n const zoom = (requested: Region) =>\n lane\n .read(\"zoom\")(\n Effect.gen(function* () {\n const region = yield* Schema.decodeEffect(Region)(requested).pipe(\n Effect.mapError((error) =>\n undispatched(\"zoom\", new InvalidRequest({ detail: error.message })),\n ),\n );\n\n // The viewport's latest known size, as the pictures the region was chosen from had it.\n const size = viewport.knownViewport() ?? (yield* viewport.viewportFor(\"zoom\"));\n\n if (region.x + region.width > size.width || region.y + region.height > size.height)\n return yield* failWith(\n \"zoom\",\n new InvalidRequest({ detail: \"the crop must fit entirely within the viewport\" }),\n );\n const image = yield* picture(\"zoom\", 80, region);\n\n return new Zoom({ page: id, region, image });\n }).pipe(within(\"zoom\")),\n )\n .pipe(span(\"Page.zoom\"), owned);\n\n const captureStats = (options: { readonly window?: Duration.Input | undefined } = {}) => {\n if (options.window === undefined) return capture.stats();\n const millis = millisOf(options.window);\n\n return millis > 0 && millis <= Duration.toMillis(Capture.countsKept)\n ? capture.stats(millis)\n : failWith(\n \"captureStats\",\n new InvalidRequest({ detail: \"window must be over zero and at most a minute\" }),\n );\n };\n\n // The browser's clock mapping, measured on this page only while the browser has none, as the\n // change record's times need it.\n const estimate = mapping.current(calibrateClock);\n\n return { capture, screenshot, frame, zoom, captureStats, estimate };\n});\n","/**\n * Reading a page: its outline with refs, the elements a query finds and the text it shows. Each\n * read takes its turn on the page and shares its work with identical reads, as `lane.ts`\n * describes. The viewport's text as it was last read is kept, for `Page.state`.\n */\nimport { Duration, Effect, Ref, Schema } from \"effect\";\n\nimport { InvalidRequest, StaleRef, Timeout } from \"../../BrowserError.ts\";\nimport { type FindQuery, Found, Text, type TextOptions, type WaitCondition } from \"../../Page.ts\";\nimport { Snapshot, type SnapshotOptions } from \"../../Snapshot.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { contextGone, decodeWith, failWith, type PageContext } from \"../page/context.ts\";\nimport * as Url from \"../page/url.ts\";\nimport type { ConditionRequest } from \"./controls.inpage.ts\";\nimport type { Want } from \"./expect.inpage.ts\";\nimport type { FindRequest, Wanted } from \"./match.inpage.ts\";\nimport type { SnapshotRequest } from \"./outline.inpage.ts\";\nimport { type TextRequest, TextResultSchema } from \"./text.inpage.ts\";\n\n// What `snapshot` and `find` read back, each with the next ref the page may give, and why a\n// snapshot's selector is not CSS.\nconst SnapshotResult = Schema.Union([\n Schema.Struct({ snapshot: Snapshot, nextRef: Schema.Finite }),\n Schema.Struct({ invalid: Schema.String }),\n]);\n\nconst FindResults = Schema.Struct({ found: Schema.Array(Found), nextRef: Schema.Finite });\n\nconst UntilResult = Schema.Struct({ met: Schema.Boolean, mark: Schema.String });\n\nconst ConditionResult = Schema.Union([\n Schema.Struct({ met: Schema.Boolean }),\n Schema.Struct({ invalid: Schema.String }),\n]);\n\n// A pattern crosses into the page as its source and flags.\nconst wanted = (value: string | RegExp | undefined): Wanted | null =>\n value === undefined\n ? null\n : typeof value === \"string\"\n ? value\n : { source: value.source, flags: value.flags };\n\n/** A query as the page takes it, but for the first ref it may give. */\nconst askedOf = (query: FindQuery, scope: \"viewport\" | \"document\") => ({\n role: query.role ?? null,\n name: wanted(query.name),\n text: wanted(query.text),\n near: query.near ?? null,\n at: query.at ?? null,\n scope: query.scope ?? scope,\n});\n\nexport const make = Effect.fnUntraced(function* (page: PageContext, bridge: Bridge) {\n const { now, span, owned, within, lane } = page;\n const { evaluate } = bridge;\n // Refs count up across the page's documents, so one never names two elements.\n const nextRef = yield* Ref.make(1);\n const counted = (next: number) => Ref.update(nextRef, (current) => Math.max(current, next));\n const snapshots = lane.shared<Snapshot>(\"snapshot\", true);\n const finds = lane.shared<ReadonlyArray<Found>>(\"find\", true);\n const texts = lane.shared<Text>(\"text\", true);\n let viewed: Text | undefined;\n\n const snapshot = (snapshotOptions: SnapshotOptions = {}) => {\n const asked = {\n full: snapshotOptions.full ?? false,\n query: snapshotOptions.query ?? null,\n within: snapshotOptions.within ?? null,\n maxChars: snapshotOptions.maxChars ?? 12_000,\n };\n\n return snapshots(\n JSON.stringify(asked),\n Effect.gen(function* () {\n const request: SnapshotRequest = { ...asked, firstRef: yield* Ref.get(nextRef) };\n\n const result = yield* evaluate(\"snapshot\", scriptCall(\"snapshot\", request)).pipe(\n Effect.flatMap(decodeWith(\"snapshot\", SnapshotResult)),\n );\n\n if (\"invalid\" in result)\n return yield* failWith(\"snapshot\", new InvalidRequest({ detail: result.invalid }));\n const { text, truncated, url } = result.snapshot;\n\n yield* counted(result.nextRef);\n yield* Effect.annotateCurrentSpan({ chars: text.length, truncated });\n\n return new Snapshot({ ...result.snapshot, url: Url.redact(url) });\n }).pipe(within(\"snapshot\")),\n ).pipe(span(\"Page.snapshot\", { full: asked.full }), owned);\n };\n\n const find = (query: FindQuery = {}) => {\n const asked = askedOf(query, \"viewport\");\n\n return finds(\n JSON.stringify(asked),\n Effect.gen(function* () {\n const request: FindRequest = { ...asked, firstRef: yield* Ref.get(nextRef) };\n\n const result = yield* evaluate(\"find\", scriptCall(\"find\", request)).pipe(\n Effect.flatMap(decodeWith(\"find\", FindResults)),\n );\n\n yield* counted(result.nextRef);\n yield* Effect.annotateCurrentSpan({ found: result.found.length });\n\n return result.found;\n }).pipe(within(\"find\")),\n ).pipe(\n // The query's words are the caller's, and may be anything; only its shape is traced.\n span(\"Page.find\", { scope: asked.scope, role: asked.role ?? \"\" }),\n owned,\n );\n };\n\n const text = (options: TextOptions = {}) => {\n const scope = options.scope ?? \"viewport\";\n\n const request: TextRequest = {\n ref: scope === \"viewport\" ? null : scope,\n maxChars: options.maxChars ?? 12_000,\n unmask: options.unmask ?? false,\n };\n\n return (\n scope !== \"viewport\" && !/^e\\d+$/.test(scope)\n ? failWith(\n \"text\",\n new InvalidRequest({ detail: `${scope} is neither \"viewport\" nor a ref such as e12` }),\n )\n : texts(\n JSON.stringify(request),\n Effect.gen(function* () {\n const result = yield* evaluate(\"text\", scriptCall(\"text\", request)).pipe(\n Effect.flatMap(decodeWith(\"text\", TextResultSchema)),\n );\n\n if (result === null) return yield* failWith(\"text\", new StaleRef({ ref: scope }));\n yield* Effect.annotateCurrentSpan({\n chars: result.text.length,\n truncated: result.truncated,\n });\n const shown = new Text({ ...result, url: Url.redact(result.url), at: now() });\n\n if (request.ref === null) viewed = shown;\n\n return shown;\n }).pipe(within(\"text\")),\n )\n ).pipe(span(\"Page.text\", { scope: scope === \"viewport\" ? \"viewport\" : \"ref\" }), owned);\n };\n\n // One call, which the page answers once the condition holds or at the deadline. It follows the\n // action in flight, as a read does, but holds no later one back while it waits, and it waits on\n // in a document that replaces the one it began in.\n const waitFor = (condition: WaitCondition, timeout: Duration.Input = Duration.seconds(10)) => {\n const request: ConditionRequest = {\n selector: condition.selector ?? null,\n text: condition.text ?? null,\n state: condition.state ?? \"visible\",\n };\n\n // JSON has no infinity; the deadline here ends a wait without one in any case.\n const millis = Math.min(Duration.toMillis(timeout), Number.MAX_SAFE_INTEGER);\n const unmet = () => failWith(\"waitFor\", new Timeout({ millis }));\n\n const look = evaluate(\"waitFor\", scriptCall(\"waitUntil\", request, millis)).pipe(\n Effect.flatMap(decodeWith(\"waitFor\", ConditionResult)),\n Effect.flatMap((result) =>\n \"invalid\" in result\n ? failWith(\"waitFor\", new InvalidRequest({ detail: result.invalid }))\n : result.met\n ? Effect.void\n : unmet(),\n ),\n );\n\n return lane\n .read(\"waitFor\")(Effect.void)\n .pipe(\n Effect.andThen(Effect.retry(look, { while: contextGone })),\n Effect.timeoutOrElse({ duration: timeout, orElse: unmet }),\n span(\"Page.waitFor\", { state: request.state }),\n owned,\n );\n };\n\n // One call, which the page answers once `want` holds of what `query` matches, the whole document\n // unless it says otherwise, or at the deadline, with the mark of what matched then. It follows\n // the action in flight, as `waitFor` does, and the page has the action timeout past the deadline\n // to answer.\n const until = (query: FindQuery, want: Want, millis: number) => {\n const look = Effect.gen(function* () {\n const request: FindRequest = {\n ...askedOf(query, \"document\"),\n firstRef: yield* Ref.get(nextRef),\n };\n\n return yield* evaluate(\"expect\", scriptCall(\"until\", request, want, millis)).pipe(\n Effect.flatMap(decodeWith(\"expect\", UntilResult)),\n );\n });\n\n return lane\n .read(\"expect\")(Effect.void)\n .pipe(\n Effect.andThen(Effect.retry(look, { while: contextGone })),\n within(\"expect\", Duration.sum(Duration.millis(millis), page.settings.actionTimeout)),\n span(\"Page.expect\", { want: typeof want === \"string\" ? want : \"other\" }),\n owned,\n );\n };\n\n /** The viewport's text as it was last read, if after `since`, as a document began. */\n const viewedSince = (since: number) =>\n viewed !== undefined && viewed.at > since ? viewed : undefined;\n\n return { snapshot, find, text, waitFor, until, viewedSince };\n});\n\nexport type Reading = Effect.Success<ReturnType<typeof make>>;\n","/**\n * Waiting until a page is ready to be shown. The page's own evidence leads: one page-script call\n * that checks in the page until nothing is left to wait for, or the time is up. A caller that also\n * needs the screen still, such as after spinning a canvas game's reels, gives a quiet spell, and\n * the capture must then show no frame that long. A capture's silence cannot prove the last paint\n * arrived: a frame can be held on its way by a stalled connection, and Chromium sends frames only\n * while few acknowledgements are unanswered. So the spell counts only while every acknowledgement\n * is answered, and it ends with the page's evidence once more and, where the capture runs on a\n * connection of its own, a round trip there: each answer comes behind every frame sent before it on\n * its connection, and a frame that arrives first starts the spell again. Where the page's changes\n * are recorded, its evidence includes them: nothing in view may have changed for the spell, which a\n * DOM page's changes show better than its paint, and no stall on the way can hide.\n */\nimport { Duration, Effect, Schedule, Stream } from \"effect\";\n\nimport { Timeout } from \"../../BrowserError.ts\";\nimport type { ReadyOptions } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { decodeWith, failWith, type PageContext } from \"../page/context.ts\";\nimport type * as Capture from \"../pictures/capture.ts\";\nimport { ReadinessSchema } from \"./ready.inpage.ts\";\n\nexport const make =\n (page: PageContext, bridge: Bridge, capture: Capture.Controller) =>\n (options: ReadyOptions = {}) => {\n const timeout = options.timeout ?? Duration.seconds(15);\n\n // The page's own evidence, checked in the page until nothing is left or `until` has come.\n const settled = (until: number) =>\n Effect.suspend(() =>\n bridge.evaluate(\n \"ready\",\n scriptCall(\n \"ready\",\n Math.max(0, Math.round(until - page.now())),\n options.quietMillis ?? 0,\n ),\n ),\n ).pipe(\n Effect.flatMap(decodeWith(\"ready\", ReadinessSchema)),\n Effect.tap((waiting) => Effect.annotateCurrentSpan({ waiting: waiting.join(\",\") })),\n Effect.filterOrElse(\n (waiting) => waiting.length === 0,\n () => failWith(\"ready\", new Timeout({ millis: Duration.toMillis(timeout) })),\n ),\n );\n\n // A capture the wait starts sends its first frame late, over half a second from a hosted\n // browser, so the spell counts from that frame (#202); Chrome sends one as a capture starts,\n // even of a still page.\n const quiet = (millis: number, until: number) =>\n Effect.gen(function* () {\n const running = yield* capture.active;\n let { received } = yield* capture.stats();\n let stirred = running ? page.now() : Number.POSITIVE_INFINITY;\n\n // How long the screen has been still: since a frame, or an unanswered acknowledgement.\n const look = Effect.map(capture.stats(), (stats) => {\n if (stats.received !== received || stats.ackBacklog > 0) {\n received = stats.received;\n stirred = page.now();\n }\n\n return page.now() - stirred;\n });\n\n const spell = Effect.repeat(look, {\n schedule: Schedule.spaced(Duration.millis(25)),\n until: (still) => still >= millis,\n });\n\n const capturing = running\n ? Effect.never\n : capture.stream().pipe(Stream.runDrain, Effect.andThen(Effect.never));\n\n const still = Effect.gen(function* () {\n for (;;) {\n yield* spell;\n const before = received;\n\n yield* Effect.all([settled(until), capture.sync], { concurrency: 2, discard: true });\n if ((yield* look) >= millis && received === before) return;\n }\n });\n\n return yield* Effect.raceFirst(capturing, still);\n });\n\n // The wait follows the action in flight, as a read does, but holds no later one back while it\n // watches the page settle, which can take its whole timeout.\n return page.lane\n .read(\"ready\")(Effect.void)\n .pipe(\n Effect.andThen(\n Effect.gen(function* () {\n const until = page.now() + Duration.toMillis(timeout);\n\n yield* settled(until);\n if (options.quietMillis !== undefined) yield* quiet(options.quietMillis, until);\n }).pipe(page.within(\"ready\", timeout)),\n ),\n page.span(\"Page.ready\"),\n page.owned,\n );\n };\n","/**\n * Reading a page's record of what changed, in one call to the page. The first read also registers\n * the recorder with the page's own session, in the same round trip, so that every later document\n * records from its start. The page's times map to the owner's clock through the browser's one\n * clock mapping, as frames' do, which a browser's first read measures, once, where no capture has;\n * and a window can begin on the page's own clock where the previous one ended, so consecutive\n * reads neither miss nor repeat a change. A read takes its turn on the page as other reads do, and\n * identical ones in flight share it; none is kept for a later caller, since its window ends when\n * it was read.\n */\nimport { Effect, Schema } from \"effect\";\n\nimport type { BrowserError } from \"../../BrowserError.ts\";\nimport { Change, Changes } from \"../../Change.ts\";\nimport type { Frame } from \"../../Frame.ts\";\nimport type { ChangesOptions } from \"../../Page.ts\";\nimport { type Bridge, scriptCall } from \"../page/bridge.ts\";\nimport { decodeWith, type PageContext } from \"../page/context.ts\";\nimport * as BrowserClock from \"../pictures/clock.ts\";\nimport { type ChangesRequest, ChangesResultSchema } from \"./changes.inpage.ts\";\n\nconst isChanges = Schema.is(Changes);\n\n// Where a window starts or ends as its caller gave it, which tells identical reads apart.\nconst markOf = (time: Changes | Frame | number | undefined) =>\n time === undefined || typeof time === \"number\"\n ? time\n : isChanges(time)\n ? `cursor ${time.cursor}`\n : `frame ${time.timestamp ?? time.hostTime}`;\n\nexport const make = (\n page: PageContext,\n bridge: Bridge,\n estimate: Effect.Effect<BrowserClock.Estimate, BrowserError>,\n) => {\n const reads = page.lane.shared<Changes>(\"changes\", false);\n\n return (options: ChangesOptions = {}) =>\n reads(\n JSON.stringify([markOf(options.since), markOf(options.until), options.unmask ?? false]),\n Effect.gen(function* () {\n const mapping = yield* estimate;\n const host = (epoch: number) => BrowserClock.toHostTime(mapping, epoch);\n\n // A frame's paint is on the page's clock already; a screenshot has only its host time.\n const onPage = (time: Frame | number) =>\n typeof time === \"number\"\n ? time + mapping.offsetMillis\n : (time.timestamp ?? time.hostTime + mapping.offsetMillis);\n\n const request: ChangesRequest = {\n since:\n options.since === undefined\n ? null\n : isChanges(options.since)\n ? options.since.cursor\n : onPage(options.since),\n until: options.until === undefined ? null : onPage(options.until),\n unmask: options.unmask ?? false,\n };\n\n const [, result] = yield* Effect.all(\n [\n bridge.registerRecorder(\"changes\"),\n bridge\n .evaluate(\"changes\", scriptCall(\"changes\", request))\n .pipe(Effect.flatMap(decodeWith(\"changes\", ChangesResultSchema))),\n ],\n { concurrency: \"unbounded\" },\n );\n\n yield* Effect.annotateCurrentSpan({\n changes: result.records.length,\n dropped: result.dropped,\n });\n\n const later = (epoch: number | undefined) =>\n epoch === undefined ? undefined : host(epoch);\n\n return new Changes({\n document: bridge.frameTag().document,\n from: host(result.from),\n until: host(result.until),\n cursor: result.until,\n dropped: result.dropped,\n changes: result.records.map(\n (one) =>\n new Change({\n ...one,\n startedAt: host(one.startedAt),\n at: host(one.at),\n earlier: later(one.earlier),\n cause: later(one.cause),\n }),\n ),\n });\n }).pipe(page.within(\"changes\")),\n ).pipe(page.span(\"Page.changes\"), page.owned);\n};\n","/**\n * A page's window over its three tracks on the browser's host clock: the events and frames it\n * keeps, at no call, and one read of its changes, the first starting its record. A read that fails\n * is missing, with why, and the window is still made.\n */\nimport { Duration, Effect, Option, Result, Schema } from \"effect\";\n\nimport { type BrowserError, InvalidRequest } from \"../../BrowserError.ts\";\nimport { type BrowserEvent, TrackEvent } from \"../../BrowserEvent.ts\";\nimport type { Changes } from \"../../Change.ts\";\nimport { Frame } from \"../../Frame.ts\";\nimport { Window } from \"../../Moment.ts\";\nimport type { ChangesOptions, WindowOptions } from \"../../Page.ts\";\nimport { failWith, type PageContext } from \"../page/context.ts\";\n\nconst isWindow = Schema.is(Window);\nconst isFrame = Schema.is(Frame);\nconst isTrackEvent = Schema.is(TrackEvent);\n\n/**\n * Where a window asked at `now` starts and ends: never after now, nor starting after it ends.\n * Nothing for a bound that is not finite, or a negative reach back.\n */\nexport const boundsOf = ({ since, until }: Pick<WindowOptions, \"since\" | \"until\">, now: number) => {\n const end = until === undefined ? now : isFrame(until) ? until.hostTime : Math.min(until, now);\n\n const start = isWindow(since)\n ? since.until\n : isFrame(since)\n ? since.hostTime\n : !Duration.isDuration(since)\n ? since\n : Duration.isNegative(since)\n ? Number.NaN\n : end - Duration.toMillis(since);\n\n return Number.isFinite(start) && Number.isFinite(end)\n ? Option.some({ since: Math.min(start, end), until: end })\n : Option.none();\n};\n\n/**\n * A window's share of the kept tracks: events after its start, frames painted from it, both up to\n * its end, so consecutive windows hold each event once and the next begins with the frame the last\n * ended on. Pointer, key and wheel input is the presentation track, not an event here.\n */\nexport const within = (\n { since, until }: { readonly since: number; readonly until: number },\n events: ReadonlyArray<BrowserEvent>,\n frames: ReadonlyArray<Frame>,\n) => ({\n events: events.filter((event) => event.at > since && event.at <= until && !isTrackEvent(event)),\n frames: frames.filter((frame) => frame.hostTime >= since && frame.hostTime <= until),\n});\n\nexport const make =\n (\n page: PageContext,\n read: (options: ChangesOptions) => Effect.Effect<Changes, BrowserError>,\n frames: Effect.Effect<ReadonlyArray<Frame>>,\n ) =>\n ({ since, until, unmask }: WindowOptions) =>\n Effect.gen(function* () {\n const asked = boundsOf({ since, until }, page.now());\n\n if (Option.isNone(asked))\n return yield* failWith(\n \"window\",\n new InvalidRequest({\n detail: \"a window's bounds must be finite, its reach not negative\",\n }),\n );\n const bounds = asked.value;\n\n // A previous window's changes go on exactly where they ended, on the page's own clock, and a\n // frame bounds them at its paint, so that they hold nothing it does not show.\n const changes = yield* Effect.result(\n read({\n since: isWindow(since)\n ? (since.changes ?? bounds.since)\n : isFrame(since)\n ? since\n : bounds.since,\n until: isFrame(until) ? until : bounds.until,\n unmask,\n }),\n );\n\n return new Window({\n page: page.id,\n ...bounds,\n ...within(bounds, yield* page.recentEvents, yield* frames),\n changes: Result.getOrUndefined(changes),\n missing: Option.toArray(Result.getFailure(changes)),\n });\n }).pipe(page.span(\"Page.window\"), page.owned);\n","/**\n * Moving a page between documents: going to an address, back through its history, or reloading.\n * Each move is an action, so it takes the page's turn, goes through the input guard and is\n * recorded, but it sends no input.\n */\nimport { Deferred, Duration, Effect, Schedule } from \"effect\";\n\nimport {\n BrowserError,\n InvalidRequest,\n NavigationFailed,\n NotActionable,\n NotFound,\n} from \"../../BrowserError.ts\";\nimport type { Guard } from \"../input/guard.ts\";\nimport type { InputMarks, Perform } from \"../input/perform.ts\";\nimport { failWith, type PageContext } from \"./context.ts\";\nimport * as Url from \"./url.ts\";\n\nexport const make = (\n page: PageContext,\n perform: Perform,\n preparePolicy: Guard[\"preparePolicy\"],\n) => {\n const { playwright, settings, native } = page;\n const { send } = page.protocol;\n\n // `address` is where `run` goes, as the action, the guard and a failure report it.\n const navigation = (name: string, run: () => Promise<unknown>, address: string) => {\n const url = Url.redact(address);\n\n return perform(\n name,\n { target: url, input: false },\n settings.navigationTimeout,\n preparePolicy(name, { target: url }, [], { destination: url }),\n (marks) =>\n marks.sent.pipe(\n Effect.andThen(native(name, run)),\n Effect.mapError((error) =>\n error.reason._tag === \"Failed\" &&\n /net::|NS_ERROR|Cannot navigate/i.test(error.reason.detail)\n ? new BrowserError({\n operation: name,\n reason: new NavigationFailed({ url, detail: error.reason.detail }),\n dispatched: true,\n })\n : error,\n ),\n Effect.asVoid,\n ),\n );\n };\n\n const history = native(\"back\", () => send(\"Page.getNavigationHistory\"));\n\n // While a traversal swaps documents, Chromium can briefly route this session to the outgoing\n // document, which has become inactive (for instance after it entered the back-forward cache),\n // so a read during the traversal is retried until the session reaches the active document.\n const traversingHistory = history.pipe(\n Effect.retry({\n schedule: Schedule.spaced(Duration.millis(50)),\n while: (error) =>\n error.reason._tag === \"Failed\" &&\n /not attached to an active page/i.test(error.reason.detail),\n }),\n );\n\n // The current entry's title is the one the page last set, and empty where it set none, so no\n // address stands in for it. The browser answers it, whatever the page's script is doing.\n const title = native(\"title\", () => send(\"Page.getNavigationHistory\")).pipe(\n Effect.map(({ entries, currentIndex }) => entries[currentIndex]?.title ?? \"\"),\n );\n\n const noPrevious = failWith(\"back\", new NotFound({ target: \"a previous page in this tab\" }));\n\n const prepareBack = Effect.gen(function* () {\n const before = yield* history;\n const current = before.entries[before.currentIndex];\n const previous = before.entries[before.currentIndex - 1];\n\n if (previous === undefined) return yield* noPrevious;\n const plan = yield* preparePolicy(\"back\", {}, [], { destination: Url.redact(previous.url) });\n\n return {\n request: plan.request,\n validate: Effect.gen(function* () {\n const approval = yield* plan.validate;\n const latest = yield* history;\n\n if (\n latest.currentIndex !== before.currentIndex ||\n latest.entries[latest.currentIndex]?.id !== current?.id ||\n latest.entries[latest.currentIndex - 1]?.id !== previous.id ||\n latest.entries[latest.currentIndex - 1]?.url !== previous.url\n )\n return yield* failWith(\n \"back\",\n new NotActionable({\n detail: \"the navigation history changed while input policy was pending\",\n }),\n );\n\n return approval;\n }),\n };\n });\n\n // One protocol traversal on every path. It has committed once the tab leaves its entry, which\n // also covers entries that only an iframe created, where the main frame never navigates, and\n // entries sharing a URL. A frame navigation then shows Playwright has caught up before the\n // main document's readiness is read.\n const goBack = (marks: InputMarks) =>\n Effect.gen(function* () {\n const before = yield* history;\n const current = before.entries[before.currentIndex];\n const previous = before.entries[before.currentIndex - 1];\n\n if (current === undefined || previous === undefined) return yield* noPrevious;\n const navigated = yield* Deferred.make<void>();\n\n const onNavigation = () => {\n Deferred.doneUnsafe(navigated, Effect.void);\n };\n\n yield* Effect.acquireUseRelease(\n Effect.sync(() => playwright.on(\"framenavigated\", onNavigation)),\n () =>\n Effect.gen(function* () {\n yield* marks.sent;\n yield* native(\"back\", () =>\n send(\"Page.navigateToHistoryEntry\", { entryId: previous.id }),\n );\n yield* traversingHistory.pipe(\n Effect.repeat({\n schedule: Schedule.spaced(Duration.millis(50)),\n until: (latest) => latest.entries[latest.currentIndex]?.id !== current.id,\n }),\n );\n yield* Deferred.await(navigated);\n }),\n () => Effect.sync(() => playwright.off(\"framenavigated\", onNavigation)),\n );\n yield* native(\"back\", () => playwright.waitForLoadState(\"domcontentloaded\", { timeout: 0 }));\n });\n\n const goto = (url: string) => {\n const parsed = Url.parse(url);\n\n if (\n parsed === null ||\n ![\"http:\", \"https:\", \"about:\", \"data:\", \"file:\"].includes(parsed.protocol)\n )\n return failWith(\n \"navigate\",\n new InvalidRequest({ detail: `\"${Url.redact(url)}\" is not a URL` }),\n );\n\n return navigation(\n \"navigate\",\n () => playwright.goto(parsed.href, { waitUntil: \"domcontentloaded\", timeout: 0 }),\n parsed.href,\n );\n };\n\n const back = perform(\n \"back\",\n { target: \"back\", input: false },\n settings.navigationTimeout,\n prepareBack,\n goBack,\n );\n\n const reload = Effect.suspend(() =>\n navigation(\n \"reload\",\n () => playwright.reload({ waitUntil: \"domcontentloaded\", timeout: 0 }),\n playwright.url(),\n ),\n );\n\n return { goto, back, reload, title };\n};\n","/**\n * The viewport's size in CSS pixels. Playwright knows it only for a context it created; over CDP it\n * reports none, so the page answers, and so does a picture taken at one device pixel per CSS\n * pixel. Pointer bounds, page scrolls, crops, capture size and frame reuse all read this one\n * source; the latest answer serves checks that cannot wait for the page.\n */\nimport { Effect } from \"effect\";\n\nimport { ViewportResultSchema } from \"../reading/outline.inpage.ts\";\nimport { type Bridge, scriptCall } from \"./bridge.ts\";\nimport { decodeWith, type PageContext } from \"./context.ts\";\n\nexport const make = (page: PageContext, bridge: Bridge) => {\n const { playwright } = page;\n let measuredViewport: { readonly width: number; readonly height: number } | null = null;\n\n const knownViewport = () => playwright.viewportSize() ?? measuredViewport;\n\n const viewportFor = (operation: string) =>\n Effect.suspend(() => {\n const known = playwright.viewportSize();\n\n return known === null\n ? bridge.evaluate(operation, scriptCall(\"viewport\")).pipe(\n Effect.flatMap(decodeWith(operation, ViewportResultSchema)),\n Effect.tap((measured) =>\n Effect.sync(() => {\n measuredViewport = measured;\n }),\n ),\n )\n : Effect.succeed(known);\n });\n\n /** The size of an unscaled picture of the whole viewport, which is the viewport's own. */\n const remember = (size: { readonly width: number; readonly height: number }) => {\n measuredViewport = { width: size.width, height: size.height };\n };\n\n return { knownViewport, viewportFor, remember };\n};\n\nexport type Viewport = ReturnType<typeof make>;\n","/**\n * The page implementation behind `Page.Page`. `Browser` constructs pages and owns the state they\n * share (the clock mapping and event publication), so construction stays internal. A page is\n * assembled here from its domains: the script bridge, pictures, reading, its timeline, input and\n * navigation.\n * What a presenter and a stage need of a page, and no caller should, it keeps out of sight.\n */\nimport { type Effect as Eff, Effect, Option } from \"effect\";\n\nimport type { BrowserError } from \"../../BrowserError.ts\";\nimport { type Page, State } from \"../../Page.ts\";\nimport * as Actions from \"../input/actions.ts\";\nimport * as Pictures from \"../pictures/pictures.ts\";\nimport * as Reading from \"../reading/reading.ts\";\nimport * as Ready from \"../reading/ready.ts\";\nimport * as Changes from \"../timeline/changes.ts\";\nimport * as Window from \"../timeline/window.ts\";\nimport * as Bridge from \"./bridge.ts\";\nimport * as Context from \"./context.ts\";\nimport * as Navigation from \"./navigation.ts\";\nimport * as Url from \"./url.ts\";\nimport * as Viewport from \"./viewport.ts\";\n\nexport interface Internals {\n /** The page's input, in any style. */\n readonly input: Actions.Input;\n /** Completes once the input asked of the page so far has ended, failing `Busy` if it lasts. */\n readonly inputEnded: Eff.Effect<void, BrowserError>;\n /** The page's documents so far, counted as `Navigated` counts them. */\n readonly document: () => number;\n /** Wait, in one call, until what a query finds is there, is not, or shows something else. */\n readonly until: Reading.Reading[\"until\"];\n}\n\n/** A page this library built: it keeps its internals where only this module reaches them. */\nclass Built {\n readonly #internals: Internals;\n\n constructor(internals: Internals) {\n this.#internals = internals;\n }\n\n static internalsOf(page: Page): Internals | undefined {\n return page instanceof Built ? page.#internals : undefined;\n }\n}\n\n/** What a page this library built keeps out of sight; nothing for any other `Page`. */\nexport const internalsOf = (page: Page) => Built.internalsOf(page);\n\n/** `view`, made from `page` with some of its operations replaced, keeping what `page` keeps out of sight. */\nexport const viewOf = <A extends Page>(page: Page, view: A): A => {\n const internals = internalsOf(page);\n\n return internals === undefined ? view : Object.assign(new Built(internals), view);\n};\n\nexport const make = Effect.fnUntraced(function* (options: Context.MakeOptions) {\n const page = Context.make(options, yield* Effect.scope);\n const { id, playwright, native, owned, within, lane, span } = page;\n const bridge = yield* Bridge.make(page);\n const viewport = Viewport.make(page, bridge);\n const input = Actions.make(page, bridge, viewport);\n const pictures = yield* Pictures.make(page, bridge, viewport);\n const reading = yield* Reading.make(page, bridge);\n const navigation = Navigation.make(page, input.perform, input.preparePolicy);\n const { capture } = pictures;\n const changes = Changes.make(page, bridge, pictures.estimate);\n const titles = lane.shared<string>(\"title\", true);\n const viewports = lane.shared<Effect.Success<Page[\"viewport\"]>>(\"viewport\", true);\n\n // What the page's parts already know, asking it nothing: its documents as its own session saw\n // them, the newest frame, and the viewport's text as last read since the document began.\n const state = Effect.map(capture.latest, (latest) => {\n const { document, url } = bridge.frameTag();\n const committedAt = page.activity.documentAt;\n\n return new State({\n page: id,\n at: page.now(),\n url,\n document,\n committedAt: Number.isFinite(committedAt) ? committedAt : undefined,\n load: bridge.loaded(),\n frame: Option.getOrUndefined(latest),\n text: reading.viewedSince(committedAt),\n });\n });\n\n const assembled: Page = {\n id,\n playwright,\n url: Effect.sync(() => Url.redact(playwright.url())),\n title: titles(\"\", navigation.title.pipe(within(\"title\"))).pipe(span(\"Page.title\"), owned),\n goto: navigation.goto,\n back: navigation.back,\n reload: navigation.reload,\n bringToFront: native(\"bringToFront\", () => playwright.bringToFront()),\n // Playwright answers once the page has closed, and at once for one already closed.\n close: native(\"close\", () => playwright.close()),\n snapshot: reading.snapshot,\n screenshot: pictures.screenshot,\n frame: pictures.frame,\n zoom: pictures.zoom,\n viewport: viewports(\"\", viewport.viewportFor(\"viewport\").pipe(within(\"viewport\"))).pipe(\n span(\"Page.viewport\"),\n owned,\n ),\n find: reading.find,\n text: reading.text,\n changes,\n window: Window.make(page, changes, capture.recent),\n state,\n click: (target, options) => input.click(target, options),\n hover: (target) => input.hover(target),\n drag: (from, to) => input.drag(from, to),\n type: (text, options) => input.type(text, options),\n press: (keys, options) => input.press(keys, options),\n scroll: (options) => input.scroll(options),\n select: input.select,\n waitFor: reading.waitFor,\n ready: Ready.make(page, bridge, capture),\n screencast: capture.stream,\n captureStats: pictures.captureStats,\n recentFrames: capture.recent,\n recentEvents: options.recentEvents,\n };\n\n const internals: Internals = {\n input,\n inputEnded: lane.read(\"inputEnded\")(Effect.void).pipe(owned),\n document: () => bridge.frameTag().document,\n until: reading.until,\n };\n\n return Object.assign(new Built(internals), assembled);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAa,QAAQ,OAAc,OAAc,YAA2B;CAC1E,MAAM,EACJ,eACA,OACA,UACA,YACA,QACA,SACA,UACA,UACA,YACA,QACA,QACA,WACE;CAEJ,MAAM,EAAE,WAAW,kBAAkB;;CAGrC,MAAM,YAAY,KAAoB,WAAoC;EACxE,MAAM,UAAU,QAAQ,OAAO,cAAc,IAAI,OAAO,GAAG;EAE3D,IAAI,YAAY,KAAA,GACd,OAAO;GACL,OAAO;GACP,QAAQ,GAAG,OAAO,sBAAsB;EAC1C;EAEF,MAAM,UACJ,YAAY,OACR,SACE,4CACA,KAAA,IACD,cAAc,SAAS,QAAQ,IAAI,MACnC,UAAU,CAAC,SAAS,OAAO,IACxB,GAAG,SAAS,OAAO,EAAE,0BACrB,KAAA;EAEV,IAAI,YAAY,KAAA,GAAW,OAAO;GAAE,OAAO;GAAc,QAAQ;EAAQ;EACzE,IAAI,YAAY,QAAQ,QAAQ,QAAQ,CAAC,UAAU,OAAO,GACxD,OAAO;GAAE,IAAI;GAAM,QAAQ,YAAY,QAAQ,SAAS,OAAO;EAAE;EACnE,MAAM,OAAO,OAAO,OAAO;EAC3B,MAAM,MAAM,QAAQ,QAAQ,YAAY;EAExC,OAAO;GACL,IAAI;GACJ,QAAQ,SAAS,OAAO;GACxB,SAAS;IAAE;IAAM,MAAM,OAAO,SAAS,IAAI;IAAG;IAAK,SAAS,QAAQ,UAAU,OAAO;GAAE;EACzF;CACF;CAEA,MAAM,SAAS,KAAa,YAAkC;EAC5D,MAAM,UAAU,OAAO,GAAG;EAE1B,IAAI,YAAY,KAAA,GAAW,OAAO;GAAE,OAAO,GAAG,IAAI;GAA+B,OA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