@browserbasehq/orca 3.5.0-preview.1 → 3.5.1-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/dist/cjs/lib/utils.d.ts +2 -0
- package/dist/cjs/lib/utils.js +20 -0
- package/dist/cjs/lib/utils.js.map +1 -1
- package/dist/cjs/lib/v3/agent/AgentProvider.js +1 -0
- package/dist/cjs/lib/v3/agent/AgentProvider.js.map +1 -1
- package/dist/cjs/lib/v3/agent/AnthropicCUAClient.js +1 -0
- package/dist/cjs/lib/v3/agent/AnthropicCUAClient.js.map +1 -1
- package/dist/cjs/lib/v3/api.js +28 -33
- package/dist/cjs/lib/v3/api.js.map +1 -1
- package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.d.ts +24 -24
- package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js +24 -24
- package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
- package/dist/cjs/lib/v3/dom/locatorScripts/xpathResolver.js +79 -10
- package/dist/cjs/lib/v3/dom/locatorScripts/xpathResolver.js.map +1 -1
- package/dist/cjs/lib/v3/index.d.ts +2 -1
- package/dist/cjs/lib/v3/llm/LLMProvider.js +18 -2
- package/dist/cjs/lib/v3/llm/LLMProvider.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/agent.d.ts +2 -2
- package/dist/cjs/lib/v3/types/public/agent.js +1 -0
- package/dist/cjs/lib/v3/types/public/agent.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/api.d.ts +538 -27
- package/dist/cjs/lib/v3/types/public/api.js +83 -7
- package/dist/cjs/lib/v3/types/public/api.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/clipboard.d.ts +15 -0
- package/dist/cjs/lib/v3/types/public/clipboard.js +3 -0
- package/dist/cjs/lib/v3/types/public/clipboard.js.map +1 -0
- package/dist/cjs/lib/v3/types/public/index.d.ts +1 -0
- package/dist/cjs/lib/v3/types/public/index.js +1 -0
- package/dist/cjs/lib/v3/types/public/index.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/model.d.ts +18 -3
- package/dist/cjs/lib/v3/types/public/model.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/page.d.ts +29 -0
- package/dist/cjs/lib/v3/types/public/page.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/sdkErrors.d.ts +3 -0
- package/dist/cjs/lib/v3/types/public/sdkErrors.js +8 -2
- package/dist/cjs/lib/v3/types/public/sdkErrors.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/clipboard.d.ts +24 -0
- package/dist/cjs/lib/v3/understudy/clipboard.js +166 -0
- package/dist/cjs/lib/v3/understudy/clipboard.js.map +1 -0
- package/dist/cjs/lib/v3/understudy/context.d.ts +3 -0
- package/dist/cjs/lib/v3/understudy/context.js +15 -0
- package/dist/cjs/lib/v3/understudy/context.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/page.d.ts +23 -1
- package/dist/cjs/lib/v3/understudy/page.js +283 -0
- package/dist/cjs/lib/v3/understudy/page.js.map +1 -1
- package/dist/cjs/lib/v3/v3.js +15 -6
- package/dist/cjs/lib/v3/v3.js.map +1 -1
- package/dist/cjs/lib/version.d.ts +1 -1
- package/dist/cjs/lib/version.js +1 -1
- package/dist/cjs/lib/version.js.map +1 -1
- package/dist/esm/lib/utils.d.ts +2 -0
- package/dist/esm/lib/utils.js +18 -0
- package/dist/esm/lib/utils.js.map +1 -1
- package/dist/esm/lib/v3/agent/AgentProvider.js +1 -0
- package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -1
- package/dist/esm/lib/v3/agent/AnthropicCUAClient.js +1 -0
- package/dist/esm/lib/v3/agent/AnthropicCUAClient.js.map +1 -1
- package/dist/esm/lib/v3/api.js +29 -34
- package/dist/esm/lib/v3/api.js.map +1 -1
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.d.ts +24 -24
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +24 -24
- package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
- package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js +79 -10
- package/dist/esm/lib/v3/dom/locatorScripts/xpathResolver.js.map +1 -1
- package/dist/esm/lib/v3/index.d.ts +2 -1
- package/dist/esm/lib/v3/llm/LLMProvider.js +18 -2
- package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -1
- package/dist/esm/lib/v3/types/public/agent.d.ts +2 -2
- package/dist/esm/lib/v3/types/public/agent.js +1 -0
- package/dist/esm/lib/v3/types/public/agent.js.map +1 -1
- package/dist/esm/lib/v3/types/public/api.d.ts +538 -27
- package/dist/esm/lib/v3/types/public/api.js +81 -5
- package/dist/esm/lib/v3/types/public/api.js.map +1 -1
- package/dist/esm/lib/v3/types/public/clipboard.d.ts +15 -0
- package/dist/esm/lib/v3/types/public/clipboard.js +2 -0
- package/dist/esm/lib/v3/types/public/clipboard.js.map +1 -0
- package/dist/esm/lib/v3/types/public/index.d.ts +1 -0
- package/dist/esm/lib/v3/types/public/index.js +1 -0
- package/dist/esm/lib/v3/types/public/index.js.map +1 -1
- package/dist/esm/lib/v3/types/public/model.d.ts +18 -3
- package/dist/esm/lib/v3/types/public/model.js.map +1 -1
- package/dist/esm/lib/v3/types/public/page.d.ts +29 -0
- package/dist/esm/lib/v3/types/public/page.js.map +1 -1
- package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +3 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.js +5 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -1
- package/dist/esm/lib/v3/understudy/clipboard.d.ts +24 -0
- package/dist/esm/lib/v3/understudy/clipboard.js +163 -0
- package/dist/esm/lib/v3/understudy/clipboard.js.map +1 -0
- package/dist/esm/lib/v3/understudy/context.d.ts +3 -0
- package/dist/esm/lib/v3/understudy/context.js +15 -0
- package/dist/esm/lib/v3/understudy/context.js.map +1 -1
- package/dist/esm/lib/v3/understudy/page.d.ts +23 -1
- package/dist/esm/lib/v3/understudy/page.js +284 -1
- package/dist/esm/lib/v3/understudy/page.js.map +1 -1
- package/dist/esm/lib/v3/v3.js +16 -7
- package/dist/esm/lib/v3/v3.js.map +1 -1
- package/dist/esm/lib/version.d.ts +1 -1
- package/dist/esm/lib/version.js +1 -1
- package/dist/esm/lib/version.js.map +1 -1
- package/package.json +13 -7
|
@@ -5,31 +5,31 @@ exports.locatorScriptGlobalRefs = exports.locatorScriptSources = exports.locator
|
|
|
5
5
|
* AUTO-GENERATED FILE. DO NOT EDIT.
|
|
6
6
|
* Run `pnpm run build-dom-scripts` to regenerate.
|
|
7
7
|
*/
|
|
8
|
-
exports.locatorScriptBootstrap = "if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,o)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let r of U(t))!Q.call(e,r)&&r!==n&&M(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var J=e=>j(M({},\"__esModule\",{value:!0}),e);var Oe={};Z(Oe,{assignFilePayloadsToInputElement:()=>te,countCssMatchesPierce:()=>Me,countCssMatchesPrimary:()=>Ce,countTextMatches:()=>Le,countXPathMatchesMainWorld:()=>Pe,dispatchDomClick:()=>ne,ensureFileInputElement:()=>ee,fillElementValue:()=>se,focusElement:()=>le,isElementChecked:()=>ce,isElementVisible:()=>ae,prepareElementForTyping:()=>v,readElementInnerHTML:()=>me,readElementInnerText:()=>fe,readElementInputValue:()=>ue,readElementTextContent:()=>de,resolveCssSelector:()=>ve,resolveCssSelectorPierce:()=>Te,resolveTextSelector:()=>Re,resolveXPathMainWorld:()=>Ne,scrollElementToPercent:()=>oe,selectElementOptions:()=>ie,waitForSelector:()=>_e});function ee(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}function te(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\"input\"||(t.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",i=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),a=window.atob(r.base64??\"\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}function ne(e){let t=e??{};try{let n=new MouseEvent(\"click\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\"number\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function oe(e){let t=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}var H=new Set([\"color\",\"date\",\"datetime-local\",\"month\",\"range\",\"time\",\"week\"]),re=new Set([\"\",\"email\",\"number\",\"password\",\"search\",\"tel\",\"text\",\"url\"]);function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\"function\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\"function\")return e.select(),!0}catch{}try{let o=(e.value??\"\").length;if(typeof e.setSelectionRange==\"function\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function se(e){let t=this;if(!t.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\"\";try{let l=s=>{let i;if(typeof o.InputEvent==\"function\")try{i=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{i=new o.Event(\"input\",{bubbles:!0,composed:!0})}else i=new o.Event(\"input\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\"change\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\"\").toLowerCase();if(!re.has(s)&&!H.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\"number\"){let a=e.trim();if(a!==\"\"&&Number.isNaN(Number(a)))return{status:\"error\",reason:\"invalid-number-value\"};i=a}if(r=i,H.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\"value\")?.set;return typeof c==\"function\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\"error\",reason:\"malformed-value\"}:(l(a),{status:\"done\"})}return v.call(t),{status:\"needsinput\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\"needsinput\",value:e}):t instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:t.isContentEditable?(v.call(t),r=e,{status:\"needsinput\",value:e}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let i=l.message;typeof i==\"string\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\"needsinput\",value:r,reason:s}}}function le(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}function ie(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\"\").trim())),o=s=>{let i=(s.label||s.textContent||\"\").trim(),a=String(s.value??\"\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function ae(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\"none\"||t.visibility===\"hidden\")return!1;let n=parseFloat(t.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}function ce(){try{let e=this;if((e.tagName||\"\").toLowerCase()===\"input\"){let o=e.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!e.checked}let n=e.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}function ue(){try{let e=this,t=(e.tagName||\"\").toLowerCase();return t===\"input\"||t===\"textarea\"||t===\"select\"?String(e.value??\"\"):e.isContentEditable?String(e.textContent??\"\"):\"\"}catch{return\"\"}}function de(){try{return String(this.textContent??\"\")}catch{return\"\"}}function me(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}function fe(){try{let e=this,t=e.innerText;if(typeof t==\"string\"&&t.length>0)return t;let n=e.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}function O(e){let t=String(e||\"\").trim().replace(/^xpath=/i,\"\");if(!t)return[];let n=[],o=0;for(;o<t.length;){let r=\"child\";t.startsWith(\"//\",o)?(r=\"desc\",o+=2):t[o]===\"/\"&&(r=\"child\",o+=1);let l=o,s=0,i=null;for(;o<t.length;){let c=t[o];if(i)c===i&&(i=null);else if(c===\"'\"||c==='\"')i=c;else if(c===\"[\")s++;else if(c===\"]\")s--;else if(c===\"/\"&&s===0)break;o+=1}let a=t.slice(l,o).trim();if(!a)continue;let{tag:d,predicates:f}=pe(a);n.push({axis:r,tag:d,predicates:f})}return n}function he(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==\"[\"){n++;continue}n++;let o=n,r=null;for(;n<e.length;){let l=e[n];if(r)l===r&&(r=null);else if(l===\"'\"||l==='\"')r=l;else if(l===\"]\")break;n++}t.push(e.slice(o,n).trim()),n++}return t}function pe(e){let t=e.indexOf(\"[\");if(t===-1)return{tag:e===\"\"?\"*\":e.toLowerCase(),predicates:[]};let n=e.slice(0,t).trim(),o=n===\"\"?\"*\":n.toLowerCase(),r=e.slice(t),l=[];for(let s of he(r)){let i=T(s);i&&l.push(i)}return{tag:o,predicates:l}}function T(e){let t=e.trim();if(!t)return null;let n=A(t,\"or\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\"or\",predicates:l}}let o=A(t,\"and\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\"and\",predicates:l}}let r=we(t,\"not\");if(r!=null){let l=T(r);return l?{type:\"not\",predicate:l}:null}return ge(t)}function ge(e){let t=/^(?:'([^']*)'|\"([^\"]*)\")$/,n=\"[a-zA-Z_][\\\\w.-]*\",o=`(?:'([^']*)'|\"([^\"]*)\")`;if(/^\\d+$/.test(e))return{type:\"index\",index:Math.max(1,Number(e))};let r=e.match(new RegExp(`^normalize-space\\\\(\\\\s*@(${n})\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(r)return{type:\"attrEquals\",name:r[1],value:r[2]??r[3]??\"\",normalize:!0};let l=e.match(new RegExp(`^normalize-space\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(l)return{type:\"textEquals\",value:l[1]??l[2]??\"\",normalize:!0};let s=e.match(new RegExp(`^@(${n})\\\\s*=\\\\s*${o}$`));if(s)return{type:\"attrEquals\",name:s[1],value:s[2]??s[3]??\"\"};let i=e.match(new RegExp(`^@(${n})$`));if(i)return{type:\"attrExists\",name:i[1]};let a=e.match(new RegExp(`^contains\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(a)return{type:\"attrContains\",name:a[1],value:a[2]??a[3]??\"\"};let d=e.match(new RegExp(`^starts-with\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(d)return{type:\"attrStartsWith\",name:d[1],value:d[2]??d[3]??\"\"};let f=e.match(new RegExp(`^(?:text\\\\(\\\\)|\\\\.)\\\\s*=\\\\s*${o}$`));if(f)return{type:\"textEquals\",value:f[1]??f[2]??\"\"};let c=e.match(new RegExp(`^contains\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));return c?{type:\"textContains\",value:c[1]??c[2]??\"\"}:(t.test(e),null)}function A(e,t){let n=[],o=0,r=0,l=null,s=0;for(;s<e.length;){let i=e[s];if(l){i===l&&(l=null),s+=1;continue}if(i===\"'\"||i==='\"'){l=i,s+=1;continue}if(i===\"(\"){r+=1,s+=1;continue}if(i===\")\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&Ee(e,s,t)){n.push(e.slice(o,s).trim()),s+=t.length,o=s;continue}s+=1}return n.push(e.slice(o).trim()),n.filter(i=>i.length>0)}function Ee(e,t,n){if(!e.startsWith(n,t))return!1;let o=t>0?e[t-1]:\" \";if(o===\"@\")return!1;let r=t+n.length<e.length?e[t+n.length]:\" \";return W(o)&&W(r)}function W(e){return!/[a-zA-Z0-9_.-]/.test(e)}function we(e,t){let n=`${t}(`;if(!e.startsWith(n)||!e.endsWith(\")\"))return null;let o=e.slice(n.length,-1);return ye(o)?o:null}function ye(e){let t=0,n=null;for(let o=0;o<e.length;o+=1){let r=e[o];if(n){r===n&&(n=null);continue}if(r===\"'\"||r==='\"'){n=r;continue}if(r===\"(\"?t+=1:r===\")\"&&(t-=1),t<0)return!1}return t===0}var be=e=>e.replace(/\\s+/g,\" \").trim();function _(e){return String(e.textContent??\"\")}function S(e,t){return t?be(e):e}function R(e,t){switch(t.type){case\"and\":return t.predicates.every(n=>R(e,n));case\"or\":return t.predicates.some(n=>R(e,n));case\"not\":return!R(e,t.predicate);case\"attrExists\":return e.getAttribute(t.name)!==null;case\"attrEquals\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize)===S(t.value,t.normalize)}case\"attrContains\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).includes(S(t.value,t.normalize))}case\"attrStartsWith\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).startsWith(S(t.value,t.normalize))}case\"textEquals\":return S(_(e),t.normalize)===S(t.value,t.normalize);case\"textContains\":return S(_(e),t.normalize).includes(S(t.value,t.normalize));case\"index\":return!0;default:return!0}}function q(e,t){let n=e;for(let o of t){if(!n.length)return[];if(o.type===\"index\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var P=e=>{let t=String(e??\"\").trim();return t?t.replace(/^xpath=/i,\"\").trim():\"\"};function I(e,t){return k(e,0,t)}function k(e,t,n){if(!Number.isFinite(t)||t<0)return null;let o=P(e);if(!o)return null;let r=Math.floor(t),l=n?.pierceShadow!==!1,s=l?z():null;if(!l)return X(o,r).value;if(!s?.hasShadow){let a=X(o,r);return a.error?N(o,s?.getClosedRoot)[r]??null:a.value}return N(o,s.getClosedRoot)[r]??null}function $(e,t){let n=P(e);if(!n)return 0;let o=t?.pierceShadow!==!1,r=o?z():null;if(!o)return F(n).count;if(!r?.hasShadow){let l=F(n);return l.error?N(n,r?.getClosedRoot).length:l.count}return N(n,r.getClosedRoot).length}function N(e,t){let n=P(e);if(!n)return[];let o=O(n);if(!o.length)return[];let r=t??null,l=[document];for(let s of o){let i=[],a=new Set;for(let d of l){if(!d)continue;let f=s.axis===\"child\"?L(d,r):Se(d,r);if(!f.length)continue;let c=f.filter(g=>xe(g,s)),p=q(c,s.predicates);for(let g of p)a.has(g)||(a.add(g),i.push(g))}if(!i.length)return[];l=i}return l}function xe(e,t){return t.tag===\"*\"?!0:e.localName===t.tag}function z(){let e=window.__stagehandV3__,t=e&&typeof e.getClosedRoot==\"function\"?o=>{try{return e.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(e&&typeof e.stats==\"function\"){let o=e.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:t,hasShadow:n}}function L(e,t){let n=[];if(!e)return n;if(e instanceof Document)return e.documentElement&&n.push(e.documentElement),n;if(e instanceof ShadowRoot||e instanceof DocumentFragment)return n.push(...Array.from(e.children??[])),n;if(e instanceof Element){n.push(...Array.from(e.children??[]));let o=e.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),t){let r=t(e);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Se(e,t){let n=[],o=new Set,r=[...L(e,t)].reverse();for(;r.length;){let l=r.pop();if(!l||o.has(l))continue;o.add(l),n.push(l);let s=L(l,t);for(let i=s.length-1;i>=0;i-=1)r.push(s[i])}return n}function X(e,t){try{return{value:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(t),error:!1}}catch{return{value:null,error:!0}}}function F(e){try{return{count:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var C=e=>{let t=Number(e??0);return!Number.isFinite(t)||t<0?0:Math.floor(t)},V=(e,t)=>{if(!e)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=i=>{if(!(!i||n.has(i)||r.length>=t)){n.add(i);try{let a=i.querySelectorAll(e);for(let d of a)if(!o.has(d)&&(o.add(d),r.push(d),r.length>=t))return}catch{}try{let d=(i instanceof Document?i:i.host?.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),f;for(;f=d.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<t;){let i=l.shift();i&&s(i)}return r};function ve(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t);return V(n,o+1)[o]??null}function Te(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return V(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}function Re(e,t){let n=String(e??\"\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\"\";return l.has(h)},i=u=>{try{if(s(u))return\"\";let h=u.innerText;if(typeof h==\"string\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\"string\")return h.trim()}catch{}return\"\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\"function\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:i(E)});let b=E.shadowRoot;b&&w(b);let D=f(E);D&&w(D)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Ne(e,t){let n=C(t);return k(e,n,{pierceShadow:!0})}function Ce(e){let t=String(e??\"\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}function Me(e){let t=String(e??\"\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\"function\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}function Le(e){let t=String(e??\"\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\"\";return o.has(u)},l=m=>{try{if(r(m))return\"\";let u=m.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\"function\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\"\",id:m.id??\"\",className:m.className??\"\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}function Pe(e){return $(e,{pierceShadow:!0})}var ke=e=>e.startsWith(\"xpath=\")||e.startsWith(\"/\"),De=e=>{try{let t=window.__stagehandV3__;if(t&&typeof t.getClosedRoot==\"function\")return t.getClosedRoot(e)??null}catch{}return null},Y=e=>e.shadowRoot?e.shadowRoot:De(e),He=(e,t,n)=>{try{let l=e.querySelector(t);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[e];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(t);if(s)return s}catch{}try{let i=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();){if(!(a instanceof Element))continue;let d=Y(a);d&&!o.has(d)&&r.push(d)}}catch{}}}return null},Ae=(e,t)=>I(e,{pierceShadow:t}),B=(e,t)=>ke(e)?Ae(e,t):He(document,e,t),G=(e,t)=>{if(t===\"detached\")return e===null;if(t===\"attached\")return e!==null;if(e===null)return!1;if(t===\"hidden\")try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display===\"none\"||n.visibility===\"hidden\"||n.opacity===\"0\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display!==\"none\"&&n.visibility!==\"hidden\"&&n.opacity!==\"0\"&&o.width>0&&o.height>0}catch{return!1}},We=(e,t)=>{let n=new WeakSet,o=l=>{let s=Y(l);if(s&&!n.has(s)){n.add(s);let i=new MutationObserver(e);i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),t.push(i);for(let a of Array.from(s.children))o(a)}for(let i of Array.from(l.children))o(i)},r=document.documentElement||document.body;r&&o(r)};function _e(e,t,n,o){let r=String(e??\"\").trim(),l=String(t??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=B(r,i);if(G(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},m=()=>{if(p)return;let E=B(r,i);G(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,m(),h()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),i&&We(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}return J(Oe);})();\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\n}";
|
|
8
|
+
exports.locatorScriptBootstrap = "if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var L=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var tt=(t,e)=>{for(var n in e)L(t,n,{get:e[n],enumerable:!0})},et=(t,e,n,o)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let r of j(e))!J.call(t,r)&&r!==n&&L(t,r,{get:()=>e[r],enumerable:!(o=Z(e,r))||o.enumerable});return t};var nt=t=>et(L({},\"__esModule\",{value:!0}),t);var Xt={};tt(Xt,{assignFilePayloadsToInputElement:()=>rt,countCssMatchesPierce:()=>kt,countCssMatchesPrimary:()=>Pt,countTextMatches:()=>Dt,countXPathMatchesMainWorld:()=>Ht,dispatchDomClick:()=>st,ensureFileInputElement:()=>ot,fillElementValue:()=>it,focusElement:()=>ct,isElementChecked:()=>ht,isElementVisible:()=>mt,prepareElementForTyping:()=>v,readElementInnerHTML:()=>pt,readElementInnerText:()=>gt,readElementInputValue:()=>ft,readElementTextContent:()=>dt,resolveCssSelector:()=>Ct,resolveCssSelectorPierce:()=>Mt,resolveTextSelector:()=>Nt,resolveXPathMainWorld:()=>Lt,scrollElementToPercent:()=>lt,selectElementOptions:()=>ut,waitForSelector:()=>Ft});function ot(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}function rt(t){try{let e=this;if(!e||e.tagName?.toLowerCase()!==\"input\"||(e.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(t)?t:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",a=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),i=window.atob(r.base64??\"\"),m=new Uint8Array(i.length);for(let p=0;p<i.length;p+=1)m[p]=i.charCodeAt(p);let f=new Blob([m],{type:s}),c=new File([f],l,{type:s,lastModified:a});n.items.add(c)}return e.files=n.files,e.dispatchEvent(new Event(\"input\",{bubbles:!0})),e.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}function st(t){let e=t??{};try{let n=new MouseEvent(\"click\",{bubbles:!!e.bubbles,cancelable:!!e.cancelable,composed:!!e.composed,detail:typeof e.detail==\"number\"?e.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function lt(t){let e=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(e(t),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,a=o.clientHeight??0,m=Math.max(0,s-a)*(n/100);return o.scrollTo({top:m,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}var W=new Set([\"color\",\"date\",\"datetime-local\",\"month\",\"range\",\"time\",\"week\"]),at=new Set([\"\",\"email\",\"number\",\"password\",\"search\",\"tel\",\"text\",\"url\"]);function v(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument||document,n=e.defaultView||window;try{typeof t.focus==\"function\"&&t.focus()}catch{}if(t instanceof n.HTMLInputElement||t instanceof n.HTMLTextAreaElement){try{if(typeof t.select==\"function\")return t.select(),!0}catch{}try{let o=(t.value??\"\").length;if(typeof t.setSelectionRange==\"function\")return t.setSelectionRange(0,o),!0}catch{}return!0}if(t.isContentEditable){let o=e.getSelection?.(),r=e.createRange?.();if(o&&r)try{r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function it(t){let e=this;if(!e.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(e.ownerDocument||document).defaultView||window,r=t??\"\";try{let l=s=>{let a;if(typeof o.InputEvent==\"function\")try{a=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{a=new o.Event(\"input\",{bubbles:!0,composed:!0})}else a=new o.Event(\"input\",{bubbles:!0,composed:!0});e.dispatchEvent(a);let i=new o.Event(\"change\",{bubbles:!0});e.dispatchEvent(i)};if(e instanceof o.HTMLInputElement){let s=(e.type||\"\").toLowerCase();if(!at.has(s)&&!W.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let a=t;if(s===\"number\"){let i=t.trim();if(i!==\"\"&&Number.isNaN(Number(i)))return{status:\"error\",reason:\"invalid-number-value\"};a=i}if(r=a,W.has(s)){let i=t.trim();r=i,v.call(e);let m=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(m,\"value\")?.set;return typeof c==\"function\"?c.call(e,i):e.value=i,e._valueTracker?.setValue?.(i),e.value!==i?{status:\"error\",reason:\"malformed-value\"}:(l(i),{status:\"done\"})}return v.call(e),{status:\"needsinput\",value:a}}return e instanceof o.HTMLTextAreaElement?(v.call(e),r=t,{status:\"needsinput\",value:t}):e instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:e.isContentEditable?(v.call(e),r=t,{status:\"needsinput\",value:t}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let a=l.message;typeof a==\"string\"&&a.trim().length>0&&(s=`exception:${a}`)}return{status:\"needsinput\",value:r,reason:s}}}function ct(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}function ut(t){try{if(!(this instanceof HTMLSelectElement))return[];let e=Array.isArray(t)?t:[t],n=new Set(e.map(s=>String(s??\"\").trim())),o=s=>{let a=(s.label||s.textContent||\"\").trim(),i=String(s.value??\"\").trim();return n.has(a)||n.has(i)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let a of Array.from(this.options))!s&&o(a)?(a.selected=!0,this.value=a.value,s=!0):a.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function mt(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument?.defaultView?.getComputedStyle(t)??window.getComputedStyle(t);if(!e||e.display===\"none\"||e.visibility===\"hidden\")return!1;let n=parseFloat(e.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=t.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||t.getClientRects().length===0)}catch{return!1}}function ht(){try{let t=this;if((t.tagName||\"\").toLowerCase()===\"input\"){let o=t.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!t.checked}let n=t.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}function ft(){try{let t=this,e=(t.tagName||\"\").toLowerCase();return e===\"input\"||e===\"textarea\"||e===\"select\"?String(t.value??\"\"):t.isContentEditable?String(t.textContent??\"\"):\"\"}catch{return\"\"}}function dt(){try{return String(this.textContent??\"\")}catch{return\"\"}}function pt(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}function gt(){try{let t=this,e=t.innerText;if(typeof e==\"string\"&&e.length>0)return e;let n=t.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}function P(t){let e=String(t||\"\").trim().replace(/^xpath=/i,\"\");if(!e)return[];let n=[],o=0;for(;o<e.length;){let r=\"child\";e.startsWith(\"//\",o)?(r=\"desc\",o+=2):e[o]===\"/\"&&(r=\"child\",o+=1);let l=o,s=0,a=null;for(;o<e.length;){let c=e[o];if(a)c===a&&(a=null);else if(c===\"'\"||c==='\"')a=c;else if(c===\"[\")s++;else if(c===\"]\")s--;else if(c===\"/\"&&s===0)break;o+=1}let i=e.slice(l,o).trim();if(!i)continue;let{tag:m,predicates:f}=wt(i);n.push({axis:r,tag:m,predicates:f})}return n}function Et(t){let e=[],n=0;for(;n<t.length;){if(t[n]!==\"[\"){n++;continue}n++;let o=n,r=null;for(;n<t.length;){let l=t[n];if(r)l===r&&(r=null);else if(l===\"'\"||l==='\"')r=l;else if(l===\"]\")break;n++}e.push(t.slice(o,n).trim()),n++}return e}function wt(t){let e=t.indexOf(\"[\");if(e===-1)return{tag:t===\"\"?\"*\":t.toLowerCase(),predicates:[]};let n=t.slice(0,e).trim(),o=n===\"\"?\"*\":n.toLowerCase(),r=t.slice(e),l=[];for(let s of Et(r)){let a=T(s);a&&l.push(a)}return{tag:o,predicates:l}}function T(t){let e=t.trim();if(!e)return null;let n=_(e,\"or\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\"or\",predicates:l}}let o=_(e,\"and\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\"and\",predicates:l}}let r=xt(e,\"not\");if(r!=null){let l=T(r);return l?{type:\"not\",predicate:l}:null}return yt(e)}function yt(t){let e=/^(?:'([^']*)'|\"([^\"]*)\")$/,n=\"[a-zA-Z_][\\\\w.-]*\",o=`(?:'([^']*)'|\"([^\"]*)\")`;if(/^\\d+$/.test(t))return{type:\"index\",index:Math.max(1,Number(t))};let r=t.match(new RegExp(`^normalize-space\\\\(\\\\s*@(${n})\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(r)return{type:\"attrEquals\",name:r[1],value:r[2]??r[3]??\"\",normalize:!0};let l=t.match(new RegExp(`^normalize-space\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*\\\\)\\\\s*=\\\\s*${o}$`));if(l)return{type:\"textEquals\",value:l[1]??l[2]??\"\",normalize:!0};let s=t.match(new RegExp(`^@(${n})\\\\s*=\\\\s*${o}$`));if(s)return{type:\"attrEquals\",name:s[1],value:s[2]??s[3]??\"\"};let a=t.match(new RegExp(`^@(${n})$`));if(a)return{type:\"attrExists\",name:a[1]};let i=t.match(new RegExp(`^contains\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(i)return{type:\"attrContains\",name:i[1],value:i[2]??i[3]??\"\"};let m=t.match(new RegExp(`^starts-with\\\\(\\\\s*@(${n})\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));if(m)return{type:\"attrStartsWith\",name:m[1],value:m[2]??m[3]??\"\"};let f=t.match(new RegExp(`^(?:text\\\\(\\\\)|\\\\.)\\\\s*=\\\\s*${o}$`));if(f)return{type:\"textEquals\",value:f[1]??f[2]??\"\"};let c=t.match(new RegExp(`^contains\\\\(\\\\s*(?:text\\\\(\\\\)|\\\\.)\\\\s*,\\\\s*${o}\\\\s*\\\\)$`));return c?{type:\"textContains\",value:c[1]??c[2]??\"\"}:(e.test(t),null)}function _(t,e){let n=[],o=0,r=0,l=null,s=0;for(;s<t.length;){let a=t[s];if(l){a===l&&(l=null),s+=1;continue}if(a===\"'\"||a==='\"'){l=a,s+=1;continue}if(a===\"(\"){r+=1,s+=1;continue}if(a===\")\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&bt(t,s,e)){n.push(t.slice(o,s).trim()),s+=e.length,o=s;continue}s+=1}return n.push(t.slice(o).trim()),n.filter(a=>a.length>0)}function bt(t,e,n){if(!t.startsWith(n,e))return!1;let o=e>0?t[e-1]:\" \";if(o===\"@\")return!1;let r=e+n.length<t.length?t[e+n.length]:\" \";return O(o)&&O(r)}function O(t){return!/[a-zA-Z0-9_.-]/.test(t)}function xt(t,e){let n=`${e}(`;if(!t.startsWith(n)||!t.endsWith(\")\"))return null;let o=t.slice(n.length,-1);return St(o)?o:null}function St(t){let e=0,n=null;for(let o=0;o<t.length;o+=1){let r=t[o];if(n){r===n&&(n=null);continue}if(r===\"'\"||r==='\"'){n=r;continue}if(r===\"(\"?e+=1:r===\")\"&&(e-=1),e<0)return!1}return e===0}var vt=t=>t.replace(/\\s+/g,\" \").trim();function q(t){return String(t.textContent??\"\")}function S(t,e){return e?vt(t):t}function R(t,e){switch(e.type){case\"and\":return e.predicates.every(n=>R(t,n));case\"or\":return e.predicates.some(n=>R(t,n));case\"not\":return!R(t,e.predicate);case\"attrExists\":return t.getAttribute(e.name)!==null;case\"attrEquals\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize)===S(e.value,e.normalize)}case\"attrContains\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize).includes(S(e.value,e.normalize))}case\"attrStartsWith\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize).startsWith(S(e.value,e.normalize))}case\"textEquals\":return S(q(t),e.normalize)===S(e.value,e.normalize);case\"textContains\":return S(q(t),e.normalize).includes(S(e.value,e.normalize));case\"index\":return!0;default:return!0}}function k(t,e){let n=t;for(let o of e){if(!n.length)return[];if(o.type===\"index\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var M=t=>{let e=String(t??\"\").trim();return e?e.replace(/^xpath=/i,\"\").trim():\"\"};function I(t,e){return H(t,0,e)}function H(t,e,n){if(!Number.isFinite(e)||e<0)return null;let o=M(t);if(!o)return null;let r=Math.floor(e),l=n?.pierceShadow!==!1,s=l?B():null;if(!l)return F(o,r).value;if(!s?.hasShadow){let m=F(o,r);return m.error?C(o,s?.getClosedRoot)[r]??null:m.value}let a=C(o,s.getClosedRoot);return a.length>0?a[r]??null:z(o,s.getClosedRoot)[r]??null}function $(t,e){let n=M(t);if(!n)return 0;let o=e?.pierceShadow!==!1,r=o?B():null;if(!o)return X(n).count;if(!r?.hasShadow){let s=X(n);return s.error?C(n,r?.getClosedRoot).length:s.count}let l=C(n,r.getClosedRoot).length;return l>0?l:z(n,r.getClosedRoot).length}function C(t,e){let n=M(t);if(!n)return[];let o=P(n);if(!o.length)return[];let r=e??null,l=[document];for(let s of o){let a=[],i=new Set;for(let m of l){let f=s.axis===\"child\"?D(m,r):G(m,r);if(!f.length)continue;let c=f.filter(g=>V(g,s)),p=k(c,s.predicates);for(let g of p)i.has(g)||(i.add(g),a.push(g))}if(!a.length)return[];l=a}return l}function z(t,e){let n=M(t);if(!n)return[];let o=P(n);if(!o.some((s,a)=>s.axis===\"desc\"&&a>0))return[];let r=e??null,l=[document];for(let s=0;s<o.length;s+=1){let a=o[s],i=[],m=new Set;for(let f of l){let c=a.axis===\"child\"?Tt(f):s===0?G(f,r):Rt(f,r);if(!c.length)continue;let p=c.filter(w=>V(w,a)),g=k(p,a.predicates);for(let w of g)m.has(w)||(m.add(w),i.push(w))}if(!i.length)return[];l=i}return l}function V(t,e){return e.tag===\"*\"?!0:t.localName===e.tag}function B(){let t=window.__stagehandV3__,e=t&&typeof t.getClosedRoot==\"function\"?o=>{try{return t.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(t&&typeof t.stats==\"function\"){let o=t.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:e,hasShadow:n}}function D(t,e){let n=[];if(t instanceof Document)return t.documentElement&&n.push(t.documentElement),n;if(t instanceof ShadowRoot||t instanceof DocumentFragment)return n.push(...Array.from(t.children??[])),n;if(t instanceof Element){n.push(...Array.from(t.children??[]));let o=t.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),e){let r=e(t);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Tt(t){let e=[];return t instanceof Document?(t.documentElement&&e.push(t.documentElement),e):t instanceof ShadowRoot||t instanceof DocumentFragment?(e.push(...Array.from(t.children??[])),e):(t instanceof Element&&e.push(...Array.from(t.children??[])),e)}function Rt(t,e){let n=[];if(!(t instanceof Element))return n;let o=t.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),e){let r=e(t);r&&n.push(...Array.from(r.children??[]))}return n}function G(t,e){let n=[],o=new Set,r=[...D(t,e)].reverse();for(;r.length;){let l=r.pop();if(o.has(l))continue;o.add(l),n.push(l);let s=D(l,e);for(let a=s.length-1;a>=0;a-=1)r.push(s[a])}return n}function F(t,e){try{return{value:document.evaluate(t,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(e),error:!1}}catch{return{value:null,error:!0}}}function X(t){try{return{count:document.evaluate(t,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var N=t=>{let e=Number(t??0);return!Number.isFinite(e)||e<0?0:Math.floor(e)},Y=(t,e)=>{if(!t)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=a=>{if(!(!a||n.has(a)||r.length>=e)){n.add(a);try{let i=a.querySelectorAll(t);for(let m of i)if(!o.has(m)&&(o.add(m),r.push(m),r.length>=e))return}catch{}try{let m=(a instanceof Document?a:a.host?.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),f;for(;f=m.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<e;){let a=l.shift();a&&s(a)}return r};function Ct(t,e){let n=String(t??\"\").trim();if(!n)return null;let o=N(e);return Y(n,o+1)[o]??null}function Mt(t,e){let n=String(t??\"\").trim();if(!n)return null;let o=N(e),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return Y(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,a=new Set,i=[],m=[document],f=c=>{if(!(!c||s.has(c)||i.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!a.has(g)&&(a.add(g),i.push(g),i.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&m.push(x);let y=l(w);y&&m.push(y)}}catch{}}};for(;m.length&&i.length<o+1;){let c=m.shift();c&&f(c)}return i[o]??null}function Nt(t,e){let n=String(t??\"\");if(!n)return null;let o=n.toLowerCase(),r=N(e),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let d=u.tagName?.toUpperCase()??\"\";return l.has(d)},a=u=>{try{if(s(u))return\"\";let d=u.innerText;if(typeof d==\"string\"&&d.trim())return d.trim()}catch{}try{let d=u.textContent;if(typeof d==\"string\")return d.trim()}catch{}return\"\"},i=u=>{let d=a(u);return!!d&&d.toLowerCase().includes(o)},m=window.__stagehandV3__,f=m&&typeof m.getClosedRoot==\"function\"?u=>{try{return m.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&i(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:a(u)});let d=x(u);if(!d)continue;let E;for(;E=d.nextNode();){if(!(E instanceof Element))continue;i(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:a(E)});let b=E.shadowRoot;b&&w(b);let A=f(E);A&&w(A)}}let y=[];for(let u of g){let d=u.element,E=!1;for(let b of g)if(u!==b)try{if(d.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Lt(t,e){let n=N(e);return H(t,n,{pierceShadow:!0})}function Pt(t){let e=String(t??\"\").trim();if(!e)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(e).length)}catch{}try{let a=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();)i instanceof Element&&i.shadowRoot&&(l+=o(i.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(e).length}catch{return 0}}}function kt(t){let e=String(t??\"\").trim();if(!e)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(e).length}catch{return 0}let o=new WeakSet,r=[],l=i=>{!i||o.has(i)||(o.add(i),r.push(i))};l(document);let s=0,a=i=>{let m=i.shadowRoot;m&&l(m);try{let f=n.getClosedRoot(i);f&&l(f)}catch{}};for(;r.length;){let i=r.shift();if(i){try{let m=i;typeof m.querySelectorAll==\"function\"&&(s+=m.querySelectorAll(e).length)}catch{}try{let f=(i instanceof Document?i:i instanceof ShadowRoot?i.host?.ownerDocument??document:i.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&a(c)}catch{}}}return s}function Dt(t){let e=String(t??\"\");if(!e)return{count:0,sample:[],error:null};let n=e.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=h=>{if(!h)return!1;let u=h.tagName?.toUpperCase()??\"\";return o.has(u)},l=h=>{try{if(r(h))return\"\";let u=h.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=h.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=h=>{let u=l(h);return!!u&&u.toLowerCase().includes(n)},a=window.__stagehandV3__,i=a&&typeof a.getClosedRoot==\"function\"?h=>{try{return a.getClosedRoot(h)??null}catch{return null}}:h=>null,m=new WeakSet,f=[],c=h=>{!h||m.has(h)||(m.add(h),f.push(h))},p=h=>{try{return(h instanceof Document?h:h?.ownerDocument??document).createTreeWalker(h,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let h=f.shift();if(!h)continue;h instanceof Element&&s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let u=p(h);if(!u)continue;let d;for(;d=u.nextNode();){if(!(d instanceof Element))continue;s(d)&&g.push({element:d,tag:d.tagName??\"\",id:d.id??\"\",className:d.className??\"\",text:l(d)});let E=d.shadowRoot;E&&c(E);let b=i(d);b&&c(b)}}let w=[];for(let h of g){let u=h.element,d=!1;for(let E of g)if(h!==E)try{if(u.contains(E.element)){d=!0;break}}catch{}d||w.push(h)}let x=w.length,y=w.slice(0,5).map(h=>({tag:h.tag,id:h.id,class:h.className,text:h.text}));return{count:x,sample:y,error:null}}function Ht(t){return $(t,{pierceShadow:!0})}var At=t=>t.startsWith(\"xpath=\")||t.startsWith(\"/\"),Wt=t=>{try{let e=window.__stagehandV3__;if(e&&typeof e.getClosedRoot==\"function\")return e.getClosedRoot(t)??null}catch{}return null},Q=t=>t.shadowRoot?t.shadowRoot:Wt(t),_t=(t,e,n)=>{try{let l=t.querySelector(e);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[t];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(e);if(s)return s}catch{}try{let a=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();){if(!(i instanceof Element))continue;let m=Q(i);m&&!o.has(m)&&r.push(m)}}catch{}}}return null},Ot=(t,e)=>I(t,{pierceShadow:e}),K=(t,e)=>At(t)?Ot(t,e):_t(document,t,e),U=(t,e)=>{if(e===\"detached\")return t===null;if(e===\"attached\")return t!==null;if(t===null)return!1;if(e===\"hidden\")try{let n=window.getComputedStyle(t),o=t.getBoundingClientRect();return n.display===\"none\"||n.visibility===\"hidden\"||n.opacity===\"0\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(t),o=t.getBoundingClientRect();return n.display!==\"none\"&&n.visibility!==\"hidden\"&&n.opacity!==\"0\"&&o.width>0&&o.height>0}catch{return!1}},qt=(t,e)=>{let n=new WeakSet,o=l=>{let s=Q(l);if(s&&!n.has(s)){n.add(s);let a=new MutationObserver(t);a.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),e.push(a);for(let i of Array.from(s.children))o(i)}for(let a of Array.from(l.children))o(a)},r=document.documentElement||document.body;r&&o(r)};function Ft(t,e,n,o){let r=String(t??\"\").trim(),l=String(e??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,a=o!==!1;return new Promise((i,m)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=K(r,a);if(U(w,l)){p=!0,i(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},h=()=>{if(p)return;let E=K(r,a);U(E,l)&&(p=!0,g(),y(),i(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,h(),d()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let d=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(h);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),a&&qt(h,x)};d(),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}return nt(Xt);})();\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\n}";
|
|
9
9
|
exports.locatorScriptSources = {
|
|
10
|
-
"assignFilePayloadsToInputElement": "function
|
|
11
|
-
"countCssMatchesPierce": "function
|
|
12
|
-
"countCssMatchesPrimary": "function
|
|
13
|
-
"countTextMatches": "function
|
|
14
|
-
"countXPathMatchesMainWorld": "function
|
|
15
|
-
"dispatchDomClick": "function
|
|
16
|
-
"ensureFileInputElement": "function
|
|
17
|
-
"fillElementValue": "function
|
|
18
|
-
"focusElement": "function
|
|
19
|
-
"isElementChecked": "function
|
|
20
|
-
"isElementVisible": "function
|
|
21
|
-
"prepareElementForTyping": "function v(){try{let
|
|
22
|
-
"readElementInnerHTML": "function
|
|
23
|
-
"readElementInnerText": "function
|
|
24
|
-
"readElementInputValue": "function
|
|
25
|
-
"readElementTextContent": "function
|
|
26
|
-
"resolveCssSelector": "function
|
|
27
|
-
"resolveCssSelectorPierce": "function
|
|
28
|
-
"resolveTextSelector": "function
|
|
29
|
-
"resolveXPathMainWorld": "function
|
|
30
|
-
"scrollElementToPercent": "function
|
|
31
|
-
"selectElementOptions": "function
|
|
32
|
-
"waitForSelector": "function
|
|
10
|
+
"assignFilePayloadsToInputElement": "function ht(t){try{let e=this;if(!e||e.tagName?.toLowerCase()!==\"input\"||(e.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(t)?t:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",a=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),i=window.atob(r.base64??\"\"),m=new Uint8Array(i.length);for(let p=0;p<i.length;p+=1)m[p]=i.charCodeAt(p);let f=new Blob([m],{type:s}),c=new File([f],l,{type:s,lastModified:a});n.items.add(c)}return e.files=n.files,e.dispatchEvent(new Event(\"input\",{bubbles:!0})),e.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}",
|
|
11
|
+
"countCssMatchesPierce": "function _t(t){let e=String(t??\"\").trim();if(!e)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(e).length}catch{return 0}let o=new WeakSet,r=[],l=i=>{!i||o.has(i)||(o.add(i),r.push(i))};l(document);let s=0,a=i=>{let m=i.shadowRoot;m&&l(m);try{let f=n.getClosedRoot(i);f&&l(f)}catch{}};for(;r.length;){let i=r.shift();if(i){try{let m=i;typeof m.querySelectorAll==\"function\"&&(s+=m.querySelectorAll(e).length)}catch{}try{let f=(i instanceof Document?i:i instanceof ShadowRoot?i.host?.ownerDocument??document:i.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&a(c)}catch{}}}return s}",
|
|
12
|
+
"countCssMatchesPrimary": "function Wt(t){let e=String(t??\"\").trim();if(!e)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(e).length)}catch{}try{let a=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();)i instanceof Element&&i.shadowRoot&&(l+=o(i.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(e).length}catch{return 0}}}",
|
|
13
|
+
"countTextMatches": "function Ot(t){let e=String(t??\"\");if(!e)return{count:0,sample:[],error:null};let n=e.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=h=>{if(!h)return!1;let u=h.tagName?.toUpperCase()??\"\";return o.has(u)},l=h=>{try{if(r(h))return\"\";let u=h.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=h.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=h=>{let u=l(h);return!!u&&u.toLowerCase().includes(n)},a=window.__stagehandV3__,i=a&&typeof a.getClosedRoot==\"function\"?h=>{try{return a.getClosedRoot(h)??null}catch{return null}}:h=>null,m=new WeakSet,f=[],c=h=>{!h||m.has(h)||(m.add(h),f.push(h))},p=h=>{try{return(h instanceof Document?h:h?.ownerDocument??document).createTreeWalker(h,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let h=f.shift();if(!h)continue;h instanceof Element&&s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let u=p(h);if(!u)continue;let d;for(;d=u.nextNode();){if(!(d instanceof Element))continue;s(d)&&g.push({element:d,tag:d.tagName??\"\",id:d.id??\"\",className:d.className??\"\",text:l(d)});let E=d.shadowRoot;E&&c(E);let b=i(d);b&&c(b)}}let w=[];for(let h of g){let u=h.element,d=!1;for(let E of g)if(h!==E)try{if(u.contains(E.element)){d=!0;break}}catch{}d||w.push(h)}let x=w.length,y=w.slice(0,5).map(h=>({tag:h.tag,id:h.id,class:h.className,text:h.text}));return{count:x,sample:y,error:null}}",
|
|
14
|
+
"countXPathMatchesMainWorld": "function qt(t){return I(t,{pierceShadow:!0})}",
|
|
15
|
+
"dispatchDomClick": "function ft(t){let e=t??{};try{let n=new MouseEvent(\"click\",{bubbles:!!e.bubbles,cancelable:!!e.cancelable,composed:!!e.composed,detail:typeof e.detail==\"number\"?e.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}",
|
|
16
|
+
"ensureFileInputElement": "function mt(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}",
|
|
17
|
+
"fillElementValue": "function pt(t){let e=this;if(!e.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(e.ownerDocument||document).defaultView||window,r=t??\"\";try{let l=s=>{let a;if(typeof o.InputEvent==\"function\")try{a=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{a=new o.Event(\"input\",{bubbles:!0,composed:!0})}else a=new o.Event(\"input\",{bubbles:!0,composed:!0});e.dispatchEvent(a);let i=new o.Event(\"change\",{bubbles:!0});e.dispatchEvent(i)};if(e instanceof o.HTMLInputElement){let s=(e.type||\"\").toLowerCase();if(!Q.has(s)&&!A.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let a=t;if(s===\"number\"){let i=t.trim();if(i!==\"\"&&Number.isNaN(Number(i)))return{status:\"error\",reason:\"invalid-number-value\"};a=i}if(r=a,A.has(s)){let i=t.trim();r=i,v.call(e);let m=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(m,\"value\")?.set;return typeof c==\"function\"?c.call(e,i):e.value=i,e._valueTracker?.setValue?.(i),e.value!==i?{status:\"error\",reason:\"malformed-value\"}:(l(i),{status:\"done\"})}return v.call(e),{status:\"needsinput\",value:a}}return e instanceof o.HTMLTextAreaElement?(v.call(e),r=t,{status:\"needsinput\",value:t}):e instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:e.isContentEditable?(v.call(e),r=t,{status:\"needsinput\",value:t}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let a=l.message;typeof a==\"string\"&&a.trim().length>0&&(s=`exception:${a}`)}return{status:\"needsinput\",value:r,reason:s}}}",
|
|
18
|
+
"focusElement": "function gt(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}",
|
|
19
|
+
"isElementChecked": "function yt(){try{let t=this;if((t.tagName||\"\").toLowerCase()===\"input\"){let o=t.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!t.checked}let n=t.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}",
|
|
20
|
+
"isElementVisible": "function wt(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument?.defaultView?.getComputedStyle(t)??window.getComputedStyle(t);if(!e||e.display===\"none\"||e.visibility===\"hidden\")return!1;let n=parseFloat(e.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=t.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||t.getClientRects().length===0)}catch{return!1}}",
|
|
21
|
+
"prepareElementForTyping": "function v(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument||document,n=e.defaultView||window;try{typeof t.focus==\"function\"&&t.focus()}catch{}if(t instanceof n.HTMLInputElement||t instanceof n.HTMLTextAreaElement){try{if(typeof t.select==\"function\")return t.select(),!0}catch{}try{let o=(t.value??\"\").length;if(typeof t.setSelectionRange==\"function\")return t.setSelectionRange(0,o),!0}catch{}return!0}if(t.isContentEditable){let o=e.getSelection?.(),r=e.createRange?.();if(o&&r)try{r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}",
|
|
22
|
+
"readElementInnerHTML": "function St(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}",
|
|
23
|
+
"readElementInnerText": "function vt(){try{let t=this,e=t.innerText;if(typeof e==\"string\"&&e.length>0)return e;let n=t.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}",
|
|
24
|
+
"readElementInputValue": "function bt(){try{let t=this,e=(t.tagName||\"\").toLowerCase();return e===\"input\"||e===\"textarea\"||e===\"select\"?String(t.value??\"\"):t.isContentEditable?String(t.textContent??\"\"):\"\"}catch{return\"\"}}",
|
|
25
|
+
"readElementTextContent": "function xt(){try{return String(this.textContent??\"\")}catch{return\"\"}}",
|
|
26
|
+
"resolveCssSelector": "function Lt(t,e){let n=String(t??\"\").trim();if(!n)return null;let o=N(e);return G(n,o+1)[o]??null}",
|
|
27
|
+
"resolveCssSelectorPierce": "function Pt(t,e){let n=String(t??\"\").trim();if(!n)return null;let o=N(e),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return G(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,a=new Set,i=[],m=[document],f=c=>{if(!(!c||s.has(c)||i.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!a.has(g)&&(a.add(g),i.push(g),i.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&m.push(x);let y=l(w);y&&m.push(y)}}catch{}}};for(;m.length&&i.length<o+1;){let c=m.shift();c&&f(c)}return i[o]??null}",
|
|
28
|
+
"resolveTextSelector": "function kt(t,e){let n=String(t??\"\");if(!n)return null;let o=n.toLowerCase(),r=N(e),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let d=u.tagName?.toUpperCase()??\"\";return l.has(d)},a=u=>{try{if(s(u))return\"\";let d=u.innerText;if(typeof d==\"string\"&&d.trim())return d.trim()}catch{}try{let d=u.textContent;if(typeof d==\"string\")return d.trim()}catch{}return\"\"},i=u=>{let d=a(u);return!!d&&d.toLowerCase().includes(o)},m=window.__stagehandV3__,f=m&&typeof m.getClosedRoot==\"function\"?u=>{try{return m.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&i(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:a(u)});let d=x(u);if(!d)continue;let E;for(;E=d.nextNode();){if(!(E instanceof Element))continue;i(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:a(E)});let b=E.shadowRoot;b&&w(b);let H=f(E);H&&w(H)}}let y=[];for(let u of g){let d=u.element,E=!1;for(let b of g)if(u!==b)try{if(d.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}",
|
|
29
|
+
"resolveXPathMainWorld": "function Dt(t,e){let n=N(e);return D(t,n,{pierceShadow:!0})}",
|
|
30
|
+
"scrollElementToPercent": "function dt(t){let e=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(e(t),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,a=o.clientHeight??0,m=Math.max(0,s-a)*(n/100);return o.scrollTo({top:m,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}",
|
|
31
|
+
"selectElementOptions": "function Et(t){try{if(!(this instanceof HTMLSelectElement))return[];let e=Array.isArray(t)?t:[t],n=new Set(e.map(s=>String(s??\"\").trim())),o=s=>{let a=(s.label||s.textContent||\"\").trim(),i=String(s.value??\"\").trim();return n.has(a)||n.has(i)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let a of Array.from(this.options))!s&&o(a)?(a.selected=!0,this.value=a.value,s=!0):a.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}",
|
|
32
|
+
"waitForSelector": "function It(t,e,n,o){let r=String(t??\"\").trim(),l=String(e??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,a=o!==!1;return new Promise((i,m)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=Y(r,a);if(K(w,l)){p=!0,i(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},h=()=>{if(p)return;let E=Y(r,a);K(E,l)&&(p=!0,g(),y(),i(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,h(),d()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let d=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(h);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),a&&ut(h,x)};d(),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}"
|
|
33
33
|
};
|
|
34
34
|
exports.locatorScriptGlobalRefs = {
|
|
35
35
|
"assignFilePayloadsToInputElement": "globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locatorScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/locatorScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,sBAAsB,GAAG,0rtBAA0rtB,CAAC;AACpttB,QAAA,oBAAoB,GAAG;IAClC,kCAAkC,EAAE,8tBAA8tB;IAClwB,uBAAuB,EAAE,ktBAAktB;IAC3uB,wBAAwB,EAAE,sgBAAsgB;IAChiB,kBAAkB,EAAE,ugDAAugD;IAC3hD,4BAA4B,EAAE,+CAA+C;IAC7E,kBAAkB,EAAE,yRAAyR;IAC7S,wBAAwB,EAAE,8IAA8I;IACxK,kBAAkB,EAAE,mlDAAmlD;IACvmD,cAAc,EAAE,0EAA0E;IAC1F,kBAAkB,EAAE,8PAA8P;IAClR,kBAAkB,EAAE,mZAAmZ;IACva,yBAAyB,EAAE,imBAAimB;IAC5nB,sBAAsB,EAAE,0EAA0E;IAClG,sBAAsB,EAAE,mKAAmK;IAC3L,uBAAuB,EAAE,qNAAqN;IAC9O,wBAAwB,EAAE,4EAA4E;IACtG,oBAAoB,EAAE,sGAAsG;IAC5H,0BAA0B,EAAE,8uBAA8uB;IAC1wB,qBAAqB,EAAE,o5CAAo5C;IAC36C,uBAAuB,EAAE,8DAA8D;IACvF,wBAAwB,EAAE,45BAA45B;IACt7B,sBAAsB,EAAE,snBAAsnB;IAC9oB,iBAAiB,EAAE,+lCAA+lC;CAC1mC,CAAC;AACE,QAAA,uBAAuB,GAAG;IACrC,kCAAkC,EAAE,uEAAuE;IAC3G,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,4BAA4B,EAAE,iEAAiE;IAC/F,kBAAkB,EAAE,uDAAuD;IAC3E,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,cAAc,EAAE,mDAAmD;IACnE,kBAAkB,EAAE,uDAAuD;IAC3E,kBAAkB,EAAE,uDAAuD;IAC3E,yBAAyB,EAAE,8DAA8D;IACzF,sBAAsB,EAAE,2DAA2D;IACnF,sBAAsB,EAAE,2DAA2D;IACnF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,oBAAoB,EAAE,yDAAyD;IAC/E,0BAA0B,EAAE,+DAA+D;IAC3F,qBAAqB,EAAE,0DAA0D;IACjF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,sBAAsB,EAAE,2DAA2D;IACnF,iBAAiB,EAAE,sDAAsD;CACjE,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Run `pnpm run build-dom-scripts` to regenerate.\n */\nexport const locatorScriptBootstrap = \"if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,o)=>{if(t&&typeof t==\\\"object\\\"||typeof t==\\\"function\\\")for(let r of U(t))!Q.call(e,r)&&r!==n&&M(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var J=e=>j(M({},\\\"__esModule\\\",{value:!0}),e);var Oe={};Z(Oe,{assignFilePayloadsToInputElement:()=>te,countCssMatchesPierce:()=>Me,countCssMatchesPrimary:()=>Ce,countTextMatches:()=>Le,countXPathMatchesMainWorld:()=>Pe,dispatchDomClick:()=>ne,ensureFileInputElement:()=>ee,fillElementValue:()=>se,focusElement:()=>le,isElementChecked:()=>ce,isElementVisible:()=>ae,prepareElementForTyping:()=>v,readElementInnerHTML:()=>me,readElementInnerText:()=>fe,readElementInputValue:()=>ue,readElementTextContent:()=>de,resolveCssSelector:()=>ve,resolveCssSelectorPierce:()=>Te,resolveTextSelector:()=>Re,resolveXPathMainWorld:()=>Ne,scrollElementToPercent:()=>oe,selectElementOptions:()=>ie,waitForSelector:()=>_e});function ee(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}function te(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\\\"input\\\"||(t.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",i=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),a=window.atob(r.base64??\\\"\\\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),t.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}function ne(e){let t=e??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\\\"number\\\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function oe(e){let t=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}var H=new Set([\\\"color\\\",\\\"date\\\",\\\"datetime-local\\\",\\\"month\\\",\\\"range\\\",\\\"time\\\",\\\"week\\\"]),re=new Set([\\\"\\\",\\\"email\\\",\\\"number\\\",\\\"password\\\",\\\"search\\\",\\\"tel\\\",\\\"text\\\",\\\"url\\\"]);function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\\\"function\\\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\\\"function\\\")return e.select(),!0}catch{}try{let o=(e.value??\\\"\\\").length;if(typeof e.setSelectionRange==\\\"function\\\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function se(e){let t=this;if(!t.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\\\"\\\";try{let l=s=>{let i;if(typeof o.InputEvent==\\\"function\\\")try{i=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\\\"change\\\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\\\"\\\").toLowerCase();if(!re.has(s)&&!H.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\\\"number\\\"){let a=e.trim();if(a!==\\\"\\\"&&Number.isNaN(Number(a)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};i=a}if(r=i,H.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(a),{status:\\\"done\\\"})}return v.call(t),{status:\\\"needsinput\\\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):t instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:t.isContentEditable?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let i=l.message;typeof i==\\\"string\\\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}function le(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}function ie(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\\\"\\\").trim())),o=s=>{let i=(s.label||s.textContent||\\\"\\\").trim(),a=String(s.value??\\\"\\\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function ae(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\\\"none\\\"||t.visibility===\\\"hidden\\\")return!1;let n=parseFloat(t.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}function ce(){try{let e=this;if((e.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=e.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!e.checked}let n=e.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}function ue(){try{let e=this,t=(e.tagName||\\\"\\\").toLowerCase();return t===\\\"input\\\"||t===\\\"textarea\\\"||t===\\\"select\\\"?String(e.value??\\\"\\\"):e.isContentEditable?String(e.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}function de(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}function me(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}function fe(){try{let e=this,t=e.innerText;if(typeof t==\\\"string\\\"&&t.length>0)return t;let n=e.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}function O(e){let t=String(e||\\\"\\\").trim().replace(/^xpath=/i,\\\"\\\");if(!t)return[];let n=[],o=0;for(;o<t.length;){let r=\\\"child\\\";t.startsWith(\\\"//\\\",o)?(r=\\\"desc\\\",o+=2):t[o]===\\\"/\\\"&&(r=\\\"child\\\",o+=1);let l=o,s=0,i=null;for(;o<t.length;){let c=t[o];if(i)c===i&&(i=null);else if(c===\\\"'\\\"||c==='\\\"')i=c;else if(c===\\\"[\\\")s++;else if(c===\\\"]\\\")s--;else if(c===\\\"/\\\"&&s===0)break;o+=1}let a=t.slice(l,o).trim();if(!a)continue;let{tag:d,predicates:f}=pe(a);n.push({axis:r,tag:d,predicates:f})}return n}function he(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==\\\"[\\\"){n++;continue}n++;let o=n,r=null;for(;n<e.length;){let l=e[n];if(r)l===r&&(r=null);else if(l===\\\"'\\\"||l==='\\\"')r=l;else if(l===\\\"]\\\")break;n++}t.push(e.slice(o,n).trim()),n++}return t}function pe(e){let t=e.indexOf(\\\"[\\\");if(t===-1)return{tag:e===\\\"\\\"?\\\"*\\\":e.toLowerCase(),predicates:[]};let n=e.slice(0,t).trim(),o=n===\\\"\\\"?\\\"*\\\":n.toLowerCase(),r=e.slice(t),l=[];for(let s of he(r)){let i=T(s);i&&l.push(i)}return{tag:o,predicates:l}}function T(e){let t=e.trim();if(!t)return null;let n=A(t,\\\"or\\\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\\\"or\\\",predicates:l}}let o=A(t,\\\"and\\\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\\\"and\\\",predicates:l}}let r=we(t,\\\"not\\\");if(r!=null){let l=T(r);return l?{type:\\\"not\\\",predicate:l}:null}return ge(t)}function ge(e){let t=/^(?:'([^']*)'|\\\"([^\\\"]*)\\\")$/,n=\\\"[a-zA-Z_][\\\\\\\\w.-]*\\\",o=`(?:'([^']*)'|\\\"([^\\\"]*)\\\")`;if(/^\\\\d+$/.test(e))return{type:\\\"index\\\",index:Math.max(1,Number(e))};let r=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(r)return{type:\\\"attrEquals\\\",name:r[1],value:r[2]??r[3]??\\\"\\\",normalize:!0};let l=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(l)return{type:\\\"textEquals\\\",value:l[1]??l[2]??\\\"\\\",normalize:!0};let s=e.match(new RegExp(`^@(${n})\\\\\\\\s*=\\\\\\\\s*${o}$`));if(s)return{type:\\\"attrEquals\\\",name:s[1],value:s[2]??s[3]??\\\"\\\"};let i=e.match(new RegExp(`^@(${n})$`));if(i)return{type:\\\"attrExists\\\",name:i[1]};let a=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(a)return{type:\\\"attrContains\\\",name:a[1],value:a[2]??a[3]??\\\"\\\"};let d=e.match(new RegExp(`^starts-with\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(d)return{type:\\\"attrStartsWith\\\",name:d[1],value:d[2]??d[3]??\\\"\\\"};let f=e.match(new RegExp(`^(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(f)return{type:\\\"textEquals\\\",value:f[1]??f[2]??\\\"\\\"};let c=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));return c?{type:\\\"textContains\\\",value:c[1]??c[2]??\\\"\\\"}:(t.test(e),null)}function A(e,t){let n=[],o=0,r=0,l=null,s=0;for(;s<e.length;){let i=e[s];if(l){i===l&&(l=null),s+=1;continue}if(i===\\\"'\\\"||i==='\\\"'){l=i,s+=1;continue}if(i===\\\"(\\\"){r+=1,s+=1;continue}if(i===\\\")\\\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&Ee(e,s,t)){n.push(e.slice(o,s).trim()),s+=t.length,o=s;continue}s+=1}return n.push(e.slice(o).trim()),n.filter(i=>i.length>0)}function Ee(e,t,n){if(!e.startsWith(n,t))return!1;let o=t>0?e[t-1]:\\\" \\\";if(o===\\\"@\\\")return!1;let r=t+n.length<e.length?e[t+n.length]:\\\" \\\";return W(o)&&W(r)}function W(e){return!/[a-zA-Z0-9_.-]/.test(e)}function we(e,t){let n=`${t}(`;if(!e.startsWith(n)||!e.endsWith(\\\")\\\"))return null;let o=e.slice(n.length,-1);return ye(o)?o:null}function ye(e){let t=0,n=null;for(let o=0;o<e.length;o+=1){let r=e[o];if(n){r===n&&(n=null);continue}if(r===\\\"'\\\"||r==='\\\"'){n=r;continue}if(r===\\\"(\\\"?t+=1:r===\\\")\\\"&&(t-=1),t<0)return!1}return t===0}var be=e=>e.replace(/\\\\s+/g,\\\" \\\").trim();function _(e){return String(e.textContent??\\\"\\\")}function S(e,t){return t?be(e):e}function R(e,t){switch(t.type){case\\\"and\\\":return t.predicates.every(n=>R(e,n));case\\\"or\\\":return t.predicates.some(n=>R(e,n));case\\\"not\\\":return!R(e,t.predicate);case\\\"attrExists\\\":return e.getAttribute(t.name)!==null;case\\\"attrEquals\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize)===S(t.value,t.normalize)}case\\\"attrContains\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).includes(S(t.value,t.normalize))}case\\\"attrStartsWith\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).startsWith(S(t.value,t.normalize))}case\\\"textEquals\\\":return S(_(e),t.normalize)===S(t.value,t.normalize);case\\\"textContains\\\":return S(_(e),t.normalize).includes(S(t.value,t.normalize));case\\\"index\\\":return!0;default:return!0}}function q(e,t){let n=e;for(let o of t){if(!n.length)return[];if(o.type===\\\"index\\\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var P=e=>{let t=String(e??\\\"\\\").trim();return t?t.replace(/^xpath=/i,\\\"\\\").trim():\\\"\\\"};function I(e,t){return k(e,0,t)}function k(e,t,n){if(!Number.isFinite(t)||t<0)return null;let o=P(e);if(!o)return null;let r=Math.floor(t),l=n?.pierceShadow!==!1,s=l?z():null;if(!l)return X(o,r).value;if(!s?.hasShadow){let a=X(o,r);return a.error?N(o,s?.getClosedRoot)[r]??null:a.value}return N(o,s.getClosedRoot)[r]??null}function $(e,t){let n=P(e);if(!n)return 0;let o=t?.pierceShadow!==!1,r=o?z():null;if(!o)return F(n).count;if(!r?.hasShadow){let l=F(n);return l.error?N(n,r?.getClosedRoot).length:l.count}return N(n,r.getClosedRoot).length}function N(e,t){let n=P(e);if(!n)return[];let o=O(n);if(!o.length)return[];let r=t??null,l=[document];for(let s of o){let i=[],a=new Set;for(let d of l){if(!d)continue;let f=s.axis===\\\"child\\\"?L(d,r):Se(d,r);if(!f.length)continue;let c=f.filter(g=>xe(g,s)),p=q(c,s.predicates);for(let g of p)a.has(g)||(a.add(g),i.push(g))}if(!i.length)return[];l=i}return l}function xe(e,t){return t.tag===\\\"*\\\"?!0:e.localName===t.tag}function z(){let e=window.__stagehandV3__,t=e&&typeof e.getClosedRoot==\\\"function\\\"?o=>{try{return e.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(e&&typeof e.stats==\\\"function\\\"){let o=e.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:t,hasShadow:n}}function L(e,t){let n=[];if(!e)return n;if(e instanceof Document)return e.documentElement&&n.push(e.documentElement),n;if(e instanceof ShadowRoot||e instanceof DocumentFragment)return n.push(...Array.from(e.children??[])),n;if(e instanceof Element){n.push(...Array.from(e.children??[]));let o=e.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),t){let r=t(e);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Se(e,t){let n=[],o=new Set,r=[...L(e,t)].reverse();for(;r.length;){let l=r.pop();if(!l||o.has(l))continue;o.add(l),n.push(l);let s=L(l,t);for(let i=s.length-1;i>=0;i-=1)r.push(s[i])}return n}function X(e,t){try{return{value:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(t),error:!1}}catch{return{value:null,error:!0}}}function F(e){try{return{count:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var C=e=>{let t=Number(e??0);return!Number.isFinite(t)||t<0?0:Math.floor(t)},V=(e,t)=>{if(!e)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=i=>{if(!(!i||n.has(i)||r.length>=t)){n.add(i);try{let a=i.querySelectorAll(e);for(let d of a)if(!o.has(d)&&(o.add(d),r.push(d),r.length>=t))return}catch{}try{let d=(i instanceof Document?i:i.host?.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),f;for(;f=d.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<t;){let i=l.shift();i&&s(i)}return r};function ve(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t);return V(n,o+1)[o]??null}function Te(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return V(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}function Re(e,t){let n=String(e??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\\\"\\\";return l.has(h)},i=u=>{try{if(s(u))return\\\"\\\";let h=u.innerText;if(typeof h==\\\"string\\\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\\\"string\\\")return h.trim()}catch{}return\\\"\\\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\\\"function\\\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:i(E)});let b=E.shadowRoot;b&&w(b);let D=f(E);D&&w(D)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Ne(e,t){let n=C(t);return k(e,n,{pierceShadow:!0})}function Ce(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}function Me(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\\\"function\\\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}function Le(e){let t=String(e??\\\"\\\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=m=>{try{if(r(m))return\\\"\\\";let u=m.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\\\"function\\\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\\\"\\\",id:m.id??\\\"\\\",className:m.className??\\\"\\\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}function Pe(e){return $(e,{pierceShadow:!0})}var ke=e=>e.startsWith(\\\"xpath=\\\")||e.startsWith(\\\"/\\\"),De=e=>{try{let t=window.__stagehandV3__;if(t&&typeof t.getClosedRoot==\\\"function\\\")return t.getClosedRoot(e)??null}catch{}return null},Y=e=>e.shadowRoot?e.shadowRoot:De(e),He=(e,t,n)=>{try{let l=e.querySelector(t);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[e];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(t);if(s)return s}catch{}try{let i=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();){if(!(a instanceof Element))continue;let d=Y(a);d&&!o.has(d)&&r.push(d)}}catch{}}}return null},Ae=(e,t)=>I(e,{pierceShadow:t}),B=(e,t)=>ke(e)?Ae(e,t):He(document,e,t),G=(e,t)=>{if(t===\\\"detached\\\")return e===null;if(t===\\\"attached\\\")return e!==null;if(e===null)return!1;if(t===\\\"hidden\\\")try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display===\\\"none\\\"||n.visibility===\\\"hidden\\\"||n.opacity===\\\"0\\\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display!==\\\"none\\\"&&n.visibility!==\\\"hidden\\\"&&n.opacity!==\\\"0\\\"&&o.width>0&&o.height>0}catch{return!1}},We=(e,t)=>{let n=new WeakSet,o=l=>{let s=Y(l);if(s&&!n.has(s)){n.add(s);let i=new MutationObserver(e);i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),t.push(i);for(let a of Array.from(s.children))o(a)}for(let i of Array.from(l.children))o(i)},r=document.documentElement||document.body;r&&o(r)};function _e(e,t,n,o){let r=String(e??\\\"\\\").trim(),l=String(t??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=B(r,i);if(G(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},m=()=>{if(p)return;let E=B(r,i);G(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,m(),h()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),i&&We(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}return J(Oe);})();\\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\\n}\";\nexport const locatorScriptSources = {\n \"assignFilePayloadsToInputElement\": \"function ce(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\\\"input\\\"||(t.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",i=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),a=window.atob(r.base64??\\\"\\\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),t.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}\",\n \"countCssMatchesPierce\": \"function He(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\\\"function\\\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}\",\n \"countCssMatchesPrimary\": \"function De(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}\",\n \"countTextMatches\": \"function Ae(e){let t=String(e??\\\"\\\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=m=>{try{if(r(m))return\\\"\\\";let u=m.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\\\"function\\\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\\\"\\\",id:m.id??\\\"\\\",className:m.className??\\\"\\\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}\",\n \"countXPathMatchesMainWorld\": \"function We(e){return I(e,{pierceShadow:!0})}\",\n \"dispatchDomClick\": \"function ue(e){let t=e??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\\\"number\\\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}\",\n \"ensureFileInputElement\": \"function ae(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}\",\n \"fillElementValue\": \"function me(e){let t=this;if(!t.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\\\"\\\";try{let l=s=>{let i;if(typeof o.InputEvent==\\\"function\\\")try{i=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\\\"change\\\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\\\"\\\").toLowerCase();if(!Y.has(s)&&!D.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\\\"number\\\"){let a=e.trim();if(a!==\\\"\\\"&&Number.isNaN(Number(a)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};i=a}if(r=i,D.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(a),{status:\\\"done\\\"})}return v.call(t),{status:\\\"needsinput\\\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):t instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:t.isContentEditable?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let i=l.message;typeof i==\\\"string\\\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}\",\n \"focusElement\": \"function fe(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}\",\n \"isElementChecked\": \"function ge(){try{let e=this;if((e.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=e.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!e.checked}let n=e.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}\",\n \"isElementVisible\": \"function pe(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\\\"none\\\"||t.visibility===\\\"hidden\\\")return!1;let n=parseFloat(t.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}\",\n \"prepareElementForTyping\": \"function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\\\"function\\\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\\\"function\\\")return e.select(),!0}catch{}try{let o=(e.value??\\\"\\\").length;if(typeof e.setSelectionRange==\\\"function\\\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}\",\n \"readElementInnerHTML\": \"function ye(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"readElementInnerText\": \"function be(){try{let e=this,t=e.innerText;if(typeof t==\\\"string\\\"&&t.length>0)return t;let n=e.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementInputValue\": \"function Ee(){try{let e=this,t=(e.tagName||\\\"\\\").toLowerCase();return t===\\\"input\\\"||t===\\\"textarea\\\"||t===\\\"select\\\"?String(e.value??\\\"\\\"):e.isContentEditable?String(e.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementTextContent\": \"function we(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"resolveCssSelector\": \"function Ne(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t);return z(n,o+1)[o]??null}\",\n \"resolveCssSelectorPierce\": \"function Ce(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return z(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}\",\n \"resolveTextSelector\": \"function Me(e,t){let n=String(e??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\\\"\\\";return l.has(h)},i=u=>{try{if(s(u))return\\\"\\\";let h=u.innerText;if(typeof h==\\\"string\\\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\\\"string\\\")return h.trim()}catch{}return\\\"\\\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\\\"function\\\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:i(E)});let b=E.shadowRoot;b&&w(b);let k=f(E);k&&w(k)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}\",\n \"resolveXPathMainWorld\": \"function Le(e,t){let n=C(t);return P(e,n,{pierceShadow:!0})}\",\n \"scrollElementToPercent\": \"function de(e){let t=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}\",\n \"selectElementOptions\": \"function he(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\\\"\\\").trim())),o=s=>{let i=(s.label||s.textContent||\\\"\\\").trim(),a=String(s.value??\\\"\\\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}\",\n \"waitForSelector\": \"function qe(e,t,n,o){let r=String(e??\\\"\\\").trim(),l=String(t??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=V(r,i);if(B(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},m=()=>{if(p)return;let E=V(r,i);B(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,m(),h()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),i&&ie(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}\"\n} as const;\nexport const locatorScriptGlobalRefs = {\n \"assignFilePayloadsToInputElement\": \"globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement\",\n \"countCssMatchesPierce\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPierce\",\n \"countCssMatchesPrimary\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPrimary\",\n \"countTextMatches\": \"globalThis.__stagehandLocatorScripts.countTextMatches\",\n \"countXPathMatchesMainWorld\": \"globalThis.__stagehandLocatorScripts.countXPathMatchesMainWorld\",\n \"dispatchDomClick\": \"globalThis.__stagehandLocatorScripts.dispatchDomClick\",\n \"ensureFileInputElement\": \"globalThis.__stagehandLocatorScripts.ensureFileInputElement\",\n \"fillElementValue\": \"globalThis.__stagehandLocatorScripts.fillElementValue\",\n \"focusElement\": \"globalThis.__stagehandLocatorScripts.focusElement\",\n \"isElementChecked\": \"globalThis.__stagehandLocatorScripts.isElementChecked\",\n \"isElementVisible\": \"globalThis.__stagehandLocatorScripts.isElementVisible\",\n \"prepareElementForTyping\": \"globalThis.__stagehandLocatorScripts.prepareElementForTyping\",\n \"readElementInnerHTML\": \"globalThis.__stagehandLocatorScripts.readElementInnerHTML\",\n \"readElementInnerText\": \"globalThis.__stagehandLocatorScripts.readElementInnerText\",\n \"readElementInputValue\": \"globalThis.__stagehandLocatorScripts.readElementInputValue\",\n \"readElementTextContent\": \"globalThis.__stagehandLocatorScripts.readElementTextContent\",\n \"resolveCssSelector\": \"globalThis.__stagehandLocatorScripts.resolveCssSelector\",\n \"resolveCssSelectorPierce\": \"globalThis.__stagehandLocatorScripts.resolveCssSelectorPierce\",\n \"resolveTextSelector\": \"globalThis.__stagehandLocatorScripts.resolveTextSelector\",\n \"resolveXPathMainWorld\": \"globalThis.__stagehandLocatorScripts.resolveXPathMainWorld\",\n \"scrollElementToPercent\": \"globalThis.__stagehandLocatorScripts.scrollElementToPercent\",\n \"selectElementOptions\": \"globalThis.__stagehandLocatorScripts.selectElementOptions\",\n \"waitForSelector\": \"globalThis.__stagehandLocatorScripts.waitForSelector\"\n} as const;\nexport type LocatorScriptName = keyof typeof locatorScriptSources;\n"]}
|
|
1
|
+
{"version":3,"file":"locatorScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/locatorScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,sBAAsB,GAAG,0kvBAA0kvB,CAAC;AACpmvB,QAAA,oBAAoB,GAAG;IAClC,kCAAkC,EAAE,8tBAA8tB;IAClwB,uBAAuB,EAAE,ktBAAktB;IAC3uB,wBAAwB,EAAE,sgBAAsgB;IAChiB,kBAAkB,EAAE,ugDAAugD;IAC3hD,4BAA4B,EAAE,+CAA+C;IAC7E,kBAAkB,EAAE,yRAAyR;IAC7S,wBAAwB,EAAE,8IAA8I;IACxK,kBAAkB,EAAE,mlDAAmlD;IACvmD,cAAc,EAAE,0EAA0E;IAC1F,kBAAkB,EAAE,8PAA8P;IAClR,kBAAkB,EAAE,mZAAmZ;IACva,yBAAyB,EAAE,imBAAimB;IAC5nB,sBAAsB,EAAE,0EAA0E;IAClG,sBAAsB,EAAE,mKAAmK;IAC3L,uBAAuB,EAAE,qNAAqN;IAC9O,wBAAwB,EAAE,4EAA4E;IACtG,oBAAoB,EAAE,sGAAsG;IAC5H,0BAA0B,EAAE,8uBAA8uB;IAC1wB,qBAAqB,EAAE,o5CAAo5C;IAC36C,uBAAuB,EAAE,8DAA8D;IACvF,wBAAwB,EAAE,45BAA45B;IACt7B,sBAAsB,EAAE,snBAAsnB;IAC9oB,iBAAiB,EAAE,+lCAA+lC;CAC1mC,CAAC;AACE,QAAA,uBAAuB,GAAG;IACrC,kCAAkC,EAAE,uEAAuE;IAC3G,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,4BAA4B,EAAE,iEAAiE;IAC/F,kBAAkB,EAAE,uDAAuD;IAC3E,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,cAAc,EAAE,mDAAmD;IACnE,kBAAkB,EAAE,uDAAuD;IAC3E,kBAAkB,EAAE,uDAAuD;IAC3E,yBAAyB,EAAE,8DAA8D;IACzF,sBAAsB,EAAE,2DAA2D;IACnF,sBAAsB,EAAE,2DAA2D;IACnF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,oBAAoB,EAAE,yDAAyD;IAC/E,0BAA0B,EAAE,+DAA+D;IAC3F,qBAAqB,EAAE,0DAA0D;IACjF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,sBAAsB,EAAE,2DAA2D;IACnF,iBAAiB,EAAE,sDAAsD;CACjE,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Run `pnpm run build-dom-scripts` to regenerate.\n */\nexport const locatorScriptBootstrap = \"if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var L=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var tt=(t,e)=>{for(var n in e)L(t,n,{get:e[n],enumerable:!0})},et=(t,e,n,o)=>{if(e&&typeof e==\\\"object\\\"||typeof e==\\\"function\\\")for(let r of j(e))!J.call(t,r)&&r!==n&&L(t,r,{get:()=>e[r],enumerable:!(o=Z(e,r))||o.enumerable});return t};var nt=t=>et(L({},\\\"__esModule\\\",{value:!0}),t);var Xt={};tt(Xt,{assignFilePayloadsToInputElement:()=>rt,countCssMatchesPierce:()=>kt,countCssMatchesPrimary:()=>Pt,countTextMatches:()=>Dt,countXPathMatchesMainWorld:()=>Ht,dispatchDomClick:()=>st,ensureFileInputElement:()=>ot,fillElementValue:()=>it,focusElement:()=>ct,isElementChecked:()=>ht,isElementVisible:()=>mt,prepareElementForTyping:()=>v,readElementInnerHTML:()=>pt,readElementInnerText:()=>gt,readElementInputValue:()=>ft,readElementTextContent:()=>dt,resolveCssSelector:()=>Ct,resolveCssSelectorPierce:()=>Mt,resolveTextSelector:()=>Nt,resolveXPathMainWorld:()=>Lt,scrollElementToPercent:()=>lt,selectElementOptions:()=>ut,waitForSelector:()=>Ft});function ot(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}function rt(t){try{let e=this;if(!e||e.tagName?.toLowerCase()!==\\\"input\\\"||(e.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(t)?t:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",a=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),i=window.atob(r.base64??\\\"\\\"),m=new Uint8Array(i.length);for(let p=0;p<i.length;p+=1)m[p]=i.charCodeAt(p);let f=new Blob([m],{type:s}),c=new File([f],l,{type:s,lastModified:a});n.items.add(c)}return e.files=n.files,e.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),e.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}function st(t){let e=t??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!e.bubbles,cancelable:!!e.cancelable,composed:!!e.composed,detail:typeof e.detail==\\\"number\\\"?e.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function lt(t){let e=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(e(t),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,a=o.clientHeight??0,m=Math.max(0,s-a)*(n/100);return o.scrollTo({top:m,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}var W=new Set([\\\"color\\\",\\\"date\\\",\\\"datetime-local\\\",\\\"month\\\",\\\"range\\\",\\\"time\\\",\\\"week\\\"]),at=new Set([\\\"\\\",\\\"email\\\",\\\"number\\\",\\\"password\\\",\\\"search\\\",\\\"tel\\\",\\\"text\\\",\\\"url\\\"]);function v(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument||document,n=e.defaultView||window;try{typeof t.focus==\\\"function\\\"&&t.focus()}catch{}if(t instanceof n.HTMLInputElement||t instanceof n.HTMLTextAreaElement){try{if(typeof t.select==\\\"function\\\")return t.select(),!0}catch{}try{let o=(t.value??\\\"\\\").length;if(typeof t.setSelectionRange==\\\"function\\\")return t.setSelectionRange(0,o),!0}catch{}return!0}if(t.isContentEditable){let o=e.getSelection?.(),r=e.createRange?.();if(o&&r)try{r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function it(t){let e=this;if(!e.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(e.ownerDocument||document).defaultView||window,r=t??\\\"\\\";try{let l=s=>{let a;if(typeof o.InputEvent==\\\"function\\\")try{a=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{a=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else a=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});e.dispatchEvent(a);let i=new o.Event(\\\"change\\\",{bubbles:!0});e.dispatchEvent(i)};if(e instanceof o.HTMLInputElement){let s=(e.type||\\\"\\\").toLowerCase();if(!at.has(s)&&!W.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let a=t;if(s===\\\"number\\\"){let i=t.trim();if(i!==\\\"\\\"&&Number.isNaN(Number(i)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};a=i}if(r=a,W.has(s)){let i=t.trim();r=i,v.call(e);let m=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(m,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(e,i):e.value=i,e._valueTracker?.setValue?.(i),e.value!==i?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(i),{status:\\\"done\\\"})}return v.call(e),{status:\\\"needsinput\\\",value:a}}return e instanceof o.HTMLTextAreaElement?(v.call(e),r=t,{status:\\\"needsinput\\\",value:t}):e instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:e.isContentEditable?(v.call(e),r=t,{status:\\\"needsinput\\\",value:t}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let a=l.message;typeof a==\\\"string\\\"&&a.trim().length>0&&(s=`exception:${a}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}function ct(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}function ut(t){try{if(!(this instanceof HTMLSelectElement))return[];let e=Array.isArray(t)?t:[t],n=new Set(e.map(s=>String(s??\\\"\\\").trim())),o=s=>{let a=(s.label||s.textContent||\\\"\\\").trim(),i=String(s.value??\\\"\\\").trim();return n.has(a)||n.has(i)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let a of Array.from(this.options))!s&&o(a)?(a.selected=!0,this.value=a.value,s=!0):a.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function mt(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument?.defaultView?.getComputedStyle(t)??window.getComputedStyle(t);if(!e||e.display===\\\"none\\\"||e.visibility===\\\"hidden\\\")return!1;let n=parseFloat(e.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=t.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||t.getClientRects().length===0)}catch{return!1}}function ht(){try{let t=this;if((t.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=t.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!t.checked}let n=t.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}function ft(){try{let t=this,e=(t.tagName||\\\"\\\").toLowerCase();return e===\\\"input\\\"||e===\\\"textarea\\\"||e===\\\"select\\\"?String(t.value??\\\"\\\"):t.isContentEditable?String(t.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}function dt(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}function pt(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}function gt(){try{let t=this,e=t.innerText;if(typeof e==\\\"string\\\"&&e.length>0)return e;let n=t.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}function P(t){let e=String(t||\\\"\\\").trim().replace(/^xpath=/i,\\\"\\\");if(!e)return[];let n=[],o=0;for(;o<e.length;){let r=\\\"child\\\";e.startsWith(\\\"//\\\",o)?(r=\\\"desc\\\",o+=2):e[o]===\\\"/\\\"&&(r=\\\"child\\\",o+=1);let l=o,s=0,a=null;for(;o<e.length;){let c=e[o];if(a)c===a&&(a=null);else if(c===\\\"'\\\"||c==='\\\"')a=c;else if(c===\\\"[\\\")s++;else if(c===\\\"]\\\")s--;else if(c===\\\"/\\\"&&s===0)break;o+=1}let i=e.slice(l,o).trim();if(!i)continue;let{tag:m,predicates:f}=wt(i);n.push({axis:r,tag:m,predicates:f})}return n}function Et(t){let e=[],n=0;for(;n<t.length;){if(t[n]!==\\\"[\\\"){n++;continue}n++;let o=n,r=null;for(;n<t.length;){let l=t[n];if(r)l===r&&(r=null);else if(l===\\\"'\\\"||l==='\\\"')r=l;else if(l===\\\"]\\\")break;n++}e.push(t.slice(o,n).trim()),n++}return e}function wt(t){let e=t.indexOf(\\\"[\\\");if(e===-1)return{tag:t===\\\"\\\"?\\\"*\\\":t.toLowerCase(),predicates:[]};let n=t.slice(0,e).trim(),o=n===\\\"\\\"?\\\"*\\\":n.toLowerCase(),r=t.slice(e),l=[];for(let s of Et(r)){let a=T(s);a&&l.push(a)}return{tag:o,predicates:l}}function T(t){let e=t.trim();if(!e)return null;let n=_(e,\\\"or\\\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\\\"or\\\",predicates:l}}let o=_(e,\\\"and\\\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\\\"and\\\",predicates:l}}let r=xt(e,\\\"not\\\");if(r!=null){let l=T(r);return l?{type:\\\"not\\\",predicate:l}:null}return yt(e)}function yt(t){let e=/^(?:'([^']*)'|\\\"([^\\\"]*)\\\")$/,n=\\\"[a-zA-Z_][\\\\\\\\w.-]*\\\",o=`(?:'([^']*)'|\\\"([^\\\"]*)\\\")`;if(/^\\\\d+$/.test(t))return{type:\\\"index\\\",index:Math.max(1,Number(t))};let r=t.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(r)return{type:\\\"attrEquals\\\",name:r[1],value:r[2]??r[3]??\\\"\\\",normalize:!0};let l=t.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(l)return{type:\\\"textEquals\\\",value:l[1]??l[2]??\\\"\\\",normalize:!0};let s=t.match(new RegExp(`^@(${n})\\\\\\\\s*=\\\\\\\\s*${o}$`));if(s)return{type:\\\"attrEquals\\\",name:s[1],value:s[2]??s[3]??\\\"\\\"};let a=t.match(new RegExp(`^@(${n})$`));if(a)return{type:\\\"attrExists\\\",name:a[1]};let i=t.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(i)return{type:\\\"attrContains\\\",name:i[1],value:i[2]??i[3]??\\\"\\\"};let m=t.match(new RegExp(`^starts-with\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(m)return{type:\\\"attrStartsWith\\\",name:m[1],value:m[2]??m[3]??\\\"\\\"};let f=t.match(new RegExp(`^(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(f)return{type:\\\"textEquals\\\",value:f[1]??f[2]??\\\"\\\"};let c=t.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));return c?{type:\\\"textContains\\\",value:c[1]??c[2]??\\\"\\\"}:(e.test(t),null)}function _(t,e){let n=[],o=0,r=0,l=null,s=0;for(;s<t.length;){let a=t[s];if(l){a===l&&(l=null),s+=1;continue}if(a===\\\"'\\\"||a==='\\\"'){l=a,s+=1;continue}if(a===\\\"(\\\"){r+=1,s+=1;continue}if(a===\\\")\\\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&bt(t,s,e)){n.push(t.slice(o,s).trim()),s+=e.length,o=s;continue}s+=1}return n.push(t.slice(o).trim()),n.filter(a=>a.length>0)}function bt(t,e,n){if(!t.startsWith(n,e))return!1;let o=e>0?t[e-1]:\\\" \\\";if(o===\\\"@\\\")return!1;let r=e+n.length<t.length?t[e+n.length]:\\\" \\\";return O(o)&&O(r)}function O(t){return!/[a-zA-Z0-9_.-]/.test(t)}function xt(t,e){let n=`${e}(`;if(!t.startsWith(n)||!t.endsWith(\\\")\\\"))return null;let o=t.slice(n.length,-1);return St(o)?o:null}function St(t){let e=0,n=null;for(let o=0;o<t.length;o+=1){let r=t[o];if(n){r===n&&(n=null);continue}if(r===\\\"'\\\"||r==='\\\"'){n=r;continue}if(r===\\\"(\\\"?e+=1:r===\\\")\\\"&&(e-=1),e<0)return!1}return e===0}var vt=t=>t.replace(/\\\\s+/g,\\\" \\\").trim();function q(t){return String(t.textContent??\\\"\\\")}function S(t,e){return e?vt(t):t}function R(t,e){switch(e.type){case\\\"and\\\":return e.predicates.every(n=>R(t,n));case\\\"or\\\":return e.predicates.some(n=>R(t,n));case\\\"not\\\":return!R(t,e.predicate);case\\\"attrExists\\\":return t.getAttribute(e.name)!==null;case\\\"attrEquals\\\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize)===S(e.value,e.normalize)}case\\\"attrContains\\\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize).includes(S(e.value,e.normalize))}case\\\"attrStartsWith\\\":{let n=t.getAttribute(e.name);return n===null?!1:S(n,e.normalize).startsWith(S(e.value,e.normalize))}case\\\"textEquals\\\":return S(q(t),e.normalize)===S(e.value,e.normalize);case\\\"textContains\\\":return S(q(t),e.normalize).includes(S(e.value,e.normalize));case\\\"index\\\":return!0;default:return!0}}function k(t,e){let n=t;for(let o of e){if(!n.length)return[];if(o.type===\\\"index\\\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var M=t=>{let e=String(t??\\\"\\\").trim();return e?e.replace(/^xpath=/i,\\\"\\\").trim():\\\"\\\"};function I(t,e){return H(t,0,e)}function H(t,e,n){if(!Number.isFinite(e)||e<0)return null;let o=M(t);if(!o)return null;let r=Math.floor(e),l=n?.pierceShadow!==!1,s=l?B():null;if(!l)return F(o,r).value;if(!s?.hasShadow){let m=F(o,r);return m.error?C(o,s?.getClosedRoot)[r]??null:m.value}let a=C(o,s.getClosedRoot);return a.length>0?a[r]??null:z(o,s.getClosedRoot)[r]??null}function $(t,e){let n=M(t);if(!n)return 0;let o=e?.pierceShadow!==!1,r=o?B():null;if(!o)return X(n).count;if(!r?.hasShadow){let s=X(n);return s.error?C(n,r?.getClosedRoot).length:s.count}let l=C(n,r.getClosedRoot).length;return l>0?l:z(n,r.getClosedRoot).length}function C(t,e){let n=M(t);if(!n)return[];let o=P(n);if(!o.length)return[];let r=e??null,l=[document];for(let s of o){let a=[],i=new Set;for(let m of l){let f=s.axis===\\\"child\\\"?D(m,r):G(m,r);if(!f.length)continue;let c=f.filter(g=>V(g,s)),p=k(c,s.predicates);for(let g of p)i.has(g)||(i.add(g),a.push(g))}if(!a.length)return[];l=a}return l}function z(t,e){let n=M(t);if(!n)return[];let o=P(n);if(!o.some((s,a)=>s.axis===\\\"desc\\\"&&a>0))return[];let r=e??null,l=[document];for(let s=0;s<o.length;s+=1){let a=o[s],i=[],m=new Set;for(let f of l){let c=a.axis===\\\"child\\\"?Tt(f):s===0?G(f,r):Rt(f,r);if(!c.length)continue;let p=c.filter(w=>V(w,a)),g=k(p,a.predicates);for(let w of g)m.has(w)||(m.add(w),i.push(w))}if(!i.length)return[];l=i}return l}function V(t,e){return e.tag===\\\"*\\\"?!0:t.localName===e.tag}function B(){let t=window.__stagehandV3__,e=t&&typeof t.getClosedRoot==\\\"function\\\"?o=>{try{return t.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(t&&typeof t.stats==\\\"function\\\"){let o=t.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:e,hasShadow:n}}function D(t,e){let n=[];if(t instanceof Document)return t.documentElement&&n.push(t.documentElement),n;if(t instanceof ShadowRoot||t instanceof DocumentFragment)return n.push(...Array.from(t.children??[])),n;if(t instanceof Element){n.push(...Array.from(t.children??[]));let o=t.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),e){let r=e(t);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Tt(t){let e=[];return t instanceof Document?(t.documentElement&&e.push(t.documentElement),e):t instanceof ShadowRoot||t instanceof DocumentFragment?(e.push(...Array.from(t.children??[])),e):(t instanceof Element&&e.push(...Array.from(t.children??[])),e)}function Rt(t,e){let n=[];if(!(t instanceof Element))return n;let o=t.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),e){let r=e(t);r&&n.push(...Array.from(r.children??[]))}return n}function G(t,e){let n=[],o=new Set,r=[...D(t,e)].reverse();for(;r.length;){let l=r.pop();if(o.has(l))continue;o.add(l),n.push(l);let s=D(l,e);for(let a=s.length-1;a>=0;a-=1)r.push(s[a])}return n}function F(t,e){try{return{value:document.evaluate(t,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(e),error:!1}}catch{return{value:null,error:!0}}}function X(t){try{return{count:document.evaluate(t,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var N=t=>{let e=Number(t??0);return!Number.isFinite(e)||e<0?0:Math.floor(e)},Y=(t,e)=>{if(!t)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=a=>{if(!(!a||n.has(a)||r.length>=e)){n.add(a);try{let i=a.querySelectorAll(t);for(let m of i)if(!o.has(m)&&(o.add(m),r.push(m),r.length>=e))return}catch{}try{let m=(a instanceof Document?a:a.host?.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),f;for(;f=m.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<e;){let a=l.shift();a&&s(a)}return r};function Ct(t,e){let n=String(t??\\\"\\\").trim();if(!n)return null;let o=N(e);return Y(n,o+1)[o]??null}function Mt(t,e){let n=String(t??\\\"\\\").trim();if(!n)return null;let o=N(e),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return Y(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,a=new Set,i=[],m=[document],f=c=>{if(!(!c||s.has(c)||i.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!a.has(g)&&(a.add(g),i.push(g),i.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&m.push(x);let y=l(w);y&&m.push(y)}}catch{}}};for(;m.length&&i.length<o+1;){let c=m.shift();c&&f(c)}return i[o]??null}function Nt(t,e){let n=String(t??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=N(e),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let d=u.tagName?.toUpperCase()??\\\"\\\";return l.has(d)},a=u=>{try{if(s(u))return\\\"\\\";let d=u.innerText;if(typeof d==\\\"string\\\"&&d.trim())return d.trim()}catch{}try{let d=u.textContent;if(typeof d==\\\"string\\\")return d.trim()}catch{}return\\\"\\\"},i=u=>{let d=a(u);return!!d&&d.toLowerCase().includes(o)},m=window.__stagehandV3__,f=m&&typeof m.getClosedRoot==\\\"function\\\"?u=>{try{return m.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&i(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:a(u)});let d=x(u);if(!d)continue;let E;for(;E=d.nextNode();){if(!(E instanceof Element))continue;i(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:a(E)});let b=E.shadowRoot;b&&w(b);let A=f(E);A&&w(A)}}let y=[];for(let u of g){let d=u.element,E=!1;for(let b of g)if(u!==b)try{if(d.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Lt(t,e){let n=N(e);return H(t,n,{pierceShadow:!0})}function Pt(t){let e=String(t??\\\"\\\").trim();if(!e)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(e).length)}catch{}try{let a=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();)i instanceof Element&&i.shadowRoot&&(l+=o(i.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(e).length}catch{return 0}}}function kt(t){let e=String(t??\\\"\\\").trim();if(!e)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(e).length}catch{return 0}let o=new WeakSet,r=[],l=i=>{!i||o.has(i)||(o.add(i),r.push(i))};l(document);let s=0,a=i=>{let m=i.shadowRoot;m&&l(m);try{let f=n.getClosedRoot(i);f&&l(f)}catch{}};for(;r.length;){let i=r.shift();if(i){try{let m=i;typeof m.querySelectorAll==\\\"function\\\"&&(s+=m.querySelectorAll(e).length)}catch{}try{let f=(i instanceof Document?i:i instanceof ShadowRoot?i.host?.ownerDocument??document:i.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&a(c)}catch{}}}return s}function Dt(t){let e=String(t??\\\"\\\");if(!e)return{count:0,sample:[],error:null};let n=e.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=h=>{if(!h)return!1;let u=h.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=h=>{try{if(r(h))return\\\"\\\";let u=h.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=h.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=h=>{let u=l(h);return!!u&&u.toLowerCase().includes(n)},a=window.__stagehandV3__,i=a&&typeof a.getClosedRoot==\\\"function\\\"?h=>{try{return a.getClosedRoot(h)??null}catch{return null}}:h=>null,m=new WeakSet,f=[],c=h=>{!h||m.has(h)||(m.add(h),f.push(h))},p=h=>{try{return(h instanceof Document?h:h?.ownerDocument??document).createTreeWalker(h,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let h=f.shift();if(!h)continue;h instanceof Element&&s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let u=p(h);if(!u)continue;let d;for(;d=u.nextNode();){if(!(d instanceof Element))continue;s(d)&&g.push({element:d,tag:d.tagName??\\\"\\\",id:d.id??\\\"\\\",className:d.className??\\\"\\\",text:l(d)});let E=d.shadowRoot;E&&c(E);let b=i(d);b&&c(b)}}let w=[];for(let h of g){let u=h.element,d=!1;for(let E of g)if(h!==E)try{if(u.contains(E.element)){d=!0;break}}catch{}d||w.push(h)}let x=w.length,y=w.slice(0,5).map(h=>({tag:h.tag,id:h.id,class:h.className,text:h.text}));return{count:x,sample:y,error:null}}function Ht(t){return $(t,{pierceShadow:!0})}var At=t=>t.startsWith(\\\"xpath=\\\")||t.startsWith(\\\"/\\\"),Wt=t=>{try{let e=window.__stagehandV3__;if(e&&typeof e.getClosedRoot==\\\"function\\\")return e.getClosedRoot(t)??null}catch{}return null},Q=t=>t.shadowRoot?t.shadowRoot:Wt(t),_t=(t,e,n)=>{try{let l=t.querySelector(e);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[t];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(e);if(s)return s}catch{}try{let a=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();){if(!(i instanceof Element))continue;let m=Q(i);m&&!o.has(m)&&r.push(m)}}catch{}}}return null},Ot=(t,e)=>I(t,{pierceShadow:e}),K=(t,e)=>At(t)?Ot(t,e):_t(document,t,e),U=(t,e)=>{if(e===\\\"detached\\\")return t===null;if(e===\\\"attached\\\")return t!==null;if(t===null)return!1;if(e===\\\"hidden\\\")try{let n=window.getComputedStyle(t),o=t.getBoundingClientRect();return n.display===\\\"none\\\"||n.visibility===\\\"hidden\\\"||n.opacity===\\\"0\\\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(t),o=t.getBoundingClientRect();return n.display!==\\\"none\\\"&&n.visibility!==\\\"hidden\\\"&&n.opacity!==\\\"0\\\"&&o.width>0&&o.height>0}catch{return!1}},qt=(t,e)=>{let n=new WeakSet,o=l=>{let s=Q(l);if(s&&!n.has(s)){n.add(s);let a=new MutationObserver(t);a.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),e.push(a);for(let i of Array.from(s.children))o(i)}for(let a of Array.from(l.children))o(a)},r=document.documentElement||document.body;r&&o(r)};function Ft(t,e,n,o){let r=String(t??\\\"\\\").trim(),l=String(e??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,a=o!==!1;return new Promise((i,m)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=K(r,a);if(U(w,l)){p=!0,i(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},h=()=>{if(p)return;let E=K(r,a);U(E,l)&&(p=!0,g(),y(),i(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,h(),d()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let d=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(h);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),a&&qt(h,x)};d(),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}return nt(Xt);})();\\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\\n}\";\nexport const locatorScriptSources = {\n \"assignFilePayloadsToInputElement\": \"function ht(t){try{let e=this;if(!e||e.tagName?.toLowerCase()!==\\\"input\\\"||(e.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(t)?t:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",a=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),i=window.atob(r.base64??\\\"\\\"),m=new Uint8Array(i.length);for(let p=0;p<i.length;p+=1)m[p]=i.charCodeAt(p);let f=new Blob([m],{type:s}),c=new File([f],l,{type:s,lastModified:a});n.items.add(c)}return e.files=n.files,e.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),e.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}\",\n \"countCssMatchesPierce\": \"function _t(t){let e=String(t??\\\"\\\").trim();if(!e)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(e).length}catch{return 0}let o=new WeakSet,r=[],l=i=>{!i||o.has(i)||(o.add(i),r.push(i))};l(document);let s=0,a=i=>{let m=i.shadowRoot;m&&l(m);try{let f=n.getClosedRoot(i);f&&l(f)}catch{}};for(;r.length;){let i=r.shift();if(i){try{let m=i;typeof m.querySelectorAll==\\\"function\\\"&&(s+=m.querySelectorAll(e).length)}catch{}try{let f=(i instanceof Document?i:i instanceof ShadowRoot?i.host?.ownerDocument??document:i.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&a(c)}catch{}}}return s}\",\n \"countCssMatchesPrimary\": \"function Wt(t){let e=String(t??\\\"\\\").trim();if(!e)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(e).length)}catch{}try{let a=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),i;for(;i=a.nextNode();)i instanceof Element&&i.shadowRoot&&(l+=o(i.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(e).length}catch{return 0}}}\",\n \"countTextMatches\": \"function Ot(t){let e=String(t??\\\"\\\");if(!e)return{count:0,sample:[],error:null};let n=e.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=h=>{if(!h)return!1;let u=h.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=h=>{try{if(r(h))return\\\"\\\";let u=h.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=h.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=h=>{let u=l(h);return!!u&&u.toLowerCase().includes(n)},a=window.__stagehandV3__,i=a&&typeof a.getClosedRoot==\\\"function\\\"?h=>{try{return a.getClosedRoot(h)??null}catch{return null}}:h=>null,m=new WeakSet,f=[],c=h=>{!h||m.has(h)||(m.add(h),f.push(h))},p=h=>{try{return(h instanceof Document?h:h?.ownerDocument??document).createTreeWalker(h,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let h=f.shift();if(!h)continue;h instanceof Element&&s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let u=p(h);if(!u)continue;let d;for(;d=u.nextNode();){if(!(d instanceof Element))continue;s(d)&&g.push({element:d,tag:d.tagName??\\\"\\\",id:d.id??\\\"\\\",className:d.className??\\\"\\\",text:l(d)});let E=d.shadowRoot;E&&c(E);let b=i(d);b&&c(b)}}let w=[];for(let h of g){let u=h.element,d=!1;for(let E of g)if(h!==E)try{if(u.contains(E.element)){d=!0;break}}catch{}d||w.push(h)}let x=w.length,y=w.slice(0,5).map(h=>({tag:h.tag,id:h.id,class:h.className,text:h.text}));return{count:x,sample:y,error:null}}\",\n \"countXPathMatchesMainWorld\": \"function qt(t){return I(t,{pierceShadow:!0})}\",\n \"dispatchDomClick\": \"function ft(t){let e=t??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!e.bubbles,cancelable:!!e.cancelable,composed:!!e.composed,detail:typeof e.detail==\\\"number\\\"?e.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}\",\n \"ensureFileInputElement\": \"function mt(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}\",\n \"fillElementValue\": \"function pt(t){let e=this;if(!e.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(e.ownerDocument||document).defaultView||window,r=t??\\\"\\\";try{let l=s=>{let a;if(typeof o.InputEvent==\\\"function\\\")try{a=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{a=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else a=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});e.dispatchEvent(a);let i=new o.Event(\\\"change\\\",{bubbles:!0});e.dispatchEvent(i)};if(e instanceof o.HTMLInputElement){let s=(e.type||\\\"\\\").toLowerCase();if(!Q.has(s)&&!A.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let a=t;if(s===\\\"number\\\"){let i=t.trim();if(i!==\\\"\\\"&&Number.isNaN(Number(i)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};a=i}if(r=a,A.has(s)){let i=t.trim();r=i,v.call(e);let m=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(m,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(e,i):e.value=i,e._valueTracker?.setValue?.(i),e.value!==i?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(i),{status:\\\"done\\\"})}return v.call(e),{status:\\\"needsinput\\\",value:a}}return e instanceof o.HTMLTextAreaElement?(v.call(e),r=t,{status:\\\"needsinput\\\",value:t}):e instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:e.isContentEditable?(v.call(e),r=t,{status:\\\"needsinput\\\",value:t}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let a=l.message;typeof a==\\\"string\\\"&&a.trim().length>0&&(s=`exception:${a}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}\",\n \"focusElement\": \"function gt(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}\",\n \"isElementChecked\": \"function yt(){try{let t=this;if((t.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=t.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!t.checked}let n=t.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}\",\n \"isElementVisible\": \"function wt(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument?.defaultView?.getComputedStyle(t)??window.getComputedStyle(t);if(!e||e.display===\\\"none\\\"||e.visibility===\\\"hidden\\\")return!1;let n=parseFloat(e.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=t.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||t.getClientRects().length===0)}catch{return!1}}\",\n \"prepareElementForTyping\": \"function v(){try{let t=this;if(!t.isConnected)return!1;let e=t.ownerDocument||document,n=e.defaultView||window;try{typeof t.focus==\\\"function\\\"&&t.focus()}catch{}if(t instanceof n.HTMLInputElement||t instanceof n.HTMLTextAreaElement){try{if(typeof t.select==\\\"function\\\")return t.select(),!0}catch{}try{let o=(t.value??\\\"\\\").length;if(typeof t.setSelectionRange==\\\"function\\\")return t.setSelectionRange(0,o),!0}catch{}return!0}if(t.isContentEditable){let o=e.getSelection?.(),r=e.createRange?.();if(o&&r)try{r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}\",\n \"readElementInnerHTML\": \"function St(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"readElementInnerText\": \"function vt(){try{let t=this,e=t.innerText;if(typeof e==\\\"string\\\"&&e.length>0)return e;let n=t.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementInputValue\": \"function bt(){try{let t=this,e=(t.tagName||\\\"\\\").toLowerCase();return e===\\\"input\\\"||e===\\\"textarea\\\"||e===\\\"select\\\"?String(t.value??\\\"\\\"):t.isContentEditable?String(t.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementTextContent\": \"function xt(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"resolveCssSelector\": \"function Lt(t,e){let n=String(t??\\\"\\\").trim();if(!n)return null;let o=N(e);return G(n,o+1)[o]??null}\",\n \"resolveCssSelectorPierce\": \"function Pt(t,e){let n=String(t??\\\"\\\").trim();if(!n)return null;let o=N(e),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return G(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,a=new Set,i=[],m=[document],f=c=>{if(!(!c||s.has(c)||i.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!a.has(g)&&(a.add(g),i.push(g),i.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&m.push(x);let y=l(w);y&&m.push(y)}}catch{}}};for(;m.length&&i.length<o+1;){let c=m.shift();c&&f(c)}return i[o]??null}\",\n \"resolveTextSelector\": \"function kt(t,e){let n=String(t??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=N(e),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let d=u.tagName?.toUpperCase()??\\\"\\\";return l.has(d)},a=u=>{try{if(s(u))return\\\"\\\";let d=u.innerText;if(typeof d==\\\"string\\\"&&d.trim())return d.trim()}catch{}try{let d=u.textContent;if(typeof d==\\\"string\\\")return d.trim()}catch{}return\\\"\\\"},i=u=>{let d=a(u);return!!d&&d.toLowerCase().includes(o)},m=window.__stagehandV3__,f=m&&typeof m.getClosedRoot==\\\"function\\\"?u=>{try{return m.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&i(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:a(u)});let d=x(u);if(!d)continue;let E;for(;E=d.nextNode();){if(!(E instanceof Element))continue;i(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:a(E)});let b=E.shadowRoot;b&&w(b);let H=f(E);H&&w(H)}}let y=[];for(let u of g){let d=u.element,E=!1;for(let b of g)if(u!==b)try{if(d.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}\",\n \"resolveXPathMainWorld\": \"function Dt(t,e){let n=N(e);return D(t,n,{pierceShadow:!0})}\",\n \"scrollElementToPercent\": \"function dt(t){let e=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(e(t),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,a=o.clientHeight??0,m=Math.max(0,s-a)*(n/100);return o.scrollTo({top:m,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}\",\n \"selectElementOptions\": \"function Et(t){try{if(!(this instanceof HTMLSelectElement))return[];let e=Array.isArray(t)?t:[t],n=new Set(e.map(s=>String(s??\\\"\\\").trim())),o=s=>{let a=(s.label||s.textContent||\\\"\\\").trim(),i=String(s.value??\\\"\\\").trim();return n.has(a)||n.has(i)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let a of Array.from(this.options))!s&&o(a)?(a.selected=!0,this.value=a.value,s=!0):a.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}\",\n \"waitForSelector\": \"function It(t,e,n,o){let r=String(t??\\\"\\\").trim(),l=String(e??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,a=o!==!1;return new Promise((i,m)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=Y(r,a);if(K(w,l)){p=!0,i(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},h=()=>{if(p)return;let E=Y(r,a);K(E,l)&&(p=!0,g(),y(),i(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,h(),d()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let d=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(h);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),a&&ut(h,x)};d(),f=setTimeout(()=>{p||(p=!0,g(),y(),m(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}\"\n} as const;\nexport const locatorScriptGlobalRefs = {\n \"assignFilePayloadsToInputElement\": \"globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement\",\n \"countCssMatchesPierce\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPierce\",\n \"countCssMatchesPrimary\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPrimary\",\n \"countTextMatches\": \"globalThis.__stagehandLocatorScripts.countTextMatches\",\n \"countXPathMatchesMainWorld\": \"globalThis.__stagehandLocatorScripts.countXPathMatchesMainWorld\",\n \"dispatchDomClick\": \"globalThis.__stagehandLocatorScripts.dispatchDomClick\",\n \"ensureFileInputElement\": \"globalThis.__stagehandLocatorScripts.ensureFileInputElement\",\n \"fillElementValue\": \"globalThis.__stagehandLocatorScripts.fillElementValue\",\n \"focusElement\": \"globalThis.__stagehandLocatorScripts.focusElement\",\n \"isElementChecked\": \"globalThis.__stagehandLocatorScripts.isElementChecked\",\n \"isElementVisible\": \"globalThis.__stagehandLocatorScripts.isElementVisible\",\n \"prepareElementForTyping\": \"globalThis.__stagehandLocatorScripts.prepareElementForTyping\",\n \"readElementInnerHTML\": \"globalThis.__stagehandLocatorScripts.readElementInnerHTML\",\n \"readElementInnerText\": \"globalThis.__stagehandLocatorScripts.readElementInnerText\",\n \"readElementInputValue\": \"globalThis.__stagehandLocatorScripts.readElementInputValue\",\n \"readElementTextContent\": \"globalThis.__stagehandLocatorScripts.readElementTextContent\",\n \"resolveCssSelector\": \"globalThis.__stagehandLocatorScripts.resolveCssSelector\",\n \"resolveCssSelectorPierce\": \"globalThis.__stagehandLocatorScripts.resolveCssSelectorPierce\",\n \"resolveTextSelector\": \"globalThis.__stagehandLocatorScripts.resolveTextSelector\",\n \"resolveXPathMainWorld\": \"globalThis.__stagehandLocatorScripts.resolveXPathMainWorld\",\n \"scrollElementToPercent\": \"globalThis.__stagehandLocatorScripts.scrollElementToPercent\",\n \"selectElementOptions\": \"globalThis.__stagehandLocatorScripts.selectElementOptions\",\n \"waitForSelector\": \"globalThis.__stagehandLocatorScripts.waitForSelector\"\n} as const;\nexport type LocatorScriptName = keyof typeof locatorScriptSources;\n"]}
|