spana-test 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +11 -0
  2. package/dist/agent/index.js +19 -18
  3. package/dist/agent/index.js.map +1 -1
  4. package/dist/api/app.d.ts +3 -1
  5. package/dist/api/app.d.ts.map +1 -1
  6. package/dist/api/expect.d.ts +2 -0
  7. package/dist/api/expect.d.ts.map +1 -1
  8. package/dist/{app-TX4RYRBY.js → app-LGNFQMU7.js} +5 -5
  9. package/dist/{appium-OI2CQON6.js → appium-2PJWZXJI.js} +55 -56
  10. package/dist/{appium-OI2CQON6.js.map → appium-2PJWZXJI.js.map} +1 -1
  11. package/dist/channels/cdp-client.d.ts.map +1 -1
  12. package/dist/channels/dom-channel.d.ts +4 -2
  13. package/dist/channels/dom-channel.d.ts.map +1 -1
  14. package/dist/{chunk-FPCMRYOS.js → chunk-3ONT32BO.js} +36 -35
  15. package/dist/chunk-3ONT32BO.js.map +1 -0
  16. package/dist/{chunk-FCUT3OKD.js → chunk-44U3F2RY.js} +10 -10
  17. package/dist/chunk-44U3F2RY.js.map +1 -0
  18. package/dist/{chunk-YNA6LFBF.js → chunk-4TTYSFBG.js} +2 -1
  19. package/dist/chunk-4TTYSFBG.js.map +1 -0
  20. package/dist/chunk-67PLJEY2.js +24645 -0
  21. package/dist/chunk-67PLJEY2.js.map +1 -0
  22. package/dist/{chunk-CXXK3JAI.js → chunk-6X2SK2XO.js} +3 -3
  23. package/dist/{chunk-CR55BHI2.js → chunk-7K24Q7V3.js} +255 -40
  24. package/dist/chunk-7K24Q7V3.js.map +1 -0
  25. package/dist/{chunk-RXQKH6Z7.js → chunk-AP5SGSO7.js} +42 -42
  26. package/dist/{chunk-RXQKH6Z7.js.map → chunk-AP5SGSO7.js.map} +1 -1
  27. package/dist/{chunk-WZY3MBNG.js → chunk-BPUBV7OF.js} +5 -3
  28. package/dist/chunk-BPUBV7OF.js.map +1 -0
  29. package/dist/{chunk-QJPIPZ4S.js → chunk-C2YM5GNF.js} +30 -30
  30. package/dist/{chunk-QJPIPZ4S.js.map → chunk-C2YM5GNF.js.map} +1 -1
  31. package/dist/{chunk-4GESFVZL.js → chunk-C7HZJIGQ.js} +2 -2
  32. package/dist/{chunk-22VPSGCA.js → chunk-CQ67PB3R.js} +2 -2
  33. package/dist/{chunk-XG6UF6BP.js → chunk-DNWVDGKS.js} +38 -38
  34. package/dist/{chunk-XG6UF6BP.js.map → chunk-DNWVDGKS.js.map} +1 -1
  35. package/dist/{chunk-HFQ3KKIB.js → chunk-E67QUGT3.js} +323 -202
  36. package/dist/chunk-E67QUGT3.js.map +1 -0
  37. package/dist/{chunk-GS7DRAOQ.js → chunk-FLPPA2XY.js} +3 -2
  38. package/dist/chunk-FLPPA2XY.js.map +1 -0
  39. package/dist/{chunk-KRATI3A5.js → chunk-FZ7EMXIM.js} +131 -108
  40. package/dist/chunk-FZ7EMXIM.js.map +1 -0
  41. package/dist/{chunk-L5EVAGCV.js → chunk-G4ZUJCEN.js} +432 -280
  42. package/dist/chunk-G4ZUJCEN.js.map +1 -0
  43. package/dist/{chunk-H5ZMLSVC.js → chunk-IC46FAEW.js} +2 -2
  44. package/dist/{chunk-3NZRRXDP.js → chunk-IJWAAODK.js} +2 -2
  45. package/dist/{chunk-FWFT3FEP.js → chunk-KIDTBRIV.js} +45 -6
  46. package/dist/chunk-KIDTBRIV.js.map +1 -0
  47. package/dist/{chunk-YWASMWPK.js → chunk-LX6GMZIN.js} +5 -5
  48. package/dist/{chunk-YWASMWPK.js.map → chunk-LX6GMZIN.js.map} +1 -1
  49. package/dist/{chunk-7YJBZ4HB.js → chunk-NC32K762.js} +66 -66
  50. package/dist/{chunk-7YJBZ4HB.js.map → chunk-NC32K762.js.map} +1 -1
  51. package/dist/{chunk-OKU46IDG.js → chunk-NR4QAM5W.js} +80 -54
  52. package/dist/chunk-NR4QAM5W.js.map +1 -0
  53. package/dist/chunk-PS3DALTI.js +17 -0
  54. package/dist/chunk-PS3DALTI.js.map +1 -0
  55. package/dist/{chunk-T7Z2T3NP.js → chunk-YKNHKVE6.js} +47 -39
  56. package/dist/chunk-YKNHKVE6.js.map +1 -0
  57. package/dist/{chunk-X5W7LV2O.js → chunk-Z5BMFLZ5.js} +2 -2
  58. package/dist/cli/test-command.d.ts.map +1 -1
  59. package/dist/cli.js +15 -15
  60. package/dist/cloud/common.d.ts.map +1 -1
  61. package/dist/{config-loader-OSHDDKH5.js → config-loader-MX232REU.js} +3 -3
  62. package/dist/core/rejections.d.ts +5 -0
  63. package/dist/core/rejections.d.ts.map +1 -0
  64. package/dist/core/screenshot-compare.d.ts +7 -2
  65. package/dist/core/screenshot-compare.d.ts.map +1 -1
  66. package/dist/core/video-recorder.d.ts.map +1 -1
  67. package/dist/{daemon-manager-VEMRSZ5R.js → daemon-manager-6CFUXGTR.js} +2 -2
  68. package/dist/{doctor-command-2O4VK3QR.js → doctor-command-YTT5SMQW.js} +10 -9
  69. package/dist/{doctor-command-2O4VK3QR.js.map → doctor-command-YTT5SMQW.js.map} +1 -1
  70. package/dist/{driver-ZVDLV6QF.js → driver-AN3I4H6O.js} +8 -7
  71. package/dist/{driver-BHHIEDX6.js → driver-X4FWTDNU.js} +6 -6
  72. package/dist/drivers/cdp-browser.d.ts +15 -0
  73. package/dist/drivers/cdp-browser.d.ts.map +1 -1
  74. package/dist/drivers/electron.d.ts +0 -8
  75. package/dist/drivers/electron.d.ts.map +1 -1
  76. package/dist/drivers/playwright.d.ts +2 -0
  77. package/dist/drivers/playwright.d.ts.map +1 -1
  78. package/dist/{electrobun-4Z66F5NW.js → electrobun-OUTYOM5G.js} +7 -6
  79. package/dist/{electron-ZXM6SMZU.js → electron-XL7H25IQ.js} +3 -3
  80. package/dist/index.js +87 -88
  81. package/dist/index.js.map +1 -1
  82. package/dist/{installer-6HV5CU2I.js → installer-3X5SKWVX.js} +3 -3
  83. package/dist/{installer-DYGA4MRU.js → installer-Q37BOG5G.js} +3 -3
  84. package/dist/{local-OYNEJSSQ.js → local-UWIYOREU.js} +10 -7
  85. package/dist/{playwright-SZP56NN2.js → playwright-KBWUBU5S.js} +9 -8
  86. package/dist/{provider-FKT6FEQS.js → provider-HWM3GF54.js} +3 -2
  87. package/dist/runtime/daemon-manager.d.ts.map +1 -1
  88. package/dist/runtime/local.d.ts +4 -0
  89. package/dist/runtime/local.d.ts.map +1 -1
  90. package/dist/schemas/config.d.ts +4 -1
  91. package/dist/schemas/config.d.ts.map +1 -1
  92. package/dist/{screenshot-compare-7TE44H7F.js → screenshot-compare-DNIP2EK4.js} +6 -4
  93. package/dist/{server-7QYNULRB.js → server-BS3O4WVU.js} +25 -24
  94. package/dist/{server-7QYNULRB.js.map → server-BS3O4WVU.js.map} +1 -1
  95. package/dist/{server-VIXRVKP5.js → server-CWCMC244.js} +2 -2
  96. package/dist/session-YWYRRXXR.js +42 -0
  97. package/dist/smart/auto-wait.d.ts.map +1 -1
  98. package/dist/smart/channel-resolver.d.ts +4 -0
  99. package/dist/smart/channel-resolver.d.ts.map +1 -1
  100. package/dist/smart/coordinator.d.ts +1 -0
  101. package/dist/smart/coordinator.d.ts.map +1 -1
  102. package/dist/smart/element-matcher.d.ts.map +1 -1
  103. package/dist/{studio-command-ALDWIKEE.js → studio-command-XJDGLNAJ.js} +2 -2
  104. package/dist/{test-command-HP5YE675.js → test-command-3IRGNEPB.js} +89 -20
  105. package/dist/test-command-3IRGNEPB.js.map +1 -0
  106. package/native/win32-x64/spana_native.dll +0 -0
  107. package/package.json +15 -6
  108. package/studio-dist/assets/{index-DXGUfzm3.js → index-DAE7R_Zp.js} +1 -1
  109. package/studio-dist/index.html +1 -1
  110. package/dist/chunk-CR55BHI2.js.map +0 -1
  111. package/dist/chunk-FCUT3OKD.js.map +0 -1
  112. package/dist/chunk-FPCMRYOS.js.map +0 -1
  113. package/dist/chunk-FWFT3FEP.js.map +0 -1
  114. package/dist/chunk-GS7DRAOQ.js.map +0 -1
  115. package/dist/chunk-HFQ3KKIB.js.map +0 -1
  116. package/dist/chunk-KRATI3A5.js.map +0 -1
  117. package/dist/chunk-L5EVAGCV.js.map +0 -1
  118. package/dist/chunk-OKU46IDG.js.map +0 -1
  119. package/dist/chunk-T7Z2T3NP.js.map +0 -1
  120. package/dist/chunk-WPG77TPT.js +0 -98
  121. package/dist/chunk-WPG77TPT.js.map +0 -1
  122. package/dist/chunk-WZY3MBNG.js.map +0 -1
  123. package/dist/chunk-YNA6LFBF.js.map +0 -1
  124. package/dist/session-3KME2U42.js +0 -41
  125. package/dist/test-command-HP5YE675.js.map +0 -1
  126. /package/dist/{app-TX4RYRBY.js.map → app-LGNFQMU7.js.map} +0 -0
  127. /package/dist/{chunk-CXXK3JAI.js.map → chunk-6X2SK2XO.js.map} +0 -0
  128. /package/dist/{chunk-4GESFVZL.js.map → chunk-C7HZJIGQ.js.map} +0 -0
  129. /package/dist/{chunk-22VPSGCA.js.map → chunk-CQ67PB3R.js.map} +0 -0
  130. /package/dist/{chunk-H5ZMLSVC.js.map → chunk-IC46FAEW.js.map} +0 -0
  131. /package/dist/{chunk-3NZRRXDP.js.map → chunk-IJWAAODK.js.map} +0 -0
  132. /package/dist/{chunk-X5W7LV2O.js.map → chunk-Z5BMFLZ5.js.map} +0 -0
  133. /package/dist/{config-loader-OSHDDKH5.js.map → config-loader-MX232REU.js.map} +0 -0
  134. /package/dist/{daemon-manager-VEMRSZ5R.js.map → daemon-manager-6CFUXGTR.js.map} +0 -0
  135. /package/dist/{driver-BHHIEDX6.js.map → driver-AN3I4H6O.js.map} +0 -0
  136. /package/dist/{driver-ZVDLV6QF.js.map → driver-X4FWTDNU.js.map} +0 -0
  137. /package/dist/{electrobun-4Z66F5NW.js.map → electrobun-OUTYOM5G.js.map} +0 -0
  138. /package/dist/{electron-ZXM6SMZU.js.map → electron-XL7H25IQ.js.map} +0 -0
  139. /package/dist/{installer-6HV5CU2I.js.map → installer-3X5SKWVX.js.map} +0 -0
  140. /package/dist/{installer-DYGA4MRU.js.map → installer-Q37BOG5G.js.map} +0 -0
  141. /package/dist/{local-OYNEJSSQ.js.map → local-UWIYOREU.js.map} +0 -0
  142. /package/dist/{playwright-SZP56NN2.js.map → playwright-KBWUBU5S.js.map} +0 -0
  143. /package/dist/{provider-FKT6FEQS.js.map → provider-HWM3GF54.js.map} +0 -0
  144. /package/dist/{screenshot-compare-7TE44H7F.js.map → screenshot-compare-DNIP2EK4.js.map} +0 -0
  145. /package/dist/{server-VIXRVKP5.js.map → server-CWCMC244.js.map} +0 -0
  146. /package/dist/{session-3KME2U42.js.map → session-YWYRRXXR.js.map} +0 -0
  147. /package/dist/{studio-command-ALDWIKEE.js.map → studio-command-XJDGLNAJ.js.map} +0 -0
@@ -260,7 +260,7 @@ export declare const SPANA_RUNTIME_MISSING_SENTINEL = "__SPANA_RT_MISSING__";
260
260
  * Cuts per-action CDP `Runtime.evaluate` payload by ~100× (~8 KB → ~70 bytes)
261
261
  * and lets V8 TurboFan JIT-compile the selector & actionability helpers once.
262
262
  */
