@mindstudio-ai/browser-agent 0.1.75 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";var __MindStudioBrowserAgent=(()=>{var Bn=Object.defineProperty;var Zs=Object.getOwnPropertyDescriptor;var Ks=Object.getOwnPropertyNames;var Xs=Object.prototype.hasOwnProperty;var Hn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Js=(e,t)=>{for(var n in t)Bn(e,n,{get:t[n],enumerable:!0})},Qs=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ks(t))!Xs.call(e,o)&&o!==n&&Bn(e,o,{get:()=>t[o],enumerable:!(r=Zs(t,o))||r.enumerable});return e};var el=e=>Qs(Bn({},"__esModule",{value:!0}),e);var Om={};Js(Om,{executeSteps:()=>Et,getRefMap:()=>He,resolveElement:()=>xe,takeSnapshot:()=>Ue,takeSnapshotSync:()=>Wt});var Un="__ms";function tl(){return{ws:{ws:null,clientId:null,reconnectDelay:1e3,closing:!1,busy:!1},cursor:{el:null,rippleEl:null,x:-100,y:-100,hasPosition:!1,hideTimer:null,executing:!1,targetElement:null,trackingFrame:null,settledResolve:null,visibilityState:"hidden",preSnapshotState:null},snapshot:{refCounter:0,refMap:new Map},networkIdle:{activeRequests:0},transport:{buffer:[],flushTimer:null,capturing:!1,captured:[],wsGetter:null},noteLayer:{host:null,overlay:null,cursorEl:null,notes:[],currentNote:null,pointerDown:!1,startX:0,startY:0,didDrag:!1,consumedByDeactivation:!1,dragPreview:null,movingNote:null,moveOffsetX:0,moveOffsetY:0},noteElement:{counter:0},notesMode:{active:!1,wasTouchActive:!1},messages:{handler:null},nav:{lastUrl:null},screenshot:{cameraEl:null,flashEl:null,capturing:!1},fonts:{initialized:!1,observer:null},zoom:{pipMode:!1,mobilePreview:!1},touch:{circleEl:null,active:!1,pressed:!1,dragging:!1,startX:0,startY:0,lastX:0,lastY:0,onMouseMove:null,onMouseDown:null,onMouseUp:null,onMouseLeave:null,onDragStart:null,momentumFrame:null,overscrollY:0,bouncing:!1,bounceTimer:null,scrollContainer:null,velocityX:0,velocityY:0,lastMoveTime:0},mirror:{recording:!1,stopFn:null},sessionRecording:{active:!1,runId:null,stopFn:null,buffer:[]},authCredsWidget:{initialized:!1,host:null,observer:null,debounceTimer:null,awaitingCode:!1,awaitingCodeTimer:null,codePollTimer:null,codeAttempts:0,codeSubmitted:!1,codeSeenCount:0,blankPolls:0}}}function x(){let e=window;return e[Un]||(e[Un]=tl()),e[Un]}var mo="/__mindstudio_dev__/logs",nl=2e3;function po(e){x().transport.wsGetter=e}function ho(){let e=x().transport;if(e.buffer.length===0)return;let t=e.buffer;e.buffer=[];let n=e.wsGetter?.();if(n&&n.readyState===WebSocket.OPEN)try{n.send(JSON.stringify({type:"log",entries:t}));return}catch{}try{let r=new XMLHttpRequest;r.open("POST",mo,!0),r.setRequestHeader("Content-Type","application/json"),r.send(JSON.stringify(t))}catch{}}function rl(){let e=x().transport;e.flushTimer||(e.flushTimer=setTimeout(()=>{e.flushTimer=null,ho()},nl))}function ol(){let e=x().transport;e.flushTimer&&(clearTimeout(e.flushTimer),e.flushTimer=null),ho()}function pe(e){let t=x().transport;t.buffer.push(e),t.capturing&&t.captured.push(e),rl()}function Vn(e){let t=x().transport;t.buffer.push(e),t.capturing&&t.captured.push(e),ol()}function Gn(){let e=x().transport;e.capturing=!0,e.captured=[]}function zn(){let e=x().transport;e.capturing=!1;let t=e.captured;return e.captured=[],t}function go(){window.addEventListener("beforeunload",()=>{let e=x().transport;e.buffer.length>0&&navigator.sendBeacon&&navigator.sendBeacon(mo,JSON.stringify(e.buffer))})}var il={a:"link",button:"button",input:"textbox",textarea:"textbox",select:"combobox",option:"option",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",nav:"navigation",main:"main",header:"banner",footer:"contentinfo",aside:"complementary",dialog:"dialog",details:"group",summary:"button",img:"img",ul:"list",ol:"list",li:"listitem",table:"table",tr:"row",th:"columnheader",td:"cell",form:"form",article:"article",section:"region",label:"label",fieldset:"group",legend:"legend",p:"paragraph",blockquote:"blockquote",pre:"code",code:"code",hr:"separator",progress:"progressbar"};function ye(e){let t=e.getAttribute("role");if(t)return t==="presentation"||t==="none"?null:t;let n=e.tagName.toLowerCase();if(n==="a")return e.hasAttribute("href")?"link":null;if(n==="section")return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?"region":null;if(n==="form")return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?"form":null;if(n==="img")return e.alt===""?null:"img";if(n==="input")switch(e.type){case"checkbox":return"checkbox";case"radio":return"radio";case"range":return"slider";case"submit":case"button":case"reset":return"button";case"hidden":return null;default:return"textbox"}return il[n]??null}function yo(e){if(e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1")return!0;try{if(getComputedStyle(e).cursor==="pointer")return!0}catch{}return!1}function Se(e){let t=e.getAttribute("aria-label");if(t)return t.trim();let n=e.getAttribute("aria-labelledby");if(n){let a=n.split(/\s+/).map(s=>{let c=document.getElementById(s);return c?Be(c):""}).filter(Boolean).join(" ");if(a)return a}let r=e.tagName.toLowerCase();if(r==="input"||r==="textarea"||r==="select"){let a=al(e);if(a)return a}if(r==="img"){let a=e.alt;if(a)return a.trim()}if(r==="fieldset"){let a=e.querySelector("legend");if(a)return Be(a)}let o=Be(e);if(o)return o;let i=e.getAttribute("title");return i?i.trim():""}function Be(e){if(!e.children.length)return(e.textContent||"").trim();let t=[];for(let n of Array.from(e.childNodes))if(n.nodeType===Node.TEXT_NODE){let r=(n.textContent||"").trim();r&&t.push(r)}else if(n.nodeType===Node.ELEMENT_NODE){let r=n;if(ll(r))continue;let o=sl(r),i=Be(r);i&&(o&&t.length>0&&t.push(" "),t.push(i),o&&t.push(" "))}return t.join("").replace(/\s+/g," ").trim()}function al(e){if(e.id){let n=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(n)return Be(n)}let t=e.closest("label");if(t){let n=t.cloneNode(!0),r=n.querySelector("input, textarea, select");r&&r.remove();let o=n.textContent?.trim();if(o)return o}return null}function sl(e){try{return!getComputedStyle(e).display.includes("inline")}catch{let t=e.tagName.toLowerCase();return["div","p","h1","h2","h3","h4","h5","h6","li","section","article","header","footer","nav","main","aside","blockquote","pre","form","fieldset","table","tr","br"].includes(t)}}function ll(e){let t=e.tagName.toLowerCase();if(t==="script"||t==="style"||t==="noscript"||t==="template"||e.getAttribute("aria-hidden")==="true")return!0;try{let n=getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden")return!0}catch{}return!1}function qn(e,t){try{let n=getComputedStyle(e,t).content;if(!n||n==="none"||n==="normal")return"";let r=n.match(/^["'](.*)["']$/);return r?r[1]:""}catch{return""}}function Pt(){x().networkIdle.activeRequests++}function gt(){let e=x().networkIdle;e.activeRequests=Math.max(0,e.activeRequests-1)}function bo(e=5e3,t=200){return new Promise((n,r)=>{let o=Date.now()+e,i=null;function a(){if(Date.now()>o){i&&clearTimeout(i),n();return}x().networkIdle.activeRequests===0?i||(i=setTimeout(()=>{x().networkIdle.activeRequests===0?n():(i=null,a())},t)):(i&&(clearTimeout(i),i=null),setTimeout(a,50))}a()})}function He(){return x().snapshot.refMap}async function Ue(){return await bo(),Wt()}function Wt(){let e=x().snapshot;e.refCounter=0,e.refMap=new Map;let t=document.body;if(!t)return"(empty page)";let n=wo(t);return Yn(n,0).trimEnd()}function he(e){let t=ye(e),n=Se(e),r=n.length>60?n.slice(0,57)+"...":n;if(t&&r)return`${t} "${r}"`;if(t)return t;if(r)return`"${r}"`;let o=e.tagName.toLowerCase();return e.id?`${o}#${e.id}`:o}function wo(e){if(ul(e))return[];let t=ye(e),n=!t&&yo(e),r=t||(n?"clickable":null),o="";if(r){o=Se(e);let u=qn(e,"::before"),d=qn(e,"::after");(u||d)&&(o=[u,o,d].filter(Boolean).join(" ")),o.length>80&&(o=o.slice(0,77)+"...")}let i=dl(e),a=t==="button"||t==="link"||t==="textbox"||t==="combobox"||t==="checkbox"||t==="radio"||t==="slider"||t==="tab"||t==="menuitem"||n,s=r&&o&&!a,c=null;if(a||s){let u=x().snapshot;u.refCounter++,c=`e${u.refCounter}`,u.refMap.set(c,e)}let l=cl(e);if(r){let u=l.length===0?"":Yn(l,0).trim();return[{tag:r,name:o,attrs:i,ref:c,children:u&&u===o?[]:l,element:e}]}if(l.length===0){let u=Be(e);if(u)return[{tag:null,name:u.length>80?u.slice(0,77)+"...":u,attrs:[],ref:null,children:[],element:e}]}return l}function cl(e){let t=[];for(let n of Array.from(e.childNodes))n.nodeType===Node.ELEMENT_NODE&&t.push(...wo(n));return t}function ul(e){let t=e.tagName.toLowerCase();if(t==="script"||t==="style"||t==="noscript"||t==="template"||t==="head"||e.getAttribute("aria-hidden")==="true"||e.id==="__mindstudio-browser-agent"||e.id==="__mindstudio-cursor"||e.id==="__mindstudio-cursor-ripple"||e.id==="__mindstudio-notes-host")return!0;try{let n=getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"&&n.position!=="static")return!0}catch{}return!1}function dl(e){let t=[],n=e.tagName.toLowerCase();if((n==="dialog"&&e.open||n==="details"&&e.open)&&t.push("open"),e.disabled&&t.push("disabled"),n==="input"){let i=e;(i.type==="checkbox"||i.type==="radio")&&i.checked&&t.push("checked")}if(n==="input"){let i=e;i.type!=="checkbox"&&i.type!=="radio"&&i.type!=="hidden"&&i.type!=="submit"&&i.type!=="button"&&i.type!=="reset"&&(t.push(`value="${i.value}"`),i.placeholder&&t.push(`placeholder="${i.placeholder}"`))}if(n==="textarea"){let i=e;t.push(`value="${i.value}"`),i.placeholder&&t.push(`placeholder="${i.placeholder}"`)}if(n==="select"){let i=e,a=i.options[i.selectedIndex];a&&t.push(`value="${a.text}"`)}let r=n.match(/^h([1-6])$/);r&&t.push(`level=${r[1]}`);let o=e.getAttribute("aria-expanded");return o==="true"&&t.push("expanded"),o==="false"&&t.push("collapsed"),e.getAttribute("aria-selected")==="true"&&t.push("selected"),e.getAttribute("aria-pressed")==="true"&&t.push("pressed"),t}function Yn(e,t){let n="";for(let r of e)n+=fl(r,t);return n}function fl(e,t){let n=" ".repeat(t),r=[];e.tag&&r.push(e.tag),e.name&&r.push(`"${e.name}"`);for(let a of e.attrs)r.push(`[${a}]`);e.ref&&r.push(`[ref=${e.ref}]`);let o="";r.length>0&&(o+=`${n}${r.join(" ")}
2
- `);let i=r.length>0?t+1:t;return o+=Yn(e.children,i),o}function vo(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e instanceof Error)return e.stack||e.message||String(e);if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function le(e){return new Promise(t=>setTimeout(t,e))}function et(){let e=null,t=0;for(let n of document.querySelectorAll("*")){let r=n,o=getComputedStyle(r).overflowY;if(o!=="auto"&&o!=="scroll")continue;let i=r.scrollHeight-r.clientHeight;i<=20||i>t&&(t=i,e=r)}return e??document.documentElement}var ml=["log","info","warn","error","debug"];function Co(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of ml){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),pe({type:"console",level:e,args:n.map(vo),url:location.href})}}}}function So(){window.__ms_error_patched||(window.__ms_error_patched=!0,window.addEventListener("error",e=>{Vn({type:"error",message:e.message,stack:e.error&&e.error.stack||"",source:e.filename,line:e.lineno,column:e.colno,url:location.href})}),window.addEventListener("unhandledrejection",e=>{let t=e.reason||{};Vn({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})}))}function xo(){if(!window.fetch||window.fetch.__ms_patched)return;let e=window.fetch;window.fetch=function(t,n){let r=(n?.method||"GET").toUpperCase(),o=typeof t=="string"?t:t instanceof URL?t.href:t.url||String(t);if(o.includes("/__mindstudio_dev__/"))return e.apply(this,[t,n]);let i=Date.now();return Pt(),e.apply(this,[t,n]).then(a=>{gt();let s={type:"network",method:r,url:o,status:a.status,statusText:a.statusText,duration:Date.now()-i,ok:a.ok};if(a.ok)pe(s);else try{a.clone().text().then(c=>{s.body=c.slice(0,1e3),pe(s)}).catch(()=>pe(s))}catch{pe(s)}return a},a=>{throw gt(),pe({type:"network",method:r,url:o,error:a.message||String(a),duration:Date.now()-i,ok:!1}),a})},window.fetch.__ms_patched=!0}function Io(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target,n=(t?.textContent||"").trim().slice(0,100);pe({type:"interaction",event:"click",target:he(t),text:n,url:location.href})},!0))}function Eo(){if(XMLHttpRequest.prototype.open.__ms_patched)return;let e=window.XMLHttpRequest,t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...i){return this.__ms_method=r.toUpperCase(),this.__ms_url=String(o),t.apply(this,[r,o,...i])},e.prototype.send=function(r){let o=this.__ms_method||"GET",i=this.__ms_url||"";if(i.includes("/__mindstudio_dev__/"))return n.apply(this,[r]);let a=Date.now();return Pt(),this.addEventListener("loadend",function(){gt(),pe({type:"network",method:o,url:i,status:this.status,statusText:this.statusText,duration:Date.now()-a,ok:this.status>=200&&this.status<300,...this.status>=400?{body:(this.responseText||"").slice(0,1e3)}:{},via:"xhr"})},{once:!0}),n.apply(this,[r])},XMLHttpRequest.prototype.open.__ms_patched=!0}function xe(e){let t=null;if(e.ref){let n=He(),r=n.get(e.ref);if(r&&r.isConnected)if(Le(r))t={element:r,matched:`${he(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${jn(r)}). It may be inside a closed dialog or collapsed section.`);else{let o=[...n.entries()].filter(([,i])=>i.isConnected&&Le(i)).slice(0,10).map(([i,a])=>`${he(a)} [ref=${i}]`).join(", ");throw new Error(`Element [ref=${e.ref}] not found. `+(o?`Available refs: ${o}`:"No refs available \u2014 take a snapshot first."))}}if(!t&&(e.text||e.role&&e.text)){let n=e.text,r=e.role,o=Ao(n,r);if(o.length===0){let i=Ao(n,r,!0);if(i.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${jn(i[0])}). Wait for it to become visible or check if a dialog/modal needs to be opened first.`);let a=r?`${r} "${n}"`:`"${n}"`,s=Mo(r);throw new Error(`No element found matching ${a}. `+(s?`Visible ${r||"element"}s: ${s}`:"The page may still be loading \u2014 try a wait command first."))}if(o.length>1){let i=o.filter(ko),a=i.length===1?i[0]:o[0];t={element:a,matched:he(a)}}else t={element:o[0],matched:he(o[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=pl(n);if(r.length===0){let o=Mo(n);throw new Error(`No visible element with role "${n}" found. `+(o?`Visible ${n}s: ${o}`:"The page may still be loading \u2014 try a wait command first."))}t={element:r[0],matched:he(r[0])}}if(!t&&e.label){let n=e.label,r=hl(n);if(!r){let o=[...document.querySelectorAll("label")].filter(Le).map(i=>`"${(i.textContent||"").trim().slice(0,40)}"`).slice(0,8).join(", ");throw new Error(`No input found with label "${n}". `+(o?`Visible labels: ${o}`:"No labels found on the page."))}t={element:r,matched:`${he(r)} via label "${n}"`}}if(!t&&e.selector){let n=e.selector,r=document.querySelector(n);if(!r)throw new Error(`No element found for selector "${n}".`);if(!Le(r))throw new Error(`Found element for selector "${n}" but it is hidden (${jn(r)}).`);t={element:r,matched:`${he(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function Ao(e,t,n=!1){let r=[],o=e.toLowerCase();for(let i of document.querySelectorAll("*")){if(!n&&!Le(i)||n&&!i.isConnected||t&&ye(i)!==t)continue;if(Se(i).toLowerCase().includes(o)){r.push(i);continue}i.children.length||(i.textContent||"").trim().toLowerCase().includes(o)&&r.push(i)}return r}function pl(e){let t=[];for(let n of document.querySelectorAll("*"))Le(n)&&ye(n)===e&&t.push(n);return t}function hl(e){let t=e.toLowerCase();for(let n of document.querySelectorAll("label")){if(!(n.textContent||"").trim().toLowerCase().includes(t))continue;let o=n.getAttribute("for");if(o){let a=document.getElementById(o);if(a&&Le(a))return a}let i=n.querySelector("input, textarea, select");if(i&&Le(i))return i}return null}function Le(e){if(!e.isConnected)return!1;try{let t=getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden")return!1}catch{return!1}return!0}function ko(e){if(e.matches('a, button, input, textarea, select, [role="button"], [role="link"], [tabindex]'))return!0;try{return getComputedStyle(e).cursor==="pointer"}catch{return!1}}function jn(e){try{let t=getComputedStyle(e);if(t.display==="none")return"display: none";if(t.visibility==="hidden")return"visibility: hidden"}catch{}return e.getAttribute("aria-hidden")==="true"?'aria-hidden="true"':"hidden"}function Mo(e){let t=[];for(let n of document.querySelectorAll("*"))if(Le(n)&&(e?ye(n)===e&&t.push(n):ko(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${Se(n).slice(0,40)||he(n)}"`).join(", ")}function Zn(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,o={bubbles:!0,cancelable:!0,clientX:n,clientY:r,button:0};e.dispatchEvent(new PointerEvent("pointerdown",{...o,pointerId:1})),e.dispatchEvent(new MouseEvent("mousedown",o)),e instanceof HTMLElement&&e.focus(),e.dispatchEvent(new PointerEvent("pointerup",{...o,pointerId:1})),e.dispatchEvent(new MouseEvent("mouseup",o)),e.dispatchEvent(new MouseEvent("click",o))}var gl=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,yl=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function No(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),Zn(e),n.clear&&(To(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})));for(let r=0;r<t.length;r++){let o=t[r];e.dispatchEvent(new KeyboardEvent("keydown",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keypress",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),To(e,e.value+o),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),await le(bl(o,t.length))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function bl(e,t){let n=Math.random()*50-25,r;if(e===" "?r=120+n:/[.,!?;:\-]/.test(e)?r=140+n:/[A-Z]/.test(e)?r=115+n:r=85+n,t<=20)return r;let o=Math.max(.1,20/t);return r*o}function To(e,t){let n=e instanceof HTMLTextAreaElement?yl:gl;n?n.call(e,t):e.value=t}async function Ro(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...xe(e),elapsed:Date.now()-n}}catch{await le(100)}let o=e.text?`"${e.text}"`:e.role?`role "${e.role}"`:e.selector?`selector "${e.selector}"`:"element";throw new Error(`Timed out waiting for ${o} after ${t}ms`)}var Lo=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function _o(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("select command requires a <select> element");let n=t.toLowerCase(),r=null;for(let o of e.options)if(o.text.toLowerCase().includes(n)||o.value.toLowerCase()===n||o.label.toLowerCase().includes(n)){r=o;break}if(!r){let o=[...e.options].map(i=>`"${i.text}"`).join(", ");throw new Error(`No option matching "${t}" in select. Available options: ${o}`)}return Lo?Lo.call(e,r.value):e.value=r.value,e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new Event("input",{bubbles:!0})),r.text}async function Fo(e){try{let t=e.trim(),r=/\breturn\b/.test(t)||/[;{]/.test(t)?e:`return (${e})`,i=new Function(r)();return i instanceof Promise?await i:i}catch(t){throw new Error(`evaluate failed: ${t instanceof Error?t.message:String(t)}`)}}var Oo="__mindstudio-touch-circle",Kn="__mindstudio-touch-style",$o=44,Do=5,Po=.95,Bt=.5,Xn=.45,Wo=600;function vl(){document.getElementById(Oo)?.remove();let e=document.createElement("div");return e.id=Oo,e.style.cssText=["position: fixed","z-index: 2147483647","pointer-events: none",`width: ${$o}px`,`height: ${$o}px`,"border-radius: 50%","background: rgba(255, 255, 255, 0.08)","border: 2px solid rgba(255, 255, 255, 0.85)","box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 0 0.5px rgba(0, 0, 0, 0.1)","backdrop-filter: blur(1px)","-webkit-backdrop-filter: blur(1.5px)","transform: translate(-50%, -50%) scale(1)","transition: transform 100ms ease, opacity 100ms ease, background 100ms ease","opacity: 0","will-change: left, top, transform, opacity"].join("; "),document.documentElement.appendChild(e),e}function Cl(e){e.style.transform="translate(-50%, -50%) scale(0.88)",e.style.background="rgba(255, 255, 255, 0.18)"}function Bo(e){e.style.transform="translate(-50%, -50%) scale(1)",e.style.background="rgba(255, 255, 255, 0.08)"}function Ho(){window.parent!==window&&x().zoom.mobilePreview&&yt()}function yt(){let e=x().touch;if(e.active)return;e.active=!0,e.scrollContainer=et(),El();let t=vl();e.circleEl=t,e.onMouseMove=n=>{let r=x();if(r.cursor.executing||r.screenshot.capturing){t.style.opacity="0";return}if(t.style.left=`${n.clientX}px`,t.style.top=`${n.clientY}px`,t.style.opacity="1",e.pressed){let o=Math.abs(n.clientX-e.startX),i=Math.abs(n.clientY-e.startY);if(!e.dragging&&(o>Do||i>Do)&&(e.dragging=!0),e.dragging){let a=e.scrollContainer||document.documentElement,s=performance.now(),c=s-e.lastMoveTime||16,l=e.lastX-n.clientX,u=e.lastY-n.clientY;e.bouncing&&Il();let d=a.scrollTop;a.scrollTop+=u,a.scrollLeft+=l;let m=a.scrollTop-d,p=u-m;if(Math.abs(p)>.5){let g=Xn/(1+Math.abs(e.overscrollY)/200);e.overscrollY+=p*g,Jn()}else if(e.overscrollY!==0){let g=Xn/(1+Math.abs(e.overscrollY)/200);e.overscrollY+=p*g,(e.overscrollY>0&&u<0||e.overscrollY<0&&u>0)&&(e.overscrollY*=.7),Jn()}e.velocityX=.8*(l/c)+.2*e.velocityX,e.velocityY=.8*(u/c)+.2*e.velocityY,e.lastMoveTime=s,n.preventDefault()}e.lastX=n.clientX,e.lastY=n.clientY}},e.onMouseDown=n=>{x().cursor.executing||(Ht(),e.pressed=!0,e.dragging=!1,e.startX=n.clientX,e.startY=n.clientY,e.lastX=n.clientX,e.lastY=n.clientY,e.velocityX=0,e.velocityY=0,e.lastMoveTime=performance.now(),Cl(t))},e.onMouseUp=()=>{let n=e.dragging;n&&document.addEventListener("click",Sl,{capture:!0,once:!0}),e.pressed=!1,e.dragging=!1,Bo(t),n&&(e.overscrollY!==0&&Go(),(Math.abs(e.velocityX)>Bt/16||Math.abs(e.velocityY)>Bt/16)&&xl())},e.onMouseLeave=()=>{e.pressed=!1,e.dragging=!1,Ht(),t.style.opacity="0",Bo(t)},e.onDragStart=n=>n.preventDefault(),document.addEventListener("mousemove",e.onMouseMove),document.addEventListener("mousedown",e.onMouseDown),document.addEventListener("mouseup",e.onMouseUp),document.addEventListener("mouseleave",e.onMouseLeave),document.addEventListener("dragstart",e.onDragStart)}function Ut(){let e=x().touch;e.active&&(e.active=!1,e.pressed=!1,e.dragging=!1,Ht(),e.overscrollY!==0&&(e.overscrollY=0,document.body.style.transition="",document.body.style.transform=""),Al(),e.circleEl&&(e.circleEl.remove(),e.circleEl=null),e.onMouseMove&&document.removeEventListener("mousemove",e.onMouseMove),e.onMouseDown&&document.removeEventListener("mousedown",e.onMouseDown),e.onMouseUp&&document.removeEventListener("mouseup",e.onMouseUp),e.onMouseLeave&&document.removeEventListener("mouseleave",e.onMouseLeave),e.onDragStart&&document.removeEventListener("dragstart",e.onDragStart),e.onMouseMove=null,e.onMouseDown=null,e.onMouseUp=null,e.onMouseLeave=null,e.onDragStart=null)}function Uo(){let{circleEl:e}=x().touch;e&&(e.style.opacity="0")}function Vo(){let e=x().touch;e.active&&e.circleEl&&(e.circleEl.style.opacity="1")}function Sl(e){e.preventDefault(),e.stopPropagation()}function xl(){Ht();let e=x().touch,t=e.scrollContainer||document.documentElement,n=e.velocityX*16,r=e.velocityY*16;function o(){let i=x().touch;if(n*=Po,r*=Po,Math.abs(n)<Bt&&Math.abs(r)<Bt){i.momentumFrame=null,i.overscrollY!==0&&Go();return}let a=t.scrollTop;t.scrollTop+=r,t.scrollLeft+=n;let s=t.scrollTop-a,c=r-s;if(Math.abs(c)>.5){let l=Xn*.5/(1+Math.abs(i.overscrollY)/200);i.overscrollY+=c*l,Jn(),r*=.7}i.momentumFrame=requestAnimationFrame(o)}e.momentumFrame=requestAnimationFrame(o)}function Ht(){let e=x().touch;e.momentumFrame!==null&&(cancelAnimationFrame(e.momentumFrame),e.momentumFrame=null)}function Jn(){let e=x().touch;document.body.style.transition="none",document.body.style.transform=`translateY(${-e.overscrollY}px)`}function Go(){let e=x().touch;e.bouncing=!0,e.overscrollY=0,document.body.style.transition=`transform ${Wo}ms cubic-bezier(0.2, 0.9, 0.3, 1)`,document.body.style.transform="",e.bounceTimer&&clearTimeout(e.bounceTimer),e.bounceTimer=setTimeout(()=>{let t=x().touch;t.bouncing=!1,t.bounceTimer=null,document.body.style.transition="",document.body.style.transform=""},Wo)}function Il(){let e=x().touch;e.bouncing&&(e.bouncing=!1,e.bounceTimer&&(clearTimeout(e.bounceTimer),e.bounceTimer=null),document.body.style.transition="")}function El(){document.getElementById(Kn)?.remove();let e=document.createElement("style");e.id=Kn,e.textContent=`
2
+ `);let i=r.length>0?t+1:t;return o+=Yn(e.children,i),o}function vo(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e instanceof Error)return e.stack||e.message||String(e);if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function le(e){return new Promise(t=>setTimeout(t,e))}function et(){let e=null,t=0;for(let n of document.querySelectorAll("*")){let r=n,o=getComputedStyle(r).overflowY;if(o!=="auto"&&o!=="scroll")continue;let i=r.scrollHeight-r.clientHeight;i<=20||i>t&&(t=i,e=r)}return e??document.documentElement}var ml=["log","info","warn","error","debug"];function Co(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of ml){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),pe({type:"console",level:e,args:n.map(vo),url:location.href})}}}}function So(){window.__ms_error_patched||(window.__ms_error_patched=!0,window.addEventListener("error",e=>{Vn({type:"error",message:e.message,stack:e.error&&e.error.stack||"",source:e.filename,line:e.lineno,column:e.colno,url:location.href})}),window.addEventListener("unhandledrejection",e=>{let t=e.reason||{};Vn({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})}))}function xo(){if(!window.fetch||window.fetch.__ms_patched)return;let e=window.fetch;window.fetch=function(t,n){let r=(n?.method||"GET").toUpperCase(),o=typeof t=="string"?t:t instanceof URL?t.href:t.url||String(t);if(o.includes("/__mindstudio_dev__/"))return e.apply(this,[t,n]);let i=Date.now();return Pt(),e.apply(this,[t,n]).then(a=>{gt();let s={type:"network",method:r,url:o,status:a.status,statusText:a.statusText,duration:Date.now()-i,ok:a.ok};if(a.ok)pe(s);else try{a.clone().text().then(c=>{s.body=c.slice(0,1e3),pe(s)}).catch(()=>pe(s))}catch{pe(s)}return a},a=>{throw gt(),pe({type:"network",method:r,url:o,error:a.message||String(a),duration:Date.now()-i,ok:!1}),a})},window.fetch.__ms_patched=!0}function Io(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target;if(!t)return;let n=(t.textContent||"").trim().slice(0,100);pe({type:"interaction",event:"click",target:he(t),text:n,url:location.href})},!0))}function Eo(){if(XMLHttpRequest.prototype.open.__ms_patched)return;let e=window.XMLHttpRequest,t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...i){return this.__ms_method=r.toUpperCase(),this.__ms_url=String(o),t.apply(this,[r,o,...i])},e.prototype.send=function(r){let o=this.__ms_method||"GET",i=this.__ms_url||"";if(i.includes("/__mindstudio_dev__/"))return n.apply(this,[r]);let a=Date.now();return Pt(),this.addEventListener("loadend",function(){gt(),pe({type:"network",method:o,url:i,status:this.status,statusText:this.statusText,duration:Date.now()-a,ok:this.status>=200&&this.status<300,...this.status>=400?{body:(this.responseText||"").slice(0,1e3)}:{},via:"xhr"})},{once:!0}),n.apply(this,[r])},XMLHttpRequest.prototype.open.__ms_patched=!0}function xe(e){let t=null;if(e.ref){let n=He(),r=n.get(e.ref);if(r&&r.isConnected)if(Le(r))t={element:r,matched:`${he(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${jn(r)}). It may be inside a closed dialog or collapsed section.`);else{let o=[...n.entries()].filter(([,i])=>i.isConnected&&Le(i)).slice(0,10).map(([i,a])=>`${he(a)} [ref=${i}]`).join(", ");throw new Error(`Element [ref=${e.ref}] not found. `+(o?`Available refs: ${o}`:"No refs available \u2014 take a snapshot first."))}}if(!t&&(e.text||e.role&&e.text)){let n=e.text,r=e.role,o=Ao(n,r);if(o.length===0){let i=Ao(n,r,!0);if(i.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${jn(i[0])}). Wait for it to become visible or check if a dialog/modal needs to be opened first.`);let a=r?`${r} "${n}"`:`"${n}"`,s=Mo(r);throw new Error(`No element found matching ${a}. `+(s?`Visible ${r||"element"}s: ${s}`:"The page may still be loading \u2014 try a wait command first."))}if(o.length>1){let i=o.filter(ko),a=i.length===1?i[0]:o[0];t={element:a,matched:he(a)}}else t={element:o[0],matched:he(o[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=pl(n);if(r.length===0){let o=Mo(n);throw new Error(`No visible element with role "${n}" found. `+(o?`Visible ${n}s: ${o}`:"The page may still be loading \u2014 try a wait command first."))}t={element:r[0],matched:he(r[0])}}if(!t&&e.label){let n=e.label,r=hl(n);if(!r){let o=[...document.querySelectorAll("label")].filter(Le).map(i=>`"${(i.textContent||"").trim().slice(0,40)}"`).slice(0,8).join(", ");throw new Error(`No input found with label "${n}". `+(o?`Visible labels: ${o}`:"No labels found on the page."))}t={element:r,matched:`${he(r)} via label "${n}"`}}if(!t&&e.selector){let n=e.selector,r=document.querySelector(n);if(!r)throw new Error(`No element found for selector "${n}".`);if(!Le(r))throw new Error(`Found element for selector "${n}" but it is hidden (${jn(r)}).`);t={element:r,matched:`${he(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function Ao(e,t,n=!1){let r=[],o=e.toLowerCase();for(let i of document.querySelectorAll("*")){if(!n&&!Le(i)||n&&!i.isConnected||t&&ye(i)!==t)continue;if(Se(i).toLowerCase().includes(o)){r.push(i);continue}i.children.length||(i.textContent||"").trim().toLowerCase().includes(o)&&r.push(i)}return r}function pl(e){let t=[];for(let n of document.querySelectorAll("*"))Le(n)&&ye(n)===e&&t.push(n);return t}function hl(e){let t=e.toLowerCase();for(let n of document.querySelectorAll("label")){if(!(n.textContent||"").trim().toLowerCase().includes(t))continue;let o=n.getAttribute("for");if(o){let a=document.getElementById(o);if(a&&Le(a))return a}let i=n.querySelector("input, textarea, select");if(i&&Le(i))return i}return null}function Le(e){if(!e.isConnected)return!1;try{let t=getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden")return!1}catch{return!1}return!0}function ko(e){if(e.matches('a, button, input, textarea, select, [role="button"], [role="link"], [tabindex]'))return!0;try{return getComputedStyle(e).cursor==="pointer"}catch{return!1}}function jn(e){try{let t=getComputedStyle(e);if(t.display==="none")return"display: none";if(t.visibility==="hidden")return"visibility: hidden"}catch{}return e.getAttribute("aria-hidden")==="true"?'aria-hidden="true"':"hidden"}function Mo(e){let t=[];for(let n of document.querySelectorAll("*"))if(Le(n)&&(e?ye(n)===e&&t.push(n):ko(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${Se(n).slice(0,40)||he(n)}"`).join(", ")}function Zn(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,o={bubbles:!0,cancelable:!0,clientX:n,clientY:r,button:0};e.dispatchEvent(new PointerEvent("pointerdown",{...o,pointerId:1})),e.dispatchEvent(new MouseEvent("mousedown",o)),e instanceof HTMLElement&&e.focus(),e.dispatchEvent(new PointerEvent("pointerup",{...o,pointerId:1})),e.dispatchEvent(new MouseEvent("mouseup",o)),e.dispatchEvent(new MouseEvent("click",o))}var gl=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,yl=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function No(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),Zn(e),n.clear&&(To(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})));for(let r=0;r<t.length;r++){let o=t[r];e.dispatchEvent(new KeyboardEvent("keydown",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keypress",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),To(e,e.value+o),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{key:o,code:`Key${o.toUpperCase()}`,bubbles:!0})),await le(bl(o,t.length))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function bl(e,t){let n=Math.random()*50-25,r;if(e===" "?r=120+n:/[.,!?;:\-]/.test(e)?r=140+n:/[A-Z]/.test(e)?r=115+n:r=85+n,t<=20)return r;let o=Math.max(.1,20/t);return r*o}function To(e,t){let n=e instanceof HTMLTextAreaElement?yl:gl;n?n.call(e,t):e.value=t}async function Ro(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...xe(e),elapsed:Date.now()-n}}catch{await le(100)}let o=e.text?`"${e.text}"`:e.role?`role "${e.role}"`:e.selector?`selector "${e.selector}"`:"element";throw new Error(`Timed out waiting for ${o} after ${t}ms`)}var Lo=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function _o(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("select command requires a <select> element");let n=t.toLowerCase(),r=null;for(let o of e.options)if(o.text.toLowerCase().includes(n)||o.value.toLowerCase()===n||o.label.toLowerCase().includes(n)){r=o;break}if(!r){let o=[...e.options].map(i=>`"${i.text}"`).join(", ");throw new Error(`No option matching "${t}" in select. Available options: ${o}`)}return Lo?Lo.call(e,r.value):e.value=r.value,e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new Event("input",{bubbles:!0})),r.text}async function Fo(e){try{let t=e.trim(),r=/\breturn\b/.test(t)||/[;{]/.test(t)?e:`return (${e})`,i=new Function(r)();return i instanceof Promise?await i:i}catch(t){throw new Error(`evaluate failed: ${t instanceof Error?t.message:String(t)}`)}}var Oo="__mindstudio-touch-circle",Kn="__mindstudio-touch-style",$o=44,Do=5,Po=.95,Bt=.5,Xn=.45,Wo=600;function vl(){document.getElementById(Oo)?.remove();let e=document.createElement("div");return e.id=Oo,e.style.cssText=["position: fixed","z-index: 2147483647","pointer-events: none",`width: ${$o}px`,`height: ${$o}px`,"border-radius: 50%","background: rgba(255, 255, 255, 0.08)","border: 2px solid rgba(255, 255, 255, 0.85)","box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 0 0.5px rgba(0, 0, 0, 0.1)","backdrop-filter: blur(1px)","-webkit-backdrop-filter: blur(1.5px)","transform: translate(-50%, -50%) scale(1)","transition: transform 100ms ease, opacity 100ms ease, background 100ms ease","opacity: 0","will-change: left, top, transform, opacity"].join("; "),document.documentElement.appendChild(e),e}function Cl(e){e.style.transform="translate(-50%, -50%) scale(0.88)",e.style.background="rgba(255, 255, 255, 0.18)"}function Bo(e){e.style.transform="translate(-50%, -50%) scale(1)",e.style.background="rgba(255, 255, 255, 0.08)"}function Ho(){window.parent!==window&&x().zoom.mobilePreview&&yt()}function yt(){let e=x().touch;if(e.active)return;e.active=!0,e.scrollContainer=et(),El();let t=vl();e.circleEl=t,e.onMouseMove=n=>{let r=x();if(r.cursor.executing||r.screenshot.capturing){t.style.opacity="0";return}if(t.style.left=`${n.clientX}px`,t.style.top=`${n.clientY}px`,t.style.opacity="1",e.pressed){let o=Math.abs(n.clientX-e.startX),i=Math.abs(n.clientY-e.startY);if(!e.dragging&&(o>Do||i>Do)&&(e.dragging=!0),e.dragging){let a=e.scrollContainer||document.documentElement,s=performance.now(),c=s-e.lastMoveTime||16,l=e.lastX-n.clientX,u=e.lastY-n.clientY;e.bouncing&&Il();let d=a.scrollTop;a.scrollTop+=u,a.scrollLeft+=l;let m=a.scrollTop-d,p=u-m;if(Math.abs(p)>.5){let g=Xn/(1+Math.abs(e.overscrollY)/200);e.overscrollY+=p*g,Jn()}else if(e.overscrollY!==0){let g=Xn/(1+Math.abs(e.overscrollY)/200);e.overscrollY+=p*g,(e.overscrollY>0&&u<0||e.overscrollY<0&&u>0)&&(e.overscrollY*=.7),Jn()}e.velocityX=.8*(l/c)+.2*e.velocityX,e.velocityY=.8*(u/c)+.2*e.velocityY,e.lastMoveTime=s,n.preventDefault()}e.lastX=n.clientX,e.lastY=n.clientY}},e.onMouseDown=n=>{x().cursor.executing||(Ht(),e.pressed=!0,e.dragging=!1,e.startX=n.clientX,e.startY=n.clientY,e.lastX=n.clientX,e.lastY=n.clientY,e.velocityX=0,e.velocityY=0,e.lastMoveTime=performance.now(),Cl(t))},e.onMouseUp=()=>{let n=e.dragging;n&&document.addEventListener("click",Sl,{capture:!0,once:!0}),e.pressed=!1,e.dragging=!1,Bo(t),n&&(e.overscrollY!==0&&Go(),(Math.abs(e.velocityX)>Bt/16||Math.abs(e.velocityY)>Bt/16)&&xl())},e.onMouseLeave=()=>{e.pressed=!1,e.dragging=!1,Ht(),t.style.opacity="0",Bo(t)},e.onDragStart=n=>n.preventDefault(),document.addEventListener("mousemove",e.onMouseMove),document.addEventListener("mousedown",e.onMouseDown),document.addEventListener("mouseup",e.onMouseUp),document.addEventListener("mouseleave",e.onMouseLeave),document.addEventListener("dragstart",e.onDragStart)}function Ut(){let e=x().touch;e.active&&(e.active=!1,e.pressed=!1,e.dragging=!1,Ht(),e.overscrollY!==0&&(e.overscrollY=0,document.body.style.transition="",document.body.style.transform=""),Al(),e.circleEl&&(e.circleEl.remove(),e.circleEl=null),e.onMouseMove&&document.removeEventListener("mousemove",e.onMouseMove),e.onMouseDown&&document.removeEventListener("mousedown",e.onMouseDown),e.onMouseUp&&document.removeEventListener("mouseup",e.onMouseUp),e.onMouseLeave&&document.removeEventListener("mouseleave",e.onMouseLeave),e.onDragStart&&document.removeEventListener("dragstart",e.onDragStart),e.onMouseMove=null,e.onMouseDown=null,e.onMouseUp=null,e.onMouseLeave=null,e.onDragStart=null)}function Uo(){let{circleEl:e}=x().touch;e&&(e.style.opacity="0")}function Vo(){let e=x().touch;e.active&&e.circleEl&&(e.circleEl.style.opacity="1")}function Sl(e){e.preventDefault(),e.stopPropagation()}function xl(){Ht();let e=x().touch,t=e.scrollContainer||document.documentElement,n=e.velocityX*16,r=e.velocityY*16;function o(){let i=x().touch;if(n*=Po,r*=Po,Math.abs(n)<Bt&&Math.abs(r)<Bt){i.momentumFrame=null,i.overscrollY!==0&&Go();return}let a=t.scrollTop;t.scrollTop+=r,t.scrollLeft+=n;let s=t.scrollTop-a,c=r-s;if(Math.abs(c)>.5){let l=Xn*.5/(1+Math.abs(i.overscrollY)/200);i.overscrollY+=c*l,Jn(),r*=.7}i.momentumFrame=requestAnimationFrame(o)}e.momentumFrame=requestAnimationFrame(o)}function Ht(){let e=x().touch;e.momentumFrame!==null&&(cancelAnimationFrame(e.momentumFrame),e.momentumFrame=null)}function Jn(){let e=x().touch;document.body.style.transition="none",document.body.style.transform=`translateY(${-e.overscrollY}px)`}function Go(){let e=x().touch;e.bouncing=!0,e.overscrollY=0,document.body.style.transition=`transform ${Wo}ms cubic-bezier(0.2, 0.9, 0.3, 1)`,document.body.style.transform="",e.bounceTimer&&clearTimeout(e.bounceTimer),e.bounceTimer=setTimeout(()=>{let t=x().touch;t.bouncing=!1,t.bounceTimer=null,document.body.style.transition="",document.body.style.transform=""},Wo)}function Il(){let e=x().touch;e.bouncing&&(e.bouncing=!1,e.bounceTimer&&(clearTimeout(e.bounceTimer),e.bounceTimer=null),document.body.style.transition="")}function El(){document.getElementById(Kn)?.remove();let e=document.createElement("style");e.id=Kn,e.textContent=`
3
3
  *, *::before, *::after {
4
4
  cursor: none !important;
5
5
  user-select: none !important;
@@ -326,7 +326,7 @@ ${g}
326
326
  @keyframes __ms_auth_spin {
327
327
  to { transform: rotate(360deg); }
328
328
  }
329
- `,n.appendChild(r);let o=document.createElement("div");o.className="card",n.appendChild(o),document.body.appendChild(t),e.host=t}function um(e){let t=x().authCredsWidget;if(!t.host)return;let n=t.host.shadowRoot;if(!n)return;let r=n.querySelector(".card");if(!r||e.loading&&r.querySelector(".loading"))return;r.innerHTML="";let o=document.createElement("div");o.className="header";let i=document.createElement("span");i.className="title",i.textContent="Dev mode";let a=document.createElement("button");if(a.className="dismiss",a.setAttribute("aria-label","Dismiss"),a.title="Dismiss",a.textContent="\xD7",a.addEventListener("click",e.onDismiss),o.appendChild(i),o.appendChild(a),r.appendChild(o),e.loading){let l=document.createElement("div");l.className="loading";let u=document.createElement("span");u.className="spinner";let d=document.createElement("span");d.textContent="Signing in\u2026",l.appendChild(u),l.appendChild(d),r.appendChild(l);return}let s=document.createElement("p");s.className="body",s.textContent="Use your own credentials, or use these test credentials to bypass verification.",r.appendChild(s);let c=document.createElement("div");if(c.className="actions",r.appendChild(c),e.identifier&&e.identifierKind){let l=e.identifierKind==="email"?sm:lm,u=document.createElement("button");u.className="primary",u.textContent=`Continue with ${l}`,u.title=`Continue with ${l}`,u.addEventListener("click",()=>{e.identifier&&(Ts(e.identifier,l),e.onIdentifierFilled())}),c.appendChild(u)}if(e.code){let l=document.createElement("button");l.className="primary",l.textContent=`Continue with ${Qe}`,l.title=`Continue with ${Qe}`,l.addEventListener("click",()=>{e.code&&On(e.code,Qe)}),c.appendChild(l)}}var Ns="__ms_dev_creds_dismissed",dm=150,fm=8e3,mm=250,pm=8,hm=6,gm=200,ym=1e4;function Rs(){let e=x();e.authCredsWidget||(e.authCredsWidget={initialized:!1,host:null,observer:null,debounceTimer:null,awaitingCode:!1,awaitingCodeTimer:null,codePollTimer:null,codeAttempts:0,codeSubmitted:!1,codeSeenCount:0,blankPolls:0});let t=e.authCredsWidget;if(t.initialized||(t.initialized=!0,Nr()))return;let n=Lr();n!=="iframe"&&n!=="standalone"||_s(Date.now()+ym)}function _s(e){if(typeof window.__MINDSTUDIO__?.releaseId!="string"){Date.now()<e&&setTimeout(()=>_s(e),gm);return}let n=x().authCredsWidget;if(n.observer)return;let r=new MutationObserver(ao);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["type","autocomplete","inputmode","maxlength","style","hidden","class"]}),n.observer=r,ao()}function ao(){let e=x().authCredsWidget;e.debounceTimer&&clearTimeout(e.debounceTimer),e.debounceTimer=setTimeout(()=>{e.debounceTimer=null,Fs()},dm)}function Fs(){let e=x().authCredsWidget;if(wm()){$n(),lo();return}let t=Is();if(!t.identifier&&!t.code){if(e.awaitingCode&&!e.codeSubmitted&&e.blankPolls<hm){e.blankPolls++,so();return}$n(),lo();return}if(e.blankPolls=0,e.awaitingCode){if(t.code)if(ro(t.code)===Qe)e.codeSubmitted||(oo(t.code),e.codeSubmitted=!0);else{let r=t.code.cells.length,o=!t.code.segmented||r===e.codeSeenCount;e.codeSeenCount=r,o&&e.codeAttempts<pm&&(e.codeAttempts++,On(t.code,Qe)===Qe&&(e.codeSubmitted=!0))}else e.codeSeenCount=0;so();return}io({identifier:t.identifier,identifierKind:t.identifierKind,code:bm(t.code),loading:!1,onDismiss:$s,onIdentifierFilled:Os})}function bm(e){return e&&e.cells.some(t=>!t.disabled)?e:null}function so(){io({identifier:null,identifierKind:null,code:null,loading:!0,onDismiss:$s,onIdentifierFilled:Os})}function Os(){let e=x().authCredsWidget;e.awaitingCode=!0,e.codeAttempts=0,e.codeSubmitted=!1,e.codeSeenCount=0,e.blankPolls=0,e.awaitingCodeTimer&&clearTimeout(e.awaitingCodeTimer),e.awaitingCodeTimer=setTimeout(()=>{$n(),ao()},fm),e.codePollTimer&&clearInterval(e.codePollTimer),e.codePollTimer=setInterval(Fs,mm),so()}function $n(){let e=x().authCredsWidget;e.awaitingCode=!1,e.codeAttempts=0,e.codeSubmitted=!1,e.codeSeenCount=0,e.blankPolls=0,e.awaitingCodeTimer&&(clearTimeout(e.awaitingCodeTimer),e.awaitingCodeTimer=null),e.codePollTimer&&(clearInterval(e.codePollTimer),e.codePollTimer=null)}function lo(){Ls()}function $s(){$n();try{sessionStorage.setItem(Ns,"1")}catch{}lo()}function wm(){try{return sessionStorage.getItem(Ns)==="1"}catch{return!1}}var vm=new Set(["__mindstudio-browser-agent","__mindstudio-cursor","__mindstudio-cursor-ripple","__mindstudio-notes-overlay","__mindstudio-notes-cursor"]),Cm=["backgroundColor","backgroundImage","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxShadow"],Ds=60,Sm=80;function Ps(){let e=window.innerWidth,t=window.innerHeight,n=window.scrollY,r=document.documentElement.scrollHeight,o=[];o.push(`viewport: ${e} \xD7 ${t}`),o.push(`scroll: ${Math.round(n)} / ${r} (${n<10?"top":n+t>=r-10?"bottom":Math.round(n/(r-t)*100)+"%"})`),o.push("");let i=[],a=document.body;if(!a)return o.join(`
329
+ `,n.appendChild(r);let o=document.createElement("div");o.className="card",n.appendChild(o),document.body.appendChild(t),e.host=t}function um(e){let t=x().authCredsWidget;if(!t.host)return;let n=t.host.shadowRoot;if(!n)return;let r=n.querySelector(".card");if(!r||e.loading&&r.querySelector(".loading"))return;r.innerHTML="";let o=document.createElement("div");o.className="header";let i=document.createElement("span");i.className="title",i.textContent="Dev mode";let a=document.createElement("button");if(a.className="dismiss",a.setAttribute("aria-label","Dismiss"),a.title="Dismiss",a.textContent="\xD7",a.addEventListener("click",e.onDismiss),o.appendChild(i),o.appendChild(a),r.appendChild(o),e.loading){let l=document.createElement("div");l.className="loading";let u=document.createElement("span");u.className="spinner";let d=document.createElement("span");d.textContent="Signing in\u2026",l.appendChild(u),l.appendChild(d),r.appendChild(l);return}let s=document.createElement("p");s.className="body",s.textContent="Use your own credentials, or use these test credentials to bypass verification.",r.appendChild(s);let c=document.createElement("div");if(c.className="actions",r.appendChild(c),e.identifier&&e.identifierKind){let l=e.identifierKind==="email"?sm:lm,u=document.createElement("button");u.className="primary",u.textContent=`Continue with ${l}`,u.title=`Continue with ${l}`,u.addEventListener("click",()=>{e.identifier&&(Ts(e.identifier,l),e.onIdentifierFilled())}),c.appendChild(u)}if(e.code){let l=document.createElement("button");l.className="primary",l.textContent=`Continue with ${Qe}`,l.title=`Continue with ${Qe}`,l.addEventListener("click",()=>{e.code&&On(e.code,Qe)}),c.appendChild(l)}}var Ns="__ms_dev_creds_dismissed",dm=150,fm=8e3,mm=250,pm=8,hm=6,gm=200,ym=1e4;function Rs(){let e=x();e.authCredsWidget||(e.authCredsWidget={initialized:!1,host:null,observer:null,debounceTimer:null,awaitingCode:!1,awaitingCodeTimer:null,codePollTimer:null,codeAttempts:0,codeSubmitted:!1,codeSeenCount:0,blankPolls:0});let t=e.authCredsWidget;if(t.initialized||(t.initialized=!0,Nr()))return;let n=Lr();n!=="iframe"&&n!=="standalone"||_s(Date.now()+ym)}function _s(e){if(typeof window.__MINDSTUDIO__?.releaseId!="string"){Date.now()<e&&setTimeout(()=>_s(e),gm);return}let n=x().authCredsWidget;if(n.observer)return;let r=new MutationObserver(ao);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["type","autocomplete","inputmode","maxlength","style","hidden","class"]}),n.observer=r,ao()}function ao(){let e=x().authCredsWidget;e.debounceTimer&&clearTimeout(e.debounceTimer),e.debounceTimer=setTimeout(()=>{e.debounceTimer=null,Fs()},dm)}function Fs(){let e=x().authCredsWidget;if(wm()){$n(),lo();return}let t=Is();if(!t.identifier&&!t.code){if(e.awaitingCode&&!e.codeSubmitted&&e.blankPolls<hm){e.blankPolls++,so();return}$n(),lo();return}if(e.blankPolls=0,e.awaitingCode){if(t.code&&!e.codeSubmitted)if(ro(t.code)===Qe)oo(t.code),e.codeSubmitted=!0;else{let r=t.code.cells.length,o=!t.code.segmented||r===e.codeSeenCount;e.codeSeenCount=r,o&&e.codeAttempts<pm&&(e.codeAttempts++,On(t.code,Qe)===Qe&&(e.codeSubmitted=!0))}else t.code||(e.codeSeenCount=0);so();return}io({identifier:t.identifier,identifierKind:t.identifierKind,code:bm(t.code),loading:!1,onDismiss:$s,onIdentifierFilled:Os})}function bm(e){return e&&e.cells.some(t=>!t.disabled)?e:null}function so(){io({identifier:null,identifierKind:null,code:null,loading:!0,onDismiss:$s,onIdentifierFilled:Os})}function Os(){let e=x().authCredsWidget;e.awaitingCode=!0,e.codeAttempts=0,e.codeSubmitted=!1,e.codeSeenCount=0,e.blankPolls=0,e.awaitingCodeTimer&&clearTimeout(e.awaitingCodeTimer),e.awaitingCodeTimer=setTimeout(()=>{$n(),ao()},fm),e.codePollTimer&&clearInterval(e.codePollTimer),e.codePollTimer=setInterval(Fs,mm),so()}function $n(){let e=x().authCredsWidget;e.awaitingCode=!1,e.codeAttempts=0,e.codeSubmitted=!1,e.codeSeenCount=0,e.blankPolls=0,e.awaitingCodeTimer&&(clearTimeout(e.awaitingCodeTimer),e.awaitingCodeTimer=null),e.codePollTimer&&(clearInterval(e.codePollTimer),e.codePollTimer=null)}function lo(){Ls()}function $s(){$n();try{sessionStorage.setItem(Ns,"1")}catch{}lo()}function wm(){try{return sessionStorage.getItem(Ns)==="1"}catch{return!1}}var vm=new Set(["__mindstudio-browser-agent","__mindstudio-cursor","__mindstudio-cursor-ripple","__mindstudio-notes-overlay","__mindstudio-notes-cursor"]),Cm=["backgroundColor","backgroundImage","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxShadow"],Ds=60,Sm=80;function Ps(){let e=window.innerWidth,t=window.innerHeight,n=window.scrollY,r=document.documentElement.scrollHeight,o=[];o.push(`viewport: ${e} \xD7 ${t}`),o.push(`scroll: ${Math.round(n)} / ${r} (${n<10?"top":n+t>=r-10?"bottom":Math.round(n/(r-t)*100)+"%"})`),o.push("");let i=[],a=document.body;if(!a)return o.join(`
330
330
  `)+"(empty page)";Ws(a,i,e,t,n);let s=Nm(i);for(let u of s)if("count"in u){let d=u;o.push(`[${d.count} ${d.role}, each ~${d.avgWidth} \xD7 ${d.avgHeight}, first: "${d.firstName}", last: "${d.lastName}"]`),o.push("")}else Mm(u,o,e,t,n);let c=Lm(i);if(c.length>0){for(let u of c)o.push(`\xD7 ${u.a} overlaps ${u.b} by ${u.overlapPx}px ${u.axis}ly`);o.push("")}let l=i.filter(u=>{let d=u.rect;return d.right<0||d.left>e||d.bottom<-n||d.top>t+n});for(let u of l){let d=u.rect,f="";d.right<0?f=`left: ${Math.round(d.left)}px`:d.left>e?f=`left: ${Math.round(d.left)}px`:d.bottom<0?f=`top: ${Math.round(d.top)}px`:f=`top: ${Math.round(d.top)}px`,o.push(`\xD7 ${u.label} \u2014 off-viewport (${f})`)}return o.join(`
331
331
  `).trimEnd()}function Ws(e,t,n,r,o){if(xm(e)||t.length>=Sm)return;let i=e.tagName.toLowerCase(),a=ye(e),s=Bs(e),c=a!==null,l=i==="img"||i==="svg"||i==="canvas"||i==="video",u=i==="input"||i==="textarea"||i==="select",d=c||l||u;if(!d&&Im(e)&&(d=!0),d&&!s&&!l&&!u&&Em(a)&&(d=!1),d){let f=e.getBoundingClientRect();if(f.width>0&&f.height>0)try{let m=getComputedStyle(e),p=Am(e,a,i);t.push({label:p,rect:f,style:m,el:e,tag:i})}catch{}}for(let f of Array.from(e.children))Ws(f,t,n,r,o)}function xm(e){if(vm.has(e.id))return!0;let t=e.tagName.toLowerCase();if(t==="script"||t==="style"||t==="noscript"||t==="template"||t==="head"||e.getAttribute("aria-hidden")==="true")return!0;try{let n=getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden")return!0}catch{}return!1}function Bs(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim())return!0;return!1}function Im(e){try{let t=getComputedStyle(e);for(let n of Cm){let r=t[n];if(!(!r||r==="none"||r==="0px"||r==="rgba(0, 0, 0, 0)"||r==="transparent"))return!0}}catch{}return!1}function Em(e){return e==="navigation"||e==="main"||e==="banner"||e==="contentinfo"||e==="complementary"||e==="region"||e==="form"||e==="list"||e==="table"||e==="article"||e==="group"}function Am(e,t,n){let r=Se(e),o=r.length>Ds?r.slice(0,Ds-1)+"\u2026":r;if(t&&o)return`${t} "${o}"`;if(t)return t;if(o)return`${n} "${o}"`;if(e.id)return`${n}#${e.id}`;let i=e.className&&typeof e.className=="string"?e.className.split(/\s+/).find(a=>!a.startsWith("sc-")&&!a.startsWith("css-")&&a.length<30):null;return i?`${n}.${i}`:n}function Mm(e,t,n,r,o){let{label:i,rect:a,style:s,el:c,tag:l}=e,u=Math.round(a.width),d=Math.round(a.height),f=Math.round(a.left),m=Math.round(a.top+o),p=[],g=Bs(c)||l==="input"||l==="textarea";if(g){p.push(s.fontSize);let b=Rm(s.fontFamily);b&&p.push(`"${b}"`);let w=s.fontWeight;w!=="400"&&w!=="normal"&&p.push(w),p.push(co(s.color));let S=co(s.backgroundColor);S&&S!=="transparent"&&p.push(`on ${S}`)}else if(!(l==="img"||l==="svg"||l==="canvas"||l==="video")){let b=co(s.backgroundColor);b&&b!=="transparent"&&p.push(`bg: ${b}`)}let h=p.length>0?` \u2014 ${p.join(" ")}`:"";t.push(`${i}${h}`);let y=[];if(y.push(`${u} \xD7 ${d}`),y.push(`at (${f}, ${m})`),y.push(`${(u/n*100).toFixed(1)}% vw`),(l==="img"||l==="svg"||l==="canvas"||l==="video")&&u>0&&d>0){let b=_m(u,d);y.push(`aspect: ${b}`)}if(g){let b=km(c,s);b&&(y.push(`${b.lines} line${b.lines!==1?"s":""}`),b.capacity!==null&&y.push(`(line-height: ${b.lineHeight}, capacity: ${b.capacity.toFixed(1)})`))}t.push(` ${y.join(", ")}`);let v=Tm(c);v&&t.push(` ${v}`),t.push("")}function km(e,t){let n=Hs(e);if(!n||!n.textContent?.trim())return null;try{let r=document.createRange();r.selectNodeContents(n.parentElement||e);let o=r.getClientRects();if(o.length===0)return null;let i=o.length,a=t.lineHeight,s=parseFloat(a),c=null;return!isNaN(s)&&s>0&&(c=e.clientHeight/s),{lines:i,lineHeight:isNaN(s)?a:`${Math.round(s)}px`,capacity:c}}catch{return null}}function Hs(e){for(let t of Array.from(e.childNodes)){if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim())return t;if(t.nodeType===Node.ELEMENT_NODE){let n=Hs(t);if(n)return n}}return null}function Tm(e){let t=e,n=t.scrollWidth,r=t.scrollHeight,o=t.clientWidth,i=t.clientHeight;if(n<=o&&r<=i)return null;let a=getComputedStyle(e),s=a.overflowX,c=a.overflowY,l=a.textOverflow,u=[];if(n>o){let d=Math.round((n-o)/n*100),f=l==="ellipsis"?"ellipsis":s==="hidden"?"hidden":"scroll";u.push(`container: ${o}px, content: ${n}px wide, overflow: ${f} (${d}% hidden)`)}if(r>i&&c!=="visible"){let d=Math.round((r-i)/r*100),f=c==="hidden"?"hidden":"scroll";u.push(`container: ${i}px, content: ${r}px tall, overflow: ${f} (${d}% hidden)`)}return u.length>0?u.join("; "):null}function Lm(e){let t=[],n=new Map;for(let r of e){let o=r.el.parentElement,i=n.get(o)||[];i.push(r),n.set(o,i)}for(let r of n.values())if(!(r.length<2))for(let o=0;o<r.length;o++)for(let i=o+1;i<r.length;i++){let a=r[o].rect,s=r[i].rect,c=Math.min(a.bottom,s.bottom)-Math.max(a.top,s.top),l=Math.min(a.right,s.right)-Math.max(a.left,s.left);if(c>2&&l>2){let u=c<l?"vertical":"horizontal",d=Math.round(Math.min(c,l));t.push({a:r[o].label,b:r[i].label,overlapPx:d,axis:u})}}return t.slice(0,5)}function Nm(e){if(e.length===0)return[];let t=[],n=0;for(;n<e.length;){let r=e[n],o=r.el.parentElement,i=ye(r.el);if(i&&o){let a=n+1;for(;a<e.length&&e[a].el.parentElement===o&&ye(e[a].el)===i;)a++;let s=a-n;if(s>=4){let c=e.slice(n,a),l=Math.round(c.reduce((m,p)=>m+p.rect.width,0)/s),u=Math.round(c.reduce((m,p)=>m+p.rect.height,0)/s),d=Se(c[0].el),f=Se(c[s-1].el);t.push({count:s,role:i,avgWidth:l,avgHeight:u,firstName:d.length>40?d.slice(0,39)+"\u2026":d,lastName:f.length>40?f.slice(0,39)+"\u2026":f}),n=a;continue}}t.push(r),n++}return t}function co(e){if(!e||e==="transparent"||e==="rgba(0, 0, 0, 0)")return"transparent";let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(!t)return e;let n=parseInt(t[1]),r=parseInt(t[2]),o=parseInt(t[3]),i=t[4]!==void 0?parseFloat(t[4]):1;return i<1?`rgba(${n},${r},${o},${i})`:"#"+[n,r,o].map(a=>a.toString(16).padStart(2,"0")).join("")}function Rm(e){let t=e.split(",").map(o=>o.trim().replace(/^["']|["']$/g,"")),n=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","-apple-system","BlinkMacSystemFont"]);return t.find(o=>!n.has(o))||""}function _m(e,t){let n=Fm(e,t),r=e/n,o=t/n;return r>20||o>20?`${(e/t).toFixed(2)}:1`:`${r}:${o}`}function Fm(e,t){for(;t;)[e,t]=[t,e%t];return e}window.__MINDSTUDIO_BROWSER_AGENT__||(window.__MINDSTUDIO_BROWSER_AGENT__={takeSnapshot:Ue,takeSnapshotSync:Wt,getRefMap:He,executeSteps:Et,resolveElement:xe,computeStyleMap:Ps,captureWithNotes:Nn,enterNotesMode:Ln,exitNotesMode:Ot},go(),Co(),So(),xo(),Eo(),Io(),qi(),ws(),vs(),Jo(),Ho(),xs(),ms(),Rs(),window.parent!==window&&window.parent.postMessage({channel:"mindstudio-browser-agent",command:"ready"},"*"));return el(Om);})();
332
332
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/browser-agent",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "description": "Browser-side agent for MindStudio dev previews — captures logs, provides DOM snapshots, and enables remote interaction.",
5
5
  "main": "dist/index.js",
6
6
  "files": [