@rtrvr-ai/rover 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -15
- package/dist/embed.js +16 -16
- package/dist/index.d.ts +25 -2
- package/dist/rover.js +379 -33
- package/dist/worker/rover-worker.js +41 -25
- package/package.json +1 -1
package/dist/embed.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var __ROVER_SCRIPT_EL__=document.currentScript||null;var __ROVER_SCRIPT_URL__=(__ROVER_SCRIPT_EL__&&__ROVER_SCRIPT_EL__.src)||'';
|
|
2
|
-
"use strict";var __roverSDK=(()=>{var Wr=Object.defineProperty;var Cc=Object.getOwnPropertyDescriptor;var Mc=Object.getOwnPropertyNames;var Lc=Object.prototype.hasOwnProperty;var Nc=(e,t,n)=>t in e?Wr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Dc=(e,t)=>{for(var n in t)Wr(e,n,{get:t[n],enumerable:!0})},Oc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mc(t))!Lc.call(e,o)&&o!==n&&Wr(e,o,{get:()=>t[o],enumerable:!(r=Cc(t,o))||r.enumerable});return e};var Uc=e=>Oc(Wr({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Nc(e,typeof t!="symbol"?t+"":t,n);var bf={};Dc(bf,{boot:()=>Or,close:()=>Jo,endTask:()=>Zo,getState:()=>Zs,hide:()=>Qs,init:()=>zs,installGlobal:()=>Ac,newTask:()=>Pr,open:()=>Fr,registerTool:()=>ei,send:()=>Js,show:()=>Ks,shutdown:()=>js,update:()=>Qo});var L;(function(e){e.click_element="click_element",e.type_into_element="type_into_element",e.type_and_enter="type_and_enter",e.select_dropdown_value="select_dropdown_value",e.clear_element="clear_element",e.focus_element="focus_element",e.check_field_validity="check_field_validity",e.select_text="select_text",e.hover_element="hover_element",e.right_click_element="right_click_element",e.double_click_element="double_click_element",e.press_key="press_key",e.mouse_wheel="mouse_wheel",e.dispatch_pointer_path="dispatch_pointer_path",e.drag_element="drag_element",e.drag_and_drop="drag_and_drop",e.adjust_slider="adjust_slider",e.scroll_page="scroll_page",e.scroll_to_element="scroll_to_element",e.swipe_element="swipe_element",e.long_press_element="long_press_element",e.pinch_zoom="pinch_zoom",e.go_back="go_back",e.go_forward="go_forward",e.goto_url="goto_url",e.refresh_page="refresh_page",e.open_new_tab="open_new_tab",e.switch_tab="switch_tab",e.close_tab="close_tab",e.describe_images="describe_images",e.google_search="google_search",e.network_run_recipe="network_run_recipe",e.copy_text="copy_text",e.paste_text="paste_text",e.wait_action="wait_action",e.wait_for_element="wait_for_element",e.answer_task="answer_task",e.upload_file="upload_file",e.solve_captcha="solve_captcha"})(L||(L={}));var wf=new Set(Object.values(L));var Hc=40;function ni(e){let t=Array.isArray(e?.element_ids)?e.element_ids:e?.element_id!=null?[e.element_id]:[];return Array.from(new Set(t.map(r=>Math.trunc(Number(r))))).filter(r=>Number.isFinite(r)&&r>0).slice(0,Hc)}var yt;(function(e){e[e.Unknown=0]="Unknown",e[e.React=1]="React",e[e.Vue=2]="Vue",e[e.Angular=3]="Angular",e[e.Svelte=4]="Svelte",e[e.JQuery=5]="JQuery"})(yt||(yt={}));var ri={[yt.Unknown]:"unknown",[yt.React]:"react",[yt.Vue]:"vue",[yt.Angular]:"angular",[yt.Svelte]:"svelte",[yt.JQuery]:"jquery"},es={react:yt.React,vue:yt.Vue,angular:yt.Angular,svelte:yt.Svelte,jquery:yt.JQuery},$e;(function(e){e[e.Other=0]="Other",e[e.Inline=1]="Inline",e[e.Delegated=2]="Delegated",e[e.React=3]="React",e[e.Vue=4]="Vue",e[e.Angular=5]="Angular",e[e.Svelte=6]="Svelte",e[e.JQuery=7]="JQuery",e[e.Native=8]="Native"})($e||($e={}));var vf={[$e.Other]:"other",[$e.Inline]:"inline",[$e.Delegated]:"delegated",[$e.React]:"react",[$e.Vue]:"vue",[$e.Angular]:"angular",[$e.Svelte]:"svelte",[$e.JQuery]:"jquery",[$e.Native]:"native"},Tf={inline:$e.Inline,delegated:$e.Delegated,react:$e.React,vue:$e.Vue,angular:$e.Angular,svelte:$e.Svelte,jquery:$e.JQuery,other:$e.Other,native:$e.Native},de;(function(e){e[e.click_element=1]="click_element",e[e.type_into_element=2]="type_into_element",e[e.type_and_enter=3]="type_and_enter",e[e.select_dropdown_value=4]="select_dropdown_value",e[e.clear_element=5]="clear_element",e[e.focus_element=6]="focus_element",e[e.hover_element=7]="hover_element",e[e.right_click_element=8]="right_click_element",e[e.double_click_element=9]="double_click_element",e[e.long_press_element=10]="long_press_element",e[e.drag_element=11]="drag_element",e[e.drag_and_drop=12]="drag_and_drop",e[e.swipe_element=13]="swipe_element",e[e.adjust_slider=14]="adjust_slider",e[e.describe_images=15]="describe_images",e[e.scroll_to_element=16]="scroll_to_element",e[e.paste_text=17]="paste_text",e[e.check_field_validity=18]="check_field_validity",e[e.select_text=19]="select_text",e[e.mouse_wheel=20]="mouse_wheel",e[e.copy_text=21]="copy_text",e[e.upload_file=22]="upload_file",e[e.go_back=23]="go_back",e[e.go_forward=24]="go_forward",e[e.refresh_page=25]="refresh_page",e[e.press_key=26]="press_key",e[e.scroll_page=27]="scroll_page",e[e.wait_action=28]="wait_action",e[e.wait_for_element=29]="wait_for_element",e[e.pinch_zoom=30]="pinch_zoom",e[e.goto_url=31]="goto_url",e[e.google_search=32]="google_search",e[e.open_new_tab=33]="open_new_tab",e[e.switch_tab=34]="switch_tab",e[e.close_tab=35]="close_tab",e[e.solve_captcha=36]="solve_captcha",e[e.answer_task=37]="answer_task",e[e.dispatch_pointer_path=38]="dispatch_pointer_path",e[e.network_run_recipe=40]="network_run_recipe"})(de||(de={}));var Vr={[L.click_element]:de.click_element,[L.type_into_element]:de.type_into_element,[L.type_and_enter]:de.type_and_enter,[L.select_dropdown_value]:de.select_dropdown_value,[L.clear_element]:de.clear_element,[L.focus_element]:de.focus_element,[L.hover_element]:de.hover_element,[L.right_click_element]:de.right_click_element,[L.double_click_element]:de.double_click_element,[L.long_press_element]:de.long_press_element,[L.drag_element]:de.drag_element,[L.drag_and_drop]:de.drag_and_drop,[L.swipe_element]:de.swipe_element,[L.adjust_slider]:de.adjust_slider,[L.describe_images]:de.describe_images,[L.scroll_to_element]:de.scroll_to_element,[L.paste_text]:de.paste_text,[L.check_field_validity]:de.check_field_validity,[L.select_text]:de.select_text,[L.mouse_wheel]:de.mouse_wheel,[L.copy_text]:de.copy_text,[L.upload_file]:de.upload_file,[L.go_back]:de.go_back,[L.go_forward]:de.go_forward,[L.refresh_page]:de.refresh_page,[L.press_key]:de.press_key,[L.scroll_page]:de.scroll_page,[L.wait_action]:de.wait_action,[L.wait_for_element]:de.wait_for_element,[L.pinch_zoom]:de.pinch_zoom,[L.goto_url]:de.goto_url,[L.google_search]:de.google_search,[L.open_new_tab]:de.open_new_tab,[L.switch_tab]:de.switch_tab,[L.close_tab]:de.close_tab,[L.solve_captcha]:de.solve_captcha,[L.answer_task]:de.answer_task,[L.dispatch_pointer_path]:de.dispatch_pointer_path,[L.network_run_recipe]:de.network_run_recipe},oi=Object.fromEntries(Object.entries(Vr).map(([e,t])=>[t,e]));function $r(e){let t=[];return e&&(e&1&&t.push("native"),e&2&&t.push("inline"),e&4&&t.push("react"),e&8&&t.push("vue"),e&16&&t.push("angular"),e&32&&t.push("svelte"),e&64&&t.push("jquery"),e&128&&t.push("delegated"),e&256&&t.push("other")),t}var ii={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},dt={...ii},qr=globalThis;function ai(e){dt={...ii,...e||{}}}function kn(){return dt.signalProvider??null}function Xe(){try{return typeof qr.document<"u"?qr.document:null}catch{return null}}function zt(){try{return typeof qr.window<"u"?qr.window:null}catch{return null}}function G(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??Xe()??{}}function oe(e,t){return G(e,t?t.document:null)?.defaultView??t??zt()??{}}function X(e,t){return e?.defaultView??t??zt()??{}}function Yr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Xr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function ts(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function In(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function zr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function _t(e,t){try{return e[t]}catch{return}}function jt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function ci(e,t){let n=_t(t,"HTMLAnchorElement");return n?e instanceof n:jt(e,"A")}function Mt(e,t){let n=_t(t,"HTMLInputElement");return n?e instanceof n:jt(e,"INPUT")}function Ut(e,t){let n=_t(t,"HTMLTextAreaElement");return n?e instanceof n:jt(e,"TEXTAREA")}function li(e,t){let n=_t(t,"HTMLLabelElement");return n?e instanceof n:jt(e,"LABEL")}function ui(e,t){let n=_t(t,"HTMLSelectElement");return n?e instanceof n:jt(e,"SELECT")}function di(e,t){let n=_t(t,"HTMLSlotElement");return n?e instanceof n:jt(e,"SLOT")}function fi(e,t){let n=_t(t,"HTMLButtonElement");return n?e instanceof n:jt(e,"BUTTON")}function pi(e,t){let n=_t(t,"HTMLImageElement");return n?e instanceof n:jt(e,"IMG")}function hi(e,t){let n=_t(t,"HTMLVideoElement");return n?e instanceof n:jt(e,"VIDEO")}function mi(e,t){let n=_t(t,"HTMLCanvasElement");return n?e instanceof n:jt(e,"CANVAS")}function Ge(e,t){if(!e||e.nodeType!==1)return!1;let n=_t(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function vt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function Sn(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function dr(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Fc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=_t(t,"Document");return n?e instanceof n:!1}function Pc(e,t){if(!e)return!1;let n=_t(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function jr(e){try{return e.document}catch{return null}}function Kr(e,t){if(Fc(e,t))try{return e.documentElement}catch{return null}if(Pc(e,t)){let n=jr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Gr(e){if(!e)return null;if(typeof e=="string")return e;if(typeof e=="object"&&typeof e.baseVal=="string")return e.baseVal;try{return String(e)}catch{return null}}function si(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function gi(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=si(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=Gr(o.href)||Gr(o.src)||Gr(o.data)||Gr(o.action);return s?si(s,e,t):null}catch{return null}}var bi=["click","dblclick","doubleclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","mouseover","mouseout","contextmenu","auxclick","keydown","keyup","keypress","input","change","submit","reset","select","search","invalid","beforeinput","focus","blur","focusin","focusout","touchstart","touchend","touchmove","touchcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","dragstart","dragend","drag","dragenter","dragleave","dragover","drop","copy","cut","paste","scroll","wheel","play","pause","ended","volumechange","seeking","seeked","animationstart","animationend","transitionend","transitionstart","resize","toggle","fullscreenchange","load","error","abort","beforeunload","unload","hashchange","popstate","storage","message"],ye={};bi.forEach((e,t)=>{ye[e]=t});var tn={};bi.forEach((e,t)=>{tn[t]=e});function An(e){if(!e)return null;let t=e.trim();if(!t||!t.includes("~"))return null;let n=[];for(let r of t.split(",")){if(!r)continue;let[o,s]=r.split("~"),a=Number(o);if(!Number.isFinite(a))continue;let i=s&&parseInt(s,36)||0;n.push({id:a,mask:i})}return n.length?{entries:n}:null}function Bc(e){let t=An(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function fr(e){return Xn(e).map(n=>tn[n]).filter(n=>!!n)}function Xn(e){let t=kn();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(fn),r=Bc(n);return!r||r.length===0?[]:r}var ns=["media"],Ei=new Set(ns),rs=["alert","alertdialog","application","directory","feed","grid","log","marquee","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","note","radiogroup","scrollbar","search","switch","tab","tablist","tabpanel","timer","toolbar","tooltip","tree","treegrid","treeitem"];var wi=new Set(rs),nn=new Set(["button","checkbox","combobox","figure","img","link","listbox","option","radio","scrollbar","searchbox","separator","slider","spinbutton","switch","tab","tabpanel","textbox","tooltip","treeitem","grid","gridcell","table","cell","columnheader","rowheader","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","tree","treegrid","radiogroup","application","dialog","alertdialog","alert","status","progressbar","meter","search","code","media"]),pr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var yi=["none","presentation"],he;(function(e){e[e.ANCESTOR_ROLE_REQUIRED=6]="ANCESTOR_ROLE_REQUIRED",e[e.PROPERTY_VALUE_MATCH=5]="PROPERTY_VALUE_MATCH",e[e.HAS_TABLE_ROW_DATA=7]="HAS_TABLE_ROW_DATA",e[e.BOOLEAN_PROPERTY=0]="BOOLEAN_PROPERTY",e[e.ATTRIBUTE_GREATER_THAN=2]="ATTRIBUTE_GREATER_THAN",e[e.HAS_TABLE_COLUMN_DATA=8]="HAS_TABLE_COLUMN_DATA",e[e.FORBIDDEN_ANCESTORS=1]="FORBIDDEN_ANCESTORS",e[e.HAS_ACCESSIBLE_NAME=4]="HAS_ACCESSIBLE_NAME",e[e.ATTRIBUTE_LESS_THAN=3]="ATTRIBUTE_LESS_THAN"})(he||(he={}));var _i={a:["link"],area:["link"],article:["article"],aside:["complementary"],body:["document"],button:["button"],datalist:["listbox"],dd:["definition"],details:["group"],dfn:["term"],dialog:["dialog"],dt:["term"],fieldset:["group"],figure:["figure"],footer:["contentinfo"],form:["form"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"],header:["banner"],hr:["separator"],img:["img"],input:["button","checkbox","combobox","radio","searchbox","slider","spinbutton","textbox"],li:["listitem"],link:["link"],main:["main"],math:["math"],menu:["list"],nav:["navigation"],ol:["list"],optgroup:["group"],option:["option"],output:["status"],progress:["progressbar"],section:["region"],select:["combobox","listbox"],summary:["button"],table:["table"],tbody:["rowgroup"],td:["cell","gridcell"],textarea:["textbox"],tfoot:["rowgroup"],th:["cell","columnheader","gridcell","rowheader"],thead:["rowgroup"],tr:["row"],ul:["list"],code:["code"],pre:["code"]},hr={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["checkbox"]}]}]},navigation:{selector:"nav"},row:{selector:"tr"},complementary:{selector:"aside"},table:{selector:"table"},gridcell:{conditionalSelectors:[{selector:"td",conditions:[{type:he.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:he.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:he.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:he.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:he.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:he.FORBIDDEN_ANCESTORS,selector:'section,nav,main,aside,article,[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"]'}]}]},definition:{selector:"dd"},button:{selector:"summary,button",conditionalSelectors:[{selector:"input",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:he.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["radio"]}]}]},columnheader:{selector:'th[scope="colgroup"],th[scope="col"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:he.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:he.HAS_ACCESSIBLE_NAME}]}]},document:{selector:"body"},option:{selector:"select > option,select > optgroup > option,datalist > option"},separator:{selector:"hr"},link:{selector:"area[href],a[href],link[href]"},img:{selector:"img[alt],img:not([alt])"},main:{selector:"main"},searchbox:{conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:he.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:he.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:he.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:he.HAS_TABLE_ROW_DATA,hasData:!0}]}]},rowheader:{selector:'th[scope="rowgroup"],th[scope="row"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:he.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:he.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:he.ATTRIBUTE_GREATER_THAN,attribute:"size",value:1}]}]},group:{selector:"optgroup,fieldset,details"},term:{selector:"dt,dfn"},progressbar:{selector:"progress"},figure:{selector:"figure"},spinbutton:{conditionalSelectors:[{selector:"input",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:he.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:he.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:he.FORBIDDEN_ANCESTORS,selector:'[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"],section,nav,main,aside,article'}]}]},rowgroup:{selector:"thead,tfoot,tbody"},code:{selector:"code,pre"}},fn="rtrvr-ls",rn="rtrvr-ro",os="rtrvr-mw-ready",mr="rtrvr-mw-busy",ss="rtrvr-mwa-ready",vi=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowgroup","rowheader","switch","tab","tooltip","tree","treeitem","sectionhead","definition","term","deletion","insertion"]),Ti=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],xi=["h1","h2","h3","h4","h5","h6"],Ri="http://www.w3.org/1999/xhtml",ki="http://www.w3.org/2000/svg",it="rtrvr-label";var Zr=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Cn="CODE",Mn="PRE",Ii="aria-hidden",Si="target";var Qr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Qr||(Qr={}));var zn;(function(e){e[e["data-icon"]=13]="data-icon",e[e["data-name"]=14]="data-name",e[e["data-tooltip"]=15]="data-tooltip",e[e["data-label"]=16]="data-label"})(zn||(zn={}));var Jr;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Jr||(Jr={}));var is=new Set([ye.click,ye.dblclick,ye.doubleclick,ye.contextmenu,ye.auxclick,ye.pointerdown,ye.pointerup,ye.mousedown,ye.mouseup,ye.touchstart,ye.touchend,ye.keydown,ye.keyup,ye.input,ye.beforeinput,ye.change,ye.submit,ye.reset,ye.paste,ye.dragstart,ye.dragend,ye.drop]),Ai=new Set([...is,ye.scroll,ye.wheel,ye.mouseenter,ye.mouseover,ye.focus,ye.blur,ye.focusin,ye.focusout]),eo=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),as=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),cs=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var gr;(function(e){e[e.ELEMENT=1]="ELEMENT",e[e.ATTRIBUTE=2]="ATTRIBUTE",e[e.TEXT=3]="TEXT",e[e.CDATA_SECTION=4]="CDATA_SECTION",e[e.ENTITY_REFERENCE=5]="ENTITY_REFERENCE",e[e.ENTITY=6]="ENTITY",e[e.PROCESSING_INSTRUCTION=7]="PROCESSING_INSTRUCTION",e[e.COMMENT=8]="COMMENT",e[e.DOCUMENT=9]="DOCUMENT",e[e.DOCUMENT_TYPE=10]="DOCUMENT_TYPE",e[e.DOCUMENT_FRAGMENT=11]="DOCUMENT_FRAGMENT",e[e.NOTATION=12]="NOTATION"})(gr||(gr={}));var br;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(br||(br={}));var to;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT",e[e.ATOMIC=2]="ATOMIC",e[e.AUTOCOMPLETE=3]="AUTOCOMPLETE",e[e.COLCOUNT=4]="COLCOUNT",e[e.COLINDEX=5]="COLINDEX",e[e.COLSPAN=6]="COLSPAN",e[e.ERRORMESSAGE=7]="ERRORMESSAGE",e[e.HASPOPUP=8]="HASPOPUP",e[e.LEVEL=9]="LEVEL",e[e.LIVE=10]="LIVE",e[e.MULTILINE=11]="MULTILINE",e[e.MULTISELECTABLE=12]="MULTISELECTABLE",e[e.ORIENTATION=13]="ORIENTATION",e[e.PLACEHOLDER=14]="PLACEHOLDER",e[e.POSINSET=15]="POSINSET",e[e.READONLY=16]="READONLY",e[e.RELEVANT=17]="RELEVANT",e[e.REQUIRED=18]="REQUIRED",e[e.ROWCOUNT=19]="ROWCOUNT",e[e.ROWINDEX=20]="ROWINDEX",e[e.ROWSPAN=21]="ROWSPAN",e[e.SETSIZE=22]="SETSIZE",e[e.SORT=23]="SORT",e[e.VALUEMAX=24]="VALUEMAX",e[e.VALUEMIN=25]="VALUEMIN",e[e.KEYSHORTCUTS=26]="KEYSHORTCUTS",e[e.ROLEDESCRIPTION=27]="ROLEDESCRIPTION"})(to||(to={}));var no;(function(e){e[e.BUSY=0]="BUSY",e[e.CHECKED=1]="CHECKED",e[e.CURRENT=2]="CURRENT",e[e.EXPANDED=3]="EXPANDED",e[e.INVALID=4]="INVALID",e[e.PRESSED=5]="PRESSED",e[e.SELECTED=6]="SELECTED"})(no||(no={}));var bt;(function(e){e[e["rtrvr-label"]=0]="rtrvr-label",e[e.role=1]="role",e[e.value=2]="value",e[e.alt=3]="alt",e[e.list=4]="list",e[e.title=5]="title",e[e["aria-label"]=6]="aria-label",e[e["aria-labelledby"]=7]="aria-labelledby",e[e["aria-description"]=8]="aria-description",e[e["aria-describedby"]=9]="aria-describedby",e[e.disabled=10]="disabled",e[e.href=11]="href",e[e.placeholder=12]="placeholder",e[e.type=13]="type",e[e.tabindex=14]="tabindex",e[e.id=15]="id",e[e._ngcontent=16]="_ngcontent",e[e["ng-reflect-*"]=17]="ng-reflect-*",e[e["data-reactroot"]=18]="data-reactroot",e[e["data-v-*"]=19]="data-v-*",e[e.required=20]="required",e[e.contenteditable=21]="contenteditable",e[e.accept=22]="accept"})(bt||(bt={}));var tt;(function(e){e[e.display=0]="display",e[e.content=1]="content",e[e.beforeDisplay=2]="beforeDisplay",e[e.afterDisplay=3]="afterDisplay",e[e.beforeContent=4]="beforeContent",e[e.afterContent=5]="afterContent",e[e.width=6]="width",e[e.height=7]="height",e[e.minWidth=8]="minWidth",e[e.minHeight=9]="minHeight",e[e.position=10]="position",e[e.top=11]="top",e[e.left=12]="left",e[e.right=13]="right",e[e.bottom=14]="bottom",e[e.paddingTop=15]="paddingTop",e[e.paddingRight=16]="paddingRight",e[e.paddingBottom=17]="paddingBottom",e[e.paddingLeft=18]="paddingLeft",e[e.marginTop=19]="marginTop",e[e.marginRight=20]="marginRight",e[e.marginBottom=21]="marginBottom",e[e.marginLeft=22]="marginLeft",e[e.cursor=23]="cursor",e[e.opacity=24]="opacity",e[e.visibility=25]="visibility",e[e.overflowX=26]="overflowX",e[e.overflowY=27]="overflowY",e[e.backgroundColor=28]="backgroundColor",e[e.color=29]="color",e[e.borderWidth=30]="borderWidth",e[e.borderStyle=31]="borderStyle",e[e.boxShadow=32]="boxShadow",e[e.outline=33]="outline"})(tt||(tt={}));var on;(function(e){e[e.text=0]="text",e[e.elText=1]="elText",e[e.viewBox=2]="viewBox",e[e.paths=3]="paths",e[e.pathData=4]="pathData",e[e.circles=5]="circles",e[e.rects=6]="rects",e[e.lines=7]="lines",e[e.polygons=8]="polygons",e[e.polylines=9]="polylines",e[e.ellipses=10]="ellipses"})(on||(on={}));var Wc=[...rs,...Object.keys(hr),...ns],Ci=[...new Set(Wc)],jn={};Ci.forEach((e,t)=>{jn[e]=t});var Er={};Ci.forEach((e,t)=>{Er[t]=e});var ro=class{constructor(t=1){$(this,"currentId");this.currentId=t}generateId(){let t=this.currentId;return this.currentId++,t}initialize(t=1){this.currentId=t}getCurrentValue(){return this.currentId}};function wr(e){let t=kn();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(rn);if(!n)return null;let r=n.trim();if(!r)return null;if(r.startsWith("s:"))return r.slice(2);if(/^\d+$/.test(r)){let o=Number(r);if(Number.isFinite(o)){let s=Er[o];if(s)return s}}return r}function Kn(e){return Array.from(new Set(e))}function Mi(e,t){if(!e||e.length===0)return Kn(t);let n=new Set([...e,...t]);return Kn(Array.from(n))}function Tt(e,t){let r=kn()?.getEventHandlerIds?.(e)??Xn(e),o=r.length>0&&r.some(i=>is.has(i)),s=oo(e),a=t?pr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:a}}var Vc=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function $c(e){let n=oe(e).getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"||n.pointerEvents==="none")return!1;let r=e.getBoundingClientRect();return!(r.width===0||r.height===0)}function Gc(e){let t=oe(e);if(!Mt(e,t))return!1;let n=(e.type||"text").toLowerCase();return Vc.has(n)?!e.disabled&&!e.readOnly:!1}function qc(e){let t=oe(e);return Ut(e,t)&&!e.disabled&&!e.readOnly}function Yc(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function oo(e){return!e||!$c(e)?!1:!!(Gc(e)||qc(e)||Yc(e))}function yr(e){if(!e)return null;let t=e.match(/^\s*\[id=(\d+)\]/);if(t?.[1]){let o=parseInt(t[1],10);return Number.isFinite(o)?o:null}let n=/\[id=(\d+)\]/g,r;for(;r=n.exec(e);){let o=r.index??0,s=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(s)||s.includes("iframeRoot="))continue;let a=parseInt(r[1],10);if(Number.isFinite(a))return a}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let s=parseInt(o[1],10);return Number.isFinite(s)?s:null}}catch{}return null}function _r(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function Li({element:e,elementID:t,frameContextLabel:n}){let r=!dt.disableDomAnnotations,o=[`[id=${t}]`],s=oe(e);if(dr(e)){let u=_r(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${u}]`)}if(n){let u=_r(n);o.push(`[iframeRoot=${u}]`)}if(pi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(hi(e,s)||mi(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Mt(e,s)||Ut(e,s)){let u=Xc(e);o.push(...u)}e.getAttribute(Ii)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&ci(e,s)&&e.setAttribute(Si,"_self");let i=o.join(" ");return r&&e.setAttribute(it,i),i}function Xc(e){let t=[],n=oe(e),r=Mt(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=_r(e.name);o&&t.push(`[name=${o}]`)}if(r&&e.multiple&&t.push("[multiple]"),r&&(e.type==="checkbox"||e.type==="radio")&&t.push(`[checked=${e.checked}]`),r&&e.type==="file"&&e.files?.length&&t.push(`[files=${e.files.length}]`),r&&e.type==="number"&&(e.min!==""&&t.push(`[min=${e.min}]`),e.max!==""&&t.push(`[max=${e.max}]`),e.step!==""&&e.step!=="1"&&t.push(`[step=${e.step}]`)),r&&e.type==="range"&&(t.push(`[min=${e.min||"0"}]`),t.push(`[max=${e.max||"100"}]`),t.push(`[value=${e.value}]`)),e.readOnly&&t.push("[readonly]"),e.required&&t.push("[required]"),e.maxLength&&e.maxLength!==-1&&e.maxLength<524288&&t.push(`[maxlength=${e.maxLength}]`),r&&e.pattern&&t.push("[pattern]"),e.autocomplete&&e.autocomplete!=="off"&&t.push(`[autocomplete=${e.autocomplete}]`),e.placeholder){let o=_r(e.placeholder).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o&&t.push(`[placeholder="${o}"]`)}if(e.value){let o=e.value;r&&e.type==="password"&&(o="*".repeat(Math.min(o.length,10)));let s=_r(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${s}"]`)}return t}var vr=new ro,ls=new WeakMap;function Ni(){ls=new WeakMap}function so(e){let t=ls.get(e);if(t)return t;let n=vr.generateId();return ls.set(e,n),n}var io=new Map,us=new WeakMap;function Di(){io.clear(),us=new WeakMap}function ds(e,t){try{typeof WeakRef<"u"?io.set(e,new WeakRef(t)):io.set(e,t)}catch{}}function Tr(e){let t=io.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function pn(e){let t=null,n=so(e);if(dt.frameContextLabel)t=dt.frameContextLabel;else{let o=Xe();if(o&&e.ownerDocument!==o)try{let a=e.ownerDocument?.defaultView?.frameElement?.getAttribute(it)||"",i=a?yr(a):null;t=i?String(i):null}catch{t=""}}let r=Li({element:e,elementID:n,frameContextLabel:t});if(ds(n,e),r)try{us.set(e,r)}catch{}return r}function Oi(e){return us.get(e)??null}function fs(e,t){try{e.querySelectorAll?.(`[${it}]`)?.forEach(r=>r.removeAttribute(it))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&fs(o,t)}catch{}}catch{}if(t.includeIframes)try{let n=e.querySelectorAll?.("iframe");if(n)for(let r of Array.from(n))try{let o=In(r);o?.body&&fs(o.body,t)}catch{}}catch{}}function Ui(e,t={}){if(dt.disableDomAnnotations)return;let n=Sn(e)?oe(e):X(e)??window,r=Kr(e,n)??e;if(r){try{r.removeAttribute?.(it)}catch{}fs(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var hn={},ps=new WeakMap,ao=new WeakSet;function Hi(){hn={},ps=new WeakMap,ao=new WeakSet,Ni()}function at({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:a,elementContext:i}){let u=so(e);ds(u,e);let T=hn[u];if(a){if(!T){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},_=e.nodeName;_&&_.trim()&&(p.elementName=_);let A=e.getAttribute("role");A&&(p.preservedAttributes={1:A});let S=e.tagName;S&&(p.elementTag=S),hn[u]=p}}else{if(T&&!T.provisionalFromParent){if((o||Qn(e))&&(T.isFrameElement=!0,s&&s.length>0&&(T.frameContent=s)),i){let{eventHandlerIndices:p,isEditableRegion:_}=i;if(p&&p.length>0){let A=Kn(p);A.length>0&&(T.eventHandlers=Mi(T.eventHandlers,A))}_&&(T.isEditable=!0)}return u}if(ao.has(e))return u;ao.add(e);try{hn[u]=Fi({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i})}finally{ao.delete(e)}}return u}function xr(e){let t=ps.get(e);if(t!==void 0)return t;let r=(e.textContent||"").replace(/\s+/g," ").trim(),o=e.data?.replace(/\s+/g," ").trim();if(!r&&!o)return 0;let s=vr.generateId(),a={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(a.rawData=o),hn[s]=a,ps.set(e,s),s}function Bi(e,t){let n=Vi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Rr))}function Wi(e,t){let n=Vi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Rr))}var lo=class{constructor(t=[]){$(this,"cells");$(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);$(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});$(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));$(this,"getRows",()=>this.cells);$(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,s=-1;for(let a=0;a<this.rowCount;a++){let i=this.getRowAt(a),u=i.indexOf(t);u!==-1&&(o=Math.max(o,i.lastIndexOf(t)),s=Math.max(s,a),n=Math.min(n,u),r=Math.min(r,a))}return{minX:n,minY:r,maxX:o,maxY:s}});$(this,"merge",t=>{this.cells=this.getRows().concat(t.getRows())});this.cells=t}get rowCount(){return this.cells.length}get columnCount(){return Math.max(...this.cells.map(t=>t.length))}};function Vi(e){let n=oe(e).TableGrid||lo,r=new n;e.tHead!==null&&r.merge(co(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(co(s.rows))});let o=[];for(let s of Array.from(e.children))hs(s)&&Ln(s,"tr")&&o.push(s);return r.merge(co(o)),e.tFoot!==null&&r.merge(co(e.tFoot.rows)),r}function co(e){let t=new lo,n=[];for(let r=0;r<e.length;r++){let o=0;for(let s of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!Rr(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let a=o;a<o+s.colSpan;a++){Pi(s)===0&&(n[a]=s,t.setCellAt(a,r,s));for(let i=r;i<r+Pi(s);i++)Rr(t.getCellAt(a,i))||t.setCellAt(a,i,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let a=n[s];a!==void 0&&!Rr(t.getCellAt(s,r))&&t.setCellAt(s,r,a)}}return t}function Pi(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Rr(e){return e!==void 0&&Ln(e,"td")}function Ht(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=nl(e);if(r)return r}let n=$i(e);if(n===null){if(t==="dl")return"list";if(t==="form")return"form";if(t==="header")return"banner";if(t==="footer")return"contentinfo";if(t==="option")return"option";if(t==="textarea")return"textbox";if(t==="input"){let o=e;switch(o.type.toLowerCase()){case"checkbox":return"checkbox";case"radio":return"radio";case"button":case"submit":case"reset":case"image":return"button";case"number":return"spinbutton";case"range":return"slider";case"hidden":return null;default:return o.hasAttribute("list")?"combobox":"textbox"}}if(t==="select")return e.multiple?"listbox":"combobox";if(t==="svg"){if(e.getAttribute("aria-hidden")==="true")return null;let o=e.querySelector("title"),s=e.querySelector("desc"),a=e.hasAttribute("aria-label"),i=e.hasAttribute("role");return o||s||a||i||Xn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(Xn(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return zc(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&Gi(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function zc(e){return wr(e)??null}function $i(e){let t=e.getAttribute("role");if(t!==null)return yi.includes(t)||!Gi(t)?null:t;let n=e.tagName.toLowerCase();return(_i[n]??[]).find(o=>jc(e,o))||null}function jc(e,t){let n=hr[t],r=n?.selector;if(r&&uo(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(a=>uo(e,a.selector)&&a.conditions.every(u=>Qc(e,u))):!1}function Kc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(vt(r)){let o=oe(e),s=`#${zr(o,n)}`,a=Xr(r,s);if(a)return a}}catch{}return Yr(G(e),n)}function Qc(e,t){switch(t.type){case he.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case he.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case he.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>Kc(e,r)!=null);case he.FORBIDDEN_ANCESTORS:return sn(e,t.selector)===null;case he.BOOLEAN_PROPERTY:return e[t.property]===t.value;case he.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case he.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=sn(n,t.tag);return r!==null&&$i(r)===t.role}case he.HAS_TABLE_COLUMN_DATA:{let n=sn(e,"table");return n===null?!1:t.hasData===Wi(n,e)}case he.HAS_TABLE_ROW_DATA:{let n=sn(e,"table");return n===null?!1:t.hasData===Bi(n,e)}default:return Jc(t),!1}}function Jc(e){throw new Error(`unexpected value ${e}!`)}function Gi(e){return el(e)||tl(e)||Zc(e)}function Zc(e){return Ei.has(e)}function el(e){return wi.has(e)}function tl(e){return hr.hasOwnProperty(e)}function nl(e){if(e.tagName!==Cn&&e.tagName!==Mn)return null;if(fr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Mn||e.tagName===Cn&&e.closest("pre")?"code":null}var rl={[tt.display]:[tt.beforeDisplay,tt.afterDisplay],[tt.content]:[tt.beforeContent,tt.afterContent]},ms=new Map,ol={minWidth:"min-width",minHeight:"min-height",backgroundColor:"background-color",borderWidth:"border-width",borderStyle:"border-style",boxShadow:"box-shadow",paddingTop:"padding-top",paddingRight:"padding-right",paddingBottom:"padding-bottom",paddingLeft:"padding-left",marginTop:"margin-top",marginRight:"margin-right",marginBottom:"margin-bottom",marginLeft:"margin-left",overflowX:"overflow-x",overflowY:"overflow-y"};function sl(e,t){if(!ms.has(e)){let n=ol[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();ms.set(e,n)}return ms.get(e)}var il={display:e=>e!=="block"&&e!=="inline"&&e!=="",visibility:e=>e!=="visible",opacity:e=>parseFloat(e)<1,position:e=>e!=="static",cursor:e=>e!=="auto"&&e!=="default"&&e!=="text",width:e=>e!=="auto"&&e!=="",height:e=>e!=="auto"&&e!=="",minWidth:e=>e!=="0px"&&e!=="",minHeight:e=>e!=="0px"&&e!=="",paddingTop:e=>parseFloat(e)>0,paddingRight:e=>parseFloat(e)>0,paddingBottom:e=>parseFloat(e)>0,paddingLeft:e=>parseFloat(e)>0,marginTop:e=>Math.abs(parseFloat(e))>5,marginRight:e=>Math.abs(parseFloat(e))>5,marginBottom:e=>Math.abs(parseFloat(e))>5,marginLeft:e=>Math.abs(parseFloat(e))>5,overflowX:e=>e!=="visible",overflowY:e=>e!=="visible",backgroundColor:e=>e!=="transparent"&&e!=="rgba(0, 0, 0, 0)"&&e!=="initial",color:e=>e!=="initial"&&e!=="inherit"&&e!=="",borderWidth:e=>e!=="0px"&&parseFloat(e)>0,borderStyle:e=>e!=="none"&&e!=="initial",boxShadow:e=>e!=="none"&&e!=="",outline:e=>e!=="none"&&e!==""&&!e.includes("0px")};function Xi(e,t,n){let r=il[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function zi(e){let t={},n=oe(e);if(!Ge(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[tt.beforeDisplay,n.getComputedStyle(e,"::before")],[tt.afterDisplay,n.getComputedStyle(e,"::after")],[tt.beforeContent,n.getComputedStyle(e,"::before")],[tt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in tt)if(isNaN(Number(s))){let a=tt[s],i=sl(a,s),u=rl[a];u?((a===tt.display||a===tt.content)&&qi(r,i,a,s,t,e),Yi(o.get(u[0]),i,u[0],"beforeContent",t),Yi(o.get(u[1]),i,u[1],"afterContent",t)):qi(r,i,a,s,t,e)}return t}function qi(e,t,n,r,o,s){if(e){let a=e.getPropertyValue(t);a&&Xi(r,a,s)&&(o[n]=a)}}function Yi(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&Xi(r,s))&&(o[n]=s)}}function Nn(e,t){let n=oe(e);if(!Ge(e,n))return!0;if(t&&nn.has(t))return!1;if(e.hasAttribute("hidden")||sn(e,"[hidden]")!==null||sn(e,"[inert]")!==null)return!0;let r=n.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"||e.getClientRects().length===0)return!0;let o=e.getBoundingClientRect(),s=1e6;return Math.abs(o.left)>s||Math.abs(o.top)>s}function kr(e){return Ft(e)&&e.classList.contains("jasmine_html-reporter")}function al(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ji(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function Ki(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(vt(o)){let s=oe(e),a=`#${zr(s,n)}`,i=Xr(o,a);if(i)return i}}catch{}let r=G(e);return Yr(r,n)}function gs(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let s=0;s<o.length;s+=8192){let a=cl(o,s,s+8192),i=gs.apply(null,a);for(let u=0;u<i.length;u++)n.push(i[u])}else n.push(o)}return n}function cl(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function Qi(e,t){return ll(e,t).concat(ul(e))}function ll(e,t){return gs(Es(e).map(r=>oa(r)&&Ft(r)?Ji(r,t):r))}function Ji(e,t){if(!e||Nn(e,t))return[];if(!al(e))return[e];let n=Array.from(e.children);return gs(n.map(r=>Ji(r,t)))}function Zi(e){let t=ji(e.getAttribute("aria-owns"));if(!t.length)return[];let n=[],r=new Set;for(let o of t){if(r.has(o))continue;r.add(o);let s=Ki(e,o);s&&s!==e&&n.push(s)}return n}function ul(e){let t=Zi(e);for(let n of t)n["aria-owned-by"]=e;return t}function ea(e){let t=oe(e),n=G(e);if(e.getAttribute("role")!=="dialog"&&e.getAttribute("role")!=="alertdialog"||e.getAttribute("aria-modal")!=="true")return!1;let r=t.getComputedStyle(e);if(r?.position!=="fixed"&&r?.position!=="absolute"||parseInt(r?.zIndex,10)<=hl(e))return!1;let o=dl(e);return!o||!pl(o)||!gl(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:ml(e)}function dl(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(fl)||null}function fl(e){if(Nn(e))return!1;let n=oe(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function pl(e){let t=oe(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function hl(e){let t=G(e),n=oe(e),r=n?.getComputedStyle;if(!r)return 0;let o=ts(t,"*").filter(s=>s!==e&&!Nn(s)).map(s=>parseInt(r.call(n,s)?.zIndex,10)).filter(s=>Number.isFinite(s)&&!isNaN(s));return o.length?Math.max(...o):0}function ml(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function gl(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Nn(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function bl(){try{let t=Xe()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var ta=bl();function El(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function bs(e){let t=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(!t&&!e.tagName.includes("-"))try{let n=e;t=n.href||n.src||n.data||n.action||null}catch{return!1}if(!t)return!1;try{let n=G(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function na(e){return vi.has(e)}function wl(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return at({targetElement:t,originatedFromParent:!0})}function Fi({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:a}){let i={nodeCategory:e.nodeType},u=t||El(e),T=wl(e);if(T&&(i.parent=T),n){let _e=jn[n];typeof _e=="number"?i.semanticRole=_e:i.semanticRole=n}if(u&&(i.isDisabled=!0),a){let{eventHandlerIndices:_e,isEditableRegion:De}=a,He=Kn(_e);He.length>0&&(i.eventHandlers=He),De&&(i.isEditable=!0)}let p=_l(e);p&&Object.keys(p).length>0&&(i.ariaProperties=p);let _=vl(e);_&&Object.keys(_).length>0&&(i.ariaStates=_);let A=e.nodeName;A&&A.trim()&&(i.elementName=A);let S=zi(e);S&&Object.keys(S).length>0&&(i.computedStyles=S),Nn(e)&&(i.isInvisible=!0);let M=yl(e,n);M&&Object.keys(M).length>0&&(i.preservedAttributes=M),e.draggable&&(i.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(i.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(i.supportsVerticalSwipe=!0);let O=e.getAttribute("class");if(O?.trim()){O.includes("handle")&&(i.isDragHandle=!0),i.supportsHorizontalSwipe||(O.includes("horizontal")||O.includes("carousel"))&&(i.supportsHorizontalSwipe=!0),i.supportsVerticalSwipe||(O.includes("vertical")||O.includes("feed"))&&(i.supportsVerticalSwipe=!0),O.includes("dismissible")&&(i.supportsDismissSwipe=!0),(O.includes("long-press")||O.includes("hold")||O.includes("press-hold"))&&(i.supportsLongPress=!0);let _e=i.inputType||i.preservedAttributes?.[bt.type];_e==="submit"||_e==="reset"||_e==="clear"||(O.includes("submit")&&(i.preservedAttributes={...i.preservedAttributes||{},[bt.type]:"submit"}),O.includes("clear")&&(i.preservedAttributes={...i.preservedAttributes||{},[bt.type]:"clear"}),O.includes("reset")&&(i.preservedAttributes={...i.preservedAttributes||{},[bt.type]:"reset"}))}let W=Sl({element:e});W&&W.length>0&&(i.labelReferences=W);let q=e.tagName;if(q&&(i.elementTag=q),xl(e)&&(i.hasFocus=!0),!o){let _e=ws({element:e,semanticRole:n,parentDisabled:u,excludeLabels:r});_e&&_e.length>0&&(i.childElements=_e)}let U=Ol({element:e});U&&U.length>0&&(i.ownedElements=U);let P=gi(e);P&&(i.resourceLocator=P),(o||Qn(e))&&(i.isFrameElement=!0),s&&s.length>0&&(i.frameContent=s);let B=e.type;B&&typeof B=="string"&&B.trim()&&(i.inputType=B);let z=e.placeholder;z&&typeof z=="string"&&z.trim()&&(i.placeholderText=z);let te=e.value;te&&typeof te=="string"&&te.trim()&&(i.elementValue=te);let re=Al({element:e,parentDisabled:t,semanticRole:n});if(re&&re.length>0&&(i.selectedOptions=re),sn(e,"select,datalist")&&(i.nearestSelectList=!0),hs(e))i.elementNamespace=br.HTML;else if(Tl(e)){i.elementNamespace=br.SVG,i.svgStructure=Rl(e);let _e=kl(e);_e&&Object.keys(_e).length>0&&(i.preservedAttributes?i.preservedAttributes={...i.preservedAttributes,..._e}:i.preservedAttributes=_e)}let K=r?void 0:Cl({element:e});K&&K.length>0&&(i.associatedLabels=K);let ce=e.scope;ce&&typeof ce=="string"&&ce.trim()&&(i.tableScope=ce);let ne=Ll({element:e});ne&&(i.tableCaption=ne);let ue=Nl({element:e});ue&&(i.figureCaption=ue);let ge=Dl({element:e});return ge&&(i.fieldsetLegend=ge),sn(e,"table")&&(i.nearestTable=!0),i}function yl(e,t){let n={},r=new Set(Object.values(bt).filter(i=>typeof i=="string")),o=new Set(Object.keys(Qr).filter(i=>isNaN(Number(i)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),a=e?.attributes?Array.from(e.attributes):[];for(let i of a){let u=i.name,T=i.value;if(u==="id"&&(!t||!nn.has(t)))continue;let p;if(r.has(u)?p=u:u.startsWith("data-v-")?p="data-v-*":u.startsWith("ng-reflect-")?p="ng-reflect-*":u.startsWith("_ngcontent")&&(p="_ngcontent"),p){let _=T.trim()!=="",A=o.has(p);if(_||A){let S=bt[p],M=s.has(p)?"true":T;n[S]=M}}}if(!n[bt[it]]){let i=Oi(e);i&&(n[bt[it]]=i)}return n}function _l(e){return ra(e,to,Jr)}function vl(e){return ra(e,no,null)}function ra(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],i=`aria-${o.toLowerCase().replace(/_/g,"-")}`,u=e.getAttribute(i),T=!1;n!==null&&(T=Object.values(n).filter(_=>typeof _=="number").includes(s)),e.hasAttribute(i)&&T||u?.trim()?r[s]=u:i==="aria-level"&&xi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Ft(e){return oa(e)&&e.nodeType===gr.ELEMENT}function fo(e){return e.nodeType===gr.TEXT}function oa(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function hs(e){return Ft(e)&&(!e.namespaceURI||e.namespaceURI===Ri)}function Tl(e){return Ft(e)&&e.namespaceURI===ki}function Qn(e){return e.tagName==="IFRAME"}function Ln(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function sn(e,t){if(e.closest)return e.closest(t);for(;!uo(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function uo(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function xl(e){let t=e.ownerDocument,n=t?.hasFocus()?t.activeElement:null;if(n){let r=n.getAttribute("aria-activedescendant");r&&(n=t.getElementById(r)||n)}return e===n}function Rl(e){let t={},n=on.text,r=on.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),s=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:s?.alt?.trim()&&(t[r]=s.alt);let a=e.getAttribute("viewBox");a&&(t[on.viewBox]=a);let i=e.querySelectorAll("path");i.length>0&&(t[on.paths]=i.length,t[on.pathData]=Array.from(i).slice(0,3).map(T=>T.getAttribute("d")).filter(Boolean).map(T=>T.substring(0,100)));let u={circles:e.querySelectorAll("circle").length,rects:e.querySelectorAll("rect").length,lines:e.querySelectorAll("line").length,polygons:e.querySelectorAll("polygon").length,polylines:e.querySelectorAll("polyline").length,ellipses:e.querySelectorAll("ellipse").length};return Object.entries(u).forEach(([T,p])=>{if(p>0){let _=on[T];t[_]=p}}),Object.keys(t).length>0?t:void 0}function kl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(zn).filter(r=>typeof r=="number")){let r=zn[n];if(r){let o=r;if(zn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function Il({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!dt.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of Es(r))if(!(kr(s)||sa(s))){if(Ft(s)){let a=s,i=Ht(a),u=Tt(a,i),{shouldCreate:T,shouldAnnotate:p}=po(u);if(T){p&&pn(a);let _=at({targetElement:a,parentDisabled:t,semanticRole:i??void 0,excludeLabels:n,elementContext:u});_&&o.push(_)}else{let _=ws({element:a,semanticRole:i??void 0,parentDisabled:t,excludeLabels:n});o.push(..._)}}else if(fo(s)){let a=xr(s);a&&o.push(a)}}return o}function Es(e){let t=oe(e);if(di(e,t)){try{let n=e.assignedNodes({flatten:!0});if(n&&n.length)return n}catch{}return Array.from(e.childNodes)}try{let n=e.shadowRoot||kn()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(s=>!s.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function ws({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of Es(e))if(!(kr(s)||sa(s))){if(Ft(s)){let a=s,i=Ht(a),u=Tt(a,i);if(Qn(a)){pn(a);let _=Il({frameElement:a,parentDisabled:n,excludeLabels:r}),A=at({targetElement:a,parentDisabled:n,semanticRole:i??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:_,elementContext:u});A&&o.push(A);continue}let{shouldCreate:T,shouldAnnotate:p}=po(u);if(T){p&&pn(a);let _=at({targetElement:a,parentDisabled:n,semanticRole:i??void 0,excludeLabels:r,elementContext:u});_&&o.push(_)}else{let _=ws({element:a,semanticRole:i??void 0,parentDisabled:n,excludeLabels:r});o.push(..._)}}else if(fo(s)){let a=xr(s);a&&o.push(a)}}return o}function Sl({element:e}){let t=ji(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=Ki(e,r);if(!(!o||o===e)&&o){let s=Ht(o),a=at({targetElement:o,semanticRole:s,elementContext:Tt(o,s)});n.add(a)}}return Array.from(n)}function Al({element:e,parentDisabled:t,semanticRole:n}){let r=[];return e&&(n&&n==="listbox"?r=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(o=>at({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:Tt(o,"option")})):Ln(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>at({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:Tt(o,"option")})))),r}function Cl({element:e}){if(Ti.includes(e.tagName)){let t=G(e),n=ts(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&Ml(o,e)).map(o=>{let s=Ht(o),a=at({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:Tt(o,s)});r.add(a)}),Array.from(r)}}function Ml(e,t){let n=e.control;return n!==void 0?n===t:e.htmlFor!==""&&e.htmlFor===t.id?!0:!!(e.htmlFor===""&&e.contains(t))}function Ll({element:e}){if(Ln(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Ht(t);return at({targetElement:t,semanticRole:n,elementContext:Tt(t,n)})}}}function Nl({element:e}){if(Ln(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Ht(t);return at({targetElement:t,semanticRole:n,elementContext:Tt(t,n)})}}}function Dl({element:e}){if(Ln(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Ht(t);return at({targetElement:t,semanticRole:n,elementContext:Tt(t,n)})}}}function Ol({element:e}){let t=new Set,n=Zi(e);for(let r of n){let o=Ht(r),s=at({targetElement:r,semanticRole:o,elementContext:Tt(r,o)});t.add(s)}return Array.from(t)}function po(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,a=n.length>0&&n.some(_=>Ai.has(_)),u=!!t||!s&&(o||r),T=!!t&&nn.has(t);return{shouldCreate:u,shouldAnnotate:u&&(T||r||a)}}function sa(e){if(!Ft(e))return!1;let t=e,n=t.tagName;return Zr.has(n)?!0:n===Cn||n===Mn?Ul(t):!1}function Ul(e){let t=oe(e),n=t?.getComputedStyle;if(!n||n.call(t,e).display==="none")return!0;let o=e.getBoundingClientRect();return o.width===0&&o.height===0&&!(typeof e.closest=="function"&&e.closest("pre"))||o.right<-1e3||o.left>t.innerWidth+1e3}function ys(e,t={}){return ai(t),Hi(),Di(),Ui(e,{includeShadow:!0,includeIframes:dt.clearIframes}),vr.initialize(dt.semanticIdStart),{rootNodes:ia(e),semanticNodes:hn}}function ia(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(ta)).filter(s=>!Nn(s)&&ea(s));if(o.length===0)t=Jn({targetElement:e});else if(o.length===1){let s=o[0];s.contains(e)?t=Jn({targetElement:e}):e.contains(s)?t=Jn({targetElement:s}):t=Jn({targetElement:e})}else t=Jn({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function Jn({targetElement:e,parentNode:t}){if(kr(e)||aa(e))return[];let n=Ht(e),r=Tt(e,n);if(Qn(e))return[Fl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:a}=po(r);s&&(a&&pn(e),o=at({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let i=hn[o],u=Hl(e,n,o?i:t);return o&&u.length>0&&(i.semanticChildren=u),o?[o]:u}function Hl(e,t,n){let r=[],o=Qi(e,t);for(let s of o)if(!(kr(s)||aa(s))){if(Ft(s)){let a=Jn({targetElement:s,parentNode:n});r.push(...a)}else if(fo(s)&&Bl(s,n)){let a=xr(s);a&&r.push(a)}}return r}function Fl({frameElement:e,role:t,parentNode:n,elementContext:r}){pn(e);let o=Pl(e);return at({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Pl(e){if(!dt.includeFrameContents)return[];let n=In(e)?.body??null;return n?ia(n):[]}function Bl(e,t){let n=e.data.trim();if(!n||n==="")return!1;if(t?.semanticRole!==void 0&&t?.semanticRole!==null){let r=typeof t.semanticRole=="number"?Er[t.semanticRole]:t.semanticRole;if(na(r))return!1}return!0}function aa(e){if(!Ft(e))return!1;let t=e,n=t.tagName;return Zr.has(n)?!0:n===Cn||n===Mn?Wl(t):!1}function Wl(e){let t=oe(e);if(t.getComputedStyle(e).display==="none")return!0;let r=e.getBoundingClientRect();return r.width===0&&r.height===0&&!e.closest("pre")||r.right<-1e3||r.left>t.innerWidth+1e3}function mo(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function Vl(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function er(e,t,n){let r=G(e,t),o=X(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(mo(r)===e)return!0;try{let{x:s,y:a}=Vl(e),i=o.PointerEvent||PointerEvent,u=o.MouseEvent||MouseEvent;e.dispatchEvent(new i("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:a,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new u("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:a,buttons:1,button:0})),e.dispatchEvent(new u("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:a,buttons:0,button:0})),e.dispatchEvent(new i("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:a,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Mt(e,o)||Ut(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:a,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return mo(r)===e}function Ir(e,t){let n=oe(e),r=Ut(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function On(e,t,n="insertText"){let r=oe(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),s=r.Event||Event;try{o?e.dispatchEvent(new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{try{e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{o?e.dispatchEvent(new o("input",{bubbles:!0,cancelable:!1,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{try{e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new s("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}function $l(e){let n=oe(e).KeyboardEvent||KeyboardEvent,r={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},o=e.dispatchEvent(new n("keydown",r)),s=e.dispatchEvent(new n("keypress",r)),a=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&s&&a)}}function Dn(e){if(!e)return!1;let t=oe(e);if(Ut(e,t))return!e.disabled&&!e.readOnly;if(Mt(e,t)){let n=(e.type||"text").toLowerCase();return(n==="text"||n==="search"||n==="email"||n==="url"||n==="tel"||n==="password"||n==="number")&&!e.disabled&&!e.readOnly}return!1}function _s(e){let t=oe(e);if(!e||!Ge(e,t))return!1;if(e.isContentEditable)return!0;let n=e.getAttribute("contenteditable");return!!(n&&n!=="false"||e.getAttribute("role")==="textbox"&&!("value"in e))}function Gl(e,t){let n=e.getRootNode();return vt(n)?n:G(e)??t}function ql(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=oe(o);Ge(o,s)&&n.push(o)}return n}function da(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(Dn(e))return{kind:"input",el:e,via:"self-input"};if(_s(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=X(n),o=Gl(e,n);if(li(e,r)){let u=e.control;if(Dn(u))return{kind:"input",el:u,via:"label.control"};let T=e.htmlFor;if(T){let p=o.getElementById?.(T)||o.querySelector?.(`#${CSS.escape(T)}`);if(Dn(p))return{kind:"input",el:p,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let u of ql(o,s)){if(Dn(u))return{kind:"input",el:u,via:"aria-controls/owns"};if(_s(u))return{kind:"contenteditable",el:u,via:"aria-controls/owns"};let T=u.querySelector?.("input,textarea");if(Dn(T))return{kind:"input",el:T,via:"aria-controls->desc"}}let a=e.querySelector?.("input,textarea");if(Dn(a))return{kind:"input",el:a,via:"descendant"};let i=e.shadowRoot||null;if(i){let u=i.querySelector?.("input,textarea");if(Dn(u))return{kind:"input",el:u,via:"open-shadow-input"};let T=i.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(_s(T))return{kind:"contenteditable",el:T,via:"open-shadow-contenteditable"}}return e.getAttribute("role")==="textbox"&&!("value"in e)?{kind:"contenteditable",el:e,via:"role=textbox"}:{kind:"none",el:null,via:"not-found"}}function Zn(e,t,n,r=!1){let o=G(e,t),a=X(o,n).getSelection?.();if(!a)return!1;try{let i=o.createRange();return i.selectNodeContents(e),r&&i.collapse(!1),a.removeAllRanges(),a.addRange(i),!0}catch{return!1}}function Un(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var ho=e=>String(e??"").replace(/\s+/g," ").trim(),fa=new MessageChannel,pa=[];fa.port1.onmessage=()=>{let e=pa.shift();e&&e()};function ca(){return new Promise(e=>{pa.push(e),fa.port2.postMessage(0)})}async function la(e,t,n){await Promise.resolve();let r=Math.max(0,Math.min(4,Number(n)||0));for(let o=0;o<r;o++)e.hidden?await ca():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{ca().then(s)}})}function Yl(e){let t=String(e??"");return t===" "?{code:"Space",which:32}:/^[a-z]$/i.test(t)?{code:`Key${t.toUpperCase()}`,which:t.toUpperCase().charCodeAt(0)}:/^[0-9]$/.test(t)?{code:`Digit${t}`,which:t.charCodeAt(0)}:{code:"",which:t.length===1?t.charCodeAt(0):0}}function ua(e,t,n,r){let o=G(e,t),a=X(o,n).KeyboardEvent||KeyboardEvent,i=String(r??"");for(let u of i){let{code:T,which:p}=Yl(u),_={key:u,code:T,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new a("keydown",_)),e.dispatchEvent(new a("keypress",_)),e.dispatchEvent(new a("keyup",_))}}async function ha(e,t,n,r,o){let s=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let a=String(e.value??""),i=G(e,t),u=X(i,n),T=er(e,i,u),p=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):i.hidden?1:2,_=!!o?.useKeyFallback,A=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,S=_&&s.length>0&&s.length<=A;Ir(e,s),On(e,s,"insertReplacementText"),S&&ua(e,i,u,s),await la(i,u,p);let M=String(e.value??""),O=ho(a),W=ho(M),q=ho(s),U=O===q,P=W===q,B=M!==a,z=s.length>0&&!U&&M===a,te=1;if(!U&&!P&&!B){te=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ne=!1;try{i.execCommand?.("selectAll",!1,void 0),ne=!!i.execCommand?.("insertText",!1,s)}catch{ne=!1}if(!ne)try{Ir(e,s)}catch{}try{On(e,s,"insertReplacementText")}catch{}S&&ua(e,i,u,s),await la(i,u,p),M=String(e.value??"")}let ie=ho(M)===q,K=M!==a;z=s.length>0&&!U&&M===a;let ce=U||ie||K;return{success:ce,method:"type-native-setter",details:`focus=${T};attempts=${te};settleFrames=${p};beforeLen=${a.length};afterLen=${M.length};changed=${K};alreadyCorrect=${U};nowCorrect=${ie};reverted=${z};keyFallback=${S}`,allowFallback:ce?void 0:!0}}function Xl(e,t,n){let o=oe(e).InputEvent||InputEvent,s=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(s),defaultPrevented:s.defaultPrevented}}function ma(e,t,n,r){let o=G(e,n),s=X(o,r),a=s.InputEvent||InputEvent,i=s.Event||Event,u=String(t??""),T=Un(e),p=er(e,o,s),_=Zn(e,o,s,!0),A=Xl(e,u,"insertText"),S=!1,M="execCommand",O=!1,W=()=>{O=!0};try{e.addEventListener("input",W,{capture:!0})}catch{}if(A.ok&&!A.defaultPrevented)try{S=!!o.execCommand?.("insertText",!1,u)}catch{}if(!S)try{let P=s.getSelection?.(),B=P&&P.rangeCount?P.getRangeAt(0):null;if(!B||!e.contains(B.commonAncestorContainer)){Zn(e,o,s,!0);let z=s.getSelection?.();B=z&&z.rangeCount?z.getRangeAt(0):null}B&&(B.insertNode(o.createTextNode(u)),B.collapse(!1),P?.removeAllRanges(),P?.addRange(B),S=!0,M="range")}catch{}if(S&&!O){try{e.dispatchEvent(new a("input",{bubbles:!0,cancelable:!1,composed:!0,data:u,inputType:"insertText"}))}catch{try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new i("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",W,{capture:!0})}catch{}let q=Un(e);return{success:q!==T||!!u&&q.includes(u),method:`type-contenteditable-${M}`,details:`focus=${p};selectedWithin=${_};inserted=${S}`}}function ga(e){let{canceled:t}=$l(e);if(t)return{submitted:!1,method:"enter-handled"};let n=e.form||e.closest?.("form");return n?(n.requestSubmit?.()??n.submit?.(),{submitted:!0,method:"enter->form-submit"}):{submitted:!1,method:"enter-dispatched"}}function ba(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=G(e,t),o=X(r,n),s=String(e.value??""),a=er(e,r,o);Ir(e,""),On(e,"","deleteByCut");let i=String(e.value??""),u=i!==s;return{success:u||i.length===0,method:"clear-native-setter",details:`focus=${a};beforeLen=${s.length};afterLen=${i.length};changed=${u}`}}function Ea(e,t,n){let r=G(e,t),o=X(r,n),s=Un(e),a=er(e,r,o),i=Zn(e,r,o,!1),u=!1,T="execCommand";try{u=!!r.execCommand?.("delete",!1,void 0)}catch{u=!1}if(!u)try{let S=o.getSelection?.(),M=S&&S.rangeCount?S.getRangeAt(0):null;(!M||!e.contains(M.commonAncestorContainer))&&Zn(e,r,o,!1);let O=o.getSelection?.(),W=O&&O.rangeCount?O.getRangeAt(0):null;W&&(W.deleteContents(),W.collapse(!1),O?.removeAllRanges(),O?.addRange(W),u=!0,T="range")}catch{}if(!u)try{e.textContent="",u=!0,T="textContent"}catch{}On(e,"","deleteByCut");let p=Un(e),_=p!==s;return{success:u||_||p.length===0,method:`clear-contenteditable-${T}`,details:`focus=${a};selectedWithin=${i};cleared=${u};changed=${_}`}}function wa(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(vt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var go;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(go||(go={}));var ya;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(ya||(ya={}));var zl=["image/png","image/jpeg","image/webp"],jl=["application/pdf","text/plain"],rh=[...zl,...jl];var nt;(function(e){e.ACT="act_on_tab",e.CRAWL="crawl_and_extract_from_tab",e.EXTRACT="extract_from_tab",e.SHEETS_WORKFLOW="sheets_workflow",e.INFER_SHEET_DATA="infer_sheet_data",e.GRAPHBOT="graph_bot",e.PDF_FILLER="pdf_filler",e.CUSTOM_TOOL_GENERATOR="custom_tool_generator",e.WEBPAGE_GENERATOR="webpage_generator",e.GOOGLE_DOC_GENERATOR="google_doc_generator",e.GOOGLE_SLIDES_GENERATOR="google_slides_generator",e.PROCESS_TEXT="process_text",e.CREATE_SHEET_FROM_DATA="create_sheet_from_data",e.CONFIGURE_API_KEY="configure_api_key",e.TASK_COMPLETE="task_complete",e.ASK_USER="ask_user",e.EXECUTE_MULTIPLE_TOOLS="execute_multiple_tools",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(nt||(nt={}));var Ke;(function(e){e.PLANNER="Planner",e.AGENTIC_SEEK="Agentic Action",e.CRAWL_PAGES="Crawl Pages",e.EXTRACT_PAGE="Extract Page",e.SHEETS_WORKFLOW="Sheets Workflow",e.INFER_SHEET_DATA="Infer Sheet Data",e.MULTI_STEPS="Multi Steps",e.PDF_FILLER="PDF Filler",e.CUSTOM_TOOL_GENERATOR="Custom Tool Generator",e.WEBPAGE_GENERATOR="WebPage Generator",e.GOOGLE_DOC_GENERATOR="Google Doc Generator",e.GOOGLE_SLIDES_GENERATOR="Google Slides Generator",e.PROCESS_TEXT="Process Text",e.CREATE_SHEET_FROM_DATA="Create Sheet From Data",e.EXECUTE_MULTIPLE_TOOLS="Execute Multiple User Tools",e.CONFIGURE_API_KEY="Configure Gemini API Key",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(Ke||(Ke={}));var oh={[nt.ACT]:Ke.AGENTIC_SEEK,[nt.CRAWL]:Ke.CRAWL_PAGES,[nt.EXTRACT]:Ke.EXTRACT_PAGE,[nt.SHEETS_WORKFLOW]:Ke.SHEETS_WORKFLOW,[nt.INFER_SHEET_DATA]:Ke.INFER_SHEET_DATA,[nt.PDF_FILLER]:Ke.PDF_FILLER,[nt.CUSTOM_TOOL_GENERATOR]:Ke.CUSTOM_TOOL_GENERATOR,[nt.WEBPAGE_GENERATOR]:Ke.WEBPAGE_GENERATOR,[nt.GOOGLE_DOC_GENERATOR]:Ke.GOOGLE_DOC_GENERATOR,[nt.GOOGLE_SLIDES_GENERATOR]:Ke.GOOGLE_SLIDES_GENERATOR,[nt.PROCESS_TEXT]:Ke.PROCESS_TEXT,[nt.CREATE_SHEET_FROM_DATA]:Ke.CREATE_SHEET_FROM_DATA,[nt.EXECUTE_MULTIPLE_TOOLS]:Ke.EXECUTE_MULTIPLE_TOOLS,[nt.CONFIGURE_API_KEY]:Ke.CONFIGURE_API_KEY,[nt.QUERY_RTRVR_AI_DOCUMENTATION]:Ke.QUERY_RTRVR_AI_DOCUMENTATION};var vs=200;var sh=go.FLASH;var ih=Ke.PLANNER;var Ts="application/pdf",xs="application/gsheet";var ah=20*1024*1024;var bo={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var Kl=1,Ql=9,Jl=11,ks="application/gdoc",tr="text/html",Eo="text/plain";function Zl(e){return!!e&&typeof e=="object"&&e.nodeType===Ql}function _a(e){return!!e&&typeof e=="object"&&e.nodeType===Kl}function eu(e){return!!e&&typeof e=="object"&&e.nodeType===Jl&&typeof e.host=="object"&&typeof e.mode=="string"}function va(e){return _a(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Rs(e){let t;if(typeof e=="number")t=e;else if(typeof e=="bigint")t=Number(e);else if(typeof e=="string")t=Number(e.trim());else return null;if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n<=0?null:n}function tu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function nu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,a=[e],i=new WeakSet;for(;a.length;){let u=a.pop();if(u&&typeof u=="object"){if(i.has(u))continue;i.add(u)}if(Zl(u)){let _=u.documentElement||u.body;_&&a.push(_);continue}if(eu(u)){let _=u.children;if(_&&_.length)for(let A=_.length-1;A>=0;A--)a.push(_[A]);continue}if(!_a(u))continue;let T=u;if(s&&T.ownerDocument!==s)continue;let p=T.getAttribute?.(it);if(p&&yr(p)===t)return T;if(r)try{let _=tu(T);_&&a.push(_)}catch{}if(o&&va(T))try{let _=In(T);_&&a.push(_)}catch{}for(let _=T.lastElementChild;_;_=_.previousElementSibling)a.push(_)}return null}function Pt(e,t,n={}){let r=Rs(t);if(!r)return null;let o=Tr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:nu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Is(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Ta(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Rs(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Rs(e);return t?[t]:[]}if(typeof e=="string"){let t=e.match(/\d+/g);return t?t.map(r=>parseInt(r,10)).filter(r=>Number.isFinite(r)&&r>0):[]}if(typeof e=="object"){let t=e.path??e.ids??e.iframe_path;if(t!==void 0)return Ta(t)}return[]}function nr(e,t){let n=Ta(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,s=[];for(let a=0;a<n.length;a++){let i=n[a],u=n.length===1,T=Pt(o,i,{requireOwnerDocument:u?void 0:o,traverseShadow:!0,traverseIframes:u});if(!T||!va(T))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(a)};let p=null;try{p=In(T)||null}catch{p=null}if(!p)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(a)};s.push(i),o=p}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function xa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function ru(){return Date.now()}function Lt(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-ru())}async function Ra(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=Lt(n);r<=0||r<e+40||await Qe(e,t)}async function rr(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(s=>({ok:!0,value:s})),(async()=>(await Qe(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var Qe=(()=>{let e=new MessageChannel,t=[];e.port1.onmessage=()=>{let r=t.shift();r&&r()};let n=()=>new Promise(r=>{t.push(r),e.port2.postMessage(0)});return async(r,o)=>{let s=Number(r);if(!Number.isFinite(s)||s<=0)return;if(!o.hidden){let i=o.defaultView||window,u=i.setTimeout?i.setTimeout.bind(i):setTimeout;await new Promise(T=>u(T,s));return}let a=Date.now();for(;Date.now()-a<s;)await n()}})();var ou=3e4;function ka(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Ss=class extends Error{constructor(n,r){super(n);$(this,"url");$(this,"status");$(this,"statusText");$(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function su(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function iu(e){if(!e)return;let t=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1].trim().replace(/^\"(.*)\"$/,"$1"))}catch{}let n=/filename\s*=\s*(\"?)([^\";]+)\1/i.exec(e);if(n?.[2])return n[2].trim()}function As(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let i=decodeURIComponent(s[1]).split("/");return i[i.length-1].replace(/^\d+-/,"")}}catch{}}function Ia(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function au(e,t={},n,r=fetch){let o=new AbortController,s=ou,a=!1,i=()=>{};if(n){let T=!1;i=()=>{T=!0},(async()=>{try{if(await Qe(s,n),T)return;a=!0,o.abort()}catch{}})().catch(()=>{})}else{let T=setTimeout(()=>{a=!0,o.abort()},s);i=()=>clearTimeout(T)}let u=new Headers(t.headers);u.has("Accept")||u.set("Accept","*/*");try{let T=await r(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:u,signal:o.signal});if(!T.ok){let S=await T.text().catch(()=>"");throw new Ss(`Fetch failed (${T.status})`,{url:e,status:T.status,statusText:T.statusText,bodySnippet:S.slice(0,256)})}let p=await T.arrayBuffer(),_=su(T.headers.get("content-type")),A=iu(T.headers.get("content-disposition"))||As(e);return{bytes:p,mimeType:_,fileName:A}}finally{i()}}async function Sa(e,t,n){return await au(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var Ue;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(Ue||(Ue={}));var rt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(rt||(rt={}));function Ca(e){if(!e)return rt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return rt&&t in rt?rt[t]:rt.CENTER}function Cs(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function or(e,t){if(!e)return"";let n=G(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Cs(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Cs(o.id)}`,r.unshift(s);break}let i=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(u=>u&&u.length<=48).sort((u,T)=>u.length-T.length).slice(0,3).map(Cs);if(i.length)s+="."+i.join(".");else{let u=o.parentElement;if(u){let T=Array.from(u.children).filter(p=>p.tagName===o.tagName);if(T.length>1){let p=T.indexOf(o)+1;s+=`:nth-of-type(${p})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Hn(e){return e.scrollingElement||e.documentElement||e.body}function wo(e,t,n,r,o){let s=G(e,t),a=X(s,n),i=Hn(s),u=e===s.documentElement||e===s.body||e===i,T=u?i:e,p=u?a.innerHeight:T.clientHeight,_=u?a.innerWidth:T.clientWidth,A=o??p*.8;switch(r){case Ue.DOWN:{T.scrollTop+=A;break}case Ue.UP:{T.scrollTop=Math.max(0,T.scrollTop-A);break}case Ue.LEFT:return T.scrollLeft=Math.max(0,T.scrollLeft-(o??_*.8)),{success:!0,scrollLeft:T.scrollLeft};case Ue.RIGHT:return T.scrollLeft+=o??_*.8,{success:!0,scrollLeft:T.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let S=T.scrollHeight,M=u?a.innerHeight:T.clientHeight,O=S-M;return{success:!0,scrollTop:T.scrollTop,isAtTop:T.scrollTop<=5,isAtBottom:T.scrollTop>=O-5}}function cu(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),a=e;for(;a&&a!==r.body&&a!==r.documentElement;){let u=o.getComputedStyle(a).overflowY;if((u==="auto"||u==="scroll"||u==="overlay")&&a.scrollHeight>a.clientHeight+5)return a;a=a.parentElement}return s}function Aa(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),a=e===r.documentElement||e===r.body||e===s,i=a?s:e,u=i.scrollHeight,T=a?o.innerHeight:i.clientHeight,p=u-T;return i.scrollTop>=p-5}function Ms(e,t,n,r){let o=G(e,t),s=X(o,n),a=Hn(o),i=cu(e,o,s),u=i===o.documentElement||i===o.body||i===a,T=u?a:i,p=e.getBoundingClientRect(),_=u?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):i.getBoundingClientRect(),A=u?s.innerHeight:i.clientHeight,S=24,M=p.top-_.top,O=T.scrollTop+M,W;switch(r){case rt.START:W=O-S;break;case rt.END:W=O+p.height-A+S;break;case rt.NEAREST:{if(p.top>=_.top&&p.bottom<=_.bottom)return{success:!0,scrollTop:T.scrollTop,isAtTop:T.scrollTop<=5,isAtBottom:Aa(T,o,s)};p.top<_.top?W=O-S:W=O+p.height-A+S;break}case rt.CENTER:default:W=O-A/2+p.height/2;break}let q=T.scrollHeight-A;return T.scrollTop=Math.max(0,Math.min(W,q)),{success:!0,scrollTop:T.scrollTop,isAtTop:T.scrollTop<=5,isAtBottom:Aa(T,o,s)}}var lu=new Set([L.click_element,L.type_into_element,L.type_and_enter,L.hover_element,L.right_click_element,L.double_click_element,L.press_key,L.scroll_page,L.scroll_to_element,L.mouse_wheel,L.drag_element,L.drag_and_drop,L.swipe_element,L.long_press_element,L.adjust_slider,L.select_dropdown_value,L.clear_element,L.focus_element,L.check_field_validity,L.select_text,L.copy_text,L.paste_text,L.pinch_zoom,L.upload_file,L.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(ss,"1")}catch{}let n="__RTRVR_INTERNAL__";try{window.__RTRVR_INTERNAL_KEY__=window.__RTRVR_INTERNAL_KEY__||n}catch{}let r=window.__RTRVR_INTERNAL_KEY__||n,o=window[r],s=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=s}async function a(c){let w={};try{let b=oi[c.opcode];if(!b)throw new Error(`Unknown tool opcode: ${c.opcode}`);let g={...c.call,name:b};w=(await O({tabIndex:c.tabIndex,call:g,elementData:M(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(b){w={success:!1,error:b?.message||String(b),allowFallback:!0}}return w}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:a}),writable:!1,configurable:!1,enumerable:!1})}catch{}let i="__RTRVR_UPLOAD_BYTES_REQ__",u="__RTRVR_UPLOAD_BYTES_RES__",T="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function _(c){let w=c,b=w[p];if(!b||typeof b!="object"){b={handlers:new Set,installed:!1};try{Object.defineProperty(w,p,{value:b,enumerable:!1,configurable:!1})}catch{w[p]=b}}if(!b.installed){b.installed=!0,c.addEventListener("message",g=>{if(g.source===c)for(let f of Array.from(b.handlers))try{f(g)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let f=c[T]?.pending;if(f)for(let[d,h]of f){try{h.cancelTimeout()}catch{}h.reject(new Error("pagehide: upload bytes request canceled")),f.delete(d)}},!0)}catch{}}return b}function A(c){let w=c,b=w[T];if(!b||typeof b!="object"){b={pending:new Map};try{Object.defineProperty(w,T,{value:b,enumerable:!1,configurable:!1})}catch{w[T]=b}_(c).handlers.add(f=>{let d=f?.data;if(!d||typeof d!="object"||d.type!==u)return;let h=String(d.requestId||"");if(!h)return;let x=b.pending.get(h);if(!x)return;b.pending.delete(h);try{x.cancelTimeout()}catch{}if(!d.ok){x.reject(new Error(d.error||"Failed to get bytes"));return}let m=d.bytes;if(!(m instanceof ArrayBuffer)){x.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof x.expectedByteLength=="number"&&m.byteLength!==x.expectedByteLength){x.reject(new Error(`Byte length mismatch: got=${m.byteLength}, expected=${x.expectedByteLength}`));return}x.resolve(m)})}return b}function S(c,w,b,g=9e4){let f=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof f=="function")return Promise.resolve().then(()=>f({token:w,byteLength:b,timeoutMs:g})).then(v=>{if(v instanceof ArrayBuffer)return v;if(v&&v.buffer instanceof ArrayBuffer)return v.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=A(c),h=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,x=Math.max(1e3,Math.min(Number(g)||9e4,18e4)),m=jr(c)||document;return new Promise((v,C)=>{let N=!1,H=!1,Y=()=>{H=!0};(async()=>{await Qe(x,m),!(H||N)&&(d.pending.delete(h),N=!0,C(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(h,{cancelTimeout:Y,expectedByteLength:b,resolve:Q=>{N||(N=!0,Y(),v(Q))},reject:Q=>{N||(N=!0,Y(),C(Q))}}),c.postMessage({type:i,requestId:h,token:w,byteLength:b},"*")})}function M(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(w=>ri[w]).filter(w=>w&&w!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function O({tabIndex:c,call:w,elementData:b,payload:g}){let f=(()=>{try{return zt()?.top?.document||document}catch{return document}})(),d=w.args,h,x,m;try{({doc:h,win:x,unresolvedPath:m}=nr(f,d.iframe_id))}catch{if(d.iframe_id!=null)return[{name:w.name,args:w.args,response:{success:!1,error:`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`}}];h=document,x=X(h)}let v=w.name,C=d.element_id?Pt(h,d.element_id):null,N=C?.ownerDocument??null,H;if(!lu.has(v))H={success:!1,error:`Tool not promotable to main: ${v}`,allowFallback:!0};else{let Y=N??h,Q=X(Y,x);H=await q(v,C,d,b,Y,Q,g)}return[{name:w.name,args:w.args,response:H}]}async function W(c,w,b){try{let g=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=c[g]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let h=b?.doc||jr(c)||document,x=Math.max(250,Math.min(Number(b?.timeoutMs??3500),8e3)),m=await rr(Promise.resolve().then(()=>d(w)),x,h);if(!m.ok)throw new Error("scroll detector timeout");return m.value}catch(g){throw new Error(g?.message||"main-world scroll detector not available")}}async function q(c,w,b,g,f,d,h){let x=H=>({success:H.success,error:H.success?void 0:H.details||"Action failed",allowFallback:H.success?void 0:H.allowFallback??!0}),m=c===L.press_key||c===L.scroll_page||c===L.drag_and_drop||c===L.pinch_zoom;if(!w&&!m)return x({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let v=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),C=w,N=G(C,f);if(C&&v.has(c)){let H=da(C,N);(H.kind==="input"||H.kind==="contenteditable")&&(C=H.el)}try{switch(c){case L.click_element:return x(z(w,f,d,g));case L.double_click_element:return x(Ot(w,f,d));case L.right_click_element:return x(pe(w,f,d));case L.hover_element:return x(await ht(w,f,d,g,b.duration));case L.type_into_element:return x(await ot(C,f,d,b.text,g));case L.type_and_enter:return x(await wt(C,f,d,b.text,g));case L.clear_element:return x(await kt(C,f,d,g));case L.focus_element:return x(st(C,f,d));case L.select_dropdown_value:return x(ke(w,f,d,b.value,g));case L.adjust_slider:return x(Me(w,f,d,g?.value??b.value,g));case L.check_field_validity:return x(Wt(C,f,d));case L.select_text:return x(mt(C,f,d,b.start_offset,b.end_offset));case L.scroll_page:return x(await Vt(w,f,d,b));case L.scroll_to_element:return x(await cn(w,f,d,b));case L.mouse_wheel:return x(Ze(w,f,d,b.delta_x,b.delta_y));case L.drag_element:return x(await Le(w,f,d,b,g));case L.drag_and_drop:return x(await ln(b,w,f,d));case L.swipe_element:return x(await un(w,f,d,b));case L.long_press_element:return x(await wn(w,f,d,b.duration));case L.pinch_zoom:return x(await Fe(w,f,d,b));case L.press_key:return x($t(b.key,b.modifiers,w,f,d));case L.copy_text:return x(await Qt(w,f,d));case L.paste_text:return x(await dn(w,f,d,g));case L.upload_file:return x(await Dt(b,f,d,h,w,g));case L.dispatch_pointer_path:return x(await lt(b,f,d));default:return x({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(H){return x({success:!1,method:"exception",details:H?.message||"exception",allowFallback:!0})}}function U(c){let w=new Map;if(!c)return w;let b=c.trim();if(!b)return w;let g=An(b);if(g){for(let{id:f,mask:d}of g.entries){let h=tn[f];if(!h)continue;let x=new Set($r(d)),m=w.get(h);if(m)for(let v of x)m.add(v);else w.set(h,x)}return w}return w}function P(c,...w){return c?w.some(b=>c.has(b)):!1}function B(c,w){let b=U(w?.listenersRaw),g=new Set;for(let[,v]of b)for(let C of v)(C==="react"||C==="vue"||C==="angular"||C==="svelte"||C==="jquery")&&g.add(C);let f=new Set;for(let[v,C]of b)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(v))for(let N of C)f.add(N);let d=g.size>0||[...f].some(v=>["react","vue","angular","svelte","jquery"].includes(v)),h=P(b.get("click"),"delegated"),x=P(b.get("input"),"delegated")||P(b.get("change"),"delegated")||P(b.get("keydown"),"delegated"),m=w?.role||wr(c)||c.getAttribute("role");return{sourcesByType:b,fws:g,isFrameworkElement:d,delegatedClick:h,delegatedInput:x,role:m}}function z(c,w,b,g){let f=B(c,g),d=G(c,w),h=X(d,b);Ve(c,d,h),g?.pattern==="hover-activate"&&ht(c,d,h,g,120);let x=f.fws.has("react")||P(f.sourcesByType.get("click"),"react"),m=f.fws.has("vue")||P(f.sourcesByType.get("click"),"vue"),v=f.fws.has("angular")||P(f.sourcesByType.get("click"),"angular"),C=f.fws.has("svelte")||P(f.sourcesByType.get("click"),"svelte"),N=f.fws.has("jquery")||P(f.sourcesByType.get("click"),"jquery");return vn(()=>te(c,d,h),()=>re(c,d,h),()=>x?K(c,d,h):null,()=>m?ce(c,d,h):null,()=>v?ne(c,d,h):null,()=>C?ue(c,d,h):null,()=>N?ge(c,d,h):null)}function te(c,w,b){let g=G(c,w),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent,{x,y:m}=ie(c,g,f),v={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:x,clientY:m,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new d("pointerover",v),new d("pointerenter",{...v,bubbles:!1}),new h("mouseover",v),new h("mouseenter",{...v,bubbles:!1}),new d("pointerdown",v),new h("mousedown",v),new d("pointerup",{...v,buttons:0}),new h("mouseup",{...v,buttons:0}),new h("click",{...v,buttons:0})].forEach(N=>c.dispatchEvent(N)),{success:!0,method:"pointer-mouse-click"}}function re(c,w,b){let g=G(c,w),f=X(g,b);try{if(c instanceof HTMLAnchorElement){let d=c.getAttribute("target");try{c.setAttribute("target","_self"),c.click()}finally{d===null?c.removeAttribute("target"):c.setAttribute("target",d)}}else c.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function ie(c,w,b){let g=G(c,w),f=c.getBoundingClientRect(),d=[{x:f.left+f.width/2,y:f.top+f.height/2},{x:f.left+4,y:f.top+4},{x:f.right-4,y:f.top+4},{x:f.left+4,y:f.bottom-4},{x:f.right-4,y:f.bottom-4}],h=null;for(let x=0;x<d.length;x++){let m=d[x],v=g.elementFromPoint(m.x,m.y);if(x===0&&(h=v),v&&wa(c,v))return{...m,hit:v,ok:!0}}return{...d[0],hit:h,ok:!1}}function K(c,w,b){let g=G(c,w),f=X(g,b);try{let d=en(c);if(!d)return{success:!1,method:"react-no-fiber"};let h=qt(d),x=h.onClick||h.onClickCapture;return x?(x(Yt("click",c,g,f)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function ce(c,w,b){let g=G(c,w),d=X(g,b).MouseEvent||MouseEvent;try{let h=xn(c);if(!h)return{success:!1,method:"vue-none"};let x=Ct(h);return x.click?(x.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):h.$emit?(h.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ne(c,w,b){let g=G(c,w),f=X(g,b),d=f.MouseEvent||MouseEvent;try{let h=f.ng?.getZone?.()||null;return h?.run?(h.run(()=>c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0})),c.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function ue(c,w,b){let g=G(c,w),d=X(g,b).MouseEvent||MouseEvent;try{let h=c.getBoundingClientRect(),x={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:h.left+h.width/2,clientY:h.top+h.height/2};return c.dispatchEvent(new d("mousedown",x)),c.dispatchEvent(new d("mouseup",x)),c.dispatchEvent(new d("click",x)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function ge(c,w,b){let g=G(c,w),f=X(g,b);try{return f.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function ht(c,w,b,g,f=500){let d=Math.min(Math.max(0,Number(f)||500),3e4),h=G(c,w),x=X(h,b),m=B(c,g);Ve(c,h,x);let v=x.PointerEvent||PointerEvent,C=x.MouseEvent||MouseEvent,N=c.getBoundingClientRect(),H=N.left+N.width/2,Y=N.top+N.height/2;if(m.fws.has("react")){let J=en(c),Z=J?qt(J):{};Z.onMouseEnter?.(Yt("mouseenter",c,h,x)),Z.onPointerEnter?.(Yt("pointerenter",c,h,x))}else if(m.fws.has("vue")){let J=xn(c),Z=J?Ct(J):{};Z.mouseenter?.(new C("mouseenter",{bubbles:!0})),Z.mouseover?.(new C("mouseover",{bubbles:!0}))}let Q={bubbles:!0,cancelable:!0,composed:!0,view:x,clientX:H,clientY:Y};return[new v("pointerover",Q),new v("pointerenter",{...Q,bubbles:!1}),new C("mouseover",Q),new C("mouseenter",{...Q,bubbles:!1})].forEach(J=>c.dispatchEvent(J)),await Qe(d,h),{success:!0,method:"hover-seq"}}async function _e(c,w,b=1){await Promise.resolve();for(let g=0;g<b;g++)c.hidden?await At():await new Promise(f=>{try{w.requestAnimationFrame(()=>f())}catch{At().then(f)}})}let De=c=>String(c??"").replace(/\s+/g," ").trim();function He(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Ce(c){try{return typeof Un=="function"?Un(c):De(c.textContent)}catch{return""}}function Je(c,w){if(!(w.isFrameworkElement||w.delegatedInput))return!1;let b=String(c??"").length;return b>0&&b<=140}async function ot(c,w,b,g,f){let d=B(c,f),h=G(c,w),x=X(h,b);if(Ve(c,h,x),Mt(c,x)||Ut(c,x)){let v=Je(String(g??""),d),C=await ha(c,h,x,g,{settleFrames:h.hidden?1:2,useKeyFallback:v,keyFallbackMaxLen:140});return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||d.role==="textbox"&&!("value"in c)){let v=Ce(c),C=ma(c,g,h,x);await _e(h,x,h.hidden?1:2);let N=Ce(c),H=!1;if(String(g??"").length>0&&N===v){H=!0;try{er(c,h,x),Zn(c,h,x,!0);try{h.execCommand?.("insertText",!1,String(g??""))}catch{}On(c,String(g??""),"insertText")}catch{}await _e(h,x,h.hidden?1:2)}let Y=Ce(c),Q=Y!==v||!!String(g??"")&&Y.includes(String(g??""));return{success:Q,method:C.method,details:`${C.details};beforeLen=${v.length};afterLen=${Y.length};reverted=${N===v};fallback=${H}`,allowFallback:Q?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function wt(c,w,b,g,f){let d=G(c,w),h=X(d,b),x=await ot(c,d,h,g,f);if(!x.success)return x;let m=ga(c);return{success:!0,method:"type+enter",details:`${x.details};enter=${m.method}`}}async function kt(c,w,b,g){let f=G(c,w),d=X(f,b),h=d.Event||Event;if(Ve(c,f,d),Mt(c,d)||Ut(c,d)){let m=He(c),v=ba(c,f,d);if(await _e(f,d,f.hidden?1:2),He(c)===m&&m.length>0){try{Ir(c,""),On(c,"","deleteByCut")}catch{}await _e(f,d,f.hidden?1:2)}let H=He(c),Y=H.length===0||H!==m;return{success:v.success,method:v.method,details:v.details,allowFallback:!v.success}}if(c.isContentEditable===!0||B(c,g).role==="textbox"&&!("value"in c)){let m=Ea(c,f,d);return await _e(f,d,f.hidden?1:2),{success:m.success,method:m.method,details:m.details,allowFallback:!m.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new h("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new h("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function st(c,w,b){try{let g=G(c,w),f=X(g,b),d=f.FocusEvent||FocusEvent;return Ve(c,g,f),c.focus?.({preventScroll:!0}),c.dispatchEvent(new d("focus",{bubbles:!0})),c.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(g){return{success:!1,method:"focus",details:g.message,allowFallback:!0}}}function ke(c,w,b,g,f){try{let d=G(c,w),h=X(d,b),x=h.Event||Event;if(!ui(c,h))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Array.from(c.options).find(H=>H.value===g||H.text.trim()===g.trim());if(!m)return{success:!1,method:"select",details:`Option not found: ${g}`,allowFallback:!0};m.selected=!0;let v=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(v,"value");if(C?.set?C.set.call(c,m.value):c.value=m.value,c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let H=en(c);if(H){let Y=qt(H);if(Y.onChange){let Q=Yt("change",c,d,h);Q.target.value=m.value,Y.onChange(Q)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Me(c,w,b,g,f){try{let d=G(c,w),h=X(d,b),x=h.Event||Event;if(!Mt(c,h))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Object.getPrototypeOf(c),v=Object.getOwnPropertyDescriptor(m,"value");if(v?.set?v.set.call(c,String(g)):c.value=String(g),c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let N=en(c);if(N){let H=qt(N);if(H.onChange){let Y=Yt("change",c,d,h);Y.target.value=String(g),H.onChange(Y)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function Wt(c,w,b){try{let g=c.checkValidity?.()??!0;return g||c.reportValidity?.(),{success:g,method:"check-validity",details:g?void 0:c.validationMessage}}catch(g){return{success:!1,method:"check-validity",details:g.message,allowFallback:!0}}}function mt(c,w,b,g,f){try{let d=G(c,w),h=X(d,b);if("setSelectionRange"in c){let v=c;v.focus?.();let C=v.value?.length??0;return v.setSelectionRange(g??0,f??C),{success:!0,method:"select-range"}}let x=h.getSelection();if(!x)return{success:!1,method:"select-range",allowFallback:!0};let m=d.createRange();return m.selectNodeContents(c),x.removeAllRanges(),x.addRange(m),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function gt(c,w,b,g,f){let d=Hn((c&&G(c))??w),h=c||d,x=G(h,w),m=X(x,b),v=h===x.documentElement||h===x.body||h===d;if(g===Ue.TOP||g===Ue.BOTTOM){let C=h.scrollHeight,N=v?m.innerHeight:h.clientHeight,H=Math.max(0,C-N);return h.scrollTop=g===Ue.TOP?0:H,{success:!0,scrollTop:h.scrollTop}}return wo(h,x,m,g,f)}async function Vt(c,w,b,g){let f=g.direction,d=g.amount,h=G(c,w),x=X(h,b),m=!h.hidden,v=m?"smooth":"auto";try{if(c){let N=It(c,h,x),H=gt(N,h,x,f,d);return H?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(H)}:{success:!1,method:"direct-element-scroll",details:H?.error||"direct scroll failed",allowFallback:!0}}if(f===Ue.TOP||f===Ue.BOTTOM){let N=await W(x,{action:"scrollTo",direction:f,options:{behavior:v,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(N)}}let C=await W(x,{action:"scrollBy",direction:f,options:{amount:d,behavior:v,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(C)}}catch(C){let N=h?gt(Hn(h),h,x,f,d):void 0;return N?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-page-failed",details:C?.message||N?.error||"scroll_page failed",allowFallback:!0}}}async function cn(c,w,b,g){let f=G(c,w),d=X(f,b),h=!f.hidden,x=h?"smooth":"auto",m=Ca(g.position),v=or(c,f);if(!v){let C=Ms(c,f,d,m);return{success:C.success,method:"direct-scrollElement-no-selector",details:C.error,allowFallback:!C.success}}try{let C=await W(d,{action:"scrollElement",selector:v,position:m,options:{behavior:x,isTabActive:h}},{doc:f,timeoutMs:f.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(C)}}catch(C){let N=Ms(c,f,d,m);return N.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-to-element-failed",details:C?.message||N.error||"scroll_to_element failed",allowFallback:!0}}}function Ze(c,w,b,g,f){try{let d=G(c,w),h=X(d,b),x=h.WheelEvent||WheelEvent;Ve(c,d,h);let m=It(c,d,h);return m.dispatchEvent(new x("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,deltaX:g||0,deltaY:f||0,deltaMode:x.DOM_DELTA_PIXEL})),m.scrollBy({left:g||0,top:f||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function It(c,w,b){let g=G(c,w),f=X(g,b),d=g.scrollingElement||g.documentElement||g.body,h=c;for(;h&&h!==g.body&&h!==g.documentElement;){let m=f.getComputedStyle(h).overflowY;if((m==="auto"||m==="scroll"||m==="overlay")&&h.scrollHeight>h.clientHeight+5)return h;h=h.parentElement}return d}async function Le(c,w,b,g,f){try{let d=G(c,w),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.MouseEvent||MouseEvent,v=h.DragEvent||DragEvent,C=h.DataTransfer||DataTransfer;Ve(c,d,h);let N=ie(c,d,h),H=Ge(N.hit,h)?N.hit:c,Y=c.getBoundingClientRect(),Q=Number.isFinite(Number(g?.distance))?Number(g.distance):160,fe=0,J=0;switch(String(g?.direction||"").toUpperCase()){case"UP":J=-Q;break;case"DOWN":J=Q;break;case"LEFT":fe=-Q;break;case"RIGHT":fe=Q;break;default:fe=Number(g?.delta_x)||0,J=Number(g?.delta_y)||0}let Z=(I,D)=>({x:Math.max(2,Math.min(I,h.innerWidth-3)),y:Math.max(2,Math.min(D,h.innerHeight-3))}),se=Z(N.x,N.y),Ee=Z(N.x+fe,N.y+J),Pe=500+Date.now()%1e4,le=Math.max(12,Math.min(36,Number(g?.steps)||18)),be=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:I,clientY:D,pageX:I+(h.scrollX||0),pageY:D+(h.scrollY||0)}),we=(I,D,V)=>({...be(I,D),pointerId:Pe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(I,D,V)=>({...be(I,D),buttons:V,button:0});H.dispatchEvent(new x("pointerdown",we(se.x,se.y,1))),H.dispatchEvent(new m("mousedown",l(se.x,se.y,1)));try{H.setPointerCapture?.(Pe)}catch{}let E=null;try{(c.draggable||B(c,f).sourcesByType.has("dragstart"))&&(E=new C)}catch{E=null}if(E)try{c.dispatchEvent(new v("dragstart",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:E}))}catch{}let k=null;for(let I=1;I<=le;I++){let D=se.x+(Ee.x-se.x)*I/le,V=se.y+(Ee.y-se.y)*I/le,j=d.elementFromPoint(D,V)||c;if(j.dispatchEvent(new x("pointermove",we(D,V,1))),j.dispatchEvent(new m("mousemove",l(D,V,1))),E)try{k&&k!==j&&k.dispatchEvent(new v("dragleave",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),j.dispatchEvent(new v("dragover",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),k=j}catch{}I%3===0&&await At()}let R=d.elementFromPoint(Ee.x,Ee.y)||c;if(R.dispatchEvent(new x("pointerup",we(Ee.x,Ee.y,0))),R.dispatchEvent(new m("mouseup",l(Ee.x,Ee.y,0))),E)try{c.dispatchEvent(new v("dragend",{bubbles:!0,cancelable:!0,clientX:Ee.x,clientY:Ee.y,dataTransfer:E}))}catch{}return{success:!0,method:"drag",details:`dx=${fe};dy=${J};steps=${le};hitOk=${N.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function ln(c,w,b,g){try{let f=G(w,b),d=X(f,g),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.DragEvent||DragEvent,v=d.DataTransfer||DataTransfer,C=c?.source_element_id??c?.element_id,N=(C?Pt(f,String(C)):null)||w;if(!N)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let H=null,Y=Number(c?.target_x),Q=Number(c?.target_y);if(c?.target_element_id){if(H=Pt(f,String(c.target_element_id)),!H)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let R=H.getBoundingClientRect();Y=R.left+R.width/2,Q=R.top+R.height/2}if((!Number.isFinite(Y)||!Number.isFinite(Q))&&!H)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ve(N,f,d),H&&Ve(H,f,d);let fe=(R,I)=>({x:Math.max(2,Math.min(R,d.innerWidth-3)),y:Math.max(2,Math.min(I,d.innerHeight-3))}),J=N.getBoundingClientRect(),Z=fe(J.left+J.width/2,J.top+J.height/2),se=fe(Number(Y),Number(Q)),Ee=600+Date.now()%1e4,Pe=Math.max(14,Math.min(42,Number(c?.steps)||22)),le=(R,I)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:R,clientY:I,pageX:R+(d.scrollX||0),pageY:I+(d.scrollY||0)}),be=(R,I,D)=>({...le(R,I),pointerId:Ee,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:D?.5:0,buttons:D,button:0}),we=(R,I,D)=>({...le(R,I),buttons:D,button:0}),l=null;try{l=new v}catch{l=null}N.dispatchEvent(new h("pointerdown",be(Z.x,Z.y,1))),N.dispatchEvent(new x("mousedown",we(Z.x,Z.y,1)));try{N.setPointerCapture?.(Ee)}catch{}if(l)try{N.dispatchEvent(new m("dragstart",{bubbles:!0,cancelable:!0,clientX:Z.x,clientY:Z.y,dataTransfer:l}))}catch{}let E=null;for(let R=1;R<=Pe;R++){let I=Z.x+(se.x-Z.x)*R/Pe,D=Z.y+(se.y-Z.y)*R/Pe,V=f.elementFromPoint(I,D)||H||f.body;if(V.dispatchEvent(new h("pointermove",be(I,D,1))),V.dispatchEvent(new x("mousemove",we(I,D,1))),l)try{E&&E!==V&&E.dispatchEvent(new m("dragleave",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragenter",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragover",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),E=V}catch{}R%3===0&&await At()}let k=H||f.elementFromPoint(se.x,se.y)||f.body;if(l)try{k.dispatchEvent(new m("drop",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}if(k.dispatchEvent(new h("pointerup",be(se.x,se.y,0))),k.dispatchEvent(new x("mouseup",we(se.x,se.y,0))),l)try{N.dispatchEvent(new m("dragend",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Pe};source=${String(C)}`}}catch(f){return{success:!1,method:"drag-drop",details:f?.message||"drag-drop failed",allowFallback:!0}}}async function un(c,w,b,g){try{let f=G(c,w),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent;Ve(c,f,d);let m=ie(c,f,d),v={x:m.x,y:m.y},C=c.getBoundingClientRect(),N=Number.isFinite(Number(g?.distance))?Number(g.distance):Math.min(Math.max(80,Math.min(C.width,C.height)),220),H=String(g?.direction||"RIGHT").toUpperCase(),Y=v.x,Q=v.y;H==="LEFT"&&(Y-=N),H==="RIGHT"&&(Y+=N),H==="UP"&&(Q-=N),H==="DOWN"&&(Q+=N);let fe=(I,D)=>({x:Math.max(2,Math.min(I,d.innerWidth-3)),y:Math.max(2,Math.min(D,d.innerHeight-3))}),J=fe(v.x,v.y),Z=fe(Y,Q),se=700+Date.now()%1e4,Ee=Math.max(10,Math.min(28,Number(g?.steps)||16)),Pe=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:I,clientY:D,pageX:I+(d.scrollX||0),pageY:D+(d.scrollY||0)}),le=(I,D,V)=>({...Pe(I,D),pointerId:se,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),be=(I,D,V)=>({...Pe(I,D),buttons:V,button:0}),we=f.elementFromPoint(J.x,J.y)||c;we.dispatchEvent(new h("pointerdown",le(J.x,J.y,1))),we.dispatchEvent(new x("mousedown",be(J.x,J.y,1)));let l=d.Touch,E=d.TouchEvent,k=!!l&&!!E;if(k)try{let I=new l({identifier:se,target:we,clientX:J.x,clientY:J.y,pageX:J.x,pageY:J.y,screenX:J.x,screenY:J.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});we.dispatchEvent(new E("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[I],targetTouches:[I],changedTouches:[I]}))}catch{}for(let I=1;I<=Ee;I++){let D=J.x+(Z.x-J.x)*I/Ee,V=J.y+(Z.y-J.y)*I/Ee,j=f.elementFromPoint(D,V)||c;if(j.dispatchEvent(new h("pointermove",le(D,V,1))),j.dispatchEvent(new x("mousemove",be(D,V,1))),k)try{let ae=new l({identifier:se,target:j,clientX:D,clientY:V,pageX:D,pageY:V,screenX:D,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});j.dispatchEvent(new E("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ae],targetTouches:[ae],changedTouches:[ae]}))}catch{}I%3===0&&await At()}let R=f.elementFromPoint(Z.x,Z.y)||c;if(R.dispatchEvent(new h("pointerup",le(Z.x,Z.y,0))),R.dispatchEvent(new x("mouseup",be(Z.x,Z.y,0))),k)try{let I=new l({identifier:se,target:R,clientX:Z.x,clientY:Z.y,pageX:Z.x,pageY:Z.y,screenX:Z.x,screenY:Z.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});R.dispatchEvent(new E("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[I]}))}catch{}return{success:!0,method:"swipe",details:`dir=${H};dist=${N};steps=${Ee};hitOk=${m.ok}`}}catch(f){return{success:!1,method:"swipe",details:f?.message||"swipe failed",allowFallback:!0}}}async function Fe(c,w,b,g){try{let f=c||w.body,d=G(f,w),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.WheelEvent||WheelEvent;Ve(f,d,h);let v=Number.isFinite(Number(g?.scale))?Number(g.scale):1.2,C=f.getBoundingClientRect(),N=C.left+C.width/2,H=C.top+C.height/2,Y=24,Q=Math.max(6,Math.min(200,Y*v)),fe=Math.max(6,Math.min(18,Number(g?.steps)||10)),J=h.Touch,Z=h.TouchEvent;if(!!J&&!!Z)try{let le=(k,R)=>new J({identifier:k,target:f,clientX:R,clientY:H,pageX:R,pageY:H,screenX:R,screenY:H,radiusX:1,radiusY:1,rotationAngle:0,force:1}),be=le(911,N-Y),we=le(912,N+Y);f.dispatchEvent(new Z("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[be,we],targetTouches:[be,we],changedTouches:[be,we]}));for(let k=1;k<=fe;k++){let R=Y+(Q-Y)*k/fe,I=le(911,N-R),D=le(912,N+R);f.dispatchEvent(new Z("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[I,D],targetTouches:[I,D],changedTouches:[I,D]})),k%2===0&&await At()}let l=le(911,N-Q),E=le(912,N+Q);f.dispatchEvent(new Z("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,E]}))}catch{}try{let le=(be,we,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:we,clientY:H,pointerId:be,pointerType:"touch",isPrimary:be===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});f.dispatchEvent(new x("pointerdown",le(821,N-Y,1))),f.dispatchEvent(new x("pointerdown",le(822,N+Y,1)));for(let be=1;be<=fe;be++){let we=Y+(Q-Y)*be/fe;f.dispatchEvent(new x("pointermove",le(821,N-we,1))),f.dispatchEvent(new x("pointermove",le(822,N+we,1))),be%2===0&&await At()}f.dispatchEvent(new x("pointerup",le(821,N-Q,0))),f.dispatchEvent(new x("pointerup",le(822,N+Q,0)))}catch{}try{let Ee=v>=1?-120:120;f.dispatchEvent(new m("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:N,clientY:H,ctrlKey:!0,deltaY:Ee,deltaMode:m.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${v};steps=${fe}`}}catch(f){return{success:!1,method:"pinch-zoom",details:f?.message||"pinch-zoom failed",allowFallback:!0}}}async function wn(c,w,b,g=800){try{let f=G(c,w),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.FocusEvent||FocusEvent;Ve(c,f,d);let v=ie(c,f,d),C=c;!v.ok&&Ge(v.hit,d)?C=v.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||v.hit:Ge(v.hit,d)&&(C=v.hit);let N=Jt(C,f,d),H=v.x,Y=v.y,Q=1+Date.now()%1e4,fe={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:H,clientY:Y,pageX:H+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:H+(d.screenX||0),screenY:Y+(d.screenY||0)},J={...fe,pointerId:Q,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{C.dispatchEvent(new h("pointerover",J)),C.dispatchEvent(new h("pointerenter",{...J,bubbles:!1}))}catch{}try{C.dispatchEvent(new x("mouseover",fe)),C.dispatchEvent(new x("mouseenter",{...fe,bubbles:!1}))}catch{}try{C.focus?.({preventScroll:!0}),C.dispatchEvent(new m("focus",{bubbles:!0,composed:!0})),C.dispatchEvent(new m("focusin",{bubbles:!0,composed:!0}))}catch{}try{C.dispatchEvent(new h("pointerdown",{...J,buttons:1,pressure:.5}))}catch{}try{C.dispatchEvent(new x("mousedown",{...fe,buttons:1,button:0}))}catch{}try{let le=d.Touch,be=d.TouchEvent;if(typeof le<"u"&&typeof be<"u"){let we=new le({identifier:Q,target:C,clientX:H,clientY:Y,pageX:H+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:H+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});C.dispatchEvent(new be("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[we],targetTouches:[we],changedTouches:[we]}))}}catch{}let Z=Number(g),se=Number.isFinite(Z)&&Z>0?Z:800,Ee=f.hidden?Math.max(se,1200):se;await Qe(Ee,f);try{C.dispatchEvent(new x("contextmenu",{...fe,button:2,buttons:2}))}catch{}try{C.dispatchEvent(new h("pointerup",{...J,buttons:0,pressure:0}))}catch{}try{C.dispatchEvent(new x("mouseup",{...fe,buttons:0,button:0}))}catch{}try{let le=d.Touch,be=d.TouchEvent;if(typeof le<"u"&&typeof be<"u"){let we=new le({identifier:Q,target:C,clientX:H,clientY:Y,pageX:H+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:H+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});C.dispatchEvent(new be("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[we]}))}}catch{}let Pe=await Oe(C,f,d,N);return{success:!0,method:"long-press",details:`holdMs=${Ee};verified=${Pe};hitOk=${v.ok};target=${C.tagName.toLowerCase()}`}}catch(f){return{success:!1,method:"long-press",details:f?.message||"long-press failed",allowFallback:!0}}}function $t(c,w,b,g,f){try{let d=G(b,g),x=X(d,f).KeyboardEvent||KeyboardEvent,m=b||d.activeElement||d.body||d.documentElement;m.focus?.();let v={key:c,code:Zt(c),bubbles:!0,cancelable:!0,ctrlKey:w?.includes("CTRL"),altKey:w?.includes("ALT"),shiftKey:w?.includes("SHIFT"),metaKey:w?.includes("META")},C=m.dispatchEvent(new x("keydown",v)),N=m.dispatchEvent(new x("keypress",v)),H=m.dispatchEvent(new x("keyup",v));if(c==="Enter"&&!!(C&&N&&H)){let Q=m.form||m.closest?.("form");Q?.requestSubmit?Q.requestSubmit():Q?.submit?.()}return{success:!0,method:"press-key"}}catch(d){return{success:!1,method:"press-key",details:d.message,allowFallback:!0}}}async function Qt(c,w,b){try{let g=c.innerText||c.value||"";if(!g)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let f=G(c,w),d=X(f,b);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(g),{success:!0,method:"clipboard-copy"};let h=f.createRange();h.selectNodeContents(c);let x=d.getSelection?.()||(f.defaultView||window).getSelection?.();x?.removeAllRanges(),x?.addRange(h);let m=f.execCommand?.("copy")??!1;return x?.removeAllRanges(),{success:!!m,method:"execCommand-copy",allowFallback:!m}}catch(g){return{success:!1,method:"clipboard-copy",details:g.message,allowFallback:!0}}}async function dn(c,w,b,g){try{c.focus?.();let f=G(c,w),d=X(f,b);if(d.navigator?.clipboard?.readText){let x=await d.navigator.clipboard.readText();if(x)return await ot(c,f,d,x,g)}return f.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(f){return{success:!1,method:"paste",details:f.message,allowFallback:!0}}}function yn(c){return`${(c/1024).toFixed(1)}KB`}function _n(c,w){if(c instanceof w.defaultView.HTMLInputElement){let h=c;if((h.type||"").toLowerCase()==="file")return h}let b=c.closest?.("label"),g=b?.htmlFor||c.htmlFor||"";if(g){let h=w.getElementById(g);if(h&&(h.type||"").toLowerCase()==="file")return h}if(b){let h=b.querySelector?.('input[type="file"]');if(h)return h}let f=c.closest?.("form");if(f){let h=f.querySelector?.('input[type="file"]');if(h)return h}let d=c.closest?.("div,section,main,article")||c.parentElement;if(d){let h=d.querySelector?.('input[type="file"]');if(h)return h}return null}function St(c,w,b){try{let g=b.HTMLInputElement?.prototype,f=g?Object.getOwnPropertyDescriptor(g,"files")?.set:void 0;if(!f){let d=Object.getPrototypeOf(c);for(;d&&!f;)f=Object.getOwnPropertyDescriptor(d,"files")?.set,d=Object.getPrototypeOf(d)}return f?(f.call(c,w),!0):(c.files=w,!0)}catch{try{return c.files=w,!0}catch{return!1}}}async function Dt(c,w,b,g,f,d){try{let{file_url:h,element_id:x,file_name:m}=c,v=null;if(f&&(v=_n(f,w)),!v&&x!==void 0&&(v=w.querySelector(`input[type="file"][${it}*="[id=${x}]"]`)),!v){let R=w.querySelectorAll('input[type="file"]');for(let I of R){if(I.disabled)continue;let D=I.getBoundingClientRect();if(D.width>0&&D.height>0){v=I;break}}}if(!v)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(v.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let C=G(v,w),N=X(C,b);if(!(g?.kind==="upload_file"&&typeof g.byteLength=="number"&&g.byteLength>=0&&typeof g.mimeType=="string"&&(typeof g.inlineB64=="string"||typeof g.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let Y=Number(g.byteLength),Q=(g.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",fe;if(g.inlineB64&&typeof g.inlineB64=="string"){let R=Ia(g.inlineB64);if(R.byteLength!==Y)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${R.byteLength} expected=${Y}`,allowFallback:!0};fe=R.buffer}else{let R=String(g.token);fe=await S(N,R,Y,9e4)}let J=N.Blob||Blob,Z=new J([fe],{type:Q}),se=m||g?.fileName;!se&&h&&typeof h=="string"&&(se=As(h,N)),se=ka(se||"upload");let Ee=N.File||File,Pe=new Ee([Z],se,{type:Q,lastModified:Date.now()}),le=N.Event||Event,be=N.DataTransfer||DataTransfer;if(!be)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let we=new be;if(we.items.add(Pe),!St(v,we.files,N))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};v.dispatchEvent(new le("input",{bubbles:!0,composed:!0,cancelable:!0})),v.dispatchEvent(new le("change",{bubbles:!0,composed:!0,cancelable:!0}));let E=en(v);if(E){let R=qt(E);if(R.onChange){let I=Yt("change",v,C,N);I.target.files=we.files,R.onChange(I)}}let k=xn(v);if(k){let R=Ct(k);if(R.change){let I=new le("change",{bubbles:!0});I.target=v,I.target.files=we.files,R.change(I)}}try{let R=N.jQuery||N.$;R&&typeof R=="function"&&R(v).triggerHandler?.("change")}catch{}return v.focus?.({preventScroll:!0}),await _e(C,N,2),{success:!0,method:"upload-file",details:`Uploaded ${se} (${yn(Z.size)}) [token]`}}catch(h){return{success:!1,method:"upload-file",details:h?.message||"Upload failed",allowFallback:!0}}}async function lt(c,w,b){let g=Array.isArray(c.path)?c.path:[];if(!g.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let f=b.PointerEvent||PointerEvent,d=b.MouseEvent||MouseEvent,h=16;for(let x=0;x<g.length;x++){let m=g[x],v=Number(m.x)||0,C=Number(m.y)||0,N=Number(m.pressure)||(x===0||x===g.length-1?0:.5),H=w.elementFromPoint(v,C)||w.documentElement,Y={bubbles:!0,cancelable:!0,clientX:v,clientY:C,screenX:v,screenY:C,view:b};if(x===0?(H.dispatchEvent(new f("pointerdown",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),H.dispatchEvent(new d("mousedown",{...Y,button:0,buttons:1}))):(H.dispatchEvent(new f("pointermove",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),H.dispatchEvent(new d("mousemove",{...Y,button:0,buttons:1}))),x===g.length-1&&(H.dispatchEvent(new f("pointerup",{...Y,pressure:0,pointerId:1,pointerType:"mouse"})),H.dispatchEvent(new d("mouseup",{...Y,button:0,buttons:0}))),x<g.length-1){let Q=Number(m.timestamp)||0,fe=Number(g[x+1].timestamp)||0,J=Q&&fe?Math.max(0,Math.min(fe-Q,1e3)):h;J>0&&await Qe(J,w)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${g.length} point(s)`}}function Ot(c,w,b){let g=G(c,w),f=X(g,b),d=f.MouseEvent||MouseEvent;Ve(c,g,f),te(c,g,f),te(c,g,f);let h=c.getBoundingClientRect();return c.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:h.left+h.width/2,clientY:h.top+h.height/2,detail:2,view:f})),{success:!0,method:"dblclick"}}function pe(c,w,b){let g=G(c,w),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent;Ve(c,g,f);let x=c.getBoundingClientRect(),m=x.left+x.width/2,v=x.top+x.height/2,C={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:m,clientY:v,button:2,buttons:2};return c.dispatchEvent(new d("pointerdown",C)),c.dispatchEvent(new h("mousedown",C)),c.dispatchEvent(new d("pointerup",{...C,buttons:0})),c.dispatchEvent(new h("mouseup",{...C,buttons:0})),c.dispatchEvent(new h("contextmenu",C)),{success:!0,method:"contextmenu"}}function Jt(c,w,b){let g=G(c,w),f=X(g,b),d=c,h=c.getBoundingClientRect();return{href:String(f.location.href),hash:String(f.location.hash),ariaExpanded:c.getAttribute("aria-expanded"),ariaPressed:c.getAttribute("aria-pressed"),ariaDisabled:c.getAttribute("aria-disabled"),disabled:!!d.disabled,open:typeof d.open<"u"?d.open:void 0,checked:typeof d.checked<"u"?d.checked:void 0,value:typeof d.value<"u"?d.value:void 0,active:mo(g),rect:{w:h.width,h:h.height}}}function Gt(c,w){let b=Math.abs(c.rect.w-w.rect.w)>2||Math.abs(c.rect.h-w.rect.h)>2;return c.href!==w.href||c.hash!==w.hash||c.ariaExpanded!==w.ariaExpanded||c.ariaPressed!==w.ariaPressed||c.ariaDisabled!==w.ariaDisabled||c.disabled!==w.disabled||c.open!==w.open||c.checked!==w.checked||c.value!==w.value||c.active!==w.active||b}async function Oe(c,w,b,g){await Promise.resolve();let f=G(c,w),d=X(f,b);w.hidden||await At();let h=Jt(c,f,d);return Gt(g,h)}function et(c,w,b){c.focus?.({preventScroll:!0});let g=G(c,w),f=X(g,b),x=c.getAttribute("role")==="button"||fi(c,f)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],m=f.KeyboardEvent||KeyboardEvent;for(let v of x){let C={key:v,code:v===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new m("keydown",C)),c.dispatchEvent(new m("keypress",C)),c.dispatchEvent(new m("keyup",C))}return{success:!0,method:"keyboard-activate"}}async function Br(c,w,b,...g){let f=null;for(let d of g){let h=G(c,w),x=X(h,b),m=Jt(c,h,x),v=d();if(!v||!v.success)continue;if(await Oe(c,h,x,m))return{...v,details:(v.details?v.details+";":"")+"verified=true"};f=v}return f?{...f,details:(f.details?f.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function vn(...c){for(let w of c)try{let b=w();if(b&&b.success)return b}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ve(c,w,b){let g=G(c,w),f=X(g,b),d=c.getBoundingClientRect();d.top>=0&&d.left>=0&&d.bottom<=f.innerHeight&&d.right<=f.innerWidth||(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),c.offsetHeight)}function Tn(c,w,b,g){let f=G(c,w),h=X(f,b).KeyboardEvent||KeyboardEvent;for(let x of g){let m=String(x??""),v="";/^[a-z]$/i.test(m)?v=`Key${m.toUpperCase()}`:/^[0-9]$/.test(m)?v=`Digit${m}`:m===" "&&(v="Space");let C=m.length===1?m.charCodeAt(0):0,N={key:m,code:v,bubbles:!0,cancelable:!0,composed:!0,keyCode:C,which:C};c.dispatchEvent(new h("keydown",N)),c.dispatchEvent(new h("keypress",N)),c.dispatchEvent(new h("keyup",N))}}function $n(c,w,b){let g=G(c,w),d=X(g,b).KeyboardEvent||KeyboardEvent,h={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},x=c.dispatchEvent(new d("keydown",h)),m=c.dispatchEvent(new d("keypress",h)),v=c.dispatchEvent(new d("keyup",h));if(!!(x&&m&&v)){let N=c.form||c.closest?.("form");N?.requestSubmit?.()??N?.submit?.()}}function Zt(c){return{Enter:"Enter",Tab:"Tab",Escape:"Escape",Space:"Space"," ":"Space",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Backspace:"Backspace",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12"}[c]||`Key${c.toUpperCase()}`}let Gn=new MessageChannel,qn=[];Gn.port1.onmessage=()=>{let c=qn.shift();c&&c()};function At(){return new Promise(c=>{qn.push(c),Gn.port2.postMessage(0)})}function en(c){let w=g=>{if(!g)return null;let f=Object.keys(g);for(let d of f)if(d.startsWith("__reactFiber")||d.startsWith("__reactInternalInstance")||d.includes("reactFiber")||d.includes("reactProps")||d.includes("reactEventHandlers")||/^__r\d+/.test(d))return g[d];return null},b=c;for(let g=0;g<4&&b;g++){let f=w(b);if(f)return f;b=b.parentElement}return null}function qt(c){let w={},b=c,g=0;for(;b&&g++<10;){let f=[b.memoizedProps,b.pendingProps,b.stateNode?.props,b._memoizedProps,b._pendingProps,b.alternate?.memoizedProps].filter(Boolean);for(let d of f)if(!(!d||typeof d!="object"))for(let h in d)h.startsWith("on")&&typeof d[h]=="function"&&(w[h]=d[h]);if(Object.keys(w).length)break;b=b.return||b.alternate}return w}function ur(c,w){let b=c;for(;b;){if(b._reactRootContainer||b.__reactContainer||b.hasAttribute("data-reactroot")||b.hasAttribute("data-react-root")||["root","app","__next"].includes(b.id))return b;b=b.parentElement}return G(c,w).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Yt(c,w,b,g){let f=G(w,b),d=X(f,g),h=d.MouseEvent||MouseEvent,x=w.getBoundingClientRect(),m=new h(c,{bubbles:!0,cancelable:!0,view:d,clientX:x.left+x.width/2,clientY:x.top+x.height/2});return{type:c,target:w,currentTarget:w,bubbles:!0,cancelable:!0,nativeEvent:m,isTrusted:!0,preventDefault(){m.preventDefault()},stopPropagation(){m.stopPropagation()}}}function xn(c){let w=c;if(w.__vue__)return w.__vue__;if(w.__vueParentComponent)return w.__vueParentComponent;if(w._vnode)return w._vnode;let b=c.parentElement;for(let g=0;g<3&&b;g++){let f=b;if(f.__vue__||f.__vueParentComponent||f._vnode)return f.__vue__||f.__vueParentComponent||f._vnode;b=b.parentElement}return null}function Ct(c){let w={};if(c?.$listeners&&Object.assign(w,c.$listeners),c?._events)for(let b in c._events){let g=c._events[b];w[b]=Array.isArray(g)?g[0]:g}if(c?.props)for(let b in c.props)b.startsWith("on")&&typeof c.props[b]=="function"&&(w[b.substring(2).toLowerCase()]=c.props[b]);if(c?.vnode?.props)for(let b in c.vnode.props)b.startsWith("on")&&typeof c.vnode.props[b]=="function"&&(w[b.substring(2).toLowerCase()]=c.vnode.props[b]);return w}})();function Ma(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function La(e){let t=window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.actions?.execute;if(typeof o!="function")throw new Error("Rover main-world action executor not initialized");return o(e)}function yo(e,t,n={}){let{rootNodes:r,semanticNodes:o}=ys(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),s={};for(let a of Object.keys(o)){let i=Number(a);if(!Number.isFinite(i))continue;let u=Tr(i);u&&(s[i]=t.getFrameworkMetadata(u))}return{rootNodes:r,semanticNodes:o,elementMeta:s}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(p=document,_=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=p,this.win=_,this.viewport={width:_.innerWidth,height:_.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let _=this.detectPrimaryScrollable();if(!_)return null;let{target:A,isRoot:S}=this.getScrollContext(_.element),M=A.scrollHeight,O=zt(),W=S&&O?O.innerHeight:A.clientHeight,q=Math.max(0,M-W),U=A.scrollTop;return{selector:_.selector,score:_.score,type:_.type,metrics:{scrollTop:U,scrollHeight:M,clientHeight:W,isAtTop:U<=5,isAtBottom:U>=q-5}}}case"scrollTo":if(!p.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(p.direction,p.options);case"scrollBy":if(!p.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(p.direction,p.options);case"scrollElement":if(!p.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(p.selector,p.position,p.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${p.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(p){return this.handleCommand(p)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let S=Array.from(this.detectionCache.values()).sort((M,O)=>O.score-M.score)[0];if(S)return this.lastDetectedPrimary=S.element,S}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let S=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!S)return null;let M=this.buildFeatures(S),O=G(S,this.doc),W={element:S,selector:or(S,O),score:.5,features:M,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(W.selector,W),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=S,W}let _=this.scoreCandidates(p);if(_.length===0)return null;this.detectionCache.clear();for(let S of _)this.detectionCache.set(S.selector,S);this.lastDetectionTime=Date.now();let A=_[0];return A&&(this.lastDetectedPrimary=A.element),A||null}collectAllElementsDeep(p,_=15e4){let A=[],S=[],M=p.body||p.documentElement;M&&S.push(M);let O=0,W=q=>{try{let U=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",B=this.win[U]?.shadow?.getRoot;if(typeof B=="function"){let z=B(q);if(z)return z}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;S.length&&!(++O>_);){let q=S.pop();if(vt(q)){let B=q.children;for(let z=B.length-1;z>=0;z--)S.push(B[z]);continue}let U=q,P=oe(U);Ge(U,P)&&A.push(U);try{let B=W(U);B&&S.push(B)}catch{}for(let B=U.lastElementChild;B;B=B.previousElementSibling)S.push(B)}return A}collectScrollableCandidates(){let p=[],_=new WeakSet,A=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let M of A){if(!M||_.has(M))continue;let O=this.isScrollable(M);(O.vertical||O.horizontal)&&(p.push(M),_.add(M))}let S=this.collectAllElementsDeep(this.doc);for(let M of Array.from(S)){if(_.has(M))continue;let O=M.getBoundingClientRect(),W=this.win.getComputedStyle(M);if(!this.isElementRendered(M,O,W)||!this.isScrollable(M).vertical)continue;let U=40,P=this.viewport.width*.15;if(O.height<U||O.width<P){let B=(M.className||"").toLowerCase().includes("scroll"),z=W.overflowY==="auto"||W.overflowY==="scroll"||W.overflow==="auto"||W.overflow==="scroll";if(!B&&!z)continue}p.push(M),_.add(M)}return p}isElementRendered(p,_,A){if(A.display==="none"||A.visibility==="hidden")return!1;let S=parseFloat(A.opacity||"1");return!(!Number.isNaN(S)&&S<.01||_.width<=1||_.height<=1)}isScrollable(p){let _=this.win.getComputedStyle(p),A=_.overflowY,S=_.overflowX,M=this.doc.scrollingElement,O=p===this.doc.documentElement||p===this.doc.body||!!M&&p===M,W=p.scrollHeight,q=p.clientHeight,U=p.scrollWidth,P=p.clientWidth;if(O){let ne=this.doc.documentElement,ue=this.doc.body;W=Math.max(ne?ne.scrollHeight:0,ue?ue.scrollHeight:0),q=this.win.innerHeight}let B=W-q>8,z=U-P>8,te=A==="auto"||A==="scroll"||A==="overlay",re=S==="auto"||S==="scroll"||S==="overlay";return{vertical:O?B:B&&te,horizontal:O?z:z&&re,byOverflow:te||re}}calculateVisibleIntersection(p){let _=Math.max(0,p.left),A=Math.max(0,p.top),S=Math.min(this.viewport.width,p.right),M=Math.min(this.viewport.height,p.bottom),O=Math.max(0,S-_),W=Math.max(0,M-A);return{width:O,height:W,area:O*W}}analyzeTextContent(p,_=2e3){let A=0,S=0,M=p.ownerDocument||this.doc,W=(M.defaultView||this.win).NodeFilter||NodeFilter,q=M.createTreeWalker(p,W.SHOW_ELEMENT|W.SHOW_TEXT,null),U=0,P=q.currentNode,B=[];for(;P&&U<_;){if(P.nodeType===Node.TEXT_NODE){let K=(P.textContent||"").replace(/\s+/g,"").length;if(K>0){A+=K;let ce=P.parentElement;ce&&ce.closest("a")&&(S+=K)}}else P.nodeType===Node.ELEMENT_NODE&&B.push(P);U++,P=q.nextNode()}let z=B.length||1,te=A/z,re=A>0?S/A:0;return{textChars:A,linkChars:S,textDensity:te,linkDensity:re}}calculateRepetitionScore(p){let _=Array.from(p.children);if(_.length<3)return 0;let A=_.slice(0,50),S=new Map,M=new Map,O=new Map;for(let ie of A){let K=oe(ie);if(!Ge(ie,K))continue;let ce=ie.getBoundingClientRect();if(ce.height<5||ce.width<this.viewport.width*.1)continue;let ne=Math.round(ce.height/10)*10,ue=Math.round(ce.width/10)*10;S.set(ne,(S.get(ne)||0)+1),M.set(ue,(M.get(ue)||0)+1);let ge=(ie.className||ie.tagName).toString();O.set(ge,(O.get(ge)||0)+1)}let W=A.length||1,q=Math.max(0,...S.values()),U=Math.max(0,...M.values()),P=Math.max(0,...O.values()),B=q/W,z=U/W,te=P/W,re=.4*B+.3*z+.3*te;return Math.min(1,Math.max(0,re))}calculateSemanticScore(p){let _=0,A=null,S=!1,M=(p.getAttribute("role")||"").toLowerCase(),O=p.tagName.toLowerCase(),W=(p.id||"").toLowerCase(),q=(p.className||"").toLowerCase(),U=`${M} ${O} ${W} ${q}`;return(O==="main"||M==="main")&&(_+=1.2,A="article"),O==="article"&&(_+=1,A=A||"article"),(M==="feed"||U.includes("feed"))&&(_+=1,A="feed"),(M==="log"||U.includes("chat")||U.includes("messages"))&&(_+=1,A="chat"),U.includes("content")&&(_+=.5),(U.includes("results")||U.includes("list"))&&(_+=.4),(U.includes("job")||U.includes("jobs"))&&(_+=.4),(O==="nav"||M==="navigation"||U.includes("sidebar"))&&(_-=1,S=!0),(O==="aside"||M==="complementary")&&(_-=.7,S=!0),(O==="footer"||M==="contentinfo"||U.includes("footer"))&&(_-=.8,S=!0),U.includes("header")&&(_-=.6),_=Math.max(-1,Math.min(1,_)),{semanticScore:_,typeHint:A,navLike:S}}detectScrollListeners(p){return[p.querySelector('[class*="infinite"]'),p.querySelector('[class*="load-more"]'),p.querySelector("[data-infinite]"),p.querySelector('[loading="lazy"]'),p.querySelector(".observer-target"),p.querySelector("[data-scroll]")].some(A=>A!==null)}buildFeatures(p){let _=p.getBoundingClientRect(),A=this.win.getComputedStyle(p),S=this.calculateVisibleIntersection(_),M=this.viewport.width*this.viewport.height||1,O=S.area/M,W=this.viewport.width>0?S.width/this.viewport.width:0,q=_.top+_.height/2,U=this.viewport.height/2||1,P=Math.min(1,Math.abs(q-U)/U),B=this.isScrollable(p),z=this.doc.scrollingElement,te=p===this.doc.documentElement||p===this.doc.body||!!z&&p===z,re=p.scrollHeight,ie=p.clientHeight;if(te){let Ce=this.doc.documentElement,Je=this.doc.body;re=Math.max(Ce?Ce.scrollHeight:0,Je?Je.scrollHeight:0),ie=this.win.innerHeight}let K=Math.max(0,re-ie),ce=K*S.width,ne=this.analyzeTextContent(p),ue=this.calculateRepetitionScore(p),ge=this.calculateSemanticScore(p),ht=p.contains(this.doc.activeElement),_e=this.detectScrollListeners(p),De=parseInt(A.zIndex||"0",10),He=Number.isFinite(De)?De:0;return{geometry:{viewportCoverage:O,widthProminence:W,centerDistance:P,scrollCapacity:K,scrollSurface:ce,zIndex:He},content:{textDensity:ne.textDensity,linkDensity:ne.linkDensity,repetitionScore:ue,semanticScore:ge.semanticScore},interaction:{hasScrollListeners:_e,hasFocus:ht,recentActivity:ht?1:0}}}inferElementType(p,_,A,S){if(A)return A;let M=(p.getAttribute("role")||"").toLowerCase(),O=(p.className||"").toLowerCase(),W=p.tagName.toLowerCase(),q=_.geometry,U=_.content;if(M==="log"||O.includes("chat")||O.includes("messages"))return"chat";let P=this.win.getComputedStyle(p);if((P.position==="fixed"||P.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(M==="feed"||U.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(W==="article"||U.textDensity>40&&U.linkDensity<.4&&q.widthProminence>.4)return"article";if(S||q.widthProminence<.3&&U.linkDensity>.3)return"sidebar";let z=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||z&&p===z?"document":"unknown"}scoreCandidates(p){let _=[],A=[],S=[],M=[],O=[],W=[];for(let te of p){let re=this.buildFeatures(te),ie=re.content.semanticScore,K=this.calculateSemanticScore(te),ce=this.inferElementType(te,re,K.typeHint,K.navLike);W.push({element:te,features:{geometry:{...re.geometry},content:{...re.content,semanticScore:K.semanticScore},interaction:re.interaction},type:ce,navLike:K.navLike,semanticScore:K.semanticScore}),A.push(re.geometry.scrollSurface),S.push(re.content.textDensity),M.push(Math.abs(K.semanticScore)),O.push(re.content.repetitionScore)}let q=Math.max(0,...A),U=Math.max(0,...S),P=Math.max(0,...M),B=Math.max(0,...O),z=-1/0;for(let te of W){let{element:re,features:ie,type:K,navLike:ce,semanticScore:ne}=te,ue=ie.geometry,ge=ie.content,ht=ie.interaction,_e=q>0?ue.scrollSurface/q:0,De=U>0?ge.textDensity/U:0,He=P>0?(ne/P+1)/2:.5,Ce=K==="feed"||ge.repetitionScore>.3&&ue.scrollCapacity>400,Je=ge.linkDensity>.5?(ge.linkDensity-.5)/.5:0,ot=Ce?0:Je,wt=(Ce?1:.5)*ge.repetitionScore*Math.min(1,ue.scrollCapacity/4e3),st={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[K]||0,ke=0;ke+=ue.viewportCoverage*.18,ke+=ue.widthProminence*.15,ke+=(1-ue.centerDistance)*.07,ke+=_e*.22,ke+=wt*.18,ke+=De*.08,ke+=(B>0?ge.repetitionScore/B:0)*.05,ke+=He*.07,ke-=ot*.05,ht.hasFocus&&(ke+=.05),ht.hasScrollListeners&&(ke+=.05),ke+=st,ce&&(ke-=.05);let Me=Math.max(0,Math.min(1,ke));Me>z&&(z=Me),_.push({element:re,selector:or(re,G(re)),score:Me,features:ie,type:K})}if(_.sort((te,re)=>re.score-te.score),_.length>=2){let te=_[0],re=_[1];Math.abs(te.score-re.score)<.08&&te.type==="article"&&re.type==="feed"&&(_[0]=re,_[1]=te)}return _}getScrollContext(p){let _=document.scrollingElement;return p===document.documentElement||p===document.body||!!_&&p===_?{target:_||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=G(S),W=X(O),q=_?.isTabActive??!O.hidden,U=_?.behavior,P=q&&U==="smooth",B=M?Math.max(O.documentElement?O.documentElement.scrollHeight:0,O.body?O.body.scrollHeight:0):S.scrollHeight,z=M?W.innerHeight:S.clientHeight,te=Math.max(0,B-z),re=()=>M?W.scrollY:S.scrollTop,ie=K=>{if(P)try{M?W.scrollTo({top:K,behavior:"smooth"}):S.scrollTo({top:K,behavior:"smooth"})}catch{M?(O.scrollingElement||O.documentElement||O.body).scrollTop=K:S.scrollTop=K}else if(M){let ce=O.scrollingElement||O.documentElement||O.body;ce.scrollTop=K}else S.scrollTop=K};switch(p){case Ue.TOP:return ie(0),{success:!0,scrollTop:0,isAtTop:!0};case Ue.BOTTOM:return ie(te),{success:!0,scrollTop:te,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=_?.isTabActive??!document.hidden,W=_?.behavior,q=O&&W==="smooth",U=zt(),P=M&&U?U.innerHeight:S.clientHeight,B=M&&U?U.innerWidth:S.clientWidth,z=_?.amount??P*.8,te=M?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):S.scrollHeight,re=M&&U?U.innerHeight:S.clientHeight,ie=Math.max(0,te-re),K=ne=>{if(q)try{M?U?.scrollTo({top:ne,behavior:"smooth"}):S.scrollTo({top:ne,behavior:"smooth"})}catch{let ue=document.scrollingElement||document.documentElement||document.body;ue.scrollTop=ne}else{let ue=M?document.scrollingElement||document.documentElement||document.body:S;ue.scrollTop=ne}},ce=ne=>{if(q)try{S.scrollBy({left:ne,behavior:"smooth"})}catch{S.scrollLeft+=ne}else S.scrollLeft+=ne};switch(p){case Ue.DOWN:{let ue=(M&&U?U.scrollY:S.scrollTop)+z;K(ue);let ge=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:ge,isAtTop:ge<=5,isAtBottom:ge>=ie-5}}case Ue.UP:{let ne=M&&U?U.scrollY:S.scrollTop,ue=Math.max(0,ne-z);K(ue);let ge=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:ge,isAtTop:ge<=5,isAtBottom:ge>=ie-5}}case Ue.LEFT:{let ne=-(_?.amount??B*.8);return ce(ne),{success:!0,scrollLeft:S.scrollLeft}}case Ue.RIGHT:{let ne=_?.amount??B*.8;return ce(ne),{success:!0,scrollLeft:S.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case rt.START:return"start";case rt.END:return"end";case rt.NEAREST:return"nearest";case rt.CENTER:default:return"center"}}getScrollContainerForElement(p){let _=document.scrollingElement,A=p;for(;A&&A!==document.body&&A!==document.documentElement;){let O=getComputedStyle(A).overflowY,W=O==="auto"||O==="scroll"||O==="overlay",q=A.scrollHeight-A.clientHeight>8;if(W&&q)return{container:A,isRoot:!1};A=A.parentElement}return{container:_||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,_,A){let S=document.querySelector(p);if(!S)return{success:!1,error:`Element not found for selector: ${p}`};let{container:M,isRoot:O}=this.getScrollContainerForElement(S),W=oe(M),q=W?.DOMRect||DOMRect,U=O?new q(0,0,W.innerWidth??0,W.innerHeight??0):M.getBoundingClientRect(),P=S.getBoundingClientRect(),B=24,z=P.top>=U.top+B&&P.bottom<=U.bottom-B,te=A?.isTabActive??!document.hidden,re=A?.behavior,ie=te&&re==="smooth",K=this.normalizeScrollPosition(_);if(_===rt.NEAREST&&z)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(M,O)};try{S.scrollIntoView({behavior:ie?"smooth":"auto",block:K,inline:"nearest"})}catch{S.scrollIntoView()}let ce=this.getScrollMetricsForContainer(M,O);return{success:!0,position:K,...ce}}getScrollMetricsForContainer(p,_){let A=_?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,S=G(p),M=oe(p),O=_&&M?M.innerHeight:p.clientHeight,W=Math.max(0,A-O),U=(_?S.scrollingElement||S.documentElement||S.body:p).scrollTop;return{scrollTop:U,scrollHeight:A,clientHeight:O,maxScroll:W,isAtTop:U<=5,isAtBottom:U>=W-5,scrollPercentage:W>0?U/W*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:_,isRoot:A}=this.getScrollContext(p),S=G(_),M=X(S),O=A?Math.max(S.documentElement?S.documentElement.scrollHeight:0,S.body?S.body.scrollHeight:0):_.scrollHeight,W=A?M.innerHeight:_.clientHeight,q=Math.max(0,O-W),P=(A?S.scrollingElement||S.documentElement||S.body:_).scrollTop;return{element:or(_,S),scrollTop:P,scrollHeight:O,clientHeight:W,maxScroll:q,isAtTop:P<=5,isAtBottom:P>=q-5,scrollPercentage:q>0?P/q*100:0}}}let o=new r;window[e]=o;let s={execute:T=>o.execute(T)};try{Object.defineProperty(window,t,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=s}catch{}}let a=window.__RTRVR_INTERNAL_KEY__||n,i=window[a],u=i&&typeof i=="object"?i:null;if(u){try{u.scroll=u.scroll||s}catch{}try{u.scroll||Object.defineProperty(u,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(a!==n)try{!window[n]&&u&&Object.defineProperty(window,n,{value:u,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var uu=/\[id=(\d+)\]/,qe;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(qe||(qe={}));var Na=new Map;function du(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[bt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let a=o.match(uu);if(a?.[1]){let i=Number(a[1]);Number.isFinite(i)&&(t[i]=s)}}}return t}async function Fa(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||bo,s=String(r.contentType||"").trim().toLowerCase(),a=hu(s,r),i=pu(a.documentType,s),u={url:r.URL,title:r.title,contentType:i},T=fu(o);if(a.documentType!==qe.HTML){let O=Number(o?.pageDataTimeoutMs),W=Number.isFinite(O)?Math.max(200,Math.floor(O)):9e3,q=Math.max(200,Math.min(W,Lt(T))),U=Eu(r,a.documentType,o,T),P=await rr(U,q,r);if(!P.ok)return{...u,content:"",error:`non_html_timeout:${i}`,metadata:{extractionMethod:"timeout"}};let B=P.value||{},z=a.documentType===qe.GOOGLE_SHEET?Xu(r):void 0;return{...u,...B,contentType:B.contentType||u.contentType,sheetInfo:B.sheetInfo||z}}if(o?.onlyTextContent)return{...u,contentType:tr,content:xo(r)};let p=Math.max(0,Math.min(3e3,Lt(T))),_=performance.now(),A=!1;if(!o?.disableAutoScroll&&p>80){let O=r.hidden?900:1500,W=Math.min(O,p);W>80&&(A=await Gu(r,{profile:"light",timeBudgetMs:W,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let S=Math.max(0,p-(performance.now()-_));S>80&&await Yu(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,S),budgetMs:Math.min(r.hidden?650:850,S),maxPasses:r.hidden?1:2});let M=yo(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return _u(M.rootNodes,M.semanticNodes)?{...u,contentType:tr,content:xo(r),metadata:{scrollingPerformed:A}}:{...u,contentType:tr,roots:M.rootNodes,nodes:M.semanticNodes,elementLinkRecord:du(M.semanticNodes),metadata:{scrollingPerformed:A}}}function fu(e){let t=Number(e?.deadlineEpochMs);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.totalBudgetMs),r=Number.isFinite(n)?Math.max(1500,Math.floor(n)):9e3;return Date.now()+r}function pu(e,t){switch(e){case qe.PDF:return Ts;case qe.GOOGLE_DOC:return ks;case qe.GOOGLE_SHEET:return xs;case qe.PLAIN_TEXT:return Eo;case qe.HTML:default:return t||tr}}function hu(e,t){let n=e||String(t.contentType||"").toLowerCase();return xa(n)?{documentType:qe.PDF}:mu(t)&&(bu(t)||gu(t.URL))?{documentType:qe.PDF}:Au(t)?{documentType:qe.GOOGLE_DOC}:Cu(t)?{documentType:qe.GOOGLE_SHEET}:n.includes(Eo)?{documentType:qe.PLAIN_TEXT}:{documentType:qe.HTML}}function mu(e){try{let t=vu(e);return Is(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function gu(e){try{return e?e.toLowerCase().includes(".pdf")?!0:(new URL(e).searchParams.get("file")||"").toLowerCase().includes(".pdf"):!1}catch{return String(e||"").toLowerCase().includes(".pdf")}}function bu(e){try{let t=e.body;return!t||t.querySelectorAll('embed[type="application/pdf"],embed[type="application/x-google-chrome-pdf"],object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]').length===0||(t.innerText||"").trim().length>40?!1:Array.from(t.children).filter(s=>!["SCRIPT","STYLE"].includes(String(s.tagName).toUpperCase())).length<=3}catch{return!1}}async function Eu(e,t,n,r){switch(t){case qe.PDF:return wu(e,n,r);case qe.GOOGLE_DOC:return yu(e);case qe.GOOGLE_SHEET:return Wu(e,n);case qe.PLAIN_TEXT:return{content:xo(e),contentType:Eo};case qe.HTML:default:return{content:xo(e),contentType:tr}}}async function wu(e,t,n){Lt(n)>vs+50&&await Ra(vs,e,n);let o=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),_=bo.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):_})(),s=Lt(n),i=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,u=await xu(e,i),T=!!u.success&&!!(u.data||"").trim();return{content:T&&u.data||"",contentType:Ts,error:T?void 0:`pdf_extraction_failed:${u.reason||"unknown"}`}}async function yu(e){return{content:Bu(),contentType:ks}}function _u(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function xo(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function vu(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let s=o(e.body||e.documentElement);if(s)return s}}catch{}return e}function Tu(e){let t=e.URL||"";try{let n=new URL(t),r=n.searchParams.get("file")||n.searchParams.get("src")||"";return r||t}catch{return t}}async function xu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):bo.pdfTextSelectionTimeoutMs,r=Tu(e),o=Na.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await Ru(e,n);return s.success&&s.data.trim()&&Na.set(r,s.data),s}async function Ru(e,t){let n=e.defaultView||window,r=ku(e);if(!r||typeof r.postMessage!="function")return{success:!1,data:"",reason:"no_viewer"};let o=globalThis.crypto&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,s=!1,a="",i=p=>{if(s||!Iu(String(p.origin||""),e))return;let _=p.data;Su(_,o)&&typeof _.selectedText=="string"&&_.selectedText.trim().length>0&&(a=_.selectedText,s=!0)};n.addEventListener("message",i);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let u=Date.now();for(;!s&&Date.now()-u<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await Qe(200,e),a.trim()){s=!0;break}}return n.removeEventListener("message",i),a.trim()?{success:!0,data:a,reason:"ok"}:{success:!1,data:"",reason:Date.now()-u>=t?"timeout":"no_response"}}function ku(e){let t=Is(e)||e.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]');if(t&&typeof t.postMessage=="function")return t;let n=e.querySelector?.('iframe[type="application/pdf"]');return n?.contentWindow?n.contentWindow:null}function Iu(e,t){let n=(e||"").toLowerCase();if(!n||n==="null"||n.startsWith("chrome-extension://")||n.startsWith("chrome://")||n.startsWith("chrome-untrusted://"))return!0;try{let r=new URL(t.URL||"").origin.toLowerCase();if(r&&n===r)return!0}catch{}return!1}function Su(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function Au(e){try{let t=e.defaultView||zt();if(t?.location.hostname==="docs.google.com"&&t?.location.pathname.startsWith("/document/d/"))return!0}catch{}try{if(e.querySelector('iframe[src^="https://docs.google.com/document/d/"]'))return!0}catch{}return sr(e)!==null}function Cu(e){let n=(e.defaultView||zt())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function Mu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function Ro(e){let t=[e],n=Mu(e);return n!==e&&t.push(n),t}var Lu=".docs-texteventtarget-iframe",Nu=".kix-cursor",Du=".docos-replyview-body",Ou=".docos-replyview",Uu=".docos-author",Pa="\u200B",Hu="\xA0";function sr(e){for(let t of Ro(e)){let n=t.querySelector(Lu);if(n)return n}return null}function Fu(e){for(let t of Ro(e)){let n=t.querySelector(Nu);if(n)return n}return null}function _o(e){let t=Fu(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function vo(e,t){let n=sr(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",s={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},a=n.contentDocument,i=n.contentWindow;if(!a)return;let u=i?.KeyboardEvent||KeyboardEvent;a.dispatchEvent(new u("keydown",s))}function Da(e){let t=sr(e);if(!t)return;let n={key:"ArrowLeft",keyCode:37,code:"ArrowLeft",bubbles:!0,cancelable:!0},r=t.contentDocument,o=t.contentWindow;if(!r)return;let s=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new s("keydown",n))}function Pu(e){let t=sr(e);if(!t)return;let r=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0,o={key:"a",code:"KeyA",ctrlKey:!r,metaKey:r,bubbles:!0,cancelable:!0},s=t.contentDocument,a=t.contentWindow;if(!s)return;let i=a?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new i("keydown",o))}function To(e){let t=sr(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let i=r?.ClipboardEvent||ClipboardEvent,u=new i("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(u),o.firstChild?.dispatchEvent||o.dispatchEvent(u)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(Pa,"g"),"")??""}function Ls(e){let t=`
|
|
3
|
-
|
|
4
|
-
Comments: `,n=new Set,r=[];for(let s of
|
|
5
|
-
Author: ${
|
|
6
|
-
`)}return t.trim()}function
|
|
7
|
-
|
|
8
|
-
`)||(s+=u.trimEnd())}if(
|
|
9
|
-
`)&&
|
|
10
|
-
`)&&(s+=u)}Da(e);let a=Ls(e).trim(),i=s.trim()+a;return i.trim()?i:o()}catch{return o()}}async function Wu(e,t){let n="",r;Ba(e,e.defaultView||window);let o=Lt(t?.deadlineEpochMs);try{let s=Math.max(250,Math.min(1500,Math.floor(o*.45))),a=await rr(Vu(e),s,e);if(!(a.ok&&a.value))throw new Error("google_sheet_copy_failed");let u=Lt(t?.deadlineEpochMs),T=Math.max(250,Math.min(2500,Math.floor(u*.55)));if(n=await $u(T,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(s){r=s instanceof Error?s.message:String(s)}return{content:n,contentType:xs,error:r}}function Ba(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Ns(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),s=e.activeElement;(s&&s.ownerDocument===e?s:e).dispatchEvent(o)}async function Vu(e){try{if(Ba(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Ns(e,{key:"Escape",code:"Escape"}),await Qe(150,e);let t=e.querySelector(".grid-container")||Oa(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Oa(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await Qe(100,e)}else if(t){try{t.focus?.()}catch{}await Qe(80,e)}let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Ns(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await Qe(200,e),Ns(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await Qe(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function $u(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let s=await rr(navigator.clipboard.readText(),n,t);if(s.ok)return s.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function Oa(e,t){let n=Ro(e);for(let i of n)try{let u=i.querySelector(t);if(u)return u}catch{}let r=25e3,o=0,s=(i,u)=>{if(!u)return;let T=u.children;if(T)for(let p=0;p<T.length;p++)i.push(T[p])},a=[];for(let i of n)try{s(a,i.documentElement??i.body??null)}catch{}for(;a.length&&o<r;){let i=a.pop();o++;try{if(i.matches(t))return i}catch{}s(a,i);let u=i.shadowRoot;if(u&&s(a,u),String(i.tagName).toUpperCase()==="IFRAME")try{let p=i.contentDocument;p&&s(a,p.documentElement??p.body??null)}catch{}}return null}async function Gu(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let s=Date.now(),a=()=>o-(Date.now()-s),i=t?.delayMs??(n==="light"?220:280),u=t?.finalWaitMs??(n==="light"?350:900),T=r?i:0,p=r?u:0,_=t?.amount,A=t?.maxSteps??(n==="light"?8:18),S=t?.maxDistancePx??(n==="light"?12e3:3e4),M=null;try{let U=await Ua(e,{action:"detectPrimary"});if(U?.selector){let B=qu(e,U.selector);B&&(M=B)}let P=U?.metrics;if(P&&typeof P.scrollHeight=="number"&&typeof P.clientHeight=="number"){let B=Math.max(0,P.scrollHeight-P.clientHeight);S=Math.min(S,B||S),B<1500?A=Math.min(A,2):B<4e3?A=Math.min(A,4):B<1e4&&(A=Math.min(A,6))}}catch{}if(M||(M=e.scrollingElement||e.documentElement||e.body),!M)return!1;let O=0,W=null,q=0;for(let U=0;U<A&&!(a()<=0);U++){let P=null;try{P=await Ua(e,{action:"scrollBy",direction:Ue.DOWN,options:{amount:_,behavior:"auto",isTabActive:r}})}catch{}if(!P||!P.success){let z=e.defaultView||window;P=wo(M,e,z,Ue.DOWN,_),q=2}if(!P?.success)break;let B=P.scrollTop??W??0;if(W!==null){let z=Math.max(0,B-W);O+=z,q=z===0?q+1:0}if(W=B,P.isAtBottom||q>=2||O>=S)break;if(T>0&&U<A-1){let z=Math.min(T,Math.max(0,a()));if(z<=0)break;await Qe(z,e)}}if(p>0){let U=Math.min(p,Math.max(0,a()));U>0&&await Qe(U,e)}if(a()>80)try{let U=e.scrollingElement||e.documentElement||e.body,P=e.defaultView||window,B=M===e.documentElement||M===e.body||M===U?U:M;if(B){let z=B===U?P.innerHeight:B.clientHeight||P.innerHeight,te=Math.max(0,B.scrollHeight-z);B.scrollTop=te}}catch{}return!0}function qu(e,t){try{return e.querySelector(t)}catch{return null}}async function Ua(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",a=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof a!="function"?null:a(t)}async function Yu(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let a=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),i=0;for(;i<t.maxPasses&&Lt(a)>0;){let u=Math.max(50,Math.min(t.budgetMs,Lt(a)));try{await s({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:a})}catch{break}if(Ha(e)===0)break;i++}if(Ha(e)>0&&Lt(a)>50){let u=Math.min(120,Lt(a));try{await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:a})}catch{}}}function Ha(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(mr);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function Xu(e){let t=zu(e.URL||"");if(!t?.sheetId)return;let n=ju(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function zu(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let s=n[o+1];if(!s||!/^[a-zA-Z0-9_-]+$/.test(s))return null;let a;return t.hash&&t.hash.includes("gid=")&&(a=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!a&&t.searchParams.has("gid")&&(a=t.searchParams.get("gid")??void 0),a&&!/^\\d+$/.test(a)&&(a=void 0),{sheetId:s,sheetTabId:a?parseInt(a,10):0}}catch{return null}}function ju(e){try{let t=e.querySelector('[role="tab"][aria-selected="true"]')||e.querySelector(".docs-sheet-tab-active")||e.querySelector('.docs-sheet-tab[aria-selected="true"]');if(!t)return null;let n=t.getAttribute("aria-label")||t.textContent?.trim()||void 0,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}catch{return null}}var xt;(function(e){e[e.Native=1]="Native",e[e.Inline=2]="Inline",e[e.React=4]="React",e[e.Vue=8]="Vue",e[e.Angular=16]="Angular",e[e.Svelte=32]="Svelte",e[e.JQuery=64]="JQuery",e[e.Delegated=128]="Delegated",e[e.Other=256]="Other",e[e.Inferred=512]="Inferred"})(xt||(xt={}));var Ku={native:xt.Native,inline:xt.Inline,react:xt.React,vue:xt.Vue,angular:xt.Angular,svelte:xt.Svelte,jquery:xt.JQuery,delegated:xt.Delegated,other:xt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,s=new WeakMap,a=new Set,i=500,u=200,T=0,p=0,_=new WeakSet,A="__RTRVR_ET_HOOKED__",S="__RTRVR_ATTACH_SHADOW_HOOKED__";function M(l){if(l&&!_.has(l)){_.add(l);try{O(l)}catch{}try{W(l)}catch{}}}function O(l){try{let E=l.EventTarget;if(!E?.prototype||E.prototype[A])return;E.prototype[A]=!0;let k=E.prototype.addEventListener,R=E.prototype.removeEventListener;E.prototype.addEventListener=function(I,D,V){try{cn(D)||At(this,I,V)}catch{}return k.call(this,I,D,V)},E.prototype.removeEventListener=function(I,D,V){try{en(this,I,V)}catch{}return R.call(this,I,D,V)};try{let I=Function.prototype.toString;E.prototype.addEventListener.toString=()=>I.call(k),E.prototype.removeEventListener.toString=()=>I.call(R)}catch{}}catch{}}function W(l){try{let E=l.Element;if(!E?.prototype?.attachShadow||E.prototype[S])return;E.prototype[S]=!0;let k=E.prototype.attachShadow;E.prototype.attachShadow=function(R){let I=k.call(this,R);try{Pe.set(this,I)}catch{}try{J(I)}catch{}return I};try{let R=Function.prototype.toString;E.prototype.attachShadow.toString=()=>R.call(k)}catch{}}catch{}}function q(l){let k=n.get(l)?.listenerTypeMasks;if(k&&k.size){let R=[];for(let I of k.keys()){let D=tn[I];D&&R.push(D)}return R}return fr(l)}let U=["onclick","ondblclick","ondoubleclick","onmousedown","onmouseup","role","contenteditable","draggable","tabindex","disabled","type","aria-haspopup","aria-expanded","data-click","data-action","data-handler","data-toggle","data-target"],P=0,B=new Set,z=6,te=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],re=["mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","wheel","scroll","dragstart","drop","touchstart","touchend"];if(e[t]){typeof e.rtrvrAIMarkInteractiveElements=="function"&&e.rtrvrAIMarkInteractiveElements();return}e[t]=!0;let ie={onclick:"click",ondblclick:"dblclick",ondoubleclick:"doubleclick",onmousedown:"mousedown",onmouseup:"mouseup",onmouseenter:"mouseenter",onmouseleave:"mouseleave",onmousemove:"mousemove",onmouseover:"mouseover",onmouseout:"mouseout",oncontextmenu:"contextmenu",onauxclick:"auxclick",onkeydown:"keydown",onkeyup:"keyup",onkeypress:"keypress",oninput:"input",onchange:"change",onsubmit:"submit",onreset:"reset",onselect:"select",onsearch:"search",oninvalid:"invalid",onbeforeinput:"beforeinput",onfocus:"focus",onblur:"blur",onfocusin:"focusin",onfocusout:"focusout",ontouchstart:"touchstart",ontouchend:"touchend",ontouchmove:"touchmove",ontouchcancel:"touchcancel",onpointerdown:"pointerdown",onpointerup:"pointerup",onpointermove:"pointermove",onpointerenter:"pointerenter",onpointerleave:"pointerleave",onpointercancel:"pointercancel",onpointerover:"pointerover",ondragstart:"dragstart",ondragend:"dragend",ondrag:"drag",ondragenter:"dragenter",ondragleave:"dragleave",ondragover:"dragover",ondrop:"drop",oncopy:"copy",oncut:"cut",onpaste:"paste",onscroll:"scroll",onwheel:"wheel",onplay:"play",onpause:"pause",onended:"ended",onvolumechange:"volumechange",onseeking:"seeking",onseeked:"seeked",onanimationstart:"animationstart",onanimationend:"animationend",ontransitionend:"transitionend",ontransitionstart:"transitionstart",onresize:"resize",ontoggle:"toggle",onfullscreenchange:"fullscreenchange",onload:"load",onerror:"error",onabort:"abort",onbeforeunload:"beforeunload",onunload:"unload",onhashchange:"hashchange",onpopstate:"popstate",onstorage:"storage",onmessage:"message"};function K(l){return l?String(l).split(".")[0].toLowerCase():""}let ce=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],ne=0,ue=null,ge=new MessageChannel,ht=[];ge.port1.onmessage=()=>{let l=ht.shift();l&&l()};function _e(){return Date.now()}function De(l){return!l||!Number.isFinite(l)?Number.POSITIVE_INFINITY:Math.max(0,l-_e())}let He=8,Ce=new MessageChannel,Je=!1;function ot(){if(!Je){Je=!0;try{Ce.port2.postMessage(0)}catch{}}}function wt(l){let E=l.values().next();if(E.done)return null;let k=E.value;return l.delete(k),k}function kt(){return new Promise(l=>{ht.push(l),ge.port2.postMessage(0)})}let st=!1;function ke(){if(!st)try{let l=e.jQuery;l&&l.fn&&(qt(l),st=!0,Oe("jquery"))}catch{}}function Me(l,E){for(let k=E.lastElementChild;k;k=k.previousElementSibling)l.push(k)}function Wt(l,E,k){if(k)try{let R=le(E);R&&l.push(R)}catch{}}function mt(l,E,k){if(k&&dr(E))try{let R=E.contentWindow||null;R&&M(R);let I=R?.document?.documentElement;I&&l.push(I)}catch{}}let gt=new WeakSet;function Vt(l){l&&(typeof l=="function"||typeof l=="object")&>.add(l)}function cn(l){return!!l&&(typeof l=="function"||typeof l=="object")&>.has(l)}Ce.port1.onmessage=()=>{Je=!1,un(500);let l=performance.now();for(;B.size&&performance.now()-l<He;){let E=wt(B);if(!E)break;try{C(E)}catch{}finally{P=Math.max(0,P-1)}}for(;a.size&&performance.now()-l<He;){let E=wt(a);if(!E)break;try{et(E)}catch{}}Ze(),(B.size||a.size)&&ot()};function Ze(){try{let l=Xe()?.documentElement;if(!l)return;l.setAttribute(mr,String(P))}catch{}}function It(l){let E=n.get(l);return E||(E={frameworks:new Set,listeners:new Map},n.set(l,E)),E}function Le(l){a.add(l),ot()}function ln(l){B.has(l)||(B.add(l),P++,Ze(),ot(),B.size>8e3&&un(3e3))}function un(l=2e3){let E=0;for(let k of B){if(E>l)break;k.isConnected||(B.delete(k),P=Math.max(0,P-1))}E=0;for(let k of a){if(E>l)break;k.isConnected||a.delete(k)}Ze()}let Fe=null;function wn(l,E,k){return`${l}|${E?1:0}|${k?1:0}`}function $t(l){let E=l.tagName;if(E==="A"||E==="BUTTON"||E==="INPUT"||E==="SELECT"||E==="TEXTAREA"||E==="SUMMARY"||l.hasAttribute("role")||l.hasAttribute("tabindex")||l.hasAttribute("contenteditable")||l.hasAttribute("onclick")||l.getAttributeNames().some(k=>k.startsWith("on")))return!0;for(let k of ce)if(l.hasAttribute(k))return!0;return!!(l.hasAttribute("aria-haspopup")||l.hasAttribute("aria-expanded"))}function Qt(l){let E=oe(l);if(!Ge(l,E))return!1;let k=l.tagName;if(k!=="DIV"&&k!=="SPAN"&&k!=="LI"&&k!=="SECTION"&&k!=="ARTICLE"&&k!=="P")return!1;let R=l;if(R.__ngContext__||R.__svelte__||R.__vue__||R._vnode||R.__reactFiber$||R.__reactProps$)return!0;let I=0;for(let D in R){if(++I>30)break;if(D.startsWith("__react")||D.includes("reactFiber")||D.includes("reactProps"))return!0}return!1}function dn(){let l=Xe()?.documentElement;return l?r.frameworks.size>0||l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte")||l.hasAttribute("rtrvr-jquery"):!1}function yn(l){let E=performance.now();for(;B.size&&performance.now()-E<l;){let k=wt(B);if(!k)break;try{C(k)}catch{}finally{P=Math.max(0,P-1)}}for(;a.size&&performance.now()-E<l;){let k=wt(a);if(!k)break;try{et(k)}catch{}}}async function _n(l={}){un(3e3),ke(),be();let E=l.mode??"full",k=l.includeShadow??!0,R=l.includeSameOriginIframes??!0,I=Math.max(50,Math.min(l.budgetMs??2500,15e3)),D=l.deadlineEpochMs,V=Math.max(0,Math.min(I,De(D))),j=wn(E,k,R);if(V<=0){let je=(Fe?.stack?.length??0)+B.size+a.size;return{revision:++ne,scanned:0,durationMs:0,done:je===0,remaining:je}}if((!Fe||Fe.optsKey!==j)&&De(D)>30&&await Y({budgetMs:18,deadlineEpochMs:D}),E==="priority"){let je=performance.now(),Ne=0;for(;B.size&&performance.now()-je<=V&&!(D&&De(D)<=0);){let Be=wt(B);if(!Be)break;try{C(Be)}catch{}Ne++,P=Math.max(0,P-1)}for(;a.size&&performance.now()-je<=V&&!(D&&De(D)<=0);){let Be=wt(a);if(!Be)break;try{et(Be)}catch{}}return Ze(),{revision:++ne,scanned:Ne,durationMs:performance.now()-je,done:B.size===0&&a.size===0,remaining:B.size+a.size}}if(!Fe||Fe.optsKey!==j){let je=Xe()?.documentElement;Fe={optsKey:j,stack:je?[je]:[],scannedTotal:0}}let ve=performance.now(),xe=0;for(P++,Ze();Fe.stack.length&&!(D&&De(D)<=0);){let je=Fe.stack.pop();if(vt(je)){let Be=je.children;for(let Rn=Be.length-1;Rn>=0;Rn--)Fe.stack.push(Be[Rn]);continue}let Ne=je;if(!(!Ne||Ne.nodeType!==1)&&!(Ne.tagName==="SCRIPT"||Ne.tagName==="STYLE"||Ne.tagName==="META"||Ne.tagName==="NOSCRIPT")){try{($t(Ne)||dn()&&Qt(Ne))&&C(Ne)}catch{}try{et(Ne)}catch{}if(B.delete(Ne)&&(P=Math.max(0,P-1)),a.delete(Ne),xe++,Fe.scannedTotal++,k)try{let Be=le(Ne);Be&&(J(Be),Fe.stack.push(Be))}catch{}if(R&&dr(Ne))try{let Be=Ne.contentWindow||null;Be&&M(Be);let Rn=Be?.document,ti=Rn?.documentElement;Rn&&ti&&(se(Rn),Fe.stack.push(ti))}catch{}for(let Be=Ne.lastElementChild;Be;Be=Be.previousElementSibling)Fe.stack.push(Be);xe%800===0&&De(D)>20&&await kt()}}let Se=Math.max(0,V-(performance.now()-ve)),ut=De(D);yn(Math.min(250,Se,ut)),P=Math.max(0,P-1),Ze();let Xt=Fe.stack.length===0,Yn=Fe.stack.length;return Xt&&(Fe=null),{revision:++ne,scanned:xe,durationMs:performance.now()-ve,done:Xt,remaining:Yn}}async function St(l={}){return ue||(ue=_n(l).finally(()=>{ue=null}),ue)}e.rtrvrAIFlushScan=St;let Dt="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=Dt;let lt=e[Dt],Ot=lt&&typeof lt=="object"?lt:{};if(!lt)try{Object.defineProperty(e,Dt,{value:Ot,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(Ot,"flushScan",{value:St,writable:!1,configurable:!1,enumerable:!1})}catch{}function pe(l,E){let k=It(l),R=K(E.type);if(!R)return;let I=!1,D=k.listeners.get(R);D||(D=[],k.listeners.set(R,D),I=!0);let V=D.find(ae=>ae.source===E.source&&!!ae.inferred==!!E.inferred);if(V){let ae=!!V.capture,ve=!!V.passive,xe=!!V.once;V.capture=V.capture||E.capture,V.passive=V.passive||E.passive,V.once=V.once||E.once,(ae!==!!V.capture||ve!==!!V.passive||xe!==!!V.once)&&(I=!0)}else D.push({...E,type:R}),I=!0;let j=ye[R];if(j!==void 0){k.listenerTypeMasks||(k.listenerTypeMasks=new Map);let ae=0,ve=Ku[E.source];ae|=ve!==void 0?ve:xt.Other,E.inferred&&(ae|=xt.Inferred);let xe=k.listenerTypeMasks.get(j)||0,Se=xe|ae;Se!==xe&&(k.listenerTypeMasks.set(j,Se),I=!0)}I&&(k.role=void 0,Le(l))}function Jt(l){let E=l.listenerTypeMasks;return!E||E.size===0?null:[...E.entries()].sort((R,I)=>R[0]-I[0]).map(([R,I])=>`${R}~${(I||0).toString(36)}`).join(",")}function Gt(l,E){let k=It(l);k.frameworks.has(E)||(k.frameworks.add(E),Le(l))}function Oe(l){r.frameworks.has(l)||(r.frameworks.add(l),Xe()?.documentElement?.setAttribute(`rtrvr-${l}`,"1"))}function et(l){let E=n.get(l);if(!E)return;a.delete(l);let k=Jt(E);k?k!==E.lastListenersSerialized&&(l.setAttribute(fn,k),E.lastListenersSerialized=k):E.lastListenersSerialized&&(l.removeAttribute(fn),E.lastListenersSerialized=void 0);let R=oe(l);if(Ge(l,R))if(E.role===void 0&&(E.role=Tn(l)),E.role){let I=jn[E.role],D=typeof I=="number"?String(I):`s:${E.role}`;D!==E.lastRoleSerialized&&(l.setAttribute(rn,D),E.lastRoleSerialized=D)}else(E.lastRoleSerialized||l.hasAttribute(rn))&&(l.removeAttribute(rn),E.lastRoleSerialized=void 0)}function Br(l){let E=[],k=l;for(;k;)E.push(k),k=k.parentNode||k.host;return E}function vn(l){let E=l.tagName.toLowerCase(),k=l.getAttribute("role"),R=k?k.toLowerCase().trim():"";if(R&&nn.has(R)||E==="button"||(E==="a"||E==="area")&&l.hasAttribute("href"))return!0;if(E==="input")return l.type?.toLowerCase()!=="hidden";if(E==="select"||E==="textarea"||(E==="video"||E==="audio")&&l.hasAttribute("controls")||l.isContentEditable||l.hasAttribute("contenteditable"))return!0;let I=l.getAttribute("tabindex");return!!(I!==null&&!Number.isNaN(Number.parseInt(I,10))&&(q(l).some(j=>eo.has(j))||l.getAttributeNames().some(j=>j.startsWith("on"))))}function Ve(l,E=10,k=600){let R=[];for(let D=0;D<l.children.length;D++)R.push({node:l.children[D],depth:1});let I=0;for(;R.length;){let{node:D,depth:V}=R.pop();if(++I>k||vn(D))return!0;if(!(V>=E))for(let j=0;j<D.children.length;j++)R.push({node:D.children[j],depth:V+1})}return!1}function Tn(l){let E=l.tagName.toLowerCase(),k=l.getAttribute("role"),R=k?k.toLowerCase().trim():"",I=l.type?.toLowerCase();if(R&&nn.has(R))return R;if(R&&pr.has(R))return null;if(E==="a"&&l.hasAttribute("href"))return"link";if(E==="button")return"button";if(E==="input")return I==="hidden"?null:I==="checkbox"?"checkbox":I==="radio"?"radio":I==="range"?"slider":I==="number"?"spinbutton":I==="search"?"searchbox":["button","submit","reset","image","file"].includes(I)?"button":l.hasAttribute("list")?"combobox":"textbox";if(E==="textarea")return"textbox";if(E==="select"){let Se=l;return Se.multiple||Se.size&&Se.size>1?"listbox":"combobox"}if(E==="option")return"option";if(E==="form")return"form";if(E==="video"||E==="audio"){let Se=fr(l);return l.hasAttribute("controls")||Se.length>0?"media":null}if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";let D=q(l);if(!D.length)return null;let V=!1,j=!1,ae=!1;for(let Se=0;Se<D.length;Se++){let ut=D[Se];!V&&eo.has(ut)&&(V=!0),!j&&as.has(ut)&&(j=!0),!ae&&cs.has(ut)&&(ae=!0)}if(!V&&!j&&!ae)return null;let ve=l.getAttribute("tabindex"),xe=ve!==null&&!Number.isNaN(Number.parseInt(ve,10));if(V&&(bs(l)||l.getAttribute("href")||l.closest("a[href]")))return"link";if(j){if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";if(R==="textbox"||R==="searchbox"||R==="combobox"||R==="spinbutton")return R;if(!V&&xe)return"textbox"}if(V){let Se=l.getAttribute("aria-checked"),ut=l.getAttribute("aria-pressed");if(Se!==null||ut!==null){if(R==="radio")return"radio";if(R==="menuitemradio")return"menuitemradio";if(R==="menuitemcheckbox")return"menuitemcheckbox";if(ut!==null)return"button";if(Se!==null)return"checkbox"}if((xe||R==="button")&&!Ve(l))return"button"}return ae?"application":null}let $n=EventTarget.prototype.addEventListener,Zt=EventTarget.prototype.removeEventListener;function Gn(l){let E=!1,k,R;return typeof l=="boolean"?E=l:l&&typeof l=="object"&&(E=!!l.capture,k=l.passive,R=l.once),{capture:E,passive:k,once:R}}function qn(l){try{let E=l;if(E?.nodeType===9&&E?.documentElement)return E;let k=E?.document;if(k&&k.nodeType===9&&k.documentElement)return k}catch{}return null}function At(l,E,k){let R=K(E);if(!R)return;let{capture:I,passive:D,once:V}=Gn(k),j=o.get(l);j||(j=new Map,o.set(l,j));let ae=j.get(R);if(ae?(ae.count+=1,ae.capture=ae.capture||I,ae.passive=ae.passive||D):j.set(R,{count:1,capture:I,passive:D}),Sn(l))try{pe(l,{type:R,source:"native",capture:I,passive:D,once:V})}catch{}let ve=qn(l);if(ve&&(R==="click"||R==="input"||R==="keydown"))try{ve.documentElement?.setAttribute(`rtrvr-gl-${R}`,"1")}catch{}}function en(l,E,k){let R=K(E);if(!R)return;let I=o.get(l);if(!I)return;let D=I.get(R);D&&(D.count-=1,D.count<=0&&I.delete(R),I.size===0&&o.delete(l))}M(window);function qt(l){if(!l||!l.fn)return;let E=l.fn.on,k=l.fn.off;function R(D){if(!D)return[];if(typeof D=="string")return D.split(/\s/).map(V=>K(V)).filter(Boolean);if(typeof D=="object")try{return Object.keys(D).map(V=>K(V)).filter(Boolean)}catch{return[]}return[]}function I(D){try{if(!D)return null;if(Sn(D))return D;let V=oe(D);return Kr(D,V)||null}catch{}return null}l.fn.on=function(D,V){let j=R(D),ae=typeof V=="string"&&!!V;return this.each(function(){let ve=I(this);if(ve){if(ae){let xe=s.get(ve);xe||(xe=[],s.set(ve,xe));for(let Se of j){let ut=`${Se}::${V}`;xe.some(Xt=>`${Xt.type}::${Xt.selector}`===ut)||(xe.push({type:Se,selector:V}),xe.length>400&&xe.shift())}}else for(let xe of j)pe(ve,{type:xe,source:"jquery"});Gt(ve,"jquery"),Oe("jquery"),r.jqueryRoots.add(ve)}}),E.apply(this,arguments)},l.fn.off=function(){return k.apply(this,arguments)},Oe("jquery")}function ur(l){ce.some(k=>l.hasAttribute(k))&&(pe(l,{type:"click",source:"other",inferred:!0}),(l.tagName==="INPUT"||l.tagName==="TEXTAREA")&&(pe(l,{type:"input",source:"other",inferred:!0}),pe(l,{type:"change",source:"other",inferred:!0})))}function Yt(l){let E=oe(l),k=Ge(l,E),R=l.getAttributeNames().some(ae=>ae.startsWith("on")),I=/^(button|a|input|select|textarea|summary)$/i.test(l.tagName),D=l,V=k&&(oo(l)||!!D.isContentEditable||l.hasAttribute("contenteditable")),j=k&&!!D.draggable;if(!R&&!I&&!V&&!j){ur(l);return}for(let[ae,ve]of Object.entries(ie))typeof l[ae]=="function"&&pe(l,{type:ve,source:"inline"});V&&(pe(l,{type:"input",source:"other",inferred:!0}),pe(l,{type:"keydown",source:"other",inferred:!0}),pe(l,{type:"keyup",source:"other",inferred:!0}),pe(l,{type:"paste",source:"other",inferred:!0})),j&&(pe(l,{type:"dragstart",source:"other",inferred:!0}),pe(l,{type:"dragend",source:"other",inferred:!0})),ur(l)}function xn(l){if(!l.startsWith("on")||l.length<=2)return null;if(l.endsWith("Capture")){let k=l.substring(2,l.length-7);return k?{type:k.toLowerCase(),capture:!0}:null}let E=l.substring(2);return E?{type:E.toLowerCase(),capture:!1}:null}function Ct(l){let E=null;if(l){for(let k in l)if(k.startsWith("__react")||k.startsWith("_react")||k.includes("reactFiber")||k.includes("reactProps")||k.includes("reactInternalInstance")){E=k;break}if(E)try{let k=l[E],R=k?.memoizedProps||k?.pendingProps;if(R&&typeof R=="object"){for(let I in R){if(typeof R[I]!="function")continue;let V=xn(I);V&&pe(l,{type:V.type,source:"react",capture:V.capture})}Sn(k?.stateNode)&&r.reactRoots.add(k.stateNode),Gt(l,"react"),Oe("react")}}catch{}}}function c(l){let E=l,k=!1;if(E.__vue__){k=!0;let R=E.__vue__;R.$listeners&&Object.keys(R.$listeners).forEach(I=>pe(l,{type:I,source:"vue"})),R._events&&Object.keys(R._events).forEach(I=>pe(l,{type:I,source:"vue"})),R.$options?._parentListeners&&Object.keys(R.$options._parentListeners).forEach(I=>pe(l,{type:I,source:"vue"})),r.vueRoots.add(l)}if(E._vnode?.props){k=!0;let R=E._vnode.props;Object.keys(R).forEach(I=>{I.startsWith("on")&&I.length>2&&pe(l,{type:I.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(l)}k&&(Gt(l,"vue"),Oe("vue"))}function w(l){let E=l,k=!1;if(E.__ngContext__||l.hasAttribute("_ngcontent")||l.hasAttribute("ng-version")){k=!0,Array.from(l.attributes).forEach(R=>{if(R.name.startsWith("(")&&R.name.endsWith(")")){let I=R.name.slice(1,-1).split(".")[0];I&&pe(l,{type:I,source:"angular"})}if(R.name.startsWith("on-")){let I=R.name.substring(3);I&&pe(l,{type:I,source:"angular"})}if(R.name.includes(".")){let I=R.name.match(/\(([^.)]+)/);I?.[1]&&pe(l,{type:I[1],source:"angular"})}});try{if(e.ng?.getComponent){let R=e.ng.getComponent(l);R&&Object.keys(R).forEach(I=>{(I.endsWith("Output")||I.endsWith("Emitter"))&&pe(l,{type:I.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}k&&(Gt(l,"angular"),Oe("angular"),r.angularRoots.add(l))}function b(l){let E=l,k=!1;if(E.__svelte__){k=!0,Array.from(l.attributes).forEach(R=>{if(R.name.startsWith("on:")){let I=R.name.substring(3);I&&pe(l,{type:I,source:"svelte"})}});try{let R=E.__svelte__?.$$?.callbacks;R&&typeof R=="object"&&Object.keys(R).forEach(I=>pe(l,{type:I,source:"svelte"}))}catch{}r.svelteRoots.add(l)}k&&(Gt(l,"svelte"),Oe("svelte"))}function g(l,E){return l?!!o.get(l)?.has(E):!1}function f(l,E,k=96){let R=K(E);if(!R)return!1;let I=G(l),D=X(I);if(g(I,R)||g(D,R))return!0;let V=0,j=l;for(;j&&V<k;){if(j.parentElement)j=j.parentElement;else{let ae=j.getRootNode?.();if(vt(ae)){if(g(ae,R)||g(ae.host,R))return!0;j=ae.host}else break}if(j&&g(j,R))return!0}return!1}function d(l,E,k=128){let R=0,I=l;for(;I&&R<k;){if(E(I),I.parentElement){I=I.parentElement;continue}let D=I.getRootNode?.();if(vt(D)){I=D.host;continue}break}}function h(l){let E=oe(l);if(!Ge(l,E))return;let k=It(l);k.role=k.role||Tn(l);let R=f(l,"click"),I=f(l,"input"),D=f(l,"keydown"),j=G(l).documentElement;if(r.frameworks.size>0||j.hasAttribute("rtrvr-react")||j.hasAttribute("rtrvr-vue")||j.hasAttribute("rtrvr-angular")||j.hasAttribute("rtrvr-svelte")||j.hasAttribute("rtrvr-jquery")||R||I||D){let ve=k.role||"other";R&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(ve)&&pe(l,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(ve)&&(I&&(pe(l,{type:"input",source:"delegated",inferred:!0}),pe(l,{type:"change",source:"delegated",inferred:!0})),D&&pe(l,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(ve)&&(R&&pe(l,{type:"click",source:"delegated",inferred:!0}),I&&pe(l,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(ve)&&I&&pe(l,{type:"input",source:"delegated",inferred:!0})}d(l,ve=>{let xe=s.get(ve);if(xe?.length)for(let{type:Se,selector:ut}of xe)try{l.matches(ut)&&(pe(l,{type:Se,source:"jquery",inferred:!0}),Gt(l,"jquery"),Oe("jquery"))}catch{}})}function x(l){let E=k=>{let R=k,I=R.composedPath&&R.composedPath()||Br(k.target),V=l==="mousemove"||l==="pointermove"||l==="scroll"||l==="wheel"?1:Math.min(I.length,z);for(let j=0;j<V;j++){let ae=I[j];Sn(ae)&&pe(ae,{type:l,source:"delegated",inferred:!0})}};Vt(E);try{$n.call(document,l,E,{capture:!0,passive:!0})}catch{}}let m=!1;function v(){te.forEach(x);let l=Xe()?.documentElement;if(!l)return;let E=()=>{if(m)return;let k=l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte"),R=l.hasAttribute("rtrvr-gl-click")||l.hasAttribute("rtrvr-gl-input")||l.hasAttribute("rtrvr-gl-keydown");(k||R)&&(m=!0,re.forEach(x))};E();try{new MutationObserver(()=>E()).observe(l,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function C(l){if(l.nodeType!==1)return;let E=oe(l);if(Ge(l,E)){let k=It(l);k.role=void 0}Yt(l),Ct(l),c(l),w(l),b(l),h(l),Le(l)}function N(){let l=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(nn).map(E=>`[role="${E}"]`),"[onclick]","[ondblclick]","[ondoubleclick]","[onmousedown]","[tabindex]","[contenteditable]",'[draggable="true"]',"[aria-haspopup]","[aria-expanded]","[data-click]","[data-action]","[data-handler]","[data-toggle]","[data-target]",".clickable",".interactive",".btn",".button"];P++,Ze();try{let E=l.join(",");Xe()?.querySelectorAll(E).forEach(k=>{try{C(k)}catch{}})}finally{P=Math.max(0,P-1),Ze()}}function H(l){for(let E of l){for(let k of Array.from(E.addedNodes)){if(k.nodeType!==1)continue;let R=k;ln(R),R.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(ln)}if(E.type==="attributes"&&E.target.nodeType===1){let k=E.target;E.attributeName==="class"?(dn()||$t(k))&&ln(k):ln(k)}}}async function Y(l={}){let E=Xe(),k=E?.documentElement;if(!k||!(k.hasAttribute("rtrvr-react")||k.hasAttribute("rtrvr-vue")||k.hasAttribute("rtrvr-angular")||k.hasAttribute("rtrvr-svelte")))return;let I=l.deadlineEpochMs,D=Math.max(5,Math.min(l.budgetMs??12,50));if(Math.max(0,Math.min(D,De(I)))<=0)return;let j=performance.now();P++,Ze();try{let ae=0,ve=4e3,xe=["div","span","li","section","article","p"];for(let Se of xe){let ut=E.getElementsByTagName(Se)??[];for(let Xt=0;Xt<ut.length;Xt++){if(ae++>=ve||I&&De(I)<=0)return;let Yn=ut[Xt],je=Yn;(je.__ngContext__||je.__svelte__||je.__vue__||je._vnode||Qt(Yn))&&C(Yn),ae%250===0&&De(I)>20&&await kt()}}}finally{P=Math.max(0,P-1),Ze()}}let Q=new MutationObserver(H),fe=new WeakMap;function J(l){if(!fe.has(l)&&!(T>=i))try{let E=X(l.ownerDocument).MutationObserver||MutationObserver,k=new E(H);fe.set(l,k),T++,k.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}catch{}}let Z=new WeakMap;function se(l){if(!Z.has(l)&&!(p>=u))try{M(l.defaultView||null);let E=l.documentElement;if(!E)return;let k=X(l).MutationObserver||MutationObserver,R=new k(H);Z.set(l,R),p++,R.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}catch{}}function Ee(){let l=Xe()?.documentElement;l&&Q.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}let Pe=new WeakMap;function le(l){return l.shadowRoot||Pe.get(l)||null}try{Object.defineProperty(Ot,"shadow",{value:Object.freeze({getRoot:l=>le(l)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function be(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&Oe("react"),e.Vue&&Oe("vue"),e.ng&&Oe("angular"),e.jQuery&&Oe("jquery"),ke()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return Xe()?.body?(N(),!0):!1};function we(){let l=Xe();ke(),be(),v();let E=()=>{ke(),be(),Ee(),e.rtrvrAIMarkInteractiveElements?.(),Y({budgetMs:20}),l?.documentElement.setAttribute(os,"1")};l?.readyState==="loading"?l.addEventListener("DOMContentLoaded",E,{once:!0}):E()}we()})();var ko=null;function Ds(e){try{return e.getAttribute(fn)}catch{return null}}function Wa(e){let t=Ds(e);return An(t)?.entries??[]}function Va(e){try{let t=e.getAttribute(rn);return t&&t.trim()?t:null}catch{return null}}function Qu(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function Ju(e){let t=new Set;for(let n of e){let r=$r(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function Zu(e){let t=new Set,n=e;return(n.__reactFiber||n.__reactProps||n.__reactInternalInstance||n.__reactRootContainer)&&t.add("react"),(n.__vue__||n.__vueParentComponent||n.__vnode||n.__vue_app__)&&t.add("vue"),n.__ngContext__&&t.add("angular"),(n.__svelte||n.__svelte_meta)&&t.add("svelte"),(n.__jquery||n.jQuery)&&t.add("jquery"),t}function ed(e){let t=Wa(e),n=Ju(t),r=Zu(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Ds(e)||"",role:Va(e)??(e.getAttribute?.("role")||null)}}function td(){return{getEventHandlerIds:e=>Wa(e).map(t=>t.id),getRoleHint:Va,getShadowRoot:Qu}}function $a(e={}){if(ko)return ko;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return ko={signalProvider:td(),getFrameworkMetadata:ed,getListenerEncoding:Ds,dispose:()=>{}},ko}var Mo=class{constructor(t={}){$(this,"root");$(this,"includeFrames");$(this,"disableDomAnnotations");$(this,"allowActions");$(this,"runtimeId");$(this,"domainScopeMode");$(this,"allowedDomains");$(this,"externalNavigationPolicy");$(this,"registerOpenedTab");$(this,"listKnownTabs");$(this,"switchToLogicalTab");$(this,"onNavigationGuardrail");$(this,"instrumentation");$(this,"highlightEl",null);$(this,"clientTools",new Map);$(this,"uploadStore",new Map);$(this,"uploadProviderInstalled",!1);this.root=t.root??document.body??document.documentElement,this.includeFrames=t.includeFrames??!0,this.disableDomAnnotations=t.disableDomAnnotations??!0,this.allowActions=t.allowActions??!0,this.runtimeId=t.runtimeId,this.domainScopeMode=Ga(t.domainScopeMode),this.allowedDomains=Os(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.instrumentation=t.instrumentation??$a({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),Ma(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=Ga(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=Os(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=Os(t.allowedDomains,window.location.hostname,this.domainScopeMode)),(t.externalNavigationPolicy||t.crossDomainPolicy)&&(this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy))}async getSnapshot(){return await za(this.root),yo(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await za(this.root),await Fa(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=nd(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r)){let A=`Current tab is outside the allowed domain scope (${Ao(this.allowedDomains)}).`;return this.domainScopeBlockedResponse(window.location.href,A,{fromCurrentContext:!0})}if(!this.allowActions&&!Xa.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===L.wait_action){let A=Number(t?.args?.duration??1e3);return await new Promise(S=>setTimeout(S,Math.max(0,Math.min(A,6e4)))),{success:!0}}if(r===L.wait_for_element)return this.waitForElement(t?.args||{});if(r===L.answer_task)return{success:!0};if(r===L.solve_captcha)return Co("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===L.network_run_recipe)return Co("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");if(r===L.click_element&&t?.args?.open_in_new_tab)return this.openElementInNewTab(t?.args||{});if(r===L.click_element&&this.shouldInterceptExternalClick(t?.args||{})){let A=this.getExternalClickTargetUrl(t?.args||{});if(A){let S=`Blocked same-tab navigation to out-of-scope domain (${new URL(A).hostname}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(A,{policyBlocked:!0,reason:S}):this.domainScopeBlockedResponse(A,S)}}if(r===L.describe_images)return this.describeImages(t?.args||{});if(!(r in Vr))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let s=t?.args||{},{doc:a}=nr(document,s.iframe_id),i=s.element_id??s.source_element_id??s.target_element_id??s.center_element_id??null,u=i?Pt(a,i):null,T;if(u){let A=this.instrumentation.getFrameworkMetadata(u),S=ld(A.listenersRaw||"",r),M=s?.value??s?.text??null;T=cd({...A,pattern:S,value:M})}let p=Vr[r];return r===L.upload_file&&!n&&(n=await this.buildUploadPayload(s).catch(()=>{})),La({opcode:p,call:{name:r,args:s},elementData:T,tabIndex:0,payload:n})}highlight(t){let n=Pt(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.height)}px`,this.highlightEl.style.display="block"}clearHighlight(){this.highlightEl&&(this.highlightEl.style.display="none")}setUploadBytesProvider(t){window.__ROVER_UPLOAD_BYTES__=t}registerTool(t,n){let r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case L.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=Io(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldGuardExternalNavigation(o)){let s=`Navigation blocked by domain policy. Allowed: ${Ao(this.allowedDomains)}`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldGuardExternalNavigation(o)){let s=`Google search opens outside the allowed domain scope (${Ao(this.allowedDomains)}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.go_back:return window.history.back(),{success:!0};case L.go_forward:return window.history.forward(),{success:!0};case L.refresh_page:return window.location.reload(),{success:!0};case L.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=Io(r,window.location.href);return o?await this.openUrlInNewTab(o,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0}}case L.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(s=>Number(s.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked outside ${Ao(this.allowedDomains)}.`)}if(!this.switchToLogicalTab)return Co("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case L.close_tab:try{return window.close(),{success:!0}}catch{return Co("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!So(t,this.allowedDomains)}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||Xa.has(t)||ad.has(t)?!1:!So(window.location.href,this.allowedDomains)}shouldInterceptExternalClick(t){if(this.externalNavigationPolicy==="allow")return!1;let n=this.getExternalClickTargetUrl(t);return n?!So(n,this.allowedDomains):!1}getExternalClickTargetUrl(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return null;let{doc:r}=nr(document,t.iframe_id),o=Pt(r,n);if(!o)return null;let s=Ya(o),a=s?.href||s?.getAttribute("href")||"";return Io(a,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,reason:n,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:n,allowFallback:!0,output:{success:!1,error:{code:"DOMAIN_SCOPE_BLOCKED",message:n,missing:[],next_action:o==="block"?"Stay on the configured domain or update allowedDomains/domainScopeMode.":"Use open_new_tab to access external pages without losing context.",retryable:!1},blocked_url:t,current_url:window.location.href,allowed_domains:this.allowedDomains,policy_action:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,allowedDomains:this.allowedDomains,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!So(t,this.allowedDomains),o=this.openVerifiedPopup(t),s;if(o.opened&&this.registerOpenedTab)try{s=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}let a=o.opened&&!s&&!!this.registerOpenedTab;if(!o.opened){let T="Browser popup settings blocked opening a new tab.";return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:n.reason||T,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:s},errorDetails:{code:"POPUP_BLOCKED",message:T,retryable:!0,next_action:"Allow popups for this site and try again."}}}let i=n?.policyBlocked?n.reason||"Opened in a new tab due to domain policy.":void 0;n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:i||"Opened in new tab due to domain policy.",allowedDomains:this.allowedDomains,openedInNewTab:!0});let u=[];return a&&u.push("Tab opened but registration failed; tab may not be targetable."),o.verified||u.push("Tab open was triggered, but browser did not return a popup handle."),{success:!0,output:{url:t,external:r,logicalTabId:s,openedInNewTab:!0,openVerification:o.verified?"verified":"unverified",policyBlocked:!!n?.policyBlocked,message:i,...u.length?{warning:u.join(" ")}:{}},allowFallback:!0}}openVerifiedPopup(t){let n=window.open("about:blank","_blank");if(n){try{n.opener=null}catch{}try{n.location.href=t}catch{}return{opened:!0,verified:!0}}try{let r=window.open(t,"_blank");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}}catch{}try{let r=window.open(t,"_blank","noopener,noreferrer");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}return{opened:!0,verified:!1}}catch{}try{let r=document.createElement("a");return r.href=t,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),{opened:!0,verified:!1}}catch{return{opened:!1,verified:!1}}}async openElementInNewTab(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return{success:!1,error:"click_element with open_in_new_tab requires element_id.",allowFallback:!0};let{doc:r}=nr(document,t.iframe_id),o=Pt(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let s=Ya(o),a=s?.href||s?.getAttribute("href")||"",i=Io(a,window.location.href);return i?await this.openUrlInNewTab(i,{policyBlocked:!1}):{success:!1,error:"click_element open_in_new_tab only works when target resolves to a valid link URL.",allowFallback:!0}}async waitForElement(t){let n=String(t.selector||"").trim(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),s=document;for(;Date.now()-o<r;){let a=null;try{a=s.querySelector(n)}catch{a=null}if(a||(a=ud(s,n)),a)return{success:!0};await new Promise(i=>setTimeout(i,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=ni(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let s of n){let a=Pt(document,s);if(!a){o.push(`element_id ${s} not found`);continue}try{let i=await dd(a);if(!i?.data||!i?.mimeType){o.push(`element_id ${s}: unsupported image`);continue}r.push({element_id:s,...i})}catch(i){o.push(`element_id ${s}: ${i?.message||String(i)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await Sa(0,n,document?.referrer||null),o=r.bytes,s=o.byteLength,a=r.mimeType||t.mime_type||"application/octet-stream",i=t.file_name||r.fileName,u=1024*1024;if(s<=u)return{kind:"upload_file",inlineB64:Ka(o),byteLength:s,mimeType:a,fileName:i};this.ensureUploadProvider();let T=crypto.randomUUID();return this.uploadStore.set(T,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:T,byteLength:s,mimeType:a,fileName:i,durable:!1}}catch{return}}};function nd(e){return e==="open_url_new_tab"?L.open_new_tab:String(e||"").trim()}function Ga(e){return e==="host_only"?"host_only":"registrable_domain"}function rd(e){if(e==="allow")return"allow";if(e==="block_new_tab")return"open_new_tab_notice"}function qa(e,t){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:rd(t)||"open_new_tab_notice"}function Os(e,t,n){let r=Array.isArray(e)?e:[],o=new Set;for(let s of r){let a=String(s||"").trim().toLowerCase().replace(/^\./,"");a&&o.add(a)}if(!o.size){let s=od(t,n);s&&o.add(s)}return Array.from(o)}function od(e,t){let n=String(e||"").trim().toLowerCase();if(!n)return"";if(n==="localhost"||/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(n))return`=${n}`;if(t==="host_only")return`=${n}`;let r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function Io(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function So(e,t){let n=sd(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(id(n,r))return!0;return!1}function sd(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function id(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function Ao(e){return e.length?e.map(t=>{let n=String(t||"");return n.startsWith("=")?n.slice(1):n}).join(", "):"*"}function Ya(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function Co(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var Xa=new Set([L.describe_images,L.wait_action,L.wait_for_element,L.answer_task,L.solve_captcha,L.network_run_recipe]),ad=new Set([L.goto_url,L.google_search,L.go_back,L.go_forward,L.refresh_page,L.open_new_tab,L.switch_tab,L.close_tab]);function cd(e){return{frameworks:(e.frameworks||[]).filter(n=>n in es).map(n=>es[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function za(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s=="function"){await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function ld(e,t){if(t!==L.click_element)return"standard";let n=An(e||"");if(!n)return"standard";let r=new Set(n.entries.map(u=>tn[u.id]).filter(u=>typeof u=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let a=r.has("touchstart"),i=r.has("touchend");return a&&i?"touch-sequence":"standard"}function Ka(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function ud(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let s of Array.from(o))if((s.textContent||"").trim().toLowerCase().includes(n)||(s.getAttribute("aria-label")||"").toLowerCase().includes(n))return s;return null}async function dd(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),s=Qa(o);if(!s)throw new Error("canvas toDataURL failed");return s}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await ja(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await ja(r[2],e.getAttribute("aria-label")||void 0);throw new Error("unsupported element")}function Qa(e){let t=/^data:([^;]+);base64,(.*)$/.exec(e);return t?{mimeType:t[1],data:t[2]}:null}async function ja(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let i=Qa(e);if(!i)throw new Error("invalid data url");return{...i,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),s=Ka(o),a=r.type||"image/png";return{data:s,mimeType:a,displayName:t}}function Ja(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:s,params:a}=r;try{let i=t[s];if(!i)throw new Error(`No handler for ${s}`);let u=await i(a);e.postMessage({t:"res",id:o,ok:!0,result:u})}catch(i){e.postMessage({t:"res",id:o,ok:!1,error:{message:i?.message||String(i)}})}}}var fd="Rover",pd="https://www.rtrvr.ai/rover/mascot.mp4",hd="https://www.rtrvr.ai/rover/mascot.webm";function tc(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Za(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function md(e){return e.status?e.status:e.kind==="tool_start"||e.kind==="plan"||e.kind==="thought"?"pending":e.kind==="tool_result"?"success":e.kind==="error"?"error":"info"}function gd(e){let t=String(e.title||"").trim().toLowerCase();return t.startsWith("running ")?`tool:${t.replace(/^running\s+/,"").trim()}`:t.endsWith(" completed")?`tool:${t.replace(/\s+completed$/,"").trim()}`:t==="run started"||t==="run resumed"||t==="run completed"?"run":e.kind==="status"?`status:${t||"status"}`:e.id||tc("trace")}function ir(e){return String(e||"").trim()}function bd(e){let t=String(e||"").trim();return t?t.slice(0,64):fd}function Ed(e){let t=String(e||"").trim();return t?t[0].toUpperCase():"R"}function wd(e){return String(e||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,3).toUpperCase()||"RVR"}function nc(e){let t=ir(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=ir(n[2]||t);return{stage:r,plainTitle:o||t}}function yd(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed")return"detail";if(e.kind==="status"){let n=nc(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function Us(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let s=document.createElement("a");s.className="rvLink",s.href=o[2],s.target="_blank",s.rel="noopener noreferrer",s.textContent=o[1],e.appendChild(s)}else if(o[3]){let s=document.createElement("strong");s.textContent=o[3],e.appendChild(s)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Sr(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
-
`),r=null;for(let o of n){let s=o.trim();if(!s){r&&(t.appendChild(r),r=null);continue}if(s==="---"){r&&(t.appendChild(r),r=null);let u=document.createElement("hr");u.className="rvSep",t.appendChild(u);continue}if(s.startsWith("- ")){r||(r=document.createElement("ul"),r.className="rvList");let u=document.createElement("li");
|
|
12
|
-
`),o=0,s=0;for(let
|
|
13
|
-
`),
|
|
14
|
-
`),u=document.createElement("div");if(u.className="expandPreview",u.appendChild(
|
|
2
|
+
"use strict";var __roverSDK=(()=>{var $r=Object.defineProperty;var Gc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Yc=Object.prototype.hasOwnProperty;var Xc=(e,t,n)=>t in e?$r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var zc=(e,t)=>{for(var n in t)$r(e,n,{get:t[n],enumerable:!0})},Kc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qc(t))!Yc.call(e,o)&&o!==n&&$r(e,o,{get:()=>t[o],enumerable:!(r=Gc(t,o))||r.enumerable});return e};var jc=e=>Kc($r({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Xc(e,typeof t!="symbol"?t+"":t,n);var Lf={};zc(Lf,{boot:()=>Fr,close:()=>ss,endTask:()=>is,getState:()=>ui,hide:()=>ci,init:()=>si,installGlobal:()=>$c,newTask:()=>Wr,open:()=>Br,registerTool:()=>di,send:()=>li,show:()=>ai,shutdown:()=>ii,update:()=>ns});var L;(function(e){e.click_element="click_element",e.type_into_element="type_into_element",e.type_and_enter="type_and_enter",e.select_dropdown_value="select_dropdown_value",e.clear_element="clear_element",e.focus_element="focus_element",e.check_field_validity="check_field_validity",e.select_text="select_text",e.hover_element="hover_element",e.right_click_element="right_click_element",e.double_click_element="double_click_element",e.press_key="press_key",e.mouse_wheel="mouse_wheel",e.dispatch_pointer_path="dispatch_pointer_path",e.drag_element="drag_element",e.drag_and_drop="drag_and_drop",e.adjust_slider="adjust_slider",e.scroll_page="scroll_page",e.scroll_to_element="scroll_to_element",e.swipe_element="swipe_element",e.long_press_element="long_press_element",e.pinch_zoom="pinch_zoom",e.go_back="go_back",e.go_forward="go_forward",e.goto_url="goto_url",e.refresh_page="refresh_page",e.open_new_tab="open_new_tab",e.switch_tab="switch_tab",e.close_tab="close_tab",e.describe_images="describe_images",e.google_search="google_search",e.network_run_recipe="network_run_recipe",e.copy_text="copy_text",e.paste_text="paste_text",e.wait_action="wait_action",e.wait_for_element="wait_for_element",e.answer_task="answer_task",e.upload_file="upload_file",e.solve_captcha="solve_captcha"})(L||(L={}));var Df=new Set(Object.values(L));var Qc=40;function pi(e){let t=Array.isArray(e?.element_ids)?e.element_ids:e?.element_id!=null?[e.element_id]:[];return Array.from(new Set(t.map(r=>Math.trunc(Number(r))))).filter(r=>Number.isFinite(r)&&r>0).slice(0,Qc)}var _t;(function(e){e[e.Unknown=0]="Unknown",e[e.React=1]="React",e[e.Vue=2]="Vue",e[e.Angular=3]="Angular",e[e.Svelte=4]="Svelte",e[e.JQuery=5]="JQuery"})(_t||(_t={}));var hi={[_t.Unknown]:"unknown",[_t.React]:"react",[_t.Vue]:"vue",[_t.Angular]:"angular",[_t.Svelte]:"svelte",[_t.JQuery]:"jquery"},as={react:_t.React,vue:_t.Vue,angular:_t.Angular,svelte:_t.Svelte,jquery:_t.JQuery},$e;(function(e){e[e.Other=0]="Other",e[e.Inline=1]="Inline",e[e.Delegated=2]="Delegated",e[e.React=3]="React",e[e.Vue=4]="Vue",e[e.Angular=5]="Angular",e[e.Svelte=6]="Svelte",e[e.JQuery=7]="JQuery",e[e.Native=8]="Native"})($e||($e={}));var Ff={[$e.Other]:"other",[$e.Inline]:"inline",[$e.Delegated]:"delegated",[$e.React]:"react",[$e.Vue]:"vue",[$e.Angular]:"angular",[$e.Svelte]:"svelte",[$e.JQuery]:"jquery",[$e.Native]:"native"},Hf={inline:$e.Inline,delegated:$e.Delegated,react:$e.React,vue:$e.Vue,angular:$e.Angular,svelte:$e.Svelte,jquery:$e.JQuery,other:$e.Other,native:$e.Native},fe;(function(e){e[e.click_element=1]="click_element",e[e.type_into_element=2]="type_into_element",e[e.type_and_enter=3]="type_and_enter",e[e.select_dropdown_value=4]="select_dropdown_value",e[e.clear_element=5]="clear_element",e[e.focus_element=6]="focus_element",e[e.hover_element=7]="hover_element",e[e.right_click_element=8]="right_click_element",e[e.double_click_element=9]="double_click_element",e[e.long_press_element=10]="long_press_element",e[e.drag_element=11]="drag_element",e[e.drag_and_drop=12]="drag_and_drop",e[e.swipe_element=13]="swipe_element",e[e.adjust_slider=14]="adjust_slider",e[e.describe_images=15]="describe_images",e[e.scroll_to_element=16]="scroll_to_element",e[e.paste_text=17]="paste_text",e[e.check_field_validity=18]="check_field_validity",e[e.select_text=19]="select_text",e[e.mouse_wheel=20]="mouse_wheel",e[e.copy_text=21]="copy_text",e[e.upload_file=22]="upload_file",e[e.go_back=23]="go_back",e[e.go_forward=24]="go_forward",e[e.refresh_page=25]="refresh_page",e[e.press_key=26]="press_key",e[e.scroll_page=27]="scroll_page",e[e.wait_action=28]="wait_action",e[e.wait_for_element=29]="wait_for_element",e[e.pinch_zoom=30]="pinch_zoom",e[e.goto_url=31]="goto_url",e[e.google_search=32]="google_search",e[e.open_new_tab=33]="open_new_tab",e[e.switch_tab=34]="switch_tab",e[e.close_tab=35]="close_tab",e[e.solve_captcha=36]="solve_captcha",e[e.answer_task=37]="answer_task",e[e.dispatch_pointer_path=38]="dispatch_pointer_path",e[e.network_run_recipe=40]="network_run_recipe"})(fe||(fe={}));var Gr={[L.click_element]:fe.click_element,[L.type_into_element]:fe.type_into_element,[L.type_and_enter]:fe.type_and_enter,[L.select_dropdown_value]:fe.select_dropdown_value,[L.clear_element]:fe.clear_element,[L.focus_element]:fe.focus_element,[L.hover_element]:fe.hover_element,[L.right_click_element]:fe.right_click_element,[L.double_click_element]:fe.double_click_element,[L.long_press_element]:fe.long_press_element,[L.drag_element]:fe.drag_element,[L.drag_and_drop]:fe.drag_and_drop,[L.swipe_element]:fe.swipe_element,[L.adjust_slider]:fe.adjust_slider,[L.describe_images]:fe.describe_images,[L.scroll_to_element]:fe.scroll_to_element,[L.paste_text]:fe.paste_text,[L.check_field_validity]:fe.check_field_validity,[L.select_text]:fe.select_text,[L.mouse_wheel]:fe.mouse_wheel,[L.copy_text]:fe.copy_text,[L.upload_file]:fe.upload_file,[L.go_back]:fe.go_back,[L.go_forward]:fe.go_forward,[L.refresh_page]:fe.refresh_page,[L.press_key]:fe.press_key,[L.scroll_page]:fe.scroll_page,[L.wait_action]:fe.wait_action,[L.wait_for_element]:fe.wait_for_element,[L.pinch_zoom]:fe.pinch_zoom,[L.goto_url]:fe.goto_url,[L.google_search]:fe.google_search,[L.open_new_tab]:fe.open_new_tab,[L.switch_tab]:fe.switch_tab,[L.close_tab]:fe.close_tab,[L.solve_captcha]:fe.solve_captcha,[L.answer_task]:fe.answer_task,[L.dispatch_pointer_path]:fe.dispatch_pointer_path,[L.network_run_recipe]:fe.network_run_recipe},mi=Object.fromEntries(Object.entries(Gr).map(([e,t])=>[t,e]));function qr(e){let t=[];return e&&(e&1&&t.push("native"),e&2&&t.push("inline"),e&4&&t.push("react"),e&8&&t.push("vue"),e&16&&t.push("angular"),e&32&&t.push("svelte"),e&64&&t.push("jquery"),e&128&&t.push("delegated"),e&256&&t.push("other")),t}var bi={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},ft={...bi},Xr=globalThis;function Ei(e){ft={...bi,...e||{}}}function In(){return ft.signalProvider??null}function Xe(){try{return typeof Xr.document<"u"?Xr.document:null}catch{return null}}function Kt(){try{return typeof Xr.window<"u"?Xr.window:null}catch{return null}}function G(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??Xe()??{}}function oe(e,t){return G(e,t?t.document:null)?.defaultView??t??Kt()??{}}function X(e,t){return e?.defaultView??t??Kt()??{}}function zr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Kr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function cs(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Sn(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function jr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function Tt(e,t){try{return e[t]}catch{return}}function jt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function wi(e,t){let n=Tt(t,"HTMLAnchorElement");return n?e instanceof n:jt(e,"A")}function Lt(e,t){let n=Tt(t,"HTMLInputElement");return n?e instanceof n:jt(e,"INPUT")}function Ft(e,t){let n=Tt(t,"HTMLTextAreaElement");return n?e instanceof n:jt(e,"TEXTAREA")}function yi(e,t){let n=Tt(t,"HTMLLabelElement");return n?e instanceof n:jt(e,"LABEL")}function _i(e,t){let n=Tt(t,"HTMLSelectElement");return n?e instanceof n:jt(e,"SELECT")}function Ti(e,t){let n=Tt(t,"HTMLSlotElement");return n?e instanceof n:jt(e,"SLOT")}function vi(e,t){let n=Tt(t,"HTMLButtonElement");return n?e instanceof n:jt(e,"BUTTON")}function xi(e,t){let n=Tt(t,"HTMLImageElement");return n?e instanceof n:jt(e,"IMG")}function Ri(e,t){let n=Tt(t,"HTMLVideoElement");return n?e instanceof n:jt(e,"VIDEO")}function ki(e,t){let n=Tt(t,"HTMLCanvasElement");return n?e instanceof n:jt(e,"CANVAS")}function Ge(e,t){if(!e||e.nodeType!==1)return!1;let n=Tt(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function vt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function An(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function pr(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Jc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=Tt(t,"Document");return n?e instanceof n:!1}function Zc(e,t){if(!e)return!1;let n=Tt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function Qr(e){try{return e.document}catch{return null}}function Jr(e,t){if(Jc(e,t))try{return e.documentElement}catch{return null}if(Zc(e,t)){let n=Qr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Yr(e){if(!e)return null;if(typeof e=="string")return e;if(typeof e=="object"&&typeof e.baseVal=="string")return e.baseVal;try{return String(e)}catch{return null}}function gi(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function Ii(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=gi(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=Yr(o.href)||Yr(o.src)||Yr(o.data)||Yr(o.action);return s?gi(s,e,t):null}catch{return null}}var Si=["click","dblclick","doubleclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","mouseover","mouseout","contextmenu","auxclick","keydown","keyup","keypress","input","change","submit","reset","select","search","invalid","beforeinput","focus","blur","focusin","focusout","touchstart","touchend","touchmove","touchcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","dragstart","dragend","drag","dragenter","dragleave","dragover","drop","copy","cut","paste","scroll","wheel","play","pause","ended","volumechange","seeking","seeked","animationstart","animationend","transitionend","transitionstart","resize","toggle","fullscreenchange","load","error","abort","beforeunload","unload","hashchange","popstate","storage","message"],_e={};Si.forEach((e,t)=>{_e[e]=t});var nn={};Si.forEach((e,t)=>{nn[t]=e});function Cn(e){if(!e)return null;let t=e.trim();if(!t||!t.includes("~"))return null;let n=[];for(let r of t.split(",")){if(!r)continue;let[o,s]=r.split("~"),i=Number(o);if(!Number.isFinite(i))continue;let a=s&&parseInt(s,36)||0;n.push({id:i,mask:a})}return n.length?{entries:n}:null}function el(e){let t=Cn(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function hr(e){return zn(e).map(n=>nn[n]).filter(n=>!!n)}function zn(e){let t=In();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(pn),r=el(n);return!r||r.length===0?[]:r}var ls=["media"],Ai=new Set(ls),us=["alert","alertdialog","application","directory","feed","grid","log","marquee","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","note","radiogroup","scrollbar","search","switch","tab","tablist","tabpanel","timer","toolbar","tooltip","tree","treegrid","treeitem"];var Ci=new Set(us),rn=new Set(["button","checkbox","combobox","figure","img","link","listbox","option","radio","scrollbar","searchbox","separator","slider","spinbutton","switch","tab","tabpanel","textbox","tooltip","treeitem","grid","gridcell","table","cell","columnheader","rowheader","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","tree","treegrid","radiogroup","application","dialog","alertdialog","alert","status","progressbar","meter","search","code","media"]),mr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var Mi=["none","presentation"],me;(function(e){e[e.ANCESTOR_ROLE_REQUIRED=6]="ANCESTOR_ROLE_REQUIRED",e[e.PROPERTY_VALUE_MATCH=5]="PROPERTY_VALUE_MATCH",e[e.HAS_TABLE_ROW_DATA=7]="HAS_TABLE_ROW_DATA",e[e.BOOLEAN_PROPERTY=0]="BOOLEAN_PROPERTY",e[e.ATTRIBUTE_GREATER_THAN=2]="ATTRIBUTE_GREATER_THAN",e[e.HAS_TABLE_COLUMN_DATA=8]="HAS_TABLE_COLUMN_DATA",e[e.FORBIDDEN_ANCESTORS=1]="FORBIDDEN_ANCESTORS",e[e.HAS_ACCESSIBLE_NAME=4]="HAS_ACCESSIBLE_NAME",e[e.ATTRIBUTE_LESS_THAN=3]="ATTRIBUTE_LESS_THAN"})(me||(me={}));var Li={a:["link"],area:["link"],article:["article"],aside:["complementary"],body:["document"],button:["button"],datalist:["listbox"],dd:["definition"],details:["group"],dfn:["term"],dialog:["dialog"],dt:["term"],fieldset:["group"],figure:["figure"],footer:["contentinfo"],form:["form"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"],header:["banner"],hr:["separator"],img:["img"],input:["button","checkbox","combobox","radio","searchbox","slider","spinbutton","textbox"],li:["listitem"],link:["link"],main:["main"],math:["math"],menu:["list"],nav:["navigation"],ol:["list"],optgroup:["group"],option:["option"],output:["status"],progress:["progressbar"],section:["region"],select:["combobox","listbox"],summary:["button"],table:["table"],tbody:["rowgroup"],td:["cell","gridcell"],textarea:["textbox"],tfoot:["rowgroup"],th:["cell","columnheader","gridcell","rowheader"],thead:["rowgroup"],tr:["row"],ul:["list"],code:["code"],pre:["code"]},gr={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["checkbox"]}]}]},navigation:{selector:"nav"},row:{selector:"tr"},complementary:{selector:"aside"},table:{selector:"table"},gridcell:{conditionalSelectors:[{selector:"td",conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:me.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:me.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:me.FORBIDDEN_ANCESTORS,selector:'section,nav,main,aside,article,[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"]'}]}]},definition:{selector:"dd"},button:{selector:"summary,button",conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:me.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["radio"]}]}]},columnheader:{selector:'th[scope="colgroup"],th[scope="col"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:me.HAS_ACCESSIBLE_NAME}]}]},document:{selector:"body"},option:{selector:"select > option,select > optgroup > option,datalist > option"},separator:{selector:"hr"},link:{selector:"area[href],a[href],link[href]"},img:{selector:"img[alt],img:not([alt])"},main:{selector:"main"},searchbox:{conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:me.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:me.HAS_TABLE_ROW_DATA,hasData:!0}]}]},rowheader:{selector:'th[scope="rowgroup"],th[scope="row"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:me.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:me.ATTRIBUTE_GREATER_THAN,attribute:"size",value:1}]}]},group:{selector:"optgroup,fieldset,details"},term:{selector:"dt,dfn"},progressbar:{selector:"progress"},figure:{selector:"figure"},spinbutton:{conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:me.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:me.FORBIDDEN_ANCESTORS,selector:'[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"],section,nav,main,aside,article'}]}]},rowgroup:{selector:"thead,tfoot,tbody"},code:{selector:"code,pre"}},pn="rtrvr-ls",on="rtrvr-ro",ds="rtrvr-mw-ready",br="rtrvr-mw-busy",fs="rtrvr-mwa-ready",Ni=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowgroup","rowheader","switch","tab","tooltip","tree","treeitem","sectionhead","definition","term","deletion","insertion"]),Di=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],Oi=["h1","h2","h3","h4","h5","h6"],Ui="http://www.w3.org/1999/xhtml",Fi="http://www.w3.org/2000/svg",at="rtrvr-label";var to=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Mn="CODE",Ln="PRE",Hi="aria-hidden",Pi="target";var Zr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Zr||(Zr={}));var Kn;(function(e){e[e["data-icon"]=13]="data-icon",e[e["data-name"]=14]="data-name",e[e["data-tooltip"]=15]="data-tooltip",e[e["data-label"]=16]="data-label"})(Kn||(Kn={}));var eo;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(eo||(eo={}));var ps=new Set([_e.click,_e.dblclick,_e.doubleclick,_e.contextmenu,_e.auxclick,_e.pointerdown,_e.pointerup,_e.mousedown,_e.mouseup,_e.touchstart,_e.touchend,_e.keydown,_e.keyup,_e.input,_e.beforeinput,_e.change,_e.submit,_e.reset,_e.paste,_e.dragstart,_e.dragend,_e.drop]),Bi=new Set([...ps,_e.scroll,_e.wheel,_e.mouseenter,_e.mouseover,_e.focus,_e.blur,_e.focusin,_e.focusout]),no=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),hs=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),ms=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var Er;(function(e){e[e.ELEMENT=1]="ELEMENT",e[e.ATTRIBUTE=2]="ATTRIBUTE",e[e.TEXT=3]="TEXT",e[e.CDATA_SECTION=4]="CDATA_SECTION",e[e.ENTITY_REFERENCE=5]="ENTITY_REFERENCE",e[e.ENTITY=6]="ENTITY",e[e.PROCESSING_INSTRUCTION=7]="PROCESSING_INSTRUCTION",e[e.COMMENT=8]="COMMENT",e[e.DOCUMENT=9]="DOCUMENT",e[e.DOCUMENT_TYPE=10]="DOCUMENT_TYPE",e[e.DOCUMENT_FRAGMENT=11]="DOCUMENT_FRAGMENT",e[e.NOTATION=12]="NOTATION"})(Er||(Er={}));var wr;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(wr||(wr={}));var ro;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT",e[e.ATOMIC=2]="ATOMIC",e[e.AUTOCOMPLETE=3]="AUTOCOMPLETE",e[e.COLCOUNT=4]="COLCOUNT",e[e.COLINDEX=5]="COLINDEX",e[e.COLSPAN=6]="COLSPAN",e[e.ERRORMESSAGE=7]="ERRORMESSAGE",e[e.HASPOPUP=8]="HASPOPUP",e[e.LEVEL=9]="LEVEL",e[e.LIVE=10]="LIVE",e[e.MULTILINE=11]="MULTILINE",e[e.MULTISELECTABLE=12]="MULTISELECTABLE",e[e.ORIENTATION=13]="ORIENTATION",e[e.PLACEHOLDER=14]="PLACEHOLDER",e[e.POSINSET=15]="POSINSET",e[e.READONLY=16]="READONLY",e[e.RELEVANT=17]="RELEVANT",e[e.REQUIRED=18]="REQUIRED",e[e.ROWCOUNT=19]="ROWCOUNT",e[e.ROWINDEX=20]="ROWINDEX",e[e.ROWSPAN=21]="ROWSPAN",e[e.SETSIZE=22]="SETSIZE",e[e.SORT=23]="SORT",e[e.VALUEMAX=24]="VALUEMAX",e[e.VALUEMIN=25]="VALUEMIN",e[e.KEYSHORTCUTS=26]="KEYSHORTCUTS",e[e.ROLEDESCRIPTION=27]="ROLEDESCRIPTION"})(ro||(ro={}));var oo;(function(e){e[e.BUSY=0]="BUSY",e[e.CHECKED=1]="CHECKED",e[e.CURRENT=2]="CURRENT",e[e.EXPANDED=3]="EXPANDED",e[e.INVALID=4]="INVALID",e[e.PRESSED=5]="PRESSED",e[e.SELECTED=6]="SELECTED"})(oo||(oo={}));var bt;(function(e){e[e["rtrvr-label"]=0]="rtrvr-label",e[e.role=1]="role",e[e.value=2]="value",e[e.alt=3]="alt",e[e.list=4]="list",e[e.title=5]="title",e[e["aria-label"]=6]="aria-label",e[e["aria-labelledby"]=7]="aria-labelledby",e[e["aria-description"]=8]="aria-description",e[e["aria-describedby"]=9]="aria-describedby",e[e.disabled=10]="disabled",e[e.href=11]="href",e[e.placeholder=12]="placeholder",e[e.type=13]="type",e[e.tabindex=14]="tabindex",e[e.id=15]="id",e[e._ngcontent=16]="_ngcontent",e[e["ng-reflect-*"]=17]="ng-reflect-*",e[e["data-reactroot"]=18]="data-reactroot",e[e["data-v-*"]=19]="data-v-*",e[e.required=20]="required",e[e.contenteditable=21]="contenteditable",e[e.accept=22]="accept"})(bt||(bt={}));var nt;(function(e){e[e.display=0]="display",e[e.content=1]="content",e[e.beforeDisplay=2]="beforeDisplay",e[e.afterDisplay=3]="afterDisplay",e[e.beforeContent=4]="beforeContent",e[e.afterContent=5]="afterContent",e[e.width=6]="width",e[e.height=7]="height",e[e.minWidth=8]="minWidth",e[e.minHeight=9]="minHeight",e[e.position=10]="position",e[e.top=11]="top",e[e.left=12]="left",e[e.right=13]="right",e[e.bottom=14]="bottom",e[e.paddingTop=15]="paddingTop",e[e.paddingRight=16]="paddingRight",e[e.paddingBottom=17]="paddingBottom",e[e.paddingLeft=18]="paddingLeft",e[e.marginTop=19]="marginTop",e[e.marginRight=20]="marginRight",e[e.marginBottom=21]="marginBottom",e[e.marginLeft=22]="marginLeft",e[e.cursor=23]="cursor",e[e.opacity=24]="opacity",e[e.visibility=25]="visibility",e[e.overflowX=26]="overflowX",e[e.overflowY=27]="overflowY",e[e.backgroundColor=28]="backgroundColor",e[e.color=29]="color",e[e.borderWidth=30]="borderWidth",e[e.borderStyle=31]="borderStyle",e[e.boxShadow=32]="boxShadow",e[e.outline=33]="outline"})(nt||(nt={}));var sn;(function(e){e[e.text=0]="text",e[e.elText=1]="elText",e[e.viewBox=2]="viewBox",e[e.paths=3]="paths",e[e.pathData=4]="pathData",e[e.circles=5]="circles",e[e.rects=6]="rects",e[e.lines=7]="lines",e[e.polygons=8]="polygons",e[e.polylines=9]="polylines",e[e.ellipses=10]="ellipses"})(sn||(sn={}));var tl=[...us,...Object.keys(gr),...ls],Wi=[...new Set(tl)],jn={};Wi.forEach((e,t)=>{jn[e]=t});var yr={};Wi.forEach((e,t)=>{yr[t]=e});var so=class{constructor(t=1){$(this,"currentId");this.currentId=t}generateId(){let t=this.currentId;return this.currentId++,t}initialize(t=1){this.currentId=t}getCurrentValue(){return this.currentId}};function _r(e){let t=In();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(on);if(!n)return null;let r=n.trim();if(!r)return null;if(r.startsWith("s:"))return r.slice(2);if(/^\d+$/.test(r)){let o=Number(r);if(Number.isFinite(o)){let s=yr[o];if(s)return s}}return r}function Qn(e){return Array.from(new Set(e))}function Vi(e,t){if(!e||e.length===0)return Qn(t);let n=new Set([...e,...t]);return Qn(Array.from(n))}function xt(e,t){let r=In()?.getEventHandlerIds?.(e)??zn(e),o=r.length>0&&r.some(a=>ps.has(a)),s=io(e),i=t?mr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}}var nl=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function rl(e){let n=oe(e).getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"||n.pointerEvents==="none")return!1;let r=e.getBoundingClientRect();return!(r.width===0||r.height===0)}function ol(e){let t=oe(e);if(!Lt(e,t))return!1;let n=(e.type||"text").toLowerCase();return nl.has(n)?!e.disabled&&!e.readOnly:!1}function sl(e){let t=oe(e);return Ft(e,t)&&!e.disabled&&!e.readOnly}function il(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function io(e){return!e||!rl(e)?!1:!!(ol(e)||sl(e)||il(e))}function Tr(e){if(!e)return null;let t=e.match(/^\s*\[id=(\d+)\]/);if(t?.[1]){let o=parseInt(t[1],10);return Number.isFinite(o)?o:null}let n=/\[id=(\d+)\]/g,r;for(;r=n.exec(e);){let o=r.index??0,s=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(s)||s.includes("iframeRoot="))continue;let i=parseInt(r[1],10);if(Number.isFinite(i))return i}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let s=parseInt(o[1],10);return Number.isFinite(s)?s:null}}catch{}return null}function vr(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function $i({element:e,elementID:t,frameContextLabel:n}){let r=!ft.disableDomAnnotations,o=[`[id=${t}]`],s=oe(e);if(pr(e)){let u=vr(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${u}]`)}if(n){let u=vr(n);o.push(`[iframeRoot=${u}]`)}if(xi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(Ri(e,s)||ki(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Lt(e,s)||Ft(e,s)){let u=al(e);o.push(...u)}e.getAttribute(Hi)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&wi(e,s)&&e.setAttribute(Pi,"_self");let a=o.join(" ");return r&&e.setAttribute(at,a),a}function al(e){let t=[],n=oe(e),r=Lt(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=vr(e.name);o&&t.push(`[name=${o}]`)}if(r&&e.multiple&&t.push("[multiple]"),r&&(e.type==="checkbox"||e.type==="radio")&&t.push(`[checked=${e.checked}]`),r&&e.type==="file"&&e.files?.length&&t.push(`[files=${e.files.length}]`),r&&e.type==="number"&&(e.min!==""&&t.push(`[min=${e.min}]`),e.max!==""&&t.push(`[max=${e.max}]`),e.step!==""&&e.step!=="1"&&t.push(`[step=${e.step}]`)),r&&e.type==="range"&&(t.push(`[min=${e.min||"0"}]`),t.push(`[max=${e.max||"100"}]`),t.push(`[value=${e.value}]`)),e.readOnly&&t.push("[readonly]"),e.required&&t.push("[required]"),e.maxLength&&e.maxLength!==-1&&e.maxLength<524288&&t.push(`[maxlength=${e.maxLength}]`),r&&e.pattern&&t.push("[pattern]"),e.autocomplete&&e.autocomplete!=="off"&&t.push(`[autocomplete=${e.autocomplete}]`),e.placeholder){let o=vr(e.placeholder).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o&&t.push(`[placeholder="${o}"]`)}if(e.value){let o=e.value;r&&e.type==="password"&&(o="*".repeat(Math.min(o.length,10)));let s=vr(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${s}"]`)}return t}var xr=new so,gs=new WeakMap;function Gi(){gs=new WeakMap}function ao(e){let t=gs.get(e);if(t)return t;let n=xr.generateId();return gs.set(e,n),n}var co=new Map,bs=new WeakMap;function qi(){co.clear(),bs=new WeakMap}function Es(e,t){try{typeof WeakRef<"u"?co.set(e,new WeakRef(t)):co.set(e,t)}catch{}}function Rr(e){let t=co.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function hn(e){let t=null,n=ao(e);if(ft.frameContextLabel)t=ft.frameContextLabel;else{let o=Xe();if(o&&e.ownerDocument!==o)try{let i=e.ownerDocument?.defaultView?.frameElement?.getAttribute(at)||"",a=i?Tr(i):null;t=a?String(a):null}catch{t=""}}let r=$i({element:e,elementID:n,frameContextLabel:t});if(Es(n,e),r)try{bs.set(e,r)}catch{}return r}function Yi(e){return bs.get(e)??null}function ws(e,t){try{e.querySelectorAll?.(`[${at}]`)?.forEach(r=>r.removeAttribute(at))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&ws(o,t)}catch{}}catch{}if(t.includeIframes)try{let n=e.querySelectorAll?.("iframe");if(n)for(let r of Array.from(n))try{let o=Sn(r);o?.body&&ws(o.body,t)}catch{}}catch{}}function Xi(e,t={}){if(ft.disableDomAnnotations)return;let n=An(e)?oe(e):X(e)??window,r=Jr(e,n)??e;if(r){try{r.removeAttribute?.(at)}catch{}ws(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var mn={},ys=new WeakMap,lo=new WeakSet;function zi(){mn={},ys=new WeakMap,lo=new WeakSet,Gi()}function ct({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:i,elementContext:a}){let u=ao(e);Es(u,e);let v=mn[u];if(i){if(!v){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},_=e.nodeName;_&&_.trim()&&(p.elementName=_);let A=e.getAttribute("role");A&&(p.preservedAttributes={1:A});let S=e.tagName;S&&(p.elementTag=S),mn[u]=p}}else{if(v&&!v.provisionalFromParent){if((o||Jn(e))&&(v.isFrameElement=!0,s&&s.length>0&&(v.frameContent=s)),a){let{eventHandlerIndices:p,isEditableRegion:_}=a;if(p&&p.length>0){let A=Qn(p);A.length>0&&(v.eventHandlers=Vi(v.eventHandlers,A))}_&&(v.isEditable=!0)}return u}if(lo.has(e))return u;lo.add(e);try{mn[u]=Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:a})}finally{lo.delete(e)}}return u}function kr(e){let t=ys.get(e);if(t!==void 0)return t;let r=(e.textContent||"").replace(/\s+/g," ").trim(),o=e.data?.replace(/\s+/g," ").trim();if(!r&&!o)return 0;let s=xr.generateId(),i={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(i.rawData=o),mn[s]=i,ys.set(e,s),s}function Qi(e,t){let n=Zi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Ir))}function Ji(e,t){let n=Zi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Ir))}var fo=class{constructor(t=[]){$(this,"cells");$(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);$(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});$(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));$(this,"getRows",()=>this.cells);$(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,s=-1;for(let i=0;i<this.rowCount;i++){let a=this.getRowAt(i),u=a.indexOf(t);u!==-1&&(o=Math.max(o,a.lastIndexOf(t)),s=Math.max(s,i),n=Math.min(n,u),r=Math.min(r,i))}return{minX:n,minY:r,maxX:o,maxY:s}});$(this,"merge",t=>{this.cells=this.getRows().concat(t.getRows())});this.cells=t}get rowCount(){return this.cells.length}get columnCount(){return Math.max(...this.cells.map(t=>t.length))}};function Zi(e){let n=oe(e).TableGrid||fo,r=new n;e.tHead!==null&&r.merge(uo(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(uo(s.rows))});let o=[];for(let s of Array.from(e.children))_s(s)&&Nn(s,"tr")&&o.push(s);return r.merge(uo(o)),e.tFoot!==null&&r.merge(uo(e.tFoot.rows)),r}function uo(e){let t=new fo,n=[];for(let r=0;r<e.length;r++){let o=0;for(let s of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!Ir(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let i=o;i<o+s.colSpan;i++){ji(s)===0&&(n[i]=s,t.setCellAt(i,r,s));for(let a=r;a<r+ji(s);a++)Ir(t.getCellAt(i,a))||t.setCellAt(i,a,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let i=n[s];i!==void 0&&!Ir(t.getCellAt(s,r))&&t.setCellAt(s,r,i)}}return t}function ji(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Ir(e){return e!==void 0&&Nn(e,"td")}function Ht(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=gl(e);if(r)return r}let n=ea(e);if(n===null){if(t==="dl")return"list";if(t==="form")return"form";if(t==="header")return"banner";if(t==="footer")return"contentinfo";if(t==="option")return"option";if(t==="textarea")return"textbox";if(t==="input"){let o=e;switch(o.type.toLowerCase()){case"checkbox":return"checkbox";case"radio":return"radio";case"button":case"submit":case"reset":case"image":return"button";case"number":return"spinbutton";case"range":return"slider";case"hidden":return null;default:return o.hasAttribute("list")?"combobox":"textbox"}}if(t==="select")return e.multiple?"listbox":"combobox";if(t==="svg"){if(e.getAttribute("aria-hidden")==="true")return null;let o=e.querySelector("title"),s=e.querySelector("desc"),i=e.hasAttribute("aria-label"),a=e.hasAttribute("role");return o||s||i||a||zn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(zn(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return cl(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&ta(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function cl(e){return _r(e)??null}function ea(e){let t=e.getAttribute("role");if(t!==null)return Mi.includes(t)||!ta(t)?null:t;let n=e.tagName.toLowerCase();return(Li[n]??[]).find(o=>ll(e,o))||null}function ll(e,t){let n=gr[t],r=n?.selector;if(r&&po(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(i=>po(e,i.selector)&&i.conditions.every(u=>dl(e,u))):!1}function ul(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(vt(r)){let o=oe(e),s=`#${jr(o,n)}`,i=Kr(r,s);if(i)return i}}catch{}return zr(G(e),n)}function dl(e,t){switch(t.type){case me.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case me.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case me.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>ul(e,r)!=null);case me.FORBIDDEN_ANCESTORS:return an(e,t.selector)===null;case me.BOOLEAN_PROPERTY:return e[t.property]===t.value;case me.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case me.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=an(n,t.tag);return r!==null&&ea(r)===t.role}case me.HAS_TABLE_COLUMN_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Ji(n,e)}case me.HAS_TABLE_ROW_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Qi(n,e)}default:return fl(t),!1}}function fl(e){throw new Error(`unexpected value ${e}!`)}function ta(e){return hl(e)||ml(e)||pl(e)}function pl(e){return Ai.has(e)}function hl(e){return Ci.has(e)}function ml(e){return gr.hasOwnProperty(e)}function gl(e){if(e.tagName!==Mn&&e.tagName!==Ln)return null;if(hr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Ln||e.tagName===Mn&&e.closest("pre")?"code":null}var bl={[nt.display]:[nt.beforeDisplay,nt.afterDisplay],[nt.content]:[nt.beforeContent,nt.afterContent]},Ts=new Map,El={minWidth:"min-width",minHeight:"min-height",backgroundColor:"background-color",borderWidth:"border-width",borderStyle:"border-style",boxShadow:"box-shadow",paddingTop:"padding-top",paddingRight:"padding-right",paddingBottom:"padding-bottom",paddingLeft:"padding-left",marginTop:"margin-top",marginRight:"margin-right",marginBottom:"margin-bottom",marginLeft:"margin-left",overflowX:"overflow-x",overflowY:"overflow-y"};function wl(e,t){if(!Ts.has(e)){let n=El[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();Ts.set(e,n)}return Ts.get(e)}var yl={display:e=>e!=="block"&&e!=="inline"&&e!=="",visibility:e=>e!=="visible",opacity:e=>parseFloat(e)<1,position:e=>e!=="static",cursor:e=>e!=="auto"&&e!=="default"&&e!=="text",width:e=>e!=="auto"&&e!=="",height:e=>e!=="auto"&&e!=="",minWidth:e=>e!=="0px"&&e!=="",minHeight:e=>e!=="0px"&&e!=="",paddingTop:e=>parseFloat(e)>0,paddingRight:e=>parseFloat(e)>0,paddingBottom:e=>parseFloat(e)>0,paddingLeft:e=>parseFloat(e)>0,marginTop:e=>Math.abs(parseFloat(e))>5,marginRight:e=>Math.abs(parseFloat(e))>5,marginBottom:e=>Math.abs(parseFloat(e))>5,marginLeft:e=>Math.abs(parseFloat(e))>5,overflowX:e=>e!=="visible",overflowY:e=>e!=="visible",backgroundColor:e=>e!=="transparent"&&e!=="rgba(0, 0, 0, 0)"&&e!=="initial",color:e=>e!=="initial"&&e!=="inherit"&&e!=="",borderWidth:e=>e!=="0px"&&parseFloat(e)>0,borderStyle:e=>e!=="none"&&e!=="initial",boxShadow:e=>e!=="none"&&e!=="",outline:e=>e!=="none"&&e!==""&&!e.includes("0px")};function oa(e,t,n){let r=yl[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function sa(e){let t={},n=oe(e);if(!Ge(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[nt.beforeDisplay,n.getComputedStyle(e,"::before")],[nt.afterDisplay,n.getComputedStyle(e,"::after")],[nt.beforeContent,n.getComputedStyle(e,"::before")],[nt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in nt)if(isNaN(Number(s))){let i=nt[s],a=wl(i,s),u=bl[i];u?((i===nt.display||i===nt.content)&&na(r,a,i,s,t,e),ra(o.get(u[0]),a,u[0],"beforeContent",t),ra(o.get(u[1]),a,u[1],"afterContent",t)):na(r,a,i,s,t,e)}return t}function na(e,t,n,r,o,s){if(e){let i=e.getPropertyValue(t);i&&oa(r,i,s)&&(o[n]=i)}}function ra(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&oa(r,s))&&(o[n]=s)}}function Dn(e,t){let n=oe(e);if(!Ge(e,n))return!0;if(t&&rn.has(t))return!1;if(e.hasAttribute("hidden")||an(e,"[hidden]")!==null||an(e,"[inert]")!==null)return!0;let r=n.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"||e.getClientRects().length===0)return!0;let o=e.getBoundingClientRect(),s=1e6;return Math.abs(o.left)>s||Math.abs(o.top)>s}function Sr(e){return Pt(e)&&e.classList.contains("jasmine_html-reporter")}function _l(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ia(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function aa(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(vt(o)){let s=oe(e),i=`#${jr(s,n)}`,a=Kr(o,i);if(a)return a}}catch{}let r=G(e);return zr(r,n)}function vs(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let s=0;s<o.length;s+=8192){let i=Tl(o,s,s+8192),a=vs.apply(null,i);for(let u=0;u<a.length;u++)n.push(a[u])}else n.push(o)}return n}function Tl(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function ca(e,t){return vl(e,t).concat(xl(e))}function vl(e,t){return vs(Rs(e).map(r=>ma(r)&&Pt(r)?la(r,t):r))}function la(e,t){if(!e||Dn(e,t))return[];if(!_l(e))return[e];let n=Array.from(e.children);return vs(n.map(r=>la(r,t)))}function ua(e){let t=ia(e.getAttribute("aria-owns"));if(!t.length)return[];let n=[],r=new Set;for(let o of t){if(r.has(o))continue;r.add(o);let s=aa(e,o);s&&s!==e&&n.push(s)}return n}function xl(e){let t=ua(e);for(let n of t)n["aria-owned-by"]=e;return t}function da(e){let t=oe(e),n=G(e);if(e.getAttribute("role")!=="dialog"&&e.getAttribute("role")!=="alertdialog"||e.getAttribute("aria-modal")!=="true")return!1;let r=t.getComputedStyle(e);if(r?.position!=="fixed"&&r?.position!=="absolute"||parseInt(r?.zIndex,10)<=Sl(e))return!1;let o=Rl(e);return!o||!Il(o)||!Cl(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:Al(e)}function Rl(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(kl)||null}function kl(e){if(Dn(e))return!1;let n=oe(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function Il(e){let t=oe(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function Sl(e){let t=G(e),n=oe(e),r=n?.getComputedStyle;if(!r)return 0;let o=cs(t,"*").filter(s=>s!==e&&!Dn(s)).map(s=>parseInt(r.call(n,s)?.zIndex,10)).filter(s=>Number.isFinite(s)&&!isNaN(s));return o.length?Math.max(...o):0}function Al(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function Cl(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Dn(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function Ml(){try{let t=Xe()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var fa=Ml();function Ll(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function xs(e){let t=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(!t&&!e.tagName.includes("-"))try{let n=e;t=n.href||n.src||n.data||n.action||null}catch{return!1}if(!t)return!1;try{let n=G(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function pa(e){return Ni.has(e)}function Nl(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return ct({targetElement:t,originatedFromParent:!0})}function Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i}){let a={nodeCategory:e.nodeType},u=t||Ll(e),v=Nl(e);if(v&&(a.parent=v),n){let Te=jn[n];typeof Te=="number"?a.semanticRole=Te:a.semanticRole=n}if(u&&(a.isDisabled=!0),i){let{eventHandlerIndices:Te,isEditableRegion:Oe}=i,He=Qn(Te);He.length>0&&(a.eventHandlers=He),Oe&&(a.isEditable=!0)}let p=Ol(e);p&&Object.keys(p).length>0&&(a.ariaProperties=p);let _=Ul(e);_&&Object.keys(_).length>0&&(a.ariaStates=_);let A=e.nodeName;A&&A.trim()&&(a.elementName=A);let S=sa(e);S&&Object.keys(S).length>0&&(a.computedStyles=S),Dn(e)&&(a.isInvisible=!0);let M=Dl(e,n);M&&Object.keys(M).length>0&&(a.preservedAttributes=M),e.draggable&&(a.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(a.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(a.supportsVerticalSwipe=!0);let O=e.getAttribute("class");if(O?.trim()){O.includes("handle")&&(a.isDragHandle=!0),a.supportsHorizontalSwipe||(O.includes("horizontal")||O.includes("carousel"))&&(a.supportsHorizontalSwipe=!0),a.supportsVerticalSwipe||(O.includes("vertical")||O.includes("feed"))&&(a.supportsVerticalSwipe=!0),O.includes("dismissible")&&(a.supportsDismissSwipe=!0),(O.includes("long-press")||O.includes("hold")||O.includes("press-hold"))&&(a.supportsLongPress=!0);let Te=a.inputType||a.preservedAttributes?.[bt.type];Te==="submit"||Te==="reset"||Te==="clear"||(O.includes("submit")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"submit"}),O.includes("clear")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"clear"}),O.includes("reset")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"reset"}))}let W=Vl({element:e});W&&W.length>0&&(a.labelReferences=W);let q=e.tagName;if(q&&(a.elementTag=q),Hl(e)&&(a.hasFocus=!0),!o){let Te=ks({element:e,semanticRole:n,parentDisabled:u,excludeLabels:r});Te&&Te.length>0&&(a.childElements=Te)}let U=Kl({element:e});U&&U.length>0&&(a.ownedElements=U);let P=Ii(e);P&&(a.resourceLocator=P),(o||Jn(e))&&(a.isFrameElement=!0),s&&s.length>0&&(a.frameContent=s);let B=e.type;B&&typeof B=="string"&&B.trim()&&(a.inputType=B);let z=e.placeholder;z&&typeof z=="string"&&z.trim()&&(a.placeholderText=z);let te=e.value;te&&typeof te=="string"&&te.trim()&&(a.elementValue=te);let re=$l({element:e,parentDisabled:t,semanticRole:n});if(re&&re.length>0&&(a.selectedOptions=re),an(e,"select,datalist")&&(a.nearestSelectList=!0),_s(e))a.elementNamespace=wr.HTML;else if(Fl(e)){a.elementNamespace=wr.SVG,a.svgStructure=Pl(e);let Te=Bl(e);Te&&Object.keys(Te).length>0&&(a.preservedAttributes?a.preservedAttributes={...a.preservedAttributes,...Te}:a.preservedAttributes=Te)}let j=r?void 0:Gl({element:e});j&&j.length>0&&(a.associatedLabels=j);let le=e.scope;le&&typeof le=="string"&&le.trim()&&(a.tableScope=le);let ne=Yl({element:e});ne&&(a.tableCaption=ne);let de=Xl({element:e});de&&(a.figureCaption=de);let be=zl({element:e});return be&&(a.fieldsetLegend=be),an(e,"table")&&(a.nearestTable=!0),a}function Dl(e,t){let n={},r=new Set(Object.values(bt).filter(a=>typeof a=="string")),o=new Set(Object.keys(Zr).filter(a=>isNaN(Number(a)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),i=e?.attributes?Array.from(e.attributes):[];for(let a of i){let u=a.name,v=a.value;if(u==="id"&&(!t||!rn.has(t)))continue;let p;if(r.has(u)?p=u:u.startsWith("data-v-")?p="data-v-*":u.startsWith("ng-reflect-")?p="ng-reflect-*":u.startsWith("_ngcontent")&&(p="_ngcontent"),p){let _=v.trim()!=="",A=o.has(p);if(_||A){let S=bt[p],M=s.has(p)?"true":v;n[S]=M}}}if(!n[bt[at]]){let a=Yi(e);a&&(n[bt[at]]=a)}return n}function Ol(e){return ha(e,ro,eo)}function Ul(e){return ha(e,oo,null)}function ha(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],a=`aria-${o.toLowerCase().replace(/_/g,"-")}`,u=e.getAttribute(a),v=!1;n!==null&&(v=Object.values(n).filter(_=>typeof _=="number").includes(s)),e.hasAttribute(a)&&v||u?.trim()?r[s]=u:a==="aria-level"&&Oi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Pt(e){return ma(e)&&e.nodeType===Er.ELEMENT}function ho(e){return e.nodeType===Er.TEXT}function ma(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function _s(e){return Pt(e)&&(!e.namespaceURI||e.namespaceURI===Ui)}function Fl(e){return Pt(e)&&e.namespaceURI===Fi}function Jn(e){return e.tagName==="IFRAME"}function Nn(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function an(e,t){if(e.closest)return e.closest(t);for(;!po(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function po(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function Hl(e){let t=e.ownerDocument,n=t?.hasFocus()?t.activeElement:null;if(n){let r=n.getAttribute("aria-activedescendant");r&&(n=t.getElementById(r)||n)}return e===n}function Pl(e){let t={},n=sn.text,r=sn.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),s=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:s?.alt?.trim()&&(t[r]=s.alt);let i=e.getAttribute("viewBox");i&&(t[sn.viewBox]=i);let a=e.querySelectorAll("path");a.length>0&&(t[sn.paths]=a.length,t[sn.pathData]=Array.from(a).slice(0,3).map(v=>v.getAttribute("d")).filter(Boolean).map(v=>v.substring(0,100)));let u={circles:e.querySelectorAll("circle").length,rects:e.querySelectorAll("rect").length,lines:e.querySelectorAll("line").length,polygons:e.querySelectorAll("polygon").length,polylines:e.querySelectorAll("polyline").length,ellipses:e.querySelectorAll("ellipse").length};return Object.entries(u).forEach(([v,p])=>{if(p>0){let _=sn[v];t[_]=p}}),Object.keys(t).length>0?t:void 0}function Bl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Kn).filter(r=>typeof r=="number")){let r=Kn[n];if(r){let o=r;if(Kn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function Wl({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!ft.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of Rs(r))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a),{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:t,semanticRole:a??void 0,excludeLabels:n,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:t,excludeLabels:n});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Rs(e){let t=oe(e);if(Ti(e,t)){try{let n=e.assignedNodes({flatten:!0});if(n&&n.length)return n}catch{}return Array.from(e.childNodes)}try{let n=e.shadowRoot||In()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(s=>!s.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function ks({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of Rs(e))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a);if(Jn(i)){hn(i);let _=Wl({frameElement:i,parentDisabled:n,excludeLabels:r}),A=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:_,elementContext:u});A&&o.push(A);continue}let{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:n,excludeLabels:r});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Vl({element:e}){let t=ia(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=aa(e,r);if(!(!o||o===e)&&o){let s=Ht(o),i=ct({targetElement:o,semanticRole:s,elementContext:xt(o,s)});n.add(i)}}return Array.from(n)}function $l({element:e,parentDisabled:t,semanticRole:n}){let r=[];return e&&(n&&n==="listbox"?r=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(o=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})):Nn(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})))),r}function Gl({element:e}){if(Di.includes(e.tagName)){let t=G(e),n=cs(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&ql(o,e)).map(o=>{let s=Ht(o),i=ct({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:xt(o,s)});r.add(i)}),Array.from(r)}}function ql(e,t){let n=e.control;return n!==void 0?n===t:e.htmlFor!==""&&e.htmlFor===t.id?!0:!!(e.htmlFor===""&&e.contains(t))}function Yl({element:e}){if(Nn(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Xl({element:e}){if(Nn(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function zl({element:e}){if(Nn(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Kl({element:e}){let t=new Set,n=ua(e);for(let r of n){let o=Ht(r),s=ct({targetElement:r,semanticRole:o,elementContext:xt(r,o)});t.add(s)}return Array.from(t)}function mo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,i=n.length>0&&n.some(_=>Bi.has(_)),u=!!t||!s&&(o||r),v=!!t&&rn.has(t);return{shouldCreate:u,shouldAnnotate:u&&(v||r||i)}}function ga(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?jl(t):!1}function jl(e){let t=oe(e),n=t?.getComputedStyle;if(!n||n.call(t,e).display==="none")return!0;let o=e.getBoundingClientRect();return o.width===0&&o.height===0&&!(typeof e.closest=="function"&&e.closest("pre"))||o.right<-1e3||o.left>t.innerWidth+1e3}function Is(e,t={}){return Ei(t),zi(),qi(),Xi(e,{includeShadow:!0,includeIframes:ft.clearIframes}),xr.initialize(ft.semanticIdStart),{rootNodes:ba(e),semanticNodes:mn}}function ba(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(fa)).filter(s=>!Dn(s)&&da(s));if(o.length===0)t=Zn({targetElement:e});else if(o.length===1){let s=o[0];s.contains(e)?t=Zn({targetElement:e}):e.contains(s)?t=Zn({targetElement:s}):t=Zn({targetElement:e})}else t=Zn({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function Zn({targetElement:e,parentNode:t}){if(Sr(e)||Ea(e))return[];let n=Ht(e),r=xt(e,n);if(Jn(e))return[Jl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:i}=mo(r);s&&(i&&hn(e),o=ct({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let a=mn[o],u=Ql(e,n,o?a:t);return o&&u.length>0&&(a.semanticChildren=u),o?[o]:u}function Ql(e,t,n){let r=[],o=ca(e,t);for(let s of o)if(!(Sr(s)||Ea(s))){if(Pt(s)){let i=Zn({targetElement:s,parentNode:n});r.push(...i)}else if(ho(s)&&eu(s,n)){let i=kr(s);i&&r.push(i)}}return r}function Jl({frameElement:e,role:t,parentNode:n,elementContext:r}){hn(e);let o=Zl(e);return ct({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Zl(e){if(!ft.includeFrameContents)return[];let n=Sn(e)?.body??null;return n?ba(n):[]}function eu(e,t){let n=e.data.trim();if(!n||n==="")return!1;if(t?.semanticRole!==void 0&&t?.semanticRole!==null){let r=typeof t.semanticRole=="number"?yr[t.semanticRole]:t.semanticRole;if(pa(r))return!1}return!0}function Ea(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?tu(t):!1}function tu(e){let t=oe(e);if(t.getComputedStyle(e).display==="none")return!0;let r=e.getBoundingClientRect();return r.width===0&&r.height===0&&!e.closest("pre")||r.right<-1e3||r.left>t.innerWidth+1e3}function bo(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function nu(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function tr(e,t,n){let r=G(e,t),o=X(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(bo(r)===e)return!0;try{let{x:s,y:i}=nu(e),a=o.PointerEvent||PointerEvent,u=o.MouseEvent||MouseEvent;e.dispatchEvent(new a("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new u("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0})),e.dispatchEvent(new u("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0})),e.dispatchEvent(new a("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Lt(e,o)||Ft(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return bo(r)===e}function Ar(e,t){let n=oe(e),r=Ft(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function Un(e,t,n="insertText"){let r=oe(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),s=r.Event||Event;try{o?e.dispatchEvent(new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{try{e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{o?e.dispatchEvent(new o("input",{bubbles:!0,cancelable:!1,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{try{e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new s("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}function ru(e){let n=oe(e).KeyboardEvent||KeyboardEvent,r={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},o=e.dispatchEvent(new n("keydown",r)),s=e.dispatchEvent(new n("keypress",r)),i=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&s&&i)}}function On(e){if(!e)return!1;let t=oe(e);if(Ft(e,t))return!e.disabled&&!e.readOnly;if(Lt(e,t)){let n=(e.type||"text").toLowerCase();return(n==="text"||n==="search"||n==="email"||n==="url"||n==="tel"||n==="password"||n==="number")&&!e.disabled&&!e.readOnly}return!1}function Ss(e){let t=oe(e);if(!e||!Ge(e,t))return!1;if(e.isContentEditable)return!0;let n=e.getAttribute("contenteditable");return!!(n&&n!=="false"||e.getAttribute("role")==="textbox"&&!("value"in e))}function ou(e,t){let n=e.getRootNode();return vt(n)?n:G(e)??t}function su(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=oe(o);Ge(o,s)&&n.push(o)}return n}function Ta(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(On(e))return{kind:"input",el:e,via:"self-input"};if(Ss(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=X(n),o=ou(e,n);if(yi(e,r)){let u=e.control;if(On(u))return{kind:"input",el:u,via:"label.control"};let v=e.htmlFor;if(v){let p=o.getElementById?.(v)||o.querySelector?.(`#${CSS.escape(v)}`);if(On(p))return{kind:"input",el:p,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let u of su(o,s)){if(On(u))return{kind:"input",el:u,via:"aria-controls/owns"};if(Ss(u))return{kind:"contenteditable",el:u,via:"aria-controls/owns"};let v=u.querySelector?.("input,textarea");if(On(v))return{kind:"input",el:v,via:"aria-controls->desc"}}let i=e.querySelector?.("input,textarea");if(On(i))return{kind:"input",el:i,via:"descendant"};let a=e.shadowRoot||null;if(a){let u=a.querySelector?.("input,textarea");if(On(u))return{kind:"input",el:u,via:"open-shadow-input"};let v=a.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(Ss(v))return{kind:"contenteditable",el:v,via:"open-shadow-contenteditable"}}return e.getAttribute("role")==="textbox"&&!("value"in e)?{kind:"contenteditable",el:e,via:"role=textbox"}:{kind:"none",el:null,via:"not-found"}}function er(e,t,n,r=!1){let o=G(e,t),i=X(o,n).getSelection?.();if(!i)return!1;try{let a=o.createRange();return a.selectNodeContents(e),r&&a.collapse(!1),i.removeAllRanges(),i.addRange(a),!0}catch{return!1}}function Fn(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var go=e=>String(e??"").replace(/\s+/g," ").trim(),va=new MessageChannel,xa=[];va.port1.onmessage=()=>{let e=xa.shift();e&&e()};function wa(){return new Promise(e=>{xa.push(e),va.port2.postMessage(0)})}async function ya(e,t,n){await Promise.resolve();let r=Math.max(0,Math.min(4,Number(n)||0));for(let o=0;o<r;o++)e.hidden?await wa():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{wa().then(s)}})}function iu(e){let t=String(e??"");return t===" "?{code:"Space",which:32}:/^[a-z]$/i.test(t)?{code:`Key${t.toUpperCase()}`,which:t.toUpperCase().charCodeAt(0)}:/^[0-9]$/.test(t)?{code:`Digit${t}`,which:t.charCodeAt(0)}:{code:"",which:t.length===1?t.charCodeAt(0):0}}function _a(e,t,n,r){let o=G(e,t),i=X(o,n).KeyboardEvent||KeyboardEvent,a=String(r??"");for(let u of a){let{code:v,which:p}=iu(u),_={key:u,code:v,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new i("keydown",_)),e.dispatchEvent(new i("keypress",_)),e.dispatchEvent(new i("keyup",_))}}async function Ra(e,t,n,r,o){let s=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let i=String(e.value??""),a=G(e,t),u=X(a,n),v=tr(e,a,u),p=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):a.hidden?1:2,_=!!o?.useKeyFallback,A=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,S=_&&s.length>0&&s.length<=A;Ar(e,s),Un(e,s,"insertReplacementText"),S&&_a(e,a,u,s),await ya(a,u,p);let M=String(e.value??""),O=go(i),W=go(M),q=go(s),U=O===q,P=W===q,B=M!==i,z=s.length>0&&!U&&M===i,te=1;if(!U&&!P&&!B){te=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ne=!1;try{a.execCommand?.("selectAll",!1,void 0),ne=!!a.execCommand?.("insertText",!1,s)}catch{ne=!1}if(!ne)try{Ar(e,s)}catch{}try{Un(e,s,"insertReplacementText")}catch{}S&&_a(e,a,u,s),await ya(a,u,p),M=String(e.value??"")}let ie=go(M)===q,j=M!==i;z=s.length>0&&!U&&M===i;let le=U||ie||j;return{success:le,method:"type-native-setter",details:`focus=${v};attempts=${te};settleFrames=${p};beforeLen=${i.length};afterLen=${M.length};changed=${j};alreadyCorrect=${U};nowCorrect=${ie};reverted=${z};keyFallback=${S}`,allowFallback:le?void 0:!0}}function au(e,t,n){let o=oe(e).InputEvent||InputEvent,s=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(s),defaultPrevented:s.defaultPrevented}}function ka(e,t,n,r){let o=G(e,n),s=X(o,r),i=s.InputEvent||InputEvent,a=s.Event||Event,u=String(t??""),v=Fn(e),p=tr(e,o,s),_=er(e,o,s,!0),A=au(e,u,"insertText"),S=!1,M="execCommand",O=!1,W=()=>{O=!0};try{e.addEventListener("input",W,{capture:!0})}catch{}if(A.ok&&!A.defaultPrevented)try{S=!!o.execCommand?.("insertText",!1,u)}catch{}if(!S)try{let P=s.getSelection?.(),B=P&&P.rangeCount?P.getRangeAt(0):null;if(!B||!e.contains(B.commonAncestorContainer)){er(e,o,s,!0);let z=s.getSelection?.();B=z&&z.rangeCount?z.getRangeAt(0):null}B&&(B.insertNode(o.createTextNode(u)),B.collapse(!1),P?.removeAllRanges(),P?.addRange(B),S=!0,M="range")}catch{}if(S&&!O){try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0,data:u,inputType:"insertText"}))}catch{try{e.dispatchEvent(new a("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new a("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",W,{capture:!0})}catch{}let q=Fn(e);return{success:q!==v||!!u&&q.includes(u),method:`type-contenteditable-${M}`,details:`focus=${p};selectedWithin=${_};inserted=${S}`}}function Ia(e){let{canceled:t}=ru(e);if(t)return{submitted:!1,method:"enter-handled"};let n=e.form||e.closest?.("form");return n?(n.requestSubmit?.()??n.submit?.(),{submitted:!0,method:"enter->form-submit"}):{submitted:!1,method:"enter-dispatched"}}function Sa(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=G(e,t),o=X(r,n),s=String(e.value??""),i=tr(e,r,o);Ar(e,""),Un(e,"","deleteByCut");let a=String(e.value??""),u=a!==s;return{success:u||a.length===0,method:"clear-native-setter",details:`focus=${i};beforeLen=${s.length};afterLen=${a.length};changed=${u}`}}function Aa(e,t,n){let r=G(e,t),o=X(r,n),s=Fn(e),i=tr(e,r,o),a=er(e,r,o,!1),u=!1,v="execCommand";try{u=!!r.execCommand?.("delete",!1,void 0)}catch{u=!1}if(!u)try{let S=o.getSelection?.(),M=S&&S.rangeCount?S.getRangeAt(0):null;(!M||!e.contains(M.commonAncestorContainer))&&er(e,r,o,!1);let O=o.getSelection?.(),W=O&&O.rangeCount?O.getRangeAt(0):null;W&&(W.deleteContents(),W.collapse(!1),O?.removeAllRanges(),O?.addRange(W),u=!0,v="range")}catch{}if(!u)try{e.textContent="",u=!0,v="textContent"}catch{}Un(e,"","deleteByCut");let p=Fn(e),_=p!==s;return{success:u||_||p.length===0,method:`clear-contenteditable-${v}`,details:`focus=${i};selectedWithin=${a};cleared=${u};changed=${_}`}}function Ca(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(vt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var Eo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(Eo||(Eo={}));var Ma;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(Ma||(Ma={}));var cu=["image/png","image/jpeg","image/webp"],lu=["application/pdf","text/plain"],Eh=[...cu,...lu];var rt;(function(e){e.ACT="act_on_tab",e.CRAWL="crawl_and_extract_from_tab",e.EXTRACT="extract_from_tab",e.SHEETS_WORKFLOW="sheets_workflow",e.INFER_SHEET_DATA="infer_sheet_data",e.GRAPHBOT="graph_bot",e.PDF_FILLER="pdf_filler",e.CUSTOM_TOOL_GENERATOR="custom_tool_generator",e.WEBPAGE_GENERATOR="webpage_generator",e.GOOGLE_DOC_GENERATOR="google_doc_generator",e.GOOGLE_SLIDES_GENERATOR="google_slides_generator",e.PROCESS_TEXT="process_text",e.CREATE_SHEET_FROM_DATA="create_sheet_from_data",e.CONFIGURE_API_KEY="configure_api_key",e.TASK_COMPLETE="task_complete",e.ASK_USER="ask_user",e.EXECUTE_MULTIPLE_TOOLS="execute_multiple_tools",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(rt||(rt={}));var Qe;(function(e){e.PLANNER="Planner",e.AGENTIC_SEEK="Agentic Action",e.CRAWL_PAGES="Crawl Pages",e.EXTRACT_PAGE="Extract Page",e.SHEETS_WORKFLOW="Sheets Workflow",e.INFER_SHEET_DATA="Infer Sheet Data",e.MULTI_STEPS="Multi Steps",e.PDF_FILLER="PDF Filler",e.CUSTOM_TOOL_GENERATOR="Custom Tool Generator",e.WEBPAGE_GENERATOR="WebPage Generator",e.GOOGLE_DOC_GENERATOR="Google Doc Generator",e.GOOGLE_SLIDES_GENERATOR="Google Slides Generator",e.PROCESS_TEXT="Process Text",e.CREATE_SHEET_FROM_DATA="Create Sheet From Data",e.EXECUTE_MULTIPLE_TOOLS="Execute Multiple User Tools",e.CONFIGURE_API_KEY="Configure Gemini API Key",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(Qe||(Qe={}));var wh={[rt.ACT]:Qe.AGENTIC_SEEK,[rt.CRAWL]:Qe.CRAWL_PAGES,[rt.EXTRACT]:Qe.EXTRACT_PAGE,[rt.SHEETS_WORKFLOW]:Qe.SHEETS_WORKFLOW,[rt.INFER_SHEET_DATA]:Qe.INFER_SHEET_DATA,[rt.PDF_FILLER]:Qe.PDF_FILLER,[rt.CUSTOM_TOOL_GENERATOR]:Qe.CUSTOM_TOOL_GENERATOR,[rt.WEBPAGE_GENERATOR]:Qe.WEBPAGE_GENERATOR,[rt.GOOGLE_DOC_GENERATOR]:Qe.GOOGLE_DOC_GENERATOR,[rt.GOOGLE_SLIDES_GENERATOR]:Qe.GOOGLE_SLIDES_GENERATOR,[rt.PROCESS_TEXT]:Qe.PROCESS_TEXT,[rt.CREATE_SHEET_FROM_DATA]:Qe.CREATE_SHEET_FROM_DATA,[rt.EXECUTE_MULTIPLE_TOOLS]:Qe.EXECUTE_MULTIPLE_TOOLS,[rt.CONFIGURE_API_KEY]:Qe.CONFIGURE_API_KEY,[rt.QUERY_RTRVR_AI_DOCUMENTATION]:Qe.QUERY_RTRVR_AI_DOCUMENTATION};var As=200;var yh=Eo.FLASH;var _h=Qe.PLANNER;var Cs="application/pdf",Ms="application/gsheet";var Th=20*1024*1024;var wo={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var uu=1,du=9,fu=11,Ns="application/gdoc",nr="text/html",yo="text/plain";function pu(e){return!!e&&typeof e=="object"&&e.nodeType===du}function La(e){return!!e&&typeof e=="object"&&e.nodeType===uu}function hu(e){return!!e&&typeof e=="object"&&e.nodeType===fu&&typeof e.host=="object"&&typeof e.mode=="string"}function Na(e){return La(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Ls(e){let t;if(typeof e=="number")t=e;else if(typeof e=="bigint")t=Number(e);else if(typeof e=="string")t=Number(e.trim());else return null;if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n<=0?null:n}function mu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function gu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,i=[e],a=new WeakSet;for(;i.length;){let u=i.pop();if(u&&typeof u=="object"){if(a.has(u))continue;a.add(u)}if(pu(u)){let _=u.documentElement||u.body;_&&i.push(_);continue}if(hu(u)){let _=u.children;if(_&&_.length)for(let A=_.length-1;A>=0;A--)i.push(_[A]);continue}if(!La(u))continue;let v=u;if(s&&v.ownerDocument!==s)continue;let p=v.getAttribute?.(at);if(p&&Tr(p)===t)return v;if(r)try{let _=mu(v);_&&i.push(_)}catch{}if(o&&Na(v))try{let _=Sn(v);_&&i.push(_)}catch{}for(let _=v.lastElementChild;_;_=_.previousElementSibling)i.push(_)}return null}function Bt(e,t,n={}){let r=Ls(t);if(!r)return null;let o=Rr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:gu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Ds(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Da(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Ls(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Ls(e);return t?[t]:[]}if(typeof e=="string"){let t=e.match(/\d+/g);return t?t.map(r=>parseInt(r,10)).filter(r=>Number.isFinite(r)&&r>0):[]}if(typeof e=="object"){let t=e.path??e.ids??e.iframe_path;if(t!==void 0)return Da(t)}return[]}function rr(e,t){let n=Da(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,s=[];for(let i=0;i<n.length;i++){let a=n[i],u=n.length===1,v=Bt(o,a,{requireOwnerDocument:u?void 0:o,traverseShadow:!0,traverseIframes:u});if(!v||!Na(v))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};let p=null;try{p=Sn(v)||null}catch{p=null}if(!p)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};s.push(a),o=p}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function Oa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function bu(){return Date.now()}function Nt(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-bu())}async function Ua(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=Nt(n);r<=0||r<e+40||await Je(e,t)}async function or(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(s=>({ok:!0,value:s})),(async()=>(await Je(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var Je=(()=>{let e=new MessageChannel,t=[];e.port1.onmessage=()=>{let r=t.shift();r&&r()};let n=()=>new Promise(r=>{t.push(r),e.port2.postMessage(0)});return async(r,o)=>{let s=Number(r);if(!Number.isFinite(s)||s<=0)return;if(!o.hidden){let a=o.defaultView||window,u=a.setTimeout?a.setTimeout.bind(a):setTimeout;await new Promise(v=>u(v,s));return}let i=Date.now();for(;Date.now()-i<s;)await n()}})();var Eu=3e4;function Fa(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Os=class extends Error{constructor(n,r){super(n);$(this,"url");$(this,"status");$(this,"statusText");$(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function wu(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function yu(e){if(!e)return;let t=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1].trim().replace(/^\"(.*)\"$/,"$1"))}catch{}let n=/filename\s*=\s*(\"?)([^\";]+)\1/i.exec(e);if(n?.[2])return n[2].trim()}function Us(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let a=decodeURIComponent(s[1]).split("/");return a[a.length-1].replace(/^\d+-/,"")}}catch{}}function Ha(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function _u(e,t={},n,r=fetch){let o=new AbortController,s=Eu,i=!1,a=()=>{};if(n){let v=!1;a=()=>{v=!0},(async()=>{try{if(await Je(s,n),v)return;i=!0,o.abort()}catch{}})().catch(()=>{})}else{let v=setTimeout(()=>{i=!0,o.abort()},s);a=()=>clearTimeout(v)}let u=new Headers(t.headers);u.has("Accept")||u.set("Accept","*/*");try{let v=await r(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:u,signal:o.signal});if(!v.ok){let S=await v.text().catch(()=>"");throw new Os(`Fetch failed (${v.status})`,{url:e,status:v.status,statusText:v.statusText,bodySnippet:S.slice(0,256)})}let p=await v.arrayBuffer(),_=wu(v.headers.get("content-type")),A=yu(v.headers.get("content-disposition"))||Us(e);return{bytes:p,mimeType:_,fileName:A}}finally{a()}}async function Pa(e,t,n){return await _u(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var Fe;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(Fe||(Fe={}));var ot;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(ot||(ot={}));function Wa(e){if(!e)return ot.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return ot&&t in ot?ot[t]:ot.CENTER}function Fs(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function sr(e,t){if(!e)return"";let n=G(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Fs(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Fs(o.id)}`,r.unshift(s);break}let a=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(u=>u&&u.length<=48).sort((u,v)=>u.length-v.length).slice(0,3).map(Fs);if(a.length)s+="."+a.join(".");else{let u=o.parentElement;if(u){let v=Array.from(u.children).filter(p=>p.tagName===o.tagName);if(v.length>1){let p=v.indexOf(o)+1;s+=`:nth-of-type(${p})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Hn(e){return e.scrollingElement||e.documentElement||e.body}function _o(e,t,n,r,o){let s=G(e,t),i=X(s,n),a=Hn(s),u=e===s.documentElement||e===s.body||e===a,v=u?a:e,p=u?i.innerHeight:v.clientHeight,_=u?i.innerWidth:v.clientWidth,A=o??p*.8;switch(r){case Fe.DOWN:{v.scrollTop+=A;break}case Fe.UP:{v.scrollTop=Math.max(0,v.scrollTop-A);break}case Fe.LEFT:return v.scrollLeft=Math.max(0,v.scrollLeft-(o??_*.8)),{success:!0,scrollLeft:v.scrollLeft};case Fe.RIGHT:return v.scrollLeft+=o??_*.8,{success:!0,scrollLeft:v.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let S=v.scrollHeight,M=u?i.innerHeight:v.clientHeight,O=S-M;return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:v.scrollTop>=O-5}}function Tu(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e;for(;i&&i!==r.body&&i!==r.documentElement;){let u=o.getComputedStyle(i).overflowY;if((u==="auto"||u==="scroll"||u==="overlay")&&i.scrollHeight>i.clientHeight+5)return i;i=i.parentElement}return s}function Ba(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e===r.documentElement||e===r.body||e===s,a=i?s:e,u=a.scrollHeight,v=i?o.innerHeight:a.clientHeight,p=u-v;return a.scrollTop>=p-5}function Hs(e,t,n,r){let o=G(e,t),s=X(o,n),i=Hn(o),a=Tu(e,o,s),u=a===o.documentElement||a===o.body||a===i,v=u?i:a,p=e.getBoundingClientRect(),_=u?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):a.getBoundingClientRect(),A=u?s.innerHeight:a.clientHeight,S=24,M=p.top-_.top,O=v.scrollTop+M,W;switch(r){case ot.START:W=O-S;break;case ot.END:W=O+p.height-A+S;break;case ot.NEAREST:{if(p.top>=_.top&&p.bottom<=_.bottom)return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)};p.top<_.top?W=O-S:W=O+p.height-A+S;break}case ot.CENTER:default:W=O-A/2+p.height/2;break}let q=v.scrollHeight-A;return v.scrollTop=Math.max(0,Math.min(W,q)),{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)}}var vu=new Set([L.click_element,L.type_into_element,L.type_and_enter,L.hover_element,L.right_click_element,L.double_click_element,L.press_key,L.scroll_page,L.scroll_to_element,L.mouse_wheel,L.drag_element,L.drag_and_drop,L.swipe_element,L.long_press_element,L.adjust_slider,L.select_dropdown_value,L.clear_element,L.focus_element,L.check_field_validity,L.select_text,L.copy_text,L.paste_text,L.pinch_zoom,L.upload_file,L.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(fs,"1")}catch{}let n="__RTRVR_INTERNAL__";try{window.__RTRVR_INTERNAL_KEY__=window.__RTRVR_INTERNAL_KEY__||n}catch{}let r=window.__RTRVR_INTERNAL_KEY__||n,o=window[r],s=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=s}async function i(c){let y={};try{let b=mi[c.opcode];if(!b)throw new Error(`Unknown tool opcode: ${c.opcode}`);let g={...c.call,name:b};y=(await O({tabIndex:c.tabIndex,call:g,elementData:M(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(b){y={success:!1,error:b?.message||String(b),allowFallback:!0}}return y}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:i}),writable:!1,configurable:!1,enumerable:!1})}catch{}let a="__RTRVR_UPLOAD_BYTES_REQ__",u="__RTRVR_UPLOAD_BYTES_RES__",v="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function _(c){let y=c,b=y[p];if(!b||typeof b!="object"){b={handlers:new Set,installed:!1};try{Object.defineProperty(y,p,{value:b,enumerable:!1,configurable:!1})}catch{y[p]=b}}if(!b.installed){b.installed=!0,c.addEventListener("message",g=>{if(g.source===c)for(let f of Array.from(b.handlers))try{f(g)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let f=c[v]?.pending;if(f)for(let[d,h]of f){try{h.cancelTimeout()}catch{}h.reject(new Error("pagehide: upload bytes request canceled")),f.delete(d)}},!0)}catch{}}return b}function A(c){let y=c,b=y[v];if(!b||typeof b!="object"){b={pending:new Map};try{Object.defineProperty(y,v,{value:b,enumerable:!1,configurable:!1})}catch{y[v]=b}_(c).handlers.add(f=>{let d=f?.data;if(!d||typeof d!="object"||d.type!==u)return;let h=String(d.requestId||"");if(!h)return;let x=b.pending.get(h);if(!x)return;b.pending.delete(h);try{x.cancelTimeout()}catch{}if(!d.ok){x.reject(new Error(d.error||"Failed to get bytes"));return}let m=d.bytes;if(!(m instanceof ArrayBuffer)){x.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof x.expectedByteLength=="number"&&m.byteLength!==x.expectedByteLength){x.reject(new Error(`Byte length mismatch: got=${m.byteLength}, expected=${x.expectedByteLength}`));return}x.resolve(m)})}return b}function S(c,y,b,g=9e4){let f=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof f=="function")return Promise.resolve().then(()=>f({token:y,byteLength:b,timeoutMs:g})).then(T=>{if(T instanceof ArrayBuffer)return T;if(T&&T.buffer instanceof ArrayBuffer)return T.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=A(c),h=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,x=Math.max(1e3,Math.min(Number(g)||9e4,18e4)),m=Qr(c)||document;return new Promise((T,C)=>{let N=!1,F=!1,Y=()=>{F=!0};(async()=>{await Je(x,m),!(F||N)&&(d.pending.delete(h),N=!0,C(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(h,{cancelTimeout:Y,expectedByteLength:b,resolve:Q=>{N||(N=!0,Y(),T(Q))},reject:Q=>{N||(N=!0,Y(),C(Q))}}),c.postMessage({type:a,requestId:h,token:y,byteLength:b},"*")})}function M(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(y=>hi[y]).filter(y=>y&&y!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function O({tabIndex:c,call:y,elementData:b,payload:g}){let f=(()=>{try{return Kt()?.top?.document||document}catch{return document}})(),d=y.args,h,x,m;try{({doc:h,win:x,unresolvedPath:m}=rr(f,d.iframe_id))}catch{if(d.iframe_id!=null)return[{name:y.name,args:y.args,response:{success:!1,error:`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`}}];h=document,x=X(h)}let T=y.name,C=d.element_id?Bt(h,d.element_id):null,N=C?.ownerDocument??null,F;if(!vu.has(T))F={success:!1,error:`Tool not promotable to main: ${T}`,allowFallback:!0};else{let Y=N??h,Q=X(Y,x);F=await q(T,C,d,b,Y,Q,g)}return[{name:y.name,args:y.args,response:F}]}async function W(c,y,b){try{let g=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=c[g]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let h=b?.doc||Qr(c)||document,x=Math.max(250,Math.min(Number(b?.timeoutMs??3500),8e3)),m=await or(Promise.resolve().then(()=>d(y)),x,h);if(!m.ok)throw new Error("scroll detector timeout");return m.value}catch(g){throw new Error(g?.message||"main-world scroll detector not available")}}async function q(c,y,b,g,f,d,h){let x=F=>({success:F.success,error:F.success?void 0:F.details||"Action failed",allowFallback:F.success?void 0:F.allowFallback??!0}),m=c===L.press_key||c===L.scroll_page||c===L.drag_and_drop||c===L.pinch_zoom;if(!y&&!m)return x({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let T=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),C=y,N=G(C,f);if(C&&T.has(c)){let F=Ta(C,N);(F.kind==="input"||F.kind==="contenteditable")&&(C=F.el)}try{switch(c){case L.click_element:return x(z(y,f,d,g));case L.double_click_element:return x(Ut(y,f,d));case L.right_click_element:return x(he(y,f,d));case L.hover_element:return x(await ht(y,f,d,g,b.duration));case L.type_into_element:return x(await st(C,f,d,b.text,g));case L.type_and_enter:return x(await yt(C,f,d,b.text,g));case L.clear_element:return x(await It(C,f,d,g));case L.focus_element:return x(it(C,f,d));case L.select_dropdown_value:return x(ke(y,f,d,b.value,g));case L.adjust_slider:return x(Le(y,f,d,g?.value??b.value,g));case L.check_field_validity:return x(Vt(C,f,d));case L.select_text:return x(mt(C,f,d,b.start_offset,b.end_offset));case L.scroll_page:return x(await $t(y,f,d,b));case L.scroll_to_element:return x(await ln(y,f,d,b));case L.mouse_wheel:return x(et(y,f,d,b.delta_x,b.delta_y));case L.drag_element:return x(await Ne(y,f,d,b,g));case L.drag_and_drop:return x(await un(b,y,f,d));case L.swipe_element:return x(await dn(y,f,d,b));case L.long_press_element:return x(await yn(y,f,d,b.duration));case L.pinch_zoom:return x(await Pe(y,f,d,b));case L.press_key:return x(Gt(b.key,b.modifiers,y,f,d));case L.copy_text:return x(await Jt(y,f,d));case L.paste_text:return x(await fn(y,f,d,g));case L.upload_file:return x(await Ot(b,f,d,h,y,g));case L.dispatch_pointer_path:return x(await ut(b,f,d));default:return x({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(F){return x({success:!1,method:"exception",details:F?.message||"exception",allowFallback:!0})}}function U(c){let y=new Map;if(!c)return y;let b=c.trim();if(!b)return y;let g=Cn(b);if(g){for(let{id:f,mask:d}of g.entries){let h=nn[f];if(!h)continue;let x=new Set(qr(d)),m=y.get(h);if(m)for(let T of x)m.add(T);else y.set(h,x)}return y}return y}function P(c,...y){return c?y.some(b=>c.has(b)):!1}function B(c,y){let b=U(y?.listenersRaw),g=new Set;for(let[,T]of b)for(let C of T)(C==="react"||C==="vue"||C==="angular"||C==="svelte"||C==="jquery")&&g.add(C);let f=new Set;for(let[T,C]of b)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(T))for(let N of C)f.add(N);let d=g.size>0||[...f].some(T=>["react","vue","angular","svelte","jquery"].includes(T)),h=P(b.get("click"),"delegated"),x=P(b.get("input"),"delegated")||P(b.get("change"),"delegated")||P(b.get("keydown"),"delegated"),m=y?.role||_r(c)||c.getAttribute("role");return{sourcesByType:b,fws:g,isFrameworkElement:d,delegatedClick:h,delegatedInput:x,role:m}}function z(c,y,b,g){let f=B(c,g),d=G(c,y),h=X(d,b);Ve(c,d,h),g?.pattern==="hover-activate"&&ht(c,d,h,g,120);let x=f.fws.has("react")||P(f.sourcesByType.get("click"),"react"),m=f.fws.has("vue")||P(f.sourcesByType.get("click"),"vue"),T=f.fws.has("angular")||P(f.sourcesByType.get("click"),"angular"),C=f.fws.has("svelte")||P(f.sourcesByType.get("click"),"svelte"),N=f.fws.has("jquery")||P(f.sourcesByType.get("click"),"jquery");return vn(()=>te(c,d,h),()=>re(c,d,h),()=>x?j(c,d,h):null,()=>m?le(c,d,h):null,()=>T?ne(c,d,h):null,()=>C?de(c,d,h):null,()=>N?be(c,d,h):null)}function te(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent,{x,y:m}=ie(c,g,f),T={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:x,clientY:m,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new d("pointerover",T),new d("pointerenter",{...T,bubbles:!1}),new h("mouseover",T),new h("mouseenter",{...T,bubbles:!1}),new d("pointerdown",T),new h("mousedown",T),new d("pointerup",{...T,buttons:0}),new h("mouseup",{...T,buttons:0}),new h("click",{...T,buttons:0})].forEach(N=>c.dispatchEvent(N)),{success:!0,method:"pointer-mouse-click"}}function re(c,y,b){let g=G(c,y),f=X(g,b);try{if(c instanceof HTMLAnchorElement){let d=c.getAttribute("target");try{c.setAttribute("target","_self"),c.click()}finally{d===null?c.removeAttribute("target"):c.setAttribute("target",d)}}else c.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function ie(c,y,b){let g=G(c,y),f=c.getBoundingClientRect(),d=[{x:f.left+f.width/2,y:f.top+f.height/2},{x:f.left+4,y:f.top+4},{x:f.right-4,y:f.top+4},{x:f.left+4,y:f.bottom-4},{x:f.right-4,y:f.bottom-4}],h=null;for(let x=0;x<d.length;x++){let m=d[x],T=g.elementFromPoint(m.x,m.y);if(x===0&&(h=T),T&&Ca(c,T))return{...m,hit:T,ok:!0}}return{...d[0],hit:h,ok:!1}}function j(c,y,b){let g=G(c,y),f=X(g,b);try{let d=tn(c);if(!d)return{success:!1,method:"react-no-fiber"};let h=Yt(d),x=h.onClick||h.onClickCapture;return x?(x(Xt("click",c,g,f)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function le(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=Rn(c);if(!h)return{success:!1,method:"vue-none"};let x=Mt(h);return x.click?(x.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):h.$emit?(h.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ne(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;try{let h=f.ng?.getZone?.()||null;return h?.run?(h.run(()=>c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0})),c.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function de(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=c.getBoundingClientRect(),x={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:h.left+h.width/2,clientY:h.top+h.height/2};return c.dispatchEvent(new d("mousedown",x)),c.dispatchEvent(new d("mouseup",x)),c.dispatchEvent(new d("click",x)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function be(c,y,b){let g=G(c,y),f=X(g,b);try{return f.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function ht(c,y,b,g,f=500){let d=Math.min(Math.max(0,Number(f)||500),3e4),h=G(c,y),x=X(h,b),m=B(c,g);Ve(c,h,x);let T=x.PointerEvent||PointerEvent,C=x.MouseEvent||MouseEvent,N=c.getBoundingClientRect(),F=N.left+N.width/2,Y=N.top+N.height/2;if(m.fws.has("react")){let J=tn(c),ee=J?Yt(J):{};ee.onMouseEnter?.(Xt("mouseenter",c,h,x)),ee.onPointerEnter?.(Xt("pointerenter",c,h,x))}else if(m.fws.has("vue")){let J=Rn(c),ee=J?Mt(J):{};ee.mouseenter?.(new C("mouseenter",{bubbles:!0})),ee.mouseover?.(new C("mouseover",{bubbles:!0}))}let Q={bubbles:!0,cancelable:!0,composed:!0,view:x,clientX:F,clientY:Y};return[new T("pointerover",Q),new T("pointerenter",{...Q,bubbles:!1}),new C("mouseover",Q),new C("mouseenter",{...Q,bubbles:!1})].forEach(J=>c.dispatchEvent(J)),await Je(d,h),{success:!0,method:"hover-seq"}}async function Te(c,y,b=1){await Promise.resolve();for(let g=0;g<b;g++)c.hidden?await Ct():await new Promise(f=>{try{y.requestAnimationFrame(()=>f())}catch{Ct().then(f)}})}let Oe=c=>String(c??"").replace(/\s+/g," ").trim();function He(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Me(c){try{return typeof Fn=="function"?Fn(c):Oe(c.textContent)}catch{return""}}function Ze(c,y){if(!(y.isFrameworkElement||y.delegatedInput))return!1;let b=String(c??"").length;return b>0&&b<=140}async function st(c,y,b,g,f){let d=B(c,f),h=G(c,y),x=X(h,b);if(Ve(c,h,x),Lt(c,x)||Ft(c,x)){let T=Ze(String(g??""),d),C=await Ra(c,h,x,g,{settleFrames:h.hidden?1:2,useKeyFallback:T,keyFallbackMaxLen:140});return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||d.role==="textbox"&&!("value"in c)){let T=Me(c),C=ka(c,g,h,x);await Te(h,x,h.hidden?1:2);let N=Me(c),F=!1;if(String(g??"").length>0&&N===T){F=!0;try{tr(c,h,x),er(c,h,x,!0);try{h.execCommand?.("insertText",!1,String(g??""))}catch{}Un(c,String(g??""),"insertText")}catch{}await Te(h,x,h.hidden?1:2)}let Y=Me(c),Q=Y!==T||!!String(g??"")&&Y.includes(String(g??""));return{success:Q,method:C.method,details:`${C.details};beforeLen=${T.length};afterLen=${Y.length};reverted=${N===T};fallback=${F}`,allowFallback:Q?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function yt(c,y,b,g,f){let d=G(c,y),h=X(d,b),x=await st(c,d,h,g,f);if(!x.success)return x;let m=Ia(c);return{success:!0,method:"type+enter",details:`${x.details};enter=${m.method}`}}async function It(c,y,b,g){let f=G(c,y),d=X(f,b),h=d.Event||Event;if(Ve(c,f,d),Lt(c,d)||Ft(c,d)){let m=He(c),T=Sa(c,f,d);if(await Te(f,d,f.hidden?1:2),He(c)===m&&m.length>0){try{Ar(c,""),Un(c,"","deleteByCut")}catch{}await Te(f,d,f.hidden?1:2)}let F=He(c),Y=F.length===0||F!==m;return{success:T.success,method:T.method,details:T.details,allowFallback:!T.success}}if(c.isContentEditable===!0||B(c,g).role==="textbox"&&!("value"in c)){let m=Aa(c,f,d);return await Te(f,d,f.hidden?1:2),{success:m.success,method:m.method,details:m.details,allowFallback:!m.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new h("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new h("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function it(c,y,b){try{let g=G(c,y),f=X(g,b),d=f.FocusEvent||FocusEvent;return Ve(c,g,f),c.focus?.({preventScroll:!0}),c.dispatchEvent(new d("focus",{bubbles:!0})),c.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(g){return{success:!1,method:"focus",details:g.message,allowFallback:!0}}}function ke(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!_i(c,h))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Array.from(c.options).find(F=>F.value===g||F.text.trim()===g.trim());if(!m)return{success:!1,method:"select",details:`Option not found: ${g}`,allowFallback:!0};m.selected=!0;let T=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(T,"value");if(C?.set?C.set.call(c,m.value):c.value=m.value,c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let F=tn(c);if(F){let Y=Yt(F);if(Y.onChange){let Q=Xt("change",c,d,h);Q.target.value=m.value,Y.onChange(Q)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Le(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!Lt(c,h))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Object.getPrototypeOf(c),T=Object.getOwnPropertyDescriptor(m,"value");if(T?.set?T.set.call(c,String(g)):c.value=String(g),c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let N=tn(c);if(N){let F=Yt(N);if(F.onChange){let Y=Xt("change",c,d,h);Y.target.value=String(g),F.onChange(Y)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function Vt(c,y,b){try{let g=c.checkValidity?.()??!0;return g||c.reportValidity?.(),{success:g,method:"check-validity",details:g?void 0:c.validationMessage}}catch(g){return{success:!1,method:"check-validity",details:g.message,allowFallback:!0}}}function mt(c,y,b,g,f){try{let d=G(c,y),h=X(d,b);if("setSelectionRange"in c){let T=c;T.focus?.();let C=T.value?.length??0;return T.setSelectionRange(g??0,f??C),{success:!0,method:"select-range"}}let x=h.getSelection();if(!x)return{success:!1,method:"select-range",allowFallback:!0};let m=d.createRange();return m.selectNodeContents(c),x.removeAllRanges(),x.addRange(m),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function gt(c,y,b,g,f){let d=Hn((c&&G(c))??y),h=c||d,x=G(h,y),m=X(x,b),T=h===x.documentElement||h===x.body||h===d;if(g===Fe.TOP||g===Fe.BOTTOM){let C=h.scrollHeight,N=T?m.innerHeight:h.clientHeight,F=Math.max(0,C-N);return h.scrollTop=g===Fe.TOP?0:F,{success:!0,scrollTop:h.scrollTop}}return _o(h,x,m,g,f)}async function $t(c,y,b,g){let f=g.direction,d=g.amount,h=G(c,y),x=X(h,b),m=!h.hidden,T=m?"smooth":"auto";try{if(c){let N=St(c,h,x),F=gt(N,h,x,f,d);return F?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(F)}:{success:!1,method:"direct-element-scroll",details:F?.error||"direct scroll failed",allowFallback:!0}}if(f===Fe.TOP||f===Fe.BOTTOM){let N=await W(x,{action:"scrollTo",direction:f,options:{behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(N)}}let C=await W(x,{action:"scrollBy",direction:f,options:{amount:d,behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(C)}}catch(C){let N=h?gt(Hn(h),h,x,f,d):void 0;return N?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-page-failed",details:C?.message||N?.error||"scroll_page failed",allowFallback:!0}}}async function ln(c,y,b,g){let f=G(c,y),d=X(f,b),h=!f.hidden,x=h?"smooth":"auto",m=Wa(g.position),T=sr(c,f);if(!T){let C=Hs(c,f,d,m);return{success:C.success,method:"direct-scrollElement-no-selector",details:C.error,allowFallback:!C.success}}try{let C=await W(d,{action:"scrollElement",selector:T,position:m,options:{behavior:x,isTabActive:h}},{doc:f,timeoutMs:f.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(C)}}catch(C){let N=Hs(c,f,d,m);return N.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-to-element-failed",details:C?.message||N.error||"scroll_to_element failed",allowFallback:!0}}}function et(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.WheelEvent||WheelEvent;Ve(c,d,h);let m=St(c,d,h);return m.dispatchEvent(new x("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,deltaX:g||0,deltaY:f||0,deltaMode:x.DOM_DELTA_PIXEL})),m.scrollBy({left:g||0,top:f||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function St(c,y,b){let g=G(c,y),f=X(g,b),d=g.scrollingElement||g.documentElement||g.body,h=c;for(;h&&h!==g.body&&h!==g.documentElement;){let m=f.getComputedStyle(h).overflowY;if((m==="auto"||m==="scroll"||m==="overlay")&&h.scrollHeight>h.clientHeight+5)return h;h=h.parentElement}return d}async function Ne(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.MouseEvent||MouseEvent,T=h.DragEvent||DragEvent,C=h.DataTransfer||DataTransfer;Ve(c,d,h);let N=ie(c,d,h),F=Ge(N.hit,h)?N.hit:c,Y=c.getBoundingClientRect(),Q=Number.isFinite(Number(g?.distance))?Number(g.distance):160,pe=0,J=0;switch(String(g?.direction||"").toUpperCase()){case"UP":J=-Q;break;case"DOWN":J=Q;break;case"LEFT":pe=-Q;break;case"RIGHT":pe=Q;break;default:pe=Number(g?.delta_x)||0,J=Number(g?.delta_y)||0}let ee=(I,D)=>({x:Math.max(2,Math.min(I,h.innerWidth-3)),y:Math.max(2,Math.min(D,h.innerHeight-3))}),se=ee(N.x,N.y),we=ee(N.x+pe,N.y+J),Be=500+Date.now()%1e4,ue=Math.max(12,Math.min(36,Number(g?.steps)||18)),Ee=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:I,clientY:D,pageX:I+(h.scrollX||0),pageY:D+(h.scrollY||0)}),ye=(I,D,V)=>({...Ee(I,D),pointerId:Be,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(I,D,V)=>({...Ee(I,D),buttons:V,button:0});F.dispatchEvent(new x("pointerdown",ye(se.x,se.y,1))),F.dispatchEvent(new m("mousedown",l(se.x,se.y,1)));try{F.setPointerCapture?.(Be)}catch{}let E=null;try{(c.draggable||B(c,f).sourcesByType.has("dragstart"))&&(E=new C)}catch{E=null}if(E)try{c.dispatchEvent(new T("dragstart",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:E}))}catch{}let k=null;for(let I=1;I<=ue;I++){let D=se.x+(we.x-se.x)*I/ue,V=se.y+(we.y-se.y)*I/ue,K=d.elementFromPoint(D,V)||c;if(K.dispatchEvent(new x("pointermove",ye(D,V,1))),K.dispatchEvent(new m("mousemove",l(D,V,1))),E)try{k&&k!==K&&k.dispatchEvent(new T("dragleave",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),K.dispatchEvent(new T("dragover",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),k=K}catch{}I%3===0&&await Ct()}let R=d.elementFromPoint(we.x,we.y)||c;if(R.dispatchEvent(new x("pointerup",ye(we.x,we.y,0))),R.dispatchEvent(new m("mouseup",l(we.x,we.y,0))),E)try{c.dispatchEvent(new T("dragend",{bubbles:!0,cancelable:!0,clientX:we.x,clientY:we.y,dataTransfer:E}))}catch{}return{success:!0,method:"drag",details:`dx=${pe};dy=${J};steps=${ue};hitOk=${N.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function un(c,y,b,g){try{let f=G(y,b),d=X(f,g),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.DragEvent||DragEvent,T=d.DataTransfer||DataTransfer,C=c?.source_element_id??c?.element_id,N=(C?Bt(f,String(C)):null)||y;if(!N)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let F=null,Y=Number(c?.target_x),Q=Number(c?.target_y);if(c?.target_element_id){if(F=Bt(f,String(c.target_element_id)),!F)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let R=F.getBoundingClientRect();Y=R.left+R.width/2,Q=R.top+R.height/2}if((!Number.isFinite(Y)||!Number.isFinite(Q))&&!F)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ve(N,f,d),F&&Ve(F,f,d);let pe=(R,I)=>({x:Math.max(2,Math.min(R,d.innerWidth-3)),y:Math.max(2,Math.min(I,d.innerHeight-3))}),J=N.getBoundingClientRect(),ee=pe(J.left+J.width/2,J.top+J.height/2),se=pe(Number(Y),Number(Q)),we=600+Date.now()%1e4,Be=Math.max(14,Math.min(42,Number(c?.steps)||22)),ue=(R,I)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:R,clientY:I,pageX:R+(d.scrollX||0),pageY:I+(d.scrollY||0)}),Ee=(R,I,D)=>({...ue(R,I),pointerId:we,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:D?.5:0,buttons:D,button:0}),ye=(R,I,D)=>({...ue(R,I),buttons:D,button:0}),l=null;try{l=new T}catch{l=null}N.dispatchEvent(new h("pointerdown",Ee(ee.x,ee.y,1))),N.dispatchEvent(new x("mousedown",ye(ee.x,ee.y,1)));try{N.setPointerCapture?.(we)}catch{}if(l)try{N.dispatchEvent(new m("dragstart",{bubbles:!0,cancelable:!0,clientX:ee.x,clientY:ee.y,dataTransfer:l}))}catch{}let E=null;for(let R=1;R<=Be;R++){let I=ee.x+(se.x-ee.x)*R/Be,D=ee.y+(se.y-ee.y)*R/Be,V=f.elementFromPoint(I,D)||F||f.body;if(V.dispatchEvent(new h("pointermove",Ee(I,D,1))),V.dispatchEvent(new x("mousemove",ye(I,D,1))),l)try{E&&E!==V&&E.dispatchEvent(new m("dragleave",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragenter",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragover",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),E=V}catch{}R%3===0&&await Ct()}let k=F||f.elementFromPoint(se.x,se.y)||f.body;if(l)try{k.dispatchEvent(new m("drop",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}if(k.dispatchEvent(new h("pointerup",Ee(se.x,se.y,0))),k.dispatchEvent(new x("mouseup",ye(se.x,se.y,0))),l)try{N.dispatchEvent(new m("dragend",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Be};source=${String(C)}`}}catch(f){return{success:!1,method:"drag-drop",details:f?.message||"drag-drop failed",allowFallback:!0}}}async function dn(c,y,b,g){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent;Ve(c,f,d);let m=ie(c,f,d),T={x:m.x,y:m.y},C=c.getBoundingClientRect(),N=Number.isFinite(Number(g?.distance))?Number(g.distance):Math.min(Math.max(80,Math.min(C.width,C.height)),220),F=String(g?.direction||"RIGHT").toUpperCase(),Y=T.x,Q=T.y;F==="LEFT"&&(Y-=N),F==="RIGHT"&&(Y+=N),F==="UP"&&(Q-=N),F==="DOWN"&&(Q+=N);let pe=(I,D)=>({x:Math.max(2,Math.min(I,d.innerWidth-3)),y:Math.max(2,Math.min(D,d.innerHeight-3))}),J=pe(T.x,T.y),ee=pe(Y,Q),se=700+Date.now()%1e4,we=Math.max(10,Math.min(28,Number(g?.steps)||16)),Be=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:I,clientY:D,pageX:I+(d.scrollX||0),pageY:D+(d.scrollY||0)}),ue=(I,D,V)=>({...Be(I,D),pointerId:se,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),Ee=(I,D,V)=>({...Be(I,D),buttons:V,button:0}),ye=f.elementFromPoint(J.x,J.y)||c;ye.dispatchEvent(new h("pointerdown",ue(J.x,J.y,1))),ye.dispatchEvent(new x("mousedown",Ee(J.x,J.y,1)));let l=d.Touch,E=d.TouchEvent,k=!!l&&!!E;if(k)try{let I=new l({identifier:se,target:ye,clientX:J.x,clientY:J.y,pageX:J.x,pageY:J.y,screenX:J.x,screenY:J.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});ye.dispatchEvent(new E("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[I],targetTouches:[I],changedTouches:[I]}))}catch{}for(let I=1;I<=we;I++){let D=J.x+(ee.x-J.x)*I/we,V=J.y+(ee.y-J.y)*I/we,K=f.elementFromPoint(D,V)||c;if(K.dispatchEvent(new h("pointermove",ue(D,V,1))),K.dispatchEvent(new x("mousemove",Ee(D,V,1))),k)try{let ae=new l({identifier:se,target:K,clientX:D,clientY:V,pageX:D,pageY:V,screenX:D,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});K.dispatchEvent(new E("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ae],targetTouches:[ae],changedTouches:[ae]}))}catch{}I%3===0&&await Ct()}let R=f.elementFromPoint(ee.x,ee.y)||c;if(R.dispatchEvent(new h("pointerup",ue(ee.x,ee.y,0))),R.dispatchEvent(new x("mouseup",Ee(ee.x,ee.y,0))),k)try{let I=new l({identifier:se,target:R,clientX:ee.x,clientY:ee.y,pageX:ee.x,pageY:ee.y,screenX:ee.x,screenY:ee.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});R.dispatchEvent(new E("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[I]}))}catch{}return{success:!0,method:"swipe",details:`dir=${F};dist=${N};steps=${we};hitOk=${m.ok}`}}catch(f){return{success:!1,method:"swipe",details:f?.message||"swipe failed",allowFallback:!0}}}async function Pe(c,y,b,g){try{let f=c||y.body,d=G(f,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.WheelEvent||WheelEvent;Ve(f,d,h);let T=Number.isFinite(Number(g?.scale))?Number(g.scale):1.2,C=f.getBoundingClientRect(),N=C.left+C.width/2,F=C.top+C.height/2,Y=24,Q=Math.max(6,Math.min(200,Y*T)),pe=Math.max(6,Math.min(18,Number(g?.steps)||10)),J=h.Touch,ee=h.TouchEvent;if(!!J&&!!ee)try{let ue=(k,R)=>new J({identifier:k,target:f,clientX:R,clientY:F,pageX:R,pageY:F,screenX:R,screenY:F,radiusX:1,radiusY:1,rotationAngle:0,force:1}),Ee=ue(911,N-Y),ye=ue(912,N+Y);f.dispatchEvent(new ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Ee,ye],targetTouches:[Ee,ye],changedTouches:[Ee,ye]}));for(let k=1;k<=pe;k++){let R=Y+(Q-Y)*k/pe,I=ue(911,N-R),D=ue(912,N+R);f.dispatchEvent(new ee("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[I,D],targetTouches:[I,D],changedTouches:[I,D]})),k%2===0&&await Ct()}let l=ue(911,N-Q),E=ue(912,N+Q);f.dispatchEvent(new ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,E]}))}catch{}try{let ue=(Ee,ye,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:ye,clientY:F,pointerId:Ee,pointerType:"touch",isPrimary:Ee===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});f.dispatchEvent(new x("pointerdown",ue(821,N-Y,1))),f.dispatchEvent(new x("pointerdown",ue(822,N+Y,1)));for(let Ee=1;Ee<=pe;Ee++){let ye=Y+(Q-Y)*Ee/pe;f.dispatchEvent(new x("pointermove",ue(821,N-ye,1))),f.dispatchEvent(new x("pointermove",ue(822,N+ye,1))),Ee%2===0&&await Ct()}f.dispatchEvent(new x("pointerup",ue(821,N-Q,0))),f.dispatchEvent(new x("pointerup",ue(822,N+Q,0)))}catch{}try{let we=T>=1?-120:120;f.dispatchEvent(new m("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:N,clientY:F,ctrlKey:!0,deltaY:we,deltaMode:m.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${T};steps=${pe}`}}catch(f){return{success:!1,method:"pinch-zoom",details:f?.message||"pinch-zoom failed",allowFallback:!0}}}async function yn(c,y,b,g=800){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.FocusEvent||FocusEvent;Ve(c,f,d);let T=ie(c,f,d),C=c;!T.ok&&Ge(T.hit,d)?C=T.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||T.hit:Ge(T.hit,d)&&(C=T.hit);let N=Zt(C,f,d),F=T.x,Y=T.y,Q=1+Date.now()%1e4,pe={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0)},J={...pe,pointerId:Q,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{C.dispatchEvent(new h("pointerover",J)),C.dispatchEvent(new h("pointerenter",{...J,bubbles:!1}))}catch{}try{C.dispatchEvent(new x("mouseover",pe)),C.dispatchEvent(new x("mouseenter",{...pe,bubbles:!1}))}catch{}try{C.focus?.({preventScroll:!0}),C.dispatchEvent(new m("focus",{bubbles:!0,composed:!0})),C.dispatchEvent(new m("focusin",{bubbles:!0,composed:!0}))}catch{}try{C.dispatchEvent(new h("pointerdown",{...J,buttons:1,pressure:.5}))}catch{}try{C.dispatchEvent(new x("mousedown",{...pe,buttons:1,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});C.dispatchEvent(new Ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[ye],targetTouches:[ye],changedTouches:[ye]}))}}catch{}let ee=Number(g),se=Number.isFinite(ee)&&ee>0?ee:800,we=f.hidden?Math.max(se,1200):se;await Je(we,f);try{C.dispatchEvent(new x("contextmenu",{...pe,button:2,buttons:2}))}catch{}try{C.dispatchEvent(new h("pointerup",{...J,buttons:0,pressure:0}))}catch{}try{C.dispatchEvent(new x("mouseup",{...pe,buttons:0,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});C.dispatchEvent(new Ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[ye]}))}}catch{}let Be=await Ue(C,f,d,N);return{success:!0,method:"long-press",details:`holdMs=${we};verified=${Be};hitOk=${T.ok};target=${C.tagName.toLowerCase()}`}}catch(f){return{success:!1,method:"long-press",details:f?.message||"long-press failed",allowFallback:!0}}}function Gt(c,y,b,g,f){try{let d=G(b,g),x=X(d,f).KeyboardEvent||KeyboardEvent,m=b||d.activeElement||d.body||d.documentElement;m.focus?.();let T={key:c,code:en(c),bubbles:!0,cancelable:!0,ctrlKey:y?.includes("CTRL"),altKey:y?.includes("ALT"),shiftKey:y?.includes("SHIFT"),metaKey:y?.includes("META")},C=m.dispatchEvent(new x("keydown",T)),N=m.dispatchEvent(new x("keypress",T)),F=m.dispatchEvent(new x("keyup",T));if(c==="Enter"&&!!(C&&N&&F)){let Q=m.form||m.closest?.("form");Q?.requestSubmit?Q.requestSubmit():Q?.submit?.()}return{success:!0,method:"press-key"}}catch(d){return{success:!1,method:"press-key",details:d.message,allowFallback:!0}}}async function Jt(c,y,b){try{let g=c.innerText||c.value||"";if(!g)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(g),{success:!0,method:"clipboard-copy"};let h=f.createRange();h.selectNodeContents(c);let x=d.getSelection?.()||(f.defaultView||window).getSelection?.();x?.removeAllRanges(),x?.addRange(h);let m=f.execCommand?.("copy")??!1;return x?.removeAllRanges(),{success:!!m,method:"execCommand-copy",allowFallback:!m}}catch(g){return{success:!1,method:"clipboard-copy",details:g.message,allowFallback:!0}}}async function fn(c,y,b,g){try{c.focus?.();let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.readText){let x=await d.navigator.clipboard.readText();if(x)return await st(c,f,d,x,g)}return f.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(f){return{success:!1,method:"paste",details:f.message,allowFallback:!0}}}function _n(c){return`${(c/1024).toFixed(1)}KB`}function Tn(c,y){if(c instanceof y.defaultView.HTMLInputElement){let h=c;if((h.type||"").toLowerCase()==="file")return h}let b=c.closest?.("label"),g=b?.htmlFor||c.htmlFor||"";if(g){let h=y.getElementById(g);if(h&&(h.type||"").toLowerCase()==="file")return h}if(b){let h=b.querySelector?.('input[type="file"]');if(h)return h}let f=c.closest?.("form");if(f){let h=f.querySelector?.('input[type="file"]');if(h)return h}let d=c.closest?.("div,section,main,article")||c.parentElement;if(d){let h=d.querySelector?.('input[type="file"]');if(h)return h}return null}function At(c,y,b){try{let g=b.HTMLInputElement?.prototype,f=g?Object.getOwnPropertyDescriptor(g,"files")?.set:void 0;if(!f){let d=Object.getPrototypeOf(c);for(;d&&!f;)f=Object.getOwnPropertyDescriptor(d,"files")?.set,d=Object.getPrototypeOf(d)}return f?(f.call(c,y),!0):(c.files=y,!0)}catch{try{return c.files=y,!0}catch{return!1}}}async function Ot(c,y,b,g,f,d){try{let{file_url:h,element_id:x,file_name:m}=c,T=null;if(f&&(T=Tn(f,y)),!T&&x!==void 0&&(T=y.querySelector(`input[type="file"][${at}*="[id=${x}]"]`)),!T){let R=y.querySelectorAll('input[type="file"]');for(let I of R){if(I.disabled)continue;let D=I.getBoundingClientRect();if(D.width>0&&D.height>0){T=I;break}}}if(!T)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(T.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let C=G(T,y),N=X(C,b);if(!(g?.kind==="upload_file"&&typeof g.byteLength=="number"&&g.byteLength>=0&&typeof g.mimeType=="string"&&(typeof g.inlineB64=="string"||typeof g.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let Y=Number(g.byteLength),Q=(g.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",pe;if(g.inlineB64&&typeof g.inlineB64=="string"){let R=Ha(g.inlineB64);if(R.byteLength!==Y)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${R.byteLength} expected=${Y}`,allowFallback:!0};pe=R.buffer}else{let R=String(g.token);pe=await S(N,R,Y,9e4)}let J=N.Blob||Blob,ee=new J([pe],{type:Q}),se=m||g?.fileName;!se&&h&&typeof h=="string"&&(se=Us(h,N)),se=Fa(se||"upload");let we=N.File||File,Be=new we([ee],se,{type:Q,lastModified:Date.now()}),ue=N.Event||Event,Ee=N.DataTransfer||DataTransfer;if(!Ee)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let ye=new Ee;if(ye.items.add(Be),!At(T,ye.files,N))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};T.dispatchEvent(new ue("input",{bubbles:!0,composed:!0,cancelable:!0})),T.dispatchEvent(new ue("change",{bubbles:!0,composed:!0,cancelable:!0}));let E=tn(T);if(E){let R=Yt(E);if(R.onChange){let I=Xt("change",T,C,N);I.target.files=ye.files,R.onChange(I)}}let k=Rn(T);if(k){let R=Mt(k);if(R.change){let I=new ue("change",{bubbles:!0});I.target=T,I.target.files=ye.files,R.change(I)}}try{let R=N.jQuery||N.$;R&&typeof R=="function"&&R(T).triggerHandler?.("change")}catch{}return T.focus?.({preventScroll:!0}),await Te(C,N,2),{success:!0,method:"upload-file",details:`Uploaded ${se} (${_n(ee.size)}) [token]`}}catch(h){return{success:!1,method:"upload-file",details:h?.message||"Upload failed",allowFallback:!0}}}async function ut(c,y,b){let g=Array.isArray(c.path)?c.path:[];if(!g.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let f=b.PointerEvent||PointerEvent,d=b.MouseEvent||MouseEvent,h=16;for(let x=0;x<g.length;x++){let m=g[x],T=Number(m.x)||0,C=Number(m.y)||0,N=Number(m.pressure)||(x===0||x===g.length-1?0:.5),F=y.elementFromPoint(T,C)||y.documentElement,Y={bubbles:!0,cancelable:!0,clientX:T,clientY:C,screenX:T,screenY:C,view:b};if(x===0?(F.dispatchEvent(new f("pointerdown",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousedown",{...Y,button:0,buttons:1}))):(F.dispatchEvent(new f("pointermove",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousemove",{...Y,button:0,buttons:1}))),x===g.length-1&&(F.dispatchEvent(new f("pointerup",{...Y,pressure:0,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mouseup",{...Y,button:0,buttons:0}))),x<g.length-1){let Q=Number(m.timestamp)||0,pe=Number(g[x+1].timestamp)||0,J=Q&&pe?Math.max(0,Math.min(pe-Q,1e3)):h;J>0&&await Je(J,y)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${g.length} point(s)`}}function Ut(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;Ve(c,g,f),te(c,g,f),te(c,g,f);let h=c.getBoundingClientRect();return c.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:h.left+h.width/2,clientY:h.top+h.height/2,detail:2,view:f})),{success:!0,method:"dblclick"}}function he(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent;Ve(c,g,f);let x=c.getBoundingClientRect(),m=x.left+x.width/2,T=x.top+x.height/2,C={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:m,clientY:T,button:2,buttons:2};return c.dispatchEvent(new d("pointerdown",C)),c.dispatchEvent(new h("mousedown",C)),c.dispatchEvent(new d("pointerup",{...C,buttons:0})),c.dispatchEvent(new h("mouseup",{...C,buttons:0})),c.dispatchEvent(new h("contextmenu",C)),{success:!0,method:"contextmenu"}}function Zt(c,y,b){let g=G(c,y),f=X(g,b),d=c,h=c.getBoundingClientRect();return{href:String(f.location.href),hash:String(f.location.hash),ariaExpanded:c.getAttribute("aria-expanded"),ariaPressed:c.getAttribute("aria-pressed"),ariaDisabled:c.getAttribute("aria-disabled"),disabled:!!d.disabled,open:typeof d.open<"u"?d.open:void 0,checked:typeof d.checked<"u"?d.checked:void 0,value:typeof d.value<"u"?d.value:void 0,active:bo(g),rect:{w:h.width,h:h.height}}}function qt(c,y){let b=Math.abs(c.rect.w-y.rect.w)>2||Math.abs(c.rect.h-y.rect.h)>2;return c.href!==y.href||c.hash!==y.hash||c.ariaExpanded!==y.ariaExpanded||c.ariaPressed!==y.ariaPressed||c.ariaDisabled!==y.ariaDisabled||c.disabled!==y.disabled||c.open!==y.open||c.checked!==y.checked||c.value!==y.value||c.active!==y.active||b}async function Ue(c,y,b,g){await Promise.resolve();let f=G(c,y),d=X(f,b);y.hidden||await Ct();let h=Zt(c,f,d);return qt(g,h)}function tt(c,y,b){c.focus?.({preventScroll:!0});let g=G(c,y),f=X(g,b),x=c.getAttribute("role")==="button"||vi(c,f)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],m=f.KeyboardEvent||KeyboardEvent;for(let T of x){let C={key:T,code:T===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new m("keydown",C)),c.dispatchEvent(new m("keypress",C)),c.dispatchEvent(new m("keyup",C))}return{success:!0,method:"keyboard-activate"}}async function Vr(c,y,b,...g){let f=null;for(let d of g){let h=G(c,y),x=X(h,b),m=Zt(c,h,x),T=d();if(!T||!T.success)continue;if(await Ue(c,h,x,m))return{...T,details:(T.details?T.details+";":"")+"verified=true"};f=T}return f?{...f,details:(f.details?f.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function vn(...c){for(let y of c)try{let b=y();if(b&&b.success)return b}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ve(c,y,b){let g=G(c,y),f=X(g,b),d=c.getBoundingClientRect();d.top>=0&&d.left>=0&&d.bottom<=f.innerHeight&&d.right<=f.innerWidth||(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),c.offsetHeight)}function xn(c,y,b,g){let f=G(c,y),h=X(f,b).KeyboardEvent||KeyboardEvent;for(let x of g){let m=String(x??""),T="";/^[a-z]$/i.test(m)?T=`Key${m.toUpperCase()}`:/^[0-9]$/.test(m)?T=`Digit${m}`:m===" "&&(T="Space");let C=m.length===1?m.charCodeAt(0):0,N={key:m,code:T,bubbles:!0,cancelable:!0,composed:!0,keyCode:C,which:C};c.dispatchEvent(new h("keydown",N)),c.dispatchEvent(new h("keypress",N)),c.dispatchEvent(new h("keyup",N))}}function Gn(c,y,b){let g=G(c,y),d=X(g,b).KeyboardEvent||KeyboardEvent,h={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},x=c.dispatchEvent(new d("keydown",h)),m=c.dispatchEvent(new d("keypress",h)),T=c.dispatchEvent(new d("keyup",h));if(!!(x&&m&&T)){let N=c.form||c.closest?.("form");N?.requestSubmit?.()??N?.submit?.()}}function en(c){return{Enter:"Enter",Tab:"Tab",Escape:"Escape",Space:"Space"," ":"Space",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Backspace:"Backspace",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12"}[c]||`Key${c.toUpperCase()}`}let qn=new MessageChannel,Yn=[];qn.port1.onmessage=()=>{let c=Yn.shift();c&&c()};function Ct(){return new Promise(c=>{Yn.push(c),qn.port2.postMessage(0)})}function tn(c){let y=g=>{if(!g)return null;let f=Object.keys(g);for(let d of f)if(d.startsWith("__reactFiber")||d.startsWith("__reactInternalInstance")||d.includes("reactFiber")||d.includes("reactProps")||d.includes("reactEventHandlers")||/^__r\d+/.test(d))return g[d];return null},b=c;for(let g=0;g<4&&b;g++){let f=y(b);if(f)return f;b=b.parentElement}return null}function Yt(c){let y={},b=c,g=0;for(;b&&g++<10;){let f=[b.memoizedProps,b.pendingProps,b.stateNode?.props,b._memoizedProps,b._pendingProps,b.alternate?.memoizedProps].filter(Boolean);for(let d of f)if(!(!d||typeof d!="object"))for(let h in d)h.startsWith("on")&&typeof d[h]=="function"&&(y[h]=d[h]);if(Object.keys(y).length)break;b=b.return||b.alternate}return y}function fr(c,y){let b=c;for(;b;){if(b._reactRootContainer||b.__reactContainer||b.hasAttribute("data-reactroot")||b.hasAttribute("data-react-root")||["root","app","__next"].includes(b.id))return b;b=b.parentElement}return G(c,y).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Xt(c,y,b,g){let f=G(y,b),d=X(f,g),h=d.MouseEvent||MouseEvent,x=y.getBoundingClientRect(),m=new h(c,{bubbles:!0,cancelable:!0,view:d,clientX:x.left+x.width/2,clientY:x.top+x.height/2});return{type:c,target:y,currentTarget:y,bubbles:!0,cancelable:!0,nativeEvent:m,isTrusted:!0,preventDefault(){m.preventDefault()},stopPropagation(){m.stopPropagation()}}}function Rn(c){let y=c;if(y.__vue__)return y.__vue__;if(y.__vueParentComponent)return y.__vueParentComponent;if(y._vnode)return y._vnode;let b=c.parentElement;for(let g=0;g<3&&b;g++){let f=b;if(f.__vue__||f.__vueParentComponent||f._vnode)return f.__vue__||f.__vueParentComponent||f._vnode;b=b.parentElement}return null}function Mt(c){let y={};if(c?.$listeners&&Object.assign(y,c.$listeners),c?._events)for(let b in c._events){let g=c._events[b];y[b]=Array.isArray(g)?g[0]:g}if(c?.props)for(let b in c.props)b.startsWith("on")&&typeof c.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.props[b]);if(c?.vnode?.props)for(let b in c.vnode.props)b.startsWith("on")&&typeof c.vnode.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.vnode.props[b]);return y}})();function Va(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function $a(e){let t=window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.actions?.execute;if(typeof o!="function")throw new Error("Rover main-world action executor not initialized");return o(e)}function To(e,t,n={}){let{rootNodes:r,semanticNodes:o}=Is(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),s={};for(let i of Object.keys(o)){let a=Number(i);if(!Number.isFinite(a))continue;let u=Rr(a);u&&(s[a]=t.getFrameworkMetadata(u))}return{rootNodes:r,semanticNodes:o,elementMeta:s}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(p=document,_=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=p,this.win=_,this.viewport={width:_.innerWidth,height:_.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let _=this.detectPrimaryScrollable();if(!_)return null;let{target:A,isRoot:S}=this.getScrollContext(_.element),M=A.scrollHeight,O=Kt(),W=S&&O?O.innerHeight:A.clientHeight,q=Math.max(0,M-W),U=A.scrollTop;return{selector:_.selector,score:_.score,type:_.type,metrics:{scrollTop:U,scrollHeight:M,clientHeight:W,isAtTop:U<=5,isAtBottom:U>=q-5}}}case"scrollTo":if(!p.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(p.direction,p.options);case"scrollBy":if(!p.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(p.direction,p.options);case"scrollElement":if(!p.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(p.selector,p.position,p.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${p.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(p){return this.handleCommand(p)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let S=Array.from(this.detectionCache.values()).sort((M,O)=>O.score-M.score)[0];if(S)return this.lastDetectedPrimary=S.element,S}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let S=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!S)return null;let M=this.buildFeatures(S),O=G(S,this.doc),W={element:S,selector:sr(S,O),score:.5,features:M,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(W.selector,W),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=S,W}let _=this.scoreCandidates(p);if(_.length===0)return null;this.detectionCache.clear();for(let S of _)this.detectionCache.set(S.selector,S);this.lastDetectionTime=Date.now();let A=_[0];return A&&(this.lastDetectedPrimary=A.element),A||null}collectAllElementsDeep(p,_=15e4){let A=[],S=[],M=p.body||p.documentElement;M&&S.push(M);let O=0,W=q=>{try{let U=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",B=this.win[U]?.shadow?.getRoot;if(typeof B=="function"){let z=B(q);if(z)return z}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;S.length&&!(++O>_);){let q=S.pop();if(vt(q)){let B=q.children;for(let z=B.length-1;z>=0;z--)S.push(B[z]);continue}let U=q,P=oe(U);Ge(U,P)&&A.push(U);try{let B=W(U);B&&S.push(B)}catch{}for(let B=U.lastElementChild;B;B=B.previousElementSibling)S.push(B)}return A}collectScrollableCandidates(){let p=[],_=new WeakSet,A=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let M of A){if(!M||_.has(M))continue;let O=this.isScrollable(M);(O.vertical||O.horizontal)&&(p.push(M),_.add(M))}let S=this.collectAllElementsDeep(this.doc);for(let M of Array.from(S)){if(_.has(M))continue;let O=M.getBoundingClientRect(),W=this.win.getComputedStyle(M);if(!this.isElementRendered(M,O,W)||!this.isScrollable(M).vertical)continue;let U=40,P=this.viewport.width*.15;if(O.height<U||O.width<P){let B=(M.className||"").toLowerCase().includes("scroll"),z=W.overflowY==="auto"||W.overflowY==="scroll"||W.overflow==="auto"||W.overflow==="scroll";if(!B&&!z)continue}p.push(M),_.add(M)}return p}isElementRendered(p,_,A){if(A.display==="none"||A.visibility==="hidden")return!1;let S=parseFloat(A.opacity||"1");return!(!Number.isNaN(S)&&S<.01||_.width<=1||_.height<=1)}isScrollable(p){let _=this.win.getComputedStyle(p),A=_.overflowY,S=_.overflowX,M=this.doc.scrollingElement,O=p===this.doc.documentElement||p===this.doc.body||!!M&&p===M,W=p.scrollHeight,q=p.clientHeight,U=p.scrollWidth,P=p.clientWidth;if(O){let ne=this.doc.documentElement,de=this.doc.body;W=Math.max(ne?ne.scrollHeight:0,de?de.scrollHeight:0),q=this.win.innerHeight}let B=W-q>8,z=U-P>8,te=A==="auto"||A==="scroll"||A==="overlay",re=S==="auto"||S==="scroll"||S==="overlay";return{vertical:O?B:B&&te,horizontal:O?z:z&&re,byOverflow:te||re}}calculateVisibleIntersection(p){let _=Math.max(0,p.left),A=Math.max(0,p.top),S=Math.min(this.viewport.width,p.right),M=Math.min(this.viewport.height,p.bottom),O=Math.max(0,S-_),W=Math.max(0,M-A);return{width:O,height:W,area:O*W}}analyzeTextContent(p,_=2e3){let A=0,S=0,M=p.ownerDocument||this.doc,W=(M.defaultView||this.win).NodeFilter||NodeFilter,q=M.createTreeWalker(p,W.SHOW_ELEMENT|W.SHOW_TEXT,null),U=0,P=q.currentNode,B=[];for(;P&&U<_;){if(P.nodeType===Node.TEXT_NODE){let j=(P.textContent||"").replace(/\s+/g,"").length;if(j>0){A+=j;let le=P.parentElement;le&&le.closest("a")&&(S+=j)}}else P.nodeType===Node.ELEMENT_NODE&&B.push(P);U++,P=q.nextNode()}let z=B.length||1,te=A/z,re=A>0?S/A:0;return{textChars:A,linkChars:S,textDensity:te,linkDensity:re}}calculateRepetitionScore(p){let _=Array.from(p.children);if(_.length<3)return 0;let A=_.slice(0,50),S=new Map,M=new Map,O=new Map;for(let ie of A){let j=oe(ie);if(!Ge(ie,j))continue;let le=ie.getBoundingClientRect();if(le.height<5||le.width<this.viewport.width*.1)continue;let ne=Math.round(le.height/10)*10,de=Math.round(le.width/10)*10;S.set(ne,(S.get(ne)||0)+1),M.set(de,(M.get(de)||0)+1);let be=(ie.className||ie.tagName).toString();O.set(be,(O.get(be)||0)+1)}let W=A.length||1,q=Math.max(0,...S.values()),U=Math.max(0,...M.values()),P=Math.max(0,...O.values()),B=q/W,z=U/W,te=P/W,re=.4*B+.3*z+.3*te;return Math.min(1,Math.max(0,re))}calculateSemanticScore(p){let _=0,A=null,S=!1,M=(p.getAttribute("role")||"").toLowerCase(),O=p.tagName.toLowerCase(),W=(p.id||"").toLowerCase(),q=(p.className||"").toLowerCase(),U=`${M} ${O} ${W} ${q}`;return(O==="main"||M==="main")&&(_+=1.2,A="article"),O==="article"&&(_+=1,A=A||"article"),(M==="feed"||U.includes("feed"))&&(_+=1,A="feed"),(M==="log"||U.includes("chat")||U.includes("messages"))&&(_+=1,A="chat"),U.includes("content")&&(_+=.5),(U.includes("results")||U.includes("list"))&&(_+=.4),(U.includes("job")||U.includes("jobs"))&&(_+=.4),(O==="nav"||M==="navigation"||U.includes("sidebar"))&&(_-=1,S=!0),(O==="aside"||M==="complementary")&&(_-=.7,S=!0),(O==="footer"||M==="contentinfo"||U.includes("footer"))&&(_-=.8,S=!0),U.includes("header")&&(_-=.6),_=Math.max(-1,Math.min(1,_)),{semanticScore:_,typeHint:A,navLike:S}}detectScrollListeners(p){return[p.querySelector('[class*="infinite"]'),p.querySelector('[class*="load-more"]'),p.querySelector("[data-infinite]"),p.querySelector('[loading="lazy"]'),p.querySelector(".observer-target"),p.querySelector("[data-scroll]")].some(A=>A!==null)}buildFeatures(p){let _=p.getBoundingClientRect(),A=this.win.getComputedStyle(p),S=this.calculateVisibleIntersection(_),M=this.viewport.width*this.viewport.height||1,O=S.area/M,W=this.viewport.width>0?S.width/this.viewport.width:0,q=_.top+_.height/2,U=this.viewport.height/2||1,P=Math.min(1,Math.abs(q-U)/U),B=this.isScrollable(p),z=this.doc.scrollingElement,te=p===this.doc.documentElement||p===this.doc.body||!!z&&p===z,re=p.scrollHeight,ie=p.clientHeight;if(te){let Me=this.doc.documentElement,Ze=this.doc.body;re=Math.max(Me?Me.scrollHeight:0,Ze?Ze.scrollHeight:0),ie=this.win.innerHeight}let j=Math.max(0,re-ie),le=j*S.width,ne=this.analyzeTextContent(p),de=this.calculateRepetitionScore(p),be=this.calculateSemanticScore(p),ht=p.contains(this.doc.activeElement),Te=this.detectScrollListeners(p),Oe=parseInt(A.zIndex||"0",10),He=Number.isFinite(Oe)?Oe:0;return{geometry:{viewportCoverage:O,widthProminence:W,centerDistance:P,scrollCapacity:j,scrollSurface:le,zIndex:He},content:{textDensity:ne.textDensity,linkDensity:ne.linkDensity,repetitionScore:de,semanticScore:be.semanticScore},interaction:{hasScrollListeners:Te,hasFocus:ht,recentActivity:ht?1:0}}}inferElementType(p,_,A,S){if(A)return A;let M=(p.getAttribute("role")||"").toLowerCase(),O=(p.className||"").toLowerCase(),W=p.tagName.toLowerCase(),q=_.geometry,U=_.content;if(M==="log"||O.includes("chat")||O.includes("messages"))return"chat";let P=this.win.getComputedStyle(p);if((P.position==="fixed"||P.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(M==="feed"||U.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(W==="article"||U.textDensity>40&&U.linkDensity<.4&&q.widthProminence>.4)return"article";if(S||q.widthProminence<.3&&U.linkDensity>.3)return"sidebar";let z=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||z&&p===z?"document":"unknown"}scoreCandidates(p){let _=[],A=[],S=[],M=[],O=[],W=[];for(let te of p){let re=this.buildFeatures(te),ie=re.content.semanticScore,j=this.calculateSemanticScore(te),le=this.inferElementType(te,re,j.typeHint,j.navLike);W.push({element:te,features:{geometry:{...re.geometry},content:{...re.content,semanticScore:j.semanticScore},interaction:re.interaction},type:le,navLike:j.navLike,semanticScore:j.semanticScore}),A.push(re.geometry.scrollSurface),S.push(re.content.textDensity),M.push(Math.abs(j.semanticScore)),O.push(re.content.repetitionScore)}let q=Math.max(0,...A),U=Math.max(0,...S),P=Math.max(0,...M),B=Math.max(0,...O),z=-1/0;for(let te of W){let{element:re,features:ie,type:j,navLike:le,semanticScore:ne}=te,de=ie.geometry,be=ie.content,ht=ie.interaction,Te=q>0?de.scrollSurface/q:0,Oe=U>0?be.textDensity/U:0,He=P>0?(ne/P+1)/2:.5,Me=j==="feed"||be.repetitionScore>.3&&de.scrollCapacity>400,Ze=be.linkDensity>.5?(be.linkDensity-.5)/.5:0,st=Me?0:Ze,yt=(Me?1:.5)*be.repetitionScore*Math.min(1,de.scrollCapacity/4e3),it={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[j]||0,ke=0;ke+=de.viewportCoverage*.18,ke+=de.widthProminence*.15,ke+=(1-de.centerDistance)*.07,ke+=Te*.22,ke+=yt*.18,ke+=Oe*.08,ke+=(B>0?be.repetitionScore/B:0)*.05,ke+=He*.07,ke-=st*.05,ht.hasFocus&&(ke+=.05),ht.hasScrollListeners&&(ke+=.05),ke+=it,le&&(ke-=.05);let Le=Math.max(0,Math.min(1,ke));Le>z&&(z=Le),_.push({element:re,selector:sr(re,G(re)),score:Le,features:ie,type:j})}if(_.sort((te,re)=>re.score-te.score),_.length>=2){let te=_[0],re=_[1];Math.abs(te.score-re.score)<.08&&te.type==="article"&&re.type==="feed"&&(_[0]=re,_[1]=te)}return _}getScrollContext(p){let _=document.scrollingElement;return p===document.documentElement||p===document.body||!!_&&p===_?{target:_||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=G(S),W=X(O),q=_?.isTabActive??!O.hidden,U=_?.behavior,P=q&&U==="smooth",B=M?Math.max(O.documentElement?O.documentElement.scrollHeight:0,O.body?O.body.scrollHeight:0):S.scrollHeight,z=M?W.innerHeight:S.clientHeight,te=Math.max(0,B-z),re=()=>M?W.scrollY:S.scrollTop,ie=j=>{if(P)try{M?W.scrollTo({top:j,behavior:"smooth"}):S.scrollTo({top:j,behavior:"smooth"})}catch{M?(O.scrollingElement||O.documentElement||O.body).scrollTop=j:S.scrollTop=j}else if(M){let le=O.scrollingElement||O.documentElement||O.body;le.scrollTop=j}else S.scrollTop=j};switch(p){case Fe.TOP:return ie(0),{success:!0,scrollTop:0,isAtTop:!0};case Fe.BOTTOM:return ie(te),{success:!0,scrollTop:te,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=_?.isTabActive??!document.hidden,W=_?.behavior,q=O&&W==="smooth",U=Kt(),P=M&&U?U.innerHeight:S.clientHeight,B=M&&U?U.innerWidth:S.clientWidth,z=_?.amount??P*.8,te=M?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):S.scrollHeight,re=M&&U?U.innerHeight:S.clientHeight,ie=Math.max(0,te-re),j=ne=>{if(q)try{M?U?.scrollTo({top:ne,behavior:"smooth"}):S.scrollTo({top:ne,behavior:"smooth"})}catch{let de=document.scrollingElement||document.documentElement||document.body;de.scrollTop=ne}else{let de=M?document.scrollingElement||document.documentElement||document.body:S;de.scrollTop=ne}},le=ne=>{if(q)try{S.scrollBy({left:ne,behavior:"smooth"})}catch{S.scrollLeft+=ne}else S.scrollLeft+=ne};switch(p){case Fe.DOWN:{let de=(M&&U?U.scrollY:S.scrollTop)+z;j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.UP:{let ne=M&&U?U.scrollY:S.scrollTop,de=Math.max(0,ne-z);j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.LEFT:{let ne=-(_?.amount??B*.8);return le(ne),{success:!0,scrollLeft:S.scrollLeft}}case Fe.RIGHT:{let ne=_?.amount??B*.8;return le(ne),{success:!0,scrollLeft:S.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case ot.START:return"start";case ot.END:return"end";case ot.NEAREST:return"nearest";case ot.CENTER:default:return"center"}}getScrollContainerForElement(p){let _=document.scrollingElement,A=p;for(;A&&A!==document.body&&A!==document.documentElement;){let O=getComputedStyle(A).overflowY,W=O==="auto"||O==="scroll"||O==="overlay",q=A.scrollHeight-A.clientHeight>8;if(W&&q)return{container:A,isRoot:!1};A=A.parentElement}return{container:_||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,_,A){let S=document.querySelector(p);if(!S)return{success:!1,error:`Element not found for selector: ${p}`};let{container:M,isRoot:O}=this.getScrollContainerForElement(S),W=oe(M),q=W?.DOMRect||DOMRect,U=O?new q(0,0,W.innerWidth??0,W.innerHeight??0):M.getBoundingClientRect(),P=S.getBoundingClientRect(),B=24,z=P.top>=U.top+B&&P.bottom<=U.bottom-B,te=A?.isTabActive??!document.hidden,re=A?.behavior,ie=te&&re==="smooth",j=this.normalizeScrollPosition(_);if(_===ot.NEAREST&&z)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(M,O)};try{S.scrollIntoView({behavior:ie?"smooth":"auto",block:j,inline:"nearest"})}catch{S.scrollIntoView()}let le=this.getScrollMetricsForContainer(M,O);return{success:!0,position:j,...le}}getScrollMetricsForContainer(p,_){let A=_?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,S=G(p),M=oe(p),O=_&&M?M.innerHeight:p.clientHeight,W=Math.max(0,A-O),U=(_?S.scrollingElement||S.documentElement||S.body:p).scrollTop;return{scrollTop:U,scrollHeight:A,clientHeight:O,maxScroll:W,isAtTop:U<=5,isAtBottom:U>=W-5,scrollPercentage:W>0?U/W*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:_,isRoot:A}=this.getScrollContext(p),S=G(_),M=X(S),O=A?Math.max(S.documentElement?S.documentElement.scrollHeight:0,S.body?S.body.scrollHeight:0):_.scrollHeight,W=A?M.innerHeight:_.clientHeight,q=Math.max(0,O-W),P=(A?S.scrollingElement||S.documentElement||S.body:_).scrollTop;return{element:sr(_,S),scrollTop:P,scrollHeight:O,clientHeight:W,maxScroll:q,isAtTop:P<=5,isAtBottom:P>=q-5,scrollPercentage:q>0?P/q*100:0}}}let o=new r;window[e]=o;let s={execute:v=>o.execute(v)};try{Object.defineProperty(window,t,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=s}catch{}}let i=window.__RTRVR_INTERNAL_KEY__||n,a=window[i],u=a&&typeof a=="object"?a:null;if(u){try{u.scroll=u.scroll||s}catch{}try{u.scroll||Object.defineProperty(u,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(i!==n)try{!window[n]&&u&&Object.defineProperty(window,n,{value:u,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var xu=/\[id=(\d+)\]/,qe;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(qe||(qe={}));var Ga=new Map;function Ru(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[bt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let i=o.match(xu);if(i?.[1]){let a=Number(i[1]);Number.isFinite(a)&&(t[a]=s)}}}return t}async function Ka(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||wo,s=String(r.contentType||"").trim().toLowerCase(),i=Su(s,r),a=Iu(i.documentType,s),u={url:r.URL,title:r.title,contentType:a},v=ku(o);if(i.documentType!==qe.HTML){let O=Number(o?.pageDataTimeoutMs),W=Number.isFinite(O)?Math.max(200,Math.floor(O)):9e3,q=Math.max(200,Math.min(W,Nt(v))),U=Lu(r,i.documentType,o,v),P=await or(U,q,r);if(!P.ok)return{...u,content:"",error:`non_html_timeout:${a}`,metadata:{extractionMethod:"timeout"}};let B=P.value||{},z=i.documentType===qe.GOOGLE_SHEET?ad(r):void 0;return{...u,...B,contentType:B.contentType||u.contentType,sheetInfo:B.sheetInfo||z}}if(o?.onlyTextContent)return{...u,contentType:nr,content:ko(r)};let p=Math.max(0,Math.min(3e3,Nt(v))),_=performance.now(),A=!1;if(!o?.disableAutoScroll&&p>80){let O=r.hidden?900:1500,W=Math.min(O,p);W>80&&(A=await od(r,{profile:"light",timeBudgetMs:W,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let S=Math.max(0,p-(performance.now()-_));S>80&&await id(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,S),budgetMs:Math.min(r.hidden?650:850,S),maxPasses:r.hidden?1:2});let M=To(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return Ou(M.rootNodes,M.semanticNodes)?{...u,contentType:nr,content:ko(r),metadata:{scrollingPerformed:A}}:{...u,contentType:nr,roots:M.rootNodes,nodes:M.semanticNodes,elementLinkRecord:Ru(M.semanticNodes),metadata:{scrollingPerformed:A}}}function ku(e){let t=Number(e?.deadlineEpochMs);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.totalBudgetMs),r=Number.isFinite(n)?Math.max(1500,Math.floor(n)):9e3;return Date.now()+r}function Iu(e,t){switch(e){case qe.PDF:return Cs;case qe.GOOGLE_DOC:return Ns;case qe.GOOGLE_SHEET:return Ms;case qe.PLAIN_TEXT:return yo;case qe.HTML:default:return t||nr}}function Su(e,t){let n=e||String(t.contentType||"").toLowerCase();return Oa(n)?{documentType:qe.PDF}:Au(t)&&(Mu(t)||Cu(t.URL))?{documentType:qe.PDF}:$u(t)?{documentType:qe.GOOGLE_DOC}:Gu(t)?{documentType:qe.GOOGLE_SHEET}:n.includes(yo)?{documentType:qe.PLAIN_TEXT}:{documentType:qe.HTML}}function Au(e){try{let t=Uu(e);return Ds(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function Cu(e){try{return e?e.toLowerCase().includes(".pdf")?!0:(new URL(e).searchParams.get("file")||"").toLowerCase().includes(".pdf"):!1}catch{return String(e||"").toLowerCase().includes(".pdf")}}function Mu(e){try{let t=e.body;return!t||t.querySelectorAll('embed[type="application/pdf"],embed[type="application/x-google-chrome-pdf"],object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]').length===0||(t.innerText||"").trim().length>40?!1:Array.from(t.children).filter(s=>!["SCRIPT","STYLE"].includes(String(s.tagName).toUpperCase())).length<=3}catch{return!1}}async function Lu(e,t,n,r){switch(t){case qe.PDF:return Nu(e,n,r);case qe.GOOGLE_DOC:return Du(e);case qe.GOOGLE_SHEET:return td(e,n);case qe.PLAIN_TEXT:return{content:ko(e),contentType:yo};case qe.HTML:default:return{content:ko(e),contentType:nr}}}async function Nu(e,t,n){Nt(n)>As+50&&await Ua(As,e,n);let o=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),_=wo.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):_})(),s=Nt(n),a=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,u=await Hu(e,a),v=!!u.success&&!!(u.data||"").trim();return{content:v&&u.data||"",contentType:Cs,error:v?void 0:`pdf_extraction_failed:${u.reason||"unknown"}`}}async function Du(e){return{content:ed(),contentType:Ns}}function Ou(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function ko(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function Uu(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let s=o(e.body||e.documentElement);if(s)return s}}catch{}return e}function Fu(e){let t=e.URL||"";try{let n=new URL(t),r=n.searchParams.get("file")||n.searchParams.get("src")||"";return r||t}catch{return t}}async function Hu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):wo.pdfTextSelectionTimeoutMs,r=Fu(e),o=Ga.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await Pu(e,n);return s.success&&s.data.trim()&&Ga.set(r,s.data),s}async function Pu(e,t){let n=e.defaultView||window,r=Bu(e);if(!r||typeof r.postMessage!="function")return{success:!1,data:"",reason:"no_viewer"};let o=globalThis.crypto&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,s=!1,i="",a=p=>{if(s||!Wu(String(p.origin||""),e))return;let _=p.data;Vu(_,o)&&typeof _.selectedText=="string"&&_.selectedText.trim().length>0&&(i=_.selectedText,s=!0)};n.addEventListener("message",a);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let u=Date.now();for(;!s&&Date.now()-u<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await Je(200,e),i.trim()){s=!0;break}}return n.removeEventListener("message",a),i.trim()?{success:!0,data:i,reason:"ok"}:{success:!1,data:"",reason:Date.now()-u>=t?"timeout":"no_response"}}function Bu(e){let t=Ds(e)||e.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]');if(t&&typeof t.postMessage=="function")return t;let n=e.querySelector?.('iframe[type="application/pdf"]');return n?.contentWindow?n.contentWindow:null}function Wu(e,t){let n=(e||"").toLowerCase();if(!n||n==="null"||n.startsWith("chrome-extension://")||n.startsWith("chrome://")||n.startsWith("chrome-untrusted://"))return!0;try{let r=new URL(t.URL||"").origin.toLowerCase();if(r&&n===r)return!0}catch{}return!1}function Vu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function $u(e){try{let t=e.defaultView||Kt();if(t?.location.hostname==="docs.google.com"&&t?.location.pathname.startsWith("/document/d/"))return!0}catch{}try{if(e.querySelector('iframe[src^="https://docs.google.com/document/d/"]'))return!0}catch{}return ir(e)!==null}function Gu(e){let n=(e.defaultView||Kt())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function qu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function Io(e){let t=[e],n=qu(e);return n!==e&&t.push(n),t}var Yu=".docs-texteventtarget-iframe",Xu=".kix-cursor",zu=".docos-replyview-body",Ku=".docos-replyview",ju=".docos-author",ja="\u200B",Qu="\xA0";function ir(e){for(let t of Io(e)){let n=t.querySelector(Yu);if(n)return n}return null}function Ju(e){for(let t of Io(e)){let n=t.querySelector(Xu);if(n)return n}return null}function vo(e){let t=Ju(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function xo(e,t){let n=ir(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",s={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},i=n.contentDocument,a=n.contentWindow;if(!i)return;let u=a?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new u("keydown",s))}function qa(e){let t=ir(e);if(!t)return;let n={key:"ArrowLeft",keyCode:37,code:"ArrowLeft",bubbles:!0,cancelable:!0},r=t.contentDocument,o=t.contentWindow;if(!r)return;let s=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new s("keydown",n))}function Zu(e){let t=ir(e);if(!t)return;let r=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0,o={key:"a",code:"KeyA",ctrlKey:!r,metaKey:r,bubbles:!0,cancelable:!0},s=t.contentDocument,i=t.contentWindow;if(!s)return;let a=i?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new a("keydown",o))}function Ro(e){let t=ir(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let a=r?.ClipboardEvent||ClipboardEvent,u=new a("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(u),o.firstChild?.dispatchEvent||o.dispatchEvent(u)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(ja,"g"),"")??""}function Ps(e){let t=`
|
|
3
|
+
|
|
4
|
+
Comments: `,n=new Set,r=[];for(let s of Io(e))try{let i=Array.from(s.querySelectorAll(zu));for(let a of i)n.has(a)||(n.add(a),r.push(a))}catch{}let o=r.filter(s=>s.textContent);if(o.length===0)return"";for(let s of o){let i=s.closest(Ku);if(!i)continue;let a=i.querySelector(ju);a&&a.textContent&&(t+=`
|
|
5
|
+
Author: ${a.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
6
|
+
`)}return t.trim()}function ed(){let e=Xe()||document,t=ir(e),n=t?.contentDocument,r=t?.contentWindow,o=()=>{let s=n?.body,i=Xe(),a=s?.innerText||s?.textContent||""||i?.body?.innerText||i?.body?.textContent||"";return String(a).replace(new RegExp(ja,"g"),"")+Ps(e)};try{try{r?.focus(),n?.body?.focus?.()}catch{}if(Zu(e),vo(e)){let u=Ro(e);if(u.trim()!==""){let v=Ps(e).trim();return u+v}else qa(e)}let s="";if(xo(e,!0),vo(e)){let u=Ro(e);u.endsWith(`
|
|
7
|
+
|
|
8
|
+
`)||(s+=u.trimEnd())}if(xo(e,!1),vo(e)?Ro(e).endsWith(Qu+`
|
|
9
|
+
`)&&xo(e,!1):xo(e,!1),vo(e)){let u=Ro(e);u.trim()!==""&&!u.startsWith(`
|
|
10
|
+
`)&&(s+=u)}qa(e);let i=Ps(e).trim(),a=s.trim()+i;return a.trim()?a:o()}catch{return o()}}async function td(e,t){let n="",r;Qa(e,e.defaultView||window);let o=Nt(t?.deadlineEpochMs);try{let s=Math.max(250,Math.min(1500,Math.floor(o*.45))),i=await or(nd(e),s,e);if(!(i.ok&&i.value))throw new Error("google_sheet_copy_failed");let u=Nt(t?.deadlineEpochMs),v=Math.max(250,Math.min(2500,Math.floor(u*.55)));if(n=await rd(v,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(s){r=s instanceof Error?s.message:String(s)}return{content:n,contentType:Ms,error:r}}function Qa(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Bs(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),s=e.activeElement;(s&&s.ownerDocument===e?s:e).dispatchEvent(o)}async function nd(e){try{if(Qa(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Bs(e,{key:"Escape",code:"Escape"}),await Je(150,e);let t=e.querySelector(".grid-container")||Ya(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Ya(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await Je(100,e)}else if(t){try{t.focus?.()}catch{}await Je(80,e)}let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Bs(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await Je(200,e),Bs(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await Je(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function rd(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let s=await or(navigator.clipboard.readText(),n,t);if(s.ok)return s.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function Ya(e,t){let n=Io(e);for(let a of n)try{let u=a.querySelector(t);if(u)return u}catch{}let r=25e3,o=0,s=(a,u)=>{if(!u)return;let v=u.children;if(v)for(let p=0;p<v.length;p++)a.push(v[p])},i=[];for(let a of n)try{s(i,a.documentElement??a.body??null)}catch{}for(;i.length&&o<r;){let a=i.pop();o++;try{if(a.matches(t))return a}catch{}s(i,a);let u=a.shadowRoot;if(u&&s(i,u),String(a.tagName).toUpperCase()==="IFRAME")try{let p=a.contentDocument;p&&s(i,p.documentElement??p.body??null)}catch{}}return null}async function od(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let s=Date.now(),i=()=>o-(Date.now()-s),a=t?.delayMs??(n==="light"?220:280),u=t?.finalWaitMs??(n==="light"?350:900),v=r?a:0,p=r?u:0,_=t?.amount,A=t?.maxSteps??(n==="light"?8:18),S=t?.maxDistancePx??(n==="light"?12e3:3e4),M=null;try{let U=await Xa(e,{action:"detectPrimary"});if(U?.selector){let B=sd(e,U.selector);B&&(M=B)}let P=U?.metrics;if(P&&typeof P.scrollHeight=="number"&&typeof P.clientHeight=="number"){let B=Math.max(0,P.scrollHeight-P.clientHeight);S=Math.min(S,B||S),B<1500?A=Math.min(A,2):B<4e3?A=Math.min(A,4):B<1e4&&(A=Math.min(A,6))}}catch{}if(M||(M=e.scrollingElement||e.documentElement||e.body),!M)return!1;let O=0,W=null,q=0;for(let U=0;U<A&&!(i()<=0);U++){let P=null;try{P=await Xa(e,{action:"scrollBy",direction:Fe.DOWN,options:{amount:_,behavior:"auto",isTabActive:r}})}catch{}if(!P||!P.success){let z=e.defaultView||window;P=_o(M,e,z,Fe.DOWN,_),q=2}if(!P?.success)break;let B=P.scrollTop??W??0;if(W!==null){let z=Math.max(0,B-W);O+=z,q=z===0?q+1:0}if(W=B,P.isAtBottom||q>=2||O>=S)break;if(v>0&&U<A-1){let z=Math.min(v,Math.max(0,i()));if(z<=0)break;await Je(z,e)}}if(p>0){let U=Math.min(p,Math.max(0,i()));U>0&&await Je(U,e)}if(i()>80)try{let U=e.scrollingElement||e.documentElement||e.body,P=e.defaultView||window,B=M===e.documentElement||M===e.body||M===U?U:M;if(B){let z=B===U?P.innerHeight:B.clientHeight||P.innerHeight,te=Math.max(0,B.scrollHeight-z);B.scrollTop=te}}catch{}return!0}function sd(e,t){try{return e.querySelector(t)}catch{return null}}async function Xa(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof i!="function"?null:i(t)}async function id(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let i=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),a=0;for(;a<t.maxPasses&&Nt(i)>0;){let u=Math.max(50,Math.min(t.budgetMs,Nt(i)));try{await s({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:i})}catch{break}if(za(e)===0)break;a++}if(za(e)>0&&Nt(i)>50){let u=Math.min(120,Nt(i));try{await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:i})}catch{}}}function za(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(br);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function ad(e){let t=cd(e.URL||"");if(!t?.sheetId)return;let n=ld(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function cd(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let s=n[o+1];if(!s||!/^[a-zA-Z0-9_-]+$/.test(s))return null;let i;return t.hash&&t.hash.includes("gid=")&&(i=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!i&&t.searchParams.has("gid")&&(i=t.searchParams.get("gid")??void 0),i&&!/^\\d+$/.test(i)&&(i=void 0),{sheetId:s,sheetTabId:i?parseInt(i,10):0}}catch{return null}}function ld(e){try{let t=e.querySelector('[role="tab"][aria-selected="true"]')||e.querySelector(".docs-sheet-tab-active")||e.querySelector('.docs-sheet-tab[aria-selected="true"]');if(!t)return null;let n=t.getAttribute("aria-label")||t.textContent?.trim()||void 0,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}catch{return null}}var Rt;(function(e){e[e.Native=1]="Native",e[e.Inline=2]="Inline",e[e.React=4]="React",e[e.Vue=8]="Vue",e[e.Angular=16]="Angular",e[e.Svelte=32]="Svelte",e[e.JQuery=64]="JQuery",e[e.Delegated=128]="Delegated",e[e.Other=256]="Other",e[e.Inferred=512]="Inferred"})(Rt||(Rt={}));var ud={native:Rt.Native,inline:Rt.Inline,react:Rt.React,vue:Rt.Vue,angular:Rt.Angular,svelte:Rt.Svelte,jquery:Rt.JQuery,delegated:Rt.Delegated,other:Rt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,s=new WeakMap,i=new Set,a=500,u=200,v=0,p=0,_=new WeakSet,A="__RTRVR_ET_HOOKED__",S="__RTRVR_ATTACH_SHADOW_HOOKED__";function M(l){if(l&&!_.has(l)){_.add(l);try{O(l)}catch{}try{W(l)}catch{}}}function O(l){try{let E=l.EventTarget;if(!E?.prototype||E.prototype[A])return;E.prototype[A]=!0;let k=E.prototype.addEventListener,R=E.prototype.removeEventListener;E.prototype.addEventListener=function(I,D,V){try{ln(D)||Ct(this,I,V)}catch{}return k.call(this,I,D,V)},E.prototype.removeEventListener=function(I,D,V){try{tn(this,I,V)}catch{}return R.call(this,I,D,V)};try{let I=Function.prototype.toString;E.prototype.addEventListener.toString=()=>I.call(k),E.prototype.removeEventListener.toString=()=>I.call(R)}catch{}}catch{}}function W(l){try{let E=l.Element;if(!E?.prototype?.attachShadow||E.prototype[S])return;E.prototype[S]=!0;let k=E.prototype.attachShadow;E.prototype.attachShadow=function(R){let I=k.call(this,R);try{Be.set(this,I)}catch{}try{J(I)}catch{}return I};try{let R=Function.prototype.toString;E.prototype.attachShadow.toString=()=>R.call(k)}catch{}}catch{}}function q(l){let k=n.get(l)?.listenerTypeMasks;if(k&&k.size){let R=[];for(let I of k.keys()){let D=nn[I];D&&R.push(D)}return R}return hr(l)}let U=["onclick","ondblclick","ondoubleclick","onmousedown","onmouseup","role","contenteditable","draggable","tabindex","disabled","type","aria-haspopup","aria-expanded","data-click","data-action","data-handler","data-toggle","data-target"],P=0,B=new Set,z=6,te=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],re=["mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","wheel","scroll","dragstart","drop","touchstart","touchend"];if(e[t]){typeof e.rtrvrAIMarkInteractiveElements=="function"&&e.rtrvrAIMarkInteractiveElements();return}e[t]=!0;let ie={onclick:"click",ondblclick:"dblclick",ondoubleclick:"doubleclick",onmousedown:"mousedown",onmouseup:"mouseup",onmouseenter:"mouseenter",onmouseleave:"mouseleave",onmousemove:"mousemove",onmouseover:"mouseover",onmouseout:"mouseout",oncontextmenu:"contextmenu",onauxclick:"auxclick",onkeydown:"keydown",onkeyup:"keyup",onkeypress:"keypress",oninput:"input",onchange:"change",onsubmit:"submit",onreset:"reset",onselect:"select",onsearch:"search",oninvalid:"invalid",onbeforeinput:"beforeinput",onfocus:"focus",onblur:"blur",onfocusin:"focusin",onfocusout:"focusout",ontouchstart:"touchstart",ontouchend:"touchend",ontouchmove:"touchmove",ontouchcancel:"touchcancel",onpointerdown:"pointerdown",onpointerup:"pointerup",onpointermove:"pointermove",onpointerenter:"pointerenter",onpointerleave:"pointerleave",onpointercancel:"pointercancel",onpointerover:"pointerover",ondragstart:"dragstart",ondragend:"dragend",ondrag:"drag",ondragenter:"dragenter",ondragleave:"dragleave",ondragover:"dragover",ondrop:"drop",oncopy:"copy",oncut:"cut",onpaste:"paste",onscroll:"scroll",onwheel:"wheel",onplay:"play",onpause:"pause",onended:"ended",onvolumechange:"volumechange",onseeking:"seeking",onseeked:"seeked",onanimationstart:"animationstart",onanimationend:"animationend",ontransitionend:"transitionend",ontransitionstart:"transitionstart",onresize:"resize",ontoggle:"toggle",onfullscreenchange:"fullscreenchange",onload:"load",onerror:"error",onabort:"abort",onbeforeunload:"beforeunload",onunload:"unload",onhashchange:"hashchange",onpopstate:"popstate",onstorage:"storage",onmessage:"message"};function j(l){return l?String(l).split(".")[0].toLowerCase():""}let le=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],ne=0,de=null,be=new MessageChannel,ht=[];be.port1.onmessage=()=>{let l=ht.shift();l&&l()};function Te(){return Date.now()}function Oe(l){return!l||!Number.isFinite(l)?Number.POSITIVE_INFINITY:Math.max(0,l-Te())}let He=8,Me=new MessageChannel,Ze=!1;function st(){if(!Ze){Ze=!0;try{Me.port2.postMessage(0)}catch{}}}function yt(l){let E=l.values().next();if(E.done)return null;let k=E.value;return l.delete(k),k}function It(){return new Promise(l=>{ht.push(l),be.port2.postMessage(0)})}let it=!1;function ke(){if(!it)try{let l=e.jQuery;l&&l.fn&&(Yt(l),it=!0,Ue("jquery"))}catch{}}function Le(l,E){for(let k=E.lastElementChild;k;k=k.previousElementSibling)l.push(k)}function Vt(l,E,k){if(k)try{let R=ue(E);R&&l.push(R)}catch{}}function mt(l,E,k){if(k&&pr(E))try{let R=E.contentWindow||null;R&&M(R);let I=R?.document?.documentElement;I&&l.push(I)}catch{}}let gt=new WeakSet;function $t(l){l&&(typeof l=="function"||typeof l=="object")&>.add(l)}function ln(l){return!!l&&(typeof l=="function"||typeof l=="object")&>.has(l)}Me.port1.onmessage=()=>{Ze=!1,dn(500);let l=performance.now();for(;B.size&&performance.now()-l<He;){let E=yt(B);if(!E)break;try{C(E)}catch{}finally{P=Math.max(0,P-1)}}for(;i.size&&performance.now()-l<He;){let E=yt(i);if(!E)break;try{tt(E)}catch{}}et(),(B.size||i.size)&&st()};function et(){try{let l=Xe()?.documentElement;if(!l)return;l.setAttribute(br,String(P))}catch{}}function St(l){let E=n.get(l);return E||(E={frameworks:new Set,listeners:new Map},n.set(l,E)),E}function Ne(l){i.add(l),st()}function un(l){B.has(l)||(B.add(l),P++,et(),st(),B.size>8e3&&dn(3e3))}function dn(l=2e3){let E=0;for(let k of B){if(E>l)break;k.isConnected||(B.delete(k),P=Math.max(0,P-1))}E=0;for(let k of i){if(E>l)break;k.isConnected||i.delete(k)}et()}let Pe=null;function yn(l,E,k){return`${l}|${E?1:0}|${k?1:0}`}function Gt(l){let E=l.tagName;if(E==="A"||E==="BUTTON"||E==="INPUT"||E==="SELECT"||E==="TEXTAREA"||E==="SUMMARY"||l.hasAttribute("role")||l.hasAttribute("tabindex")||l.hasAttribute("contenteditable")||l.hasAttribute("onclick")||l.getAttributeNames().some(k=>k.startsWith("on")))return!0;for(let k of le)if(l.hasAttribute(k))return!0;return!!(l.hasAttribute("aria-haspopup")||l.hasAttribute("aria-expanded"))}function Jt(l){let E=oe(l);if(!Ge(l,E))return!1;let k=l.tagName;if(k!=="DIV"&&k!=="SPAN"&&k!=="LI"&&k!=="SECTION"&&k!=="ARTICLE"&&k!=="P")return!1;let R=l;if(R.__ngContext__||R.__svelte__||R.__vue__||R._vnode||R.__reactFiber$||R.__reactProps$)return!0;let I=0;for(let D in R){if(++I>30)break;if(D.startsWith("__react")||D.includes("reactFiber")||D.includes("reactProps"))return!0}return!1}function fn(){let l=Xe()?.documentElement;return l?r.frameworks.size>0||l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte")||l.hasAttribute("rtrvr-jquery"):!1}function _n(l){let E=performance.now();for(;B.size&&performance.now()-E<l;){let k=yt(B);if(!k)break;try{C(k)}catch{}finally{P=Math.max(0,P-1)}}for(;i.size&&performance.now()-E<l;){let k=yt(i);if(!k)break;try{tt(k)}catch{}}}async function Tn(l={}){dn(3e3),ke(),Ee();let E=l.mode??"full",k=l.includeShadow??!0,R=l.includeSameOriginIframes??!0,I=Math.max(50,Math.min(l.budgetMs??2500,15e3)),D=l.deadlineEpochMs,V=Math.max(0,Math.min(I,Oe(D))),K=yn(E,k,R);if(V<=0){let je=(Pe?.stack?.length??0)+B.size+i.size;return{revision:++ne,scanned:0,durationMs:0,done:je===0,remaining:je}}if((!Pe||Pe.optsKey!==K)&&Oe(D)>30&&await Y({budgetMs:18,deadlineEpochMs:D}),E==="priority"){let je=performance.now(),De=0;for(;B.size&&performance.now()-je<=V&&!(D&&Oe(D)<=0);){let We=yt(B);if(!We)break;try{C(We)}catch{}De++,P=Math.max(0,P-1)}for(;i.size&&performance.now()-je<=V&&!(D&&Oe(D)<=0);){let We=yt(i);if(!We)break;try{tt(We)}catch{}}return et(),{revision:++ne,scanned:De,durationMs:performance.now()-je,done:B.size===0&&i.size===0,remaining:B.size+i.size}}if(!Pe||Pe.optsKey!==K){let je=Xe()?.documentElement;Pe={optsKey:K,stack:je?[je]:[],scannedTotal:0}}let ve=performance.now(),xe=0;for(P++,et();Pe.stack.length&&!(D&&Oe(D)<=0);){let je=Pe.stack.pop();if(vt(je)){let We=je.children;for(let kn=We.length-1;kn>=0;kn--)Pe.stack.push(We[kn]);continue}let De=je;if(!(!De||De.nodeType!==1)&&!(De.tagName==="SCRIPT"||De.tagName==="STYLE"||De.tagName==="META"||De.tagName==="NOSCRIPT")){try{(Gt(De)||fn()&&Jt(De))&&C(De)}catch{}try{tt(De)}catch{}if(B.delete(De)&&(P=Math.max(0,P-1)),i.delete(De),xe++,Pe.scannedTotal++,k)try{let We=ue(De);We&&(J(We),Pe.stack.push(We))}catch{}if(R&&pr(De))try{let We=De.contentWindow||null;We&&M(We);let kn=We?.document,fi=kn?.documentElement;kn&&fi&&(se(kn),Pe.stack.push(fi))}catch{}for(let We=De.lastElementChild;We;We=We.previousElementSibling)Pe.stack.push(We);xe%800===0&&Oe(D)>20&&await It()}}let Ae=Math.max(0,V-(performance.now()-ve)),dt=Oe(D);_n(Math.min(250,Ae,dt)),P=Math.max(0,P-1),et();let zt=Pe.stack.length===0,Xn=Pe.stack.length;return zt&&(Pe=null),{revision:++ne,scanned:xe,durationMs:performance.now()-ve,done:zt,remaining:Xn}}async function At(l={}){return de||(de=Tn(l).finally(()=>{de=null}),de)}e.rtrvrAIFlushScan=At;let Ot="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=Ot;let ut=e[Ot],Ut=ut&&typeof ut=="object"?ut:{};if(!ut)try{Object.defineProperty(e,Ot,{value:Ut,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(Ut,"flushScan",{value:At,writable:!1,configurable:!1,enumerable:!1})}catch{}function he(l,E){let k=St(l),R=j(E.type);if(!R)return;let I=!1,D=k.listeners.get(R);D||(D=[],k.listeners.set(R,D),I=!0);let V=D.find(ae=>ae.source===E.source&&!!ae.inferred==!!E.inferred);if(V){let ae=!!V.capture,ve=!!V.passive,xe=!!V.once;V.capture=V.capture||E.capture,V.passive=V.passive||E.passive,V.once=V.once||E.once,(ae!==!!V.capture||ve!==!!V.passive||xe!==!!V.once)&&(I=!0)}else D.push({...E,type:R}),I=!0;let K=_e[R];if(K!==void 0){k.listenerTypeMasks||(k.listenerTypeMasks=new Map);let ae=0,ve=ud[E.source];ae|=ve!==void 0?ve:Rt.Other,E.inferred&&(ae|=Rt.Inferred);let xe=k.listenerTypeMasks.get(K)||0,Ae=xe|ae;Ae!==xe&&(k.listenerTypeMasks.set(K,Ae),I=!0)}I&&(k.role=void 0,Ne(l))}function Zt(l){let E=l.listenerTypeMasks;return!E||E.size===0?null:[...E.entries()].sort((R,I)=>R[0]-I[0]).map(([R,I])=>`${R}~${(I||0).toString(36)}`).join(",")}function qt(l,E){let k=St(l);k.frameworks.has(E)||(k.frameworks.add(E),Ne(l))}function Ue(l){r.frameworks.has(l)||(r.frameworks.add(l),Xe()?.documentElement?.setAttribute(`rtrvr-${l}`,"1"))}function tt(l){let E=n.get(l);if(!E)return;i.delete(l);let k=Zt(E);k?k!==E.lastListenersSerialized&&(l.setAttribute(pn,k),E.lastListenersSerialized=k):E.lastListenersSerialized&&(l.removeAttribute(pn),E.lastListenersSerialized=void 0);let R=oe(l);if(Ge(l,R))if(E.role===void 0&&(E.role=xn(l)),E.role){let I=jn[E.role],D=typeof I=="number"?String(I):`s:${E.role}`;D!==E.lastRoleSerialized&&(l.setAttribute(on,D),E.lastRoleSerialized=D)}else(E.lastRoleSerialized||l.hasAttribute(on))&&(l.removeAttribute(on),E.lastRoleSerialized=void 0)}function Vr(l){let E=[],k=l;for(;k;)E.push(k),k=k.parentNode||k.host;return E}function vn(l){let E=l.tagName.toLowerCase(),k=l.getAttribute("role"),R=k?k.toLowerCase().trim():"";if(R&&rn.has(R)||E==="button"||(E==="a"||E==="area")&&l.hasAttribute("href"))return!0;if(E==="input")return l.type?.toLowerCase()!=="hidden";if(E==="select"||E==="textarea"||(E==="video"||E==="audio")&&l.hasAttribute("controls")||l.isContentEditable||l.hasAttribute("contenteditable"))return!0;let I=l.getAttribute("tabindex");return!!(I!==null&&!Number.isNaN(Number.parseInt(I,10))&&(q(l).some(K=>no.has(K))||l.getAttributeNames().some(K=>K.startsWith("on"))))}function Ve(l,E=10,k=600){let R=[];for(let D=0;D<l.children.length;D++)R.push({node:l.children[D],depth:1});let I=0;for(;R.length;){let{node:D,depth:V}=R.pop();if(++I>k||vn(D))return!0;if(!(V>=E))for(let K=0;K<D.children.length;K++)R.push({node:D.children[K],depth:V+1})}return!1}function xn(l){let E=l.tagName.toLowerCase(),k=l.getAttribute("role"),R=k?k.toLowerCase().trim():"",I=l.type?.toLowerCase();if(R&&rn.has(R))return R;if(R&&mr.has(R))return null;if(E==="a"&&l.hasAttribute("href"))return"link";if(E==="button")return"button";if(E==="input")return I==="hidden"?null:I==="checkbox"?"checkbox":I==="radio"?"radio":I==="range"?"slider":I==="number"?"spinbutton":I==="search"?"searchbox":["button","submit","reset","image","file"].includes(I)?"button":l.hasAttribute("list")?"combobox":"textbox";if(E==="textarea")return"textbox";if(E==="select"){let Ae=l;return Ae.multiple||Ae.size&&Ae.size>1?"listbox":"combobox"}if(E==="option")return"option";if(E==="form")return"form";if(E==="video"||E==="audio"){let Ae=hr(l);return l.hasAttribute("controls")||Ae.length>0?"media":null}if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";let D=q(l);if(!D.length)return null;let V=!1,K=!1,ae=!1;for(let Ae=0;Ae<D.length;Ae++){let dt=D[Ae];!V&&no.has(dt)&&(V=!0),!K&&hs.has(dt)&&(K=!0),!ae&&ms.has(dt)&&(ae=!0)}if(!V&&!K&&!ae)return null;let ve=l.getAttribute("tabindex"),xe=ve!==null&&!Number.isNaN(Number.parseInt(ve,10));if(V&&(xs(l)||l.getAttribute("href")||l.closest("a[href]")))return"link";if(K){if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";if(R==="textbox"||R==="searchbox"||R==="combobox"||R==="spinbutton")return R;if(!V&&xe)return"textbox"}if(V){let Ae=l.getAttribute("aria-checked"),dt=l.getAttribute("aria-pressed");if(Ae!==null||dt!==null){if(R==="radio")return"radio";if(R==="menuitemradio")return"menuitemradio";if(R==="menuitemcheckbox")return"menuitemcheckbox";if(dt!==null)return"button";if(Ae!==null)return"checkbox"}if((xe||R==="button")&&!Ve(l))return"button"}return ae?"application":null}let Gn=EventTarget.prototype.addEventListener,en=EventTarget.prototype.removeEventListener;function qn(l){let E=!1,k,R;return typeof l=="boolean"?E=l:l&&typeof l=="object"&&(E=!!l.capture,k=l.passive,R=l.once),{capture:E,passive:k,once:R}}function Yn(l){try{let E=l;if(E?.nodeType===9&&E?.documentElement)return E;let k=E?.document;if(k&&k.nodeType===9&&k.documentElement)return k}catch{}return null}function Ct(l,E,k){let R=j(E);if(!R)return;let{capture:I,passive:D,once:V}=qn(k),K=o.get(l);K||(K=new Map,o.set(l,K));let ae=K.get(R);if(ae?(ae.count+=1,ae.capture=ae.capture||I,ae.passive=ae.passive||D):K.set(R,{count:1,capture:I,passive:D}),An(l))try{he(l,{type:R,source:"native",capture:I,passive:D,once:V})}catch{}let ve=Yn(l);if(ve&&(R==="click"||R==="input"||R==="keydown"))try{ve.documentElement?.setAttribute(`rtrvr-gl-${R}`,"1")}catch{}}function tn(l,E,k){let R=j(E);if(!R)return;let I=o.get(l);if(!I)return;let D=I.get(R);D&&(D.count-=1,D.count<=0&&I.delete(R),I.size===0&&o.delete(l))}M(window);function Yt(l){if(!l||!l.fn)return;let E=l.fn.on,k=l.fn.off;function R(D){if(!D)return[];if(typeof D=="string")return D.split(/\s/).map(V=>j(V)).filter(Boolean);if(typeof D=="object")try{return Object.keys(D).map(V=>j(V)).filter(Boolean)}catch{return[]}return[]}function I(D){try{if(!D)return null;if(An(D))return D;let V=oe(D);return Jr(D,V)||null}catch{}return null}l.fn.on=function(D,V){let K=R(D),ae=typeof V=="string"&&!!V;return this.each(function(){let ve=I(this);if(ve){if(ae){let xe=s.get(ve);xe||(xe=[],s.set(ve,xe));for(let Ae of K){let dt=`${Ae}::${V}`;xe.some(zt=>`${zt.type}::${zt.selector}`===dt)||(xe.push({type:Ae,selector:V}),xe.length>400&&xe.shift())}}else for(let xe of K)he(ve,{type:xe,source:"jquery"});qt(ve,"jquery"),Ue("jquery"),r.jqueryRoots.add(ve)}}),E.apply(this,arguments)},l.fn.off=function(){return k.apply(this,arguments)},Ue("jquery")}function fr(l){le.some(k=>l.hasAttribute(k))&&(he(l,{type:"click",source:"other",inferred:!0}),(l.tagName==="INPUT"||l.tagName==="TEXTAREA")&&(he(l,{type:"input",source:"other",inferred:!0}),he(l,{type:"change",source:"other",inferred:!0})))}function Xt(l){let E=oe(l),k=Ge(l,E),R=l.getAttributeNames().some(ae=>ae.startsWith("on")),I=/^(button|a|input|select|textarea|summary)$/i.test(l.tagName),D=l,V=k&&(io(l)||!!D.isContentEditable||l.hasAttribute("contenteditable")),K=k&&!!D.draggable;if(!R&&!I&&!V&&!K){fr(l);return}for(let[ae,ve]of Object.entries(ie))typeof l[ae]=="function"&&he(l,{type:ve,source:"inline"});V&&(he(l,{type:"input",source:"other",inferred:!0}),he(l,{type:"keydown",source:"other",inferred:!0}),he(l,{type:"keyup",source:"other",inferred:!0}),he(l,{type:"paste",source:"other",inferred:!0})),K&&(he(l,{type:"dragstart",source:"other",inferred:!0}),he(l,{type:"dragend",source:"other",inferred:!0})),fr(l)}function Rn(l){if(!l.startsWith("on")||l.length<=2)return null;if(l.endsWith("Capture")){let k=l.substring(2,l.length-7);return k?{type:k.toLowerCase(),capture:!0}:null}let E=l.substring(2);return E?{type:E.toLowerCase(),capture:!1}:null}function Mt(l){let E=null;if(l){for(let k in l)if(k.startsWith("__react")||k.startsWith("_react")||k.includes("reactFiber")||k.includes("reactProps")||k.includes("reactInternalInstance")){E=k;break}if(E)try{let k=l[E],R=k?.memoizedProps||k?.pendingProps;if(R&&typeof R=="object"){for(let I in R){if(typeof R[I]!="function")continue;let V=Rn(I);V&&he(l,{type:V.type,source:"react",capture:V.capture})}An(k?.stateNode)&&r.reactRoots.add(k.stateNode),qt(l,"react"),Ue("react")}}catch{}}}function c(l){let E=l,k=!1;if(E.__vue__){k=!0;let R=E.__vue__;R.$listeners&&Object.keys(R.$listeners).forEach(I=>he(l,{type:I,source:"vue"})),R._events&&Object.keys(R._events).forEach(I=>he(l,{type:I,source:"vue"})),R.$options?._parentListeners&&Object.keys(R.$options._parentListeners).forEach(I=>he(l,{type:I,source:"vue"})),r.vueRoots.add(l)}if(E._vnode?.props){k=!0;let R=E._vnode.props;Object.keys(R).forEach(I=>{I.startsWith("on")&&I.length>2&&he(l,{type:I.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(l)}k&&(qt(l,"vue"),Ue("vue"))}function y(l){let E=l,k=!1;if(E.__ngContext__||l.hasAttribute("_ngcontent")||l.hasAttribute("ng-version")){k=!0,Array.from(l.attributes).forEach(R=>{if(R.name.startsWith("(")&&R.name.endsWith(")")){let I=R.name.slice(1,-1).split(".")[0];I&&he(l,{type:I,source:"angular"})}if(R.name.startsWith("on-")){let I=R.name.substring(3);I&&he(l,{type:I,source:"angular"})}if(R.name.includes(".")){let I=R.name.match(/\(([^.)]+)/);I?.[1]&&he(l,{type:I[1],source:"angular"})}});try{if(e.ng?.getComponent){let R=e.ng.getComponent(l);R&&Object.keys(R).forEach(I=>{(I.endsWith("Output")||I.endsWith("Emitter"))&&he(l,{type:I.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}k&&(qt(l,"angular"),Ue("angular"),r.angularRoots.add(l))}function b(l){let E=l,k=!1;if(E.__svelte__){k=!0,Array.from(l.attributes).forEach(R=>{if(R.name.startsWith("on:")){let I=R.name.substring(3);I&&he(l,{type:I,source:"svelte"})}});try{let R=E.__svelte__?.$$?.callbacks;R&&typeof R=="object"&&Object.keys(R).forEach(I=>he(l,{type:I,source:"svelte"}))}catch{}r.svelteRoots.add(l)}k&&(qt(l,"svelte"),Ue("svelte"))}function g(l,E){return l?!!o.get(l)?.has(E):!1}function f(l,E,k=96){let R=j(E);if(!R)return!1;let I=G(l),D=X(I);if(g(I,R)||g(D,R))return!0;let V=0,K=l;for(;K&&V<k;){if(K.parentElement)K=K.parentElement;else{let ae=K.getRootNode?.();if(vt(ae)){if(g(ae,R)||g(ae.host,R))return!0;K=ae.host}else break}if(K&&g(K,R))return!0}return!1}function d(l,E,k=128){let R=0,I=l;for(;I&&R<k;){if(E(I),I.parentElement){I=I.parentElement;continue}let D=I.getRootNode?.();if(vt(D)){I=D.host;continue}break}}function h(l){let E=oe(l);if(!Ge(l,E))return;let k=St(l);k.role=k.role||xn(l);let R=f(l,"click"),I=f(l,"input"),D=f(l,"keydown"),K=G(l).documentElement;if(r.frameworks.size>0||K.hasAttribute("rtrvr-react")||K.hasAttribute("rtrvr-vue")||K.hasAttribute("rtrvr-angular")||K.hasAttribute("rtrvr-svelte")||K.hasAttribute("rtrvr-jquery")||R||I||D){let ve=k.role||"other";R&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(ve)&&he(l,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(ve)&&(I&&(he(l,{type:"input",source:"delegated",inferred:!0}),he(l,{type:"change",source:"delegated",inferred:!0})),D&&he(l,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(ve)&&(R&&he(l,{type:"click",source:"delegated",inferred:!0}),I&&he(l,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(ve)&&I&&he(l,{type:"input",source:"delegated",inferred:!0})}d(l,ve=>{let xe=s.get(ve);if(xe?.length)for(let{type:Ae,selector:dt}of xe)try{l.matches(dt)&&(he(l,{type:Ae,source:"jquery",inferred:!0}),qt(l,"jquery"),Ue("jquery"))}catch{}})}function x(l){let E=k=>{let R=k,I=R.composedPath&&R.composedPath()||Vr(k.target),V=l==="mousemove"||l==="pointermove"||l==="scroll"||l==="wheel"?1:Math.min(I.length,z);for(let K=0;K<V;K++){let ae=I[K];An(ae)&&he(ae,{type:l,source:"delegated",inferred:!0})}};$t(E);try{Gn.call(document,l,E,{capture:!0,passive:!0})}catch{}}let m=!1;function T(){te.forEach(x);let l=Xe()?.documentElement;if(!l)return;let E=()=>{if(m)return;let k=l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte"),R=l.hasAttribute("rtrvr-gl-click")||l.hasAttribute("rtrvr-gl-input")||l.hasAttribute("rtrvr-gl-keydown");(k||R)&&(m=!0,re.forEach(x))};E();try{new MutationObserver(()=>E()).observe(l,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function C(l){if(l.nodeType!==1)return;let E=oe(l);if(Ge(l,E)){let k=St(l);k.role=void 0}Xt(l),Mt(l),c(l),y(l),b(l),h(l),Ne(l)}function N(){let l=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(rn).map(E=>`[role="${E}"]`),"[onclick]","[ondblclick]","[ondoubleclick]","[onmousedown]","[tabindex]","[contenteditable]",'[draggable="true"]',"[aria-haspopup]","[aria-expanded]","[data-click]","[data-action]","[data-handler]","[data-toggle]","[data-target]",".clickable",".interactive",".btn",".button"];P++,et();try{let E=l.join(",");Xe()?.querySelectorAll(E).forEach(k=>{try{C(k)}catch{}})}finally{P=Math.max(0,P-1),et()}}function F(l){for(let E of l){for(let k of Array.from(E.addedNodes)){if(k.nodeType!==1)continue;let R=k;un(R),R.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(un)}if(E.type==="attributes"&&E.target.nodeType===1){let k=E.target;E.attributeName==="class"?(fn()||Gt(k))&&un(k):un(k)}}}async function Y(l={}){let E=Xe(),k=E?.documentElement;if(!k||!(k.hasAttribute("rtrvr-react")||k.hasAttribute("rtrvr-vue")||k.hasAttribute("rtrvr-angular")||k.hasAttribute("rtrvr-svelte")))return;let I=l.deadlineEpochMs,D=Math.max(5,Math.min(l.budgetMs??12,50));if(Math.max(0,Math.min(D,Oe(I)))<=0)return;let K=performance.now();P++,et();try{let ae=0,ve=4e3,xe=["div","span","li","section","article","p"];for(let Ae of xe){let dt=E.getElementsByTagName(Ae)??[];for(let zt=0;zt<dt.length;zt++){if(ae++>=ve||I&&Oe(I)<=0)return;let Xn=dt[zt],je=Xn;(je.__ngContext__||je.__svelte__||je.__vue__||je._vnode||Jt(Xn))&&C(Xn),ae%250===0&&Oe(I)>20&&await It()}}}finally{P=Math.max(0,P-1),et()}}let Q=new MutationObserver(F),pe=new WeakMap;function J(l){if(!pe.has(l)&&!(v>=a))try{let E=X(l.ownerDocument).MutationObserver||MutationObserver,k=new E(F);pe.set(l,k),v++,k.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}catch{}}let ee=new WeakMap;function se(l){if(!ee.has(l)&&!(p>=u))try{M(l.defaultView||null);let E=l.documentElement;if(!E)return;let k=X(l).MutationObserver||MutationObserver,R=new k(F);ee.set(l,R),p++,R.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}catch{}}function we(){let l=Xe()?.documentElement;l&&Q.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...U,"class"]})}let Be=new WeakMap;function ue(l){return l.shadowRoot||Be.get(l)||null}try{Object.defineProperty(Ut,"shadow",{value:Object.freeze({getRoot:l=>ue(l)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function Ee(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&Ue("react"),e.Vue&&Ue("vue"),e.ng&&Ue("angular"),e.jQuery&&Ue("jquery"),ke()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return Xe()?.body?(N(),!0):!1};function ye(){let l=Xe();ke(),Ee(),T();let E=()=>{ke(),Ee(),we(),e.rtrvrAIMarkInteractiveElements?.(),Y({budgetMs:20}),l?.documentElement.setAttribute(ds,"1")};l?.readyState==="loading"?l.addEventListener("DOMContentLoaded",E,{once:!0}):E()}ye()})();var So=null;function Ws(e){try{return e.getAttribute(pn)}catch{return null}}function Ja(e){let t=Ws(e);return Cn(t)?.entries??[]}function Za(e){try{let t=e.getAttribute(on);return t&&t.trim()?t:null}catch{return null}}function dd(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function fd(e){let t=new Set;for(let n of e){let r=qr(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function pd(e){let t=new Set,n=e;return(n.__reactFiber||n.__reactProps||n.__reactInternalInstance||n.__reactRootContainer)&&t.add("react"),(n.__vue__||n.__vueParentComponent||n.__vnode||n.__vue_app__)&&t.add("vue"),n.__ngContext__&&t.add("angular"),(n.__svelte||n.__svelte_meta)&&t.add("svelte"),(n.__jquery||n.jQuery)&&t.add("jquery"),t}function hd(e){let t=Ja(e),n=fd(t),r=pd(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Ws(e)||"",role:Za(e)??(e.getAttribute?.("role")||null)}}function md(){return{getEventHandlerIds:e=>Ja(e).map(t=>t.id),getRoleHint:Za,getShadowRoot:dd}}function ec(e={}){if(So)return So;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return So={signalProvider:md(),getFrameworkMetadata:hd,getListenerEncoding:Ws,dispose:()=>{}},So}var No=class{constructor(t={}){$(this,"root");$(this,"includeFrames");$(this,"disableDomAnnotations");$(this,"allowActions");$(this,"runtimeId");$(this,"domainScopeMode");$(this,"allowedDomains");$(this,"externalNavigationPolicy");$(this,"registerOpenedTab");$(this,"listKnownTabs");$(this,"switchToLogicalTab");$(this,"onNavigationGuardrail");$(this,"instrumentation");$(this,"highlightEl",null);$(this,"clientTools",new Map);$(this,"uploadStore",new Map);$(this,"uploadProviderInstalled",!1);this.root=t.root??document.body??document.documentElement,this.includeFrames=t.includeFrames??!0,this.disableDomAnnotations=t.disableDomAnnotations??!0,this.allowActions=t.allowActions??!0,this.runtimeId=t.runtimeId,this.domainScopeMode=tc(t.domainScopeMode),this.allowedDomains=Vs(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=nc(t.externalNavigationPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.instrumentation=t.instrumentation??ec({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),Va(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=tc(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=Vs(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=Vs(t.allowedDomains,window.location.hostname,this.domainScopeMode)),t.externalNavigationPolicy&&(this.externalNavigationPolicy=nc(t.externalNavigationPolicy))}async getSnapshot(){return await sc(this.root),To(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await sc(this.root),await Ka(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=gd(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r)){let A=`Current tab is outside the allowed domain scope (${Mo(this.allowedDomains)}).`;return this.domainScopeBlockedResponse(window.location.href,A,{fromCurrentContext:!0})}if(!this.allowActions&&!oc.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===L.wait_action){let A=Number(t?.args?.duration??1e3);return await new Promise(S=>setTimeout(S,Math.max(0,Math.min(A,6e4)))),{success:!0}}if(r===L.wait_for_element)return this.waitForElement(t?.args||{});if(r===L.answer_task)return{success:!0};if(r===L.solve_captcha)return Lo("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===L.network_run_recipe)return Lo("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");if(r===L.click_element&&t?.args?.open_in_new_tab)return this.openElementInNewTab(t?.args||{});if(r===L.click_element&&this.shouldInterceptExternalClick(t?.args||{})){let A=this.getExternalClickTargetUrl(t?.args||{});if(A){let S=`Blocked same-tab navigation to out-of-scope domain (${new URL(A).hostname}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(A,{policyBlocked:!0,reason:S}):this.domainScopeBlockedResponse(A,S)}}if(r===L.describe_images)return this.describeImages(t?.args||{});if(!(r in Gr))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let s=t?.args||{},{doc:i}=rr(document,s.iframe_id),a=s.element_id??s.source_element_id??s.target_element_id??s.center_element_id??null,u=a?Bt(i,a):null,v;if(u){let A=this.instrumentation.getFrameworkMetadata(u),S=_d(A.listenersRaw||"",r),M=s?.value??s?.text??null;v=yd({...A,pattern:S,value:M})}let p=Gr[r];return r===L.upload_file&&!n&&(n=await this.buildUploadPayload(s).catch(()=>{})),$a({opcode:p,call:{name:r,args:s},elementData:v,tabIndex:0,payload:n})}highlight(t){let n=Bt(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.height)}px`,this.highlightEl.style.display="block"}clearHighlight(){this.highlightEl&&(this.highlightEl.style.display="none")}setUploadBytesProvider(t){window.__ROVER_UPLOAD_BYTES__=t}registerTool(t,n){let r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case L.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=Ao(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldGuardExternalNavigation(o)){let s=`Navigation blocked by domain policy. Allowed: ${Mo(this.allowedDomains)}`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldGuardExternalNavigation(o)){let s=`Google search opens outside the allowed domain scope (${Mo(this.allowedDomains)}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.go_back:return window.history.back(),{success:!0};case L.go_forward:return window.history.forward(),{success:!0};case L.refresh_page:return window.location.reload(),{success:!0};case L.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=Ao(r,window.location.href);return o?await this.openUrlInNewTab(o,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0}}case L.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(s=>Number(s.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked outside ${Mo(this.allowedDomains)}.`)}if(!this.switchToLogicalTab)return Lo("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case L.close_tab:try{return window.close(),{success:!0}}catch{return Lo("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!Co(t,this.allowedDomains)}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||oc.has(t)||wd.has(t)?!1:!Co(window.location.href,this.allowedDomains)}shouldInterceptExternalClick(t){if(this.externalNavigationPolicy==="allow")return!1;let n=this.getExternalClickTargetUrl(t);return n?!Co(n,this.allowedDomains):!1}getExternalClickTargetUrl(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return null;let{doc:r}=rr(document,t.iframe_id),o=Bt(r,n);if(!o)return null;let s=rc(o),i=s?.href||s?.getAttribute("href")||"";return Ao(i,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,reason:n,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:n,allowFallback:!0,output:{success:!1,error:{code:"DOMAIN_SCOPE_BLOCKED",message:n,missing:[],next_action:o==="block"?"Stay on the configured domain or update allowedDomains/domainScopeMode.":"Use open_new_tab to access external pages without losing context.",retryable:!1},blocked_url:t,current_url:window.location.href,allowed_domains:this.allowedDomains,policy_action:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,allowedDomains:this.allowedDomains,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!Co(t,this.allowedDomains),o=this.snapshotKnownTabIds(),s=this.openVerifiedPopup(t),i;if(s.opened&&this.registerOpenedTab)try{i=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}if(s.opened&&!i&&(i=await this.reconcileOpenedTab(t,o)),!s.opened){let p=await this.reconcileOpenedTab(t,o);p&&(s={opened:!0,verified:!1},i=i||p)}let a=s.opened&&!i&&!!this.registerOpenedTab;if(!s.opened){let p="Browser popup settings blocked opening a new tab.";return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:n.reason||p,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:i},errorDetails:{code:"POPUP_BLOCKED",message:p,retryable:!0,next_action:"Allow popups for this site and try again."}}}let u=n?.policyBlocked?n.reason||"Opened in a new tab due to domain policy.":void 0;n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:u||"Opened in new tab due to domain policy.",allowedDomains:this.allowedDomains,openedInNewTab:!0});let v=[];return a&&v.push("Tab opened but registration failed; tab may not be targetable."),s.verified||v.push("Tab open was triggered, but browser did not return a popup handle."),{success:!0,output:{url:t,external:r,logicalTabId:i,openedInNewTab:!0,openVerification:s.verified?"verified":"unverified",policyBlocked:!!n?.policyBlocked,message:u,...v.length?{warning:v.join(" ")}:{}},allowFallback:!0}}openVerifiedPopup(t){let n=window.open("about:blank","_blank");if(n){try{n.opener=null}catch{}try{n.location.href=t}catch{}return{opened:!0,verified:!0}}try{let r=window.open(t,"_blank");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}}catch{}try{let r=window.open(t,"_blank","noopener,noreferrer");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}return{opened:!0,verified:!1}}catch{}try{let r=document.createElement("a");return r.href=t,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),{opened:!0,verified:!1}}catch{return{opened:!1,verified:!1}}}snapshotKnownTabIds(){let t=new Set;if(!this.listKnownTabs)return t;try{let n=this.listKnownTabs();for(let r of n){let o=Number(r?.logicalTabId);!Number.isFinite(o)||o<=0||t.add(o)}}catch{return t}return t}async reconcileOpenedTab(t,n){if(!this.listKnownTabs)return;let r=$s(t),o=Date.now()+2e3;for(;Date.now()<o;){try{let s=this.listKnownTabs();for(let i of s){let a=Number(i?.logicalTabId);if(!Number.isFinite(a)||a<=0||n.has(a))continue;let u=String(i?.url||"").trim();if(!u)return a;let v=$s(u);if(!r||!v||v===r)return a}}catch{}await new Promise(s=>setTimeout(s,120))}}async openElementInNewTab(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return{success:!1,error:"click_element with open_in_new_tab requires element_id.",allowFallback:!0};let{doc:r}=rr(document,t.iframe_id),o=Bt(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let s=rc(o),i=s?.href||s?.getAttribute("href")||"",a=Ao(i,window.location.href);return a?await this.openUrlInNewTab(a,{policyBlocked:!1}):{success:!1,error:"click_element open_in_new_tab only works when target resolves to a valid link URL.",allowFallback:!0}}async waitForElement(t){let n=String(t.selector||"").trim(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),s=document;for(;Date.now()-o<r;){let i=null;try{i=s.querySelector(n)}catch{i=null}if(i||(i=Td(s,n)),i)return{success:!0};await new Promise(a=>setTimeout(a,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=pi(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let s of n){let i=Bt(document,s);if(!i){o.push(`element_id ${s} not found`);continue}try{let a=await vd(i);if(!a?.data||!a?.mimeType){o.push(`element_id ${s}: unsupported image`);continue}r.push({element_id:s,...a})}catch(a){o.push(`element_id ${s}: ${a?.message||String(a)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await Pa(0,n,document?.referrer||null),o=r.bytes,s=o.byteLength,i=r.mimeType||t.mime_type||"application/octet-stream",a=t.file_name||r.fileName,u=1024*1024;if(s<=u)return{kind:"upload_file",inlineB64:ac(o),byteLength:s,mimeType:i,fileName:a};this.ensureUploadProvider();let v=crypto.randomUUID();return this.uploadStore.set(v,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:v,byteLength:s,mimeType:i,fileName:a,durable:!1}}catch{return}}};function gd(e){return e==="open_url_new_tab"?L.open_new_tab:String(e||"").trim()}function tc(e){return e==="host_only"?"host_only":"registrable_domain"}function nc(e){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:"open_new_tab_notice"}function Vs(e,t,n){let r=Array.isArray(e)?e:[],o=new Set;for(let s of r){let i=String(s||"").trim().toLowerCase().replace(/^\./,"");i&&o.add(i)}if(!o.size){let s=bd(t,n);s&&o.add(s)}return Array.from(o)}function bd(e,t){let n=String(e||"").trim().toLowerCase();if(!n)return"";if(n==="localhost"||/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(n))return`=${n}`;if(t==="host_only")return`=${n}`;let r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function Ao(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function Co(e,t){let n=$s(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(Ed(n,r))return!0;return!1}function $s(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Ed(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function Mo(e){return e.length?e.map(t=>{let n=String(t||"");return n.startsWith("=")?n.slice(1):n}).join(", "):"*"}function rc(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function Lo(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var oc=new Set([L.describe_images,L.wait_action,L.wait_for_element,L.answer_task,L.solve_captcha,L.network_run_recipe]),wd=new Set([L.goto_url,L.google_search,L.go_back,L.go_forward,L.refresh_page,L.open_new_tab,L.switch_tab,L.close_tab]);function yd(e){return{frameworks:(e.frameworks||[]).filter(n=>n in as).map(n=>as[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function sc(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s=="function"){await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function _d(e,t){if(t!==L.click_element)return"standard";let n=Cn(e||"");if(!n)return"standard";let r=new Set(n.entries.map(u=>nn[u.id]).filter(u=>typeof u=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let i=r.has("touchstart"),a=r.has("touchend");return i&&a?"touch-sequence":"standard"}function ac(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function Td(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let s of Array.from(o))if((s.textContent||"").trim().toLowerCase().includes(n)||(s.getAttribute("aria-label")||"").toLowerCase().includes(n))return s;return null}async function vd(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),s=cc(o);if(!s)throw new Error("canvas toDataURL failed");return s}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await ic(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await ic(r[2],e.getAttribute("aria-label")||void 0);throw new Error("unsupported element")}function cc(e){let t=/^data:([^;]+);base64,(.*)$/.exec(e);return t?{mimeType:t[1],data:t[2]}:null}async function ic(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let a=cc(e);if(!a)throw new Error("invalid data url");return{...a,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),s=ac(o),i=r.type||"image/png";return{data:s,mimeType:i,displayName:t}}function lc(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:s,params:i}=r;try{let a=t[s];if(!a)throw new Error(`No handler for ${s}`);let u=await a(i);e.postMessage({t:"res",id:o,ok:!0,result:u})}catch(a){e.postMessage({t:"res",id:o,ok:!1,error:{message:a?.message||String(a)}})}}}var xd="Rover",Rd="https://www.rtrvr.ai/rover/mascot.mp4",kd="https://www.rtrvr.ai/rover/mascot.webm";function fc(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function uc(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Id(e){return e.status?e.status:e.kind==="tool_start"||e.kind==="plan"||e.kind==="thought"?"pending":e.kind==="tool_result"?"success":e.kind==="error"?"error":"info"}function Sd(e){let t=String(e.title||"").trim().toLowerCase();return t.startsWith("running ")?`tool:${t.replace(/^running\s+/,"").trim()}`:t.endsWith(" completed")?`tool:${t.replace(/\s+completed$/,"").trim()}`:t==="run started"||t==="run resumed"||t==="run completed"?"run":e.kind==="status"?`status:${t||"status"}`:e.id||fc("trace")}function ar(e){return String(e||"").trim()}function Ad(e){let t=String(e||"").trim();return t?t.slice(0,64):xd}function Cd(e){let t=String(e||"").trim();return t?t[0].toUpperCase():"R"}function Md(e){return String(e||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,3).toUpperCase()||"RVR"}function pc(e){let t=ar(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=ar(n[2]||t);return{stage:r,plainTitle:o||t}}function Ld(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed")return"detail";if(e.kind==="status"){let n=pc(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function Gs(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let s=document.createElement("a");s.className="rvLink",s.href=o[2],s.target="_blank",s.rel="noopener noreferrer",s.textContent=o[1],e.appendChild(s)}else if(o[3]){let s=document.createElement("strong");s.textContent=o[3],e.appendChild(s)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Cr(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
+
`),r=null;for(let o of n){let s=o.trim();if(!s){r&&(t.appendChild(r),r=null);continue}if(s==="---"){r&&(t.appendChild(r),r=null);let u=document.createElement("hr");u.className="rvSep",t.appendChild(u);continue}if(s.startsWith("- ")){r||(r=document.createElement("ul"),r.className="rvList");let u=document.createElement("li");Gs(u,s.slice(2)),r.appendChild(u);continue}if(r&&(t.appendChild(r),r=null),/^Step \d+/i.test(s)){let u=document.createElement("div");u.className="rvStepHeader",u.textContent=s,t.appendChild(u);continue}if(s.startsWith("[error] ")){let u=document.createElement("div");u.className="rvError",u.textContent=s.slice(8),t.appendChild(u);continue}if(s.startsWith("[next] ")){let u=document.createElement("div");u.className="rvNext",u.textContent=s.slice(7),t.appendChild(u);continue}let i=s.match(/^\*\*(.+?):\*\*\s*(.*)$/);if(i){let u=document.createElement("div");u.className="rvKv";let v=document.createElement("span");v.className="rvKvLabel",v.textContent=i[1];let p=document.createElement("span");p.className="rvKvValue",Gs(p,i[2]),u.appendChild(v),u.appendChild(p),t.appendChild(u);continue}let a=document.createElement("div");a.className="rvLine",Gs(a,s),t.appendChild(a)}return r&&t.appendChild(r),t}function dc(e,t){let n=document.createElement("div");if(n.className="expandableWrap",e.length<=t)return n.appendChild(Cr(e)),n;let r=e.split(`
|
|
12
|
+
`),o=0,s=0;for(let v=0;v<r.length;v++)if(o+=r[v].length+1,o>=t){s=v+1;break}s===0&&(s=1);let i=r.slice(0,s).join(`
|
|
13
|
+
`),a=r.slice(s).join(`
|
|
14
|
+
`),u=document.createElement("div");if(u.className="expandPreview",u.appendChild(Cr(i)),n.appendChild(u),a.trim()){let v=document.createElement("div");v.className="expandRest",v.appendChild(Cr(a)),v.style.display="none",n.appendChild(v);let p=document.createElement("button");p.type="button",p.className="expandToggle",p.textContent="...Show more",p.addEventListener("click",_=>{_.stopPropagation();let A=v.style.display==="none";v.style.display=A?"block":"none",p.textContent=A?" Show less":"...Show more"}),n.appendChild(p)}return n}function hc(e){let t=Ad(e.agent?.name),n=Cd(t),r=Md(t),o=document.createElement("div");o.id="rover-widget-root",document.documentElement.appendChild(o);let s=o.attachShadow({mode:"closed"}),i=document.createElement("style");i.textContent=`
|
|
15
15
|
@font-face {
|
|
16
16
|
font-family: 'Manrope';
|
|
17
17
|
font-style: normal;
|
|
@@ -19,7 +19,7 @@ Author: ${i.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
|
19
19
|
font-display: swap;
|
|
20
20
|
src: url('https://rover.rtrvr.ai/rover/fonts/manrope-latin.woff2') format('woff2');
|
|
21
21
|
}
|
|
22
|
-
`,document.head.appendChild(
|
|
22
|
+
`,document.head.appendChild(i);let a=document.createElement("style");a.textContent=`
|
|
23
23
|
/* \u2500\u2500 Step 2: Self-hosted font \u2500\u2500 */
|
|
24
24
|
@font-face {
|
|
25
25
|
font-family: 'Manrope';
|
|
@@ -1043,10 +1043,10 @@ Author: ${i.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
|
1043
1043
|
gap: 8px;
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
|
-
`;let u=document.createElement("div");u.className="rover",u.dataset.mood="idle";let
|
|
1046
|
+
`;let u=document.createElement("div");u.className="rover",u.dataset.mood="idle";let v=document.createElement("button");v.className="launcher",v.setAttribute("aria-label",`Open ${t} assistant`);let p=e.mascot?.disabled===!0,_=null;if(!p){_=document.createElement("video"),_.autoplay=!0,_.muted=!0,_.loop=!0,_.playsInline=!0,_.preload="metadata";let m=document.createElement("source");m.src=e.mascot?.mp4Url||Rd,m.type="video/mp4";let T=document.createElement("source");T.src=e.mascot?.webmUrl||kd,T.type="video/webm",_.appendChild(m),_.appendChild(T),v.appendChild(_)}let A=document.createElement("span");A.className="launcherFallback",A.textContent=r;let S=document.createElement("div");S.className="launcherShine",v.appendChild(A),v.appendChild(S);let M=document.createElement("div");M.className="panel";let O=document.createElement("div");O.className="header";let W=document.createElement("div");W.className="avatar";let q=null;!p&&_&&(q=_.cloneNode(!0),W.appendChild(q));let U=document.createElement("span");U.className="avatarFallback",U.textContent=n,W.appendChild(U);let P=document.createElement("div");P.className="meta";let B=document.createElement("div");B.className="title",B.textContent=t;let z=document.createElement("div");z.className="status";let te=document.createElement("span");te.className="statusDot";let re=document.createElement("span");re.textContent="ready",z.appendChild(te),z.appendChild(re),P.appendChild(B),P.appendChild(z);let ie=document.createElement("div");ie.className="headerActions";let j=document.createElement("span");j.className="modeBadge controller",j.textContent="active";let le=document.createElement("button");le.type="button",le.className="overflowBtn",le.setAttribute("aria-label","More options"),le.innerHTML="⋯";let ne=document.createElement("button");ne.type="button",ne.className="closeBtn",ne.setAttribute("aria-label","Close Rover panel"),ne.textContent="\xD7";let de=document.createElement("button");de.type="button",de.className="muteBtn",de.setAttribute("aria-label","Toggle sound");let be=e.muted??!1;try{let m=localStorage.getItem("rover:muted");m!==null&&(be=m!=="false")}catch{}let ht='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/></svg>',Te='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>';function Oe(){de.innerHTML=be?ht:Te,de.setAttribute("aria-label",be?"Unmute":"Mute"),_&&(_.muted=be),q&&(q.muted=be)}Oe(),de.addEventListener("click",m=>{m.stopPropagation(),be=!be;try{localStorage.setItem("rover:muted",String(be))}catch{}Oe()});let He=document.createElement("button");He.type="button",He.className="stopBtn",He.setAttribute("aria-label","Cancel task"),He.textContent="\u25A0",ie.appendChild(He),ie.appendChild(j),ie.appendChild(de),ie.appendChild(le),ie.appendChild(ne);let Me=document.createElement("div");Me.className="overflowMenu";let Ze=document.createElement("button");Ze.type="button",Ze.className="menuItem",Ze.textContent="New task";let st=document.createElement("button");st.type="button",st.className="menuItem danger",st.textContent="End task";let yt=document.createElement("div");yt.className="menuDivider";let It=document.createElement("button");It.type="button",It.className="menuItem",It.textContent="Show details";let it=document.createElement("button");it.type="button",it.className="menuItem",it.textContent="Take control",it.style.display="none",Me.appendChild(Ze),Me.appendChild(st),Me.appendChild(yt),Me.appendChild(It),Me.appendChild(it),e.showTaskControls===!1&&(Ze.style.display="none",st.style.display="none"),O.appendChild(W),O.appendChild(P),O.appendChild(ie),O.appendChild(Me);let ke=document.createElement("div");ke.style.cssText="position:relative;flex:1;min-height:0;display:flex;flex-direction:column;";let Le=document.createElement("div");Le.className="feed";let Vt=document.createElement("div");Vt.className="typingIndicator";for(let m=0;m<3;m++){let T=document.createElement("span");T.className="typingDot",Vt.appendChild(T)}Le.appendChild(Vt);let mt=document.createElement("button");mt.type="button",mt.className="scrollBtn",mt.setAttribute("aria-label","Scroll to bottom"),mt.innerHTML='<svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"></polyline></svg>',ke.appendChild(Le),ke.appendChild(mt);let gt=document.createElement("div");gt.className="taskSuggestion",gt.innerHTML=`
|
|
1047
1047
|
<div class="taskSuggestionText"></div>
|
|
1048
1048
|
<div class="taskSuggestionActions">
|
|
1049
1049
|
<button type="button" class="taskSuggestionBtn primary">Start new</button>
|
|
1050
1050
|
<button type="button" class="taskSuggestionBtn secondary">Continue</button>
|
|
1051
1051
|
</div>
|
|
1052
|
-
`;let Vt=document.createElement("form");Vt.className="composer";let cn=document.createElement("textarea");cn.rows=1,cn.placeholder=`Ask ${t} to act on this website...`,Vt.appendChild(cn);let Ze=document.createElement("button");Ze.type="submit",Ze.className="sendBtn",Ze.innerHTML='<svg viewBox="0 0 24 24"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',Vt.appendChild(Ze);let It=document.createElement("div");It.className="resizeHandle",It.setAttribute("aria-hidden","true"),M.appendChild(O),M.appendChild(ke),M.appendChild(gt),M.appendChild(Vt),M.appendChild(It),u.appendChild(T),u.appendChild(M),s.appendChild(i),s.appendChild(u);let Le=cn,ln=gt.querySelector(".taskSuggestionText"),un=gt.querySelector(".taskSuggestionBtn.primary"),Fe=gt.querySelector(".taskSuggestionBtn.secondary"),wn=new Set,$t=new Map,Qt=[],dn="controller",yn=!1,_n=!1,St=null,Dt=!1,lt=null,Ot=!1,pe=!1,Jt=0;function Gt(){Ot=!Ot,Ce.classList.toggle("visible",Ot)}function Oe(){Ot=!1,Ce.classList.remove("visible")}function et(m,v=0){u.dataset.mood=m,lt!=null&&(window.clearTimeout(lt),lt=null),m==="typing"||m==="running"?(Wt.classList.add("visible"),Me.appendChild(Wt),vn()):Wt.classList.remove("visible"),v>0&&m!=="idle"&&(lt=window.setTimeout(()=>{u.dataset.mood="idle",Wt.classList.remove("visible"),lt=null},v))}function Br(){return Me.scrollHeight-Me.scrollTop-Me.clientHeight<60}function vn(){pe?mt.classList.add("visible"):(requestAnimationFrame(()=>{Me.scrollTo({top:Me.scrollHeight,behavior:"smooth"}),Jt=Date.now()}),mt.classList.remove("visible"))}Me.addEventListener("scroll",()=>{Date.now()-Jt<200||(Br()?(pe=!1,mt.classList.remove("visible")):(pe=!0,mt.classList.add("visible")))},{passive:!0}),mt.addEventListener("click",()=>{pe=!1,Jt=Date.now(),Me.scrollTo({top:Me.scrollHeight,behavior:"smooth"}),mt.classList.remove("visible")});function Ve(){Le.disabled=dn==="observer"&&!yn}function Tn(m){Dt=m,u.dataset.showDetails=m?"true":"false",kt.textContent=Dt?"Hide details":"Show details";for(let v of Qt){let C=v.dataset.status,N=C==="success"||C==="error"||C==="info";v.classList.toggle("compact",!Dt&&N)}}function $n(){u.style.display="",M.classList.remove("closing"),M.classList.add("open"),et("idle"),e.onOpen?.(),Le.disabled||Le.focus()}function Zt(){if(Oe(),!M.classList.contains("open")){e.onClose?.();return}M.classList.remove("open"),M.classList.add("closing"),et("idle");let m=()=>{M.classList.remove("closing"),M.removeEventListener("animationend",m)};M.addEventListener("animationend",m),e.onClose?.()}function Gn(){u.style.display=""}function qn(){Zt(),u.style.display="none"}function At(m,v){let C=ir(v);if(!C)return;let N=document.createElement("div");N.className=`entry message ${m}`;let H=document.createElement("div");H.className="bubble",m==="assistant"?C.length>280?H.appendChild(ec(C,280)):H.appendChild(Sr(C)):H.textContent=C;let Y=document.createElement("div");Y.className="stamp",Y.textContent=Za(Date.now()),N.appendChild(H),N.appendChild(Y),Me.appendChild(N),m==="user"?et("typing",1200):m==="assistant"?et("success",1400):et("running",900),vn()}function en(){for(let m of Array.from(Me.querySelectorAll(".entry.message")))m.remove()}function qt(m){let v=$t.get(m);if(v)return v;let C=document.createElement("div");C.className="entry trace pending";let N=document.createElement("div");N.className="traceTop";let H=document.createElement("div");H.className="traceMeta";let Y=document.createElement("span");Y.className="traceStage",Y.textContent="step";let Q=document.createElement("div");Q.className="traceTitle";let fe=document.createElement("div");fe.className="traceTs",H.appendChild(Y),H.appendChild(Q),N.appendChild(H),N.appendChild(fe);let J=document.createElement("div");return J.className="traceDetail",C.appendChild(N),C.appendChild(J),$t.set(m,C),Qt.push(C),Me.appendChild(C),C}function ur(m,v){let C=Number(v.ts)||Date.now(),N=md(v),H=m.querySelector(".traceTop"),Q=H.querySelector(".traceMeta").querySelector(".traceStage"),fe=H.querySelector(".traceTitle"),J=H.querySelector(".traceTs"),Z=m.querySelector(".traceDetail"),se=nc(v.title||"");fe.textContent=se.plainTitle||"Step",Q.textContent=se.stage||v.kind||"step",Q.style.display=se.stage||v.kind==="status"||v.kind==="plan"||v.kind==="thought"?"":"none",J.textContent=Za(C),Z.innerHTML="";let Ee=ir(v.detail||"");if(Ee){let le=v.kind==="thought"?150:v.kind==="tool_start"||v.kind==="tool_result"?100:280;Ee.length>le?Z.appendChild(ec(Ee,le)):Z.appendChild(Sr(Ee)),Z.style.display=""}else Z.style.display="none";m.classList.remove("pending","success","error","info"),m.classList.add(N),m.dataset.status=N,m.dataset.kind=v.kind,m.dataset.visibility=yd(v);let Pe=N==="success"||N==="error"||N==="info";m.classList.toggle("compact",!Dt&&Pe),N==="error"?et("error",2200):N==="success"?et("success",1200):N==="pending"&&et("running",800)}function Yt(m){let v=ir(m.title||"");if(!v||v.toLowerCase()==="assistant update")return;let C=m.id||tc("timeline");if(m.id&&wn.has(C))return;wn.add(C);let N=gd(m),H=N==="run"||N.startsWith("tool:")||m.kind==="tool_result"||m.kind==="status"&&$t.has(N),Y=qt(H?N:`${N}:${C}`);ur(Y,{...m,title:v}),v.toLowerCase()==="run completed"&&Tn(!1),vn()}function xn(){wn.clear(),$t.clear(),Qt.length=0;for(let m of Array.from(Me.querySelectorAll(".entry.trace")))m.remove()}function Ct(m){let v=!!m?.visible;gt.classList.toggle("visible",v),ln.textContent=m?.text||"Looks like a new request. Start a new task?",un.textContent=m?.primaryLabel||"Start new",Fe.textContent=m?.secondaryLabel||"Continue"}function c(m){let v=String(m||"ready");re.textContent=v;let C=v.toLowerCase();C.includes("error")||C.includes("failed")?et("error",1800):C==="ready"||C.includes("complete")?et("idle"):et("running",1e3)}function w(m){_n=m,He.classList.toggle("visible",m),K.style.display=m?"none":""}function b(m,v){dn=m,yn=m==="observer"?v?.canComposeInObserver===!0:!0,Ve(),K.classList.remove("controller","observer"),K.classList.add(m),m==="controller"?(K.textContent="active",st.style.display="none",Le.placeholder=`Ask ${t} to act on this website...`):(K.textContent="observer",v?.canTakeControl!==!1?st.style.display="":st.style.display="none",v?.note?Le.placeholder=v.note:yn?Le.placeholder="Send to take control and run here.":v?.activeLogicalTabId&&v?.localLogicalTabId&&v.activeLogicalTabId!==v.localLogicalTabId?Le.placeholder=`Observing: ${t} is acting in tab #${v.activeLogicalTabId}`:Le.placeholder="Observer mode. Take control to run actions here.")}function g(){lt!=null&&(window.clearTimeout(lt),lt=null),document.removeEventListener("keydown",f),a.remove(),o.remove()}T.addEventListener("click",()=>{M.classList.contains("open")?Zt():$n()}),ne.addEventListener("click",()=>Zt()),ce.addEventListener("click",m=>{m.stopPropagation(),Gt()}),u.addEventListener("click",m=>{Ot&&!Ce.contains(m.target)&&m.target!==ce&&Oe()}),Je.addEventListener("click",()=>{Oe(),_n&&e.onCancelRun?(St="new_task",Ct({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),ot.addEventListener("click",()=>{Oe(),_n&&e.onCancelRun?(St="end_task",Ct({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),kt.addEventListener("click",()=>{Oe(),Tn(!Dt)}),st.addEventListener("click",()=>{Oe(),e.onRequestControl?.()}),He.addEventListener("click",()=>{e.onCancelRun?.()}),un.addEventListener("click",()=>{if(St){let m=St;St=null,Ct({visible:!1}),e.onCancelRun?.(),m==="new_task"?e.onNewTask?.():m==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),Fe.addEventListener("click",()=>{if(St){St=null,Ct({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Le.addEventListener("input",()=>{Le.style.height="auto",Le.style.height=`${Math.min(96,Math.max(44,Le.scrollHeight))}px`}),Le.addEventListener("keydown",m=>{m.key==="Enter"&&!m.shiftKey&&!m.isComposing&&(m.preventDefault(),Vt.requestSubmit())}),Vt.addEventListener("submit",m=>{if(m.preventDefault(),Le.disabled)return;let v=ir(Le.value);v&&(Ct({visible:!1}),e.onSend(v),Le.value="",Le.style.height="44px")}),s.addEventListener("keydown",m=>{let v=m;v.key==="Escape"&&M.classList.contains("open")&&(v.stopPropagation(),Zt())});let f=m=>{m.code==="Period"&&m.shiftKey&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),m.stopPropagation(),M.classList.contains("open")?Zt():$n())};document.addEventListener("keydown",f);let d=null,h=m=>{if(!d)return;let v=d.startX-m.clientX,C=m.clientY-d.startY,N=Math.max(320,Math.min(window.innerWidth-16,d.startW+v)),H=Math.max(460,Math.min(window.innerHeight-16,d.startH+C));M.style.width=`${N}px`,M.style.height=`${H}px`},x=()=>{d=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",x)};if(It.addEventListener("pointerdown",m=>{window.matchMedia("(max-width: 640px)").matches||(m.preventDefault(),d={startX:m.clientX,startY:m.clientY,startW:M.getBoundingClientRect().width,startH:M.getBoundingClientRect().height},window.addEventListener("pointermove",h),window.addEventListener("pointerup",x))}),_){let m=()=>{_.style.display="none",A.style.display="grid"};_.addEventListener("error",m,{once:!0}),A.style.display="none"}if(q){let m=()=>{q.style.display="none",U.style.display="grid"};q.addEventListener("error",m,{once:!0}),U.style.display="none"}return b("controller"),Tn(!1),{addMessage:At,clearMessages:en,addTimelineEvent:Yt,clearTimeline:xn,setTaskSuggestion:Ct,setStatus:c,setRunning:w,setExecutionMode:b,open:$n,close:Zt,show:Gn,hide:qn,destroy:g}}var _d="rover:shared:",vd="rover:channel:";function ee(){return Date.now()}function Kt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Hs(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function sc(e){if(!e||typeof e!="object")return;let t=typeof e.taskId=="string"?e.taskId.trim():"";if(!t)return;let n=e.status==="completed"||e.status==="ended"||e.status==="running"?e.status:"running";return{taskId:t,status:n,startedAt:Number(e.startedAt)||ee(),lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?e.boundaryReason:void 0,endedAt:Number(e.endedAt)||void 0}}function Td(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function oc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Td(r);o!==void 0&&n.push(o)}return n}function ic(e){if(!e||typeof e!="object")return;let t=s=>s.slice(-80).map(a=>({role:typeof a?.role=="string"?a.role:"assistant",content:typeof a?.content=="string"?a.content:""})).filter(a=>!!a.content),n=Array.isArray(e.history)?t(e.history):[],r=oc(e.plannerHistory,40),o=oc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||ee()}}function Fs(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:ee(),lease:void 0,tabs:[],nextLogicalTabId:1,activeLogicalTabId:void 0,uiMessages:[],timeline:[],uiStatus:void 0,activeRun:void 0,taskEpoch:1,task:void 0,workerContext:void 0,workflowLock:void 0}}function ar(e,t,n){let r=Fs(t,n);if(!e||typeof e!="object")return r;let o={...r,version:2,siteId:t,sessionId:n,seq:Math.max(1,Number(e.seq)||1),updatedAt:Number(e.updatedAt)||ee(),tabs:Array.isArray(e.tabs)?e.tabs.map(i=>({logicalTabId:Math.max(1,Number(i?.logicalTabId)||0),runtimeId:typeof i?.runtimeId=="string"?i.runtimeId:void 0,url:String(i?.url||""),title:typeof i?.title=="string"?i.title:void 0,openedAt:Number(i?.openedAt)||ee(),updatedAt:Number(i?.updatedAt)||ee(),external:!!i?.external,openerRuntimeId:typeof i?.openerRuntimeId=="string"?i.openerRuntimeId:void 0})).filter(i=>!!i.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(i=>({id:String(i?.id||Kt("msg")),role:i?.role==="user"||i?.role==="assistant"||i?.role==="system"?i.role:"system",text:String(i?.text||""),ts:Number(i?.ts)||ee(),sourceRuntimeId:typeof i?.sourceRuntimeId=="string"?i.sourceRuntimeId:void 0})).filter(i=>!!i.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(i=>({id:String(i?.id||Kt("timeline")),kind:String(i?.kind||"status"),title:String(i?.title||"Step"),detail:typeof i?.detail=="string"?i.detail:void 0,status:i?.status==="pending"||i?.status==="success"||i?.status==="error"||i?.status==="info"?i.status:void 0,ts:Number(i?.ts)||ee(),sourceRuntimeId:typeof i?.sourceRuntimeId=="string"?i.sourceRuntimeId:void 0})).filter(i=>!!i.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:sc(e.task),workerContext:ic(e.workerContext),uiStatus:typeof e.uiStatus=="string"?e.uiStatus:void 0,activeRun:e.activeRun&&typeof e.activeRun=="object"?{runId:String(e.activeRun.runId||""),text:String(e.activeRun.text||""),runtimeId:String(e.activeRun.runtimeId||""),startedAt:Number(e.activeRun.startedAt)||ee(),updatedAt:Number(e.activeRun.updatedAt)||ee()}:void 0,lease:e.lease&&typeof e.lease=="object"&&e.lease.holderRuntimeId?{holderRuntimeId:String(e.lease.holderRuntimeId),expiresAt:Number(e.lease.expiresAt)||0,updatedAt:Number(e.lease.updatedAt)||ee()}:void 0,workflowLock:e.workflowLock&&typeof e.workflowLock=="object"&&e.workflowLock.runtimeId&&e.workflowLock.runId?{runtimeId:String(e.workflowLock.runtimeId),runId:String(e.workflowLock.runId),lockedAt:Number(e.workflowLock.lockedAt)||ee(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,a=new Set;return o.tabs=o.tabs.filter(i=>a.has(i.logicalTabId)?!1:(a.add(i.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((i,u)=>Math.max(i,u.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var No=class No{constructor(t){$(this,"siteId");$(this,"sessionId");$(this,"runtimeId");$(this,"leaseMs");$(this,"heartbeatMs");$(this,"maxMessages");$(this,"maxTimeline");$(this,"onRoleChange");$(this,"onStateChange");$(this,"onSwitchRequested");$(this,"key");$(this,"channelName");$(this,"state");$(this,"channel",null);$(this,"heartbeatTimer",null);$(this,"storageHandler",null);$(this,"localLogicalTabId");$(this,"closing",!1);$(this,"started",!1);$(this,"pendingRpcRequests",new Map);$(this,"rpcRequestHandler");$(this,"lastNotifiedRole");$(this,"roleChangeTimer",null);this.siteId=t.siteId,this.sessionId=t.sessionId,this.runtimeId=t.runtimeId,this.leaseMs=Math.max(4e3,Number(t.leaseMs)||12e3),this.heartbeatMs=Math.max(800,Number(t.heartbeatMs)||2e3),this.maxMessages=Math.max(40,Number(t.maxMessages)||220),this.maxTimeline=Math.max(40,Number(t.maxTimeline)||280),this.onRoleChange=t.onRoleChange,this.onStateChange=t.onStateChange,this.onSwitchRequested=t.onSwitchRequested,this.key=`${_d}${this.siteId}:${this.sessionId}`,this.channelName=`${vd}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,s=ee(),a=t.tabs.length;t.tabs=t.tabs.filter(i=>i.runtimeId?i.runtimeId===this.runtimeId?!0:s-Math.max(i.updatedAt||0,i.openedAt||0)<=45e3:r&&i.openerRuntimeId===this.runtimeId?!1:i.external?o?!1:s-Math.max(i.updatedAt||0,i.openedAt||0)<=12e4:s-Math.max(i.updatedAt||0,i.openedAt||0)<=6e5),a!==t.tabs.length&&(t.activeLogicalTabId&&!t.tabs.some(i=>i.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=this.localLogicalTabId||t.tabs[0]?.logicalTabId),t.nextLogicalTabId<=(t.tabs.at(-1)?.logicalTabId??0)&&(t.nextLogicalTabId=t.tabs.reduce((i,u)=>Math.max(i,u.logicalTabId),0)+1))}start(){this.started||(this.started=!0,this.mutate("local",t=>{this.pruneDetachedTabs(t,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),this.registerCurrentTab(window.location.href,document.title||void 0),this.claimLease(!1),this.state.task||this.mutate("local",t=>{t.task={taskId:Kt("task"),status:"running",startedAt:ee(),boundaryReason:"session_start"}}),typeof BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(this.channelName),this.channel.onmessage=t=>{let n=t.data;if(!(!n||typeof n!="object")){if(n.type==="state"&&n.state){let r=ar(n.state,this.siteId,this.sessionId);this.applyIncomingState(r)}n.type==="switch_request"&&n.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(n.logicalTabId)||0),n.type==="rpc_request"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcRequest(n),n.type==="rpc_response"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcResponse(n),n.type==="tab_navigated"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteNavigation(n),n.type==="tab_closing"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteTabClosing(n)}}),this.storageHandler=t=>{if(!(t.key!==this.key||!t.newValue))try{let n=ar(JSON.parse(t.newValue),this.siteId,this.sessionId);this.applyIncomingState(n)}catch{}},window.addEventListener("storage",this.storageHandler),this.heartbeatTimer=window.setInterval(()=>{this.heartbeat()},this.heartbeatMs),this.notifyRoleChange(),this.onStateChange?.(this.state,"local"))}stop(){if(this.started){this.started=!1,this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.roleChangeTimer!=null&&(window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.channel&&(this.channel.close(),this.channel=null);for(let[,t]of this.pendingRpcRequests)window.clearTimeout(t.timer),t.reject(new Error("SessionCoordinator stopped"));this.pendingRpcRequests.clear(),this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.lease?.holderRuntimeId===this.runtimeId&&(t.lease=void 0),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)})}}isController(){let t=this.state.lease;return!t||t.expiresAt<=ee()?!1:t.holderRuntimeId===this.runtimeId}getRole(){return this.isController()?"controller":"observer"}getLocalLogicalTabId(){return this.localLogicalTabId}getActiveLogicalTabId(){return this.state.activeLogicalTabId}getCurrentHolderRuntimeId(){return this.state.lease?.holderRuntimeId}getState(){return this.state}getTaskEpoch(){return this.state.taskEpoch}getTask(){return this.state.task}getWorkerContext(){return this.state.workerContext}syncTask(t,n){this.mutate("local",r=>{n&&Number.isFinite(n)&&n>r.taskEpoch&&(r.taskEpoch=Math.max(1,Math.trunc(n))),t&&(r.task=sc(t)||r.task)})}hydrateExternalState(t){let n=ar(t,this.siteId,this.sessionId);this.pruneDetachedTabs(n,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0});let r=this.state.seq,o=this.state.updatedAt;this.applyIncomingState(n);let s=this.state.seq!==r||this.state.updatedAt!==o;if(!s&&this.state.tabs.some(i=>i.runtimeId?!1:i.external?!0:i.openerRuntimeId===this.runtimeId)){let i=this.state.tabs.length;this.mutate("local",u=>{this.pruneDetachedTabs(u,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),s=this.state.tabs.length!==i}return s?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){let t=ee();return this.state.tabs.filter(n=>n.runtimeId?n.runtimeId===this.runtimeId?!0:t-Math.max(n.updatedAt||0,n.openedAt||0)<=45e3:n.external?t-Math.max(n.updatedAt||0,n.openedAt||0)<=12e4:t-Math.max(n.updatedAt||0,n.openedAt||0)<=6e5)}pruneTabs(t){this.mutate("local",n=>{this.pruneDetachedTabs(n,t)})}startNewTask(t){let n=Number(t.startedAt)||ee(),r={taskId:String(t.taskId||Kt("task")),status:t.status==="completed"||t.status==="ended"?t.status:"running",startedAt:n,lastUserAt:Number(t.lastUserAt)||n,lastAssistantAt:Number(t.lastAssistantAt)||void 0,boundaryReason:t.boundaryReason,endedAt:void 0};return this.mutate("local",o=>{o.taskEpoch=Math.max(1,Number(o.taskEpoch)||1)+1,o.task=r,o.uiMessages=[],o.timeline=[],o.uiStatus=void 0,o.activeRun=void 0,o.workerContext=void 0,this.pruneDetachedTabs(o,{dropAllDetachedExternal:!0})}),r}endTask(t){let n;return this.mutate("local",r=>{r.task&&(r.task={...r.task,status:"ended",boundaryReason:t||r.task.boundaryReason,endedAt:ee()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=ee()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:Kt("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n),r.task.status==="ended"&&(r.task.status="running",r.task.endedAt=void 0)})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=ic(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||Kt("msg"),role:t.role,text:String(t.text||""),ts:Number(t.ts)||ee(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.uiMessages.push(n),r.uiMessages.length>this.maxMessages&&(r.uiMessages=r.uiMessages.slice(-this.maxMessages)),r.task||(r.task={taskId:Kt("task"),status:"running",startedAt:n.ts,boundaryReason:"implicit"}),n.role==="user"?r.task.lastUserAt=n.ts:n.role==="assistant"&&(r.task.lastAssistantAt=n.ts)}),n}appendTimeline(t){let n={id:t.id||Kt("timeline"),kind:String(t.kind||"status"),title:String(t.title||"Step"),detail:t.detail?String(t.detail):void 0,status:t.status,ts:Number(t.ts)||ee(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.timeline.push(n),r.timeline.length>this.maxTimeline&&(r.timeline=r.timeline.slice(-this.maxTimeline))}),n}clearTimeline(){this.mutate("local",t=>{t.timeline=[]})}setActiveRun(t){this.mutate("local",n=>{if(!t){n.activeRun=void 0;return}n.activeRun={runId:t.runId,text:t.text,runtimeId:this.runtimeId,startedAt:n.activeRun?.runId===t.runId?n.activeRun.startedAt:ee(),updatedAt:ee()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:Kt("task"),status:"running",startedAt:ee()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=Hs(t),o;return this.mutate("local",s=>{let a=s.tabs.find(i=>i.runtimeId===this.runtimeId);if(a)a.url=r||a.url,a.title=n||a.title,a.updatedAt=ee(),o=a.logicalTabId;else{let i=s.tabs.find(u=>!u.runtimeId&&u.url===r&&ee()-u.openedAt<18e4);if(i)i.runtimeId=this.runtimeId,i.title=n||i.title,i.updatedAt=ee(),o=i.logicalTabId;else{let u=s.nextLogicalTabId++;s.tabs.push({logicalTabId:u,runtimeId:this.runtimeId,url:r,title:n,openedAt:ee(),updatedAt:ee(),external:!1}),o=u}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=Hs(t.url),r=0;return this.mutate("local",o=>{r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:ee(),updatedAt:ee(),external:!!t.external,openerRuntimeId:t.openerRuntimeId})}),{logicalTabId:r}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",r=>{let o=r.tabs.find(s=>s.logicalTabId===t);if(!o){n={ok:!1,reason:`Tab ${t} not found`};return}if(r.activeLogicalTabId=t,o.runtimeId&&o.runtimeId!==this.runtimeId){r.lease={holderRuntimeId:o.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},this.channel&&this.channel.postMessage({type:"switch_request",logicalTabId:t,targetRuntimeId:o.runtimeId,sourceRuntimeId:this.runtimeId}),n={ok:!0,delegated:!0};return}if(!o.runtimeId){n={ok:!1,reason:`Tab ${t} is not attached to an active Rover runtime yet`};return}r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((s,a)=>{if(!this.channel){a(new Error("BroadcastChannel not available"));return}let i=Kt("rpc"),u=window.setTimeout(()=>{this.pendingRpcRequests.delete(i),a(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(i,{resolve:s,reject:a,timer:u}),this.channel.postMessage({type:"rpc_request",requestId:i,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:ee()})})}setRpcRequestHandler(t){this.rpcRequestHandler=t}broadcastNavigation(t,n){this.channel&&this.channel.postMessage({type:"tab_navigated",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId,url:t,title:n})}broadcastClosing(){this.closing=!0,this.channel&&(this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)}),this.channel.postMessage({type:"tab_closing",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId}))}isTabAlive(t){let n=this.state.tabs.find(r=>r.logicalTabId===t);return n?n.updatedAt>ee()-2*this.heartbeatMs:!1}acquireWorkflowLock(t){let n=!1;return this.mutate("local",r=>{let o=r.workflowLock;if(o&&o.runtimeId!==this.runtimeId&&o.expiresAt>ee()){let s=r.tabs.find(i=>i.runtimeId===o.runtimeId);if(s&&s.updatedAt>ee()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:ee(),expiresAt:ee()+this.leaseMs*5},n=!0}),n}clearActiveRunRuntimeId(t){this.mutate("local",n=>{n.activeRun&&n.activeRun.runId===t&&(n.activeRun.runtimeId="")})}releaseWorkflowLock(t){this.mutate("local",n=>{n.workflowLock&&n.workflowLock.runId===t&&(n.workflowLock=void 0)})}isWorkflowLocked(){let t=this.state.workflowLock;return!t||t.runtimeId===this.runtimeId?!1:t.expiresAt>ee()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=ee()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:s}=t;if(!this.rpcRequestHandler){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:"No RPC handler registered",code:"NO_HANDLER"}});return}try{let a=await this.rpcRequestHandler({method:o,params:s});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:a})}catch(a){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:a?.message||String(a)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:s}=t,a=this.pendingRpcRequests.get(n);a&&(this.pendingRpcRequests.delete(n),window.clearTimeout(a.timer),r?a.resolve(o):a.reject(new Error(s?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",s=>{let a=s.tabs.find(i=>i.runtimeId===n);a&&(a.url=r||a.url,a.title=o||a.title,a.updatedAt=ee())})}handleRemoteTabClosing(t){let{runtimeId:n}=t;this.mutate("local",r=>{r.tabs=r.tabs.filter(o=>o.runtimeId!==n),r.lease?.holderRuntimeId===n&&(r.lease=void 0),r.workflowLock?.runtimeId===n&&(r.workflowLock=void 0),r.activeRun?.runtimeId===n&&(r.activeRun=void 0),r.activeLogicalTabId&&!r.tabs.some(o=>o.logicalTabId===r.activeLogicalTabId)&&(r.activeLogicalTabId=void 0)}),this.notifyRoleChange()}heartbeat(){if(this.closing)return;let t=Hs(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(i=>i.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=ee();else{let i=r.nextLogicalTabId++;r.tabs.push({logicalTabId:i,runtimeId:this.runtimeId,url:t,title:n,openedAt:ee(),updatedAt:ee(),external:!1})}let s=r.lease;(!s||s.expiresAt<=ee()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=ee()+this.leaseMs*5),this.pruneDetachedTabs(r)}),this.notifyRoleChange()}reloadFromStorage(){let t=this.loadState();return(t.seq>this.state.seq||t.seq===this.state.seq&&t.updatedAt>this.state.updatedAt)&&(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote")),this.closing=!1,this.state}claimLease(t){let n=!1;return this.mutate("local",r=>{let o=r.lease,s=!o||o.expiresAt<=ee();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId),n=!0)}),this.notifyRoleChange(),n}notifyRoleChange(){this.getRole()!==this.lastNotifiedRole&&(this.roleChangeTimer!=null&&window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=window.setTimeout(()=>{this.roleChangeTimer=null;let n=this.getRole();n!==this.lastNotifiedRole&&(this.lastNotifiedRole=n,this.onRoleChange?.(n,{localLogicalTabId:this.localLogicalTabId,activeLogicalTabId:this.state.activeLogicalTabId,holderRuntimeId:this.state.lease?.holderRuntimeId}))},No.ROLE_CHANGE_DEBOUNCE_MS))}syncLocalLogicalTabId(){let t=this.state.tabs.find(n=>n.runtimeId===this.runtimeId);this.localLogicalTabId=t?.logicalTabId}mutate(t,n){if(t==="local")try{let o=window.localStorage.getItem(this.key);if(o){let s=ar(JSON.parse(o),this.siteId,this.sessionId);(s.seq>this.state.seq||s.seq===this.state.seq&&s.updatedAt>this.state.updatedAt)&&(this.state=s)}}catch{}let r=ar(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=ee(),this.state=r,this.syncLocalLogicalTabId(),t==="local"&&(this.persistState(),this.channel&&this.channel.postMessage({type:"state",sourceRuntimeId:this.runtimeId,state:this.state})),this.onStateChange?.(this.state,t)}applyIncomingState(t){t&&(t.seq<this.state.seq||t.seq===this.state.seq&&t.updatedAt<=this.state.updatedAt||(this.pruneDetachedTabs(t),this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Fs(this.siteId,this.sessionId);let n=JSON.parse(t);return ar(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Fs(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(No,"ROLE_CHANGE_DEBOUNCE_MS",200);var Lo=No;var xd="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function cr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Rd(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function kd(e){let t=Number(e.sharedState?.seq||0),n=Array.isArray(e.sharedState?.uiMessages)?e.sharedState.uiMessages.length:0,r=Number(e.runtimeState?.updatedAt||0),o=Array.isArray(e.runtimeState?.uiMessages)?e.runtimeState.uiMessages.length:0;return[e.sessionId,cr(e.updatedAt,0),t,n,r,o].join(":")}function Id(e){let t=(e||xd).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Ps(e,t){let n=new Error(e);return n.details=t,n}var Do=class{constructor(t){$(this,"endpoint");$(this,"token");$(this,"siteId");$(this,"visitorId");$(this,"ttlHours");$(this,"flushIntervalMs");$(this,"pullIntervalMs");$(this,"minFlushIntervalMs");$(this,"shouldWrite");$(this,"buildCheckpoint");$(this,"onCheckpoint");$(this,"onError");$(this,"started",!1);$(this,"dirty",!1);$(this,"flushTimer",null);$(this,"pullTimer",null);$(this,"lastFlushAt",0);$(this,"lastPullAt",0);$(this,"lastUploadedRevision","");$(this,"lastAppliedRemoteUpdatedAt",0);$(this,"pushInFlight",!1);$(this,"pullInFlight",!1);let n=String(t.apiKey||t.authToken||"").trim();if(!n)throw Ps("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=Id(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(cr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(cr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(cr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(cr(t.minFlushIntervalMs,2500))),this.shouldWrite=t.shouldWrite||(()=>!0),this.buildCheckpoint=t.buildCheckpoint,this.onCheckpoint=t.onCheckpoint,this.onError=t.onError}start(){this.started||(this.started=!0,this.flushTimer=window.setInterval(()=>{this.flush(!1)},this.flushIntervalMs),this.pullTimer=window.setInterval(()=>{this.pull(!1)},this.pullIntervalMs),this.pull(!0))}stop(){this.started&&(this.started=!1,this.flushTimer!=null&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.pullTimer!=null&&(window.clearInterval(this.pullTimer),this.pullTimer=null),this.flush(!0))}markDirty(){this.dirty=!0}syncNow(){this.flush(!0),this.pull(!0)}async flush(t){if(this.pushInFlight||!this.dirty&&!t||!this.shouldWrite()||!t&&Date.now()-this.lastFlushAt<this.minFlushIntervalMs)return;let n=this.buildCheckpoint();if(!n)return;let r=kd(n);if(!t&&r===this.lastUploadedRevision){this.dirty=!1;return}this.pushInFlight=!0;try{let o=await this.callExtensionRouter("roverSessionCheckpointUpsert",{siteId:this.siteId,visitorId:this.visitorId,sessionId:n.sessionId,ttlHours:this.ttlHours,updatedAt:n.updatedAt,checkpoint:n});this.lastFlushAt=Date.now(),o?.saved&&(this.dirty=!1,this.lastUploadedRevision=r),o?.stale&&o?.checkpoint&&typeof o.checkpoint=="object"&&(this.applyRemoteCheckpoint(o.checkpoint,"push_stale"),this.dirty=!1)}catch(o){this.onError?.(o)}finally{this.pushInFlight=!1}}async pull(t){if(!this.pullInFlight&&!(!t&&Date.now()-this.lastPullAt<this.pullIntervalMs)){this.pullInFlight=!0;try{let n=await this.callExtensionRouter("roverSessionCheckpointGet",{siteId:this.siteId,visitorId:this.visitorId});if(this.lastPullAt=Date.now(),!n?.found||!n?.checkpoint||typeof n.checkpoint!="object")return;this.applyRemoteCheckpoint(n.checkpoint,"pull")}catch(n){this.onError?.(n)}finally{this.pullInFlight=!1}}}applyRemoteCheckpoint(t,n){let r=Math.max(0,Math.floor(cr(t?.updatedAt,0)));r<=this.lastAppliedRemoteUpdatedAt||(this.lastAppliedRemoteUpdatedAt=r,this.onCheckpoint(t,n))}async callExtensionRouter(t,n){let r=await fetch(this.endpoint,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({action:t,data:n})});if(!r.ok){let s;try{s=await r.json()}catch{let a=await r.text().catch(()=>"");s=a?{error:Rd(a,2e3)}:void 0}throw Ps(`Checkpoint HTTP ${r.status}`,s)}let o=await r.json();if(o?.success===!1)throw Ps("Checkpoint extensionRouter returned success=false",o);return o?.data}};var Sd="rover-runtime-state-db",Oo="runtime-state",Bs=class{read(t){try{let n=window.sessionStorage.getItem(t);return n?JSON.parse(n):null}catch{return null}}write(t,n){try{window.sessionStorage.setItem(t,JSON.stringify(n))}catch{}}remove(t){try{window.sessionStorage.removeItem(t)}catch{}}},Ws=class{constructor(){$(this,"dbPromise",null)}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Error("indexedDB unavailable"));return}let r=indexedDB.open(Sd,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Oo)||o.createObjectStore(Oo)},r.onsuccess=()=>{t(r.result)},r.onerror=()=>{n(r.error||new Error("indexedDB open failed"))}}).catch(t=>{throw this.dbPromise=null,t}),this.dbPromise)}async withStore(t,n){let r=await this.openDb();return new Promise((o,s)=>{let a=r.transaction(Oo,t),i=a.objectStore(Oo);n(i,o,s),a.onerror=()=>{s(a.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let s=n.get(t);s.onsuccess=()=>{let a=s.result;r(a??null)},s.onerror=()=>{o(s.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,s)=>{let a=r.put(n,t);a.onsuccess=()=>o(),a.onerror=()=>{s(a.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let s=n.delete(t);s.onsuccess=()=>r(),s.onerror=()=>{o(s.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function ac(){let e=new Bs,t=new Ws;return{readSync:n=>e.read(n),readAsync:async n=>t.read(n),write:(n,r)=>{e.write(n,r),t.write(n,r)},remove:n=>{e.remove(n),t.remove(n)}}}var Gs=1,Ad="rover:runtime:",Cd="rover:runtime-id:",dc="rover:visitor-id:",Vs=160,$s=240,fc=80,qo=40,Md=8e3,Ld=15*6e4,Nd=12,Dd=3600*24*365,Od=1,Ud=3e3,Hd=9e4,mn=null,ze=null,Ie=null,me=null,Te=null,lr=null,y=null,Pn=null,Ae="",F=null,Et=null,ft,Yo=!1,pt="controller",En=!1,Bn=!1,Fn=null,cc=!1,Ar=null,Uo="",pc,an=new Map,Fd=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Wo=[],Vo=new Map;function We(e,t){let n=Vo.get(e);if(n)for(let r of n)try{r(t)}catch{}}function hc(e,t){Vo.has(e)||Vo.set(e,new Set);let n=Vo.get(e);return n.add(t),()=>{n.delete(t)}}function Pd(e){return typeof e=="string"?{name:e}:e}function gn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Bd(e){let t=`${Cd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=gn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return gn("runtime")}}function Xo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Ho(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function mc(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function lc(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${Dd}; samesite=lax${r}`,mc(e)===t}catch{return!1}}function Wd(e){let t=String(e||"").trim().toLowerCase();if(!t||t==="localhost"||/^\d{1,3}(\.\d{1,3}){3}$/.test(t))return[];let n=t.split(".").filter(Boolean);if(n.length<2)return[];let r=[];for(let o=n.length-2;o>=0;o-=1)r.push(`.${n.slice(o).join(".")}`);return r}function Vd(e,t){let n=`rover_vid_${Xo(e)}`;for(let r of Wd(window.location.hostname))if(lc(n,t,r))return;lc(n,t)}function Fo(e,t){let n=`${dc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}Vd(e,t)}function gc(e){let t=Ho(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${dc}${e.siteId}`,r=`rover_vid_${Xo(e.siteId)}`,o=Ho(mc(r)||"");if(o)return Fo(e.siteId,o),o;try{let a=Ho(window.localStorage.getItem(n)||"");if(a)return Fo(e.siteId,a),a}catch{}try{let a=Ho(window.sessionStorage.getItem(n)||"");if(a)return Fo(e.siteId,a),a}catch{}let s=`v_${Xo(`${e.siteId}:${gn("visitor")}`)}_${Date.now().toString(36)}`;return Fo(e.siteId,s),s}function $d(e,t){return`visitor-${Xo(`${e}:${t}`)}`}function bc(e){!ze||!Ie||(ze.registerTool(e.def,e.handler),Ie.postMessage({type:"register_tool",tool:e.def}))}function Gd(e){return`${Ad}${e}`}function bn(e="session_start"){let t=Date.now();return{taskId:gn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Ec(e,t){return{version:Gs,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:bn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function ct(e,t=Md){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function $o(e){if(e!=null){if(typeof e=="string")return ct(e,1200);try{return ct(JSON.stringify(e),1200)}catch{try{return ct(String(e),1200)}catch{return}}}}function wc(e){let t=String((e||[])[0]||"").trim();return t?t.replace(/^\*?\./,"").replace(/^=/,""):"the configured domain"}function Po(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",s=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),a=wc(e.allowedDomains),i=String(n||"").trim(),u=i?` Reason: ${i}.`:"",T=t?.external?`Rover is embedded inside ${a}. This tab is outside direct DOM access and only virtual tab context is available.${u}`:`This tab is currently not attached to an active Rover runtime. Switch to a live tab or reopen it.${u}`;return{url:o,title:s,contentType:"text/html",content:T,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function Bo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",s=wc(e.allowedDomains),a=t?.external?`Tab ${r} is outside Rover's embedded domain scope (${s}) and cannot be controlled directly.`:`Tab ${r} is not attached to an active Rover runtime.`,i=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:a,allowFallback:!0,output:{success:!1,error:{code:i,message:a,missing:[],next_action:t?.external?"Use open_new_tab for external context or continue on an in-scope tab.":"Switch to an active tab and retry.",retryable:!1},blocked_url:o||void 0,logical_tab_id:r||void 0,external:!!t?.external,policy_action:t?.external?e.externalNavigationPolicy||"open_new_tab_notice":void 0,reason:n},errorDetails:{code:i,message:a,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function qd(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function Yd(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function Xd(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function zd(e,t){if(!e)return!0;let n=e.trim();return!!(t&&n.toLowerCase()===t.trim().toLowerCase()||/^complexity score\b/i.test(n)||/\btool loop$/i.test(n)||/^calling \w[\w\s]*(workflow|sub-agent)$/i.test(n))}function jd(){return y?.pendingRun?.id}function yc(){let e=F?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Ae)}function _c(){return!yc()}function vc(e){if(e==="observer")return yc()?"Observing active run in another tab...":"Send to take control and run here."}function Kd(e){let t=typeof e?.type=="string"?e.type:"";if(!Fd.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=jd();if(t==="run_started")return!n||!r?!1:r!==n;if(!n)return!1;if(t==="run_completed"){if(!r){let o=F?.getState()?.activeRun?.runId;return!(o&&o===n)}return r!==n}return r?r!==n:!0}function Qd(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1};let t=e.needsUserInput===!0;return{taskComplete:e.taskComplete===!0&&!t,needsUserInput:t}}function Jd(e){if(e&&an.has(e))return an.get(e);if(y?.uiMessages?.length)for(let t=y.uiMessages.length-1;t>=0;t-=1){let n=y.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function Zd(e){return Pn?Pn.readSync(e):null}function ef(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function Tc(e){if(!e||typeof e!="object")return null;let t=e.role,n=e.content;return typeof t!="string"||typeof n!="string"||!n?null:{role:t,content:n}}function zo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=ef(r);o!==void 0&&n.push(o)}return n}async function tf(e){if(!Pn)return null;try{return await Pn.readAsync(e)}catch{return null}}function Cr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Vs)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:gn("msg"),role:r,text:ct(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Mr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-$s)){let r=ct(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),s=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:gn("timeline"),kind:o,title:r,detail:n?.detail?ct(String(n.detail),1200):void 0,status:s==="pending"||s==="success"||s==="error"||s==="info"?s:void 0,ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Wn(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.history)?e.history:[],n=Array.isArray(e.plannerHistory)?e.plannerHistory:[],r=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],o=t.slice(-fc).map(i=>Tc(i)).filter(i=>!!i),s=zo(n,qo),a=zo(r,qo*2);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:o,plannerHistory:s,agentPrevSteps:a,lastToolPreviousSteps:a,updatedAt:Number(e.updatedAt)||Date.now()}}function Lr(e,t,n){if(!e||typeof e!="object")return Ec(t,n);let r=bn(),o=Ur(e.activeTask,r);return{version:Gs,sessionId:typeof e.sessionId=="string"&&e.sessionId?e.sessionId:t,runtimeId:typeof e.runtimeId=="string"&&e.runtimeId?e.runtimeId:n,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?ct(e.uiStatus,300):void 0,uiMessages:Cr(e.uiMessages),timeline:Mr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Wn(e.workerState),pendingRun:Nr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:o,lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:typeof e.lastRoutingDecision.reason=="string"?ct(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Ur(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,r=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:r,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?ct(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function nf(e,t){return Ur(e,t)}function xc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-fc).map(t=>Tc(t)).filter(t=>!!t):[],plannerHistory:zo(e.plannerHistory,qo),agentPrevSteps:zo(e.agentPrevSteps,qo*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Nr(e){if(!e||typeof e!="object")return;let t=typeof e.id=="string"&&e.id.trim()?e.id.trim():void 0,n=typeof e.text=="string"?e.text.trim():"";if(!(!t||!n))return{id:t,text:n,startedAt:Number(e.startedAt)||Date.now(),attempts:Math.max(0,Number(e.attempts)||0),autoResume:e.autoResume!==!1}}function Re(){if(!(!y||!lr))try{y.updatedAt=Date.now(),Pn?.write(lr,y),Yo||Et?.markDirty()}catch{}}function rf(){if(cc)return;cc=!0;let e=()=>{y?.pendingRun?.autoResume&&F?.clearActiveRunRuntimeId(y.pendingRun.id),F?.broadcastClosing(),y?.pendingRun&&F?.releaseWorkflowLock(y.pendingRun.id),Re(),Et?.markDirty(),Et?.syncNow(),Et?.stop(),F?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(F&&(F.reloadFromStorage(),F.registerCurrentTab(window.location.href,document.title||void 0),F.claimLease(!1)),Bn=!1)};window.addEventListener("pageshow",t)}function Hr(e="implicit"){if(y)return y.activeTask||(y.activeTask=bn(e),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1)),y.activeTask}function of(e,t=Date.now()){if(!y)return;let n=Hr("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function uc(e="worker_task_active",t=Date.now()){if(!y)return;let n=Hr(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),F?.syncTask({...n},y.taskEpoch),Re())}function sf(e="worker_task_complete",t=Date.now()){if(!y)return;let n=Hr(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,F?.syncTask({...n},y.taskEpoch),Re())}function Vn(){Ar=null,me?.setTaskSuggestion({visible:!1})}function Rc(){me?.clearMessages(),me?.clearTimeline(),Vn()}function af(){let e=y?.pendingRun;if(!e)return!1;if(!F)return!0;let t=F?.getState()?.activeRun;if(t?.runId&&t.runId===e.id||t?.runtimeId&&t.runtimeId!==Ae)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=Ud}function cf(){if(!y?.pendingRun||af()||!F)return;let e=y.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<Hd||(Nt(void 0),F?.clearActiveRunRuntimeId(e.id),F?.releaseWorkflowLock(e.id),F?.setActiveRun(void 0))}function Bt(e,t,n=!0,r){let o=ct(String(t||""));if(!o)return;let s={id:r?.id||gn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return me?.addMessage(s.role,s.text),y&&n&&(y.uiMessages.push(s),y.uiMessages.length>Vs&&(y.uiMessages=y.uiMessages.slice(-Vs)),of(s.role,s.ts),Re()),F&&r?.publishShared!==!1&&(F.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),F.markTaskActivity(s.role,s.ts)),s}function qs(e){for(let t of e)Bt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function Ye(e,t=!0){let n={id:e.id||gn("timeline"),kind:e.kind,title:ct(e.title,400),detail:e.detail?ct(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return me?.addTimelineEvent(n),y&&t&&(y.timeline.push(n),y.timeline.length>$s&&(y.timeline=y.timeline.slice(-$s)),Re()),F&&e.publishShared!==!1&&F.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function Ys(e){me?.clearTimeline();for(let t of e)Ye({id:t.id,kind:t.kind,title:t.title,detail:t.detail,status:t.status,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1},!1)}function Rt(e,t){me?.setStatus(e),y&&(y.uiStatus=ct(e,300),Re()),F&&t?.publishShared!==!1&&F.setStatus(e)}function Dr(e,t){pt=e,y&&(y.executionMode=e,Re()),me?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??F?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??F?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??F?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:_c(),note:vc(e)}),We("mode_change",{mode:e,...t})}function Nt(e){if(!y)return;y.pendingRun=e;let t=Hr("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Re()}function kc(e,t){let n=String(e||"").trim();if(!n||!Ie)return;if(pt==="observer"&&!(F?.requestControl()??!1)){Bt("system","Unable to take control right now because another tab is still running Rover actions.",!0),Ye({kind:"info",title:"Observer mode",detail:"Action execution is currently owned by another tab runtime.",status:"info"});return}let r=t?.runId||crypto.randomUUID(),o=!!t?.resume;t?.appendUserMessage!==!1&&Bt("user",n,!0);let a=y?.pendingRun?.id===r?y.pendingRun.attempts:0;Nt({id:r,text:n,startedAt:Date.now(),attempts:o?a+1:0,autoResume:t?.autoResume!==!1}),pc=n,F?.acquireWorkflowLock(r),F?.setActiveRun({runId:r,text:n}),Ie.postMessage({type:"run",text:n,runId:r,resume:o}),Fn&&clearTimeout(Fn);let i=r;Fn=setTimeout(()=>{y?.pendingRun?.id===i&&(Nt(void 0),F?.releaseWorkflowLock(i),F?.setActiveRun(void 0),Rt("Task timed out."),Bt("system","Task timed out after 5 minutes with no response.",!0),We("error",{message:"Run safety timeout"})),Fn=null},5*6e4)}function Go(e,t){let n=String(e||"").trim();if(!n)return;cf();let r=y?.activeTask?.status,o=!!t?.startNewTask||r==="completed"||r==="ended";if(F?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:o}),o){let s=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");Pr({reason:s,clearUi:!0})}Vn(),kc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}function jo(){if(pt==="observer")return;let e=F?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Ae&&!(y?.pendingRun?.id===e.runId)||!En||!Ie||Bn||!y?.pendingRun||y.activeTask?.status==="ended")return;let t=y.pendingRun;if(!t.autoResume)return;let n=Te?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${n}`)&&!(F?.listTabs()||[]).some(i=>i.runtimeId!==Ae&&i.updatedAt>Date.now()-2*2e3)&&y?.pendingRun){Nt(void 0),Rt("Previous task expired.");return}if(Date.now()-t.startedAt>Ld){Nt(void 0),Rt("Previous task expired after navigation.");return}if(t.attempts>=Nd){Nt(void 0),Bt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Bn=!0,Rt("Resuming previous task after navigation..."),kc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function lf(e){if(!y)return;let t=await tf(e);if(!t||!y)return;let n=Number(y.updatedAt)||0,r=Lr({...t,sessionId:y.sessionId,runtimeId:Ae},y.sessionId,Ae);(Number(r.updatedAt)||0)<=n+200||(y=Lr({...y,...r,sessionId:y.sessionId,runtimeId:Ae},y.sessionId,Ae),Re(),me&&(me.clearMessages(),qs(y.uiMessages),Ys(y.timeline),y.uiStatus&&me.setStatus(y.uiStatus),y.uiHidden?me.hide():(me.show(),y.uiOpen?me.open():me.close())),En&&Ie&&y.workerState&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:y.workerState}),We("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function Xs(e,t){if(y){if(t==="remote"){let n=Math.max(1,Number(y.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;y.taskEpoch=Math.max(n,r);let s=y.activeTask||bn("shared_sync");y.activeTask=nf(e.task,s),o&&(y.uiMessages=[],y.timeline=[],Rc(),Nt(void 0),Vn());let a=Cr(e.uiMessages),i=new Set(a.map(A=>A.id));if(a.length<y.uiMessages.length||y.uiMessages.some(A=>!i.has(A.id)))y.uiMessages=a,me?.clearMessages(),qs(y.uiMessages);else{let A=new Set(y.uiMessages.map(S=>S.id));for(let S of a)A.has(S.id)||(Bt(S.role,S.text,!0,{id:S.id,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1}),A.add(S.id))}let T=Mr(e.timeline),p=new Set(T.map(A=>A.id));if(T.length<y.timeline.length||y.timeline.some(A=>!p.has(A.id)))y.timeline=T,Ys(y.timeline);else{let A=new Set(y.timeline.map(S=>S.id));for(let S of T)A.has(S.id)||(Ye({id:S.id,kind:S.kind,title:S.title,detail:S.detail,status:S.status,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1},!0),A.add(S.id))}if(typeof e.uiStatus=="string"&&Rt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Ae?Nt(Nr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:y.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&pt==="observer"&&Nt(void 0),pt==="observer"&&Dr("observer",{localLogicalTabId:F?.getLocalLogicalTabId(),activeLogicalTabId:F?.getActiveLogicalTabId(),holderRuntimeId:F?.getCurrentHolderRuntimeId()}),e.workerContext){let A=Wn(e.workerContext),S=Number(y.workerState?.updatedAt)||0,M=Number(A?.updatedAt)||0;A&&M>S+100&&(y.workerState=A,En&&Ie&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:A}),We("context_restored",{source:"shared_session",ts:Date.now()})))}}y.uiMessages=Cr(y.uiMessages),y.timeline=Mr(y.timeline),y.workerState=Wn(y.workerState),y.activeTask=Ur(y.activeTask,bn("implicit")),Re()}}function Ic(e){let t=bn("checkpoint_clone");return{version:Gs,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?ct(e.uiStatus,300):void 0,uiMessages:Cr(e.uiMessages),timeline:Mr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Wn(e.workerState),pendingRun:Nr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Ur(e.activeTask,t),lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:e.lastRoutingDecision.reason,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function uf(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!ft)}function df(){if(!y||!Te||!ft)return null;let e=F?.getState(),t=Ic(y),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Od,siteId:Te.siteId,visitorId:ft,sessionId:y.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function ff(e){if(!e||typeof e!="object"||!y||!Te||e.siteId&&e.siteId!==Te.siteId||ft&&e.visitorId&&e.visitorId!==ft)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():y.sessionId;Yo=!0;try{if(t&&y.sessionId!==t&&(y.sessionId=t,Te={...Te,sessionId:t},Ko(Te),Ie?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&F&&F.hydrateExternalState(e.sharedState)&&(Xs(F.getState(),"remote"),Dr(F.getRole(),{localLogicalTabId:F.getLocalLogicalTabId(),activeLogicalTabId:F.getActiveLogicalTabId(),holderRuntimeId:F.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Lr({...e.runtimeState,sessionId:t,runtimeId:Ae},t,Ae),r=Number(y.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(y=Lr({...y,...n,sessionId:t,runtimeId:Ae},t,Ae),Re(),y.uiStatus&&me?.setStatus(y.uiStatus),y.uiHidden?me?.hide():(me?.show(),y.uiOpen?me?.open():me?.close()),En&&y.workerState&&(Ie?.postMessage({type:"hydrate_state",state:y.workerState}),We("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),pt==="controller"&&jo())}}finally{Yo=!1}}function Sc(e){if(Et?.stop(),Et=null,!!uf(e)&&ft)try{Et=new Do({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:ft,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>pt==="controller",buildCheckpoint:()=>df(),onCheckpoint:t=>{ff(t)},onError:()=>{}}),Et.start(),Et.markDirty()}catch{Et=null}}function Ko(e){if(y){if(F?.stop(),F=null,e.sessionScope==="tab"){Dr("controller");return}F=new Lo({siteId:e.siteId,sessionId:y.sessionId,runtimeId:Ae,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Dr(t,n);let r=t==="controller"&&(Te?.allowActions??!0);if(ze?.setAllowActions(r),t==="controller"){let o=F?.getWorkerContext();if(o){let s=Wn(o),a=Number(y?.workerState?.updatedAt)||0,i=Number(s?.updatedAt)||0;s&&i>a+100&&(y&&(y.workerState=s,Re()),En&&Ie&&(Ie.postMessage({type:"hydrate_state",state:s}),We("context_restored",{source:"controller_handoff",ts:Date.now()})))}jo()}},onStateChange:(t,n)=>{Xs(t,n)},onSwitchRequested:t=>{t>0&&(Fr(),Ye({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),F.start(),F.setRpcRequestHandler(async t=>{if(!ze)throw new Error("Bridge not available");if(t.method==="getPageData")return ze.getPageData(t.params);if(t.method==="executeTool")return ze.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),y?.activeTask&&F.syncTask({...y.activeTask,taskId:y.activeTask.taskId},y.taskEpoch),y?.workerState&&F.setWorkerContext(xc(y.workerState))}}function pf(e){let t=ct(Jd(e)||"Done.",1200);me?.clearTimeline(),y&&(y.timeline=[]),F?.clearTimeline(),Ye({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function hf(e){if(!(!e||typeof e!="object")&&!Kd(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(an.set(e.runId,t),an.size>80)){let n=an.keys().next().value;n&&an.delete(n)}Bt("assistant",t,!0),Ye({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=qd(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=Xd(n,t,r);if(n&&Rt(n),o&&o!==Uo&&(Uo=o,n)){let s=!!(e.thought||r),a=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!zd(a,pc))Ye({kind:"thought",title:a,detail:e.thought?String(e.thought):r,status:"pending"});else{let u=t?`${Yd(t)}: ${n}`:n;Ye({kind:"status",title:u,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}We("status",e);return}if(e.type==="tool_start"){Ye({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:$o(e.call?.args),status:"pending"}),We("tool_start",e);return}if(e.type==="tool_result"){Ye({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:$o(e.result),status:e?.result?.success===!1?"error":"success"}),We("tool_result",e);return}if(e.type==="auth_required"){We("auth_required",e.error),e.error?.message&&(Bt("system",`Auth required: ${e.error.message}`,!0),Ye({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){We("navigation_guardrail",e),Ye({kind:"status",title:"Navigation guardrail",detail:$o(e),status:"info"});return}if(e.type==="error"){Bt("system",`Error: ${e.message||"unknown"}`,!0),Ye({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),We("error",e);return}if(e.type==="state_snapshot"){y&&(y.workerState=Wn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!y.pendingRun&&(y.pendingRun=Nr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&F?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),y.workerState&&F?.setWorkerContext(xc(y.workerState)),Re());return}if(e.type==="task_started"){We("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Uo="",Vn(),typeof e.runId=="string"&&e.runId&&an.delete(e.runId);let t=y?.pendingRun;Nt(Nr({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),F?.setActiveRun({runId:e.runId,text:String(e.text||"")}),me?.setRunning(!0);let n=`run:${String(e.runId||"")}:start`;y?.timeline.some(r=>r.id===n)||Ye({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){if(Uo="",Bn=!1,me?.setRunning(!1),Fn&&(clearTimeout(Fn),Fn=null),y?.pendingRun?.id===e.runId&&Nt(void 0),typeof e.runId=="string"&&e.runId&&F?.releaseWorkflowLock(e.runId),y&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(y.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?ct(e.route.reason,200):void 0,ts:Date.now()},Re()),F?.setActiveRun(void 0),!e.ok&&e.error)uc("worker_run_failed"),Rt(`Task failed: ${String(e.error)}`),an.delete(String(e.runId||"")),Ye({kind:"error",title:"Run failed",detail:String(e.error),status:"error"});else if(e.ok){let t=Qd(e),n=t.taskComplete,r=t.needsUserInput;n?(sf("worker_task_complete"),Rt("Task completed"),pf(typeof e.runId=="string"?e.runId:void 0)):(uc(r?"worker_waiting_for_input":"worker_continuation"),Rt(r?"Need more input to continue":"Execution finished. Continue when ready."),Ye({kind:"status",title:r?"Waiting for your input":"Continuation available",detail:r?"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"})),typeof e.runId=="string"&&e.runId&&an.delete(e.runId)}return}if(e.type==="ready"){En=!0,Rt("ready"),We("ready");let t=F?.getWorkerContext(),n=Wn(t),r=Number(y?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:y?.workerState;y&&s&&s!==y.workerState&&(y.workerState=s,Re()),s?(Ie?.postMessage({type:"hydrate_state",state:s}),We("context_restored",{source:"runtime_start",ts:Date.now()})):jo();return}if(e.type==="hydrated"){jo();return}e.type==="updated"&&We("updated")}}function mf(e){if(Ko(e),F){let s=F.getRole();pt=s,y&&(y.executionMode=s)}Sc(e);let t=(e.allowActions??!0)&&(F?F.isController():!0);ze=new Mo({allowActions:t,runtimeId:Ae,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy,registerOpenedTab:s=>F?.registerOpenedTab(s),switchToLogicalTab:s=>F?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(F?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{We("navigation_guardrail",s),Ye({kind:"status",title:"Navigation guardrail",detail:$o(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;Ja(n.port1,{getSnapshot:()=>ze.getSnapshot(),getPageData:async s=>{let a=Te||e,i=Number(s?.tabId),u=F?.getLocalLogicalTabId();if(!Number.isFinite(i)||i<=0||i===u||!F)return ze.getPageData(s);let p=F.listTabs().find(_=>_.logicalTabId===i);if(!p)return Po(a,{logicalTabId:i,external:!0},"target_tab_missing");if(p.runtimeId===Ae)return ze.getPageData(s);if(p.external&&a.externalNavigationPolicy!=="allow")return Po(a,p,"external_domain_inaccessible");if(!p.runtimeId||!F.isTabAlive(i))return Po(a,p,"target_tab_inactive");try{return await F.sendCrossTabRpc(p.runtimeId,"getPageData",s,15e3)}catch{return Po(a,p,"cross_tab_rpc_failed")}},executeTool:async s=>{let a=Te||e,i=F?.getActiveLogicalTabId(),u=F?.getLocalLogicalTabId();if(!i||i===u||!F)return ze.executeTool(s.call,s.payload);let p=F.listTabs().find(_=>_.logicalTabId===i);if(!p)return Bo(a,{logicalTabId:i,external:!0},"target_tab_missing");if(p.external&&a.externalNavigationPolicy!=="allow")return Bo(a,p,"external_tab_action_blocked");if(p.runtimeId===Ae)return ze.executeTool(s.call,s.payload);if(!p.runtimeId||!F.isTabAlive(i))return Bo(a,p,"target_tab_inactive");try{return await F.sendCrossTabRpc(p.runtimeId,"executeTool",s,2e4)}catch{return Bo(a,p,"cross_tab_execute_failed")}},executeClientTool:s=>ze.executeClientTool(s.name,s.args),listClientTools:()=>ze.listClientTools(),getTabContext:()=>{let s=F?.getLocalLogicalTabId(),a=F?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:a||s||1,runtimeId:Ae,mode:pt,url:window.location.href,title:document.title}},listSessionTabs:()=>F?.listTabs()||[]}),n.port1.start?.();let r=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),o=r;try{let s=window.location.origin,a=new URL(r).origin;if(s!==a){let i=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(i)}}catch{}if(Ie=new Worker(o,{type:"module"}),Ie.postMessage({type:"init",config:e,port:n.port2},[n.port2]),me=rc({onSend:s=>{Go(s)},onRequestControl:()=>{F?.requestControl()??!1?Ye({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Bt("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{y?.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),F?.releaseWorkflowLock(y.pendingRun.id),F?.setActiveRun(void 0),Nt(void 0),Rt("Task cancelled."),Bt("system","Task cancelled.",!0))},onNewTask:()=>{Pr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{Zo({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Ar;s&&Go(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Ar;s&&Go(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,agent:{name:e.ui?.agent?.name},mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{y&&(y.uiOpen=!0,y.uiHidden=!1,Re()),We("open")},onClose:()=>{y&&(y.uiOpen=!1,Re()),We("close")}}),Vn(),y?.uiMessages?.length&&qs(y.uiMessages),y?.timeline?.length&&Ys(y.timeline),y?.uiStatus&&me.setStatus(y.uiStatus),y?.executionMode&&me.setExecutionMode(y.executionMode,{localLogicalTabId:F?.getLocalLogicalTabId(),activeLogicalTabId:F?.getActiveLogicalTabId(),controllerRuntimeId:F?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:_c(),note:vc(y.executionMode)}),Ie.onmessage=s=>{hf(s.data||{})},F){let s=()=>{F?.registerCurrentTab(window.location.href,document.title),F?.broadcastNavigation(window.location.href,document.title)},a=history.pushState.bind(history),i=history.replaceState.bind(history);history.pushState=function(...u){let T=a(...u);return setTimeout(s,0),T},history.replaceState=function(...u){let T=i(...u);return setTimeout(s,0),T},window.addEventListener("popstate",s)}y?.uiHidden?me.hide():(me.show(),y?.uiOpen??!!e.openOnInit?me.open():me.close()),y&&(y.uiHidden=!!y.uiHidden,y.uiOpen=!!y.uiOpen,Re()),F&&(Xs(F.getState(),"remote"),Dr(F.getRole(),{localLogicalTabId:F.getLocalLogicalTabId(),activeLogicalTabId:F.getActiveLogicalTabId(),holderRuntimeId:F.getCurrentHolderRuntimeId()}))}function Or(e){if(mn)return Qo(e),mn;Pn=ac(),Ae=Bd(e.siteId),ft=gc(e),lr=Gd(e.siteId);let t=Zd(lr),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&ft?$d(e.siteId,ft):void 0,o=n||t?.sessionId||r||crypto.randomUUID();y=Lr(t,o,Ae),n&&y.sessionId!==n&&(y=Ec(n,Ae)),Te={...e,visitorId:ft||e.visitorId,sessionId:n||y.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{...e.taskContext}},y.sessionId=Te.sessionId,y.runtimeId=Ae,y.executionMode=y.executionMode||"controller",y.timeline=Mr(y.timeline),y.uiMessages=Cr(y.uiMessages),y.activeTask=Ur(y.activeTask,bn("boot")),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1),pt=y.executionMode,Re();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(En=!1,Bn=!1,mf(Te),lr&&lf(lr),rf(),mn={boot:Or,init:zs,update:Qo,shutdown:js,open:Fr,close:Jo,show:Ks,hide:Qs,send:Js,newTask:Pr,endTask:Zo,getState:Zs,registerTool:ei,on:hc},Wo.length){for(let s of Wo)bc(s);Wo.length=0}return mn}function zs(e){return Or(e)}function Qo(e){!mn||!Ie||!Te||(Te={...Te,...e,taskRouting:{...Te.taskRouting,...e.taskRouting},taskContext:{...Te.taskContext,...e.taskContext},ui:{...Te.ui,...e.ui,agent:{...Te.ui?.agent,...e.ui?.agent},panel:{...Te.ui?.panel,...e.ui?.panel}},tools:{...Te.tools,...e.tools,client:e.tools?.client??Te.tools?.client,web:{...Te.tools?.web,...e.tools?.web}}},ft=gc(Te),ft&&(Te.visitorId=ft),e.sessionId&&y?(y.sessionId=e.sessionId,Re(),Ko(Te)):(e.sessionScope||e.tabPolicy)&&Ko(Te),Sc(Te),ze&&(typeof e.allowActions=="boolean"&&ze.setAllowActions(e.allowActions&&pt==="controller"),(e.allowedDomains||e.crossDomainPolicy||e.domainScopeMode||e.externalNavigationPolicy)&&ze.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy})),Ie.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Fr():Jo()))}function js(){Vn(),Re(),Et?.markDirty(),Et?.syncNow(),Et?.stop(),Et=null,F?.stop(),F=null,Ie?.terminate(),Ie=null,me?.destroy(),me=null,ze=null,Te=null,En=!1,Bn=!1,Ae="",ft=void 0,Yo=!1,pt="controller",Ar=null,Pn=null,mn=null}function Fr(){me?.show(),me?.open(),y&&(y.uiHidden=!1,y.uiOpen=!0,Re())}function Jo(){me?.close(),y&&(y.uiOpen=!1,Re())}function Ks(){me?.show(),y&&(y.uiHidden=!1,Re())}function Qs(){me?.hide(),y&&(y.uiHidden=!0,y.uiOpen=!1,Re())}function Js(e){e?.trim()&&Go(e)}function Pr(e){if(!y)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(y.taskEpoch)||1)+1,o=bn(t);y.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),F?.releaseWorkflowLock(y.pendingRun.id)),Bn=!1,y.taskEpoch=r,y.activeTask=o,y.pendingRun=void 0,y.workerState=void 0,n&&(y.uiMessages=[],y.timeline=[],y.uiStatus=void 0,Rc()),F?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),F?.setActiveRun(void 0),F?.setWorkerContext(void 0),Rt("New task started."),Re(),Ie?.postMessage({type:"start_new_task",taskId:o.taskId}),Ye({kind:"info",title:"Started new task",detail:t,status:"info"}),We("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function Zo(e){if(!y)return;let t=e?.reason||"manual_end_task",n=Hr("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,y.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),F?.releaseWorkflowLock(y.pendingRun.id)),y.pendingRun=void 0,Vn(),Rt("Task ended. Start a new task to continue."),F?.endTask(t),F?.setActiveRun(void 0),Re(),Ye({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),We("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function Zs(){return{mode:pt,runtimeId:Ae,runtimeState:y?Ic(y):null,sharedState:F?.getState()||null,pendingTaskSuggestion:Ar}}function ei(e,t){let n=Pd(e);if(!mn||!ze||!Ie){Wo.push({def:n,handler:t});return}bc({def:n,handler:t})}function gf(e){if(!e)return;let t=String(e);if(t==="init")return"init";if(t==="boot")return"boot";if(t==="update")return"update";if(t==="shutdown")return"shutdown";if(t==="open")return"open";if(t==="close")return"close";if(t==="show")return"show";if(t==="hide")return"hide";if(t==="send")return"send";if(t==="newTask")return"newTask";if(t==="endTask")return"endTask";if(t==="getState")return"getState";if(t==="registerTool")return"registerTool";if(t==="on")return"on"}function Ac(){let e=window,t=e.rover,n=((r,...o)=>{let s=gf(r),a=s?n[s]:void 0;if(typeof a=="function")return a(...o)});if(n.boot=Or,n.init=zs,n.update=Qo,n.shutdown=js,n.open=Fr,n.close=Jo,n.show=Ks,n.hide=Qs,n.send=Js,n.newTask=Pr,n.endTask=Zo,n.getState=Zs,n.registerTool=ei,n.on=hc,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...s]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...s)}if(!mn){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),s=r.getAttribute("data-api-key");if(o&&s){let a={siteId:o,apiKey:s},i=r.getAttribute("data-allowed-domains");i&&(a.allowedDomains=i.split(",").map(p=>p.trim()).filter(Boolean));let u=r.getAttribute("data-site-key-id");u&&(a.siteKeyId=u);let T=r.getAttribute("data-worker-url");T&&(a.workerUrl=T),Or(a)}}}}Ac();return Uc(bf);})();
|
|
1052
|
+
`;let $t=document.createElement("form");$t.className="composer";let ln=document.createElement("textarea");ln.rows=1,ln.placeholder=`Ask ${t} to act on this website...`,$t.appendChild(ln);let et=document.createElement("button");et.type="submit",et.className="sendBtn",et.innerHTML='<svg viewBox="0 0 24 24"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',$t.appendChild(et);let St=document.createElement("div");St.className="resizeHandle",St.setAttribute("aria-hidden","true"),M.appendChild(O),M.appendChild(ke),M.appendChild(gt),M.appendChild($t),M.appendChild(St),u.appendChild(v),u.appendChild(M),s.appendChild(a),s.appendChild(u);let Ne=ln,un=gt.querySelector(".taskSuggestionText"),dn=gt.querySelector(".taskSuggestionBtn.primary"),Pe=gt.querySelector(".taskSuggestionBtn.secondary"),yn=new Set,Gt=new Map,Jt=[],fn="controller",_n=!1,Tn=!1,At=null,Ot=!1,ut=null,Ut=!1,he=!1,Zt=0;function qt(){Ut=!Ut,Me.classList.toggle("visible",Ut)}function Ue(){Ut=!1,Me.classList.remove("visible")}function tt(m,T=0){u.dataset.mood=m,ut!=null&&(window.clearTimeout(ut),ut=null),m==="typing"||m==="running"?(Vt.classList.add("visible"),Le.appendChild(Vt),vn()):Vt.classList.remove("visible"),T>0&&m!=="idle"&&(ut=window.setTimeout(()=>{u.dataset.mood="idle",Vt.classList.remove("visible"),ut=null},T))}function Vr(){return Le.scrollHeight-Le.scrollTop-Le.clientHeight<60}function vn(){he?mt.classList.add("visible"):(requestAnimationFrame(()=>{Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),Zt=Date.now()}),mt.classList.remove("visible"))}Le.addEventListener("scroll",()=>{Date.now()-Zt<200||(Vr()?(he=!1,mt.classList.remove("visible")):(he=!0,mt.classList.add("visible")))},{passive:!0}),mt.addEventListener("click",()=>{he=!1,Zt=Date.now(),Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),mt.classList.remove("visible")});function Ve(){Ne.disabled=fn==="observer"&&!_n}function xn(m){Ot=m,u.dataset.showDetails=m?"true":"false",It.textContent=Ot?"Hide details":"Show details";for(let T of Jt){let C=T.dataset.status,N=C==="success"||C==="error"||C==="info";T.classList.toggle("compact",!Ot&&N)}}function Gn(){u.style.display="",M.classList.remove("closing"),M.classList.add("open"),tt("idle"),e.onOpen?.(),Ne.disabled||Ne.focus()}function en(){if(Ue(),!M.classList.contains("open")){e.onClose?.();return}M.classList.remove("open"),M.classList.add("closing"),tt("idle");let m=()=>{M.classList.remove("closing"),M.removeEventListener("animationend",m)};M.addEventListener("animationend",m),e.onClose?.()}function qn(){u.style.display=""}function Yn(){en(),u.style.display="none"}function Ct(m,T){let C=ar(T);if(!C)return;let N=document.createElement("div");N.className=`entry message ${m}`;let F=document.createElement("div");F.className="bubble",m==="assistant"?C.length>280?F.appendChild(dc(C,280)):F.appendChild(Cr(C)):F.textContent=C;let Y=document.createElement("div");Y.className="stamp",Y.textContent=uc(Date.now()),N.appendChild(F),N.appendChild(Y),Le.appendChild(N),m==="user"?tt("typing",1200):m==="assistant"?tt("success",1400):tt("running",900),vn()}function tn(){for(let m of Array.from(Le.querySelectorAll(".entry.message")))m.remove()}function Yt(m){let T=Gt.get(m);if(T)return T;let C=document.createElement("div");C.className="entry trace pending";let N=document.createElement("div");N.className="traceTop";let F=document.createElement("div");F.className="traceMeta";let Y=document.createElement("span");Y.className="traceStage",Y.textContent="step";let Q=document.createElement("div");Q.className="traceTitle";let pe=document.createElement("div");pe.className="traceTs",F.appendChild(Y),F.appendChild(Q),N.appendChild(F),N.appendChild(pe);let J=document.createElement("div");return J.className="traceDetail",C.appendChild(N),C.appendChild(J),Gt.set(m,C),Jt.push(C),Le.appendChild(C),C}function fr(m,T){let C=Number(T.ts)||Date.now(),N=Id(T),F=m.querySelector(".traceTop"),Q=F.querySelector(".traceMeta").querySelector(".traceStage"),pe=F.querySelector(".traceTitle"),J=F.querySelector(".traceTs"),ee=m.querySelector(".traceDetail"),se=pc(T.title||"");pe.textContent=se.plainTitle||"Step",Q.textContent=se.stage||T.kind||"step",Q.style.display=se.stage||T.kind==="status"||T.kind==="plan"||T.kind==="thought"?"":"none",J.textContent=uc(C),ee.innerHTML="";let we=ar(T.detail||"");if(we){let ue=T.kind==="thought"?150:T.kind==="tool_start"||T.kind==="tool_result"?100:280;we.length>ue?ee.appendChild(dc(we,ue)):ee.appendChild(Cr(we)),ee.style.display=""}else ee.style.display="none";m.classList.remove("pending","success","error","info"),m.classList.add(N),m.dataset.status=N,m.dataset.kind=T.kind,m.dataset.visibility=Ld(T);let Be=N==="success"||N==="error"||N==="info";m.classList.toggle("compact",!Ot&&Be),N==="error"?tt("error",2200):N==="success"?tt("success",1200):N==="pending"&&tt("running",800)}function Xt(m){let T=ar(m.title||"");if(!T||T.toLowerCase()==="assistant update")return;let C=m.id||fc("timeline");if(m.id&&yn.has(C))return;yn.add(C);let N=Sd(m),F=N==="run"||N.startsWith("tool:")||m.kind==="tool_result"||m.kind==="status"&&Gt.has(N),Y=Yt(F?N:`${N}:${C}`);fr(Y,{...m,title:T}),T.toLowerCase()==="run completed"&&xn(!1),vn()}function Rn(){yn.clear(),Gt.clear(),Jt.length=0;for(let m of Array.from(Le.querySelectorAll(".entry.trace")))m.remove()}function Mt(m){let T=!!m?.visible;gt.classList.toggle("visible",T),un.textContent=m?.text||"Looks like a new request. Start a new task?",dn.textContent=m?.primaryLabel||"Start new",Pe.textContent=m?.secondaryLabel||"Continue"}function c(m){let T=String(m||"ready");re.textContent=T;let C=T.toLowerCase();C.includes("error")||C.includes("failed")?tt("error",1800):C==="ready"||C.includes("complete")?tt("idle"):tt("running",1e3)}function y(m){Tn=m,He.classList.toggle("visible",m),j.style.display=m?"none":""}function b(m,T){fn=m,_n=m==="observer"?T?.canComposeInObserver===!0:!0,Ve(),j.classList.remove("controller","observer"),j.classList.add(m),m==="controller"?(j.textContent="active",it.style.display="none",Ne.placeholder=`Ask ${t} to act on this website...`):(j.textContent="observer",T?.canTakeControl!==!1?it.style.display="":it.style.display="none",T?.note?Ne.placeholder=T.note:_n?Ne.placeholder="Send to take control and run here.":T?.activeLogicalTabId&&T?.localLogicalTabId&&T.activeLogicalTabId!==T.localLogicalTabId?Ne.placeholder=`Observing: ${t} is acting in tab #${T.activeLogicalTabId}`:Ne.placeholder="Observer mode. Take control to run actions here.")}function g(){ut!=null&&(window.clearTimeout(ut),ut=null),document.removeEventListener("keydown",f),i.remove(),o.remove()}v.addEventListener("click",()=>{M.classList.contains("open")?en():Gn()}),ne.addEventListener("click",()=>en()),le.addEventListener("click",m=>{m.stopPropagation(),qt()}),u.addEventListener("click",m=>{Ut&&!Me.contains(m.target)&&m.target!==le&&Ue()}),Ze.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="new_task",Mt({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),st.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="end_task",Mt({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),It.addEventListener("click",()=>{Ue(),xn(!Ot)}),it.addEventListener("click",()=>{Ue(),e.onRequestControl?.()}),He.addEventListener("click",()=>{e.onCancelRun?.()}),dn.addEventListener("click",()=>{if(At){let m=At;At=null,Mt({visible:!1}),e.onCancelRun?.(),m==="new_task"?e.onNewTask?.():m==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),Pe.addEventListener("click",()=>{if(At){At=null,Mt({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Ne.addEventListener("input",()=>{Ne.style.height="auto",Ne.style.height=`${Math.min(96,Math.max(44,Ne.scrollHeight))}px`}),Ne.addEventListener("keydown",m=>{m.key==="Enter"&&!m.shiftKey&&!m.isComposing&&(m.preventDefault(),$t.requestSubmit())}),$t.addEventListener("submit",m=>{if(m.preventDefault(),Ne.disabled)return;let T=ar(Ne.value);T&&(Mt({visible:!1}),e.onSend(T),Ne.value="",Ne.style.height="44px")}),s.addEventListener("keydown",m=>{let T=m;T.key==="Escape"&&M.classList.contains("open")&&(T.stopPropagation(),en())});let f=m=>{m.code==="Period"&&m.shiftKey&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),m.stopPropagation(),M.classList.contains("open")?en():Gn())};document.addEventListener("keydown",f);let d=null,h=m=>{if(!d)return;let T=d.startX-m.clientX,C=m.clientY-d.startY,N=Math.max(320,Math.min(window.innerWidth-16,d.startW+T)),F=Math.max(460,Math.min(window.innerHeight-16,d.startH+C));M.style.width=`${N}px`,M.style.height=`${F}px`},x=()=>{d=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",x)};if(St.addEventListener("pointerdown",m=>{window.matchMedia("(max-width: 640px)").matches||(m.preventDefault(),d={startX:m.clientX,startY:m.clientY,startW:M.getBoundingClientRect().width,startH:M.getBoundingClientRect().height},window.addEventListener("pointermove",h),window.addEventListener("pointerup",x))}),_){let m=()=>{_.style.display="none",A.style.display="grid"};_.addEventListener("error",m,{once:!0}),A.style.display="none"}if(q){let m=()=>{q.style.display="none",U.style.display="grid"};q.addEventListener("error",m,{once:!0}),U.style.display="none"}return b("controller"),xn(!1),{addMessage:Ct,clearMessages:tn,addTimelineEvent:Xt,clearTimeline:Rn,setTaskSuggestion:Mt,setStatus:c,setRunning:y,setExecutionMode:b,open:Gn,close:en,show:qn,hide:Yn,destroy:g}}var Nd="rover:shared:",Dd="rover:channel:";function Z(){return Date.now()}function Qt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function qs(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function gc(e){if(!e||typeof e!="object")return;let t=typeof e.taskId=="string"?e.taskId.trim():"";if(!t)return;let n=e.status==="completed"||e.status==="ended"||e.status==="running"?e.status:"running";return{taskId:t,status:n,startedAt:Number(e.startedAt)||Z(),lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?e.boundaryReason:void 0,endedAt:Number(e.endedAt)||void 0}}function Od(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function mc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Od(r);o!==void 0&&n.push(o)}return n}function bc(e){if(!e||typeof e!="object")return;let t=s=>s.slice(-80).map(i=>({role:typeof i?.role=="string"?i.role:"assistant",content:typeof i?.content=="string"?i.content:""})).filter(i=>!!i.content),n=Array.isArray(e.history)?t(e.history):[],r=mc(e.plannerHistory,40),o=mc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||Z()}}function Ys(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:Z(),lease:void 0,tabs:[],nextLogicalTabId:1,activeLogicalTabId:void 0,uiMessages:[],timeline:[],uiStatus:void 0,activeRun:void 0,taskEpoch:1,task:void 0,workerContext:void 0,workflowLock:void 0}}function cr(e,t,n){let r=Ys(t,n);if(!e||typeof e!="object")return r;let o={...r,version:2,siteId:t,sessionId:n,seq:Math.max(1,Number(e.seq)||1),updatedAt:Number(e.updatedAt)||Z(),tabs:Array.isArray(e.tabs)?e.tabs.map(a=>({logicalTabId:Math.max(1,Number(a?.logicalTabId)||0),runtimeId:typeof a?.runtimeId=="string"?a.runtimeId:void 0,url:String(a?.url||""),title:typeof a?.title=="string"?a.title:void 0,openedAt:Number(a?.openedAt)||Z(),updatedAt:Number(a?.updatedAt)||Z(),external:!!a?.external,openerRuntimeId:typeof a?.openerRuntimeId=="string"?a.openerRuntimeId:void 0})).filter(a=>!!a.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(a=>({id:String(a?.id||Qt("msg")),role:a?.role==="user"||a?.role==="assistant"||a?.role==="system"?a.role:"system",text:String(a?.text||""),ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(a=>({id:String(a?.id||Qt("timeline")),kind:String(a?.kind||"status"),title:String(a?.title||"Step"),detail:typeof a?.detail=="string"?a.detail:void 0,status:a?.status==="pending"||a?.status==="success"||a?.status==="error"||a?.status==="info"?a.status:void 0,ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:gc(e.task),workerContext:bc(e.workerContext),uiStatus:typeof e.uiStatus=="string"?e.uiStatus:void 0,activeRun:e.activeRun&&typeof e.activeRun=="object"?{runId:String(e.activeRun.runId||""),text:String(e.activeRun.text||""),runtimeId:String(e.activeRun.runtimeId||""),startedAt:Number(e.activeRun.startedAt)||Z(),updatedAt:Number(e.activeRun.updatedAt)||Z()}:void 0,lease:e.lease&&typeof e.lease=="object"&&e.lease.holderRuntimeId?{holderRuntimeId:String(e.lease.holderRuntimeId),expiresAt:Number(e.lease.expiresAt)||0,updatedAt:Number(e.lease.updatedAt)||Z()}:void 0,workflowLock:e.workflowLock&&typeof e.workflowLock=="object"&&e.workflowLock.runtimeId&&e.workflowLock.runId?{runtimeId:String(e.workflowLock.runtimeId),runId:String(e.workflowLock.runId),lockedAt:Number(e.workflowLock.lockedAt)||Z(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,i=new Set;return o.tabs=o.tabs.filter(a=>i.has(a.logicalTabId)?!1:(i.add(a.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var Oo=class Oo{constructor(t){$(this,"siteId");$(this,"sessionId");$(this,"runtimeId");$(this,"leaseMs");$(this,"heartbeatMs");$(this,"maxMessages");$(this,"maxTimeline");$(this,"onRoleChange");$(this,"onStateChange");$(this,"onSwitchRequested");$(this,"key");$(this,"channelName");$(this,"state");$(this,"channel",null);$(this,"heartbeatTimer",null);$(this,"storageHandler",null);$(this,"localLogicalTabId");$(this,"closing",!1);$(this,"started",!1);$(this,"pendingRpcRequests",new Map);$(this,"rpcRequestHandler");$(this,"lastNotifiedRole");$(this,"roleChangeTimer",null);this.siteId=t.siteId,this.sessionId=t.sessionId,this.runtimeId=t.runtimeId,this.leaseMs=Math.max(4e3,Number(t.leaseMs)||12e3),this.heartbeatMs=Math.max(800,Number(t.heartbeatMs)||2e3),this.maxMessages=Math.max(40,Number(t.maxMessages)||220),this.maxTimeline=Math.max(40,Number(t.maxTimeline)||280),this.onRoleChange=t.onRoleChange,this.onStateChange=t.onStateChange,this.onSwitchRequested=t.onSwitchRequested,this.key=`${Nd}${this.siteId}:${this.sessionId}`,this.channelName=`${Dd}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,s=Z(),i=t.tabs.length;t.tabs=t.tabs.filter(a=>a.runtimeId?a.runtimeId===this.runtimeId?!0:s-Math.max(a.updatedAt||0,a.openedAt||0)<=45e3:r&&a.openerRuntimeId===this.runtimeId?!1:a.external?o?!1:s-Math.max(a.updatedAt||0,a.openedAt||0)<=12e4:s-Math.max(a.updatedAt||0,a.openedAt||0)<=6e5),i!==t.tabs.length&&(t.activeLogicalTabId&&!t.tabs.some(a=>a.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=this.localLogicalTabId||t.tabs[0]?.logicalTabId),t.nextLogicalTabId<=(t.tabs.at(-1)?.logicalTabId??0)&&(t.nextLogicalTabId=t.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1))}start(){this.started||(this.started=!0,this.mutate("local",t=>{this.pruneDetachedTabs(t,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),this.registerCurrentTab(window.location.href,document.title||void 0),this.claimLease(!1),this.state.task||this.mutate("local",t=>{t.task={taskId:Qt("task"),status:"running",startedAt:Z(),boundaryReason:"session_start"}}),typeof BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(this.channelName),this.channel.onmessage=t=>{let n=t.data;if(!(!n||typeof n!="object")){if(n.type==="state"&&n.state){let r=cr(n.state,this.siteId,this.sessionId);this.applyIncomingState(r)}n.type==="switch_request"&&n.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(n.logicalTabId)||0),n.type==="rpc_request"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcRequest(n),n.type==="rpc_response"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcResponse(n),n.type==="tab_navigated"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteNavigation(n),n.type==="tab_closing"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteTabClosing(n)}}),this.storageHandler=t=>{if(!(t.key!==this.key||!t.newValue))try{let n=cr(JSON.parse(t.newValue),this.siteId,this.sessionId);this.applyIncomingState(n)}catch{}},window.addEventListener("storage",this.storageHandler),this.heartbeatTimer=window.setInterval(()=>{this.heartbeat()},this.heartbeatMs),this.notifyRoleChange(),this.onStateChange?.(this.state,"local"))}stop(){if(this.started){this.started=!1,this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.roleChangeTimer!=null&&(window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.channel&&(this.channel.close(),this.channel=null);for(let[,t]of this.pendingRpcRequests)window.clearTimeout(t.timer),t.reject(new Error("SessionCoordinator stopped"));this.pendingRpcRequests.clear(),this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.lease?.holderRuntimeId===this.runtimeId&&(t.lease=void 0),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)})}}isController(){let t=this.state.lease;return!t||t.expiresAt<=Z()?!1:t.holderRuntimeId===this.runtimeId}getRole(){return this.isController()?"controller":"observer"}getLocalLogicalTabId(){return this.localLogicalTabId}getActiveLogicalTabId(){return this.state.activeLogicalTabId}getCurrentHolderRuntimeId(){return this.state.lease?.holderRuntimeId}getState(){return this.state}getTaskEpoch(){return this.state.taskEpoch}getTask(){return this.state.task}getWorkerContext(){return this.state.workerContext}syncTask(t,n){this.mutate("local",r=>{n&&Number.isFinite(n)&&n>r.taskEpoch&&(r.taskEpoch=Math.max(1,Math.trunc(n))),t&&(r.task=gc(t)||r.task)})}hydrateExternalState(t){let n=cr(t,this.siteId,this.sessionId);this.pruneDetachedTabs(n,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0});let r=this.state.seq,o=this.state.updatedAt;this.applyIncomingState(n);let s=this.state.seq!==r||this.state.updatedAt!==o;if(!s&&this.state.tabs.some(a=>a.runtimeId?!1:a.external?!0:a.openerRuntimeId===this.runtimeId)){let a=this.state.tabs.length;this.mutate("local",u=>{this.pruneDetachedTabs(u,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),s=this.state.tabs.length!==a}return s?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){let t=Z();return this.state.tabs.filter(n=>n.runtimeId?n.runtimeId===this.runtimeId?!0:t-Math.max(n.updatedAt||0,n.openedAt||0)<=45e3:n.external?t-Math.max(n.updatedAt||0,n.openedAt||0)<=12e4:t-Math.max(n.updatedAt||0,n.openedAt||0)<=6e5)}pruneTabs(t){this.mutate("local",n=>{this.pruneDetachedTabs(n,t)})}startNewTask(t){let n=Number(t.startedAt)||Z(),r={taskId:String(t.taskId||Qt("task")),status:t.status==="completed"||t.status==="ended"?t.status:"running",startedAt:n,lastUserAt:Number(t.lastUserAt)||n,lastAssistantAt:Number(t.lastAssistantAt)||void 0,boundaryReason:t.boundaryReason,endedAt:void 0};return this.mutate("local",o=>{o.taskEpoch=Math.max(1,Number(o.taskEpoch)||1)+1,o.task=r,o.uiMessages=[],o.timeline=[],o.uiStatus=void 0,o.activeRun=void 0,o.workerContext=void 0,this.pruneDetachedTabs(o,{dropAllDetachedExternal:!0})}),r}endTask(t){let n;return this.mutate("local",r=>{r.task&&(r.task={...r.task,status:"ended",boundaryReason:t||r.task.boundaryReason,endedAt:Z()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=Z()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:Qt("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n),r.task.status==="ended"&&(r.task.status="running",r.task.endedAt=void 0)})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=bc(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||Qt("msg"),role:t.role,text:String(t.text||""),ts:Number(t.ts)||Z(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.uiMessages.push(n),r.uiMessages.length>this.maxMessages&&(r.uiMessages=r.uiMessages.slice(-this.maxMessages)),r.task||(r.task={taskId:Qt("task"),status:"running",startedAt:n.ts,boundaryReason:"implicit"}),n.role==="user"?r.task.lastUserAt=n.ts:n.role==="assistant"&&(r.task.lastAssistantAt=n.ts)}),n}appendTimeline(t){let n={id:t.id||Qt("timeline"),kind:String(t.kind||"status"),title:String(t.title||"Step"),detail:t.detail?String(t.detail):void 0,status:t.status,ts:Number(t.ts)||Z(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.timeline.push(n),r.timeline.length>this.maxTimeline&&(r.timeline=r.timeline.slice(-this.maxTimeline))}),n}clearTimeline(){this.mutate("local",t=>{t.timeline=[]})}setActiveRun(t){this.mutate("local",n=>{if(!t){n.activeRun=void 0;return}n.activeRun={runId:t.runId,text:t.text,runtimeId:this.runtimeId,startedAt:n.activeRun?.runId===t.runId?n.activeRun.startedAt:Z(),updatedAt:Z()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:Qt("task"),status:"running",startedAt:Z()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=qs(t),o;return this.mutate("local",s=>{let i=s.tabs.find(a=>a.runtimeId===this.runtimeId);if(i)i.url=r||i.url,i.title=n||i.title,i.updatedAt=Z(),o=i.logicalTabId;else{let a=s.tabs.find(u=>!u.runtimeId&&u.url===r&&Z()-u.openedAt<18e4);if(a)a.runtimeId=this.runtimeId,a.title=n||a.title,a.updatedAt=Z(),o=a.logicalTabId;else{let u=s.nextLogicalTabId++;s.tabs.push({logicalTabId:u,runtimeId:this.runtimeId,url:r,title:n,openedAt:Z(),updatedAt:Z(),external:!1}),o=u}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=qs(t.url),r=0;return this.mutate("local",o=>{let s=o.tabs.find(i=>!i.runtimeId&&!!i.external&&i.url===n);if(s){s.title=t.title||s.title,s.updatedAt=Z(),s.openerRuntimeId=t.openerRuntimeId||s.openerRuntimeId,r=s.logicalTabId;return}r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:Z(),updatedAt:Z(),external:!!t.external,openerRuntimeId:t.openerRuntimeId})}),{logicalTabId:r}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",r=>{let o=r.tabs.find(s=>s.logicalTabId===t);if(!o){n={ok:!1,reason:`Tab ${t} not found`};return}if(r.activeLogicalTabId=t,o.runtimeId&&o.runtimeId!==this.runtimeId){r.lease={holderRuntimeId:o.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},this.channel&&this.channel.postMessage({type:"switch_request",logicalTabId:t,targetRuntimeId:o.runtimeId,sourceRuntimeId:this.runtimeId}),n={ok:!0,delegated:!0};return}if(!o.runtimeId){n={ok:!1,reason:`Tab ${t} is not attached to an active Rover runtime yet`};return}r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((s,i)=>{if(!this.channel){i(new Error("BroadcastChannel not available"));return}let a=Qt("rpc"),u=window.setTimeout(()=>{this.pendingRpcRequests.delete(a),i(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(a,{resolve:s,reject:i,timer:u}),this.channel.postMessage({type:"rpc_request",requestId:a,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:Z()})})}setRpcRequestHandler(t){this.rpcRequestHandler=t}broadcastNavigation(t,n){this.channel&&this.channel.postMessage({type:"tab_navigated",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId,url:t,title:n})}broadcastClosing(){this.closing=!0,this.channel&&(this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)}),this.channel.postMessage({type:"tab_closing",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId}))}isTabAlive(t){let n=this.state.tabs.find(r=>r.logicalTabId===t);return n?n.updatedAt>Z()-2*this.heartbeatMs:!1}acquireWorkflowLock(t){let n=!1;return this.mutate("local",r=>{let o=r.workflowLock;if(o&&o.runtimeId!==this.runtimeId&&o.expiresAt>Z()){let s=r.tabs.find(a=>a.runtimeId===o.runtimeId);if(s&&s.updatedAt>Z()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:Z(),expiresAt:Z()+this.leaseMs*5},n=!0}),n}clearActiveRunRuntimeId(t){this.mutate("local",n=>{n.activeRun&&n.activeRun.runId===t&&(n.activeRun.runtimeId="")})}releaseWorkflowLock(t){this.mutate("local",n=>{n.workflowLock&&n.workflowLock.runId===t&&(n.workflowLock=void 0)})}isWorkflowLocked(){let t=this.state.workflowLock;return!t||t.runtimeId===this.runtimeId?!1:t.expiresAt>Z()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=Z()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:s}=t;if(!this.rpcRequestHandler){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:"No RPC handler registered",code:"NO_HANDLER"}});return}try{let i=await this.rpcRequestHandler({method:o,params:s});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:i})}catch(i){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:i?.message||String(i)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:s}=t,i=this.pendingRpcRequests.get(n);i&&(this.pendingRpcRequests.delete(n),window.clearTimeout(i.timer),r?i.resolve(o):i.reject(new Error(s?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",s=>{let i=s.tabs.find(a=>a.runtimeId===n);i&&(i.url=r||i.url,i.title=o||i.title,i.updatedAt=Z())})}handleRemoteTabClosing(t){let{runtimeId:n}=t;this.mutate("local",r=>{r.tabs=r.tabs.filter(o=>o.runtimeId!==n),r.lease?.holderRuntimeId===n&&(r.lease=void 0),r.workflowLock?.runtimeId===n&&(r.workflowLock=void 0),r.activeRun?.runtimeId===n&&(r.activeRun=void 0),r.activeLogicalTabId&&!r.tabs.some(o=>o.logicalTabId===r.activeLogicalTabId)&&(r.activeLogicalTabId=void 0)}),this.notifyRoleChange()}heartbeat(){if(this.closing)return;let t=qs(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(a=>a.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=Z();else{let a=r.nextLogicalTabId++;r.tabs.push({logicalTabId:a,runtimeId:this.runtimeId,url:t,title:n,openedAt:Z(),updatedAt:Z(),external:!1})}let s=r.lease;(!s||s.expiresAt<=Z()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=Z()+this.leaseMs*5),this.pruneDetachedTabs(r)}),this.notifyRoleChange()}reloadFromStorage(){let t=this.loadState();return(t.seq>this.state.seq||t.seq===this.state.seq&&t.updatedAt>this.state.updatedAt)&&(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote")),this.closing=!1,this.state}claimLease(t){let n=!1;return this.mutate("local",r=>{let o=r.lease,s=!o||o.expiresAt<=Z();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId),n=!0)}),this.notifyRoleChange(),n}notifyRoleChange(){this.getRole()!==this.lastNotifiedRole&&(this.roleChangeTimer!=null&&window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=window.setTimeout(()=>{this.roleChangeTimer=null;let n=this.getRole();n!==this.lastNotifiedRole&&(this.lastNotifiedRole=n,this.onRoleChange?.(n,{localLogicalTabId:this.localLogicalTabId,activeLogicalTabId:this.state.activeLogicalTabId,holderRuntimeId:this.state.lease?.holderRuntimeId}))},Oo.ROLE_CHANGE_DEBOUNCE_MS))}syncLocalLogicalTabId(){let t=this.state.tabs.find(n=>n.runtimeId===this.runtimeId);this.localLogicalTabId=t?.logicalTabId}mutate(t,n){if(t==="local")try{let o=window.localStorage.getItem(this.key);if(o){let s=cr(JSON.parse(o),this.siteId,this.sessionId);(s.seq>this.state.seq||s.seq===this.state.seq&&s.updatedAt>this.state.updatedAt)&&(this.state=s)}}catch{}let r=cr(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=Z(),this.state=r,this.syncLocalLogicalTabId(),t==="local"&&(this.persistState(),this.channel&&this.channel.postMessage({type:"state",sourceRuntimeId:this.runtimeId,state:this.state})),this.onStateChange?.(this.state,t)}applyIncomingState(t){t&&(t.seq<this.state.seq||t.seq===this.state.seq&&t.updatedAt<=this.state.updatedAt||(this.pruneDetachedTabs(t),this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Ys(this.siteId,this.sessionId);let n=JSON.parse(t);return cr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Ys(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(Oo,"ROLE_CHANGE_DEBOUNCE_MS",200);var Do=Oo;var Ud="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function lr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Ec(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function Fd(e){let t=Number(e.sharedState?.seq||0),n=Array.isArray(e.sharedState?.uiMessages)?e.sharedState.uiMessages.length:0,r=Number(e.runtimeState?.updatedAt||0),o=Array.isArray(e.runtimeState?.uiMessages)?e.runtimeState.uiMessages.length:0;return[e.sessionId,lr(e.updatedAt,0),t,n,r,o].join(":")}function Hd(e){let t=(e||Ud).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Xs(e,t){let n=new Error(e);return n.details=t,n}var Uo=class{constructor(t){$(this,"endpoint");$(this,"token");$(this,"siteId");$(this,"visitorId");$(this,"ttlHours");$(this,"flushIntervalMs");$(this,"pullIntervalMs");$(this,"minFlushIntervalMs");$(this,"shouldWrite");$(this,"buildCheckpoint");$(this,"onCheckpoint");$(this,"onStateChange");$(this,"onError");$(this,"started",!1);$(this,"dirty",!1);$(this,"flushTimer",null);$(this,"pullTimer",null);$(this,"lastFlushAt",0);$(this,"lastPullAt",0);$(this,"lastUploadedRevision","");$(this,"lastAppliedRemoteUpdatedAt",0);$(this,"pushInFlight",!1);$(this,"pullInFlight",!1);$(this,"state","active");let n=String(t.authToken||t.apiKey||"").trim();if(!n)throw Xs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=Hd(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(lr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(lr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(lr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(lr(t.minFlushIntervalMs,2500))),this.shouldWrite=t.shouldWrite||(()=>!0),this.buildCheckpoint=t.buildCheckpoint,this.onCheckpoint=t.onCheckpoint,this.onStateChange=t.onStateChange,this.onError=t.onError}start(){this.started||(this.started=!0,this.setState("active"),this.flushTimer=window.setInterval(()=>{this.flush(!1)},this.flushIntervalMs),this.pullTimer=window.setInterval(()=>{this.pull(!1)},this.pullIntervalMs),this.pull(!0))}stop(){this.started&&(this.started=!1,this.flushTimer!=null&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.pullTimer!=null&&(window.clearInterval(this.pullTimer),this.pullTimer=null),this.flush(!0))}markDirty(){this.dirty=!0}syncNow(){this.flush(!0),this.pull(!0)}async flush(t){if(this.pushInFlight||this.state==="paused_auth"||!this.dirty&&!t||!this.shouldWrite()||!t&&Date.now()-this.lastFlushAt<this.minFlushIntervalMs)return;let n=this.buildCheckpoint();if(!n)return;let r=Fd(n);if(!t&&r===this.lastUploadedRevision){this.dirty=!1;return}this.pushInFlight=!0;try{let o=await this.callExtensionRouter("roverSessionCheckpointUpsert",{siteId:this.siteId,visitorId:this.visitorId,sessionId:n.sessionId,ttlHours:this.ttlHours,updatedAt:n.updatedAt,checkpoint:n});this.lastFlushAt=Date.now(),o?.saved&&(this.dirty=!1,this.lastUploadedRevision=r),o?.stale&&o?.checkpoint&&typeof o.checkpoint=="object"&&(this.applyRemoteCheckpoint(o.checkpoint,"push_stale"),this.dirty=!1),this.setState("active")}catch(o){this.handleCheckpointError(o,"roverSessionCheckpointUpsert")}finally{this.pushInFlight=!1}}async pull(t){if(!this.pullInFlight&&this.state!=="paused_auth"&&!(!t&&Date.now()-this.lastPullAt<this.pullIntervalMs)){this.pullInFlight=!0;try{let n=await this.callExtensionRouter("roverSessionCheckpointGet",{siteId:this.siteId,visitorId:this.visitorId});if(this.lastPullAt=Date.now(),!n?.found||!n?.checkpoint||typeof n.checkpoint!="object")return;this.applyRemoteCheckpoint(n.checkpoint,"pull"),this.setState("active")}catch(n){this.handleCheckpointError(n,"roverSessionCheckpointGet")}finally{this.pullInFlight=!1}}}applyRemoteCheckpoint(t,n){let r=Math.max(0,Math.floor(lr(t?.updatedAt,0)));r<=this.lastAppliedRemoteUpdatedAt||(this.lastAppliedRemoteUpdatedAt=r,this.onCheckpoint(t,n))}async callExtensionRouter(t,n){let r=await fetch(this.endpoint,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({action:t,data:n})});if(!r.ok){let s;try{s=await r.json()}catch{let i=await r.text().catch(()=>"");s=i?{error:Ec(i,2e3)}:void 0}throw Xs(`Checkpoint HTTP ${r.status}`,{action:t,status:r.status,payload:s})}let o=await r.json();if(o?.success===!1)throw Xs("Checkpoint extensionRouter returned success=false",{action:t,status:r.status,payload:o});return o?.data}setState(t,n){this.state!==t&&(this.state=t,this.onStateChange?.(t,n||{}))}handleCheckpointError(t,n){let r=this.normalizeCheckpointError(t),o=this.isAuthFailure(r);o&&this.setState("paused_auth",{reason:"auth_failed",action:n,code:r.code,message:r.message}),this.onError?.(t,{action:n,state:this.state,code:r.code,message:r.message,status:r.status,paused:o})}normalizeCheckpointError(t){let n=t,r=n?.details,o=r?.payload||r?.response||r,s=o?.errorCode||o?.errorDetails?.code||o?.error?.code||o?.code,i=o?.error||o?.errorDetails?.message||o?.error?.message||n?.message||"Checkpoint request failed",a=Number(r?.status);return{code:typeof s=="string"?s:void 0,message:Ec(i,1e3),status:Number.isFinite(a)?a:void 0}}isAuthFailure(t){let n=String(t.code||"").toUpperCase();return n==="INVALID_API_KEY"||n==="MISSING_API_KEY"||n==="UNAUTHENTICATED"||n==="PERMISSION_DENIED"?!0:t.status===401||t.status===403}};var Pd="rover-runtime-state-db",Fo="runtime-state",zs=class{read(t){try{let n=window.sessionStorage.getItem(t);return n?JSON.parse(n):null}catch{return null}}write(t,n){try{window.sessionStorage.setItem(t,JSON.stringify(n))}catch{}}remove(t){try{window.sessionStorage.removeItem(t)}catch{}}},Ks=class{constructor(){$(this,"dbPromise",null)}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Error("indexedDB unavailable"));return}let r=indexedDB.open(Pd,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Fo)||o.createObjectStore(Fo)},r.onsuccess=()=>{t(r.result)},r.onerror=()=>{n(r.error||new Error("indexedDB open failed"))}}).catch(t=>{throw this.dbPromise=null,t}),this.dbPromise)}async withStore(t,n){let r=await this.openDb();return new Promise((o,s)=>{let i=r.transaction(Fo,t),a=i.objectStore(Fo);n(a,o,s),i.onerror=()=>{s(i.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let s=n.get(t);s.onsuccess=()=>{let i=s.result;r(i??null)},s.onerror=()=>{o(s.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,s)=>{let i=r.put(n,t);i.onsuccess=()=>o(),i.onerror=()=>{s(i.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let s=n.delete(t);s.onsuccess=()=>r(),s.onerror=()=>{o(s.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function wc(){let e=new zs,t=new Ks;return{readSync:n=>e.read(n),readAsync:async n=>t.read(n),write:(n,r)=>{e.write(n,r),t.write(n,r)},remove:n=>{e.remove(n),t.remove(n)}}}var Js=1,Bd="rover:runtime:",Wd="rover:runtime-id:",xc="rover:visitor-id:",js=160,Qs=240,Rc=80,Ko=40,Vd=8e3,$d=15*6e4,Gd=12,qd=3600*24*365,Yd=1,Xd=3e3,zd=9e4,Kd=12e3,jd=30,jo=240,gn=null,ze=null,Ie=null,ge=null,ce=null,ur=null,w=null,Bn=null,Se="",H=null,wt=null,$o=null,Et=[],Go=!1,dr=!1,kc=0,lt,Qo=!1,pt="controller",wn=!1,Wn=!1,Pn=null,yc=!1,Mr=null,Ho="",Ic,cn=new Map,Qd=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),qo=[],Yo=new Map;function Ce(e,t){af(e,t);let n=Yo.get(e);if(n)for(let r of n)try{r(t)}catch{}}function Sc(e,t){Yo.has(e)||Yo.set(e,new Set);let n=Yo.get(e);return n.add(t),()=>{n.delete(t)}}function Jd(e){return typeof e=="string"?{name:e}:e}function bn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Zd(e){let t=`${Wd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=bn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return bn("runtime")}}function Jo(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Po(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function Ac(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function _c(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${qd}; samesite=lax${r}`,Ac(e)===t}catch{return!1}}function ef(e){let t=String(e||"").trim().toLowerCase();if(!t||t==="localhost"||/^\d{1,3}(\.\d{1,3}){3}$/.test(t))return[];let n=t.split(".").filter(Boolean);if(n.length<2)return[];let r=[];for(let o=n.length-2;o>=0;o-=1)r.push(`.${n.slice(o).join(".")}`);return r}function tf(e,t){let n=`rover_vid_${Jo(e)}`;for(let r of ef(window.location.hostname))if(_c(n,t,r))return;_c(n,t)}function Bo(e,t){let n=`${xc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}tf(e,t)}function Cc(e){let t=Po(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${xc}${e.siteId}`,r=`rover_vid_${Jo(e.siteId)}`,o=Po(Ac(r)||"");if(o)return Bo(e.siteId,o),o;try{let i=Po(window.localStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}try{let i=Po(window.sessionStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}let s=`v_${Jo(`${e.siteId}:${bn("visitor")}`)}_${Date.now().toString(36)}`;return Bo(e.siteId,s),s}function nf(e,t){return`visitor-${Jo(`${e}:${t}`)}`}function Mc(e){!ze||!Ie||(ze.registerTool(e.def,e.handler),Ie.postMessage({type:"register_tool",tool:e.def}))}function rf(e){return`${Bd}${e}`}function En(e="session_start"){let t=Date.now();return{taskId:bn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Lc(e,t){return{version:Js,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:En(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function Ke(e,t=Vd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Xo(e){if(e!=null){if(typeof e=="string")return Ke(e,1200);try{return Ke(JSON.stringify(e),1200)}catch{try{return Ke(String(e),1200)}catch{return}}}}function rs(e){let t=e?.telemetry,n=Number(t?.sampleRate),r=Number.isFinite(n)?Math.min(1,Math.max(0,n)):1,o=Number(t?.flushIntervalMs),s=Number.isFinite(o)?Math.min(6e4,Math.max(2e3,Math.floor(o))):Kd,i=Number(t?.maxBatchSize),a=Number.isFinite(i)?Math.min(80,Math.max(1,Math.floor(i))):jd;return{enabled:t?.enabled!==!1,sampleRate:r,flushIntervalMs:s,maxBatchSize:a,includePayloads:t?.includePayloads===!0}}function Zs(e){return!(!e||!rs(e).enabled||!(e.authToken||e.apiKey))}function Tc(e){if(e!=null){if(typeof e=="string")return Ke(e,260);if(typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return{type:"array",length:e.length};if(typeof e=="object"){let n={type:"object",keys:Object.keys(e).slice(0,20)},r=["code","message","stage","status","reason","taskId","runId","policyAction"];for(let o of r){let s=e?.[o];s!=null&&(typeof s=="string"?n[o]=Ke(s,180):(typeof s=="number"||typeof s=="boolean")&&(n[o]=s))}return n}}}function of(e,t){if(!t)return Tc(e);let n=Uc(e);if(n!=null)return typeof n=="string"?Ke(n,1e3):typeof n=="number"||typeof n=="boolean"?n:Array.isArray(n)?{type:"array",length:n.length}:typeof n=="object"?n:Tc(e)}function ei(){$o&&(clearInterval($o),$o=null)}function sf(e){let t=(e.apiBase||"https://us-central1-rtrvr-extension-functions.cloudfunctions.net").replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}async function os(e=!1){if(Go||dr)return;if(!ce||!Zs(ce)){Et=[];return}if(!Et.length)return;let t=rs(ce),n=String(ce.authToken||ce.apiKey||"").trim();if(!n)return;let r=Et.splice(0,t.maxBatchSize);if(r.length){Go=!0;try{let o=await fetch(sf(ce),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverTelemetryIngest",data:{siteId:ce.siteId,runtimeId:Se,sessionId:w?.sessionId,visitorId:lt,flushReason:e?"manual":"interval",sdkVersion:"rover_sdk_v1",pageUrl:window.location.href,userAgent:navigator.userAgent,sampleRate:t.sampleRate,events:r}})});if(!o.ok){o.status===401||o.status===403?dr=!0:Et=[...r,...Et].slice(-jo);return}let s=await o.json().catch(()=>{});if(s?.success===!1){let i=String(s?.errorCode||s?.errorDetails?.code||"").toUpperCase();(i==="INVALID_API_KEY"||i==="MISSING_API_KEY"||i==="UNAUTHENTICATED"||i==="PERMISSION_DENIED")&&(dr=!0);return}}catch{Et=[...r,...Et].slice(-jo)}finally{Go=!1}}}function ti(e){if(ei(),dr=!1,!Zs(e)){Et=[];return}let t=rs(e);$o=setInterval(()=>{os(!1)},t.flushIntervalMs)}function af(e,t){if(!Zs(ce)||dr)return;let n=rs(ce);if(n.sampleRate<1&&Math.random()>n.sampleRate)return;let r={name:e,ts:Date.now(),seq:++kc,payload:of(t,n.includePayloads)};Et.push(r),Et.length>jo&&(Et=Et.slice(-jo)),Et.length>=n.maxBatchSize&&os(!1)}function Wo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",s=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),i=String(n||"").trim(),a=i?` Reason: ${i}.`:"",u=t?.external?`This external tab is tracked in virtual mode only. Live DOM control and accessibility-tree access are unavailable here.${a}`:`This tab is currently not attached to an active Rover runtime. Switch to a live tab or reopen it.${a}`;return{url:o,title:s,contentType:"text/html",content:u,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function Vo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",s=t?.external?`Tab ${r} is external to the active runtime and cannot be controlled directly.`:`Tab ${r} is not attached to an active Rover runtime.`,i=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:s,allowFallback:!0,output:{success:!1,error:{code:i,message:s,missing:[],next_action:t?.external?"Use open_new_tab for external context or continue on an in-scope tab.":"Switch to an active tab and retry.",retryable:!1},blocked_url:o||void 0,logical_tab_id:r||void 0,external:!!t?.external,policy_action:t?.external?e.externalNavigationPolicy||"open_new_tab_notice":void 0,reason:n},errorDetails:{code:i,message:s,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function cf(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function lf(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function uf(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function df(e,t){if(!e)return!0;let n=e.trim();return!!(t&&n.toLowerCase()===t.trim().toLowerCase()||/^complexity score\b/i.test(n)||/\btool loop$/i.test(n)||/^calling \w[\w\s]*(workflow|sub-agent)$/i.test(n))}function ff(){return w?.pendingRun?.id}function Nc(){let e=H?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Se)}function Dc(){return!Nc()}function Oc(e){if(e==="observer")return Nc()?"Observing active run in another tab...":"Send to take control and run here."}function pf(e){let t=typeof e?.type=="string"?e.type:"";if(!Qd.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=ff();if(t==="run_started")return!n||!r?!1:r!==n;if(!n)return!1;if(t==="run_completed"){if(!r){let o=H?.getState()?.activeRun?.runId;return!(o&&o===n)}return r!==n}return r?r!==n:!0}function hf(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1};let t=e.needsUserInput===!0;return{taskComplete:e.taskComplete===!0&&!t,needsUserInput:t}}function mf(e){if(e&&cn.has(e))return cn.get(e);if(w?.uiMessages?.length)for(let t=w.uiMessages.length-1;t>=0;t-=1){let n=w.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function gf(e){return Bn?Bn.readSync(e):null}function Uc(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function Fc(e){if(!e||typeof e!="object")return null;let t=e.role,n=e.content;return typeof t!="string"||typeof n!="string"||!n?null:{role:t,content:n}}function Zo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Uc(r);o!==void 0&&n.push(o)}return n}async function bf(e){if(!Bn)return null;try{return await Bn.readAsync(e)}catch{return null}}function Lr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-js)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:bn("msg"),role:r,text:Ke(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Nr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Qs)){let r=Ke(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),s=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:bn("timeline"),kind:o,title:r,detail:n?.detail?Ke(String(n.detail),1200):void 0,status:s==="pending"||s==="success"||s==="error"||s==="info"?s:void 0,ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Vn(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.history)?e.history:[],n=Array.isArray(e.plannerHistory)?e.plannerHistory:[],r=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],o=t.slice(-Rc).map(a=>Fc(a)).filter(a=>!!a),s=Zo(n,Ko),i=Zo(r,Ko*2);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:o,plannerHistory:s,agentPrevSteps:i,lastToolPreviousSteps:i,updatedAt:Number(e.updatedAt)||Date.now()}}function Dr(e,t,n){if(!e||typeof e!="object")return Lc(t,n);let r=En(),o=Hr(e.activeTask,r);return{version:Js,sessionId:typeof e.sessionId=="string"&&e.sessionId?e.sessionId:t,runtimeId:typeof e.runtimeId=="string"&&e.runtimeId?e.runtimeId:n,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:o,lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:typeof e.lastRoutingDecision.reason=="string"?Ke(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Hr(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,r=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:r,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?Ke(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function Ef(e,t){return Hr(e,t)}function Hc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-Rc).map(t=>Fc(t)).filter(t=>!!t):[],plannerHistory:Zo(e.plannerHistory,Ko),agentPrevSteps:Zo(e.agentPrevSteps,Ko*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Or(e){if(!e||typeof e!="object")return;let t=typeof e.id=="string"&&e.id.trim()?e.id.trim():void 0,n=typeof e.text=="string"?e.text.trim():"";if(!(!t||!n))return{id:t,text:n,startedAt:Number(e.startedAt)||Date.now(),attempts:Math.max(0,Number(e.attempts)||0),autoResume:e.autoResume!==!1}}function Re(){if(!(!w||!ur))try{w.updatedAt=Date.now(),Bn?.write(ur,w),Qo||wt?.markDirty()}catch{}}function wf(){if(yc)return;yc=!0;let e=()=>{w?.pendingRun?.autoResume&&H?.clearActiveRunRuntimeId(w.pendingRun.id),H?.broadcastClosing(),w?.pendingRun&&H?.releaseWorkflowLock(w.pendingRun.id),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),H?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(H&&(H.reloadFromStorage(),H.registerCurrentTab(window.location.href,document.title||void 0),H.claimLease(!1)),Wn=!1,ce&&ti(ce))};window.addEventListener("pageshow",t)}function Pr(e="implicit"){if(w)return w.activeTask||(w.activeTask=En(e),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1)),w.activeTask}function yf(e,t=Date.now()){if(!w)return;let n=Pr("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function vc(e="worker_task_active",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),H?.syncTask({...n},w.taskEpoch),Re())}function _f(e="worker_task_complete",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,H?.syncTask({...n},w.taskEpoch),Re())}function $n(){Mr=null,ge?.setTaskSuggestion({visible:!1})}function Pc(){ge?.clearMessages(),ge?.clearTimeline(),$n()}function Tf(){let e=w?.pendingRun;if(!e)return!1;if(!H)return!0;let t=H?.getState()?.activeRun;if(t?.runId&&t.runId===e.id||t?.runtimeId&&t.runtimeId!==Se)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=Xd}function vf(){if(!w?.pendingRun||Tf()||!H)return;let e=w.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<zd||(Dt(void 0),H?.clearActiveRunRuntimeId(e.id),H?.releaseWorkflowLock(e.id),H?.setActiveRun(void 0))}function Wt(e,t,n=!0,r){let o=Ke(String(t||""));if(!o)return;let s={id:r?.id||bn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return ge?.addMessage(s.role,s.text),w&&n&&(w.uiMessages.push(s),w.uiMessages.length>js&&(w.uiMessages=w.uiMessages.slice(-js)),yf(s.role,s.ts),Re()),H&&r?.publishShared!==!1&&(H.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),H.markTaskActivity(s.role,s.ts)),s}function ni(e){for(let t of e)Wt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function Ye(e,t=!0){let n={id:e.id||bn("timeline"),kind:e.kind,title:Ke(e.title,400),detail:e.detail?Ke(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return ge?.addTimelineEvent(n),w&&t&&(w.timeline.push(n),w.timeline.length>Qs&&(w.timeline=w.timeline.slice(-Qs)),Re()),H&&e.publishShared!==!1&&H.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function ri(e){ge?.clearTimeline();for(let t of e)Ye({id:t.id,kind:t.kind,title:t.title,detail:t.detail,status:t.status,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1},!1)}function kt(e,t){ge?.setStatus(e),w&&(w.uiStatus=Ke(e,300),Re()),H&&t?.publishShared!==!1&&H.setStatus(e)}function Ur(e,t){pt=e,w&&(w.executionMode=e,Re()),ge?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??H?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??H?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??H?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(e)}),Ce("mode_change",{mode:e,...t})}function Dt(e){if(!w)return;w.pendingRun=e;let t=Pr("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Re()}function Bc(e,t){let n=String(e||"").trim();if(!n||!Ie)return;if(pt==="observer"&&!(H?.requestControl()??!1)){Wt("system","Unable to take control right now because another tab is still running Rover actions.",!0),Ye({kind:"info",title:"Observer mode",detail:"Action execution is currently owned by another tab runtime.",status:"info"});return}let r=t?.runId||crypto.randomUUID(),o=!!t?.resume;t?.appendUserMessage!==!1&&Wt("user",n,!0);let i=w?.pendingRun?.id===r?w.pendingRun.attempts:0;Dt({id:r,text:n,startedAt:Date.now(),attempts:o?i+1:0,autoResume:t?.autoResume!==!1}),Ic=n,H?.acquireWorkflowLock(r),H?.setActiveRun({runId:r,text:n}),Ie.postMessage({type:"run",text:n,runId:r,resume:o}),Pn&&clearTimeout(Pn);let a=r;Pn=setTimeout(()=>{w?.pendingRun?.id===a&&(Dt(void 0),H?.releaseWorkflowLock(a),H?.setActiveRun(void 0),kt("Task timed out."),Wt("system","Task timed out after 5 minutes with no response.",!0),Ce("error",{message:"Run safety timeout"})),Pn=null},5*6e4)}function zo(e,t){let n=String(e||"").trim();if(!n)return;vf();let r=w?.activeTask?.status,o=!!t?.startNewTask||r==="completed"||r==="ended";if(H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:o}),o){let s=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");Wr({reason:s,clearUi:!0})}$n(),Bc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}function es(){if(pt==="observer")return;let e=H?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Se&&!(w?.pendingRun?.id===e.runId)||!wn||!Ie||Wn||!w?.pendingRun||w.activeTask?.status==="ended")return;let t=w.pendingRun;if(!t.autoResume)return;let n=ce?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${n}`)&&!(H?.listTabs()||[]).some(a=>a.runtimeId!==Se&&a.updatedAt>Date.now()-2*2e3)&&w?.pendingRun){Dt(void 0),kt("Previous task expired.");return}if(Date.now()-t.startedAt>$d){Dt(void 0),kt("Previous task expired after navigation.");return}if(t.attempts>=Gd){Dt(void 0),Wt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Wn=!0,kt("Resuming previous task after navigation..."),Bc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function xf(e){if(!w)return;let t=await bf(e);if(!t||!w)return;let n=Number(w.updatedAt)||0,r=Dr({...t,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se);(Number(r.updatedAt)||0)<=n+200||(w=Dr({...w,...r,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se),Re(),ge&&(ge.clearMessages(),ni(w.uiMessages),ri(w.timeline),w.uiStatus&&ge.setStatus(w.uiStatus),w.uiHidden?ge.hide():(ge.show(),w.uiOpen?ge.open():ge.close())),wn&&Ie&&w.workerState&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function oi(e,t){if(w){if(t==="remote"){let n=Math.max(1,Number(w.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;w.taskEpoch=Math.max(n,r);let s=w.activeTask||En("shared_sync");w.activeTask=Ef(e.task,s),o&&(w.uiMessages=[],w.timeline=[],Pc(),Dt(void 0),$n());let i=Lr(e.uiMessages),a=new Set(i.map(A=>A.id));if(i.length<w.uiMessages.length||w.uiMessages.some(A=>!a.has(A.id)))w.uiMessages=i,ge?.clearMessages(),ni(w.uiMessages);else{let A=new Set(w.uiMessages.map(S=>S.id));for(let S of i)A.has(S.id)||(Wt(S.role,S.text,!0,{id:S.id,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1}),A.add(S.id))}let v=Nr(e.timeline),p=new Set(v.map(A=>A.id));if(v.length<w.timeline.length||w.timeline.some(A=>!p.has(A.id)))w.timeline=v,ri(w.timeline);else{let A=new Set(w.timeline.map(S=>S.id));for(let S of v)A.has(S.id)||(Ye({id:S.id,kind:S.kind,title:S.title,detail:S.detail,status:S.status,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1},!0),A.add(S.id))}if(typeof e.uiStatus=="string"&&kt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Se?Dt(Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:w.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&pt==="observer"&&Dt(void 0),pt==="observer"&&Ur("observer",{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),holderRuntimeId:H?.getCurrentHolderRuntimeId()}),e.workerContext){let A=Vn(e.workerContext),S=Number(w.workerState?.updatedAt)||0,M=Number(A?.updatedAt)||0;A&&M>S+100&&(w.workerState=A,wn&&Ie&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:A}),Ce("context_restored",{source:"shared_session",ts:Date.now()})))}}w.uiMessages=Lr(w.uiMessages),w.timeline=Nr(w.timeline),w.workerState=Vn(w.workerState),w.activeTask=Hr(w.activeTask,En("implicit")),Re()}}function Wc(e){let t=En("checkpoint_clone");return{version:Js,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Hr(e.activeTask,t),lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:e.lastRoutingDecision.reason,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Rf(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!lt)}function kf(){if(!w||!ce||!lt)return null;let e=H?.getState(),t=Wc(w),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Yd,siteId:ce.siteId,visitorId:lt,sessionId:w.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function If(e){if(!e||typeof e!="object"||!w||!ce||e.siteId&&e.siteId!==ce.siteId||lt&&e.visitorId&&e.visitorId!==lt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():w.sessionId;Qo=!0;try{if(t&&w.sessionId!==t&&(w.sessionId=t,ce={...ce,sessionId:t},ts(ce),Ie?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&H&&H.hydrateExternalState(e.sharedState)&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Dr({...e.runtimeState,sessionId:t,runtimeId:Se},t,Se),r=Number(w.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(w=Dr({...w,...n,sessionId:t,runtimeId:Se},t,Se),Re(),w.uiStatus&&ge?.setStatus(w.uiStatus),w.uiHidden?ge?.hide():(ge?.show(),w.uiOpen?ge?.open():ge?.close()),wn&&w.workerState&&(Ie?.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),pt==="controller"&&es())}}finally{Qo=!1}}function Vc(e){if(wt?.stop(),wt=null,!!Rf(e)&<)try{let t=n=>{Ce("checkpoint_state",n),e.checkpointing?.onStateChange?.(n)};wt=new Uo({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:lt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>pt==="controller",buildCheckpoint:()=>kf(),onCheckpoint:n=>{If(n)},onStateChange:(n,r)=>{t({state:n,reason:r.reason,action:r.action,code:r.code,message:r.message}),n==="paused_auth"&&Ce("checkpoint_error",{action:r.action,code:r.code||"INVALID_API_KEY",message:r.message||"Checkpoint sync paused due to auth failure.",disabled:!0,reason:r.reason||"auth_failed"})},onError:(n,r)=>{e.checkpointing?.onError?.(r),r.paused||Ce("checkpoint_error",{action:r.action,code:r.code,message:r.message,status:r.status,disabled:!1,reason:"transient_failure"})}}),wt.start(),wt.markDirty()}catch{wt=null}}function ts(e){if(w){if(H?.stop(),H=null,e.sessionScope==="tab"){Ur("controller");return}H=new Do({siteId:e.siteId,sessionId:w.sessionId,runtimeId:Se,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Ur(t,n);let r=t==="controller"&&(ce?.allowActions??!0);if(ze?.setAllowActions(r),t==="controller"){let o=H?.getWorkerContext();if(o){let s=Vn(o),i=Number(w?.workerState?.updatedAt)||0,a=Number(s?.updatedAt)||0;s&&a>i+100&&(w&&(w.workerState=s,Re()),wn&&Ie&&(Ie.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"controller_handoff",ts:Date.now()})))}es()}},onStateChange:(t,n)=>{oi(t,n)},onSwitchRequested:t=>{t>0&&(Br(),Ye({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),H.start(),H.setRpcRequestHandler(async t=>{if(!ze)throw new Error("Bridge not available");if(t.method==="getPageData")return ze.getPageData(t.params);if(t.method==="executeTool")return ze.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),w?.activeTask&&H.syncTask({...w.activeTask,taskId:w.activeTask.taskId},w.taskEpoch),w?.workerState&&H.setWorkerContext(Hc(w.workerState))}}function Sf(e){let t=Ke(mf(e)||"Done.",1200);ge?.clearTimeline(),w&&(w.timeline=[]),H?.clearTimeline(),Ye({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function Af(e){if(!(!e||typeof e!="object")&&!pf(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(cn.set(e.runId,t),cn.size>80)){let n=cn.keys().next().value;n&&cn.delete(n)}Wt("assistant",t,!0),Ye({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=cf(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=uf(n,t,r);if(n&&kt(n),o&&o!==Ho&&(Ho=o,n)){let s=!!(e.thought||r),i=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!df(i,Ic))Ye({kind:"thought",title:i,detail:e.thought?String(e.thought):r,status:"pending"});else{let u=t?`${lf(t)}: ${n}`:n;Ye({kind:"status",title:u,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}Ce("status",e);return}if(e.type==="tool_start"){Ye({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Xo(e.call?.args),status:"pending"}),Ce("tool_start",e);return}if(e.type==="tool_result"){Ye({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Xo(e.result),status:e?.result?.success===!1?"error":"success"}),Ce("tool_result",e);return}if(e.type==="auth_required"){Ce("auth_required",e.error),e.error?.message&&(Wt("system",`Auth required: ${e.error.message}`,!0),Ye({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){Ce("navigation_guardrail",e),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(e),status:"info"});return}if(e.type==="error"){Wt("system",`Error: ${e.message||"unknown"}`,!0),Ye({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),Ce("error",e);return}if(e.type==="state_snapshot"){w&&(w.workerState=Vn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!w.pendingRun&&(w.pendingRun=Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&H?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),w.workerState&&H?.setWorkerContext(Hc(w.workerState)),Re());return}if(e.type==="task_started"){Ce("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Ho="",$n(),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId);let t=w?.pendingRun;Dt(Or({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),H?.setActiveRun({runId:e.runId,text:String(e.text||"")}),ge?.setRunning(!0);let n=`run:${String(e.runId||"")}:start`;w?.timeline.some(r=>r.id===n)||Ye({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){if(Ho="",Wn=!1,ge?.setRunning(!1),Pn&&(clearTimeout(Pn),Pn=null),w?.pendingRun?.id===e.runId&&Dt(void 0),typeof e.runId=="string"&&e.runId&&H?.releaseWorkflowLock(e.runId),w&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(w.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?Ke(e.route.reason,200):void 0,ts:Date.now()},Re()),H?.setActiveRun(void 0),!e.ok&&e.error)vc("worker_run_failed"),kt(`Task failed: ${String(e.error)}`),cn.delete(String(e.runId||"")),Ye({kind:"error",title:"Run failed",detail:String(e.error),status:"error"});else if(e.ok){let t=hf(e),n=t.taskComplete,r=t.needsUserInput;n?(_f("worker_task_complete"),H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:!0}),kt("Task completed"),Sf(typeof e.runId=="string"?e.runId:void 0)):(vc(r?"worker_waiting_for_input":"worker_continuation"),kt(r?"Need more input to continue":"Execution finished. Continue when ready."),Ye({kind:"status",title:r?"Waiting for your input":"Continuation available",detail:r?"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"})),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId)}return}if(e.type==="ready"){wn=!0,kt("ready"),Ce("ready");let t=H?.getWorkerContext(),n=Vn(t),r=Number(w?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:w?.workerState;w&&s&&s!==w.workerState&&(w.workerState=s,Re()),s?(Ie?.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"runtime_start",ts:Date.now()})):es();return}if(e.type==="hydrated"){es();return}e.type==="updated"&&Ce("updated")}}function Cf(e){if(ts(e),H){let s=H.getRole();pt=s,w&&(w.executionMode=s)}Vc(e),ti(e);let t=(e.allowActions??!0)&&(H?H.isController():!0);ze=new No({allowActions:t,runtimeId:Se,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,registerOpenedTab:s=>H?.registerOpenedTab(s),switchToLogicalTab:s=>H?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(H?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{Ce("navigation_guardrail",s),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;lc(n.port1,{getSnapshot:()=>ze.getSnapshot(),getPageData:async s=>{let i=ce||e,a=Number(s?.tabId),u=H?.getLocalLogicalTabId();if(!Number.isFinite(a)||a<=0||a===u||!H)return ze.getPageData(s);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Wo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.runtimeId===Se)return ze.getPageData(s);if(p.external&&i.externalNavigationPolicy!=="allow")return Wo(i,p,"external_domain_inaccessible");if(!p.runtimeId||!H.isTabAlive(a))return Wo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"getPageData",s,15e3)}catch{return Wo(i,p,"cross_tab_rpc_failed")}},executeTool:async s=>{let i=ce||e,a=H?.getActiveLogicalTabId(),u=H?.getLocalLogicalTabId();if(!a||a===u||!H)return ze.executeTool(s.call,s.payload);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Vo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.external&&i.externalNavigationPolicy!=="allow")return Vo(i,p,"external_tab_action_blocked");if(p.runtimeId===Se)return ze.executeTool(s.call,s.payload);if(!p.runtimeId||!H.isTabAlive(a))return Vo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"executeTool",s,2e4)}catch{return Vo(i,p,"cross_tab_execute_failed")}},executeClientTool:s=>ze.executeClientTool(s.name,s.args),listClientTools:()=>ze.listClientTools(),getTabContext:()=>{let s=H?.getLocalLogicalTabId(),i=H?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:i||s||1,runtimeId:Se,mode:pt,url:window.location.href,title:document.title}},listSessionTabs:()=>H?.listTabs()||[]}),n.port1.start?.();let r=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),o=r;try{let s=window.location.origin,i=new URL(r).origin;if(s!==i){let a=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(a)}}catch{}if(Ie=new Worker(o,{type:"module"}),Ie.postMessage({type:"init",config:e,port:n.port2},[n.port2]),ge=hc({onSend:s=>{zo(s)},onRequestControl:()=>{H?.requestControl()??!1?Ye({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Wt("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{w?.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id),H?.setActiveRun(void 0),Dt(void 0),kt("Task cancelled."),Wt("system","Task cancelled.",!0))},onNewTask:()=>{Wr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{is({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,agent:{name:e.ui?.agent?.name},mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{w&&(w.uiOpen=!0,w.uiHidden=!1,Re()),Ce("open")},onClose:()=>{w&&(w.uiOpen=!1,Re()),Ce("close")}}),$n(),w?.uiMessages?.length&&ni(w.uiMessages),w?.timeline?.length&&ri(w.timeline),w?.uiStatus&&ge.setStatus(w.uiStatus),w?.executionMode&&ge.setExecutionMode(w.executionMode,{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),controllerRuntimeId:H?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(w.executionMode)}),Ie.onmessage=s=>{Af(s.data||{})},H){let s=()=>{H?.registerCurrentTab(window.location.href,document.title),H?.broadcastNavigation(window.location.href,document.title)},i=history.pushState.bind(history),a=history.replaceState.bind(history);history.pushState=function(...u){let v=i(...u);return setTimeout(s,0),v},history.replaceState=function(...u){let v=a(...u);return setTimeout(s,0),v},window.addEventListener("popstate",s)}w?.uiHidden?ge.hide():(ge.show(),w?.uiOpen??!!e.openOnInit?ge.open():ge.close()),w&&(w.uiHidden=!!w.uiHidden,w.uiOpen=!!w.uiOpen,Re()),H&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()}))}function Fr(e){if(gn)return ns(e),gn;Bn=wc(),Se=Zd(e.siteId),lt=Cc(e),ur=rf(e.siteId);let t=gf(ur),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&<?nf(e.siteId,lt):void 0,o=n||t?.sessionId||r||crypto.randomUUID();w=Dr(t,o,Se),n&&w.sessionId!==n&&(w=Lc(n,Se)),ce={...e,visitorId:lt||e.visitorId,sessionId:n||w.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{...e.taskContext}},w.sessionId=ce.sessionId,w.runtimeId=Se,w.executionMode=w.executionMode||"controller",w.timeline=Nr(w.timeline),w.uiMessages=Lr(w.uiMessages),w.activeTask=Hr(w.activeTask,En("boot")),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1),pt=w.executionMode,Re();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(wn=!1,Wn=!1,Cf(ce),ur&&xf(ur),wf(),gn={boot:Fr,init:si,update:ns,shutdown:ii,open:Br,close:ss,show:ai,hide:ci,send:li,newTask:Wr,endTask:is,getState:ui,registerTool:di,on:Sc},qo.length){for(let s of qo)Mc(s);qo.length=0}return gn}function si(e){return Fr(e)}function ns(e){!gn||!Ie||!ce||(ce={...ce,...e,taskRouting:{...ce.taskRouting,...e.taskRouting},taskContext:{...ce.taskContext,...e.taskContext},ui:{...ce.ui,...e.ui,agent:{...ce.ui?.agent,...e.ui?.agent},panel:{...ce.ui?.panel,...e.ui?.panel}},tools:{...ce.tools,...e.tools,client:e.tools?.client??ce.tools?.client,web:{...ce.tools?.web,...e.tools?.web}}},lt=Cc(ce),lt&&(ce.visitorId=lt),e.sessionId&&w?(w.sessionId=e.sessionId,Re(),ts(ce)):(e.sessionScope||e.tabPolicy)&&ts(ce),Vc(ce),ti(ce),ze&&(typeof e.allowActions=="boolean"&&ze.setAllowActions(e.allowActions&&pt==="controller"),(e.allowedDomains||e.domainScopeMode||e.externalNavigationPolicy)&&ze.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy})),Ie.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Br():ss()))}function ii(){$n(),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),wt=null,H?.stop(),H=null,Ie?.terminate(),Ie=null,ge?.destroy(),ge=null,ze=null,ce=null,wn=!1,Wn=!1,Se="",lt=void 0,Qo=!1,Go=!1,dr=!1,Et=[],kc=0,pt="controller",Mr=null,Bn=null,gn=null}function Br(){ge?.show(),ge?.open(),w&&(w.uiHidden=!1,w.uiOpen=!0,Re())}function ss(){ge?.close(),w&&(w.uiOpen=!1,Re())}function ai(){ge?.show(),w&&(w.uiHidden=!1,Re())}function ci(){ge?.hide(),w&&(w.uiHidden=!0,w.uiOpen=!1,Re())}function li(e){e?.trim()&&zo(e)}function Wr(e){if(!w)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(w.taskEpoch)||1)+1,o=En(t);w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),Wn=!1,w.taskEpoch=r,w.activeTask=o,w.pendingRun=void 0,w.workerState=void 0,n&&(w.uiMessages=[],w.timeline=[],w.uiStatus=void 0,Pc()),H?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),H?.setActiveRun(void 0),H?.setWorkerContext(void 0),kt("New task started."),Re(),Ie?.postMessage({type:"start_new_task",taskId:o.taskId}),Ye({kind:"info",title:"Started new task",detail:t,status:"info"}),Ce("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function is(e){if(!w)return;let t=e?.reason||"manual_end_task",n=Pr("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),w.pendingRun=void 0,$n(),kt("Task ended. Start a new task to continue."),H?.endTask(t),H?.setActiveRun(void 0),Re(),Ye({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),Ce("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function ui(){return{mode:pt,runtimeId:Se,runtimeState:w?Wc(w):null,sharedState:H?.getState()||null,pendingTaskSuggestion:Mr}}function di(e,t){let n=Jd(e);if(!gn||!ze||!Ie){qo.push({def:n,handler:t});return}Mc({def:n,handler:t})}function Mf(e){if(!e)return;let t=String(e);if(t==="init")return"init";if(t==="boot")return"boot";if(t==="update")return"update";if(t==="shutdown")return"shutdown";if(t==="open")return"open";if(t==="close")return"close";if(t==="show")return"show";if(t==="hide")return"hide";if(t==="send")return"send";if(t==="newTask")return"newTask";if(t==="endTask")return"endTask";if(t==="getState")return"getState";if(t==="registerTool")return"registerTool";if(t==="on")return"on"}function $c(){let e=window,t=e.rover,n=((r,...o)=>{let s=Mf(r),i=s?n[s]:void 0;if(typeof i=="function")return i(...o)});if(n.boot=Fr,n.init=si,n.update=ns,n.shutdown=ii,n.open=Br,n.close=ss,n.show=ai,n.hide=ci,n.send=li,n.newTask=Wr,n.endTask=is,n.getState=ui,n.registerTool=di,n.on=Sc,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...s]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...s)}if(!gn){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),s=r.getAttribute("data-api-key");if(o&&s){let i={siteId:o,apiKey:s},a=r.getAttribute("data-allowed-domains");a&&(i.allowedDomains=a.split(",").map(p=>p.trim()).filter(Boolean));let u=r.getAttribute("data-site-key-id");u&&(i.siteKeyId=u);let v=r.getAttribute("data-worker-url");v&&(i.workerUrl=v),Fr(i)}}}}$c();return jc(Lf);})();
|