263
- export declare const SPANA_INJECTED_RUNTIME_SCRIPT = "(function() {\n if (typeof window === \"undefined\") return true;\n (function() {\n if (typeof globalThis === \"undefined\" || globalThis.__spanaWasm) return;\n var state = {\n moduleCount: 0,\n pendingCount: 0,\n peakWasmMemoryBytes: 0,\n modules: [],\n memories: [],\n traps: []\n };\n var nextId = 1;\n var WASM_RE = /(WebAssembly\\.(RuntimeError|CompileError|LinkError)|wasm-function\\[|memory access out of bounds|table index is out of bounds|integer divide by zero|unreachable|indirect call type mismatch|out of bounds memory access)/i;\n\n function trackMemory(mem) {\n if (!mem || typeof mem !== \"object\" || !(mem.buffer instanceof ArrayBuffer || (typeof SharedArrayBuffer !== \"undefined\" && mem.buffer instanceof SharedArrayBuffer))) {\n return;\n }\n var already = false;\n var alive = [];\n for (var i = 0; i < state.memories.length; i++) {\n var ref = state.memories[i];\n var cur = typeof ref.deref === \"function\" ? ref.deref() : ref;\n if (!cur) continue;\n if (cur === mem) already = true;\n alive.push(ref);\n }\n if (!already) {\n alive.push(typeof WeakRef !== \"undefined\" ? new WeakRef(mem) : mem);\n }\n state.memories = alive;\n computeMemoryBytes();\n }\n\n function computeMemoryBytes() {\n var total = 0;\n var alive = [];\n for (var i = 0; i < state.memories.length; i++) {\n var ref = state.memories[i];\n var cur = typeof ref.deref === \"function\" ? ref.deref() : ref;\n if (!cur) continue;\n alive.push(ref);\n try {\n total += cur.buffer ? cur.buffer.byteLength : 0;\n } catch (e) {}\n }\n state.memories = alive;\n if (total > state.peakWasmMemoryBytes) state.peakWasmMemoryBytes = total;\n return total;\n }\n\n function trackExports(instance) {\n if (!instance || !instance.exports) return { bytes: 0, pages: 0 };\n var bytes = 0;\n try {\n var keys = Object.keys(instance.exports);\n for (var i = 0; i < keys.length; i++) {\n var val = instance.exports[keys[i]];\n if (typeof WebAssembly !== \"undefined\" && typeof WebAssembly.Memory === \"function\" && val instanceof WebAssembly.Memory) {\n trackMemory(val);\n try { bytes += val.buffer.byteLength; } catch (e) {}\n }\n }\n } catch (e) {}\n return { bytes: bytes, pages: Math.round(bytes / 65536) };\n }\n\n function recordTrap(name, message, stack) {\n var combined = String(name || \"\") + \" \" + String(message || \"\") + \" \" + String(stack || \"\");\n if (!WASM_RE.test(combined)) return;\n state.traps.push({\n name: String(name || \"WebAssembly.RuntimeError\"),\n message: String(message || \"WebAssembly trap\"),\n source: typeof window === \"undefined\" ? \"worker\" : \"main\",\n stack: stack ? String(stack) : undefined,\n timestamp: Date.now()\n });\n if (state.traps.length > 100) state.traps.shift();\n }\n\n function getSizeBytes(src) {\n if (!src) return undefined;\n if (typeof src.byteLength === \"number\") return src.byteLength;\n return undefined;\n }\n\n if (typeof WebAssembly !== \"undefined\") {\n var origInstantiate = WebAssembly.instantiate;\n if (typeof origInstantiate === \"function\") {\n WebAssembly.instantiate = function(source, importObject) {\n state.pendingCount += 1;\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n var sizeBytes = getSizeBytes(source);\n return Promise.resolve(origInstantiate.apply(WebAssembly, arguments)).then(\n function(res) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n state.moduleCount += 1;\n var inst = res && res.instance ? res.instance : res;\n var memInfo = trackExports(inst);\n var elapsed = Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0);\n state.modules.push({\n id: nextId++,\n sizeBytes: sizeBytes,\n instantiateMs: elapsed,\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return res;\n },\n function(err) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n recordTrap(err && err.name, err && err.message ? err.message : String(err), err && err.stack);\n throw err;\n }\n );\n };\n }\n\n var origInstantiateStreaming = WebAssembly.instantiateStreaming;\n if (typeof origInstantiateStreaming === \"function\") {\n WebAssembly.instantiateStreaming = function(source, importObject) {\n state.pendingCount += 1;\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n return Promise.resolve(origInstantiateStreaming.apply(WebAssembly, arguments)).then(\n function(res) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n state.moduleCount += 1;\n var inst = res && res.instance ? res.instance : res;\n var memInfo = trackExports(inst);\n var elapsed = Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0);\n state.modules.push({\n id: nextId++,\n instantiateMs: elapsed,\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return res;\n },\n function(err) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n recordTrap(err && err.name, err && err.message ? err.message : String(err), err && err.stack);\n throw err;\n }\n );\n };\n }\n\n var OrigMemory = WebAssembly.Memory;\n if (typeof OrigMemory === \"function\") {\n try {\n var WrappedMemory = new Proxy(OrigMemory, {\n construct: function(target, args, newTarget) {\n var mem = Reflect.construct(target, args, newTarget);\n trackMemory(mem);\n return mem;\n }\n });\n WebAssembly.Memory = WrappedMemory;\n } catch (e) {}\n }\n\n var OrigInstance = WebAssembly.Instance;\n if (typeof OrigInstance === \"function\") {\n try {\n var WrappedInstance = new Proxy(OrigInstance, {\n construct: function(target, args, newTarget) {\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n var inst = Reflect.construct(target, args, newTarget);\n state.moduleCount += 1;\n var memInfo = trackExports(inst);\n state.modules.push({\n id: nextId++,\n instantiateMs: Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0),\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return inst;\n }\n });\n WebAssembly.Instance = WrappedInstance;\n } catch (e) {}\n }\n }\n\n if (typeof globalThis.addEventListener === \"function\") {\n globalThis.addEventListener(\"error\", function(ev) {\n var err = ev && ev.error;\n recordTrap(err && err.name, (err && err.message) || (ev && ev.message), err && err.stack);\n });\n globalThis.addEventListener(\"unhandledrejection\", function(ev) {\n var reason = ev && ev.reason;\n recordTrap(reason && reason.name, reason && reason.message ? reason.message : String(reason), reason && reason.stack);\n });\n }\n\n globalThis.__spanaWasm = {\n trackMemory: trackMemory,\n recordTrap: recordTrap,\n getMetrics: function() {\n var bytes = computeMemoryBytes();\n var perfMem = typeof performance !== \"undefined\" && performance.memory ? performance.memory : null;\n return {\n moduleCount: state.moduleCount,\n pendingCount: state.pendingCount,\n wasmMemoryBytes: bytes,\n wasmMemoryPages: Math.round(bytes / 65536),\n peakWasmMemoryBytes: state.peakWasmMemoryBytes,\n jsHeapUsedBytes: perfMem ? perfMem.usedJSHeapSize : undefined,\n jsHeapTotalBytes: perfMem ? perfMem.totalJSHeapSize : undefined,\n crossOriginIsolated: Boolean(globalThis.crossOriginIsolated),\n sharedArrayBufferAvailable: typeof SharedArrayBuffer !== \"undefined\",\n traps: state.traps.slice(),\n modules: state.modules.slice()\n };\n },\n isReady: function(minModules) {\n var req = typeof minModules === \"number\" ? minModules : 1;\n var explicit = globalThis.__SPANA_WASM_READY__;\n if (typeof explicit === \"function\") {\n try { if (!explicit()) return false; } catch (e) { return false; }\n } else if (explicit === false) {\n return false;\n }\n return state.pendingCount === 0 && (state.moduleCount >= req || explicit === true);\n }\n };\n})();\n if (window.__spanaRt) return true;\n \n function normWs(val) {\n return String(val == null ? \"\" : val).replace(/[\\s\\u00a0\\u202f]+/g, \" \").trim();\n }\n function matchSpec(actual, spec, exact) {\n var raw = String(actual || \"\");\n var str = normWs(raw);\n if (spec && typeof spec === \"object\" && typeof spec.__spanaRegex === \"string\") {\n try {\n var re = new RegExp(spec.__spanaRegex, spec.flags || \"\");\n return re.test(raw) || re.test(str);\n } catch (e) { return false; }\n }\n var needle = normWs(spec);\n if (exact) return str === needle;\n return str.toLowerCase().indexOf(needle.toLowerCase()) !== -1;\n }\n function isInsideSectioningContent(el) {\n var cur = el && el.parentElement;\n var guard = 0;\n while (cur && guard++ < 32) {\n var ptag = cur.tagName ? cur.tagName.toUpperCase() : \"\";\n if (ptag === \"ARTICLE\" || ptag === \"ASIDE\" || ptag === \"MAIN\" || ptag === \"NAV\" || ptag === \"SECTION\") {\n return true;\n }\n var prole = (cur.getAttribute && cur.getAttribute(\"role\") || \"\").trim().toLowerCase().split(/\\s+/)[0] || \"\";\n if (prole === \"article\" || prole === \"complementary\" || prole === \"main\" || prole === \"navigation\" || prole === \"region\") {\n return true;\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n return false;\n }\n function getImplicitRole(el) {\n if (!el || !el.getAttribute) return \"generic\";\n var explicit = (el.getAttribute(\"role\") || \"\").trim().toLowerCase();\n if (explicit) return explicit.split(/\\s+/)[0] || \"generic\";\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"BUTTON\") return \"button\";\n if (tag === \"A\") return el.hasAttribute(\"href\") ? \"link\" : \"generic\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return (el.hasAttribute(\"multiple\") || Number(el.getAttribute(\"size\") || 0) > 1) ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"IMG\") return el.getAttribute(\"alt\") === \"\" ? \"presentation\" : \"img\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"HEADER\") return isInsideSectioningContent(el) ? \"generic\" : \"banner\";\n if (tag === \"FOOTER\") return isInsideSectioningContent(el) ? \"generic\" : \"contentinfo\";\n if (tag === \"ASIDE\") return \"complementary\";\n if (tag === \"UL\" || tag === \"OL\") return \"list\";\n if (tag === \"LI\") return \"listitem\";\n if (tag === \"TABLE\") return \"table\";\n if (tag === \"TR\") return \"row\";\n if (tag === \"TD\") return \"cell\";\n if (tag === \"TH\") {\n var scope = (el.getAttribute(\"scope\") || \"\").trim().toLowerCase();\n if (scope === \"row\" || scope === \"rowgroup\") return \"rowheader\";\n if (scope === \"col\" || scope === \"colgroup\") return \"columnheader\";\n var tr = el.parentElement;\n if (tr && tr.tagName && tr.tagName.toUpperCase() === \"TR\" && !(el.closest && el.closest(\"thead\"))) {\n if (tr.querySelector && tr.querySelector(\"td\")) return \"rowheader\";\n }\n return \"columnheader\";\n }\n if (tag === \"ARTICLE\") return \"article\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"FIELDSET\") return \"group\";\n if (tag === \"FIGURE\") return \"figure\";\n if (tag === \"METER\") return \"meter\";\n if (tag === \"OUTPUT\") return \"status\";\n if (tag === \"P\") return \"paragraph\";\n if (tag === \"STRONG\") return \"strong\";\n if (tag === \"PROGRESS\") return \"progressbar\";\n if (tag === \"HR\") return \"separator\";\n if (tag === \"SECTION\") {\n return (el.hasAttribute(\"aria-label\") || el.hasAttribute(\"aria-labelledby\") || Boolean((el.getAttribute(\"title\") || \"\").trim())) ? \"region\" : \"generic\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"INPUT\") {\n var t = (el.getAttribute(\"type\") || \"text\").toLowerCase();\n if (t === \"button\" || t === \"submit\" || t === \"reset\" || t === \"image\") return \"button\";\n if (t === \"checkbox\") return \"checkbox\";\n if (t === \"radio\") return \"radio\";\n if (t === \"search\") return el.hasAttribute(\"list\") ? \"combobox\" : \"searchbox\";\n if (t === \"number\") return \"spinbutton\";\n if (t === \"range\") return \"slider\";\n if (t === \"hidden\") return \"generic\";\n return el.hasAttribute(\"list\") ? \"combobox\" : \"textbox\";\n }\n return \"generic\";\n }\n var BLOCK_TAGS = {\n ADDRESS: 1, ARTICLE: 1, ASIDE: 1, BLOCKQUOTE: 1, BR: 1, DD: 1, DETAILS: 1,\n DIALOG: 1, DIV: 1, DL: 1, DT: 1, FIELDSET: 1, FIGCAPTION: 1, FIGURE: 1,\n FOOTER: 1, FORM: 1, H1: 1, H2: 1, H3: 1, H4: 1, H5: 1, H6: 1, HEADER: 1,\n HGROUP: 1, HR: 1, LI: 1, MAIN: 1, NAV: 1, OL: 1, P: 1, PRE: 1, SECTION: 1,\n SUMMARY: 1, TABLE: 1, TD: 1, TH: 1, TR: 1, UL: 1,\n };\n function visibleTextOf(node, allowHiddenRoot, skipControl) {\n if (!node) return \"\";\n if (node.nodeType === 3) return node.nodeValue || \"\";\n if (node.nodeType !== 1 && node.nodeType !== 11) return \"\";\n if (node.nodeType === 1) {\n if (skipControl && node === skipControl) return \"\";\n var t = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (t === \"BR\") return \" \";\n if (t === \"SCRIPT\" || t === \"STYLE\" || t === \"NOSCRIPT\" || t === \"TEMPLATE\") return \"\";\n if (skipControl && (t === \"SELECT\" || t === \"TEXTAREA\" || t === \"INPUT\")) return \"\";\n if (t === \"IMG\") {\n var imgAlt = node.getAttribute && node.getAttribute(\"alt\");\n return imgAlt ? normWs(imgAlt) : \"\";\n }\n if (t === \"SVG\") {\n var svgRole = (node.getAttribute && node.getAttribute(\"role\") || \"\").trim().toLowerCase();\n var svgLabel = node.getAttribute && node.getAttribute(\"aria-label\");\n if (svgLabel && svgLabel.trim()) return normWs(svgLabel);\n if (svgRole === \"img\") {\n var svgTitle = node.querySelector && node.querySelector(\"title\");\n if (svgTitle && svgTitle.textContent) return normWs(svgTitle.textContent);\n }\n }\n if (!allowHiddenRoot) {\n if (node.getAttribute && node.getAttribute(\"aria-hidden\") === \"true\") return \"\";\n var win = (node.ownerDocument && node.ownerDocument.defaultView) || window;\n if (win && win.getComputedStyle) {\n var st = win.getComputedStyle(node);\n if (st && (st.display === \"none\" || st.visibility === \"hidden\" || st.visibility === \"collapse\")) {\n return \"\";\n }\n }\n }\n }\n var out = [];\n if (node.shadowRoot) {\n var stxt = visibleTextOf(node.shadowRoot, false, skipControl);\n if (stxt) out.push(stxt);\n }\n var kids = node.childNodes || [];\n for (var i = 0; i < kids.length; i++) {\n var child = kids[i];\n var k = visibleTextOf(child, false, skipControl);\n if (!k) continue;\n var cTag = child && child.nodeType === 1 && child.tagName ? child.tagName.toUpperCase() : \"\";\n if (cTag && BLOCK_TAGS[cTag]) {\n out.push(\" \", k, \" \");\n } else {\n out.push(k);\n }\n }\n return normWs(out.join(\"\"));\n }\n function isHiddenInAncestorChain(el) {\n if (!el) return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 48) {\n if (cur.getAttribute) {\n if (cur.getAttribute(\"aria-hidden\") === \"true\") return true;\n }\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs) {\n if (cs.display === \"none\") return true;\n if (cs.contentVisibility === \"hidden\") return true;\n }\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (el.nodeType === 1 && win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return true;\n }\n return false;\n }\n function isAriaHidden(el) {\n if (el && el.tagName && el.tagName.toUpperCase() === \"OPTION\") {\n var parentSel = el.closest ? el.closest(\"select\") : el.parentElement;\n if (parentSel) {\n return isHiddenInAncestorChain(parentSel);\n }\n }\n if (isHiddenInAncestorChain(el)) return true;\n if (el && el.nodeType === 1) {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var st = win && win.getComputedStyle ? win.getComputedStyle(el) : null;\n if (st && st.display === \"contents\") {\n return !hasVisibleDescendant(el, 0);\n }\n }\n return false;\n }\n function hasVisibleDescendant(el, depth) {\n if (!el || depth > 8) return false;\n var kids = el.children || [];\n for (var i = 0; i < kids.length; i++) {\n var child = kids[i];\n if (!child || child.nodeType !== 1) continue;\n var cr = child.getBoundingClientRect ? child.getBoundingClientRect() : { width: 0, height: 0 };\n if (isVisible(child, cr, depth + 1)) return true;\n }\n if (el.shadowRoot && el.shadowRoot.children) {\n var skids = el.shadowRoot.children;\n for (var j = 0; j < skids.length; j++) {\n var sc = skids[j];\n if (!sc || sc.nodeType !== 1) continue;\n var sr = sc.getBoundingClientRect ? sc.getBoundingClientRect() : { width: 0, height: 0 };\n if (isVisible(sc, sr, depth + 1)) return true;\n }\n }\n return false;\n }\n function getContentsUnionRect(el, depth) {\n if (!el || depth > 8) return null;\n var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n var found = false;\n var visit = function(list) {\n for (var i = 0; i < list.length; i++) {\n var child = list[i];\n if (!child || child.nodeType !== 1) continue;\n var win = (child.ownerDocument && child.ownerDocument.defaultView) || window;\n var cst = win && win.getComputedStyle ? win.getComputedStyle(child) : null;\n if (cst && (cst.display === \"none\" || cst.visibility === \"hidden\" || cst.visibility === \"collapse\")) continue;\n if (child.getAttribute && child.getAttribute(\"aria-hidden\") === \"true\") continue;\n var r = cst && cst.display === \"contents\"\n ? getContentsUnionRect(child, depth + 1)\n : (child.getBoundingClientRect ? child.getBoundingClientRect() : null);\n if (r && r.width > 0 && r.height > 0) {\n found = true;\n if (r.x < minX) minX = r.x;\n if (r.y < minY) minY = r.y;\n if (r.x + r.width > maxX) maxX = r.x + r.width;\n if (r.y + r.height > maxY) maxY = r.y + r.height;\n }\n }\n };\n if (el.children) visit(el.children);\n if (el.shadowRoot && el.shadowRoot.children) visit(el.shadowRoot.children);\n if (!found) return null;\n return { x: minX, y: minY, left: minX, top: minY, width: maxX - minX, height: maxY - minY, right: maxX, bottom: maxY };\n }\n function headingLevelOf(el) {\n if (!el) return null;\n var explicit = el.getAttribute && el.getAttribute(\"aria-level\");\n if (explicit) {\n var parsed = parseInt(explicit, 10);\n if (!isNaN(parsed)) return parsed;\n }\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n var m = /^H([1-6])$/.exec(tag);\n return m ? parseInt(m[1], 10) : null;\n }\n function getAccessibleName(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var labelledBy = el.getAttribute && el.getAttribute(\"aria-labelledby\");\n if (labelledBy) {\n var parts = [];\n var ids = labelledBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaLabel = el.getAttribute && el.getAttribute(\"aria-label\");\n if (ariaLabel && ariaLabel.trim()) return ariaLabel.trim();\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") {\n if (el.id && doc.querySelector) {\n try {\n var escId = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(el.id) : el.id;\n var forLbl = doc.querySelector('label[for=\"' + escId + '\"]');\n if (forLbl) {\n var ft = visibleTextOf(forLbl, false, el);\n if (ft) return ft;\n }\n } catch (e) {}\n }\n if (el.closest) {\n var wrapLbl = el.closest(\"label\");\n if (wrapLbl) {\n var wt = visibleTextOf(wrapLbl, false, el);\n if (wt) return wt;\n }\n }\n var itype = tag === \"INPUT\" ? (el.getAttribute(\"type\") || \"text\").toLowerCase() : \"\";\n if ((itype === \"button\" || itype === \"submit\" || itype === \"reset\") && el.value) {\n return String(el.value).trim();\n }\n var ph = el.getAttribute && el.getAttribute(\"placeholder\");\n if (ph && ph.trim()) return ph.trim();\n }\n if (tag === \"IMG\") {\n var alt = el.getAttribute && el.getAttribute(\"alt\");\n if (alt && alt.trim()) return alt.trim();\n }\n if (tag === \"FIELDSET\") {\n var fkids = el.children || [];\n for (var fi = 0; fi < fkids.length; fi++) {\n var fk = fkids[fi];\n if (fk && fk.tagName && fk.tagName.toUpperCase() === \"LEGEND\") {\n var ltxt = visibleTextOf(fk, false, null);\n if (ltxt) return ltxt;\n break;\n }\n }\n }\n if (tag === \"TABLE\") {\n var tkids = el.children || [];\n for (var ti = 0; ti < tkids.length; ti++) {\n var tk = tkids[ti];\n if (tk && tk.tagName && tk.tagName.toUpperCase() === \"CAPTION\") {\n var ctxt = visibleTextOf(tk, false, null);\n if (ctxt) return ctxt;\n break;\n }\n }\n }\n if (tag === \"FIGURE\") {\n var fgkids = el.children || [];\n for (var fgi = 0; fgi < fgkids.length; fgi++) {\n var fgk = fgkids[fgi];\n if (fgk && fgk.tagName && fgk.tagName.toUpperCase() === \"FIGCAPTION\") {\n var fgtxt = visibleTextOf(fgk, false, null);\n if (fgtxt) return fgtxt;\n break;\n }\n }\n }\n var role = getImplicitRole(el);\n var nameFromAuthorOnly = {\n list: 1, navigation: 1, main: 1, region: 1, form: 1, dialog: 1, alertdialog: 1,\n table: 1, grid: 1, tablist: 1, tabpanel: 1, menu: 1, menubar: 1, toolbar: 1,\n tree: 1, group: 1, radiogroup: 1, feed: 1, article: 1, banner: 1, complementary: 1,\n contentinfo: 1, search: 1, combobox: 1, listbox: 1, log: 1, marquee: 1, status: 1,\n timer: 1, alert: 1, application: 1, document: 1, directory: 1, figure: 1, img: 1,\n math: 1, meter: 1, progressbar: 1, scrollbar: 1, separator: 1, slider: 1,\n spinbutton: 1, textbox: 1, searchbox: 1,\n };\n if (role && nameFromAuthorOnly[role]) {\n var authorTitle = el.getAttribute && el.getAttribute(\"title\");\n return authorTitle ? authorTitle.trim() : \"\";\n }\n var txt = visibleTextOf(el, false, null);\n if (txt) return txt;\n var title = el.getAttribute && el.getAttribute(\"title\");\n return title ? title.trim() : \"\";\n }\n function getAccessibleDescription(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var describedBy = el.getAttribute && el.getAttribute(\"aria-describedby\");\n if (describedBy) {\n var parts = [];\n var ids = describedBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaDesc = el.getAttribute && el.getAttribute(\"aria-description\");\n if (ariaDesc && ariaDesc.trim()) return ariaDesc.trim();\n var title = el.getAttribute && el.getAttribute(\"title\");\n if (title && title.trim()) {\n var accName = getAccessibleName(el);\n if (accName && accName !== title.trim()) return title.trim();\n }\n return \"\";\n }\n function getIframeTransform(frameEl) {\n var fr = frameEl.getBoundingClientRect();\n var fwin = (frameEl.ownerDocument && frameEl.ownerDocument.defaultView) || window;\n var fcs = fwin && fwin.getComputedStyle ? fwin.getComputedStyle(frameEl) : null;\n var bLeft = fcs ? (parseFloat(fcs.borderLeftWidth) || 0) : 0;\n var bTop = fcs ? (parseFloat(fcs.borderTopWidth) || 0) : 0;\n var bRight = fcs ? (parseFloat(fcs.borderRightWidth) || 0) : 0;\n var bBottom = fcs ? (parseFloat(fcs.borderBottomWidth) || 0) : 0;\n var layoutW = frameEl.offsetWidth || (frameEl.clientWidth + bLeft + bRight);\n var layoutH = frameEl.offsetHeight || (frameEl.clientHeight + bTop + bBottom);\n var sx = layoutW > 0 ? (fr.width / layoutW) : 1;\n var sy = layoutH > 0 ? (fr.height / layoutH) : 1;\n if (!isFinite(sx) || sx <= 0) sx = 1;\n if (!isFinite(sy) || sy <= 0) sy = 1;\n return { left: fr.left + bLeft * sx, top: fr.top + bTop * sy, scaleX: sx, scaleY: sy };\n }\n function collectRoots(root, offsetX, offsetY, scaleX, scaleY, inShadow, inIframe, out) {\n if (!root) return;\n out.push({ root: root, offsetX: offsetX, offsetY: offsetY, scaleX: scaleX, scaleY: scaleY, inShadow: inShadow, inIframe: inIframe });\n if (root.shadowRoot) {\n collectRoots(root.shadowRoot, offsetX, offsetY, scaleX, scaleY, true, inIframe, out);\n }\n var nodes = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var i = 0; i < nodes.length; i++) {\n var el = nodes[i];\n if (el.shadowRoot) {\n collectRoots(el.shadowRoot, offsetX, offsetY, scaleX, scaleY, true, inIframe, out);\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var frameDoc = el.contentDocument;\n if (frameDoc) {\n var ft = getIframeTransform(el);\n collectRoots(\n frameDoc,\n offsetX + ft.left * scaleX,\n offsetY + ft.top * scaleY,\n scaleX * ft.scaleX,\n scaleY * ft.scaleY,\n inShadow,\n true,\n out\n );\n }\n } catch (e) {}\n }\n }\n }\n function findTextInRoot(root, needle, exact, ctx, pushHit) {\n if (!root) return;\n var isRegex = Boolean(needle && typeof needle === \"object\" && typeof needle.__spanaRegex === \"string\");\n var rawNeedleStr = isRegex ? \"\" : String(needle == null ? \"\" : needle);\n var trimmedNeedle = normWs(rawNeedleStr);\n var lowerNeedle = trimmedNeedle.toLowerCase();\n if (!isRegex && !trimmedNeedle) return;\n\n var skipTags = { SCRIPT: 1, STYLE: 1, NOSCRIPT: 1, TEMPLATE: 1, HEAD: 1, META: 1, LINK: 1, TITLE: 1 };\n\n // Button-like <input> elements store their label in .value (not ancestor .textContent),\n // so check them directly before textContent-based subtree pruning.\n if (root.querySelectorAll) {\n var btnInputs = root.querySelectorAll('input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"]');\n for (var bi = 0; bi < btnInputs.length; bi++) {\n var bNode = btnInputs[bi];\n var bVal = normWs(bNode.value || \"\");\n if (bVal && matchSpec(bVal, needle, exact)) {\n pushHit(bNode, ctx);\n }\n }\n }\n\n function visitNode(node) {\n if (!node || node.nodeType !== 1) return false;\n var tag = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (skipTags[tag] || tag === \"INPUT\") return false;\n\n var normText = normWs(node.textContent || \"\");\n if (!isRegex) {\n if (!normText) return false;\n if (exact) {\n if (normText.indexOf(trimmedNeedle) === -1) return false;\n } else {\n if (normText.toLowerCase().indexOf(lowerNeedle) === -1) return false;\n }\n }\n\n var childMatched = false;\n var kids = node.children || [];\n for (var i = 0; i < kids.length; i++) {\n if (visitNode(kids[i])) childMatched = true;\n }\n if (childMatched) return true;\n\n if (normText && matchSpec(normText, needle, exact)) {\n pushHit(node, ctx);\n return true;\n }\n return false;\n }\n\n if (root.nodeType === 9) {\n var startEl = root.body || root.documentElement;\n if (startEl) visitNode(startEl);\n return;\n }\n if (root.nodeType === 11) {\n var fragKids = root.children || [];\n for (var fi = 0; fi < fragKids.length; fi++) visitNode(fragKids[fi]);\n return;\n }\n visitNode(root);\n }\n function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit, includeHidden, level, pressed) {\n if (!root || !root.querySelectorAll) return;\n var candidates = root.querySelectorAll(\"*\");\n for (var i = 0; i < candidates.length; i++) {\n var el = candidates[i];\n if (getImplicitRole(el) !== roleLower) continue;\n if (!includeHidden && isAriaHidden(el)) continue;\n if (level !== undefined && level !== null && headingLevelOf(el) !== Number(level)) continue;\n if (pressed !== undefined && pressed !== null) {\n var ap = (el.getAttribute && el.getAttribute(\"aria-pressed\") || \"\").trim().toLowerCase();\n if (pressed ? ap !== \"true\" : ap !== \"false\") continue;\n }\n if (nameSpec !== undefined && nameSpec !== null) {\n var accName = getAccessibleName(el);\n if (!matchSpec(accName, nameSpec, Boolean(exact))) continue;\n }\n pushHit(el, ctx);\n }\n }\n function isHitVisible(h) {\n if (!h) return false;\n if (h.wasmNode) {\n return h.wasmNode.visible !== false && h.wasmRect && h.wasmRect.width > 0 && h.wasmRect.height > 0;\n }\n if (!h.el || !h.el.getBoundingClientRect) return false;\n return isVisible(h.el, h.el.getBoundingClientRect());\n }\n function applyModifiersAndSlice(hits, sel, preferVisible) {\n if (!sel || typeof sel !== \"object\" || \"point\" in sel) return hits;\n var filtered = hits;\n if (sel.hasText !== undefined) {\n filtered = filtered.filter(function(h) {\n var normTc = normWs(h.el.textContent || \"\");\n var innerT = normWs(h.el.innerText || \"\");\n var fallbackTxt = normWs(h.el.value || getAccessibleName(h.el) || \"\");\n return matchSpec(normTc, sel.hasText, false) || matchSpec(innerT, sel.hasText, false) || matchSpec(fallbackTxt, sel.hasText, false);\n });\n }\n if (sel.hasNotText !== undefined) {\n filtered = filtered.filter(function(h) {\n var normTc = normWs(h.el.textContent || \"\");\n var innerT = normWs(h.el.innerText || \"\");\n var fallbackTxt = normWs(h.el.value || getAccessibleName(h.el) || \"\");\n return !matchSpec(normTc, sel.hasNotText, false) && !matchSpec(innerT, sel.hasNotText, false) && !matchSpec(fallbackTxt, sel.hasNotText, false);\n });\n }\n if (sel.has !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.has, h.el, h.offsetX, h.offsetY, h.scaleX, h.scaleY, h.inShadow, h.inIframe, preferVisible).length > 0;\n });\n }\n if (sel.hasNot !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.hasNot, h.el, h.offsetX, h.offsetY, h.scaleX, h.scaleY, h.inShadow, h.inIframe, preferVisible).length === 0;\n });\n }\n var wantsSlice = Boolean(sel.first || sel.last || typeof sel.nth === \"number\");\n if (wantsSlice && !sel.includeHidden && preferVisible) {\n var visibleFiltered = filtered.filter(isHitVisible);\n if (preferVisible === \"strict\" || visibleFiltered.length > 0) {\n filtered = visibleFiltered;\n }\n }\n if (sel.first) return filtered.length > 0 ? [filtered[0]] : [];\n if (sel.last) return filtered.length > 0 ? [filtered[filtered.length - 1]] : [];\n if (typeof sel.nth === \"number\") {\n var idx = sel.nth < 0 ? filtered.length + sel.nth : sel.nth;\n return idx >= 0 && idx < filtered.length ? [filtered[idx]] : [];\n }\n return filtered;\n }\n function findInScope(sel, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible) {\n var hits = [];\n var seen = typeof Set !== \"undefined\" ? new Set() : null;\n function pushHit(el, ctx) {\n if (seen) {\n if (seen.has(el)) return;\n seen.add(el);\n }\n hits.push({\n el: el,\n offsetX: ctx.offsetX,\n offsetY: ctx.offsetY,\n scaleX: ctx.scaleX != null ? ctx.scaleX : 1,\n scaleY: ctx.scaleY != null ? ctx.scaleY : 1,\n inShadow: ctx.inShadow,\n inIframe: ctx.inIframe\n });\n }\n if (typeof sel === \"object\" && sel !== null && \"point\" in sel) {\n var atPt = document.elementFromPoint(sel.point.x, sel.point.y);\n if (atPt) pushHit(atPt, { offsetX: 0, offsetY: 0, scaleX: 1, scaleY: 1, inShadow: false, inIframe: false });\n return hits;\n }\n // Frame scoping: find matching <iframe> first, then search inside its contentDocument\n if (typeof sel === \"object\" && sel !== null && sel.frame) {\n var frameHits = findInScope(sel.frame, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var innerSel = Object.assign({}, sel);\n delete innerSel.frame;\n for (var fi = 0; fi < frameHits.length; fi++) {\n var fEl = frameHits[fi].el;\n if (fEl && fEl.tagName === \"IFRAME\") {\n try {\n var fDoc = fEl.contentDocument;\n if (fDoc) {\n var fTr = getIframeTransform(fEl);\n var pSx = frameHits[fi].scaleX != null ? frameHits[fi].scaleX : 1;\n var pSy = frameHits[fi].scaleY != null ? frameHits[fi].scaleY : 1;\n var sub = findInScope(\n innerSel,\n fDoc,\n frameHits[fi].offsetX + fTr.left * pSx,\n frameHits[fi].offsetY + fTr.top * pSy,\n pSx * fTr.scaleX,\n pSy * fTr.scaleY,\n frameHits[fi].inShadow,\n true,\n preferVisible\n );\n for (var si = 0; si < sub.length; si++) pushHit(sub[si].el, sub[si]);\n }\n } catch (e) {}\n }\n }\n return hits;\n }\n // Parent scoping: resolve 'within' first, then search inside each matched container\n if (typeof sel === \"object\" && sel !== null && sel.within) {\n var parentHits = findInScope(sel.within, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var childSel = Object.assign({}, sel);\n delete childSel.within;\n delete childSel.hasText;\n delete childSel.hasNotText;\n delete childSel.has;\n delete childSel.hasNot;\n delete childSel.first;\n delete childSel.last;\n delete childSel.nth;\n var combined = [];\n var cSeen = typeof Set !== \"undefined\" ? new Set() : null;\n for (var pi = 0; pi < parentHits.length; pi++) {\n var ph = parentHits[pi];\n var subHits = findInScope(childSel, ph.el, ph.offsetX, ph.offsetY, ph.scaleX, ph.scaleY, ph.inShadow, ph.inIframe, preferVisible);\n for (var ci = 0; ci < subHits.length; ci++) {\n if (cSeen && cSeen.has(subHits[ci].el)) continue;\n if (cSeen) cSeen.add(subHits[ci].el);\n combined.push(subHits[ci]);\n }\n }\n return applyModifiersAndSlice(combined, sel, preferVisible);\n }\n // Logical OR composition (anyOf): union deduplicated hits across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.anyOf)) {\n for (var bi = 0; bi < sel.anyOf.length; bi++) {\n var branchHits = findInScope(sel.anyOf[bi], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n for (var bh = 0; bh < branchHits.length; bh++) {\n pushHit(branchHits[bh].el, branchHits[bh]);\n }\n }\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n // Logical AND composition (allOf): intersection of matched elements across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.allOf) && sel.allOf.length > 0) {\n var firstBranch = findInScope(sel.allOf[0], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var currentHits = firstBranch;\n for (var ai = 1; ai < sel.allOf.length && currentHits.length > 0; ai++) {\n var nextBranch = findInScope(sel.allOf[ai], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var nextEls = typeof Set !== \"undefined\" ? new Set(nextBranch.map(function(h) { return h.el; })) : null;\n currentHits = currentHits.filter(function(h) {\n if (nextEls) return nextEls.has(h.el);\n return nextBranch.some(function(nh) { return nh.el === h.el; });\n });\n }\n for (var ahi = 0; ahi < currentHits.length; ahi++) pushHit(currentHits[ahi].el, currentHits[ahi]);\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n\n function queryCssSafe(root, cssStr) {\n try {\n return root.querySelectorAll(cssStr);\n } catch (e) {\n var hint = \"\";\n if (/:has-text\\(/.test(cssStr)) hint = \" (Playwright :has-text() is not valid CSS; use { ..., hasText: ... } instead)\";\n else if (cssStr.indexOf(\">>\") !== -1) hint = \" (Playwright >> chaining is not valid CSS; use within(parent, child) instead)\";\n else if (/\\bnth=/.test(cssStr)) hint = \" (Playwright nth= is not valid CSS; use { ..., nth: index } instead)\";\n throw new Error('Invalid CSS selector \"' + cssStr + '\": ' + (e && e.message ? e.message : String(e)) + hint);\n }\n }\n function findByLabelInRoot(root, spec, exact, ctx, push) {\n if (!root || !root.querySelectorAll) return;\n var seen = new Set();\n var addCtrl = function(c) {\n if (!c || seen.has(c)) return;\n if (c.tagName === \"INPUT\" && (c.getAttribute(\"type\") || \"\").toLowerCase() === \"hidden\") return;\n seen.add(c);\n push(c, ctx);\n };\n // 1. Explicit <label> elements (associated via .control, [for], or nested labelable control)\n var labels = root.querySelectorAll(\"label\");\n for (var lb = 0; lb < labels.length; lb++) {\n var lblEl = labels[lb];\n var ctrlFromLbl = lblEl.control || null;\n if (!ctrlFromLbl && lblEl.getAttribute) {\n var forAttr = lblEl.getAttribute(\"for\");\n if (forAttr) {\n var lblRoot = typeof lblEl.getRootNode === \"function\" ? lblEl.getRootNode() : null;\n if (lblRoot && typeof lblRoot.getElementById === \"function\") {\n ctrlFromLbl = lblRoot.getElementById(forAttr);\n }\n if (!ctrlFromLbl) {\n var lblDoc = lblEl.ownerDocument || document;\n ctrlFromLbl = lblDoc.getElementById ? lblDoc.getElementById(forAttr) : null;\n }\n if (!ctrlFromLbl && root.querySelector) {\n try {\n var escFor = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(forAttr) : forAttr;\n ctrlFromLbl = root.querySelector('[id=\"' + escFor + '\"]');\n } catch (e) {}\n }\n }\n }\n if (!ctrlFromLbl && lblEl.querySelector) {\n ctrlFromLbl = lblEl.querySelector(\"input:not([type=hidden]), textarea, select, meter, output, progress\");\n }\n if (!ctrlFromLbl) continue;\n var rawLblText = visibleTextOf(lblEl, false, ctrlFromLbl) || normWs(lblEl.textContent || \"\");\n var fullLblText = !lblEl.contains(ctrlFromLbl) ? normWs(lblEl.textContent || \"\") : \"\";\n if (\n (rawLblText && matchSpec(rawLblText, spec, exact)) ||\n (fullLblText && matchSpec(fullLblText, spec, exact))\n ) {\n addCtrl(ctrlFromLbl);\n }\n }\n // 2. Labelable form controls & ARIA form widgets (never match <button> by its inner text)\n var labelableRoles = {\n textbox: 1, searchbox: 1, combobox: 1, listbox: 1, spinbutton: 1,\n slider: 1, checkbox: 1, radio: 1, switch: 1,\n };\n var controls = root.querySelectorAll(\"input, textarea, select, meter, output, progress, audio, video, [contenteditable], [aria-label], [aria-labelledby]\");\n for (var li = 0; li < controls.length; li++) {\n var ctrl = controls[li];\n if (seen.has(ctrl)) continue;\n if (ctrl.tagName === \"INPUT\" && (ctrl.getAttribute(\"type\") || \"\").toLowerCase() === \"hidden\") continue;\n var tag = ctrl.tagName ? ctrl.tagName.toUpperCase() : \"\";\n var isFormControl =\n tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" ||\n tag === \"METER\" || tag === \"OUTPUT\" || tag === \"PROGRESS\" ||\n tag === \"AUDIO\" || tag === \"VIDEO\" ||\n (ctrl.hasAttribute && ctrl.hasAttribute(\"contenteditable\"));\n var role = getImplicitRole(ctrl);\n if (!isFormControl && !labelableRoles[role]) continue;\n var labelText = getAccessibleName(ctrl);\n if (!labelText && ctrl.labels && ctrl.labels.length > 0) {\n var parts = [];\n for (var lj = 0; lj < ctrl.labels.length; lj++) {\n parts.push((ctrl.labels[lj].textContent || \"\").trim());\n }\n labelText = parts.join(\" \").trim();\n }\n if (labelText && matchSpec(labelText, spec, exact)) {\n addCtrl(ctrl);\n }\n }\n }\n function findByAttrSpecInRoot(root, attrName, spec, exact, ctx, push) {\n if (!root || !root.querySelectorAll) return;\n var nodes = root.querySelectorAll(\"[\" + attrName + \"]\");\n for (var ni = 0; ni < nodes.length; ni++) {\n var val = nodes[ni].getAttribute(attrName);\n if (val !== null && matchSpec(val, spec, exact)) {\n push(nodes[ni], ctx);\n }\n }\n }\n\n var esc = function(v) {\n return typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(v) : String(v).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n };\n var mainCtx = { root: scopeRoot, offsetX: baseOffsetX, offsetY: baseOffsetY, scaleX: baseScaleX, scaleY: baseScaleY, inShadow: baseInShadow, inIframe: baseInIframe };\n var hasModifiers = typeof sel === \"object\" && sel !== null && (sel.hasText !== undefined || sel.hasNotText !== undefined || sel.has !== undefined || sel.hasNot !== undefined || sel.first || sel.last || typeof sel.nth === \"number\");\n\n // O(1)-ish Light-DOM fast path: avoids scanning thousands of nodes with querySelectorAll(\"*\")\n // unless Shadow DOM / iframe piercing is needed or no Light-DOM match exists.\n if (scopeRoot && scopeRoot.querySelectorAll && !hasModifiers) {\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var fastTid = esc(sel.testID);\n var fastFound = scopeRoot.querySelectorAll('[data-testid=\"' + fastTid + '\"], [testID=\"' + fastTid + '\"]');\n if (fastFound.length > 0) {\n for (var fi2 = 0; fi2 < fastFound.length; fi2++) pushHit(fastFound[fi2], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n var fastCss = queryCssSafe(scopeRoot, sel.css);\n if (fastCss.length > 0) {\n for (var fc = 0; fc < fastCss.length; fc++) pushHit(fastCss[fc], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var fastLbl = esc(sel.accessibilityLabel);\n var fastFoundLbl = scopeRoot.querySelectorAll('[aria-label=\"' + fastLbl + '\"]');\n if (fastFoundLbl.length > 0) {\n for (var fj = 0; fj < fastFoundLbl.length; fj++) pushHit(fastFoundLbl[fj], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"label\" in sel) {\n findByLabelInRoot(scopeRoot, sel.label, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"placeholder\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"placeholder\", sel.placeholder, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"altText\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"alt\", sel.altText, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"title\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"title\", sel.title, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit, sel.includeHidden, sel.level, sel.pressed);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var fastNeedle = typeof sel === \"string\" ? sel : sel.text;\n var fastExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(scopeRoot, fastNeedle, fastExact, mainCtx, pushHit);\n if (hits.length > 0) return hits;\n }\n }\n\n var roots = [];\n collectRoots(scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, roots);\n for (var r = 0; r < roots.length; r++) {\n var ctx = roots[r];\n var root = ctx.root;\n if (!root || !root.querySelectorAll) continue;\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var tid = esc(sel.testID);\n var found = root.querySelectorAll('[data-testid=\"' + tid + '\"], [testID=\"' + tid + '\"]');\n for (var i = 0; i < found.length; i++) pushHit(found[i], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n var foundCss = queryCssSafe(root, sel.css);\n for (var ci2 = 0; ci2 < foundCss.length; ci2++) pushHit(foundCss[ci2], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var lbl = esc(sel.accessibilityLabel);\n var foundLbl = root.querySelectorAll('[aria-label=\"' + lbl + '\"]');\n for (var j = 0; j < foundLbl.length; j++) pushHit(foundLbl[j], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"label\" in sel) {\n findByLabelInRoot(root, sel.label, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"placeholder\" in sel) {\n findByAttrSpecInRoot(root, \"placeholder\", sel.placeholder, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"altText\" in sel) {\n findByAttrSpecInRoot(root, \"alt\", sel.altText, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"title\" in sel) {\n findByAttrSpecInRoot(root, \"title\", sel.title, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit, sel.includeHidden, sel.level, sel.pressed);\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var needle = typeof sel === \"string\" ? sel : sel.text;\n var isExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(root, needle, isExact, ctx, pushHit);\n }\n }\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n function findWasmSemanticHits(sel) {\n if (typeof window === \"undefined\" || !window.__SPANA_WASM_TREE__) return [];\n var provider = window.__SPANA_WASM_TREE__;\n var nodes;\n try { nodes = typeof provider === \"function\" ? provider() : provider; } catch (e) { return []; }\n if (!Array.isArray(nodes) || nodes.length === 0) return [];\n var matched = [];\n for (var i = 0; i < nodes.length; i++) {\n var n = nodes[i];\n if (!n || typeof n !== \"object\" || !n.bounds) continue;\n var nid = n.testID || n.id || \"\";\n var ntext = String(n.text != null ? n.text : (n.label != null ? n.label : \"\"));\n var nlabel = String(n.label != null ? n.label : \"\");\n var nrole = String(n.role || \"\");\n var ok = false;\n if (typeof sel === \"string\") {\n ok = nid === sel || ntext === sel;\n } else if (sel && typeof sel === \"object\") {\n if (sel.testID !== undefined) {\n ok = nid === sel.testID;\n } else if (sel.text !== undefined) {\n ok = sel.exact ? ntext.trim() === String(sel.text).trim() : ntext.indexOf(String(sel.text)) !== -1;\n } else if (sel.accessibilityLabel !== undefined) {\n ok = nlabel === sel.accessibilityLabel || ntext === sel.accessibilityLabel;\n } else if (sel.role !== undefined) {\n var rOk = nrole.toLowerCase() === String(sel.role).toLowerCase();\n var nameOk = true;\n if (sel.name !== undefined) {\n if (typeof sel.name === \"object\" && sel.name && sel.name.__regex) {\n var re = new RegExp(sel.name.source, sel.name.flags || \"\");\n nameOk = re.test(ntext) || re.test(nlabel);\n } else {\n var exp = String(sel.name);\n nameOk = sel.exact\n ? (ntext.trim() === exp.trim() || nlabel.trim() === exp.trim())\n : (ntext.toLowerCase().indexOf(exp.toLowerCase()) !== -1 || nlabel.toLowerCase().indexOf(exp.toLowerCase()) !== -1);\n }\n }\n ok = rOk && nameOk;\n }\n }\n if (!ok) continue;\n var ox = 0;\n var oy = 0;\n var hostEl = null;\n if (n.canvasSelector && typeof document !== \"undefined\" && document.querySelector) {\n try {\n hostEl = document.querySelector(n.canvasSelector);\n if (hostEl && typeof hostEl.getBoundingClientRect === \"function\") {\n var cr = hostEl.getBoundingClientRect();\n ox = cr.left || 0;\n oy = cr.top || 0;\n }\n } catch (e) {}\n }\n var bx = (n.bounds.x || 0) + ox;\n var by = (n.bounds.y || 0) + oy;\n var bw = n.bounds.width || 0;\n var bh = n.bounds.height || 0;\n var vRect = { left: bx, top: by, x: bx, y: by, width: bw, height: bh, right: bx + bw, bottom: by + bh };\n var virtualEl = {\n isConnected: true,\n tagName: \"WASM-NODE\",\n innerText: ntext,\n textContent: ntext,\n value: n.value,\n __spanaHostCanvas: hostEl,\n getBoundingClientRect: function() { return vRect; },\n getAttribute: function(k) {\n if (k === \"data-testid\" || k === \"testID\") return nid || null;\n if (k === \"role\") return nrole || null;\n if (k === \"aria-label\") return nlabel || null;\n return (n.attributes && n.attributes[k]) || null;\n },\n hasAttribute: function(k) { return this.getAttribute(k) !== null; }\n };\n matched.push({ el: virtualEl, offsetX: 0, offsetY: 0, inShadow: false, inIframe: false, wasmNode: n, wasmRect: vRect });\n }\n return matched;\n }\n function findAcrossRoots(sel, preferVisible) {\n var pv = preferVisible === undefined ? \"prefer\" : preferVisible;\n var domHits = findInScope(sel, document, 0, 0, 1, 1, false, false, pv);\n var wasmHits = findWasmSemanticHits(sel);\n if (wasmHits.length === 0) return domHits;\n return domHits.length === 0 ? wasmHits : domHits.concat(wasmHits);\n }\n function isClickable(el) {\n var tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"A\" || tag === \"INPUT\" || tag === \"SELECT\" || tag === \"TEXTAREA\") return true;\n var role = el.getAttribute && el.getAttribute(\"role\");\n if (role === \"button\" || role === \"link\" || role === \"tab\" || role === \"checkbox\" || role === \"switch\") return true;\n if (typeof el.onclick === \"function\") return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cursor = win.getComputedStyle(el).cursor;\n return cursor === \"pointer\";\n }\n function isAppReady() {\n var sig = typeof window !== \"undefined\" ? window.__SPANA_APP_READY__ : undefined;\n if (typeof sig === \"function\") {\n try { return Boolean(sig()); } catch (e) { return false; }\n }\n if (typeof sig === \"boolean\") return sig;\n return true;\n }\n function deepElementFromPoint(rootDoc, x, y) {\n if (!rootDoc || typeof rootDoc.elementFromPoint !== \"function\") return null;\n var el = rootDoc.elementFromPoint(x, y);\n var guard = 0;\n while (el && guard++ < 16) {\n if (el.shadowRoot && typeof el.shadowRoot.elementFromPoint === \"function\") {\n var inner = el.shadowRoot.elementFromPoint(x, y);\n if (inner && inner !== el) { el = inner; continue; }\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var fdoc = el.contentDocument;\n if (fdoc && typeof fdoc.elementFromPoint === \"function\") {\n var ft = getIframeTransform(el);\n var fx = (x - ft.left) / ft.scaleX;\n var fy = (y - ft.top) / ft.scaleY;\n var fEl = fdoc.elementFromPoint(fx, fy);\n if (fEl && fEl !== el) { el = fEl; x = fx; y = fy; continue; }\n }\n } catch (e) {}\n }\n break;\n }\n return el;\n }\n function labelControlOf(node) {\n var cur = node;\n var guard = 0;\n while (cur && guard++ < 8) {\n if (cur.tagName === \"LABEL\") return cur.control || null;\n cur = cur.parentElement;\n }\n return null;\n }\n function isSameOrDescendant(target, candidate) {\n if (!target || !candidate) return false;\n if (target === candidate) return true;\n try {\n if (typeof target.contains === \"function\" && target.contains(candidate)) return true;\n } catch (e) {}\n if (labelControlOf(candidate) === target) return true;\n var cur = candidate;\n var guard = 0;\n while (cur && guard++ < 24) {\n if (cur === target) return true;\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n if (root && root.host) {\n cur = root.host;\n } else {\n cur = cur.parentElement;\n }\n }\n return false;\n }\n function describeEl(el) {\n if (!el) return \"(unknown)\";\n var tag = el.tagName ? el.tagName.toLowerCase() : \"element\";\n var idPart = el.id ? \"#\" + el.id : \"\";\n var cls = typeof el.className === \"string\" ? el.className.trim().split(/\\s+/).filter(Boolean).slice(0, 3).join(\".\") : \"\";\n var clsPart = cls ? \".\" + cls : \"\";\n var txt = (el.innerText || el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n if (txt.length > 40) txt = txt.slice(0, 37) + \"...\";\n return \"<\" + tag + idPart + clsPart + (txt ? \">\" + txt + \"</\" + tag + \">\" : \">\");\n }\n function getHitTestBlocker(hit) {\n if (hit.wasmNode) {\n var wr = hit.wasmRect;\n var wvw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || 0;\n var wvh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || 0;\n var wcx = wr.left + wr.width / 2;\n var wcy = wr.top + wr.height / 2;\n if (wvw > 0 && wvh > 0 && (wcx < 0 || wcy < 0 || wcx > wvw || wcy > wvh)) return \"outside viewport\";\n if (hit.el && hit.el.__spanaHostCanvas) {\n var topW = deepElementFromPoint(document, wcx, wcy);\n if (topW && !isSameOrDescendant(hit.el.__spanaHostCanvas, topW)) return describeEl(topW);\n }\n return null;\n }\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = hit.offsetX + (rect.left + rect.width / 2) * sx;\n var cy = hit.offsetY + (rect.top + rect.height / 2) * sy;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return \"outside viewport\";\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return null;\n if (isSameOrDescendant(el, topEl)) return null;\n return describeEl(topEl);\n }\n function getClippedViewportBox(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var left = hit.offsetX + rect.left * sx;\n var top = hit.offsetY + rect.top * sy;\n var right = hit.offsetX + (rect.left + rect.width) * sx;\n var bottom = hit.offsetY + (rect.top + rect.height) * sy;\n // Intersect with clipping ancestors (overflow: hidden/clip/scroll/auto) so half-clipped buttons\n // target their visible region rather than clicking a clipped-out center onto the parent container.\n var cur = el.parentElement;\n var guard = 0;\n while (cur && guard++ < 32) {\n var cs = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(cur) : null;\n if (cs) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n if (ox === \"hidden\" || ox === \"clip\" || ox === \"scroll\" || ox === \"auto\" ||\n oy === \"hidden\" || oy === \"clip\" || oy === \"scroll\" || oy === \"auto\") {\n var cr = cur.getBoundingClientRect();\n if (cr.width > 0 && cr.height > 0) {\n var cLeft = hit.offsetX + cr.left * sx;\n var cTop = hit.offsetY + cr.top * sy;\n var cRight = hit.offsetX + cr.right * sx;\n var cBottom = hit.offsetY + cr.bottom * sy;\n if (ox === \"hidden\" || ox === \"clip\" || ox === \"scroll\" || ox === \"auto\") {\n if (cLeft > left) left = cLeft;\n if (cRight < right) right = cRight;\n }\n if (oy === \"hidden\" || oy === \"clip\" || oy === \"scroll\" || oy === \"auto\") {\n if (cTop > top) top = cTop;\n if (cBottom < bottom) bottom = cBottom;\n }\n }\n }\n }\n cur = cur.parentElement;\n }\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n if (vw > 0 && vh > 0) {\n if (left < 0) left = 0;\n if (top < 0) top = 0;\n if (right > vw) right = vw;\n if (bottom > vh) bottom = vh;\n }\n return { left: left, top: top, right: right, bottom: bottom, vw: vw, vh: vh, rawRect: rect, sx: sx, sy: sy };\n }\n function findClickablePoint(hit) {\n if (hit.wasmNode) {\n var wr = hit.wasmRect;\n return { x: wr.left + wr.width / 2, y: wr.top + wr.height / 2 };\n }\n var el = hit.el;\n var box = getClippedViewportBox(hit);\n var rawCx = hit.offsetX + (box.rawRect.left + box.rawRect.width / 2) * box.sx;\n var rawCy = hit.offsetY + (box.rawRect.top + box.rawRect.height / 2) * box.sy;\n var clipW = box.right - box.left;\n var clipH = box.bottom - box.top;\n if (box.vw > 0 && box.vh > 0 && (clipW <= 0 || clipH <= 0)) {\n return null;\n }\n var tryPt = function(px, py) {\n if (box.vw > 0 && box.vh > 0 && (px < 0 || py < 0 || px >= box.vw || py >= box.vh)) return null;\n var topEl = deepElementFromPoint(document, px, py);\n if (!topEl || isSameOrDescendant(el, topEl)) return { x: px, y: py };\n return null;\n };\n // 1. Fast path: unclipped rounded center (matches 99.9% of elements in 1 hit-test call)\n var rRaw = tryPt(Math.round(rawCx), Math.round(rawCy));\n if (rRaw) return rRaw;\n // 2. Clipped visible center (rounded, then fractional)\n var cx = box.left + clipW / 2;\n var cy = box.top + clipH / 2;\n var rClip = tryPt(Math.round(cx), Math.round(cy));\n if (rClip) return rClip;\n var fClip = tryPt(cx, cy);\n if (fClip) return fClip;\n // 3. Interior points inside the visible clipped rect (handles 0.5px edge rounding onto clipping parent)\n var padX = Math.min(2, clipW / 4);\n var padY = Math.min(2, clipH / 4);\n var candidates = [\n [Math.floor(cx), Math.floor(cy)],\n [Math.ceil(cx), Math.floor(cy)],\n [Math.floor(cx), Math.ceil(cy)],\n [Math.floor(box.left + padX), Math.floor(box.top + padY)],\n [Math.ceil(box.left + padX), Math.ceil(box.top + padY)],\n [Math.floor(box.right - padX), Math.floor(box.bottom - padY)],\n [box.left + padX, box.top + padY],\n [box.right - padX, box.bottom - padY],\n ];\n for (var i = 0; i < candidates.length; i++) {\n var hitPt = tryPt(candidates[i][0], candidates[i][1]);\n if (hitPt) return hitPt;\n }\n return null;\n }\n function isHitTestClear(hit) {\n if (hit.wasmNode) {\n return getHitTestBlocker(hit) === null;\n }\n var pt = findClickablePoint(hit);\n if (pt) {\n hit._clickPoint = pt;\n return true;\n }\n hit._clickPoint = null;\n return false;\n }\n function isScrollableOverflow(val) {\n return val === \"auto\" || val === \"scroll\" || val === \"overlay\";\n }\n function isClippedByScrollableAncestor(hit, rect) {\n var el = hit.el;\n var doc = el.ownerDocument || document;\n var win = doc.defaultView || window;\n var cur = el.parentElement;\n var guard = 0;\n while (cur && cur.nodeType === 1 && guard++ < 32) {\n if (cur === doc.documentElement || cur === doc.body) break;\n var cs = win && win.getComputedStyle ? win.getComputedStyle(cur) : null;\n if (cs) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n var canScrollX = isScrollableOverflow(ox) && cur.scrollWidth > cur.clientWidth + 1;\n var canScrollY = isScrollableOverflow(oy) && cur.scrollHeight > cur.clientHeight + 1;\n if (canScrollX || canScrollY) {\n var cr = cur.getBoundingClientRect();\n if (cr.width > 0 && cr.height > 0) {\n if (canScrollX && (rect.left < cr.left - 0.5 || rect.right > cr.right + 0.5)) {\n return true;\n }\n if (canScrollY && (rect.top < cr.top - 0.5 || rect.bottom > cr.bottom + 0.5)) {\n return true;\n }\n }\n }\n // Inspect a position: fixed ancestor itself FIRST (it may be scrollable),\n // then stop walking above its fixed containing boundary.\n if (cs.position === \"fixed\") break;\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isFullyInViewport(hit) {\n if (hit.wasmNode) return true;\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n if (vw <= 0 || vh <= 0 || rect.width <= 0 || rect.height <= 0) return false;\n var left = hit.offsetX + rect.left * sx;\n var top = hit.offsetY + rect.top * sy;\n if (!(left >= 0 && top >= 0 && (left + rect.width * sx) <= vw && (top + rect.height * sy) <= vh)) {\n return false;\n }\n if (isClippedByScrollableAncestor(hit, rect)) return false;\n return true;\n }\n function ensureInViewport(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = hit.offsetX + (rect.left + rect.width / 2) * sx;\n var cy = hit.offsetY + (rect.top + rect.height / 2) * sy;\n var outsideWindow = vw > 0 && vh > 0 && (cx < 1 || cy < 1 || cx > vw - 1 || cy > vh - 1);\n if (outsideWindow || isClippedByScrollableAncestor(hit, rect)) {\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { el.scrollIntoView(true); } catch (e2) {} }\n }\n return true;\n }\n return false;\n }\n function canScrollToUnobscure(hit) {\n if (!hit || !hit.el || hit.wasmNode) return false;\n var el = hit.el;\n var doc = el.ownerDocument || document;\n var win = doc.defaultView || window;\n var hasScrollableAncestor = false;\n var hitFixedBoundary = false;\n var cur = el;\n var guard = 0;\n while (cur && cur.nodeType === 1 && guard++ < 32) {\n var cs = win && win.getComputedStyle ? win.getComputedStyle(cur) : null;\n if (cs) {\n if (cur !== el && cur !== doc.documentElement && cur !== doc.body) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n if ((isScrollableOverflow(ox) && cur.scrollWidth > cur.clientWidth + 1) ||\n (isScrollableOverflow(oy) && cur.scrollHeight > cur.clientHeight + 1)) {\n hasScrollableAncestor = true;\n }\n }\n if (cs.position === \"fixed\") {\n hitFixedBoundary = true;\n break;\n }\n }\n cur = cur.parentElement;\n }\n var rect = el.getBoundingClientRect();\n // If clipped outside a scrollable ancestor (including inside/on a position: fixed dialog),\n // scrolling that ancestor brings the target into view even if the clipped point hits a backdrop.\n if (hasScrollableAncestor && isClippedByScrollableAncestor(hit, rect)) {\n return true;\n }\n if (hitFixedBoundary && !hasScrollableAncestor) return false;\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var topEl = deepElementFromPoint(doc, cx, cy);\n if (!topEl) return false;\n var vpW = win.innerWidth || doc.documentElement.clientWidth || 1280;\n var vpH = win.innerHeight || doc.documentElement.clientHeight || 720;\n var b = topEl;\n while (b && b.nodeType === 1) {\n var bs = win && win.getComputedStyle ? win.getComputedStyle(b) : null;\n if (bs && (bs.position === \"fixed\" || bs.position === \"sticky\")) {\n var br = b.getBoundingClientRect();\n if (br.width >= vpW * 0.8 && br.height >= vpH * 0.8) return false;\n return true;\n }\n b = b.parentElement;\n }\n return false;\n }\n function scrollToUnobscure(hit) {\n var el = hit.el;\n if (typeof el.scrollIntoView !== \"function\") return false;\n var blocks = [\"center\", \"end\", \"start\", \"nearest\"];\n for (var i = 0; i < blocks.length; i++) {\n try {\n el.scrollIntoView({ block: blocks[i], inline: \"center\", behavior: \"instant\" });\n } catch (e) {\n try { el.scrollIntoView(true); } catch (e2) {}\n }\n if (!el.isConnected) {\n try { window.__spanaLastScrollDetached = true; } catch (e3) {}\n return false;\n }\n if (isHitTestClear(hit)) return true;\n }\n return false;\n }\n function hasActiveViewTransition() {\n if (typeof document === \"undefined\" || typeof document.getAnimations !== \"function\") return false;\n try {\n var allAnims = document.getAnimations();\n for (var i = 0; i < allAnims.length; i++) {\n var a = allAnims[i];\n var pseudo = a && a.effect && a.effect.pseudoElement;\n if (a && a.playState === \"running\" && typeof pseudo === \"string\" && pseudo.indexOf(\"::view-transition\") === 0) {\n return true;\n }\n }\n } catch (e) {}\n return false;\n }\n function hasActiveAnimation(el) {\n if (hasActiveViewTransition()) return true;\n var cur = el;\n var depth = 0;\n while (cur && depth++ < 8) {\n if (typeof cur.getAnimations === \"function\") {\n try {\n var anims = cur.getAnimations();\n for (var i = 0; i < anims.length; i++) {\n if (anims[i] && anims[i].playState === \"running\") return true;\n }\n } catch (e) {}\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isElementEnabled(el) {\n if (!el) return true;\n if (el.hasAttribute && el.hasAttribute(\"disabled\")) return false;\n if (el.getAttribute && el.getAttribute(\"aria-disabled\") === \"true\") return false;\n try {\n if (typeof el.matches === \"function\" && el.matches(\":disabled\")) return false;\n } catch (e) {}\n var cur = el.parentElement;\n var guard = 0;\n while (cur && guard++ < 16) {\n if (cur.getAttribute && cur.getAttribute(\"aria-disabled\") === \"true\") return false;\n cur = cur.parentElement;\n }\n return true;\n }\n function isVisible(el, rect, depth) {\n if (!el) return false;\n if (isHiddenInAncestorChain(el)) return false;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var style = win && win.getComputedStyle ? win.getComputedStyle(el) : null;\n if (style && style.display === \"contents\") {\n return hasVisibleDescendant(el, depth || 0);\n }\n if (!rect || rect.width <= 0 || rect.height <= 0) return false;\n return true;\n }\n function toMatch(hit) {\n if (hit.wasmNode) {\n var wn = hit.wasmNode;\n var wr = hit.wasmRect;\n var wtext = (wn.text != null ? String(wn.text) : (wn.label != null ? String(wn.label) : \"\")).trim() || undefined;\n return {\n id: wn.testID || wn.id || undefined,\n tag: \"wasm-node\",\n role: wn.role || undefined,\n text: wtext,\n textContent: wtext,\n value: wn.value != null ? String(wn.value) : undefined,\n accessibilityLabel: wn.label || undefined,\n accessibleName: wn.label || wtext,\n rect: { x: wr.left, y: wr.top, width: wr.width, height: wr.height },\n scrollX: window.scrollX || 0,\n scrollY: window.scrollY || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: window.innerWidth || 0,\n viewportHeight: window.innerHeight || 0,\n visible: wn.visible !== false && wr.width > 0 && wr.height > 0,\n enabled: wn.enabled !== false,\n clickable: wn.clickable !== undefined ? Boolean(wn.clickable) : (wn.role === \"button\" || wn.role === \"link\"),\n focused: wn.focused,\n checked: wn.checked,\n editable: wn.editable,\n empty: wn.value !== undefined ? String(wn.value).length === 0 : !wtext,\n attributes: wn.attributes || {},\n inShadowDom: false,\n inIframe: false\n };\n }\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var attrs = {};\n if (el.attributes) {\n for (var i = 0; i < el.attributes.length; i++) {\n attrs[el.attributes[i].name] = el.attributes[i].value;\n }\n }\n var tag = el.tagName ? el.tagName.toLowerCase() : undefined;\n var val = (el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.tagName === \"SELECT\")\n ? String(el.value ?? \"\")\n : undefined;\n var text = normWs(el.innerText || el.textContent || \"\") || undefined;\n var normTextContent = normWs(el.textContent || \"\") || undefined;\n var accName = getAccessibleName(el) || undefined;\n var accDesc = getAccessibleDescription(el) || undefined;\n var role = getImplicitRole(el) || undefined;\n var isEnabled = isElementEnabled(el);\n var isChecked =\n el.tagName === \"INPUT\" && (el.type === \"checkbox\" || el.type === \"radio\")\n ? Boolean(el.checked)\n : el.getAttribute(\"aria-checked\") === \"true\"\n ? true\n : el.getAttribute(\"aria-checked\") === \"false\"\n ? false\n : undefined;\n var isEditable = Boolean(\n isEnabled &&\n !el.hasAttribute(\"readonly\") &&\n el.getAttribute(\"aria-readonly\") !== \"true\" &&\n (el.isContentEditable ||\n el.tagName === \"TEXTAREA\" ||\n el.tagName === \"SELECT\" ||\n (el.tagName === \"INPUT\" &&\n [\"button\", \"submit\", \"reset\", \"image\", \"hidden\", \"checkbox\", \"radio\"].indexOf(\n String(el.type || \"text\").toLowerCase(),\n ) === -1)),\n );\n var isEmpty =\n el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\"\n ? String(el.value || \"\").length === 0\n : (el.textContent || \"\").trim().length === 0;\n var clsName = typeof el.className === \"string\" ? el.className : (el.getAttribute(\"class\") || \"\");\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n return {\n id: el.getAttribute(\"data-testid\") || el.getAttribute(\"testID\") || undefined,\n tag: tag,\n role: role,\n text: text,\n textContent: normTextContent,\n value: val,\n accessibilityLabel: el.getAttribute(\"aria-label\") || undefined,\n accessibleName: accName,\n accessibleDescription: accDesc,\n rect: { x: hit.offsetX + rect.x * sx, y: hit.offsetY + rect.y * sy, width: rect.width * sx, height: rect.height * sy },\n clickPoint: hit._clickPoint || undefined,\n scrollX: window.scrollX || window.pageXOffset || 0,\n scrollY: window.scrollY || window.pageYOffset || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0,\n viewportHeight: (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0,\n visible: isVisible(el, rect),\n enabled: isEnabled,\n clickable: isClickable(el),\n focused: document.activeElement === el,\n checked: isChecked,\n editable: isEditable,\n empty: isEmpty,\n className: clsName || undefined,\n attributes: attrs,\n inShadowDom: hit.inShadow || undefined,\n inIframe: hit.inIframe || undefined\n };\n }\n\n\n function query(sel) {\n return findAcrossRoots(sel).map(toMatch);\n }\n\n function scrollIntoView(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return null;\n var hit = hits[hits.length - 1];\n if (typeof hit.el.scrollIntoView === \"function\") {\n try { hit.el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { hit.el.scrollIntoView(true); } catch (e2) {} }\n }\n return toMatch(hit);\n }\n\n function tap(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return false;\n var hit = hits[hits.length - 1];\n var el = hit.el;\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); } catch (e) {}\n }\n var rect = el.getBoundingClientRect();\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var init = { bubbles: true, cancelable: true, composed: true, clientX: cx, clientY: cy };\n try { el.dispatchEvent(new PointerEvent(\"pointerdown\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mousedown\", init)); } catch (e) {}\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n try { el.dispatchEvent(new PointerEvent(\"pointerup\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mouseup\", init)); } catch (e) {}\n if (typeof el.click === \"function\") { el.click(); }\n else { el.dispatchEvent(new MouseEvent(\"click\", init)); }\n return true;\n }\n\n function waitForSelector(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var forAction = Boolean(opts.forAction);\n var force = Boolean(opts.force);\n var failFastWhenIdle = Boolean(opts.failFastWhenIdle);\n var idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs != null ? opts.idleQuietMs : 250));\n var reqStableFrames = force ? 0 : (opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? 2 : 0));\n var checkHitTest = force ? false : (opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : forAction);\n var waitForAppReady = opts.waitForAppReady !== undefined ? Boolean(opts.waitForAppReady) : true;\n var armTapGuard = Boolean(opts.armTapGuard && forAction && !force);\n var instantAnim = Boolean(typeof document !== \"undefined\" && document.getElementById && document.getElementById(\"__spana_instant_anim\"));\n var explicitStableFrames = (instantAnim || force) ? 0 : reqStableFrames;\n\n function armTapGuardOnEl(el) {\n if (!armTapGuard || !el || el.nodeType !== 1) return;\n try {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var doc = el.ownerDocument || document;\n if (win.__spanaTapGuardCleanup) win.__spanaTapGuardCleanup();\n win.__spanaTapMissed = false;\n var matchTarget = function(t) {\n return isSameOrDescendant(el, t);\n };\n var cleanup = function() {\n win.removeEventListener(\"pointerdown\", onEvt, true);\n win.removeEventListener(\"mousedown\", onEvt, true);\n win.removeEventListener(\"mouseup\", onMouseUp, true);\n win.removeEventListener(\"click\", onEvt, true);\n if (win.__spanaTapGuardCleanup === cleanup) delete win.__spanaTapGuardCleanup;\n };\n var onMouseUp = function(e) {\n if (!e.isTrusted) return;\n Promise.resolve().then(cleanup);\n };\n var onEvt = function(e) {\n if (!e.isTrusted) return;\n var hit = deepElementFromPoint(doc, e.clientX, e.clientY) || e.target;\n if (!matchTarget(hit) && !matchTarget(e.target)) {\n e.stopImmediatePropagation();\n e.preventDefault();\n win.__spanaTapMissed = true;\n if (e.type === \"click\") cleanup();\n } else if (e.type === \"click\") {\n cleanup();\n }\n };\n win.addEventListener(\"pointerdown\", onEvt, true);\n win.addEventListener(\"mousedown\", onEvt, true);\n win.addEventListener(\"mouseup\", onMouseUp, true);\n win.addEventListener(\"click\", onEvt, true);\n win.__spanaTapGuardCleanup = cleanup;\n } catch (e) {}\n }\n\n function findCandidates() {\n if (waitForAppReady && !isAppReady()) return null;\n if (forAction && !force && hasActiveViewTransition()) return null;\n var rawHits = findAcrossRoots(sel, \"strict\");\n var ready = [];\n for (var i = 0; i < rawHits.length; i++) {\n var h = rawHits[i];\n var m = toMatch(h);\n if (!m.visible) continue;\n if (forAction && !force && !m.enabled) continue;\n ready.push({ hit: h, match: m });\n }\n return ready.length > 0 ? ready : null;\n }\n\n function checkActionableNow() {\n var ready = findCandidates();\n if (!ready) return null;\n if (!forAction) return ready.map(function(r) { return r.match; });\n var target = ready[ready.length - 1];\n var alreadyInViewport = isFullyInViewport(target.hit);\n var didScroll = alreadyInViewport ? false : ensureInViewport(target.hit);\n if (!force && checkHitTest && !isHitTestClear(target.hit)) {\n if (!alreadyInViewport || canScrollToUnobscure(target.hit)) {\n if (scrollToUnobscure(target.hit)) {\n didScroll = true;\n }\n if (!target.hit.el.isConnected) return null;\n }\n if (!isHitTestClear(target.hit)) return null;\n }\n var updated = toMatch(target.hit);\n if (!updated.visible || (!force && !updated.enabled)) return null;\n return { hits: ready, target: target, match: updated, didScroll: didScroll };\n }\n\n function neededStableFrames(candidate) {\n if (force || !forAction || typeof requestAnimationFrame !== \"function\") return 0;\n if (explicitStableFrames >= 0) return explicitStableFrames;\n if (hasActiveAnimation(candidate.target.hit.el)) return 2;\n if (candidate.didScroll) return 1;\n return 0;\n }\n\n var imm = checkActionableNow();\n if (imm) {\n if (!forAction) return imm;\n if (neededStableFrames(imm) <= 0) {\n armTapGuardOnEl(imm.target.hit.el);\n return [imm.match];\n }\n }\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var idleTimer = null;\n var rafId = null;\n var checkingStability = false;\n\n function finish(result) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (idleTimer) clearTimeout(idleTimer);\n if (rafId !== null && typeof cancelAnimationFrame === \"function\") {\n try { cancelAnimationFrame(rafId); } catch (e) {}\n }\n resolve(result);\n }\n\n function armIdleTimer() {\n if (!failFastWhenIdle) return;\n if (idleTimer) clearTimeout(idleTimer);\n idleTimer = setTimeout(function() {\n var rootEl = document.body || document.documentElement;\n if (\n document.readyState === \"complete\" &&\n (!waitForAppReady || isAppReady()) &&\n !hasActiveAnimation(rootEl)\n ) {\n var hit = checkActionableNow();\n if (hit && forAction) armTapGuardOnEl(hit.target.hit.el);\n finish(hit ? (forAction ? [hit.match] : hit) : []);\n } else {\n armIdleTimer();\n }\n }, idleQuietMs);\n }\n\n function verifyStability(candidate) {\n if (done || checkingStability) return;\n var framesToWait = neededStableFrames(candidate);\n if (!forAction || framesToWait <= 0 || typeof requestAnimationFrame !== \"function\") {\n if (forAction) armTapGuardOnEl(candidate.target.hit.el);\n finish(forAction ? [candidate.match] : candidate);\n return;\n }\n checkingStability = true;\n var el = candidate.target.hit.el;\n var lastRect = candidate.match.rect;\n var remainingFrames = framesToWait;\n\n function step() {\n if (done) return;\n if (!el.isConnected) { checkingStability = false; scheduleAttempt(); return; }\n if (checkHitTest && !isHitTestClear(candidate.target.hit)) { checkingStability = false; scheduleAttempt(); return; }\n var cur = toMatch(candidate.target.hit);\n if (!cur.visible || !cur.enabled) { checkingStability = false; scheduleAttempt(); return; }\n var dx = Math.abs(cur.rect.x - lastRect.x);\n var dy = Math.abs(cur.rect.y - lastRect.y);\n var dw = Math.abs(cur.rect.width - lastRect.width);\n var dh = Math.abs(cur.rect.height - lastRect.height);\n if (dx <= 1 && dy <= 1 && dw <= 1 && dh <= 1) {\n remainingFrames -= 1;\n if (remainingFrames <= 0) { armTapGuardOnEl(el); finish([cur]); return; }\n } else {\n remainingFrames = framesToWait;\n lastRect = cur.rect;\n }\n rafId = requestAnimationFrame(step);\n }\n rafId = requestAnimationFrame(step);\n }\n\n function attempt() {\n if (done || checkingStability) return;\n var hit = checkActionableNow();\n if (hit) {\n if (forAction) verifyStability(hit);\n else finish(hit);\n return;\n }\n }\n\n var scheduled = false;\n function scheduleAttempt() {\n if (done || checkingStability) return;\n armIdleTimer();\n if (scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() { scheduled = false; attempt(); });\n }\n\n timeoutTimer = setTimeout(function() {\n var finalHit = checkActionableNow();\n if (finalHit && forAction) armTapGuardOnEl(finalHit.target.hit.el);\n finish(finalHit ? (forAction ? [finalHit.match] : finalHit) : []);\n }, timeoutMs);\n fallbackInterval = setInterval(attempt, forAction ? 40 : 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(scheduleAttempt);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n armIdleTimer();\n attempt();\n });\n }\n\n function waitForHidden(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n function isHiddenNow() {\n var hits = findAcrossRoots(sel, false);\n for (var i = 0; i < hits.length; i++) {\n if (toMatch(hits[i]).visible) return false;\n }\n return true;\n }\n if (isHiddenNow()) return true;\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n function finish(val) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(val);\n }\n function onChange() { if (isHiddenNow()) finish(true); }\n timeoutTimer = setTimeout(function() { finish(isHiddenNow()); }, timeoutMs);\n fallbackInterval = setInterval(onChange, 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function waitForMatch(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var kind = opts.kind;\n var expected = opts.expected !== undefined ? opts.expected : null;\n var expectedCount = opts.expectedCount !== undefined ? opts.expectedCount : null;\n var attributeName = opts.attributeName !== undefined ? opts.attributeName : null;\n var cssProperty = opts.cssProperty !== undefined ? opts.cssProperty : null;\n var patternSource = opts.patternSource !== undefined ? opts.patternSource : null;\n var patternFlags = opts.patternFlags || \"\";\n var negate = Boolean(opts.negate);\n var visibleOnly = Boolean(opts.visibleOnly);\n var ignoreCase = Boolean(opts.ignoreCase);\n var propertyName = opts.propertyName !== undefined ? opts.propertyName : null;\n var expectedValue = opts.expectedValue !== undefined ? opts.expectedValue : null;\n var lastActual = undefined;\n var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;\n var allowHidden = kind === \"text\" || kind === \"containsText\" || kind === \"matchesText\" || kind === \"value\" || kind === \"attribute\" || kind === \"attached\" || kind === \"jsProperty\";\n\n function evaluateMatch() {\n if (kind === \"url\") {\n var href = typeof window !== \"undefined\" && window.location ? String(window.location.href || \"\") : \"\";\n lastActual = href;\n var urlOk = regex\n ? regex.test(href)\n : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));\n if (negate ? !urlOk : urlOk) return { matched: true, actual: href };\n return null;\n }\n if (kind === \"title\") {\n var docTitle = String(typeof document !== \"undefined\" ? (document.title || \"\") : \"\");\n lastActual = docTitle;\n var titleOk = regex ? regex.test(docTitle) : (expected !== null && docTitle === String(expected));\n if (negate ? !titleOk : titleOk) return { matched: true, actual: docTitle };\n return null;\n }\n\n var pvMode = (kind === \"attached\" || (kind === \"count\" && !visibleOnly)) ? false : (visibleOnly ? \"strict\" : \"prefer\");\n var hits = findAcrossRoots(sel, pvMode);\n\n if (kind === \"count\") {\n var matchedCount = 0;\n if (visibleOnly) {\n for (var ci = 0; ci < hits.length; ci++) {\n if (toMatch(hits[ci]).visible) matchedCount++;\n }\n } else {\n matchedCount = hits.length;\n }\n lastActual = String(matchedCount);\n var countOk = expectedCount !== null && matchedCount === expectedCount;\n if (negate ? !countOk : countOk) {\n return { matched: true, actual: String(matchedCount) };\n }\n return null;\n }\n if (kind === \"attached\") {\n var isAttached = hits.length > 0;\n lastActual = isAttached ? \"attached\" : \"detached\";\n if (negate ? !isAttached : isAttached) return { matched: true, actual: lastActual };\n return null;\n }\n\n var anyVisible2 = false;\n var hiddenFallback2 = [];\n var checkMatch2 = function(h, m) {\n var matched = false;\n var actualVal = undefined;\n if (kind === \"text\") {\n var normTxt = normWs(m.textContent !== undefined ? m.textContent : (m.text || \"\"));\n actualVal = normTxt;\n matched = normTxt === (expected !== null ? normWs(expected) : expected);\n } else if (kind === \"containsText\") {\n var actual = normWs(m.textContent !== undefined ? m.textContent : (m.text || \"\"));\n actualVal = actual;\n var needle = expected !== null ? normWs(expected) : \"\";\n matched = expected !== null && (ignoreCase\n ? actual.toLowerCase().indexOf(needle.toLowerCase()) !== -1\n : actual.indexOf(needle) !== -1);\n } else if (kind === \"matchesText\") {\n var rawRe2 = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n var actualRe = normWs(rawRe2);\n actualVal = actualRe;\n matched = Boolean(regex && (regex.test(rawRe2) || regex.test(actualRe)));\n } else if (kind === \"value\") {\n var val = m.value !== undefined ? m.value : \"\";\n actualVal = val;\n matched = regex ? regex.test(val) : (val === expected);\n } else if (kind === \"attribute\" && attributeName !== null) {\n var attrVal = m.attributes ? m.attributes[attributeName] : undefined;\n actualVal = attrVal;\n matched = regex\n ? (attrVal !== undefined && regex.test(attrVal))\n : (expected === null ? attrVal !== undefined : attrVal === expected);\n } else if (kind === \"accessibilityLabel\") {\n var lbl = m.accessibilityLabel;\n actualVal = lbl;\n matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;\n } else if (kind === \"accessibleName\") {\n var accName = normWs(m.accessibleName || m.accessibilityLabel || m.text || \"\");\n actualVal = accName;\n matched = regex ? (regex.test(m.accessibleName || m.accessibilityLabel || m.text || \"\") || regex.test(accName)) : (expected === null ? accName.length > 0 : accName === normWs(expected));\n } else if (kind === \"accessibleDescription\") {\n var accDesc = normWs(m.accessibleDescription || \"\");\n actualVal = accDesc;\n matched = regex ? (regex.test(m.accessibleDescription || \"\") || regex.test(accDesc)) : (expected === null ? accDesc.length > 0 : accDesc === normWs(expected));\n } else if (kind === \"focused\") {\n actualVal = m.focused ? \"focused\" : \"not focused\";\n matched = Boolean(m.focused);\n } else if (kind === \"checked\") {\n actualVal = m.checked ? \"checked\" : \"unchecked\";\n matched = Boolean(m.checked);\n } else if (kind === \"enabled\") {\n var isEn2 = m.enabled !== false;\n actualVal = isEn2 ? \"enabled\" : \"disabled\";\n matched = isEn2;\n } else if (kind === \"role\") {\n var elRole2 = m.role || getImplicitRole(h.el) || \"generic\";\n actualVal = elRole2;\n matched = expected !== null && elRole2.toLowerCase() === String(expected).toLowerCase();\n } else if (kind === \"editable\") {\n actualVal = m.editable ? \"editable\" : \"not editable\";\n matched = Boolean(m.editable);\n } else if (kind === \"empty\") {\n actualVal = m.empty ? \"empty\" : (m.value || m.textContent || \"non-empty\");\n matched = Boolean(m.empty);\n } else if (kind === \"inViewport\") {\n var vpW = window.innerWidth || document.documentElement.clientWidth || 0;\n var vpH = window.innerHeight || document.documentElement.clientHeight || 0;\n var r = m.rect;\n var inVp = r.width > 0 && r.height > 0 && r.x + r.width > 0 && r.y + r.height > 0 && r.x < vpW && r.y < vpH;\n actualVal = inVp ? \"in viewport\" : \"outside viewport\";\n matched = inVp;\n } else if (kind === \"jsProperty\" && propertyName !== null) {\n var propNode = h.el;\n var rawProp = propNode ? propNode[propertyName] : undefined;\n actualVal = typeof rawProp === \"string\" ? rawProp : JSON.stringify(rawProp);\n matched = JSON.stringify(rawProp) === JSON.stringify(expectedValue);\n } else if (kind === \"class\") {\n var cls = m.className || \"\";\n actualVal = cls;\n if (regex) {\n matched = regex.test(cls);\n } else if (expected !== null) {\n var tokens = cls.trim().split(/\\s+/).filter(Boolean);\n var expectedTokens = String(expected).trim().split(/\\s+/).filter(Boolean);\n matched = expectedTokens.length > 0 && expectedTokens.every(function(tok) { return tokens.indexOf(tok) !== -1; });\n }\n } else if (kind === \"css\" && cssProperty !== null) {\n var elNode = h.el;\n var winObj = (elNode.ownerDocument && elNode.ownerDocument.defaultView) || window;\n var cssVal = winObj && winObj.getComputedStyle ? winObj.getComputedStyle(elNode).getPropertyValue(cssProperty).trim() : \"\";\n actualVal = cssVal;\n matched = regex ? regex.test(cssVal) : (expected !== null && cssVal === String(expected).trim());\n }\n lastActual = actualVal;\n if (negate ? !matched : matched) return { matched: true, actual: actualVal };\n return null;\n };\n for (var i = hits.length - 1; i >= 0; i--) {\n var m = toMatch(hits[i]);\n if (!allowHidden && !m.visible) {\n if (kind === \"enabled\" || kind === \"checked\") hiddenFallback2.push({ h: hits[i], m: m });\n continue;\n }\n if (m.visible) anyVisible2 = true;\n var resHit2 = checkMatch2(hits[i], m);\n if (resHit2) return resHit2;\n }\n if (!anyVisible2 && hiddenFallback2.length > 0) {\n for (var hi2 = 0; hi2 < hiddenFallback2.length; hi2++) {\n var hRes2 = checkMatch2(hiddenFallback2[hi2].h, hiddenFallback2[hi2].m);\n if (hRes2) return hRes2;\n }\n }\n return null;\n }\n\n var immediate = evaluateMatch();\n if (immediate) return immediate;\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n function finish(res) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"input\", onChange, true);\n document.removeEventListener(\"change\", onChange, true);\n document.removeEventListener(\"focusin\", onChange, true);\n document.removeEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"popstate\", onChange);\n window.removeEventListener(\"hashchange\", onChange);\n }\n resolve(res);\n }\n function onChange() {\n if (done || scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done) return;\n var res = evaluateMatch();\n if (res) finish(res);\n });\n }\n timeoutTimer = setTimeout(function() {\n var finalRes = evaluateMatch();\n finish(finalRes || { matched: false, actual: lastActual });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, kind === \"url\" ? 50 : 120);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"input\", onChange, true);\n document.addEventListener(\"change\", onChange, true);\n document.addEventListener(\"focusin\", onChange, true);\n document.addEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"popstate\", onChange);\n window.addEventListener(\"hashchange\", onChange);\n }\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function fill(sel, val, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : true;\n var verifyDelayMs = opts.verifyDelayMs !== undefined ? Math.max(0, Math.round(opts.verifyDelayMs)) : 12;\n function writeValue(el) {\n if (el.isContentEditable) return false;\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n var tag = el.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\") {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var proto = tag === \"TEXTAREA\"\n ? (win.HTMLTextAreaElement && win.HTMLTextAreaElement.prototype)\n : (win.HTMLInputElement && win.HTMLInputElement.prototype);\n var desc = proto ? Object.getOwnPropertyDescriptor(proto, \"value\") : null;\n if (desc && typeof desc.set === \"function\") {\n try { desc.set.call(el, val); } catch (e) { el.value = val; }\n }\n else el.value = val;\n if (el._valueTracker && typeof el._valueTracker.setValue === \"function\") {\n try { el._valueTracker.setValue(val === \"\" ? \" \" : \"\"); } catch (e) {}\n }\n } else if (tag === \"SELECT\") {\n el.value = val;\n } else {\n el.value = val;\n }\n try { el.dispatchEvent(new InputEvent(\"input\", { bubbles: true, cancelable: true, data: val, inputType: \"insertText\" })); }\n catch (e) { el.dispatchEvent(new Event(\"input\", { bubbles: true, cancelable: true })); }\n el.dispatchEvent(new Event(\"change\", { bubbles: true, cancelable: true }));\n return true;\n }\n function findEditableNow() {\n if (!isAppReady()) return null;\n var hits = findAcrossRoots(sel, \"strict\");\n for (var i = hits.length - 1; i >= 0; i--) {\n var h = hits[i];\n var m = toMatch(h);\n if (!m.visible || !m.enabled) continue;\n var alreadyInVp = isFullyInViewport(h);\n if (!alreadyInVp) ensureInViewport(h);\n if (checkHitTest && !isHitTestClear(h)) {\n if (!alreadyInVp || canScrollToUnobscure(h)) scrollToUnobscure(h);\n if (!h.el.isConnected || !isHitTestClear(h)) continue;\n }\n return h.el;\n }\n return null;\n }\n function verifyAndRetryFill(attemptsLeft) {\n var el = findEditableNow();\n if (!el || el.isContentEditable) return Promise.resolve(false);\n if (!writeValue(el)) return Promise.resolve(false);\n if (verifyDelayMs <= 0) {\n var syncLatest = findEditableNow() || el;\n if (syncLatest && syncLatest.isConnected && String(syncLatest.value == null ? \"\" : syncLatest.value) === val) {\n return Promise.resolve(true);\n }\n return attemptsLeft > 1 ? verifyAndRetryFill(attemptsLeft - 1) : Promise.resolve(false);\n }\n return new Promise(function(resolve) {\n setTimeout(function() {\n var latest = findEditableNow() || el;\n if (latest && latest.isConnected && String(latest.value == null ? \"\" : latest.value) === val) {\n resolve(true);\n return;\n }\n if (attemptsLeft > 1) {\n verifyAndRetryFill(attemptsLeft - 1).then(resolve);\n } else {\n resolve(false);\n }\n }, verifyDelayMs);\n });\n }\n var immEl = findEditableNow();\n if (immEl) {\n if (immEl.isContentEditable) return false;\n return verifyAndRetryFill(3);\n }\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n var filling = false;\n function finish(ok) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(ok);\n }\n function onChange() {\n if (done || scheduled || filling) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done || filling) return;\n var target = findEditableNow();\n if (!target) return;\n if (target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(3).then(function(ok) { finish(ok); });\n });\n }\n timeoutTimer = setTimeout(function() {\n if (filling) return;\n var target = findEditableNow();\n if (!target || target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(2).then(function(ok) { finish(ok); });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, 40);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function checkTapGuard() {\n var m = Boolean(window.__spanaTapMissed);\n if (window.__spanaTapGuardCleanup) window.__spanaTapGuardCleanup();\n delete window.__spanaTapMissed;\n return m;\n }\n\n window.__spanaRt = {\n query: query,\n scrollIntoView: scrollIntoView,\n tap: tap,\n waitForSelector: waitForSelector,\n waitForHidden: waitForHidden,\n waitForMatch: waitForMatch,\n fill: fill,\n checkTapGuard: checkTapGuard\n };\n return true;\n})();";
263
+ export declare const SPANA_INJECTED_RUNTIME_SCRIPT = "(function() {\n if (typeof window === \"undefined\") return true;\n (function() {\n if (typeof globalThis === \"undefined\" || globalThis.__spanaWasm) return;\n var state = {\n moduleCount: 0,\n pendingCount: 0,\n peakWasmMemoryBytes: 0,\n modules: [],\n memories: [],\n traps: []\n };\n var nextId = 1;\n var WASM_RE = /(WebAssembly\\.(RuntimeError|CompileError|LinkError)|wasm-function\\[|memory access out of bounds|table index is out of bounds|integer divide by zero|unreachable|indirect call type mismatch|out of bounds memory access)/i;\n\n function trackMemory(mem) {\n if (!mem || typeof mem !== \"object\" || !(mem.buffer instanceof ArrayBuffer || (typeof SharedArrayBuffer !== \"undefined\" && mem.buffer instanceof SharedArrayBuffer))) {\n return;\n }\n var already = false;\n var alive = [];\n for (var i = 0; i < state.memories.length; i++) {\n var ref = state.memories[i];\n var cur = typeof ref.deref === \"function\" ? ref.deref() : ref;\n if (!cur) continue;\n if (cur === mem) already = true;\n alive.push(ref);\n }\n if (!already) {\n alive.push(typeof WeakRef !== \"undefined\" ? new WeakRef(mem) : mem);\n }\n state.memories = alive;\n computeMemoryBytes();\n }\n\n function computeMemoryBytes() {\n var total = 0;\n var alive = [];\n for (var i = 0; i < state.memories.length; i++) {\n var ref = state.memories[i];\n var cur = typeof ref.deref === \"function\" ? ref.deref() : ref;\n if (!cur) continue;\n alive.push(ref);\n try {\n total += cur.buffer ? cur.buffer.byteLength : 0;\n } catch (e) {}\n }\n state.memories = alive;\n if (total > state.peakWasmMemoryBytes) state.peakWasmMemoryBytes = total;\n return total;\n }\n\n function trackExports(instance) {\n if (!instance || !instance.exports) return { bytes: 0, pages: 0 };\n var bytes = 0;\n try {\n var keys = Object.keys(instance.exports);\n for (var i = 0; i < keys.length; i++) {\n var val = instance.exports[keys[i]];\n if (typeof WebAssembly !== \"undefined\" && typeof WebAssembly.Memory === \"function\" && val instanceof WebAssembly.Memory) {\n trackMemory(val);\n try { bytes += val.buffer.byteLength; } catch (e) {}\n }\n }\n } catch (e) {}\n return { bytes: bytes, pages: Math.round(bytes / 65536) };\n }\n\n function recordTrap(name, message, stack) {\n var combined = String(name || \"\") + \" \" + String(message || \"\") + \" \" + String(stack || \"\");\n if (!WASM_RE.test(combined)) return;\n state.traps.push({\n name: String(name || \"WebAssembly.RuntimeError\"),\n message: String(message || \"WebAssembly trap\"),\n source: typeof window === \"undefined\" ? \"worker\" : \"main\",\n stack: stack ? String(stack) : undefined,\n timestamp: Date.now()\n });\n if (state.traps.length > 100) state.traps.shift();\n }\n\n function getSizeBytes(src) {\n if (!src) return undefined;\n if (typeof src.byteLength === \"number\") return src.byteLength;\n return undefined;\n }\n\n if (typeof WebAssembly !== \"undefined\") {\n var origInstantiate = WebAssembly.instantiate;\n if (typeof origInstantiate === \"function\") {\n WebAssembly.instantiate = function(source, importObject) {\n state.pendingCount += 1;\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n var sizeBytes = getSizeBytes(source);\n return Promise.resolve(origInstantiate.apply(WebAssembly, arguments)).then(\n function(res) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n state.moduleCount += 1;\n var inst = res && res.instance ? res.instance : res;\n var memInfo = trackExports(inst);\n var elapsed = Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0);\n state.modules.push({\n id: nextId++,\n sizeBytes: sizeBytes,\n instantiateMs: elapsed,\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return res;\n },\n function(err) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n recordTrap(err && err.name, err && err.message ? err.message : String(err), err && err.stack);\n throw err;\n }\n );\n };\n }\n\n var origInstantiateStreaming = WebAssembly.instantiateStreaming;\n if (typeof origInstantiateStreaming === \"function\") {\n WebAssembly.instantiateStreaming = function(source, importObject) {\n state.pendingCount += 1;\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n return Promise.resolve(origInstantiateStreaming.apply(WebAssembly, arguments)).then(\n function(res) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n state.moduleCount += 1;\n var inst = res && res.instance ? res.instance : res;\n var memInfo = trackExports(inst);\n var elapsed = Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0);\n state.modules.push({\n id: nextId++,\n instantiateMs: elapsed,\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return res;\n },\n function(err) {\n state.pendingCount = Math.max(0, state.pendingCount - 1);\n recordTrap(err && err.name, err && err.message ? err.message : String(err), err && err.stack);\n throw err;\n }\n );\n };\n }\n\n var OrigMemory = WebAssembly.Memory;\n if (typeof OrigMemory === \"function\") {\n try {\n var WrappedMemory = new Proxy(OrigMemory, {\n construct: function(target, args, newTarget) {\n var mem = Reflect.construct(target, args, newTarget);\n trackMemory(mem);\n return mem;\n }\n });\n WebAssembly.Memory = WrappedMemory;\n } catch (e) {}\n }\n\n var OrigInstance = WebAssembly.Instance;\n if (typeof OrigInstance === \"function\") {\n try {\n var WrappedInstance = new Proxy(OrigInstance, {\n construct: function(target, args, newTarget) {\n var t0 = typeof performance !== \"undefined\" ? performance.now() : Date.now();\n var inst = Reflect.construct(target, args, newTarget);\n state.moduleCount += 1;\n var memInfo = trackExports(inst);\n state.modules.push({\n id: nextId++,\n instantiateMs: Math.round((typeof performance !== \"undefined\" ? performance.now() : Date.now()) - t0),\n memoryBytes: memInfo.bytes || undefined,\n memoryPages: memInfo.pages || undefined,\n instantiatedAt: Date.now()\n });\n return inst;\n }\n });\n WebAssembly.Instance = WrappedInstance;\n } catch (e) {}\n }\n }\n\n if (typeof globalThis.addEventListener === \"function\") {\n globalThis.addEventListener(\"error\", function(ev) {\n var err = ev && ev.error;\n recordTrap(err && err.name, (err && err.message) || (ev && ev.message), err && err.stack);\n });\n globalThis.addEventListener(\"unhandledrejection\", function(ev) {\n var reason = ev && ev.reason;\n recordTrap(reason && reason.name, reason && reason.message ? reason.message : String(reason), reason && reason.stack);\n });\n }\n\n globalThis.__spanaWasm = {\n trackMemory: trackMemory,\n recordTrap: recordTrap,\n getMetrics: function() {\n var bytes = computeMemoryBytes();\n var perfMem = typeof performance !== \"undefined\" && performance.memory ? performance.memory : null;\n return {\n moduleCount: state.moduleCount,\n pendingCount: state.pendingCount,\n wasmMemoryBytes: bytes,\n wasmMemoryPages: Math.round(bytes / 65536),\n peakWasmMemoryBytes: state.peakWasmMemoryBytes,\n jsHeapUsedBytes: perfMem ? perfMem.usedJSHeapSize : undefined,\n jsHeapTotalBytes: perfMem ? perfMem.totalJSHeapSize : undefined,\n crossOriginIsolated: Boolean(globalThis.crossOriginIsolated),\n sharedArrayBufferAvailable: typeof SharedArrayBuffer !== \"undefined\",\n traps: state.traps.slice(),\n modules: state.modules.slice()\n };\n },\n isReady: function(minModules) {\n var req = typeof minModules === \"number\" ? minModules : 1;\n var explicit = globalThis.__SPANA_WASM_READY__;\n if (typeof explicit === \"function\") {\n try { if (!explicit()) return false; } catch (e) { return false; }\n } else if (explicit === false) {\n return false;\n }\n return state.pendingCount === 0 && (state.moduleCount >= req || explicit === true);\n }\n };\n})();\n if (window.__spanaRt) return true;\n \n function normWs(val) {\n return String(val == null ? \"\" : val).replace(/[\\s\\u00a0\\u202f]+/g, \" \").trim();\n }\n function matchSpec(actual, spec, exact) {\n var raw = String(actual || \"\");\n var str = normWs(raw);\n if (spec && typeof spec === \"object\" && typeof spec.__spanaRegex === \"string\") {\n try {\n var re = new RegExp(spec.__spanaRegex, spec.flags || \"\");\n return re.test(raw) || re.test(str);\n } catch (e) { return false; }\n }\n var needle = normWs(spec);\n if (exact) return str === needle;\n return str.toLowerCase().indexOf(needle.toLowerCase()) !== -1;\n }\n function isInsideSectioningContent(el) {\n var cur = el && el.parentElement;\n var guard = 0;\n while (cur && guard++ < 32) {\n var ptag = cur.tagName ? cur.tagName.toUpperCase() : \"\";\n if (ptag === \"ARTICLE\" || ptag === \"ASIDE\" || ptag === \"MAIN\" || ptag === \"NAV\" || ptag === \"SECTION\") {\n return true;\n }\n var prole = (cur.getAttribute && cur.getAttribute(\"role\") || \"\").trim().toLowerCase().split(/\\s+/)[0] || \"\";\n if (prole === \"article\" || prole === \"complementary\" || prole === \"main\" || prole === \"navigation\" || prole === \"region\") {\n return true;\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n return false;\n }\n function getImplicitRole(el) {\n if (!el || !el.getAttribute) return \"generic\";\n var explicit = (el.getAttribute(\"role\") || \"\").trim().toLowerCase();\n if (explicit) return explicit.split(/\\s+/)[0] || \"generic\";\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"BUTTON\") return \"button\";\n if (tag === \"A\") return el.hasAttribute(\"href\") ? \"link\" : \"generic\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return (el.hasAttribute(\"multiple\") || Number(el.getAttribute(\"size\") || 0) > 1) ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"IMG\") return el.getAttribute(\"alt\") === \"\" ? \"presentation\" : \"img\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"HEADER\") return isInsideSectioningContent(el) ? \"generic\" : \"banner\";\n if (tag === \"FOOTER\") return isInsideSectioningContent(el) ? \"generic\" : \"contentinfo\";\n if (tag === \"ASIDE\") return \"complementary\";\n if (tag === \"UL\" || tag === \"OL\") return \"list\";\n if (tag === \"LI\") return \"listitem\";\n if (tag === \"TABLE\") return \"table\";\n if (tag === \"TR\") return \"row\";\n if (tag === \"TD\") return \"cell\";\n if (tag === \"TH\") {\n var scope = (el.getAttribute(\"scope\") || \"\").trim().toLowerCase();\n if (scope === \"row\" || scope === \"rowgroup\") return \"rowheader\";\n if (scope === \"col\" || scope === \"colgroup\") return \"columnheader\";\n var tr = el.parentElement;\n if (tr && tr.tagName && tr.tagName.toUpperCase() === \"TR\" && !(el.closest && el.closest(\"thead\"))) {\n if (tr.querySelector && tr.querySelector(\"td\")) return \"rowheader\";\n }\n return \"columnheader\";\n }\n if (tag === \"ARTICLE\") return \"article\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"FIELDSET\") return \"group\";\n if (tag === \"FIGURE\") return \"figure\";\n if (tag === \"METER\") return \"meter\";\n if (tag === \"OUTPUT\") return \"status\";\n if (tag === \"P\") return \"paragraph\";\n if (tag === \"STRONG\") return \"strong\";\n if (tag === \"PROGRESS\") return \"progressbar\";\n if (tag === \"HR\") return \"separator\";\n if (tag === \"SECTION\") {\n return (el.hasAttribute(\"aria-label\") || el.hasAttribute(\"aria-labelledby\") || Boolean((el.getAttribute(\"title\") || \"\").trim())) ? \"region\" : \"generic\";\n }\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"INPUT\") {\n var t = (el.getAttribute(\"type\") || \"text\").toLowerCase();\n if (t === \"button\" || t === \"submit\" || t === \"reset\" || t === \"image\") return \"button\";\n if (t === \"checkbox\") return \"checkbox\";\n if (t === \"radio\") return \"radio\";\n if (t === \"search\") return el.hasAttribute(\"list\") ? \"combobox\" : \"searchbox\";\n if (t === \"number\") return \"spinbutton\";\n if (t === \"range\") return \"slider\";\n if (t === \"hidden\") return \"generic\";\n return el.hasAttribute(\"list\") ? \"combobox\" : \"textbox\";\n }\n return \"generic\";\n }\n var BLOCK_TAGS = {\n ADDRESS: 1, ARTICLE: 1, ASIDE: 1, BLOCKQUOTE: 1, BR: 1, DD: 1, DETAILS: 1,\n DIALOG: 1, DIV: 1, DL: 1, DT: 1, FIELDSET: 1, FIGCAPTION: 1, FIGURE: 1,\n FOOTER: 1, FORM: 1, H1: 1, H2: 1, H3: 1, H4: 1, H5: 1, H6: 1, HEADER: 1,\n HGROUP: 1, HR: 1, LI: 1, MAIN: 1, NAV: 1, OL: 1, P: 1, PRE: 1, SECTION: 1,\n SUMMARY: 1, TABLE: 1, TD: 1, TH: 1, TR: 1, UL: 1,\n };\n function visibleTextOf(node, allowHiddenRoot, skipControl) {\n if (!node) return \"\";\n if (node.nodeType === 3) return node.nodeValue || \"\";\n if (node.nodeType !== 1 && node.nodeType !== 11) return \"\";\n if (node.nodeType === 1) {\n if (skipControl && node === skipControl) return \"\";\n var t = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (t === \"BR\") return \" \";\n if (t === \"SCRIPT\" || t === \"STYLE\" || t === \"NOSCRIPT\" || t === \"TEMPLATE\") return \"\";\n if (skipControl && (t === \"SELECT\" || t === \"TEXTAREA\" || t === \"INPUT\")) return \"\";\n if (t === \"IMG\") {\n var imgAlt = node.getAttribute && node.getAttribute(\"alt\");\n return imgAlt ? normWs(imgAlt) : \"\";\n }\n if (t === \"SVG\") {\n var svgRole = (node.getAttribute && node.getAttribute(\"role\") || \"\").trim().toLowerCase();\n var svgLabel = node.getAttribute && node.getAttribute(\"aria-label\");\n if (svgLabel && svgLabel.trim()) return normWs(svgLabel);\n if (svgRole === \"img\") {\n var svgTitle = node.querySelector && node.querySelector(\"title\");\n if (svgTitle && svgTitle.textContent) return normWs(svgTitle.textContent);\n }\n }\n if (!allowHiddenRoot) {\n if (node.getAttribute && node.getAttribute(\"aria-hidden\") === \"true\") return \"\";\n var win = (node.ownerDocument && node.ownerDocument.defaultView) || window;\n if (win && win.getComputedStyle) {\n var st = win.getComputedStyle(node);\n if (st && (st.display === \"none\" || st.visibility === \"hidden\" || st.visibility === \"collapse\")) {\n return \"\";\n }\n }\n }\n }\n var out = [];\n if (node.shadowRoot) {\n var stxt = visibleTextOf(node.shadowRoot, false, skipControl);\n if (stxt) out.push(stxt);\n }\n var kids = node.childNodes || [];\n for (var i = 0; i < kids.length; i++) {\n var child = kids[i];\n var k = visibleTextOf(child, false, skipControl);\n if (!k) continue;\n var cTag = child && child.nodeType === 1 && child.tagName ? child.tagName.toUpperCase() : \"\";\n if (cTag && BLOCK_TAGS[cTag]) {\n out.push(\" \", k, \" \");\n } else {\n out.push(k);\n }\n }\n return normWs(out.join(\"\"));\n }\n function ensureNetworkTracker() {\n if (typeof window === \"undefined\" || window.__spanaNetHooked) return;\n try {\n window.__spanaNetHooked = true;\n window.__spanaInflightNet = window.__spanaInflightNet || 0;\n window.__spanaLastNetEnd = window.__spanaLastNetEnd || 0;\n if (typeof window.fetch === \"function\") {\n var origFetch = window.fetch;\n window.fetch = function() {\n window.__spanaInflightNet = (window.__spanaInflightNet || 0) + 1;\n var done = false;\n var finish = function() {\n if (done) return;\n done = true;\n window.__spanaInflightNet = Math.max(0, (window.__spanaInflightNet || 1) - 1);\n window.__spanaLastNetEnd = Date.now();\n };\n try {\n var p = origFetch.apply(this, arguments);\n if (p && typeof p.then === \"function\") {\n p.then(finish, finish);\n } else {\n finish();\n }\n return p;\n } catch (e) {\n finish();\n throw e;\n }\n };\n }\n if (typeof XMLHttpRequest !== \"undefined\" && XMLHttpRequest.prototype && typeof XMLHttpRequest.prototype.send === \"function\") {\n var origSend = XMLHttpRequest.prototype.send;\n XMLHttpRequest.prototype.send = function() {\n window.__spanaInflightNet = (window.__spanaInflightNet || 0) + 1;\n var done = false;\n var finish = function() {\n if (done) return;\n done = true;\n window.__spanaInflightNet = Math.max(0, (window.__spanaInflightNet || 1) - 1);\n window.__spanaLastNetEnd = Date.now();\n };\n try {\n this.addEventListener(\"loadend\", finish, { once: true });\n return origSend.apply(this, arguments);\n } catch (e) {\n finish();\n throw e;\n }\n };\n }\n } catch (e) {}\n }\n ensureNetworkTracker();\n function hasInflightNetwork(quietMs) {\n if (typeof window === \"undefined\") return false;\n if ((window.__spanaInflightNet || 0) > 0) return true;\n var lastEnd = window.__spanaLastNetEnd || 0;\n if (lastEnd > 0 && Date.now() - lastEnd < Math.min(quietMs || 150, 150)) return true;\n return false;\n }\n function isVisiblyHiddenInAncestorChain(el) {\n if (!el) return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 48) {\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs) {\n if (cs.display === \"none\") return true;\n if (cs.contentVisibility === \"hidden\") return true;\n }\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (el.nodeType === 1 && win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return true;\n }\n return false;\n }\n function isHiddenInAncestorChain(el) {\n if (!el) return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 48) {\n if (cur.getAttribute) {\n if (cur.getAttribute(\"aria-hidden\") === \"true\") return true;\n }\n if (cur.hasAttribute && cur.hasAttribute(\"inert\")) return true;\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs) {\n if (cs.display === \"none\") return true;\n if (cs.contentVisibility === \"hidden\") return true;\n }\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (el.nodeType === 1 && win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return true;\n }\n return false;\n }\n function isAriaHidden(el) {\n if (el && el.tagName && el.tagName.toUpperCase() === \"OPTION\") {\n var parentSel = el.closest ? el.closest(\"select\") : el.parentElement;\n if (parentSel) {\n return isHiddenInAncestorChain(parentSel);\n }\n }\n if (isHiddenInAncestorChain(el)) return true;\n if (el && el.nodeType === 1) {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var st = win && win.getComputedStyle ? win.getComputedStyle(el) : null;\n if (st && st.display === \"contents\") {\n return !hasVisibleDescendant(el, 0);\n }\n }\n return false;\n }\n function hasVisibleDescendant(el, depth) {\n if (!el || depth > 8) return false;\n var kids = el.children || [];\n for (var i = 0; i < kids.length; i++) {\n var child = kids[i];\n if (!child || child.nodeType !== 1) continue;\n var cr = child.getBoundingClientRect ? child.getBoundingClientRect() : { width: 0, height: 0 };\n if (isVisible(child, cr, depth + 1)) return true;\n }\n if (el.shadowRoot && el.shadowRoot.children) {\n var skids = el.shadowRoot.children;\n for (var j = 0; j < skids.length; j++) {\n var sc = skids[j];\n if (!sc || sc.nodeType !== 1) continue;\n var sr = sc.getBoundingClientRect ? sc.getBoundingClientRect() : { width: 0, height: 0 };\n if (isVisible(sc, sr, depth + 1)) return true;\n }\n }\n return false;\n }\n function getContentsUnionRect(el, depth) {\n if (!el || depth > 8) return null;\n var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n var found = false;\n var visit = function(list) {\n for (var i = 0; i < list.length; i++) {\n var child = list[i];\n if (!child || child.nodeType !== 1) continue;\n var win = (child.ownerDocument && child.ownerDocument.defaultView) || window;\n var cst = win && win.getComputedStyle ? win.getComputedStyle(child) : null;\n if (cst && (cst.display === \"none\" || cst.visibility === \"hidden\" || cst.visibility === \"collapse\")) continue;\n var r = cst && cst.display === \"contents\"\n ? getContentsUnionRect(child, depth + 1)\n : (child.getBoundingClientRect ? child.getBoundingClientRect() : null);\n if (r && r.width > 0 && r.height > 0) {\n found = true;\n if (r.x < minX) minX = r.x;\n if (r.y < minY) minY = r.y;\n if (r.x + r.width > maxX) maxX = r.x + r.width;\n if (r.y + r.height > maxY) maxY = r.y + r.height;\n }\n }\n };\n if (el.children) visit(el.children);\n if (el.shadowRoot && el.shadowRoot.children) visit(el.shadowRoot.children);\n if (!found) return null;\n return { x: minX, y: minY, left: minX, top: minY, width: maxX - minX, height: maxY - minY, right: maxX, bottom: maxY };\n }\n function headingLevelOf(el) {\n if (!el) return null;\n var explicit = el.getAttribute && el.getAttribute(\"aria-level\");\n if (explicit) {\n var parsed = parseInt(explicit, 10);\n if (!isNaN(parsed)) return parsed;\n }\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n var m = /^H([1-6])$/.exec(tag);\n return m ? parseInt(m[1], 10) : null;\n }\n function getAccessibleName(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var labelledBy = el.getAttribute && el.getAttribute(\"aria-labelledby\");\n if (labelledBy) {\n var parts = [];\n var ids = labelledBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaLabel = el.getAttribute && el.getAttribute(\"aria-label\");\n if (ariaLabel && ariaLabel.trim()) return ariaLabel.trim();\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") {\n if (el.id && doc.querySelector) {\n try {\n var escId = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(el.id) : el.id;\n var forLbl = doc.querySelector('label[for=\"' + escId + '\"]');\n if (forLbl) {\n var ft = visibleTextOf(forLbl, false, el);\n if (ft) return ft;\n }\n } catch (e) {}\n }\n if (el.closest) {\n var wrapLbl = el.closest(\"label\");\n if (wrapLbl) {\n var wt = visibleTextOf(wrapLbl, false, el);\n if (wt) return wt;\n }\n }\n var itype = tag === \"INPUT\" ? (el.getAttribute(\"type\") || \"text\").toLowerCase() : \"\";\n if ((itype === \"button\" || itype === \"submit\" || itype === \"reset\") && el.value) {\n return String(el.value).trim();\n }\n var ph = el.getAttribute && el.getAttribute(\"placeholder\");\n if (ph && ph.trim()) return ph.trim();\n }\n if (tag === \"IMG\") {\n var alt = el.getAttribute && el.getAttribute(\"alt\");\n if (alt && alt.trim()) return alt.trim();\n }\n if (tag === \"FIELDSET\") {\n var fkids = el.children || [];\n for (var fi = 0; fi < fkids.length; fi++) {\n var fk = fkids[fi];\n if (fk && fk.tagName && fk.tagName.toUpperCase() === \"LEGEND\") {\n var ltxt = visibleTextOf(fk, false, null);\n if (ltxt) return ltxt;\n break;\n }\n }\n }\n if (tag === \"TABLE\") {\n var tkids = el.children || [];\n for (var ti = 0; ti < tkids.length; ti++) {\n var tk = tkids[ti];\n if (tk && tk.tagName && tk.tagName.toUpperCase() === \"CAPTION\") {\n var ctxt = visibleTextOf(tk, false, null);\n if (ctxt) return ctxt;\n break;\n }\n }\n }\n if (tag === \"FIGURE\") {\n var fgkids = el.children || [];\n for (var fgi = 0; fgi < fgkids.length; fgi++) {\n var fgk = fgkids[fgi];\n if (fgk && fgk.tagName && fgk.tagName.toUpperCase() === \"FIGCAPTION\") {\n var fgtxt = visibleTextOf(fgk, false, null);\n if (fgtxt) return fgtxt;\n break;\n }\n }\n }\n var role = getImplicitRole(el);\n var nameFromAuthorOnly = {\n list: 1, navigation: 1, main: 1, region: 1, form: 1, dialog: 1, alertdialog: 1,\n table: 1, grid: 1, tablist: 1, tabpanel: 1, menu: 1, menubar: 1, toolbar: 1,\n tree: 1, group: 1, radiogroup: 1, feed: 1, article: 1, banner: 1, complementary: 1,\n contentinfo: 1, search: 1, combobox: 1, listbox: 1, log: 1, marquee: 1, status: 1,\n timer: 1, alert: 1, application: 1, document: 1, directory: 1, figure: 1, img: 1,\n math: 1, meter: 1, progressbar: 1, scrollbar: 1, separator: 1, slider: 1,\n spinbutton: 1, textbox: 1, searchbox: 1,\n };\n if (role && nameFromAuthorOnly[role]) {\n var authorTitle = el.getAttribute && el.getAttribute(\"title\");\n return authorTitle ? authorTitle.trim() : \"\";\n }\n var txt = visibleTextOf(el, false, null);\n if (txt) return txt;\n var title = el.getAttribute && el.getAttribute(\"title\");\n return title ? title.trim() : \"\";\n }\n function getAccessibleDescription(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var describedBy = el.getAttribute && el.getAttribute(\"aria-describedby\");\n if (describedBy) {\n var parts = [];\n var ids = describedBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaDesc = el.getAttribute && el.getAttribute(\"aria-description\");\n if (ariaDesc && ariaDesc.trim()) return ariaDesc.trim();\n var title = el.getAttribute && el.getAttribute(\"title\");\n if (title && title.trim()) {\n var accName = getAccessibleName(el);\n if (accName && accName !== title.trim()) return title.trim();\n }\n return \"\";\n }\n function getIframeTransform(frameEl) {\n var fr = frameEl.getBoundingClientRect();\n var fwin = (frameEl.ownerDocument && frameEl.ownerDocument.defaultView) || window;\n var fcs = fwin && fwin.getComputedStyle ? fwin.getComputedStyle(frameEl) : null;\n var bLeft = fcs ? (parseFloat(fcs.borderLeftWidth) || 0) : 0;\n var bTop = fcs ? (parseFloat(fcs.borderTopWidth) || 0) : 0;\n var bRight = fcs ? (parseFloat(fcs.borderRightWidth) || 0) : 0;\n var bBottom = fcs ? (parseFloat(fcs.borderBottomWidth) || 0) : 0;\n var layoutW = frameEl.offsetWidth || (frameEl.clientWidth + bLeft + bRight);\n var layoutH = frameEl.offsetHeight || (frameEl.clientHeight + bTop + bBottom);\n var sx = layoutW > 0 ? (fr.width / layoutW) : 1;\n var sy = layoutH > 0 ? (fr.height / layoutH) : 1;\n if (!isFinite(sx) || sx <= 0) sx = 1;\n if (!isFinite(sy) || sy <= 0) sy = 1;\n return { left: fr.left + bLeft * sx, top: fr.top + bTop * sy, scaleX: sx, scaleY: sy };\n }\n function collectRoots(root, offsetX, offsetY, scaleX, scaleY, inShadow, inIframe, out) {\n if (!root) return;\n out.push({ root: root, offsetX: offsetX, offsetY: offsetY, scaleX: scaleX, scaleY: scaleY, inShadow: inShadow, inIframe: inIframe });\n if (root.shadowRoot) {\n collectRoots(root.shadowRoot, offsetX, offsetY, scaleX, scaleY, true, inIframe, out);\n }\n var nodes = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var i = 0; i < nodes.length; i++) {\n var el = nodes[i];\n if (el.shadowRoot) {\n collectRoots(el.shadowRoot, offsetX, offsetY, scaleX, scaleY, true, inIframe, out);\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var frameDoc = el.contentDocument;\n if (frameDoc) {\n var ft = getIframeTransform(el);\n collectRoots(\n frameDoc,\n offsetX + ft.left * scaleX,\n offsetY + ft.top * scaleY,\n scaleX * ft.scaleX,\n scaleY * ft.scaleY,\n inShadow,\n true,\n out\n );\n }\n } catch (e) {}\n }\n }\n }\n function findTextInRoot(root, needle, exact, ctx, pushHit) {\n if (!root) return;\n var isRegex = Boolean(needle && typeof needle === \"object\" && typeof needle.__spanaRegex === \"string\");\n var rawNeedleStr = isRegex ? \"\" : String(needle == null ? \"\" : needle);\n var trimmedNeedle = normWs(rawNeedleStr);\n var lowerNeedle = trimmedNeedle.toLowerCase();\n if (!isRegex && !trimmedNeedle) return;\n\n var skipTags = { SCRIPT: 1, STYLE: 1, NOSCRIPT: 1, TEMPLATE: 1, HEAD: 1, META: 1, LINK: 1, TITLE: 1 };\n\n // Button-like <input> elements store their label in .value (not ancestor .textContent),\n // so check them directly before textContent-based subtree pruning.\n if (root.querySelectorAll) {\n var btnInputs = root.querySelectorAll('input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"]');\n for (var bi = 0; bi < btnInputs.length; bi++) {\n var bNode = btnInputs[bi];\n var bVal = normWs(bNode.value || \"\");\n if (bVal && matchSpec(bVal, needle, exact)) {\n pushHit(bNode, ctx);\n }\n }\n }\n\n function visitNode(node) {\n if (!node || node.nodeType !== 1) return false;\n var tag = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (skipTags[tag] || tag === \"INPUT\") return false;\n\n var normText = normWs(node.textContent || \"\");\n if (!isRegex) {\n if (!normText) return false;\n if (exact) {\n if (normText.indexOf(trimmedNeedle) === -1) return false;\n } else {\n if (normText.toLowerCase().indexOf(lowerNeedle) === -1) return false;\n }\n }\n\n var childMatched = false;\n var kids = node.children || [];\n for (var i = 0; i < kids.length; i++) {\n if (visitNode(kids[i])) childMatched = true;\n }\n if (childMatched) return true;\n\n if (normText && matchSpec(normText, needle, exact)) {\n pushHit(node, ctx);\n return true;\n }\n return false;\n }\n\n if (root.nodeType === 9) {\n var startEl = root.body || root.documentElement;\n if (startEl) visitNode(startEl);\n return;\n }\n if (root.nodeType === 11) {\n var fragKids = root.children || [];\n for (var fi = 0; fi < fragKids.length; fi++) visitNode(fragKids[fi]);\n return;\n }\n visitNode(root);\n }\n function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit, includeHidden, level, pressed) {\n if (!root || !root.querySelectorAll) return;\n var candidates = root.querySelectorAll(\"*\");\n for (var i = 0; i < candidates.length; i++) {\n var el = candidates[i];\n if (getImplicitRole(el) !== roleLower) continue;\n if (!includeHidden && isAriaHidden(el)) continue;\n if (level !== undefined && level !== null && headingLevelOf(el) !== Number(level)) continue;\n if (pressed !== undefined && pressed !== null) {\n var ap = (el.getAttribute && el.getAttribute(\"aria-pressed\") || \"\").trim().toLowerCase();\n if (pressed ? ap !== \"true\" : ap !== \"false\") continue;\n }\n if (nameSpec !== undefined && nameSpec !== null) {\n var accName = getAccessibleName(el);\n if (!matchSpec(accName, nameSpec, Boolean(exact))) continue;\n }\n pushHit(el, ctx);\n }\n }\n function isHitVisible(h) {\n if (!h) return false;\n if (h.wasmNode) {\n return h.wasmNode.visible !== false && h.wasmRect && h.wasmRect.width > 0 && h.wasmRect.height > 0;\n }\n if (!h.el || !h.el.getBoundingClientRect) return false;\n return isVisible(h.el, h.el.getBoundingClientRect());\n }\n function applyModifiersAndSlice(hits, sel, preferVisible) {\n if (!sel || typeof sel !== \"object\" || \"point\" in sel) return hits;\n var filtered = hits;\n if (sel.hasText !== undefined) {\n filtered = filtered.filter(function(h) {\n var normTc = normWs(h.el.textContent || \"\");\n var innerT = normWs(h.el.innerText || \"\");\n var fallbackTxt = normWs(h.el.value || getAccessibleName(h.el) || \"\");\n return matchSpec(normTc, sel.hasText, false) || matchSpec(innerT, sel.hasText, false) || matchSpec(fallbackTxt, sel.hasText, false);\n });\n }\n if (sel.hasNotText !== undefined) {\n filtered = filtered.filter(function(h) {\n var normTc = normWs(h.el.textContent || \"\");\n var innerT = normWs(h.el.innerText || \"\");\n var fallbackTxt = normWs(h.el.value || getAccessibleName(h.el) || \"\");\n return !matchSpec(normTc, sel.hasNotText, false) && !matchSpec(innerT, sel.hasNotText, false) && !matchSpec(fallbackTxt, sel.hasNotText, false);\n });\n }\n if (sel.has !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.has, h.el, h.offsetX, h.offsetY, h.scaleX, h.scaleY, h.inShadow, h.inIframe, preferVisible).length > 0;\n });\n }\n if (sel.hasNot !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.hasNot, h.el, h.offsetX, h.offsetY, h.scaleX, h.scaleY, h.inShadow, h.inIframe, preferVisible).length === 0;\n });\n }\n var wantsSlice = Boolean(sel.first || sel.last || typeof sel.nth === \"number\");\n if (wantsSlice && !sel.includeHidden && preferVisible) {\n var visibleFiltered = filtered.filter(isHitVisible);\n if (preferVisible === \"strict\" || visibleFiltered.length > 0) {\n filtered = visibleFiltered;\n }\n }\n if (sel.first) return filtered.length > 0 ? [filtered[0]] : [];\n if (sel.last) return filtered.length > 0 ? [filtered[filtered.length - 1]] : [];\n if (typeof sel.nth === \"number\") {\n var idx = sel.nth < 0 ? filtered.length + sel.nth : sel.nth;\n return idx >= 0 && idx < filtered.length ? [filtered[idx]] : [];\n }\n return filtered;\n }\n function findInScope(sel, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible) {\n var hits = [];\n var seen = typeof Set !== \"undefined\" ? new Set() : null;\n function pushHit(el, ctx) {\n if (seen) {\n if (seen.has(el)) return;\n seen.add(el);\n }\n hits.push({\n el: el,\n offsetX: ctx.offsetX,\n offsetY: ctx.offsetY,\n scaleX: ctx.scaleX != null ? ctx.scaleX : 1,\n scaleY: ctx.scaleY != null ? ctx.scaleY : 1,\n inShadow: ctx.inShadow,\n inIframe: ctx.inIframe\n });\n }\n if (typeof sel === \"object\" && sel !== null && \"point\" in sel) {\n var atPt = document.elementFromPoint(sel.point.x, sel.point.y);\n if (atPt) pushHit(atPt, { offsetX: 0, offsetY: 0, scaleX: 1, scaleY: 1, inShadow: false, inIframe: false });\n return hits;\n }\n // Frame scoping: find matching <iframe> first, then search inside its contentDocument\n if (typeof sel === \"object\" && sel !== null && sel.frame) {\n var frameHits = findInScope(sel.frame, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var innerSel = Object.assign({}, sel);\n delete innerSel.frame;\n for (var fi = 0; fi < frameHits.length; fi++) {\n var fEl = frameHits[fi].el;\n if (fEl && fEl.tagName === \"IFRAME\") {\n try {\n var fDoc = fEl.contentDocument;\n if (fDoc) {\n var fTr = getIframeTransform(fEl);\n var pSx = frameHits[fi].scaleX != null ? frameHits[fi].scaleX : 1;\n var pSy = frameHits[fi].scaleY != null ? frameHits[fi].scaleY : 1;\n var sub = findInScope(\n innerSel,\n fDoc,\n frameHits[fi].offsetX + fTr.left * pSx,\n frameHits[fi].offsetY + fTr.top * pSy,\n pSx * fTr.scaleX,\n pSy * fTr.scaleY,\n frameHits[fi].inShadow,\n true,\n preferVisible\n );\n for (var si = 0; si < sub.length; si++) pushHit(sub[si].el, sub[si]);\n }\n } catch (e) {}\n }\n }\n return hits;\n }\n // Parent scoping: resolve 'within' first, then search inside each matched container\n if (typeof sel === \"object\" && sel !== null && sel.within) {\n var parentHits = findInScope(sel.within, scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var childSel = Object.assign({}, sel);\n delete childSel.within;\n delete childSel.hasText;\n delete childSel.hasNotText;\n delete childSel.has;\n delete childSel.hasNot;\n delete childSel.first;\n delete childSel.last;\n delete childSel.nth;\n var combined = [];\n var cSeen = typeof Set !== \"undefined\" ? new Set() : null;\n for (var pi = 0; pi < parentHits.length; pi++) {\n var ph = parentHits[pi];\n var subHits = findInScope(childSel, ph.el, ph.offsetX, ph.offsetY, ph.scaleX, ph.scaleY, ph.inShadow, ph.inIframe, preferVisible);\n for (var ci = 0; ci < subHits.length; ci++) {\n if (cSeen && cSeen.has(subHits[ci].el)) continue;\n if (cSeen) cSeen.add(subHits[ci].el);\n combined.push(subHits[ci]);\n }\n }\n return applyModifiersAndSlice(combined, sel, preferVisible);\n }\n // Logical OR composition (anyOf): union deduplicated hits across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.anyOf)) {\n for (var bi = 0; bi < sel.anyOf.length; bi++) {\n var branchHits = findInScope(sel.anyOf[bi], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n for (var bh = 0; bh < branchHits.length; bh++) {\n pushHit(branchHits[bh].el, branchHits[bh]);\n }\n }\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n // Logical AND composition (allOf): intersection of matched elements across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.allOf) && sel.allOf.length > 0) {\n var firstBranch = findInScope(sel.allOf[0], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var currentHits = firstBranch;\n for (var ai = 1; ai < sel.allOf.length && currentHits.length > 0; ai++) {\n var nextBranch = findInScope(sel.allOf[ai], scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, preferVisible);\n var nextEls = typeof Set !== \"undefined\" ? new Set(nextBranch.map(function(h) { return h.el; })) : null;\n currentHits = currentHits.filter(function(h) {\n if (nextEls) return nextEls.has(h.el);\n return nextBranch.some(function(nh) { return nh.el === h.el; });\n });\n }\n for (var ahi = 0; ahi < currentHits.length; ahi++) pushHit(currentHits[ahi].el, currentHits[ahi]);\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n\n function queryCssSafe(root, cssStr) {\n try {\n return root.querySelectorAll(cssStr);\n } catch (e) {\n var hint = \"\";\n if (/:has-text\\(/.test(cssStr)) hint = \" (Playwright :has-text() is not valid CSS; use { ..., hasText: ... } instead)\";\n else if (cssStr.indexOf(\">>\") !== -1) hint = \" (Playwright >> chaining is not valid CSS; use within(parent, child) instead)\";\n else if (/\\bnth=/.test(cssStr)) hint = \" (Playwright nth= is not valid CSS; use { ..., nth: index } instead)\";\n throw new Error('Invalid CSS selector \"' + cssStr + '\": ' + (e && e.message ? e.message : String(e)) + hint);\n }\n }\n function findByLabelInRoot(root, spec, exact, ctx, push) {\n if (!root || !root.querySelectorAll) return;\n var seen = new Set();\n var addCtrl = function(c) {\n if (!c || seen.has(c)) return;\n if (c.tagName === \"INPUT\" && (c.getAttribute(\"type\") || \"\").toLowerCase() === \"hidden\") return;\n seen.add(c);\n push(c, ctx);\n };\n // 1. Explicit <label> elements (associated via .control, [for], or nested labelable control)\n var labels = root.querySelectorAll(\"label\");\n for (var lb = 0; lb < labels.length; lb++) {\n var lblEl = labels[lb];\n var ctrlFromLbl = lblEl.control || null;\n if (!ctrlFromLbl && lblEl.getAttribute) {\n var forAttr = lblEl.getAttribute(\"for\");\n if (forAttr) {\n var lblRoot = typeof lblEl.getRootNode === \"function\" ? lblEl.getRootNode() : null;\n if (lblRoot && typeof lblRoot.getElementById === \"function\") {\n ctrlFromLbl = lblRoot.getElementById(forAttr);\n }\n if (!ctrlFromLbl) {\n var lblDoc = lblEl.ownerDocument || document;\n ctrlFromLbl = lblDoc.getElementById ? lblDoc.getElementById(forAttr) : null;\n }\n if (!ctrlFromLbl && root.querySelector) {\n try {\n var escFor = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(forAttr) : forAttr;\n ctrlFromLbl = root.querySelector('[id=\"' + escFor + '\"]');\n } catch (e) {}\n }\n }\n }\n if (!ctrlFromLbl && lblEl.querySelector) {\n ctrlFromLbl = lblEl.querySelector(\"input:not([type=hidden]), textarea, select, meter, output, progress\");\n }\n if (!ctrlFromLbl) continue;\n var rawLblText = visibleTextOf(lblEl, false, ctrlFromLbl) || normWs(lblEl.textContent || \"\");\n var fullLblText = !lblEl.contains(ctrlFromLbl) ? normWs(lblEl.textContent || \"\") : \"\";\n if (\n (rawLblText && matchSpec(rawLblText, spec, exact)) ||\n (fullLblText && matchSpec(fullLblText, spec, exact))\n ) {\n addCtrl(ctrlFromLbl);\n }\n }\n // 2. Labelable form controls & ARIA form widgets (never match <button> by its inner text)\n var labelableRoles = {\n textbox: 1, searchbox: 1, combobox: 1, listbox: 1, spinbutton: 1,\n slider: 1, checkbox: 1, radio: 1, switch: 1,\n };\n var controls = root.querySelectorAll(\"input, textarea, select, meter, output, progress, audio, video, [contenteditable], [aria-label], [aria-labelledby]\");\n for (var li = 0; li < controls.length; li++) {\n var ctrl = controls[li];\n if (seen.has(ctrl)) continue;\n if (ctrl.tagName === \"INPUT\" && (ctrl.getAttribute(\"type\") || \"\").toLowerCase() === \"hidden\") continue;\n var tag = ctrl.tagName ? ctrl.tagName.toUpperCase() : \"\";\n var isFormControl =\n tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" ||\n tag === \"METER\" || tag === \"OUTPUT\" || tag === \"PROGRESS\" ||\n tag === \"AUDIO\" || tag === \"VIDEO\" ||\n (ctrl.hasAttribute && ctrl.hasAttribute(\"contenteditable\"));\n var role = getImplicitRole(ctrl);\n if (!isFormControl && !labelableRoles[role]) continue;\n var labelText = getAccessibleName(ctrl);\n if (!labelText && ctrl.labels && ctrl.labels.length > 0) {\n var parts = [];\n for (var lj = 0; lj < ctrl.labels.length; lj++) {\n parts.push((ctrl.labels[lj].textContent || \"\").trim());\n }\n labelText = parts.join(\" \").trim();\n }\n if (labelText && matchSpec(labelText, spec, exact)) {\n addCtrl(ctrl);\n }\n }\n }\n function findByAttrSpecInRoot(root, attrName, spec, exact, ctx, push) {\n if (!root || !root.querySelectorAll) return;\n var nodes = root.querySelectorAll(\"[\" + attrName + \"]\");\n for (var ni = 0; ni < nodes.length; ni++) {\n var val = nodes[ni].getAttribute(attrName);\n if (val !== null && matchSpec(val, spec, exact)) {\n push(nodes[ni], ctx);\n }\n }\n }\n\n var esc = function(v) {\n return typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(v) : String(v).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n };\n var mainCtx = { root: scopeRoot, offsetX: baseOffsetX, offsetY: baseOffsetY, scaleX: baseScaleX, scaleY: baseScaleY, inShadow: baseInShadow, inIframe: baseInIframe };\n var hasModifiers = typeof sel === \"object\" && sel !== null && (sel.hasText !== undefined || sel.hasNotText !== undefined || sel.has !== undefined || sel.hasNot !== undefined || sel.first || sel.last || typeof sel.nth === \"number\");\n\n // O(1)-ish Light-DOM fast path: avoids scanning thousands of nodes with querySelectorAll(\"*\")\n // unless Shadow DOM / iframe piercing is needed or no Light-DOM match exists.\n if (scopeRoot && scopeRoot.querySelectorAll && !hasModifiers) {\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var fastTid = esc(sel.testID);\n var fastFound = scopeRoot.querySelectorAll('[data-testid=\"' + fastTid + '\"], [testID=\"' + fastTid + '\"]');\n if (fastFound.length > 0) {\n for (var fi2 = 0; fi2 < fastFound.length; fi2++) pushHit(fastFound[fi2], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n var fastCss = queryCssSafe(scopeRoot, sel.css);\n if (fastCss.length > 0) {\n for (var fc = 0; fc < fastCss.length; fc++) pushHit(fastCss[fc], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var fastLbl = esc(sel.accessibilityLabel);\n var fastFoundLbl = scopeRoot.querySelectorAll('[aria-label=\"' + fastLbl + '\"]');\n if (fastFoundLbl.length > 0) {\n for (var fj = 0; fj < fastFoundLbl.length; fj++) pushHit(fastFoundLbl[fj], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"label\" in sel) {\n findByLabelInRoot(scopeRoot, sel.label, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"placeholder\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"placeholder\", sel.placeholder, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"altText\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"alt\", sel.altText, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"title\" in sel) {\n findByAttrSpecInRoot(scopeRoot, \"title\", sel.title, Boolean(sel.exact), mainCtx, pushHit);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit, sel.includeHidden, sel.level, sel.pressed);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var fastNeedle = typeof sel === \"string\" ? sel : sel.text;\n var fastExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(scopeRoot, fastNeedle, fastExact, mainCtx, pushHit);\n if (hits.length > 0) return hits;\n }\n }\n\n var roots = [];\n collectRoots(scopeRoot, baseOffsetX, baseOffsetY, baseScaleX, baseScaleY, baseInShadow, baseInIframe, roots);\n for (var r = 0; r < roots.length; r++) {\n var ctx = roots[r];\n var root = ctx.root;\n if (!root || !root.querySelectorAll) continue;\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var tid = esc(sel.testID);\n var found = root.querySelectorAll('[data-testid=\"' + tid + '\"], [testID=\"' + tid + '\"]');\n for (var i = 0; i < found.length; i++) pushHit(found[i], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n var foundCss = queryCssSafe(root, sel.css);\n for (var ci2 = 0; ci2 < foundCss.length; ci2++) pushHit(foundCss[ci2], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var lbl = esc(sel.accessibilityLabel);\n var foundLbl = root.querySelectorAll('[aria-label=\"' + lbl + '\"]');\n for (var j = 0; j < foundLbl.length; j++) pushHit(foundLbl[j], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"label\" in sel) {\n findByLabelInRoot(root, sel.label, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"placeholder\" in sel) {\n findByAttrSpecInRoot(root, \"placeholder\", sel.placeholder, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"altText\" in sel) {\n findByAttrSpecInRoot(root, \"alt\", sel.altText, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"title\" in sel) {\n findByAttrSpecInRoot(root, \"title\", sel.title, Boolean(sel.exact), ctx, pushHit);\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit, sel.includeHidden, sel.level, sel.pressed);\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var needle = typeof sel === \"string\" ? sel : sel.text;\n var isExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(root, needle, isExact, ctx, pushHit);\n }\n }\n return applyModifiersAndSlice(hits, sel, preferVisible);\n }\n function findWasmSemanticHits(sel) {\n if (typeof window === \"undefined\" || !window.__SPANA_WASM_TREE__) return [];\n var provider = window.__SPANA_WASM_TREE__;\n var nodes;\n try { nodes = typeof provider === \"function\" ? provider() : provider; } catch (e) { return []; }\n if (!Array.isArray(nodes) || nodes.length === 0) return [];\n var matched = [];\n for (var i = 0; i < nodes.length; i++) {\n var n = nodes[i];\n if (!n || typeof n !== \"object\" || !n.bounds) continue;\n var nid = n.testID || n.id || \"\";\n var ntext = String(n.text != null ? n.text : (n.label != null ? n.label : \"\"));\n var nlabel = String(n.label != null ? n.label : \"\");\n var nrole = String(n.role || \"\");\n var ok = false;\n if (typeof sel === \"string\") {\n ok = nid === sel || ntext === sel;\n } else if (sel && typeof sel === \"object\") {\n if (sel.testID !== undefined) {\n ok = nid === sel.testID;\n } else if (sel.text !== undefined) {\n ok = sel.exact ? ntext.trim() === String(sel.text).trim() : ntext.indexOf(String(sel.text)) !== -1;\n } else if (sel.accessibilityLabel !== undefined) {\n ok = nlabel === sel.accessibilityLabel || ntext === sel.accessibilityLabel;\n } else if (sel.role !== undefined) {\n var rOk = nrole.toLowerCase() === String(sel.role).toLowerCase();\n var nameOk = true;\n if (sel.name !== undefined) {\n if (typeof sel.name === \"object\" && sel.name && sel.name.__regex) {\n var re = new RegExp(sel.name.source, sel.name.flags || \"\");\n nameOk = re.test(ntext) || re.test(nlabel);\n } else {\n var exp = String(sel.name);\n nameOk = sel.exact\n ? (ntext.trim() === exp.trim() || nlabel.trim() === exp.trim())\n : (ntext.toLowerCase().indexOf(exp.toLowerCase()) !== -1 || nlabel.toLowerCase().indexOf(exp.toLowerCase()) !== -1);\n }\n }\n ok = rOk && nameOk;\n }\n }\n if (!ok) continue;\n var ox = 0;\n var oy = 0;\n var hostEl = null;\n if (n.canvasSelector && typeof document !== \"undefined\" && document.querySelector) {\n try {\n hostEl = document.querySelector(n.canvasSelector);\n if (hostEl && typeof hostEl.getBoundingClientRect === \"function\") {\n var cr = hostEl.getBoundingClientRect();\n ox = cr.left || 0;\n oy = cr.top || 0;\n }\n } catch (e) {}\n }\n var bx = (n.bounds.x || 0) + ox;\n var by = (n.bounds.y || 0) + oy;\n var bw = n.bounds.width || 0;\n var bh = n.bounds.height || 0;\n var vRect = { left: bx, top: by, x: bx, y: by, width: bw, height: bh, right: bx + bw, bottom: by + bh };\n var virtualEl = {\n isConnected: true,\n tagName: \"WASM-NODE\",\n innerText: ntext,\n textContent: ntext,\n value: n.value,\n __spanaHostCanvas: hostEl,\n getBoundingClientRect: function() { return vRect; },\n getAttribute: function(k) {\n if (k === \"data-testid\" || k === \"testID\") return nid || null;\n if (k === \"role\") return nrole || null;\n if (k === \"aria-label\") return nlabel || null;\n return (n.attributes && n.attributes[k]) || null;\n },\n hasAttribute: function(k) { return this.getAttribute(k) !== null; }\n };\n matched.push({ el: virtualEl, offsetX: 0, offsetY: 0, inShadow: false, inIframe: false, wasmNode: n, wasmRect: vRect });\n }\n return matched;\n }\n function findAcrossRoots(sel, preferVisible) {\n var pv = preferVisible === undefined ? \"prefer\" : preferVisible;\n var domHits = findInScope(sel, document, 0, 0, 1, 1, false, false, pv);\n var wasmHits = findWasmSemanticHits(sel);\n if (wasmHits.length === 0) return domHits;\n return domHits.length === 0 ? wasmHits : domHits.concat(wasmHits);\n }\n function isClickable(el) {\n var tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"A\" || tag === \"INPUT\" || tag === \"SELECT\" || tag === \"TEXTAREA\") return true;\n var role = el.getAttribute && el.getAttribute(\"role\");\n if (role === \"button\" || role === \"link\" || role === \"tab\" || role === \"checkbox\" || role === \"switch\") return true;\n if (typeof el.onclick === \"function\") return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cursor = win.getComputedStyle(el).cursor;\n return cursor === \"pointer\";\n }\n function isAppReady() {\n var sig = typeof window !== \"undefined\" ? window.__SPANA_APP_READY__ : undefined;\n if (typeof sig === \"function\") {\n try { return Boolean(sig()); } catch (e) { return false; }\n }\n if (typeof sig === \"boolean\") return sig;\n return true;\n }\n function deepElementFromPoint(rootDoc, x, y) {\n if (!rootDoc || typeof rootDoc.elementFromPoint !== \"function\") return null;\n var el = rootDoc.elementFromPoint(x, y);\n var guard = 0;\n while (el && guard++ < 16) {\n if (el.shadowRoot && typeof el.shadowRoot.elementFromPoint === \"function\") {\n var inner = el.shadowRoot.elementFromPoint(x, y);\n if (inner && inner !== el) { el = inner; continue; }\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var fdoc = el.contentDocument;\n if (fdoc && typeof fdoc.elementFromPoint === \"function\") {\n var ft = getIframeTransform(el);\n var fx = (x - ft.left) / ft.scaleX;\n var fy = (y - ft.top) / ft.scaleY;\n var fEl = fdoc.elementFromPoint(fx, fy);\n if (fEl && fEl !== el) { el = fEl; x = fx; y = fy; continue; }\n }\n } catch (e) {}\n }\n break;\n }\n return el;\n }\n function labelControlOf(node) {\n var cur = node;\n var guard = 0;\n while (cur && guard++ < 8) {\n if (cur.tagName === \"LABEL\") return cur.control || null;\n cur = cur.parentElement;\n }\n return null;\n }\n function isSameOrDescendant(target, candidate) {\n if (!target || !candidate) return false;\n if (target === candidate) return true;\n try {\n if (typeof target.contains === \"function\" && target.contains(candidate)) return true;\n } catch (e) {}\n if (labelControlOf(candidate) === target) return true;\n var cur = candidate;\n var guard = 0;\n while (cur && guard++ < 24) {\n if (cur === target) return true;\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n if (root && root.host) {\n cur = root.host;\n } else {\n cur = cur.parentElement;\n }\n }\n return false;\n }\n function describeEl(el) {\n if (!el) return \"(unknown)\";\n var tag = el.tagName ? el.tagName.toLowerCase() : \"element\";\n var idPart = el.id ? \"#\" + el.id : \"\";\n var cls = typeof el.className === \"string\" ? el.className.trim().split(/\\s+/).filter(Boolean).slice(0, 3).join(\".\") : \"\";\n var clsPart = cls ? \".\" + cls : \"\";\n var txt = (el.innerText || el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n if (txt.length > 40) txt = txt.slice(0, 37) + \"...\";\n return \"<\" + tag + idPart + clsPart + (txt ? \">\" + txt + \"</\" + tag + \">\" : \">\");\n }\n function getHitTestBlocker(hit) {\n if (hit.wasmNode) {\n var wr = hit.wasmRect;\n var wvw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || 0;\n var wvh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || 0;\n var wcx = wr.left + wr.width / 2;\n var wcy = wr.top + wr.height / 2;\n if (wvw > 0 && wvh > 0 && (wcx < 0 || wcy < 0 || wcx > wvw || wcy > wvh)) return \"outside viewport\";\n if (hit.el && hit.el.__spanaHostCanvas) {\n var topW = deepElementFromPoint(document, wcx, wcy);\n if (topW && !isSameOrDescendant(hit.el.__spanaHostCanvas, topW)) return describeEl(topW);\n }\n return null;\n }\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = hit.offsetX + (rect.left + rect.width / 2) * sx;\n var cy = hit.offsetY + (rect.top + rect.height / 2) * sy;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return \"outside viewport\";\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return null;\n if (isSameOrDescendant(el, topEl)) return null;\n return describeEl(topEl);\n }\n function getClippedViewportBox(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var left = hit.offsetX + rect.left * sx;\n var top = hit.offsetY + rect.top * sy;\n var right = hit.offsetX + (rect.left + rect.width) * sx;\n var bottom = hit.offsetY + (rect.top + rect.height) * sy;\n // Intersect with clipping ancestors (overflow: hidden/clip/scroll/auto) so half-clipped buttons\n // target their visible region rather than clicking a clipped-out center onto the parent container.\n var cur = el.parentElement;\n var guard = 0;\n while (cur && guard++ < 32) {\n var cs = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(cur) : null;\n if (cs) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n if (ox === \"hidden\" || ox === \"clip\" || ox === \"scroll\" || ox === \"auto\" ||\n oy === \"hidden\" || oy === \"clip\" || oy === \"scroll\" || oy === \"auto\") {\n var cr = cur.getBoundingClientRect();\n if (cr.width > 0 && cr.height > 0) {\n var cLeft = hit.offsetX + cr.left * sx;\n var cTop = hit.offsetY + cr.top * sy;\n var cRight = hit.offsetX + cr.right * sx;\n var cBottom = hit.offsetY + cr.bottom * sy;\n if (ox === \"hidden\" || ox === \"clip\" || ox === \"scroll\" || ox === \"auto\") {\n if (cLeft > left) left = cLeft;\n if (cRight < right) right = cRight;\n }\n if (oy === \"hidden\" || oy === \"clip\" || oy === \"scroll\" || oy === \"auto\") {\n if (cTop > top) top = cTop;\n if (cBottom < bottom) bottom = cBottom;\n }\n }\n }\n }\n cur = cur.parentElement;\n }\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n if (vw > 0 && vh > 0) {\n if (left < 0) left = 0;\n if (top < 0) top = 0;\n if (right > vw) right = vw;\n if (bottom > vh) bottom = vh;\n }\n return { left: left, top: top, right: right, bottom: bottom, vw: vw, vh: vh, rawRect: rect, sx: sx, sy: sy };\n }\n function findClickablePoint(hit) {\n if (hit.wasmNode) {\n var wr = hit.wasmRect;\n return { x: wr.left + wr.width / 2, y: wr.top + wr.height / 2 };\n }\n var el = hit.el;\n var box = getClippedViewportBox(hit);\n var rawCx = hit.offsetX + (box.rawRect.left + box.rawRect.width / 2) * box.sx;\n var rawCy = hit.offsetY + (box.rawRect.top + box.rawRect.height / 2) * box.sy;\n var clipW = box.right - box.left;\n var clipH = box.bottom - box.top;\n if (box.vw > 0 && box.vh > 0 && (clipW <= 0 || clipH <= 0)) {\n return null;\n }\n var tryPt = function(px, py) {\n if (box.vw > 0 && box.vh > 0 && (px < 0 || py < 0 || px >= box.vw || py >= box.vh)) return null;\n var topEl = deepElementFromPoint(document, px, py);\n if (!topEl || isSameOrDescendant(el, topEl)) return { x: px, y: py };\n return null;\n };\n // 1. Fast path: unclipped rounded center (matches 99.9% of elements in 1 hit-test call)\n var rRaw = tryPt(Math.round(rawCx), Math.round(rawCy));\n if (rRaw) return rRaw;\n // 2. Clipped visible center (rounded, then fractional)\n var cx = box.left + clipW / 2;\n var cy = box.top + clipH / 2;\n var rClip = tryPt(Math.round(cx), Math.round(cy));\n if (rClip) return rClip;\n var fClip = tryPt(cx, cy);\n if (fClip) return fClip;\n // 3. Interior points inside the visible clipped rect (handles 0.5px edge rounding onto clipping parent)\n var padX = Math.min(2, clipW / 4);\n var padY = Math.min(2, clipH / 4);\n var candidates = [\n [Math.floor(cx), Math.floor(cy)],\n [Math.ceil(cx), Math.floor(cy)],\n [Math.floor(cx), Math.ceil(cy)],\n [Math.floor(box.left + padX), Math.floor(box.top + padY)],\n [Math.ceil(box.left + padX), Math.ceil(box.top + padY)],\n [Math.floor(box.right - padX), Math.floor(box.bottom - padY)],\n [box.left + padX, box.top + padY],\n [box.right - padX, box.bottom - padY],\n ];\n for (var i = 0; i < candidates.length; i++) {\n var hitPt = tryPt(candidates[i][0], candidates[i][1]);\n if (hitPt) return hitPt;\n }\n return null;\n }\n function isHitTestClear(hit) {\n if (hit.wasmNode) {\n return getHitTestBlocker(hit) === null;\n }\n var pt = findClickablePoint(hit);\n if (pt) {\n hit._clickPoint = pt;\n return true;\n }\n hit._clickPoint = null;\n return false;\n }\n function isScrollableOverflow(val) {\n return val === \"auto\" || val === \"scroll\" || val === \"overlay\";\n }\n function isClippedByScrollableAncestor(hit, rect) {\n var el = hit.el;\n var doc = el.ownerDocument || document;\n var win = doc.defaultView || window;\n var cur = el.parentElement;\n var guard = 0;\n while (cur && cur.nodeType === 1 && guard++ < 32) {\n if (cur === doc.documentElement || cur === doc.body) break;\n var cs = win && win.getComputedStyle ? win.getComputedStyle(cur) : null;\n if (cs) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n var canScrollX = isScrollableOverflow(ox) && cur.scrollWidth > cur.clientWidth + 1;\n var canScrollY = isScrollableOverflow(oy) && cur.scrollHeight > cur.clientHeight + 1;\n if (canScrollX || canScrollY) {\n var cr = cur.getBoundingClientRect();\n if (cr.width > 0 && cr.height > 0) {\n if (canScrollX && (rect.left < cr.left - 0.5 || rect.right > cr.right + 0.5)) {\n return true;\n }\n if (canScrollY && (rect.top < cr.top - 0.5 || rect.bottom > cr.bottom + 0.5)) {\n return true;\n }\n }\n }\n // Inspect a position: fixed ancestor itself FIRST (it may be scrollable),\n // then stop walking above its fixed containing boundary.\n if (cs.position === \"fixed\") break;\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isFullyInViewport(hit) {\n if (hit.wasmNode) return true;\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n if (vw <= 0 || vh <= 0 || rect.width <= 0 || rect.height <= 0) return false;\n var left = hit.offsetX + rect.left * sx;\n var top = hit.offsetY + rect.top * sy;\n if (!(left >= 0 && top >= 0 && (left + rect.width * sx) <= vw && (top + rect.height * sy) <= vh)) {\n return false;\n }\n if (isClippedByScrollableAncestor(hit, rect)) return false;\n return true;\n }\n function ensureInViewport(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = hit.offsetX + (rect.left + rect.width / 2) * sx;\n var cy = hit.offsetY + (rect.top + rect.height / 2) * sy;\n var outsideWindow = vw > 0 && vh > 0 && (cx < 1 || cy < 1 || cx > vw - 1 || cy > vh - 1);\n if (outsideWindow || isClippedByScrollableAncestor(hit, rect)) {\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { el.scrollIntoView(true); } catch (e2) {} }\n }\n return true;\n }\n return false;\n }\n function canScrollToUnobscure(hit) {\n if (!hit || !hit.el || hit.wasmNode) return false;\n var el = hit.el;\n var doc = el.ownerDocument || document;\n var win = doc.defaultView || window;\n var hasScrollableAncestor = false;\n var hitFixedBoundary = false;\n var cur = el;\n var guard = 0;\n while (cur && cur.nodeType === 1 && guard++ < 32) {\n var cs = win && win.getComputedStyle ? win.getComputedStyle(cur) : null;\n if (cs) {\n if (cur !== el && cur !== doc.documentElement && cur !== doc.body) {\n var ox = cs.overflowX || cs.overflow || \"\";\n var oy = cs.overflowY || cs.overflow || \"\";\n if ((isScrollableOverflow(ox) && cur.scrollWidth > cur.clientWidth + 1) ||\n (isScrollableOverflow(oy) && cur.scrollHeight > cur.clientHeight + 1)) {\n hasScrollableAncestor = true;\n }\n }\n if (cs.position === \"fixed\") {\n hitFixedBoundary = true;\n break;\n }\n }\n cur = cur.parentElement;\n }\n var rect = el.getBoundingClientRect();\n // If clipped outside a scrollable ancestor (including inside/on a position: fixed dialog),\n // scrolling that ancestor brings the target into view even if the clipped point hits a backdrop.\n if (hasScrollableAncestor && isClippedByScrollableAncestor(hit, rect)) {\n return true;\n }\n if (hitFixedBoundary && !hasScrollableAncestor) return false;\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var topEl = deepElementFromPoint(doc, cx, cy);\n if (!topEl) return false;\n var vpW = win.innerWidth || doc.documentElement.clientWidth || 1280;\n var vpH = win.innerHeight || doc.documentElement.clientHeight || 720;\n var b = topEl;\n while (b && b.nodeType === 1) {\n var bs = win && win.getComputedStyle ? win.getComputedStyle(b) : null;\n if (bs && (bs.position === \"fixed\" || bs.position === \"sticky\")) {\n var br = b.getBoundingClientRect();\n if (br.width >= vpW * 0.8 && br.height >= vpH * 0.8) return false;\n return true;\n }\n b = b.parentElement;\n }\n return false;\n }\n function scrollToUnobscure(hit) {\n var el = hit.el;\n if (typeof el.scrollIntoView !== \"function\") return false;\n var blocks = [\"center\", \"end\", \"start\", \"nearest\"];\n for (var i = 0; i < blocks.length; i++) {\n try {\n el.scrollIntoView({ block: blocks[i], inline: \"center\", behavior: \"instant\" });\n } catch (e) {\n try { el.scrollIntoView(true); } catch (e2) {}\n }\n if (!el.isConnected) {\n try { window.__spanaLastScrollDetached = true; } catch (e3) {}\n return false;\n }\n if (isHitTestClear(hit)) return true;\n }\n return false;\n }\n function hasActiveViewTransition() {\n if (typeof document === \"undefined\" || typeof document.getAnimations !== \"function\") return false;\n try {\n var allAnims = document.getAnimations();\n for (var i = 0; i < allAnims.length; i++) {\n var a = allAnims[i];\n var pseudo = a && a.effect && a.effect.pseudoElement;\n if (a && a.playState === \"running\" && typeof pseudo === \"string\" && pseudo.indexOf(\"::view-transition\") === 0) {\n return true;\n }\n }\n } catch (e) {}\n return false;\n }\n function hasActiveAnimation(el) {\n if (hasActiveViewTransition()) return true;\n var cur = el;\n var depth = 0;\n while (cur && depth++ < 8) {\n if (typeof cur.getAnimations === \"function\") {\n try {\n var anims = cur.getAnimations();\n for (var i = 0; i < anims.length; i++) {\n if (anims[i] && anims[i].playState === \"running\") return true;\n }\n } catch (e) {}\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isElementEnabled(el) {\n if (!el) return true;\n if (el.hasAttribute && el.hasAttribute(\"disabled\")) return false;\n if (el.getAttribute && el.getAttribute(\"aria-disabled\") === \"true\") return false;\n try {\n if (typeof el.matches === \"function\" && el.matches(\":disabled\")) return false;\n } catch (e) {}\n var cur = el.parentElement;\n var guard = 0;\n while (cur && guard++ < 16) {\n if (cur.getAttribute && cur.getAttribute(\"aria-disabled\") === \"true\") return false;\n cur = cur.parentElement;\n }\n return true;\n }\n function isVisible(el, rect, depth) {\n if (!el) return false;\n if (isVisiblyHiddenInAncestorChain(el)) return false;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var style = win && win.getComputedStyle ? win.getComputedStyle(el) : null;\n if (style && style.display === \"contents\") {\n return hasVisibleDescendant(el, depth || 0);\n }\n if (!rect || rect.width <= 0 || rect.height <= 0) return false;\n return true;\n }\n function getVisibilityFailureReason(el, rect) {\n if (!el) return \"element is null\";\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 48) {\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs) {\n if (cs.display === \"none\") return cur === el ? \"display: none\" : \"ancestor has display: none\";\n if (cs.contentVisibility === \"hidden\") return cur === el ? \"content-visibility: hidden\" : \"ancestor has content-visibility: hidden\";\n }\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (el.nodeType === 1 && win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return \"visibility: \" + selfCs.visibility;\n if (selfCs && selfCs.display === \"contents\" && !hasVisibleDescendant(el, 0)) return \"display: contents with no visible children\";\n }\n if (!rect || rect.width <= 0 || rect.height <= 0) return \"bounding box has zero size (\" + (rect ? Math.round(rect.width) + \"x\" + Math.round(rect.height) : \"none\") + \")\";\n return null;\n }\n function toMatch(hit) {\n if (hit.wasmNode) {\n var wn = hit.wasmNode;\n var wr = hit.wasmRect;\n var wtext = (wn.text != null ? String(wn.text) : (wn.label != null ? String(wn.label) : \"\")).trim() || undefined;\n return {\n id: wn.testID || wn.id || undefined,\n tag: \"wasm-node\",\n role: wn.role || undefined,\n text: wtext,\n textContent: wtext,\n value: wn.value != null ? String(wn.value) : undefined,\n accessibilityLabel: wn.label || undefined,\n accessibleName: wn.label || wtext,\n rect: { x: wr.left, y: wr.top, width: wr.width, height: wr.height },\n scrollX: window.scrollX || 0,\n scrollY: window.scrollY || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: window.innerWidth || 0,\n viewportHeight: window.innerHeight || 0,\n visible: wn.visible !== false && wr.width > 0 && wr.height > 0,\n enabled: wn.enabled !== false,\n clickable: wn.clickable !== undefined ? Boolean(wn.clickable) : (wn.role === \"button\" || wn.role === \"link\"),\n focused: wn.focused,\n checked: wn.checked,\n editable: wn.editable,\n empty: wn.value !== undefined ? String(wn.value).length === 0 : !wtext,\n attributes: wn.attributes || {},\n inShadowDom: false,\n inIframe: false\n };\n }\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var winForRect = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var styleForRect = winForRect && winForRect.getComputedStyle ? winForRect.getComputedStyle(el) : null;\n if (styleForRect && styleForRect.display === \"contents\") {\n var contentsRect = getContentsUnionRect(el, 0);\n if (contentsRect) rect = contentsRect;\n }\n var attrs = {};\n if (el.attributes) {\n for (var i = 0; i < el.attributes.length; i++) {\n attrs[el.attributes[i].name] = el.attributes[i].value;\n }\n }\n var tag = el.tagName ? el.tagName.toLowerCase() : undefined;\n var val = (el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.tagName === \"SELECT\")\n ? String(el.value ?? \"\")\n : undefined;\n var text = normWs(el.innerText || el.textContent || \"\") || undefined;\n var normTextContent = normWs(el.textContent || \"\") || undefined;\n var accName = getAccessibleName(el) || undefined;\n var accDesc = getAccessibleDescription(el) || undefined;\n var role = getImplicitRole(el) || undefined;\n var isEnabled = isElementEnabled(el);\n var isChecked =\n el.tagName === \"INPUT\" && (el.type === \"checkbox\" || el.type === \"radio\")\n ? Boolean(el.checked)\n : el.getAttribute(\"aria-checked\") === \"true\"\n ? true\n : el.getAttribute(\"aria-checked\") === \"false\"\n ? false\n : undefined;\n var isEditable = Boolean(\n isEnabled &&\n !el.hasAttribute(\"readonly\") &&\n el.getAttribute(\"aria-readonly\") !== \"true\" &&\n (el.isContentEditable ||\n el.tagName === \"TEXTAREA\" ||\n el.tagName === \"SELECT\" ||\n (el.tagName === \"INPUT\" &&\n [\"button\", \"submit\", \"reset\", \"image\", \"hidden\", \"checkbox\", \"radio\"].indexOf(\n String(el.type || \"text\").toLowerCase(),\n ) === -1)),\n );\n var isEmpty =\n el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\"\n ? String(el.value || \"\").length === 0\n : (el.textContent || \"\").trim().length === 0;\n var clsName = typeof el.className === \"string\" ? el.className : (el.getAttribute(\"class\") || \"\");\n var sx = hit.scaleX != null ? hit.scaleX : 1;\n var sy = hit.scaleY != null ? hit.scaleY : 1;\n return {\n id: el.getAttribute(\"data-testid\") || el.getAttribute(\"testID\") || undefined,\n tag: tag,\n role: role,\n text: text,\n textContent: normTextContent,\n value: val,\n accessibilityLabel: el.getAttribute(\"aria-label\") || undefined,\n accessibleName: accName,\n accessibleDescription: accDesc,\n rect: { x: hit.offsetX + rect.x * sx, y: hit.offsetY + rect.y * sy, width: rect.width * sx, height: rect.height * sy },\n clickPoint: hit._clickPoint || undefined,\n scrollX: window.scrollX || window.pageXOffset || 0,\n scrollY: window.scrollY || window.pageYOffset || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0,\n viewportHeight: (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0,\n visible: isVisible(el, rect),\n enabled: isEnabled,\n clickable: isClickable(el),\n focused: document.activeElement === el,\n checked: isChecked,\n editable: isEditable,\n empty: isEmpty,\n className: clsName || undefined,\n attributes: attrs,\n inShadowDom: hit.inShadow || undefined,\n inIframe: hit.inIframe || undefined\n };\n }\n\n\n function query(sel) {\n return findAcrossRoots(sel).map(toMatch);\n }\n\n function scrollIntoView(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return null;\n var hit = hits[hits.length - 1];\n if (typeof hit.el.scrollIntoView === \"function\") {\n try { hit.el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { hit.el.scrollIntoView(true); } catch (e2) {} }\n }\n return toMatch(hit);\n }\n\n function tap(sel) {\n var hits = findAcrossRoots(sel, \"strict\");\n var hit = null;\n for (var i = hits.length - 1; i >= 0; i--) {\n var m = toMatch(hits[i]);\n if (m.visible && m.enabled) { hit = hits[i]; break; }\n }\n if (!hit) return false;\n var el = hit.el;\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); } catch (e) {}\n }\n if (!el.isConnected) return false;\n var postMatch = toMatch(hit);\n if (!postMatch.visible || !postMatch.enabled) return false;\n var rect = el.getBoundingClientRect();\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var init = { bubbles: true, cancelable: true, composed: true, clientX: cx, clientY: cy };\n try { el.dispatchEvent(new PointerEvent(\"pointerdown\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mousedown\", init)); } catch (e) {}\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n try { el.dispatchEvent(new PointerEvent(\"pointerup\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mouseup\", init)); } catch (e) {}\n if (typeof el.click === \"function\") { el.click(); }\n else { el.dispatchEvent(new MouseEvent(\"click\", init)); }\n return true;\n }\n\n function waitForSelector(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var forAction = Boolean(opts.forAction);\n var force = Boolean(opts.force);\n var failFastWhenIdle = Boolean(opts.failFastWhenIdle);\n var idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs != null ? opts.idleQuietMs : 250));\n var reqStableFrames = force ? 0 : (opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? 2 : 0));\n var checkHitTest = force ? false : (opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : forAction);\n var waitForAppReady = opts.waitForAppReady !== undefined ? Boolean(opts.waitForAppReady) : true;\n var armTapGuard = Boolean(opts.armTapGuard && forAction && !force);\n var instantAnim = Boolean(typeof document !== \"undefined\" && document.getElementById && document.getElementById(\"__spana_instant_anim\"));\n var explicitStableFrames = (instantAnim || force) ? 0 : reqStableFrames;\n\n function armTapGuardOnEl(el) {\n if (!armTapGuard || !el || el.nodeType !== 1) return;\n try {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var doc = el.ownerDocument || document;\n if (window.__spanaTapGuardCleanup) window.__spanaTapGuardCleanup();\n window.__spanaTapMissed = false;\n var matchTarget = function(t) {\n return isSameOrDescendant(el, t);\n };\n var cleanup = function() {\n win.removeEventListener(\"pointerdown\", onEvt, true);\n win.removeEventListener(\"mousedown\", onEvt, true);\n win.removeEventListener(\"mouseup\", onMouseUp, true);\n win.removeEventListener(\"click\", onEvt, true);\n if (window.__spanaTapGuardCleanup === cleanup) delete window.__spanaTapGuardCleanup;\n };\n var onMouseUp = function(e) {\n if (!e.isTrusted) return;\n Promise.resolve().then(cleanup);\n };\n var onEvt = function(e) {\n if (!e.isTrusted) return;\n var hit = deepElementFromPoint(doc, e.clientX, e.clientY) || e.target;\n if (!matchTarget(hit) && !matchTarget(e.target)) {\n e.stopImmediatePropagation();\n e.preventDefault();\n window.__spanaTapMissed = true;\n if (e.type === \"click\") cleanup();\n } else if (e.type === \"click\") {\n cleanup();\n }\n };\n win.addEventListener(\"pointerdown\", onEvt, true);\n win.addEventListener(\"mousedown\", onEvt, true);\n win.addEventListener(\"mouseup\", onMouseUp, true);\n win.addEventListener(\"click\", onEvt, true);\n window.__spanaTapGuardCleanup = cleanup;\n } catch (e) {}\n }\n\n function recordActionFailure(reason) {\n if (!forAction) return;\n try { window.__spanaLastActionDiag = reason; } catch (e) {}\n }\n\n function findCandidates() {\n if (waitForAppReady && !isAppReady()) { recordActionFailure(\"waiting for app ready (__SPANA_APP_READY__)\"); return null; }\n if (forAction && !force && hasActiveViewTransition()) { recordActionFailure(\"active CSS view transition in progress\"); return null; }\n var rawHits = findAcrossRoots(sel, \"strict\");\n if (rawHits.length === 0) { recordActionFailure(null); return null; }\n var ready = [];\n var lastFail = null;\n for (var i = 0; i < rawHits.length; i++) {\n var h = rawHits[i];\n var m = toMatch(h);\n if (!m.visible) { lastFail = getVisibilityFailureReason(h.el, h.el && h.el.getBoundingClientRect ? h.el.getBoundingClientRect() : null) || \"not visible\"; continue; }\n if (forAction && !force && !m.enabled) { lastFail = \"element is disabled\"; continue; }\n ready.push({ hit: h, match: m });\n }\n if (ready.length === 0) recordActionFailure(lastFail);\n return ready.length > 0 ? ready : null;\n }\n\n function checkActionableNow() {\n var ready = findCandidates();\n if (!ready) return null;\n if (!forAction) return ready.map(function(r) { return r.match; });\n var target = ready[ready.length - 1];\n var alreadyInViewport = isFullyInViewport(target.hit);\n var didScroll = alreadyInViewport ? false : ensureInViewport(target.hit);\n if (!force && checkHitTest && !isHitTestClear(target.hit)) {\n if (!alreadyInViewport || canScrollToUnobscure(target.hit)) {\n if (scrollToUnobscure(target.hit)) {\n didScroll = true;\n }\n if (!target.hit.el.isConnected) { recordActionFailure(\"element detached from DOM after scrolling\"); return null; }\n }\n if (!isHitTestClear(target.hit)) {\n var blocker = getHitTestBlocker(target.hit);\n recordActionFailure(blocker ? (\"hit-test blocked by \" + blocker) : \"hit-test failed (element not receiving pointer events at click point)\");\n return null;\n }\n }\n var updated = toMatch(target.hit);\n if (!updated.visible) { recordActionFailure(\"element became hidden after scroll\"); return null; }\n if (!force && !updated.enabled) { recordActionFailure(\"element became disabled\"); return null; }\n recordActionFailure(null);\n return { hits: ready, target: target, match: updated, didScroll: didScroll };\n }\n\n function neededStableFrames(candidate) {\n if (force || !forAction || typeof requestAnimationFrame !== \"function\") return 0;\n if (explicitStableFrames >= 0) return explicitStableFrames;\n if (hasActiveAnimation(candidate.target.hit.el)) return 2;\n if (candidate.didScroll) return 1;\n return 0;\n }\n\n var imm = checkActionableNow();\n if (imm) {\n if (!forAction) return imm;\n if (neededStableFrames(imm) <= 0) {\n armTapGuardOnEl(imm.target.hit.el);\n return [imm.match];\n }\n }\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var idleTimer = null;\n var rafId = null;\n var checkingStability = false;\n\n function finish(result) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (idleTimer) clearTimeout(idleTimer);\n if (rafId !== null && typeof cancelAnimationFrame === \"function\") {\n try { cancelAnimationFrame(rafId); } catch (e) {}\n }\n resolve(result);\n }\n\n function armIdleTimer() {\n if (!failFastWhenIdle) return;\n if (idleTimer) clearTimeout(idleTimer);\n idleTimer = setTimeout(function() {\n var rootEl = document.body || document.documentElement;\n if (\n document.readyState === \"complete\" &&\n (!waitForAppReady || isAppReady()) &&\n !hasActiveAnimation(rootEl) &&\n !hasInflightNetwork(idleQuietMs)\n ) {\n var hit = checkActionableNow();\n if (hit && forAction) armTapGuardOnEl(hit.target.hit.el);\n finish(hit ? (forAction ? [hit.match] : hit) : []);\n } else {\n armIdleTimer();\n }\n }, idleQuietMs);\n }\n\n function verifyStability(candidate) {\n if (done || checkingStability) return;\n var framesToWait = neededStableFrames(candidate);\n if (!forAction || framesToWait <= 0 || typeof requestAnimationFrame !== \"function\") {\n if (forAction) armTapGuardOnEl(candidate.target.hit.el);\n finish(forAction ? [candidate.match] : candidate);\n return;\n }\n checkingStability = true;\n var el = candidate.target.hit.el;\n var lastRect = candidate.match.rect;\n var remainingFrames = framesToWait;\n\n function step() {\n if (done) return;\n if (!el.isConnected) { checkingStability = false; scheduleAttempt(); return; }\n if (checkHitTest && !isHitTestClear(candidate.target.hit)) { checkingStability = false; scheduleAttempt(); return; }\n var cur = toMatch(candidate.target.hit);\n if (!cur.visible || !cur.enabled) { checkingStability = false; scheduleAttempt(); return; }\n var dx = Math.abs(cur.rect.x - lastRect.x);\n var dy = Math.abs(cur.rect.y - lastRect.y);\n var dw = Math.abs(cur.rect.width - lastRect.width);\n var dh = Math.abs(cur.rect.height - lastRect.height);\n if (dx <= 1 && dy <= 1 && dw <= 1 && dh <= 1) {\n remainingFrames -= 1;\n if (remainingFrames <= 0) { armTapGuardOnEl(el); finish([cur]); return; }\n } else {\n recordActionFailure(\"element bounding box unstable (still moving)\");\n remainingFrames = framesToWait;\n lastRect = cur.rect;\n }\n rafId = requestAnimationFrame(step);\n }\n rafId = requestAnimationFrame(step);\n }\n\n function attempt() {\n if (done || checkingStability) return;\n var hit = checkActionableNow();\n if (hit) {\n if (forAction) verifyStability(hit);\n else finish(hit);\n return;\n }\n }\n\n var scheduled = false;\n function scheduleAttempt() {\n if (done || checkingStability) return;\n armIdleTimer();\n if (scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() { scheduled = false; attempt(); });\n }\n\n timeoutTimer = setTimeout(function() {\n var finalHit = checkActionableNow();\n if (finalHit && forAction) armTapGuardOnEl(finalHit.target.hit.el);\n finish(finalHit ? (forAction ? [finalHit.match] : finalHit) : []);\n }, timeoutMs);\n fallbackInterval = setInterval(attempt, forAction ? 40 : 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(scheduleAttempt);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n armIdleTimer();\n attempt();\n });\n }\n\n function waitForHidden(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n function isHiddenNow() {\n var hits = findAcrossRoots(sel, false);\n for (var i = 0; i < hits.length; i++) {\n if (toMatch(hits[i]).visible) return false;\n }\n return true;\n }\n if (isHiddenNow()) return true;\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n function finish(val) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(val);\n }\n function onChange() { if (isHiddenNow()) finish(true); }\n timeoutTimer = setTimeout(function() { finish(isHiddenNow()); }, timeoutMs);\n fallbackInterval = setInterval(onChange, 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function waitForMatch(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var kind = opts.kind;\n var expected = opts.expected !== undefined ? opts.expected : null;\n var expectedCount = opts.expectedCount !== undefined ? opts.expectedCount : null;\n var attributeName = opts.attributeName !== undefined ? opts.attributeName : null;\n var cssProperty = opts.cssProperty !== undefined ? opts.cssProperty : null;\n var patternSource = opts.patternSource !== undefined ? opts.patternSource : null;\n var patternFlags = opts.patternFlags || \"\";\n var negate = Boolean(opts.negate);\n var visibleOnly = Boolean(opts.visibleOnly);\n var ignoreCase = Boolean(opts.ignoreCase);\n var propertyName = opts.propertyName !== undefined ? opts.propertyName : null;\n var expectedValue = opts.expectedValue !== undefined ? opts.expectedValue : null;\n var lastActual = undefined;\n var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;\n var allowHidden = kind === \"text\" || kind === \"containsText\" || kind === \"matchesText\" || kind === \"value\" || kind === \"attribute\" || kind === \"attached\" || kind === \"jsProperty\";\n\n function evaluateMatch() {\n if (kind === \"url\") {\n var href = typeof window !== \"undefined\" && window.location ? String(window.location.href || \"\") : \"\";\n lastActual = href;\n var urlOk = regex\n ? regex.test(href)\n : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));\n if (negate ? !urlOk : urlOk) return { matched: true, actual: href };\n return null;\n }\n if (kind === \"title\") {\n var docTitle = String(typeof document !== \"undefined\" ? (document.title || \"\") : \"\");\n lastActual = docTitle;\n var titleOk = regex ? regex.test(docTitle) : (expected !== null && docTitle === String(expected));\n if (negate ? !titleOk : titleOk) return { matched: true, actual: docTitle };\n return null;\n }\n\n var pvMode = (kind === \"attached\" || (kind === \"count\" && !visibleOnly)) ? false : (visibleOnly ? \"strict\" : \"prefer\");\n var hits = findAcrossRoots(sel, pvMode);\n\n if (kind === \"count\") {\n var matchedCount = 0;\n if (visibleOnly) {\n for (var ci = 0; ci < hits.length; ci++) {\n if (toMatch(hits[ci]).visible) matchedCount++;\n }\n } else {\n matchedCount = hits.length;\n }\n lastActual = String(matchedCount);\n var countOk = expectedCount !== null && matchedCount === expectedCount;\n if (negate ? !countOk : countOk) {\n return { matched: true, actual: String(matchedCount) };\n }\n return null;\n }\n if (kind === \"attached\") {\n var isAttached = hits.length > 0;\n lastActual = isAttached ? \"attached\" : \"detached\";\n if (negate ? !isAttached : isAttached) return { matched: true, actual: lastActual };\n return null;\n }\n\n var anyVisible2 = false;\n var hiddenFallback2 = [];\n var checkMatch2 = function(h, m) {\n var matched = false;\n var actualVal = undefined;\n if (kind === \"text\") {\n var normTxt = normWs(m.textContent !== undefined ? m.textContent : (m.text || \"\"));\n actualVal = normTxt;\n matched = normTxt === (expected !== null ? normWs(expected) : expected);\n } else if (kind === \"containsText\") {\n var actual = normWs(m.textContent !== undefined ? m.textContent : (m.text || \"\"));\n actualVal = actual;\n var needle = expected !== null ? normWs(expected) : \"\";\n matched = expected !== null && (ignoreCase\n ? actual.toLowerCase().indexOf(needle.toLowerCase()) !== -1\n : actual.indexOf(needle) !== -1);\n } else if (kind === \"matchesText\") {\n var rawRe2 = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n var actualRe = normWs(rawRe2);\n actualVal = actualRe;\n matched = Boolean(regex && (regex.test(rawRe2) || regex.test(actualRe)));\n } else if (kind === \"value\") {\n var val = m.value !== undefined ? m.value : \"\";\n actualVal = val;\n matched = regex ? regex.test(val) : (val === expected);\n } else if (kind === \"attribute\" && attributeName !== null) {\n var attrVal = m.attributes ? m.attributes[attributeName] : undefined;\n actualVal = attrVal;\n matched = regex\n ? (attrVal !== undefined && regex.test(attrVal))\n : (expected === null ? attrVal !== undefined : attrVal === expected);\n } else if (kind === \"accessibilityLabel\") {\n var lbl = m.accessibilityLabel;\n actualVal = lbl;\n matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;\n } else if (kind === \"accessibleName\") {\n var accName = normWs(m.accessibleName || m.accessibilityLabel || m.text || \"\");\n actualVal = accName;\n matched = regex ? (regex.test(m.accessibleName || m.accessibilityLabel || m.text || \"\") || regex.test(accName)) : (expected === null ? accName.length > 0 : accName === normWs(expected));\n } else if (kind === \"accessibleDescription\") {\n var accDesc = normWs(m.accessibleDescription || \"\");\n actualVal = accDesc;\n matched = regex ? (regex.test(m.accessibleDescription || \"\") || regex.test(accDesc)) : (expected === null ? accDesc.length > 0 : accDesc === normWs(expected));\n } else if (kind === \"focused\") {\n actualVal = m.focused ? \"focused\" : \"not focused\";\n matched = Boolean(m.focused);\n } else if (kind === \"checked\") {\n actualVal = m.checked ? \"checked\" : \"unchecked\";\n matched = Boolean(m.checked);\n } else if (kind === \"enabled\") {\n var isEn2 = m.enabled !== false;\n actualVal = isEn2 ? \"enabled\" : \"disabled\";\n matched = isEn2;\n } else if (kind === \"role\") {\n var elRole2 = m.role || getImplicitRole(h.el) || \"generic\";\n actualVal = elRole2;\n matched = expected !== null && elRole2.toLowerCase() === String(expected).toLowerCase();\n } else if (kind === \"editable\") {\n actualVal = m.editable ? \"editable\" : \"not editable\";\n matched = Boolean(m.editable);\n } else if (kind === \"empty\") {\n actualVal = m.empty ? \"empty\" : (m.value || m.textContent || \"non-empty\");\n matched = Boolean(m.empty);\n } else if (kind === \"inViewport\") {\n var vpW = window.innerWidth || document.documentElement.clientWidth || 0;\n var vpH = window.innerHeight || document.documentElement.clientHeight || 0;\n var r = m.rect;\n var inVp = r.width > 0 && r.height > 0 && r.x + r.width > 0 && r.y + r.height > 0 && r.x < vpW && r.y < vpH;\n actualVal = inVp ? \"in viewport\" : \"outside viewport\";\n matched = inVp;\n } else if (kind === \"jsProperty\" && propertyName !== null) {\n var propNode = h.el;\n var rawProp = propNode ? propNode[propertyName] : undefined;\n actualVal = typeof rawProp === \"string\" ? rawProp : JSON.stringify(rawProp);\n matched = JSON.stringify(rawProp) === JSON.stringify(expectedValue);\n } else if (kind === \"class\") {\n var cls = m.className || \"\";\n actualVal = cls;\n if (regex) {\n matched = regex.test(cls);\n } else if (expected !== null) {\n var tokens = cls.trim().split(/\\s+/).filter(Boolean);\n var expectedTokens = String(expected).trim().split(/\\s+/).filter(Boolean);\n matched = expectedTokens.length > 0 && expectedTokens.every(function(tok) { return tokens.indexOf(tok) !== -1; });\n }\n } else if (kind === \"css\" && cssProperty !== null) {\n var elNode = h.el;\n var winObj = (elNode.ownerDocument && elNode.ownerDocument.defaultView) || window;\n var cssVal = winObj && winObj.getComputedStyle ? winObj.getComputedStyle(elNode).getPropertyValue(cssProperty).trim() : \"\";\n actualVal = cssVal;\n matched = regex ? regex.test(cssVal) : (expected !== null && cssVal === String(expected).trim());\n }\n lastActual = actualVal;\n if (negate ? !matched : matched) return { matched: true, actual: actualVal };\n return null;\n };\n for (var i = hits.length - 1; i >= 0; i--) {\n var m = toMatch(hits[i]);\n if (!allowHidden && !m.visible) {\n if (kind === \"enabled\" || kind === \"checked\") hiddenFallback2.push({ h: hits[i], m: m });\n continue;\n }\n if (m.visible) anyVisible2 = true;\n var resHit2 = checkMatch2(hits[i], m);\n if (resHit2) return resHit2;\n }\n if (!anyVisible2 && hiddenFallback2.length > 0) {\n for (var hi2 = 0; hi2 < hiddenFallback2.length; hi2++) {\n var hRes2 = checkMatch2(hiddenFallback2[hi2].h, hiddenFallback2[hi2].m);\n if (hRes2) return hRes2;\n }\n }\n return null;\n }\n\n var immediate = evaluateMatch();\n if (immediate) return immediate;\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n function finish(res) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"input\", onChange, true);\n document.removeEventListener(\"change\", onChange, true);\n document.removeEventListener(\"focusin\", onChange, true);\n document.removeEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"popstate\", onChange);\n window.removeEventListener(\"hashchange\", onChange);\n }\n resolve(res);\n }\n function onChange() {\n if (done || scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done) return;\n var res = evaluateMatch();\n if (res) finish(res);\n });\n }\n timeoutTimer = setTimeout(function() {\n var finalRes = evaluateMatch();\n finish(finalRes || { matched: false, actual: lastActual });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, kind === \"url\" ? 50 : 120);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"input\", onChange, true);\n document.addEventListener(\"change\", onChange, true);\n document.addEventListener(\"focusin\", onChange, true);\n document.addEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"popstate\", onChange);\n window.addEventListener(\"hashchange\", onChange);\n }\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function fill(sel, val, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : true;\n var verifyDelayMs = opts.verifyDelayMs !== undefined ? Math.max(0, Math.round(opts.verifyDelayMs)) : 12;\n function writeValue(el) {\n if (el.isContentEditable) return false;\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n var tag = el.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\") {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var proto = tag === \"TEXTAREA\"\n ? (win.HTMLTextAreaElement && win.HTMLTextAreaElement.prototype)\n : (win.HTMLInputElement && win.HTMLInputElement.prototype);\n var desc = proto ? Object.getOwnPropertyDescriptor(proto, \"value\") : null;\n if (desc && typeof desc.set === \"function\") {\n try { desc.set.call(el, val); } catch (e) { el.value = val; }\n }\n else el.value = val;\n if (el._valueTracker && typeof el._valueTracker.setValue === \"function\") {\n try { el._valueTracker.setValue(val === \"\" ? \" \" : \"\"); } catch (e) {}\n }\n } else if (tag === \"SELECT\") {\n el.value = val;\n } else {\n el.value = val;\n }\n try { el.dispatchEvent(new InputEvent(\"input\", { bubbles: true, cancelable: true, data: val, inputType: \"insertText\" })); }\n catch (e) { el.dispatchEvent(new Event(\"input\", { bubbles: true, cancelable: true })); }\n el.dispatchEvent(new Event(\"change\", { bubbles: true, cancelable: true }));\n return true;\n }\n function findEditableNow() {\n if (!isAppReady()) return null;\n var hits = findAcrossRoots(sel, \"strict\");\n for (var i = hits.length - 1; i >= 0; i--) {\n var h = hits[i];\n var m = toMatch(h);\n if (!m.visible || !m.enabled) continue;\n var alreadyInVp = isFullyInViewport(h);\n if (!alreadyInVp) ensureInViewport(h);\n if (checkHitTest && !isHitTestClear(h)) {\n if (!alreadyInVp || canScrollToUnobscure(h)) scrollToUnobscure(h);\n if (!h.el.isConnected || !isHitTestClear(h)) continue;\n }\n return h.el;\n }\n return null;\n }\n function verifyAndRetryFill(attemptsLeft) {\n var el = findEditableNow();\n if (!el || el.isContentEditable) return Promise.resolve(false);\n if (!writeValue(el)) return Promise.resolve(false);\n if (verifyDelayMs <= 0) {\n var syncLatest = findEditableNow() || el;\n if (syncLatest && syncLatest.isConnected && String(syncLatest.value == null ? \"\" : syncLatest.value) === val) {\n return Promise.resolve(true);\n }\n return attemptsLeft > 1 ? verifyAndRetryFill(attemptsLeft - 1) : Promise.resolve(false);\n }\n return new Promise(function(resolve) {\n setTimeout(function() {\n var latest = findEditableNow() || el;\n if (latest && latest.isConnected && String(latest.value == null ? \"\" : latest.value) === val) {\n resolve(true);\n return;\n }\n if (attemptsLeft > 1) {\n verifyAndRetryFill(attemptsLeft - 1).then(resolve);\n } else {\n resolve(false);\n }\n }, verifyDelayMs);\n });\n }\n var immEl = findEditableNow();\n if (immEl) {\n if (immEl.isContentEditable) return false;\n return verifyAndRetryFill(3);\n }\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n var filling = false;\n function finish(ok) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(ok);\n }\n function onChange() {\n if (done || scheduled || filling) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done || filling) return;\n var target = findEditableNow();\n if (!target) return;\n if (target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(3).then(function(ok) { finish(ok); });\n });\n }\n timeoutTimer = setTimeout(function() {\n if (filling) return;\n var target = findEditableNow();\n if (!target || target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(2).then(function(ok) { finish(ok); });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, 40);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function checkTapGuard() {\n var m = Boolean(window.__spanaTapMissed);\n if (window.__spanaTapGuardCleanup) window.__spanaTapGuardCleanup();\n delete window.__spanaTapMissed;\n return m;\n }\n\n window.__spanaRt = {\n query: query,\n scrollIntoView: scrollIntoView,\n tap: tap,\n waitForSelector: waitForSelector,\n waitForHidden: waitForHidden,\n waitForMatch: waitForMatch,\n fill: fill,\n checkTapGuard: checkTapGuard\n };\n return true;\n})();";
264
264
  export type InjectedRuntimeMethod = "query" | "scrollIntoView" | "tap" | "waitForSelector" | "waitForHidden" | "waitForMatch" | "fill";
265
265
  export type SelectOptionInput = string | string[] | {
266
266
  value?: string;
@@ -275,7 +275,9 @@ export type SelectOptionInput = string | string[] | {
275
275
  export declare function buildDomSelectOptionScript(selector: Selector, option: SelectOptionInput): string;
276
276
  /** Build an in-page script that focuses the matched element cleanly. */
277
277
  export declare function buildDomFocusScript(selector: Selector): string;
278
- /** Build an in-page diagnostic script reporting why an existing element failed actionability (covered/disabled/hidden). */
278
+ /** Build an in-page script that arms the moving-target tap guard directly on the matched selector element. */
279
+ export declare function buildDomArmTapGuardBySelectorScript(selector: Selector): string;
280
+ /** Build an in-page diagnostic script reporting why an existing element failed actionability (covered/disabled/hidden/pointer-events/unstable). */
279
281
  export declare function buildDomActionabilityDiagScript(selector: Selector): string;
280
282
  /** Build an in-page script returning the matching DOM Element (used for CDP `DOM.setFileInputFiles`). */
281
283
  export declare function buildDomFindElementScript(selector: Selector): string;