export interface PageSnapshotRequest { interactiveOnly: boolean; viewportOnly: boolean; maxNodes: number; } export interface PageSnapshotReply { url: string; lines: string[]; refs: Array<[string, string, string]>; outsideViewport: number; capped: boolean; } export interface PageResolveRequest { ref: string; mode: "point" | "select" | "focus-select" | "rect"; deadlineMs: number; option?: string; } export interface PageResolveReply { ok: boolean; stale?: boolean; reason?: string; x?: number; y?: number; width?: number; height?: number; checked?: boolean; done?: boolean; } export interface PageQuietRequest { quietMs: number; maxMs: number; } export interface PageWaitRequest { kind: "text" | "textGone" | "selector" | "selectorGone" | "urlContains"; value: string; timeoutMs: number; } export declare const SNAPSHOT_FN = "(req) => {\n \n const S = (window.__bgAgent = window.__bgAgent || { seq: 0, byRef: new Map() });\n const INTERACTIVE = new Set([\"button\",\"link\",\"textbox\",\"searchbox\",\"checkbox\",\"radio\",\"combobox\",\n \"listbox\",\"option\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"slider\",\"spinbutton\",\"switch\",\n \"tab\",\"textarea\"]);\n const CONTEXT = new Set([\"heading\",\"dialog\",\"alert\",\"alertdialog\",\"form\",\"navigation\",\"main\",\"table\"]);\n const TEXT_INPUTS = new Set([\"text\",\"email\",\"password\",\"tel\",\"url\",\"date\",\"datetime-local\",\"month\",\n \"time\",\"week\",\"\"]);\n const BUTTON_INPUTS = new Set([\"button\",\"submit\",\"reset\",\"image\"]);\n const SKIP_TAGS = new Set([\"SCRIPT\",\"STYLE\",\"NOSCRIPT\",\"TEMPLATE\",\"HEAD\",\"META\",\"LINK\",\"TITLE\"]);\n\n function roleOf(el) {\n const explicit = (el.getAttribute(\"role\") || \"\").trim().split(/\\s+/)[0];\n if (explicit) return explicit;\n const tag = el.tagName;\n if (tag === \"A\" || tag === \"AREA\") return el.hasAttribute(\"href\") ? \"link\" : \"\";\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return \"button\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return el.multiple || el.size > 1 ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"INPUT\") {\n const type = (el.getAttribute(\"type\") || \"\").toLowerCase();\n if (type === \"hidden\") return \"\";\n if (type === \"checkbox\") return \"checkbox\";\n if (type === \"radio\") return \"radio\";\n if (type === \"range\") return \"slider\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"search\") return \"searchbox\";\n if (BUTTON_INPUTS.has(type)) return \"button\";\n return TEXT_INPUTS.has(type) ? \"textbox\" : \"textbox\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"TABLE\") return \"table\";\n if (el.isContentEditable) return \"textbox\";\n return \"\";\n }\n\n function ownText(el) {\n if (!el.querySelector || !el.querySelector(\"style,script,noscript\")) {\n return (el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n }\n let out = \"\";\n const walk = (node) => {\n if (node.nodeType === 3) { out += node.nodeValue; return; }\n if (node.nodeType !== 1 || SKIP_TAGS.has(node.tagName.toUpperCase())) return;\n for (const child of node.childNodes) walk(child);\n };\n walk(el);\n return out.replace(/\\s+/g, \" \").trim();\n }\n\n function nameOf(el, doc, fromContentsAllowed) {\n const by = el.getAttribute(\"aria-labelledby\");\n if (by) {\n const parts = by.split(/\\s+/).map((id) => doc.getElementById(id)).filter(Boolean).map(ownText);\n if (parts.length) return parts.join(\" \");\n }\n const label = el.getAttribute(\"aria-label\");\n if (label && label.trim()) return label.trim();\n if (el.id) {\n const tag = doc.querySelector('label[for=\"' + CSS.escape(el.id) + '\"]');\n if (tag) return ownText(tag);\n }\n const wrapping = el.closest ? el.closest(\"label\") : null;\n if (wrapping) {\n const text = ownText(wrapping);\n if (text) return text;\n }\n const tagName = el.tagName;\n if (tagName === \"INPUT\") {\n const type = (el.getAttribute(\"type\") || \"\").toLowerCase();\n if (BUTTON_INPUTS.has(type) && el.value) return String(el.value);\n const placeholder = el.getAttribute(\"placeholder\");\n if (placeholder && placeholder.trim()) return placeholder.trim();\n } else if (fromContentsAllowed) {\n const text = ownText(el);\n if (text) return text;\n const img = el.querySelector ? el.querySelector(\"img[alt]\") : null;\n if (img && img.getAttribute(\"alt\")) return String(img.getAttribute(\"alt\")).trim();\n const inner = el.querySelector ? el.querySelector(\"[aria-label]\") : null;\n if (inner) return String(inner.getAttribute(\"aria-label\")).trim();\n }\n const title = el.getAttribute(\"title\");\n return title && title.trim() ? title.trim() : \"\";\n }\n\n function clip(text) {\n return text.length > 120 ? text.slice(0, 120) + \"\\u2026\" : text;\n }\n\n function stateOf(el, role) {\n const parts = [];\n const value = el.value;\n if (typeof value === \"string\" && value !== \"\" && role !== \"button\" && el.tagName !== \"OPTION\") {\n parts.push('value=\"' + clip(value.replace(/\\s+/g, \" \").trim()) + '\"');\n }\n const ariaChecked = el.getAttribute(\"aria-checked\");\n if (role === \"checkbox\" || role === \"radio\" || role === \"switch\") {\n parts.length = 0;\n parts.push(\"checked=\" + String(ariaChecked !== null ? ariaChecked === \"true\" : el.checked === true));\n } else if (ariaChecked !== null) {\n parts.push(\"checked=\" + String(ariaChecked === \"true\"));\n }\n if (el.disabled === true || el.getAttribute(\"aria-disabled\") === \"true\") parts.push(\"disabled\");\n const expanded = el.getAttribute(\"aria-expanded\");\n if (expanded !== null) parts.push(\"expanded=\" + String(expanded === \"true\"));\n if (el.required === true || el.getAttribute(\"aria-required\") === \"true\") parts.push(\"required\");\n return parts.length ? \" \" + parts.join(\" \") : \"\";\n }\n\n function refFor(el, role, name) {\n const held = el.__bgRef;\n if (held && held.role === role && held.name === name) return held.id;\n const id = \"e\" + ++S.seq;\n el.__bgRef = { id: id, role: role, name: name };\n S.byRef.set(id, el);\n return id;\n }\n\n function findByRef(ref) {\n const cached = S.byRef.get(ref);\n if (cached && cached.isConnected) return cached;\n const stack = [document];\n while (stack.length) {\n const root = stack.pop();\n const all = root.querySelectorAll(\"*\");\n for (let i = 0; i < all.length; i++) {\n const el = all[i];\n if (el.__bgRef && el.__bgRef.id === ref) return el;\n if (el.tagName === \"IFRAME\") {\n let inner = null;\n try { inner = el.contentDocument; } catch (e) { inner = null; }\n if (inner) stack.push(inner);\n }\n if (el.shadowRoot) stack.push(el.shadowRoot);\n }\n }\n return null;\n }\n\n const lines = [];\n const refs = [];\n let outside = 0;\n let visited = 0;\n let capped = false;\n const containers = new Set();\n const knownElements = new Set();\n const pointerDead = new Map();\n const collected = [];\n const GENERIC_NAME_MAX = 40;\n\n function pointerBlocked(el, view) {\n let node = el;\n const chain = [];\n while (node && node.nodeType === 1) {\n const known = pointerDead.get(node);\n if (known !== undefined) {\n for (const seen of chain) pointerDead.set(seen, known);\n return known;\n }\n if (view.getComputedStyle(node).pointerEvents === \"none\") {\n for (const seen of chain) pointerDead.set(seen, true);\n pointerDead.set(node, true);\n return true;\n }\n chain.push(node);\n node = node.parentElement;\n }\n for (const seen of chain) pointerDead.set(seen, false);\n return false;\n }\n\n const TRANSPARENT_CONTROLS = new Set([\"SELECT\",\"INPUT\",\"TEXTAREA\"]);\n\n function rendered(el, style) {\n const checkOpacity = !TRANSPARENT_CONTROLS.has(el.tagName);\n if (typeof el.checkVisibility === \"function\") {\n return el.checkVisibility({ checkOpacity: checkOpacity, checkVisibilityCSS: true, contentVisibilityAuto: true });\n }\n return style.display !== \"none\" && style.visibility !== \"hidden\" && style.visibility !== \"collapse\"\n && (!checkOpacity || Number(style.opacity) !== 0);\n }\n\n function walk(root, doc, view, offsetX, offsetY) {\n const all = root.querySelectorAll(\"*\");\n for (let i = 0; i < all.length; i++) {\n if (++visited > req.maxNodes) { capped = true; return; }\n const el = all[i];\n if (SKIP_TAGS.has(el.tagName)) continue;\n const style = view.getComputedStyle(el);\n if (!rendered(el, style)) continue;\n\n if (el.tagName === \"IFRAME\") {\n let inner = null;\n try { inner = el.contentDocument; } catch (e) { inner = null; }\n if (inner && inner.body) {\n const box = el.getBoundingClientRect();\n walk(inner.body, inner, el.contentWindow, offsetX + box.left, offsetY + box.top);\n if (capped) return;\n }\n continue;\n }\n if (el.shadowRoot) {\n walk(el.shadowRoot, doc, view, offsetX, offsetY);\n if (capped) return;\n }\n\n const role = roleOf(el);\n const clickable = style.cursor === \"pointer\" || (el.hasAttribute(\"tabindex\") && Number(el.getAttribute(\"tabindex\")) >= 0);\n if (!role && !clickable) continue;\n const known = INTERACTIVE.has(role);\n if (!known && !CONTEXT.has(role) && !clickable) continue;\n if (req.interactiveOnly && !known && !clickable) continue;\n if ((known || clickable) && pointerBlocked(el, view)) continue;\n\n const rect = el.getBoundingClientRect();\n if (rect.width <= 0 && rect.height <= 0) continue;\n const left = rect.left + offsetX;\n const top = rect.top + offsetY;\n const onScreen = rect.bottom + offsetY > 0 && rect.right + offsetX > 0\n && top < window.innerHeight && left < window.innerWidth;\n\n const landmark = !known && CONTEXT.has(role) && role !== \"heading\";\n const name = el.tagName === \"SELECT\" && el.labels && el.labels.length\n ? visibleLabelText(el.labels[0]) || clip(nameOf(el, doc, !landmark))\n : clip(nameOf(el, doc, !landmark));\n if (!known && !name) continue;\n collected.push({ el: el, role: role, name: name, known: known, onScreen: onScreen });\n if (known) knownElements.add(el);\n let up = el.parentElement;\n while (up && !containers.has(up)) { containers.add(up); up = up.parentElement; }\n }\n }\n\n walk(document.body || document.documentElement, document, window, 0, 0);\n\n function insideKnown(el) {\n for (let up = el.parentElement; up; up = up.parentElement) if (knownElements.has(up)) return true;\n return false;\n }\n\n function hiddenControlOf(el) {\n const label = el.tagName === \"LABEL\" ? el : el.closest ? el.closest(\"label\") : null;\n const control = (label && label.control)\n || (el.querySelector ? el.querySelector(\"select,textarea,input:not([type=hidden])\") : null);\n return control && !knownElements.has(control) ? control : null;\n }\n\n function visibleLabelText(el) {\n let out = \"\";\n const walk = (node) => {\n if (node.nodeType === 3) { out += node.nodeValue; return; }\n if (node.nodeType !== 1 || node.tagName === \"SELECT\" || node.tagName === \"OPTION\" || SKIP_TAGS.has(node.tagName.toUpperCase())) return;\n for (const child of node.childNodes) walk(child);\n };\n walk(el);\n return clip(out.replace(/\\s+/g, \" \").trim());\n }\n\n function labelsAKnownControl(el) {\n const label = el.tagName === \"LABEL\" ? el : el.closest ? el.closest(\"label\") : null;\n const target = (label && label.control) || (el.htmlFor ? document.getElementById(el.htmlFor) : null);\n if (target && knownElements.has(target)) return true;\n const owned = el.querySelector ? el.querySelector(\"input,select,textarea,button,a[href]\") : null;\n return !!owned && knownElements.has(owned);\n }\n\n const runs = [];\n let lastName = null;\n for (const item of collected) {\n const generic = !item.known && !CONTEXT.has(item.role);\n if (generic && (containers.has(item.el) || insideKnown(item.el))) continue;\n if (generic && item.name.length > GENERIC_NAME_MAX) continue;\n if (generic && labelsAKnownControl(item.el)) continue;\n if (generic && item.name === lastName) continue;\n lastName = item.name;\n if (req.viewportOnly && !item.onScreen) { outside++; continue; }\n const control = generic ? hiddenControlOf(item.el) : null;\n const target = control && control.tagName === \"SELECT\" ? control : item.el;\n const role = control ? roleOf(control) || \"button\" : item.known || CONTEXT.has(item.role) ? item.role : \"button\";\n const name = control && control.tagName === \"SELECT\" ? visibleLabelText(item.el) || item.name : item.name;\n const named = name ? ' \"' + name + '\"' : \"\";\n let line;\n if (item.known || !CONTEXT.has(item.role)) {\n const ref = refFor(target, role, name);\n refs.push([ref, role, name]);\n line = ref + \" \" + role + named + stateOf(target, role);\n } else {\n line = \"- \" + role + named;\n }\n const prev = runs[runs.length - 1];\n if (prev && prev.line === line) prev.count++;\n else runs.push({ line: line, count: 1 });\n }\n for (const run of runs) {\n if (run.count > 2) lines.push(run.line + \" (\\u00d7\" + run.count + \")\");\n else for (let n = 0; n < run.count; n++) lines.push(run.line);\n }\n return { url: location.href, lines: lines, refs: refs, outsideViewport: outside, capped: capped };\n}"; export declare const RESOLVE_FN = "(req) => {\n \n const S = (window.__bgAgent = window.__bgAgent || { seq: 0, byRef: new Map() });\n const INTERACTIVE = new Set([\"button\",\"link\",\"textbox\",\"searchbox\",\"checkbox\",\"radio\",\"combobox\",\n \"listbox\",\"option\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"slider\",\"spinbutton\",\"switch\",\n \"tab\",\"textarea\"]);\n const CONTEXT = new Set([\"heading\",\"dialog\",\"alert\",\"alertdialog\",\"form\",\"navigation\",\"main\",\"table\"]);\n const TEXT_INPUTS = new Set([\"text\",\"email\",\"password\",\"tel\",\"url\",\"date\",\"datetime-local\",\"month\",\n \"time\",\"week\",\"\"]);\n const BUTTON_INPUTS = new Set([\"button\",\"submit\",\"reset\",\"image\"]);\n const SKIP_TAGS = new Set([\"SCRIPT\",\"STYLE\",\"NOSCRIPT\",\"TEMPLATE\",\"HEAD\",\"META\",\"LINK\",\"TITLE\"]);\n\n function roleOf(el) {\n const explicit = (el.getAttribute(\"role\") || \"\").trim().split(/\\s+/)[0];\n if (explicit) return explicit;\n const tag = el.tagName;\n if (tag === \"A\" || tag === \"AREA\") return el.hasAttribute(\"href\") ? \"link\" : \"\";\n if (tag === \"BUTTON\" || tag === \"SUMMARY\") return \"button\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return el.multiple || el.size > 1 ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"INPUT\") {\n const type = (el.getAttribute(\"type\") || \"\").toLowerCase();\n if (type === \"hidden\") return \"\";\n if (type === \"checkbox\") return \"checkbox\";\n if (type === \"radio\") return \"radio\";\n if (type === \"range\") return \"slider\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"search\") return \"searchbox\";\n if (BUTTON_INPUTS.has(type)) return \"button\";\n return TEXT_INPUTS.has(type) ? \"textbox\" : \"textbox\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"TABLE\") return \"table\";\n if (el.isContentEditable) return \"textbox\";\n return \"\";\n }\n\n function ownText(el) {\n if (!el.querySelector || !el.querySelector(\"style,script,noscript\")) {\n return (el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n }\n let out = \"\";\n const walk = (node) => {\n if (node.nodeType === 3) { out += node.nodeValue; return; }\n if (node.nodeType !== 1 || SKIP_TAGS.has(node.tagName.toUpperCase())) return;\n for (const child of node.childNodes) walk(child);\n };\n walk(el);\n return out.replace(/\\s+/g, \" \").trim();\n }\n\n function nameOf(el, doc, fromContentsAllowed) {\n const by = el.getAttribute(\"aria-labelledby\");\n if (by) {\n const parts = by.split(/\\s+/).map((id) => doc.getElementById(id)).filter(Boolean).map(ownText);\n if (parts.length) return parts.join(\" \");\n }\n const label = el.getAttribute(\"aria-label\");\n if (label && label.trim()) return label.trim();\n if (el.id) {\n const tag = doc.querySelector('label[for=\"' + CSS.escape(el.id) + '\"]');\n if (tag) return ownText(tag);\n }\n const wrapping = el.closest ? el.closest(\"label\") : null;\n if (wrapping) {\n const text = ownText(wrapping);\n if (text) return text;\n }\n const tagName = el.tagName;\n if (tagName === \"INPUT\") {\n const type = (el.getAttribute(\"type\") || \"\").toLowerCase();\n if (BUTTON_INPUTS.has(type) && el.value) return String(el.value);\n const placeholder = el.getAttribute(\"placeholder\");\n if (placeholder && placeholder.trim()) return placeholder.trim();\n } else if (fromContentsAllowed) {\n const text = ownText(el);\n if (text) return text;\n const img = el.querySelector ? el.querySelector(\"img[alt]\") : null;\n if (img && img.getAttribute(\"alt\")) return String(img.getAttribute(\"alt\")).trim();\n const inner = el.querySelector ? el.querySelector(\"[aria-label]\") : null;\n if (inner) return String(inner.getAttribute(\"aria-label\")).trim();\n }\n const title = el.getAttribute(\"title\");\n return title && title.trim() ? title.trim() : \"\";\n }\n\n function clip(text) {\n return text.length > 120 ? text.slice(0, 120) + \"\\u2026\" : text;\n }\n\n function stateOf(el, role) {\n const parts = [];\n const value = el.value;\n if (typeof value === \"string\" && value !== \"\" && role !== \"button\" && el.tagName !== \"OPTION\") {\n parts.push('value=\"' + clip(value.replace(/\\s+/g, \" \").trim()) + '\"');\n }\n const ariaChecked = el.getAttribute(\"aria-checked\");\n if (role === \"checkbox\" || role === \"radio\" || role === \"switch\") {\n parts.length = 0;\n parts.push(\"checked=\" + String(ariaChecked !== null ? ariaChecked === \"true\" : el.checked === true));\n } else if (ariaChecked !== null) {\n parts.push(\"checked=\" + String(ariaChecked === \"true\"));\n }\n if (el.disabled === true || el.getAttribute(\"aria-disabled\") === \"true\") parts.push(\"disabled\");\n const expanded = el.getAttribute(\"aria-expanded\");\n if (expanded !== null) parts.push(\"expanded=\" + String(expanded === \"true\"));\n if (el.required === true || el.getAttribute(\"aria-required\") === \"true\") parts.push(\"required\");\n return parts.length ? \" \" + parts.join(\" \") : \"\";\n }\n\n function refFor(el, role, name) {\n const held = el.__bgRef;\n if (held && held.role === role && held.name === name) return held.id;\n const id = \"e\" + ++S.seq;\n el.__bgRef = { id: id, role: role, name: name };\n S.byRef.set(id, el);\n return id;\n }\n\n function findByRef(ref) {\n const cached = S.byRef.get(ref);\n if (cached && cached.isConnected) return cached;\n const stack = [document];\n while (stack.length) {\n const root = stack.pop();\n const all = root.querySelectorAll(\"*\");\n for (let i = 0; i < all.length; i++) {\n const el = all[i];\n if (el.__bgRef && el.__bgRef.id === ref) return el;\n if (el.tagName === \"IFRAME\") {\n let inner = null;\n try { inner = el.contentDocument; } catch (e) { inner = null; }\n if (inner) stack.push(inner);\n }\n if (el.shadowRoot) stack.push(el.shadowRoot);\n }\n }\n return null;\n }\n\n const frame = () => new Promise((r) => requestAnimationFrame(() => r()));\n const labelTarget = (hit, el) => {\n let node = hit;\n while (node && node.nodeType === 1) {\n if (node === el) return true;\n if (node.tagName === \"LABEL\" && (node.control === el || node.htmlFor === el.id)) return true;\n node = node.parentElement;\n }\n return false;\n };\n return (async () => {\n const deadline = Date.now() + req.deadlineMs;\n let reason = \"never became visible\";\n let previous = null;\n for (;;) {\n const el = findByRef(req.ref);\n if (!el) return { ok: false, stale: true };\n\n if (req.mode === \"select\") {\n const options = Array.from(el.options || []);\n const match = options.find((o) => o.value === req.option || o.label === req.option\n || (o.textContent || \"\").trim() === req.option);\n if (!match) return { ok: false, reason: 'no option matching \"' + req.option + '\"' };\n el.value = match.value;\n el.dispatchEvent(new Event(\"input\", { bubbles: true }));\n el.dispatchEvent(new Event(\"change\", { bubbles: true }));\n return { ok: true, done: true };\n }\n if (req.mode === \"rect\") {\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) return { ok: false, reason: \"has no visible box\" };\n return { ok: true, x: box.left, y: box.top, width: box.width, height: box.height };\n }\n if (req.mode === \"focus-select\") {\n el.focus();\n if (typeof el.select === \"function\") el.select();\n else {\n const range = document.createRange();\n range.selectNodeContents(el);\n const selection = getSelection();\n selection.removeAllRanges();\n selection.addRange(range);\n }\n return { ok: true, done: true };\n }\n\n if (typeof el.scrollIntoViewIfNeeded === \"function\") el.scrollIntoViewIfNeeded(false);\n else el.scrollIntoView({ block: \"center\", inline: \"center\" });\n await frame();\n const rect = el.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) {\n reason = \"has no visible box\";\n } else if (el.disabled === true || el.getAttribute(\"aria-disabled\") === \"true\") {\n reason = \"is disabled\";\n } else if (previous && Math.abs(previous.x - rect.x) < 1 && Math.abs(previous.y - rect.y) < 1) {\n const x = rect.left + rect.width / 2;\n const y = rect.top + rect.height / 2;\n const doc = el.ownerDocument;\n let hit = doc.elementFromPoint(x, y);\n while (hit && hit.tagName === \"IFRAME\" && hit.contentDocument) {\n const inner = hit.getBoundingClientRect();\n const next = hit.contentDocument.elementFromPoint(x - inner.left, y - inner.top);\n if (!next || next === hit) break;\n hit = next;\n }\n if (hit && !el.contains(hit) && !labelTarget(hit, el)) {\n reason = \"is covered by another element\";\n } else {\n return { ok: true, x: x, y: y, checked: el.checked === true\n || el.getAttribute(\"aria-checked\") === \"true\" };\n }\n } else {\n reason = \"kept moving\";\n }\n previous = { x: rect.x, y: rect.y };\n if (Date.now() >= deadline) return { ok: false, reason: reason };\n await frame();\n }\n })();\n}"; export declare const QUIET_FN = "(req) => new Promise((resolve) => {\n const started = Date.now();\n let timer = setTimeout(done, req.quietMs);\n const cap = setTimeout(done, req.maxMs);\n const observer = new MutationObserver(() => {\n clearTimeout(timer);\n timer = setTimeout(done, req.quietMs);\n });\n function done() {\n clearTimeout(timer);\n clearTimeout(cap);\n observer.disconnect();\n resolve(Date.now() - started);\n }\n observer.observe(document.documentElement, { subtree: true, childList: true, attributes: true,\n characterData: true });\n})"; export declare const WAIT_FN = "(req) => new Promise((resolve) => {\n const started = Date.now();\n const holds = () => {\n const body = document.body ? document.body.innerText || \"\" : \"\";\n if (req.kind === \"text\") return body.includes(req.value);\n if (req.kind === \"textGone\") return !body.includes(req.value);\n if (req.kind === \"selector\") return !!document.querySelector(req.value);\n if (req.kind === \"selectorGone\") return !document.querySelector(req.value);\n return location.href.includes(req.value);\n };\n const finish = (met) => {\n clearInterval(tick);\n clearTimeout(cap);\n observer.disconnect();\n resolve({ met: met, waitedMs: Date.now() - started });\n };\n const check = () => { if (holds()) finish(true); };\n const observer = new MutationObserver(check);\n const tick = setInterval(check, 100);\n const cap = setTimeout(() => finish(false), req.timeoutMs);\n observer.observe(document.documentElement, { subtree: true, childList: true, attributes: true,\n characterData: true });\n check();\n})"; //# sourceMappingURL=page-script.d.ts.map