page-agent 1.4.3 → 1.4.4
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 +2 -2
- package/dist/iife/page-agent.demo.js +3 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -49,8 +49,8 @@ Fastest way to try PageAgent with our free Demo LLM:
|
|
|
49
49
|
|
|
50
50
|
| Mirrors | URL |
|
|
51
51
|
| ------- | ---------------------------------------------------------------------------------- |
|
|
52
|
-
| Global | https://cdn.jsdelivr.net/npm/page-agent@1.4.
|
|
53
|
-
| China | https://registry.npmmirror.com/page-agent/1.4.
|
|
52
|
+
| Global | https://cdn.jsdelivr.net/npm/page-agent@1.4.4/dist/iife/page-agent.demo.js |
|
|
53
|
+
| China | https://registry.npmmirror.com/page-agent/1.4.4/files/dist/iife/page-agent.demo.js |
|
|
54
54
|
|
|
55
55
|
> **⚠️ For technical evaluation only.** This demo CDN uses our free [testing LLM API](https://alibaba.github.io/page-agent/docs/features/models#free-testing-api). By using it, you agree to its [terms](https://github.com/alibaba/page-agent/blob/main/docs/terms-and-privacy.md).
|
|
56
56
|
|
|
@@ -236,7 +236,7 @@ ${c}
|
|
|
236
236
|
|
|
237
237
|
`,n+=`</browser_state>
|
|
238
238
|
|
|
239
|
-
`,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,C,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const R=l.scrollTop,D=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollTop=R+k;const O=l.scrollTop-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the bottom of the page.`:g?`✅ Scrolled page by ${h}px. Reached the top of the page.`:`✅ Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`✅ Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const R=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollLeft=R+k;const O=l.scrollLeft-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the right edge of the page.`:g?`✅ Scrolled page by ${h}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`✅ Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function T(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(T,"getCachedComputedStyle");function I(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(I,"getCachedClientRects");const A={},R={current:0},D="playwright-highlight-container";function k(u,y,P=null){if(!u)return y;const w=[];let $=null,N=20,E=16,z=null;try{let x=document.getElementById(D);x||(x=document.createElement("div"),x.id=D,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const F=u.getClientRects();if(!F||F.length===0)return y;const X=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%X.length;let ze=X[J];const te=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(P){const G=P.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of F){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${ze}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),w.push({element:H,initialRect:G})}const me=F[0];$=document.createElement("div"),$.className="playwright-highlight-label",$.style.position="fixed",$.style.background=ze,$.style.color="white",$.style.padding="1px 4px",$.style.borderRadius="4px",$.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,$.textContent=y.toString(),N=$.offsetWidth>0?$.offsetWidth:N,E=$.offsetHeight>0?$.offsetHeight:E;const Le=me.top+se.y,et=me.left+se.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<E+4)&&(nt=Le-E-2,We=et+me.width-N,We<se.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-E)),We=Math.max(0,Math.min(We,window.innerWidth-N)),$.style.top=`${nt}px`,$.style.left=`${We}px`,ge.appendChild($);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(P){const U=P.getBoundingClientRect();H.x=U.left,H.y=U.top}if(w.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ve=oe.top+H.y,Ae=oe.left+H.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<w.length)for(let U=G.length;U<w.length;U++)w[U].element.style.display="none";if($&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ve=ke+2,Ae=oe+U.width-N-2;(U.width<N+4||U.height<E+4)&&(Ve=ke-E-2,Ae=oe+U.width-N,Ae<H.x&&(Ae=oe)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-E)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),$.style.top=`${Ve}px`,$.style.left=`${Ae}px`,$.style.display="block"}else $&&($.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),w.forEach(G=>G.element.remove()),$&&$.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function v(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,$=y.overflowY,N=w==="auto"||w==="scroll",E=$==="auto"||$==="scroll";if(!N&&!E)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,F=4;if(z<F&&x<F||!E&&z<F||!N&&x<F)return null;const X=u.scrollTop,J=u.scrollLeft,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:X,right:ze,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(v,"isScrollableElement");function O(u){try{if(c===-1){const E=u.parentElement;if(!E)return!1;try{return E.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle(E);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,$=!1;for(const E of P)if(E.width>0&&E.height>0&&(w=!0,!(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))){$=!0;break}if(!w||!$)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function B(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),$=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(P?.cursor&&$.has(P.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const F=u.getAttribute("role"),X=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||F&&J.has(F)||X&&J.has(X))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!v(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){P=!0;break}if(!P)return!1;if(u.ownerDocument!==window.document)return!0;let $=Array.from(y).find(x=>x.width>0&&x.height>0);if(!$)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=$.left+$.width/2,F=$.top+$.height/2;try{const X=N.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const E=5;return[{x:$.left+$.width/2,y:$.top+$.height/2},{x:$.left+E,y:$.top+E},{x:$.right-E,y:$.bottom-E}].some(({x,y:F})=>{try{const X=document.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function K(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(K,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Ke=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),$=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||P)&&$&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(u),E=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of E)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let $=!1;return w?Xe(y)?$=!0:$=!1:$=!0,$&&(u.isInViewport=K(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,P):k(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!1){if(!u||u.id===D||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===D||u.dataset?.browserUseIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const E={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const F=_e(x,y,!1);F&&E.children.push(F)}const z=`${R.current++}`;return A[z]=E,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const E=u.textContent?.trim();if(!E)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${R.current++}`;return A[x]={type:"TEXT_NODE",text:E,isVisible:O(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const E=m(u),z=T(u),x=z&&(z.position==="fixed"||z.position==="sticky"),F=u.offsetWidth>0||u.offsetHeight>0;if(!E||!x&&!F&&(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))return null}const w={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const E=u.getAttributeNames?.()||[];for(const z of E){const x=u.getAttribute(z);w.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let $=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=B(u),w.isVisible)){w.isTopElement=ue(u);const E=u.getAttribute("role"),z=E==="menu"||E==="menubar"||E==="listbox";(w.isTopElement||z)&&(w.isInteractive=q(u),$=Qe(w,u,y,P),w.ref=u)}if(u.tagName){const E=u.tagName.toLowerCase();if(E==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const F=_e(x,u,!1);F&&w.children.push(F)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||E==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,$||P);F&&w.children.push(F)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const E=m(u);if(!(E&&E.width>0&&E.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${R.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:T,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let R="";if(n.length>0&&f.attributes){const v={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(v[B]=q.trim())}const O=n.filter(B=>B in v);if(O.length>1){const B=new Set,q={};for(const ue of O){const K=v[ue];K.length>5&&(K in q?B.add(ue):q[K]=ue)}for(const ue of B)delete v[ue]}v.role===f.tagName&&delete v.role;const Ie=["aria-label","placeholder","title"];for(const B of Ie)v[B]&&v[B].toLowerCase().trim()===A.toLowerCase().trim()&&delete v[B];Object.keys(v).length>0&&(R=Object.entries(v).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${I}${D}<${f.tagName??""}`;if(R&&(k+=` ${R}`),f.extra&&f.extra.scrollable){let v="";f.extra.scrollData?.left&&(v+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(v+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(v+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(v+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${v}"`}if(A){const v=A.trim();R||(k+=" "),k+=`>${v}`}else R||(k+=" ");k+=" />",m.push(k)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
|
|
239
|
+
`,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,C,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.2)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const R=l.scrollTop,D=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollTop=R+k;const O=l.scrollTop-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the bottom of the page.`:g?`✅ Scrolled page by ${h}px. Reached the top of the page.`:`✅ Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`✅ Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const R=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollLeft=R+k;const O=l.scrollLeft-R;if(Math.abs(O)>.5){d=!0,h=l,f=O;break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled page by ${h}px. Reached the right edge of the page.`:g?`✅ Scrolled page by ${h}px. Reached the left edge of the page.`:`✅ Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`✅ Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`✅ Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function T(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(T,"getCachedComputedStyle");function I(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(I,"getCachedClientRects");const A={},R={current:0},D="playwright-highlight-container";function k(u,y,P=null){if(!u)return y;const w=[];let $=null,N=20,E=16,z=null;try{let x=document.getElementById(D);x||(x=document.createElement("div"),x.id=D,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const F=u.getClientRects();if(!F||F.length===0)return y;const X=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%X.length;let ze=X[J];const te=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(P){const G=P.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of F){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${ze}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),w.push({element:H,initialRect:G})}const me=F[0];$=document.createElement("div"),$.className="playwright-highlight-label",$.style.position="fixed",$.style.background=ze,$.style.color="white",$.style.padding="1px 4px",$.style.borderRadius="4px",$.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,$.textContent=y.toString(),N=$.offsetWidth>0?$.offsetWidth:N,E=$.offsetHeight>0?$.offsetHeight:E;const Le=me.top+se.y,et=me.left+se.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<E+4)&&(nt=Le-E-2,We=et+me.width-N,We<se.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-E)),We=Math.max(0,Math.min(We,window.innerWidth-N)),$.style.top=`${nt}px`,$.style.left=`${We}px`,ge.appendChild($);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(P){const U=P.getBoundingClientRect();H.x=U.left,H.y=U.top}if(w.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ve=oe.top+H.y,Ae=oe.left+H.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<w.length)for(let U=G.length;U<w.length;U++)w[U].element.style.display="none";if($&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ve=ke+2,Ae=oe+U.width-N-2;(U.width<N+4||U.height<E+4)&&(Ve=ke-E-2,Ae=oe+U.width-N,Ae<H.x&&(Ae=oe)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-E)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),$.style.top=`${Ve}px`,$.style.left=`${Ae}px`,$.style.display="block"}else $&&($.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),w.forEach(G=>G.element.remove()),$&&$.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function v(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,$=y.overflowY,N=w==="auto"||w==="scroll",E=$==="auto"||$==="scroll";if(!N&&!E)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,F=4;if(z<F&&x<F||!E&&z<F||!N&&x<F)return null;const X=u.scrollTop,J=u.scrollLeft,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:X,right:ze,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(v,"isScrollableElement");function O(u){try{if(c===-1){const E=u.parentElement;if(!E)return!1;try{return E.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle(E);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,$=!1;for(const E of P)if(E.width>0&&E.height>0&&(w=!0,!(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))){$=!0;break}if(!w||!$)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function B(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),$=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(P?.cursor&&$.has(P.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const F=u.getAttribute("role"),X=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||F&&J.has(F)||X&&J.has(X))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!v(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){P=!0;break}if(!P)return!1;if(u.ownerDocument!==window.document)return!0;let $=Array.from(y).find(x=>x.width>0&&x.height>0);if(!$)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=$.left+$.width/2,F=$.top+$.height/2;try{const X=N.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const E=5;return[{x:$.left+$.width/2,y:$.top+$.height/2},{x:$.left+E,y:$.top+E},{x:$.right-E,y:$.bottom-E}].some(({x,y:F})=>{try{const X=document.elementFromPoint(x,F);if(!X)return!1;let J=X;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function K(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(K,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Ke=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),$=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||P)&&$&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(u),E=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of E)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let $=!1;return w?Xe(y)?$=!0:$=!1:$=!0,$&&(u.isInViewport=K(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,P):k(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!1){if(!u||u.id===D||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===D||u.dataset?.browserUseIgnore==="true"||u.dataset?.pageAgentIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const E={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const F=_e(x,y,!1);F&&E.children.push(F)}const z=`${R.current++}`;return A[z]=E,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const E=u.textContent?.trim();if(!E)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${R.current++}`;return A[x]={type:"TEXT_NODE",text:E,isVisible:O(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const E=m(u),z=T(u),x=z&&(z.position==="fixed"||z.position==="sticky"),F=u.offsetWidth>0||u.offsetHeight>0;if(!E||!x&&!F&&(E.bottom<-c||E.top>window.innerHeight+c||E.right<-c||E.left>window.innerWidth+c))return null}const w={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const E=u.getAttributeNames?.()||[];for(const z of E){const x=u.getAttribute(z);w.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let $=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=B(u),w.isVisible)){w.isTopElement=ue(u);const E=u.getAttribute("role"),z=E==="menu"||E==="menubar"||E==="listbox";(w.isTopElement||z)&&(w.isInteractive=q(u),$=Qe(w,u,y,P),w.ref=u)}if(u.tagName){const E=u.tagName.toLowerCase();if(E==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const F=_e(x,u,!1);F&&w.children.push(F)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||E==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,$);x&&w.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,$||P);F&&w.children.push(F)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const E=m(u);if(!(E&&E.width>0&&E.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${R.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:T,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let R="";if(n.length>0&&f.attributes){const v={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(v[B]=q.trim())}const O=n.filter(B=>B in v);if(O.length>1){const B=new Set,q={};for(const ue of O){const K=v[ue];K.length>5&&(K in q?B.add(ue):q[K]=ue)}for(const ue of B)delete v[ue]}v.role===f.tagName&&delete v.role;const Ie=["aria-label","placeholder","title"];for(const B of Ie)v[B]&&v[B].toLowerCase().trim()===A.toLowerCase().trim()&&delete v[B];Object.keys(v).length>0&&(R=Object.entries(v).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${I}${D}<${f.tagName??""}`;if(R&&(k+=` ${R}`),f.extra&&f.extra.scrollable){let v="";f.extra.scrollData?.left&&(v+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(v+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(v+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(v+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${v}"`}if(A){const v=A.trim();R||(k+=" "),k+=`>${v}`}else R||(k+=" ");k+=" />",m.push(k)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
|
|
240
240
|
`)}a(flatTreeToString,"flatTreeToString");const getAllTextTillNextClickableElement=a((e,t=-1)=>{const o=[],n=a((r,i)=>{if(!(t!==-1&&i>t)&&!(r.type==="element"&&r!==e&&r.highlightIndex!==void 0)){if(r.type==="text"&&r.text)o.push(r.text);else if(r.type==="element")for(const s of r.children)n(s,i+1)}},"collectText");return n(e,0),o.join(`
|
|
241
241
|
`).trim()},"getAllTextTillNextClickableElement");function getSelectorMap(e){const t=new Map,o=Object.keys(e.map);for(const n of o){const r=e.map[n];r.isInteractive&&typeof r.highlightIndex=="number"&&t.set(r.highlightIndex,r)}return t}a(getSelectorMap,"getSelectorMap");function getElementTextMap(e){const t=e.split(`
|
|
242
242
|
`).map(n=>n.trim()).filter(n=>n.length>0),o=new Map;for(const n of t){const i=/^\[(\d+)\]<[^>]+>([^<]*)/.exec(n);if(i){const s=parseInt(i[1],10);o.set(s,n)}}return o}a(getElementTextMap,"getElementTextMap");function cleanUpHighlights(){const e=window._highlightCleanupFunctions||[];for(const t of e)typeof t=="function"&&t();window._highlightCleanupFunctions=[]}a(cleanUpHighlights,"cleanUpHighlights"),window.addEventListener("popstate",()=>{cleanUpHighlights()}),window.addEventListener("hashchange",()=>{cleanUpHighlights()}),window.addEventListener("beforeunload",()=>{cleanUpHighlights()});const navigation=window.navigation;if(navigation&&typeof navigation.addEventListener=="function")navigation.addEventListener("navigate",()=>{cleanUpHighlights()});else{let e=window.location.href;setInterval(()=>{window.location.href!==e&&(e=window.location.href,cleanUpHighlights())},500)}function getPageInfo(){const e=window.innerWidth,t=window.innerHeight,o=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth||0),n=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight||0),r=window.scrollX||window.pageXOffset||document.documentElement.scrollLeft||0,i=window.scrollY||window.pageYOffset||document.documentElement.scrollTop||0,s=Math.max(0,n-(window.innerHeight+i)),c=Math.max(0,o-(window.innerWidth+r));return{viewport_width:e,viewport_height:t,page_width:o,page_height:n,scroll_x:r,scroll_y:i,pixels_above:i,pixels_below:s,pages_above:t>0?i/t:0,pages_below:t>0?s/t:0,total_pages:t>0?n/t:0,current_page_position:i/Math.max(1,n-t),pixels_left:r,pixels_right:c}}a(getPageInfo,"getPageInfo");function patchReact(e){const t=document.querySelectorAll('[data-reactroot], [data-reactid], [data-react-checksum], #root, #app, [id^="root-"], [id^="app-"], #adex-wrapper, #adex-root');for(const o of t)o.setAttribute("data-page-agent-not-interactive","true")}a(patchReact,"patchReact");const _PageController=class _PageController extends EventTarget{config;flatTree=null;selectorMap=new Map;elementTextMap=new Map;simplifiedHTML="<EMPTY>";lastTimeUpdate=0;isIndexed=!1;mask=null;maskReady=null;constructor(e={}){super(),this.config=e,patchReact(),e.enableMask&&this.initMask()}initMask(){this.maskReady===null&&(this.maskReady=(async()=>{const{SimulatorMask:e}=await Promise.resolve().then(()=>SimulatorMask$1);this.mask=new e})())}async getCurrentUrl(){return window.location.href}async getLastUpdateTime(){return this.lastTimeUpdate}async getBrowserState(){const e=window.location.href,t=document.title,o=getPageInfo(),n=this.config.viewportExpansion??VIEWPORT_EXPANSION;await this.updateTree();const r=this.simplifiedHTML,i=`Current Page: [${t}](${e})`,s=`Page info: ${o.viewport_width}x${o.viewport_height}px viewport, ${o.page_width}x${o.page_height}px total page size, ${o.pages_above.toFixed(1)} pages above, ${o.pages_below.toFixed(1)} pages below, ${o.total_pages.toFixed(1)} total pages, at ${(o.current_page_position*100).toFixed(0)}% of page`,c=n===-1?"Interactive elements from top layer of the current page (full page):":"Interactive elements from top layer of the current page inside the viewport:",d=o.pixels_above>4&&n!==-1?`... ${o.pixels_above} pixels above (${o.pages_above.toFixed(1)} pages) - scroll to see more ...`:"[Start of page]",h=`${i}
|
|
@@ -252,7 +252,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
|
|
|
252
252
|
</div>
|
|
253
253
|
${o?`<div class="${styles$1.historyMeta}">${o}</div>`:""}
|
|
254
254
|
</div>
|
|
255
|
-
`}a(createCard,"createCard");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>🔍 ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>💾 ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,je);Z(this,ae);Z(this,ye);Z(this,Re);Z(this,be);Z(this,Ce);Z(this,we);Z(this,W);Z(this,Ge);Z(this,Ee,!1);Z(this,j);Z(this,xe,null);Z(this,ve,!1);Z(this,Ze,null);Z(this,ee,null);Z(this,Be,!1);Z(this,He,a(()=>b(this,_,Ot).call(this),"#onStatusChange"));Z(this,Je,a(()=>b(this,_,Rt).call(this),"#onHistoryChange"));Z(this,Ye,a(t=>b(this,_,Ct).call(this,t.detail),"#onActivity"));Z(this,qe,a(()=>this.dispose(),"#onAgentDispose"));S(this,W,t),S(this,Ge,o),S(this,j,new I18n(o.language??"en-US")),p(this,W).onAskUser=n=>b(this,_,Zt).call(this,n),S(this,re,b(this,_,Dt).call(this)),S(this,je,p(this,re).querySelector(`.${styles$1.indicator}`)),S(this,ae,p(this,re).querySelector(`.${styles$1.statusText}`)),S(this,ye,p(this,re).querySelector(`.${styles$1.historySection}`)),S(this,Re,p(this,re).querySelector(`.${styles$1.expandButton}`)),S(this,be,p(this,re).querySelector(`.${styles$1.stopButton}`)),S(this,Ce,p(this,re).querySelector(`.${styles$1.inputSectionWrapper}`)),S(this,we,p(this,re).querySelector(`.${styles$1.taskInput}`)),p(this,W).addEventListener("statuschange",p(this,He)),p(this,W).addEventListener("historychange",p(this,Je)),p(this,W).addEventListener("activity",p(this,Ye)),p(this,W).addEventListener("dispose",p(this,qe)),b(this,_,Ut).call(this),b(this,_,jt).call(this),b(this,_,tt).call(this),this.hide()}get wrapper(){return p(this,re)}show(){this.wrapper.style.display="block",this.wrapper.offsetHeight,this.wrapper.style.opacity="1",this.wrapper.style.transform="translateX(-50%) translateY(0)"}hide(){this.wrapper.style.opacity="0",this.wrapper.style.transform="translateX(-50%) translateY(20px)",this.wrapper.style.display="none"}reset(){p(this,ae).textContent=p(this,j).t("ui.panel.ready"),b(this,_,Fe).call(this,"thinking"),b(this,_,kt).call(this),b(this,_,it).call(this),S(this,ve,!1),S(this,xe,null),b(this,_,tt).call(this)}expand(){b(this,_,ot).call(this)}collapse(){b(this,_,it).call(this)}dispose(){p(this,W).removeEventListener("statuschange",p(this,He)),p(this,W).removeEventListener("historychange",p(this,Je)),p(this,W).removeEventListener("activity",p(this,Ye)),p(this,W).removeEventListener("dispose",p(this,qe)),S(this,ve,!1),b(this,_,Bt).call(this),this.wrapper.remove()}};re=new WeakMap,je=new WeakMap,ae=new WeakMap,ye=new WeakMap,Re=new WeakMap,be=new WeakMap,Ce=new WeakMap,we=new WeakMap,W=new WeakMap,Ge=new WeakMap,Ee=new WeakMap,j=new WeakMap,xe=new WeakMap,ve=new WeakMap,Ze=new WeakMap,ee=new WeakMap,Be=new WeakMap,He=new WeakMap,Je=new WeakMap,Ye=new WeakMap,qe=new WeakMap,_=new WeakSet,Ot=a(function(){const t=p(this,W).status,o=t==="running"||t==="idle"?"thinking":t;b(this,_,Fe).call(this,o),t==="running"?(p(this,be).textContent="■",p(this,be).title=p(this,j).t("ui.panel.stop")):(p(this,be).textContent="X",p(this,be).title=p(this,j).t("ui.panel.close")),t==="running"&&(this.show(),b(this,_,bt).call(this)),(t==="completed"||t==="error")&&(p(this,Ee)||b(this,_,ot).call(this),b(this,_,Ft).call(this)&&b(this,_,tt).call(this))},"#handleStatusChange"),Rt=a(function(){b(this,_,kt).call(this)},"#handleHistoryChange"),Ct=a(function(t){switch(t.type){case"thinking":S(this,ee,p(this,j).t("ui.panel.thinking")),b(this,_,Fe).call(this,"thinking");break;case"executing":S(this,ee,b(this,_,yt).call(this,t.tool,t.input)),b(this,_,Fe).call(this,"executing");break;case"executed":S(this,ee,truncate(t.output,50));break;case"retrying":S(this,ee,`Retrying (${t.attempt}/${t.maxAttempts})`),b(this,_,Fe).call(this,"retrying");break;case"error":S(this,ee,truncate(t.message,50)),b(this,_,Fe).call(this,"error");break}},"#handleActivity"),Zt=a(function(t){return new Promise(o=>{S(this,ve,!0),S(this,xe,o),p(this,Ee)||b(this,_,ot).call(this);const n=document.createElement("div");n.innerHTML=createCard({icon:"❓",content:`Question: ${t}`,type:"question"});const r=n.firstElementChild;r.setAttribute("data-temp-card","true"),p(this,ye).appendChild(r),b(this,_,vt).call(this),b(this,_,tt).call(this,p(this,j).t("ui.panel.userAnswerPrompt"))})},"#askUser"),yt=a(function(t,o){const n=o;switch(t){case"click_element_by_index":return p(this,j).t("ui.tools.clicking",{index:n.index});case"input_text":return p(this,j).t("ui.tools.inputting",{index:n.index});case"select_dropdown_option":return p(this,j).t("ui.tools.selecting",{text:n.text});case"scroll":return p(this,j).t("ui.tools.scrolling");case"wait":return p(this,j).t("ui.tools.waiting",{seconds:n.seconds});case"ask_user":return p(this,j).t("ui.tools.askingUser");case"done":return p(this,j).t("ui.tools.done");default:return p(this,j).t("ui.tools.executing",{toolName:t})}},"#getToolExecutingText"),Nt=a(function(){p(this,W).status==="running"?p(this,W).stop():p(this,W).dispose()},"#handleActionButton"),Lt=a(function(){const t=p(this,we).value.trim();t&&(b(this,_,bt).call(this),p(this,ve)?b(this,_,Mt).call(this,t):p(this,W).execute(t))},"#submitTask"),Mt=a(function(t){Array.from(p(this,ye).children).forEach(o=>{o.getAttribute("data-temp-card")==="true"&&o.remove()}),S(this,ve,!1),p(this,xe)&&(p(this,xe).call(this,t),S(this,xe,null))},"#handleUserAnswer"),tt=a(function(t){p(this,we).value="",p(this,we).placeholder=t||p(this,j).t("ui.panel.taskInput"),p(this,Ce).classList.remove(styles$1.hidden),setTimeout(()=>{p(this,we).focus()},100)},"#showInputArea"),bt=a(function(){p(this,Ce).classList.add(styles$1.hidden)},"#hideInputArea"),Ft=a(function(){if(p(this,ve)||p(this,W).history.length===0)return!0;const o=p(this,W).status;return o==="completed"||o==="error"?p(this,Ge).promptForNextTask??!0:!1},"#shouldShowInputArea"),Dt=a(function(){const t=document.createElement("div");return t.id="page-agent-runtime_agent-panel",t.className=styles$1.wrapper,t.setAttribute("data-browser-use-ignore","true"),t.innerHTML=`
|
|
255
|
+
`}a(createCard,"createCard");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>🔍 ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>💾 ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,je);Z(this,ae);Z(this,ye);Z(this,Re);Z(this,be);Z(this,Ce);Z(this,we);Z(this,W);Z(this,Ge);Z(this,Ee,!1);Z(this,j);Z(this,xe,null);Z(this,ve,!1);Z(this,Ze,null);Z(this,ee,null);Z(this,Be,!1);Z(this,He,a(()=>b(this,_,Ot).call(this),"#onStatusChange"));Z(this,Je,a(()=>b(this,_,Rt).call(this),"#onHistoryChange"));Z(this,Ye,a(t=>b(this,_,Ct).call(this,t.detail),"#onActivity"));Z(this,qe,a(()=>this.dispose(),"#onAgentDispose"));S(this,W,t),S(this,Ge,o),S(this,j,new I18n(o.language??"en-US")),p(this,W).onAskUser=n=>b(this,_,Zt).call(this,n),S(this,re,b(this,_,Dt).call(this)),S(this,je,p(this,re).querySelector(`.${styles$1.indicator}`)),S(this,ae,p(this,re).querySelector(`.${styles$1.statusText}`)),S(this,ye,p(this,re).querySelector(`.${styles$1.historySection}`)),S(this,Re,p(this,re).querySelector(`.${styles$1.expandButton}`)),S(this,be,p(this,re).querySelector(`.${styles$1.stopButton}`)),S(this,Ce,p(this,re).querySelector(`.${styles$1.inputSectionWrapper}`)),S(this,we,p(this,re).querySelector(`.${styles$1.taskInput}`)),p(this,W).addEventListener("statuschange",p(this,He)),p(this,W).addEventListener("historychange",p(this,Je)),p(this,W).addEventListener("activity",p(this,Ye)),p(this,W).addEventListener("dispose",p(this,qe)),b(this,_,Ut).call(this),b(this,_,jt).call(this),b(this,_,tt).call(this),this.hide()}get wrapper(){return p(this,re)}show(){this.wrapper.style.display="block",this.wrapper.offsetHeight,this.wrapper.style.opacity="1",this.wrapper.style.transform="translateX(-50%) translateY(0)"}hide(){this.wrapper.style.opacity="0",this.wrapper.style.transform="translateX(-50%) translateY(20px)",this.wrapper.style.display="none"}reset(){p(this,ae).textContent=p(this,j).t("ui.panel.ready"),b(this,_,Fe).call(this,"thinking"),b(this,_,kt).call(this),b(this,_,it).call(this),S(this,ve,!1),S(this,xe,null),b(this,_,tt).call(this)}expand(){b(this,_,ot).call(this)}collapse(){b(this,_,it).call(this)}dispose(){p(this,W).removeEventListener("statuschange",p(this,He)),p(this,W).removeEventListener("historychange",p(this,Je)),p(this,W).removeEventListener("activity",p(this,Ye)),p(this,W).removeEventListener("dispose",p(this,qe)),S(this,ve,!1),b(this,_,Bt).call(this),this.wrapper.remove()}};re=new WeakMap,je=new WeakMap,ae=new WeakMap,ye=new WeakMap,Re=new WeakMap,be=new WeakMap,Ce=new WeakMap,we=new WeakMap,W=new WeakMap,Ge=new WeakMap,Ee=new WeakMap,j=new WeakMap,xe=new WeakMap,ve=new WeakMap,Ze=new WeakMap,ee=new WeakMap,Be=new WeakMap,He=new WeakMap,Je=new WeakMap,Ye=new WeakMap,qe=new WeakMap,_=new WeakSet,Ot=a(function(){const t=p(this,W).status,o=t==="running"||t==="idle"?"thinking":t;b(this,_,Fe).call(this,o),t==="running"?(p(this,be).textContent="■",p(this,be).title=p(this,j).t("ui.panel.stop")):(p(this,be).textContent="X",p(this,be).title=p(this,j).t("ui.panel.close")),t==="running"&&(this.show(),b(this,_,bt).call(this)),(t==="completed"||t==="error")&&(p(this,Ee)||b(this,_,ot).call(this),b(this,_,Ft).call(this)&&b(this,_,tt).call(this))},"#handleStatusChange"),Rt=a(function(){b(this,_,kt).call(this)},"#handleHistoryChange"),Ct=a(function(t){switch(t.type){case"thinking":S(this,ee,p(this,j).t("ui.panel.thinking")),b(this,_,Fe).call(this,"thinking");break;case"executing":S(this,ee,b(this,_,yt).call(this,t.tool,t.input)),b(this,_,Fe).call(this,"executing");break;case"executed":S(this,ee,truncate(t.output,50));break;case"retrying":S(this,ee,`Retrying (${t.attempt}/${t.maxAttempts})`),b(this,_,Fe).call(this,"retrying");break;case"error":S(this,ee,truncate(t.message,50)),b(this,_,Fe).call(this,"error");break}},"#handleActivity"),Zt=a(function(t){return new Promise(o=>{S(this,ve,!0),S(this,xe,o),p(this,Ee)||b(this,_,ot).call(this);const n=document.createElement("div");n.innerHTML=createCard({icon:"❓",content:`Question: ${t}`,type:"question"});const r=n.firstElementChild;r.setAttribute("data-temp-card","true"),p(this,ye).appendChild(r),b(this,_,vt).call(this),b(this,_,tt).call(this,p(this,j).t("ui.panel.userAnswerPrompt"))})},"#askUser"),yt=a(function(t,o){const n=o;switch(t){case"click_element_by_index":return p(this,j).t("ui.tools.clicking",{index:n.index});case"input_text":return p(this,j).t("ui.tools.inputting",{index:n.index});case"select_dropdown_option":return p(this,j).t("ui.tools.selecting",{text:n.text});case"scroll":return p(this,j).t("ui.tools.scrolling");case"wait":return p(this,j).t("ui.tools.waiting",{seconds:n.seconds});case"ask_user":return p(this,j).t("ui.tools.askingUser");case"done":return p(this,j).t("ui.tools.done");default:return p(this,j).t("ui.tools.executing",{toolName:t})}},"#getToolExecutingText"),Nt=a(function(){p(this,W).status==="running"?p(this,W).stop():p(this,W).dispose()},"#handleActionButton"),Lt=a(function(){const t=p(this,we).value.trim();t&&(b(this,_,bt).call(this),p(this,ve)?b(this,_,Mt).call(this,t):p(this,W).execute(t))},"#submitTask"),Mt=a(function(t){Array.from(p(this,ye).children).forEach(o=>{o.getAttribute("data-temp-card")==="true"&&o.remove()}),S(this,ve,!1),p(this,xe)&&(p(this,xe).call(this,t),S(this,xe,null))},"#handleUserAnswer"),tt=a(function(t){p(this,we).value="",p(this,we).placeholder=t||p(this,j).t("ui.panel.taskInput"),p(this,Ce).classList.remove(styles$1.hidden),setTimeout(()=>{p(this,we).focus()},100)},"#showInputArea"),bt=a(function(){p(this,Ce).classList.add(styles$1.hidden)},"#hideInputArea"),Ft=a(function(){if(p(this,ve)||p(this,W).history.length===0)return!0;const o=p(this,W).status;return o==="completed"||o==="error"?p(this,Ge).promptForNextTask??!0:!1},"#shouldShowInputArea"),Dt=a(function(){const t=document.createElement("div");return t.id="page-agent-runtime_agent-panel",t.className=styles$1.wrapper,t.setAttribute("data-browser-use-ignore","true"),t.setAttribute("data-page-agent-ignore","true"),t.innerHTML=`
|
|
256
256
|
<div class="${styles$1.background}"></div>
|
|
257
257
|
<div class="${styles$1.historySectionWrapper}">
|
|
258
258
|
<div class="${styles$1.historySection}">
|
|
@@ -397,4 +397,4 @@ out vec2 vUV;
|
|
|
397
397
|
void main() {
|
|
398
398
|
vUV = aUV;
|
|
399
399
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
400
|
-
}`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:T}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const R=performance.now();this.lastTime=R;const D=(R-this.startTime)*.001;this.render(D)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`🔴 WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),R=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(k,1.8)):(t.uniform1f(D,1),t.uniform1f(k,1));const v=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<v.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...v[O]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:T,uGlowWidth:I,uBorderRadius:A,uColors:R}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Ne);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,$t).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){S(this,Se,t),S(this,Te,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",S(this,ce,window.innerWidth/2),S(this,le,window.innerHeight/2),S(this,Se,p(this,ce)),S(this,Te,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),$t=a(function(){const t=p(this,ce)+(p(this,Se)-p(this,ce))*.2,o=p(this,le)+(p(this,Te)-p(this,le))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ce,p(this,Se)):S(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,le,p(this,Te)):S(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Ne,$t).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
|
|
400
|
+
}`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:T}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const R=performance.now();this.lastTime=R;const D=(R-this.startTime)*.001;this.render(D)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`🔴 WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),R=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(k,1.8)):(t.uniform1f(D,1),t.uniform1f(k,1));const v=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<v.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...v[O]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:T,uGlowWidth:I,uBorderRadius:A,uColors:R}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Ne);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.setAttribute("data-page-agent-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,$t).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){S(this,Se,t),S(this,Te,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",S(this,ce,window.innerWidth/2),S(this,le,window.innerHeight/2),S(this,Se,p(this,ce)),S(this,Te,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),$t=a(function(){const t=p(this,ce)+(p(this,Se)-p(this,ce))*.2,o=p(this,le)+(p(this,Te)-p(this,le))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ce,p(this,Se)):S(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,le,p(this,Te)):S(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Ne,$t).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/page-agent.js",
|
|
7
7
|
"module": "./dist/esm/page-agent.js",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@page-agent/core": "1.4.
|
|
48
|
-
"@page-agent/llms": "1.4.
|
|
49
|
-
"@page-agent/page-controller": "1.4.
|
|
50
|
-
"@page-agent/ui": "1.4.
|
|
47
|
+
"@page-agent/core": "1.4.4",
|
|
48
|
+
"@page-agent/llms": "1.4.4",
|
|
49
|
+
"@page-agent/page-controller": "1.4.4",
|
|
50
|
+
"@page-agent/ui": "1.4.4",
|
|
51
51
|
"chalk": "^5.6.2",
|
|
52
52
|
"zod": "^4.3.5"
|
|
53
53
|
}
|