@mindstudio-ai/browser-agent 0.1.24 → 0.1.25

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 +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";var __MindStudioBrowserAgent=(()=>{var bt=Object.defineProperty;var To=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var _o=Object.prototype.hasOwnProperty;var Po=(e,t)=>{for(var n in t)bt(e,n,{get:t[n],enumerable:!0})},Fo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ro(t))!_o.call(e,i)&&i!==n&&bt(e,i,{get:()=>t[i],enumerable:!(r=To(t,i))||r.enumerable});return e};var Do=e=>Fo(bt({},"__esModule",{value:!0}),e);var Cs={};Po(Cs,{executeSteps:()=>pt,getRefMap:()=>we,resolveElement:()=>te,takeSnapshot:()=>be,takeSnapshotSync:()=>kt});var xt="__ms";function Io(){return{ws:{ws:null,clientId:null,reconnectDelay:1e3,closing:!1,busy:!1},cursor:{el:null,rippleEl:null,x:0,y:0,visible:!1,hasPosition:!1,hideTimer:null,forcedState:null,executing:!1,targetElement:null,trackingFrame:null,settledResolve:null},snapshot:{refCounter:0,refMap:new Map},networkIdle:{activeRequests:0},transport:{buffer:[],flushTimer:null,capturing:!1,captured:[],wsGetter:null},noteLayer:{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},messages:{handler:null},screenshot:{cameraEl:null,flashEl:null},fonts:{initialized:!1,observer:null},zoom:{pipMode:!1}}}function k(){let e=window;return e[xt]||(e[xt]=Io()),e[xt]}var on="/__mindstudio_dev__/logs",Oo=2e3;function an(e){k().transport.wsGetter=e}function ln(){let e=k().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",on,!0),r.setRequestHeader("Content-Type","application/json"),r.send(JSON.stringify(t))}catch{}}function Ho(){let e=k().transport;e.flushTimer||(e.flushTimer=setTimeout(()=>{e.flushTimer=null,ln()},Oo))}function Wo(){let e=k().transport;e.flushTimer&&(clearTimeout(e.flushTimer),e.flushTimer=null),ln()}function V(e){let t=k().transport;t.buffer.push(e),t.capturing&&t.captured.push(e),Ho()}function vt(e){let t=k().transport;t.buffer.push(e),t.capturing&&t.captured.push(e),Wo()}function St(){let e=k().transport;e.capturing=!0,e.captured=[]}function Et(){let e=k().transport;e.capturing=!1;let t=e.captured;return e.captured=[],t}function sn(){window.addEventListener("beforeunload",()=>{let e=k().transport;e.buffer.length>0&&navigator.sendBeacon&&navigator.sendBeacon(on,JSON.stringify(e.buffer))})}var Bo={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 ue(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 Bo[n]??null}function cn(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 ye(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 l=document.getElementById(s);return l?de(l):""}).filter(Boolean).join(" ");if(a)return a}let r=e.tagName.toLowerCase();if(r==="input"||r==="textarea"||r==="select"){let a=Uo(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 de(a)}let i=de(e);if(i)return i;let o=e.getAttribute("title");return o?o.trim():""}function de(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(jo(r))continue;let i=qo(r),o=de(r);o&&(i&&t.length>0&&t.push(" "),t.push(o),i&&t.push(" "))}return t.join("").replace(/\s+/g," ").trim()}function Uo(e){if(e.id){let n=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(n)return de(n)}let t=e.closest("label");if(t){let n=t.cloneNode(!0),r=n.querySelector("input, textarea, select");r&&r.remove();let i=n.textContent?.trim();if(i)return i}return null}function qo(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 jo(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 Ct(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 Ve(){k().networkIdle.activeRequests++}function Le(){let e=k().networkIdle;e.activeRequests=Math.max(0,e.activeRequests-1)}function un(e=5e3,t=200){return new Promise((n,r)=>{let i=Date.now()+e,o=null;function a(){if(Date.now()>i){o&&clearTimeout(o),n();return}k().networkIdle.activeRequests===0?o||(o=setTimeout(()=>{k().networkIdle.activeRequests===0?n():(o=null,a())},t)):(o&&(clearTimeout(o),o=null),setTimeout(a,50))}a()})}function we(){return k().snapshot.refMap}async function be(){return await un(),kt()}function kt(){let e=k().snapshot;e.refCounter=0,e.refMap=new Map;let t=document.body;if(!t)return"(empty page)";let n=dn(t);return Mt(n,0).trimEnd()}function Y(e){let t=ue(e),n=ye(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 i=e.tagName.toLowerCase();return e.id?`${i}#${e.id}`:i}function dn(e){if(Vo(e))return[];let t=ue(e),n=!t&&cn(e),r=t||(n?"clickable":null),i="";if(r){i=ye(e);let u=Ct(e,"::before"),d=Ct(e,"::after");(u||d)&&(i=[u,i,d].filter(Boolean).join(" ")),i.length>80&&(i=i.slice(0,77)+"...")}let o=Yo(e),a=t==="button"||t==="link"||t==="textbox"||t==="combobox"||t==="checkbox"||t==="radio"||t==="slider"||t==="tab"||t==="menuitem"||n,s=r&&i&&!a,l=null;if(a||s){let u=k().snapshot;u.refCounter++,l=`e${u.refCounter}`,u.refMap.set(l,e)}let c=zo(e);if(r){let u=c.length===0?"":Mt(c,0).trim();return[{tag:r,name:i,attrs:o,ref:l,children:u&&u===i?[]:c,element:e}]}if(c.length===0){let u=de(e);if(u)return[{tag:null,name:u.length>80?u.slice(0,77)+"...":u,attrs:[],ref:null,children:[],element:e}]}return c}function zo(e){let t=[];for(let n of Array.from(e.childNodes))n.nodeType===Node.ELEMENT_NODE&&t.push(...dn(n));return t}function Vo(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-overlay"||e.id==="__mindstudio-notes-cursor")return!0;try{let n=getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"&&n.position!=="static")return!0}catch{}return!1}function Yo(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 o=e;(o.type==="checkbox"||o.type==="radio")&&o.checked&&t.push("checked")}if(n==="input"){let o=e;o.type!=="checkbox"&&o.type!=="radio"&&o.type!=="hidden"&&o.type!=="submit"&&o.type!=="button"&&o.type!=="reset"&&(t.push(`value="${o.value}"`),o.placeholder&&t.push(`placeholder="${o.placeholder}"`))}if(n==="textarea"){let o=e;t.push(`value="${o.value}"`),o.placeholder&&t.push(`placeholder="${o.placeholder}"`)}if(n==="select"){let o=e,a=o.options[o.selectedIndex];a&&t.push(`value="${a.text}"`)}let r=n.match(/^h([1-6])$/);r&&t.push(`level=${r[1]}`);let i=e.getAttribute("aria-expanded");return i==="true"&&t.push("expanded"),i==="false"&&t.push("collapsed"),e.getAttribute("aria-selected")==="true"&&t.push("selected"),e.getAttribute("aria-pressed")==="true"&&t.push("pressed"),t}function Mt(e,t){let n="";for(let r of e)n+=Xo(r,t);return n}function Xo(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 i="";r.length>0&&(i+=`${n}${r.join(" ")}
2
- `);let o=r.length>0?t+1:t;return i+=Mt(e.children,o),i}function fn(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 W(e){return new Promise(t=>setTimeout(t,e))}var Go=["log","info","warn","error","debug"];function mn(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of Go){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),V({type:"console",level:e,args:n.map(fn),url:location.href})}}}}function pn(){window.addEventListener("error",e=>{vt({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||{};vt({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})})}function hn(){if(!window.fetch||window.fetch.__ms_patched)return;let e=window.fetch;window.fetch=function(t,n){let r=(n?.method||"GET").toUpperCase(),i=typeof t=="string"?t:t instanceof URL?t.href:t.url||String(t);if(i.includes("/__mindstudio_dev__/"))return e.apply(this,[t,n]);let o=Date.now();return Ve(),e.apply(this,[t,n]).then(a=>{Le();let s={type:"network",method:r,url:i,status:a.status,statusText:a.statusText,duration:Date.now()-o,ok:a.ok};if(a.ok)V(s);else try{a.clone().text().then(l=>{s.body=l.slice(0,1e3),V(s)}).catch(()=>V(s))}catch{V(s)}return a},a=>{throw Le(),V({type:"network",method:r,url:i,error:a.message||String(a),duration:Date.now()-o,ok:!1}),a})},window.fetch.__ms_patched=!0}function gn(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target,n=(t?.textContent||"").trim().slice(0,100);V({type:"interaction",event:"click",target:Y(t),text:n,url:location.href})},!0))}function yn(){if(XMLHttpRequest.prototype.open.__ms_patched)return;let e=window.XMLHttpRequest,t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,i,...o){return this.__ms_method=r.toUpperCase(),this.__ms_url=String(i),t.apply(this,[r,i,...o])},e.prototype.send=function(r){let i=this.__ms_method||"GET",o=this.__ms_url||"";if(o.includes("/__mindstudio_dev__/"))return n.apply(this,[r]);let a=Date.now();return Ve(),this.addEventListener("loadend",function(){Le(),V({type:"network",method:i,url:o,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"})}),n.apply(this,[r])},XMLHttpRequest.prototype.open.__ms_patched=!0}function te(e){let t=null;if(e.ref){let n=we(),r=n.get(e.ref);if(r&&r.isConnected)if(ee(r))t={element:r,matched:`${Y(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${At(r)}). It may be inside a closed dialog or collapsed section.`);else{let i=[...n.entries()].filter(([,o])=>o.isConnected&&ee(o)).slice(0,10).map(([o,a])=>`${Y(a)} [ref=${o}]`).join(", ");throw new Error(`Element [ref=${e.ref}] not found. `+(i?`Available refs: ${i}`:"No refs available \u2014 take a snapshot first."))}}if(!t&&(e.text||e.role&&e.text)){let n=e.text,r=e.role,i=wn(n,r);if(i.length===0){let o=wn(n,r,!0);if(o.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${At(o[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=bn(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(i.length>1){let o=i.filter(xn),a=o.length===1?o[0]:i[0];t={element:a,matched:Y(a)}}else t={element:i[0],matched:Y(i[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=Ko(n);if(r.length===0){let i=bn(n);throw new Error(`No visible element with role "${n}" found. `+(i?`Visible ${n}s: ${i}`:"The page may still be loading \u2014 try a wait command first."))}t={element:r[0],matched:Y(r[0])}}if(!t&&e.label){let n=e.label,r=Jo(n);if(!r){let i=[...document.querySelectorAll("label")].filter(ee).map(o=>`"${(o.textContent||"").trim().slice(0,40)}"`).slice(0,8).join(", ");throw new Error(`No input found with label "${n}". `+(i?`Visible labels: ${i}`:"No labels found on the page."))}t={element:r,matched:`${Y(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(!ee(r))throw new Error(`Found element for selector "${n}" but it is hidden (${At(r)}).`);t={element:r,matched:`${Y(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function wn(e,t,n=!1){let r=[],i=e.toLowerCase();for(let o of document.querySelectorAll("*")){if(!n&&!ee(o)||n&&!o.isConnected||t&&ue(o)!==t)continue;if(ye(o).toLowerCase().includes(i)){r.push(o);continue}o.children.length||(o.textContent||"").trim().toLowerCase().includes(i)&&r.push(o)}return r}function Ko(e){let t=[];for(let n of document.querySelectorAll("*"))ee(n)&&ue(n)===e&&t.push(n);return t}function Jo(e){let t=e.toLowerCase();for(let n of document.querySelectorAll("label")){if(!(n.textContent||"").trim().toLowerCase().includes(t))continue;let i=n.getAttribute("for");if(i){let a=document.getElementById(i);if(a&&ee(a))return a}let o=n.querySelector("input, textarea, select");if(o&&ee(o))return o}return null}function ee(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 xn(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 At(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 bn(e){let t=[];for(let n of document.querySelectorAll("*"))if(ee(n)&&(e?ue(n)===e&&t.push(n):xn(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${ye(n).slice(0,40)||Y(n)}"`).join(", ")}function $t(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,i={bubbles:!0,cancelable:!0,clientX:n,clientY:r,button:0};e.dispatchEvent(new PointerEvent("pointerdown",{...i,pointerId:1})),e.dispatchEvent(new MouseEvent("mousedown",i)),e instanceof HTMLElement&&e.focus(),e.dispatchEvent(new PointerEvent("pointerup",{...i,pointerId:1})),e.dispatchEvent(new MouseEvent("mouseup",i)),e.dispatchEvent(new MouseEvent("click",i))}var Zo=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,Qo=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function En(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),$t(e),n.clear&&(vn(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})));for(let r=0;r<t.length;r++){let i=t[r];e.dispatchEvent(new KeyboardEvent("keydown",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keypress",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),vn(e,e.value+i),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),await W(ei(i))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function ei(e){let t=Math.random()*50-25;return e===" "?120+t:/[.,!?;:\-]/.test(e)?140+t:/[A-Z]/.test(e)?115+t:85+t}function vn(e,t){let n=e instanceof HTMLTextAreaElement?Qo:Zo;n?n.call(e,t):e.value=t}async function Cn(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...te(e),elapsed:Date.now()-n}}catch{await W(100)}let i=e.text?`"${e.text}"`:e.role?`role "${e.role}"`:e.selector?`selector "${e.selector}"`:"element";throw new Error(`Timed out waiting for ${i} after ${t}ms`)}var Sn=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function kn(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("select command requires a <select> element");let n=t.toLowerCase(),r=null;for(let i of e.options)if(i.text.toLowerCase().includes(n)||i.value.toLowerCase()===n||i.label.toLowerCase().includes(n)){r=i;break}if(!r){let i=[...e.options].map(o=>`"${o.text}"`).join(", ");throw new Error(`No option matching "${t}" in select. Available options: ${i}`)}return Sn?Sn.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 Mn(e){try{let n=!/\b(return|;|\{)\b/.test(e.trim())?`return (${e})`:e,i=new Function(n)();return i instanceof Promise?await i:i}catch(t){throw new Error(`evaluate failed: ${t instanceof Error?t.message:String(t)}`)}}var ni=Object.defineProperty,z=(e,t)=>()=>(e&&(t=e(e=0)),t),Fe=(e,t)=>{for(var n in t)ni(e,n,{get:t[n],enumerable:!0})};function ri(e){if(e===!0)return"soft";if(e===!1)return"disabled";if(typeof e=="string"){let t=e.toLowerCase().trim();if(t==="auto")return"auto";if(t==="full")return"full";if(t==="soft"||t==="disabled")return t}return"soft"}function oi(e="soft"){switch(C.session.__counterEpoch=(C.session.__counterEpoch||0)+1,e){case"auto":{C.session.styleMap=new Map,C.session.nodeMap=new Map;return}case"soft":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap,C.computedStyle=new WeakMap,C.baseStyle=new X(50),C.defaultStyle=new X(30),C.image=new X(100),C.background=new X(100),C.resource=new X(150),C.font=new Set;return}default:{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}}}var X,C,K=z(()=>{X=class extends Map{constructor(e=100,...t){super(...t),this._maxSize=e}set(e,t){if(this.size>=this._maxSize&&!this.has(e)){let n=this.keys().next().value;n!==void 0&&this.delete(n)}return super.set(e,t)}},C={image:new X(100),background:new X(100),resource:new X(150),defaultStyle:new X(30),baseStyle:new X(50),computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function jt(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith("#")?null:n}function ii(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==6?`matrix(${r})`:(i[4]="0",i[5]="0",`matrix(${i.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==16?`matrix3d(${r})`:(i[12]="0",i[13]="0",`matrix3d(${i.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function et(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function ai(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let n=t||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(e,n).href}catch{return e}}var nt=z(()=>{});function li(e="[snapDOM]",{ttlMs:t=5*6e4,maxEntries:n=12}={}){let r=new Map,i=0;function o(a,s,l){if(i>=n)return;let c=Date.now();(r.get(s)||0)>c||(r.set(s,c+t),i++,a==="warn"&&console&&console.warn?console.warn(`${e} ${l}`):console&&console.error&&console.error(`${e} ${l}`))}return{warnOnce(a,s){o("warn",a,s)},errorOnce(a,s){o("error",a,s)},reset(){r.clear(),i=0}}}function si(e){return/^data:|^blob:|^about:blank$/i.test(e)}function ci(e,t){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=t.includes("{url}")?t.split("{url}")[0]:t,i=new URL(r||".",n),o=new URL(e,n);if(o.origin===i.origin)return!0;let a=o.searchParams;if(a&&(a.has("url")||a.has("target")))return!0}catch{}return!1}function ui(e,t){if(!t||si(e)||ci(e,t))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(e,n);return typeof location<"u"?r.origin!==location.origin:!0}catch{return!!t}}function di(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",et(e)).replace("{url}",encodeURIComponent(e));if(/[?&]url=?$/.test(t))return`${t}${encodeURIComponent(e)}`;if(t.endsWith("?"))return`${t}url=${encodeURIComponent(e)}`;if(t.endsWith("/"))return`${t}${et(e)}`;let n=t.includes("?")?"&":"?";return`${t}${n}url=${encodeURIComponent(e)}`}function An(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.readAsDataURL(e)})}function fi(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function G(e,t={}){let n=t.as??"blob",r=t.timeout??3e3,i=t.useProxy||"",o=t.errorTTL??8e3,a=t.headers||{},s=!!t.silent;if(/^data:/i.test(e))try{if(n==="text")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(";")[0]||""};let[,m="",y=""]=String(e).match(/^data:([^,]*),(.*)$/)||[],x=/;base64/i.test(m)?atob(y):decodeURIComponent(y),b=new Uint8Array([...x].map(E=>E.charCodeAt(0))),w=new Blob([b],{type:(m||"").split(";")[0]||""});return{ok:!0,data:w,status:200,url:e,fromCache:!1,mime:w.type||""}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(e))try{let m=await fetch(e);if(!m.ok)return{ok:!1,data:null,status:m.status,url:e,fromCache:!1,reason:"http_error"};let y=await m.blob(),x=y.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await An(y),status:m.status,url:e,fromCache:!1,mime:x}:n==="text"?{ok:!0,data:await y.text(),status:m.status,url:e,fromCache:!1,mime:x}:{ok:!0,data:y,status:m.status,url:e,fromCache:!1,mime:x}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(e))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:e,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:e,fromCache:!1};let l=fi(e,{as:n,timeout:r,useProxy:i,errorTTL:o}),c=Te.get(l);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Te.delete(l);let u=Xe.get(l);if(u)return u;let d=ui(e,i)?di(e,i):e,f=t.credentials;if(!f)try{let m=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(e,m);f=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{f="omit"}let p=new AbortController,g=setTimeout(()=>p.abort("timeout"),r),h=(async()=>{try{let m=await fetch(d,{signal:p.signal,credentials:f,headers:a});if(!m.ok){let b={ok:!1,data:null,status:m.status,url:d,fromCache:!1,reason:"http_error"};if(o>0&&Te.set(l,{until:Date.now()+o,result:b}),!s){let w=`${m.status} ${m.statusText||""}`.trim();Tt.warnOnce(`http:${m.status}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,`HTTP error ${w} while fetching ${n} ${e}`)}return t.onError&&t.onError(b),b}if(n==="text")return{ok:!0,data:await m.text(),status:m.status,url:d,fromCache:!1};let y=await m.blob(),x=y.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await An(y),status:m.status,url:d,fromCache:!1,mime:x}:{ok:!0,data:y,status:m.status,url:d,fromCache:!1,mime:x}}catch(m){let y=m&&typeof m=="object"&&"name"in m&&m.name==="AbortError"?String(m.message||"").includes("timeout")?"timeout":"abort":"network",x={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:y};if(!/^blob:/i.test(e)&&o>0&&Te.set(l,{until:Date.now()+o,result:x}),!s){let b=`${y}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,w=y==="timeout"?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${e}`:y==="abort"?`Request aborted while fetching ${n} ${e}`:`Network/CORS issue while fetching ${n} ${e}. A proxy may be required`;Tt.errorOnce(b,w)}return t.onError&&t.onError(x),x}finally{clearTimeout(g),Xe.delete(l)}})();return Xe.set(l,h),h}var Tt,Xe,Te,ke=z(()=>{nt(),Tt=li("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Xe=new Map,Te=new Map});async function Jn(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let n=jt(e);if(!n)return e;let r=ai(n),i=et(r);if(C.background.has(i)){let o=C.background.get(i);return o?`url("${o}")`:"none"}try{let o=await G(i,{as:"dataURL",useProxy:t.useProxy});return o.ok?(C.background.set(i,o.data),`url("${o.data}")`):(C.background.set(i,null),"none")}catch{return C.background.set(i,null),"none"}}var mi=z(()=>{K(),nt(),ke()});function pi(e){if(e=String(e).toLowerCase(),Vt.has(e)){let o={};return C.defaultStyle.set(e,o),o}if(C.defaultStyle.has(e))return C.defaultStyle.get(e);let t=document.getElementById("snapdom-sandbox");t||(t=document.createElement("div"),t.id="snapdom-sandbox",t.setAttribute("data-snapdom-sandbox","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="0px",t.style.height="0px",t.style.overflow="hidden",document.body.appendChild(t));let n=document.createElement(e);n.style.all="initial",t.appendChild(n);let r=getComputedStyle(n),i={};for(let o of r){if(zt(o))continue;let a=r.getPropertyValue(o);i[o]=a}return t.removeChild(n),C.defaultStyle.set(e,i),i}function zt(e){let t=String(e).toLowerCase();return!!(tr.has(t)||er.test(t)||Qn.test(t))}function Rt(e,t){if(t=String(t||"").toLowerCase(),Vt.has(t))return"";let n=[],r=pi(t),i=(e.display||"").toLowerCase()==="inline"||new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]).has(t);for(let[o,a]of Object.entries(e)){if(zt(o)||i&&(o==="width"||o==="min-width"||o==="max-width"))continue;let s=r[o];a&&a!==s&&n.push(`${o}:${a}`)}return n.sort(),n.join(";")}function hi(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(n=>t.add(n.tagName.toLowerCase())),Array.from(t))}function gi(e){let t=new Map;for(let r of e){let i=C.defaultStyle.get(r);if(!i)continue;let o=Object.entries(i).map(([a,s])=>`${a}:${s};`).sort().join("");o&&(t.has(o)||t.set(o,[]),t.get(o).push(r))}let n="";for(let[r,i]of t.entries())n+=`${i.join(",")} { ${r} }
2
+ `);let o=r.length>0?t+1:t;return i+=Mt(e.children,o),i}function fn(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 W(e){return new Promise(t=>setTimeout(t,e))}var Go=["log","info","warn","error","debug"];function mn(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of Go){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),V({type:"console",level:e,args:n.map(fn),url:location.href})}}}}function pn(){window.addEventListener("error",e=>{vt({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||{};vt({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})})}function hn(){if(!window.fetch||window.fetch.__ms_patched)return;let e=window.fetch;window.fetch=function(t,n){let r=(n?.method||"GET").toUpperCase(),i=typeof t=="string"?t:t instanceof URL?t.href:t.url||String(t);if(i.includes("/__mindstudio_dev__/"))return e.apply(this,[t,n]);let o=Date.now();return Ve(),e.apply(this,[t,n]).then(a=>{Le();let s={type:"network",method:r,url:i,status:a.status,statusText:a.statusText,duration:Date.now()-o,ok:a.ok};if(a.ok)V(s);else try{a.clone().text().then(l=>{s.body=l.slice(0,1e3),V(s)}).catch(()=>V(s))}catch{V(s)}return a},a=>{throw Le(),V({type:"network",method:r,url:i,error:a.message||String(a),duration:Date.now()-o,ok:!1}),a})},window.fetch.__ms_patched=!0}function gn(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target,n=(t?.textContent||"").trim().slice(0,100);V({type:"interaction",event:"click",target:Y(t),text:n,url:location.href})},!0))}function yn(){if(XMLHttpRequest.prototype.open.__ms_patched)return;let e=window.XMLHttpRequest,t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,i,...o){return this.__ms_method=r.toUpperCase(),this.__ms_url=String(i),t.apply(this,[r,i,...o])},e.prototype.send=function(r){let i=this.__ms_method||"GET",o=this.__ms_url||"";if(o.includes("/__mindstudio_dev__/"))return n.apply(this,[r]);let a=Date.now();return Ve(),this.addEventListener("loadend",function(){Le(),V({type:"network",method:i,url:o,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"})}),n.apply(this,[r])},XMLHttpRequest.prototype.open.__ms_patched=!0}function te(e){let t=null;if(e.ref){let n=we(),r=n.get(e.ref);if(r&&r.isConnected)if(ee(r))t={element:r,matched:`${Y(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${At(r)}). It may be inside a closed dialog or collapsed section.`);else{let i=[...n.entries()].filter(([,o])=>o.isConnected&&ee(o)).slice(0,10).map(([o,a])=>`${Y(a)} [ref=${o}]`).join(", ");throw new Error(`Element [ref=${e.ref}] not found. `+(i?`Available refs: ${i}`:"No refs available \u2014 take a snapshot first."))}}if(!t&&(e.text||e.role&&e.text)){let n=e.text,r=e.role,i=wn(n,r);if(i.length===0){let o=wn(n,r,!0);if(o.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${At(o[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=bn(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(i.length>1){let o=i.filter(xn),a=o.length===1?o[0]:i[0];t={element:a,matched:Y(a)}}else t={element:i[0],matched:Y(i[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=Ko(n);if(r.length===0){let i=bn(n);throw new Error(`No visible element with role "${n}" found. `+(i?`Visible ${n}s: ${i}`:"The page may still be loading \u2014 try a wait command first."))}t={element:r[0],matched:Y(r[0])}}if(!t&&e.label){let n=e.label,r=Jo(n);if(!r){let i=[...document.querySelectorAll("label")].filter(ee).map(o=>`"${(o.textContent||"").trim().slice(0,40)}"`).slice(0,8).join(", ");throw new Error(`No input found with label "${n}". `+(i?`Visible labels: ${i}`:"No labels found on the page."))}t={element:r,matched:`${Y(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(!ee(r))throw new Error(`Found element for selector "${n}" but it is hidden (${At(r)}).`);t={element:r,matched:`${Y(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function wn(e,t,n=!1){let r=[],i=e.toLowerCase();for(let o of document.querySelectorAll("*")){if(!n&&!ee(o)||n&&!o.isConnected||t&&ue(o)!==t)continue;if(ye(o).toLowerCase().includes(i)){r.push(o);continue}o.children.length||(o.textContent||"").trim().toLowerCase().includes(i)&&r.push(o)}return r}function Ko(e){let t=[];for(let n of document.querySelectorAll("*"))ee(n)&&ue(n)===e&&t.push(n);return t}function Jo(e){let t=e.toLowerCase();for(let n of document.querySelectorAll("label")){if(!(n.textContent||"").trim().toLowerCase().includes(t))continue;let i=n.getAttribute("for");if(i){let a=document.getElementById(i);if(a&&ee(a))return a}let o=n.querySelector("input, textarea, select");if(o&&ee(o))return o}return null}function ee(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 xn(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 At(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 bn(e){let t=[];for(let n of document.querySelectorAll("*"))if(ee(n)&&(e?ue(n)===e&&t.push(n):xn(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${ye(n).slice(0,40)||Y(n)}"`).join(", ")}function $t(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,i={bubbles:!0,cancelable:!0,clientX:n,clientY:r,button:0};e.dispatchEvent(new PointerEvent("pointerdown",{...i,pointerId:1})),e.dispatchEvent(new MouseEvent("mousedown",i)),e instanceof HTMLElement&&e.focus(),e.dispatchEvent(new PointerEvent("pointerup",{...i,pointerId:1})),e.dispatchEvent(new MouseEvent("mouseup",i)),e.dispatchEvent(new MouseEvent("click",i))}var Zo=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,Qo=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function En(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),$t(e),n.clear&&(vn(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})));for(let r=0;r<t.length;r++){let i=t[r];e.dispatchEvent(new KeyboardEvent("keydown",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keypress",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),vn(e,e.value+i),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{key:i,code:`Key${i.toUpperCase()}`,bubbles:!0})),await W(ei(i,t.length))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function ei(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 i=Math.max(.1,20/t);return r*i}function vn(e,t){let n=e instanceof HTMLTextAreaElement?Qo:Zo;n?n.call(e,t):e.value=t}async function Cn(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...te(e),elapsed:Date.now()-n}}catch{await W(100)}let i=e.text?`"${e.text}"`:e.role?`role "${e.role}"`:e.selector?`selector "${e.selector}"`:"element";throw new Error(`Timed out waiting for ${i} after ${t}ms`)}var Sn=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function kn(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("select command requires a <select> element");let n=t.toLowerCase(),r=null;for(let i of e.options)if(i.text.toLowerCase().includes(n)||i.value.toLowerCase()===n||i.label.toLowerCase().includes(n)){r=i;break}if(!r){let i=[...e.options].map(o=>`"${o.text}"`).join(", ");throw new Error(`No option matching "${t}" in select. Available options: ${i}`)}return Sn?Sn.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 Mn(e){try{let n=!/\b(return|;|\{)\b/.test(e.trim())?`return (${e})`:e,i=new Function(n)();return i instanceof Promise?await i:i}catch(t){throw new Error(`evaluate failed: ${t instanceof Error?t.message:String(t)}`)}}var ni=Object.defineProperty,z=(e,t)=>()=>(e&&(t=e(e=0)),t),Fe=(e,t)=>{for(var n in t)ni(e,n,{get:t[n],enumerable:!0})};function ri(e){if(e===!0)return"soft";if(e===!1)return"disabled";if(typeof e=="string"){let t=e.toLowerCase().trim();if(t==="auto")return"auto";if(t==="full")return"full";if(t==="soft"||t==="disabled")return t}return"soft"}function oi(e="soft"){switch(C.session.__counterEpoch=(C.session.__counterEpoch||0)+1,e){case"auto":{C.session.styleMap=new Map,C.session.nodeMap=new Map;return}case"soft":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap,C.computedStyle=new WeakMap,C.baseStyle=new X(50),C.defaultStyle=new X(30),C.image=new X(100),C.background=new X(100),C.resource=new X(150),C.font=new Set;return}default:{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}}}var X,C,K=z(()=>{X=class extends Map{constructor(e=100,...t){super(...t),this._maxSize=e}set(e,t){if(this.size>=this._maxSize&&!this.has(e)){let n=this.keys().next().value;n!==void 0&&this.delete(n)}return super.set(e,t)}},C={image:new X(100),background:new X(100),resource:new X(150),defaultStyle:new X(30),baseStyle:new X(50),computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function jt(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith("#")?null:n}function ii(e){if(!e||e==="none")return"";let t=e.replace(/translate[XY]?\([^)]*\)/g,"");return t=t.replace(/matrix\(([^)]+)\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==6?`matrix(${r})`:(i[4]="0",i[5]="0",`matrix(${i.join(", ")})`)}),t=t.replace(/matrix3d\(([^)]+)\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==16?`matrix3d(${r})`:(i[12]="0",i[13]="0",`matrix3d(${i.join(", ")})`)}),t.trim().replace(/\s{2,}/g," ")}function et(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function ai(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let n=t||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(e,n).href}catch{return e}}var nt=z(()=>{});function li(e="[snapDOM]",{ttlMs:t=5*6e4,maxEntries:n=12}={}){let r=new Map,i=0;function o(a,s,l){if(i>=n)return;let c=Date.now();(r.get(s)||0)>c||(r.set(s,c+t),i++,a==="warn"&&console&&console.warn?console.warn(`${e} ${l}`):console&&console.error&&console.error(`${e} ${l}`))}return{warnOnce(a,s){o("warn",a,s)},errorOnce(a,s){o("error",a,s)},reset(){r.clear(),i=0}}}function si(e){return/^data:|^blob:|^about:blank$/i.test(e)}function ci(e,t){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=t.includes("{url}")?t.split("{url}")[0]:t,i=new URL(r||".",n),o=new URL(e,n);if(o.origin===i.origin)return!0;let a=o.searchParams;if(a&&(a.has("url")||a.has("target")))return!0}catch{}return!1}function ui(e,t){if(!t||si(e)||ci(e,t))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(e,n);return typeof location<"u"?r.origin!==location.origin:!0}catch{return!!t}}function di(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",et(e)).replace("{url}",encodeURIComponent(e));if(/[?&]url=?$/.test(t))return`${t}${encodeURIComponent(e)}`;if(t.endsWith("?"))return`${t}url=${encodeURIComponent(e)}`;if(t.endsWith("/"))return`${t}${et(e)}`;let n=t.includes("?")?"&":"?";return`${t}${n}url=${encodeURIComponent(e)}`}function An(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.readAsDataURL(e)})}function fi(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function G(e,t={}){let n=t.as??"blob",r=t.timeout??3e3,i=t.useProxy||"",o=t.errorTTL??8e3,a=t.headers||{},s=!!t.silent;if(/^data:/i.test(e))try{if(n==="text")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(";")[0]||""};let[,m="",y=""]=String(e).match(/^data:([^,]*),(.*)$/)||[],x=/;base64/i.test(m)?atob(y):decodeURIComponent(y),b=new Uint8Array([...x].map(E=>E.charCodeAt(0))),w=new Blob([b],{type:(m||"").split(";")[0]||""});return{ok:!0,data:w,status:200,url:e,fromCache:!1,mime:w.type||""}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(e))try{let m=await fetch(e);if(!m.ok)return{ok:!1,data:null,status:m.status,url:e,fromCache:!1,reason:"http_error"};let y=await m.blob(),x=y.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await An(y),status:m.status,url:e,fromCache:!1,mime:x}:n==="text"?{ok:!0,data:await y.text(),status:m.status,url:e,fromCache:!1,mime:x}:{ok:!0,data:y,status:m.status,url:e,fromCache:!1,mime:x}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(e))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:e,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:e,fromCache:!1};let l=fi(e,{as:n,timeout:r,useProxy:i,errorTTL:o}),c=Te.get(l);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Te.delete(l);let u=Xe.get(l);if(u)return u;let d=ui(e,i)?di(e,i):e,f=t.credentials;if(!f)try{let m=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(e,m);f=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{f="omit"}let p=new AbortController,g=setTimeout(()=>p.abort("timeout"),r),h=(async()=>{try{let m=await fetch(d,{signal:p.signal,credentials:f,headers:a});if(!m.ok){let b={ok:!1,data:null,status:m.status,url:d,fromCache:!1,reason:"http_error"};if(o>0&&Te.set(l,{until:Date.now()+o,result:b}),!s){let w=`${m.status} ${m.statusText||""}`.trim();Tt.warnOnce(`http:${m.status}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,`HTTP error ${w} while fetching ${n} ${e}`)}return t.onError&&t.onError(b),b}if(n==="text")return{ok:!0,data:await m.text(),status:m.status,url:d,fromCache:!1};let y=await m.blob(),x=y.type||m.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await An(y),status:m.status,url:d,fromCache:!1,mime:x}:{ok:!0,data:y,status:m.status,url:d,fromCache:!1,mime:x}}catch(m){let y=m&&typeof m=="object"&&"name"in m&&m.name==="AbortError"?String(m.message||"").includes("timeout")?"timeout":"abort":"network",x={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:y};if(!/^blob:/i.test(e)&&o>0&&Te.set(l,{until:Date.now()+o,result:x}),!s){let b=`${y}:${n}:${new URL(e,location?.href??"http://localhost/").origin}`,w=y==="timeout"?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${e}`:y==="abort"?`Request aborted while fetching ${n} ${e}`:`Network/CORS issue while fetching ${n} ${e}. A proxy may be required`;Tt.errorOnce(b,w)}return t.onError&&t.onError(x),x}finally{clearTimeout(g),Xe.delete(l)}})();return Xe.set(l,h),h}var Tt,Xe,Te,ke=z(()=>{nt(),Tt=li("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Xe=new Map,Te=new Map});async function Jn(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let n=jt(e);if(!n)return e;let r=ai(n),i=et(r);if(C.background.has(i)){let o=C.background.get(i);return o?`url("${o}")`:"none"}try{let o=await G(i,{as:"dataURL",useProxy:t.useProxy});return o.ok?(C.background.set(i,o.data),`url("${o.data}")`):(C.background.set(i,null),"none")}catch{return C.background.set(i,null),"none"}}var mi=z(()=>{K(),nt(),ke()});function pi(e){if(e=String(e).toLowerCase(),Vt.has(e)){let o={};return C.defaultStyle.set(e,o),o}if(C.defaultStyle.has(e))return C.defaultStyle.get(e);let t=document.getElementById("snapdom-sandbox");t||(t=document.createElement("div"),t.id="snapdom-sandbox",t.setAttribute("data-snapdom-sandbox","true"),t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="0px",t.style.height="0px",t.style.overflow="hidden",document.body.appendChild(t));let n=document.createElement(e);n.style.all="initial",t.appendChild(n);let r=getComputedStyle(n),i={};for(let o of r){if(zt(o))continue;let a=r.getPropertyValue(o);i[o]=a}return t.removeChild(n),C.defaultStyle.set(e,i),i}function zt(e){let t=String(e).toLowerCase();return!!(tr.has(t)||er.test(t)||Qn.test(t))}function Rt(e,t){if(t=String(t||"").toLowerCase(),Vt.has(t))return"";let n=[],r=pi(t),i=(e.display||"").toLowerCase()==="inline"||new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]).has(t);for(let[o,a]of Object.entries(e)){if(zt(o)||i&&(o==="width"||o==="min-width"||o==="max-width"))continue;let s=r[o];a&&a!==s&&n.push(`${o}:${a}`)}return n.sort(),n.join(";")}function hi(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll=="function"&&e.querySelectorAll("*").forEach(n=>t.add(n.tagName.toLowerCase())),Array.from(t))}function gi(e){let t=new Map;for(let r of e){let i=C.defaultStyle.get(r);if(!i)continue;let o=Object.entries(i).map(([a,s])=>`${a}:${s};`).sort().join("");o&&(t.has(o)||t.set(o,[]),t.get(o).push(r))}let n="";for(let[r,i]of t.entries())n+=`${i.join(",")} { ${r} }
3
3
  `;return n}function yi(e){let t=Array.from(new Set(e.values())).filter(Boolean).sort(),n=new Map,r=1;for(let i of t)n.set(i,`c${r++}`);return n}function wi(e){try{let t=e?.ownerDocument;if(!t)return typeof window<"u"?window:null;let n=t.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let r=0;r<window.frames.length;r++)try{if(window.frames[r]?.document===t)return window.frames[r]}catch{}}catch{}return typeof window<"u"?window:null}function oe(e,t=null){let n=()=>{let o={length:0,getPropertyValue:()=>"",item:()=>""};return o[Symbol.iterator]=function*(){},o};if(!(e instanceof Element)){let o=typeof window<"u"?window:null;if(o&&typeof o.getComputedStyle=="function")try{return o.getComputedStyle(e,t)||n()}catch{return n()}return n()}let r=C.computedStyle.get(e);r||(r=new Map,C.computedStyle.set(e,r));let i=r.get(t);if(!i){let o=wi(e),a=null;try{a=o&&typeof o.getComputedStyle=="function"?o.getComputedStyle(e,t):null}catch{}if(!a&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{e.ownerDocument===document&&(a=window.getComputedStyle(e,t))}catch{}i=a||n(),r.set(t,i)}return i}function $n(e){let t={};for(let n of e)t[n]=e.getPropertyValue(n);return t}function _t(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i];o==="("&&n++,o===")"&&n--,o===","&&n===0&&(t.push(e.slice(r,i).trim()),r=i+1)}return t.push(e.slice(r).trim()),t}var Zn,Vt,bi,Qn,er,tr,nr=z(()=>{K(),Zn=new Set(["meta","script","noscript","title","link","template"]),Vt=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),bi=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"],Qn=/(?:^|-)(animation|transition)(?:-|$)/i,er=/^(--.+|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,tr=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope"])});function Se(e,{fast:t=!1}={}){if(t)return e();"requestIdleCallback"in window?requestIdleCallback(e,{timeout:50}):setTimeout(e,1)}function xi(){if(typeof navigator>"u")return!1;if(navigator.userAgentData)return navigator.userAgentData.platform==="iOS";let e=navigator.userAgent||"",t=/iPhone|iPad|iPod/.test(e),n=navigator.maxTouchPoints>2&&/Macintosh/.test(e);return t||n}function fe(){if(typeof navigator>"u")return!1;let e=navigator.userAgent||"",t=e.toLowerCase(),n=t.includes("safari")&&!t.includes("chrome")&&!t.includes("crios")&&!t.includes("fxios")&&!t.includes("android"),r=/applewebkit/i.test(e),i=/mobile/i.test(e),o=!/safari/i.test(e),a=r&&i&&o,s=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(e),l=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(t),c=/ipad|iphone|ipod/.test(t)&&r;return n||a||s||l||c}function vi(){if(typeof navigator>"u")return!1;let e=(navigator.userAgent||"").toLowerCase();return e.includes("firefox")||e.includes("fxios")}var De=z(()=>{});function P(e,t,n){let r=e&&typeof e=="object"&&(e.options||e);r&&r.debug&&(n!==void 0?console.warn("[snapdom]",t,n):console.warn("[snapdom]",t))}var rr=z(()=>{}),J=z(()=>{mi(),nr(),De(),nt(),rr()}),or={};Fe(or,{toCanvas:()=>rt});function Si(e){return typeof e=="string"&&/^data:image\/svg\+xml/i.test(e)}function Ei(e){let t=e.indexOf(",");return t>=0?decodeURIComponent(e.slice(t+1)):""}function Ci(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function ki(e){let t=[],n="",r=0;for(let i=0;i<e.length;i++){let o=e[i];o==="("&&r++,o===")"&&(r=Math.max(0,r-1)),o===";"&&r===0?(t.push(n),n=""):n+=o}return n.trim()&&t.push(n),t.map(i=>i.trim()).filter(Boolean)}function Mi(e){let t=[],n="",r=0;for(let o=0;o<e.length;o++){let a=e[o];a==="("&&r++,a===")"&&(r=Math.max(0,r-1)),a===","&&r===0?(t.push(n.trim()),n=""):n+=a}n.trim()&&t.push(n.trim());let i=[];for(let o of t){if(/\binset\b/i.test(o))continue;let a=o.match(/-?\d+(?:\.\d+)?px/gi)||[],[s="0px",l="0px",c="0px"]=a,u=o.replace(/-?\d+(?:\.\d+)?px/gi,"").replace(/\binset\b/ig,"").trim().replace(/\s{2,}/g," "),d=!!u&&u!==",";i.push(`drop-shadow(${s} ${l} ${c}${d?` ${u}`:""})`)}return i.join(" ")}function ir(e){let t=ki(e),n=null,r=null,i=null,o=[];for(let s of t){let l=s.indexOf(":");if(l<0)continue;let c=s.slice(0,l).trim().toLowerCase(),u=s.slice(l+1).trim();c==="box-shadow"?i=u:c==="filter"?n=u:c==="-webkit-filter"?r=u:o.push([c,u])}if(i){let s=Mi(i);s&&(n=n?`${n} ${s}`:s,r=r?`${r} ${s}`:s)}let a=[...o];return n&&a.push(["filter",n]),r&&a.push(["-webkit-filter",r]),a.map(([s,l])=>`${s}:${l}`).join(";")}function Ai(e){return e.replace(/([^{}]+)\{([^}]*)\}/g,(t,n,r)=>`${n}{${ir(r)}}`)}function $i(e){return e=e.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(t,n)=>t.replace(n,Ai(n))),e=e.replace(/style=(['"])([\s\S]*?)\1/gi,(t,n,r)=>`style=${n}${ir(r)}${n}`),e}function Li(e){if(!fe()||!Si(e))return e;try{let t=Ei(e),n=$i(t);return Ci(n)}catch{return e}}async function rt(e,t){let{width:n,height:r,scale:i=1,dpr:o=1,meta:a={},backgroundColor:s}=t;e=Li(e);let l=new Image;l.loading="eager",l.decoding="sync",l.crossOrigin="anonymous",l.src=e,await l.decode();let c=l.naturalWidth,u=l.naturalHeight,d=Number.isFinite(a.w0)?a.w0:c,f=Number.isFinite(a.h0)?a.h0:u,p,g,h=Number.isFinite(n),m=Number.isFinite(r);if(h&&m)p=Math.max(1,n),g=Math.max(1,r);else if(h){let b=n/Math.max(1,d);p=n,g=f*b}else if(m){let b=r/Math.max(1,f);g=r,p=d*b}else p=c,g=u;p=p*i,g=g*i;let y=document.createElement("canvas");y.width=p*o,y.height=g*o,y.style.width=`${p}px`,y.style.height=`${g}px`;let x=y.getContext("2d");return o!==1&&x.scale(o,o),s&&(x.save(),x.fillStyle=s,x.fillRect(0,0,p,g),x.restore()),x.drawImage(l,0,0,p,g),y}var ot=z(()=>{De()}),Ge={};Fe(Ge,{rasterize:()=>ar});async function ar(e,t){let n=await rt(e,t),r=new Image;return r.src=n.toDataURL(`image/${t.format}`,t.quality),await r.decode(),r.style.width=`${n.width/t.dpr}px`,r.style.height=`${n.height/t.dpr}px`,r}var Ke=z(()=>{ot()}),Pt={};Fe(Pt,{toImg:()=>Ln,toSvg:()=>Ln});async function Ln(e,t){let{scale:n=1,width:r,height:i,meta:o={}}=t,a=Number.isFinite(r),s=Number.isFinite(i),l=Number.isFinite(n)&&n!==1||a||s;if(fe()&&l)return await ar(e,{...t,format:"png",quality:1,meta:o});let c=new Image;if(c.decoding="sync",c.loading="eager",c.src=e,await c.decode(),a&&s)c.style.width=`${r}px`,c.style.height=`${i}px`;else if(a){let u=Number.isFinite(o.w0)?o.w0:c.naturalWidth,d=Number.isFinite(o.h0)?o.h0:c.naturalHeight,f=r/Math.max(1,u);c.style.width=`${r}px`,c.style.height=`${Math.round(d*f)}px`}else if(s){let u=Number.isFinite(o.w0)?o.w0:c.naturalWidth,d=Number.isFinite(o.h0)?o.h0:c.naturalHeight,f=i/Math.max(1,d);c.style.height=`${i}px`,c.style.width=`${Math.round(u*f)}px`}else{let u=Math.round(c.naturalWidth*n),d=Math.round(c.naturalHeight*n);if(c.style.width=`${u}px`,c.style.height=`${d}px`,typeof e=="string"&&e.startsWith("data:image/svg+xml"))try{let f=decodeURIComponent(e.split(",")[1]).replace(/width="[^"]*"/,`width="${u}"`).replace(/height="[^"]*"/,`height="${d}"`);e=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,c.src=e}catch(f){P(t,"SVG width/height patch in toImg failed",f)}}return c}var Nn=z(()=>{J(),Ke()}),lr={};Fe(lr,{toBlob:()=>sr});async function sr(e,t){let n=t.type;if(n==="svg"){let i=decodeURIComponent(e.split(",")[1]);return new Blob([i],{type:"image/svg+xml"})}let r=await rt(e,t);return new Promise(i=>r.toBlob(o=>i(o),`image/${n}`,t.quality))}var cr=z(()=>{ot()}),ur={};Fe(ur,{download:()=>Ni});async function Tn(e,t){let n=new File([e],t,{type:e.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:t})}catch(r){if(r.name!=="AbortError")return!1}return!0}async function Ni(e,t){let n=(t?.format||t?.type||"").toLowerCase(),r=n==="jpg"?"jpeg":n||"png",i=t?.filename||`snapdom.${r}`,o={...t||{},format:r,type:r};o.dpr=1;let a=xi();if(r==="svg"){let c=await sr(e,{...o,type:"svg"});if(a&&await Tn(c,i))return;let u=URL.createObjectURL(c),d=document.createElement("a");d.href=u,d.download=i,document.body.appendChild(d),d.click(),URL.revokeObjectURL(u),d.remove();return}let s=await rt(e,o);if(a){let c=`image/${r}`,u=await new Promise(d=>s.toBlob(d,c,t?.quality));if(u&&await Tn(u,i))return}let l=document.createElement("a");l.href=s.toDataURL(`image/${r}`,t?.quality),l.download=i,document.body.appendChild(l),l.click(),l.remove()}var Ti=z(()=>{cr(),ot(),De()});J();J();K();var Rn=new WeakMap,Ft=new Map,Dt=0;function Re(){Dt++}var _n=!1;function Ri(e=document.documentElement){if(!_n){_n=!0;try{new MutationObserver(()=>Re()).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>Re()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let t=document.fonts;t&&(t.addEventListener?.("loadingdone",Re),t.ready?.then(()=>Re()).catch(()=>{}))}catch{}}}function _i(e,t={}){let n={},r=e.getPropertyValue("visibility"),i=t.excludeStyleProps;for(let d=0;d<e.length;d++){let f=e[d];if(zt(f)||i&&(i instanceof RegExp&&i.test(f)||typeof i=="function"&&i(f)))continue;let p=e.getPropertyValue(f);(f==="background-image"||f==="content")&&p.includes("url(")&&!p.includes("data:")&&(p="none"),n[f]=p}let o=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let d of o)if(!n[d])try{let f=e.getPropertyValue(d);f&&(n[d]=f)}catch{}let a=["-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order"];for(let d of a)if(!n[d])try{let f=e.getPropertyValue(d);f&&(n[d]=f)}catch{}if(t.embedFonts){let d=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let f of d)if(!n[f])try{let p=e.getPropertyValue(f);p&&(n[f]=p)}catch{}}r==="hidden"&&(n.opacity="0");let s=parseFloat(e.getPropertyValue("border-top-width")||0)||0,l=parseFloat(e.getPropertyValue("border-right-width")||0)||0,c=parseFloat(e.getPropertyValue("border-bottom-width")||0)||0,u=parseFloat(e.getPropertyValue("border-left-width")||0)||0;if(s===0&&l===0&&c===0&&u===0){let d=(e.getPropertyValue("border-image-source")||"").trim(),f=d&&d!=="none",p=["border","border-top","border-right","border-bottom","border-left","border-width","border-style","border-color","border-top-width","border-top-style","border-top-color","border-right-width","border-right-style","border-right-color","border-bottom-width","border-bottom-style","border-bottom-color","border-left-width","border-left-style","border-left-color","border-block","border-block-width","border-block-style","border-block-color","border-inline","border-inline-width","border-inline-style","border-inline-color"];for(let g of p)delete n[g];f||(n.border="none")}return n}var Pn=new WeakMap;function Pi(e){let t=Pn.get(e);return t||(t=Object.entries(e).sort((n,r)=>n[0]<r[0]?-1:n[0]>r[0]?1:0).map(([n,r])=>`${n}:${r}`).join(";"),Pn.set(e,t),t)}function Fi(e,t=null,n={}){let r=Rn.get(e);if(r&&r.epoch===Dt)return r.snapshot;let i=t||getComputedStyle(e),o=_i(i,n);return Ui(e,i,o),Rn.set(e,{epoch:Dt,snapshot:o}),o}function Di(e,t){return e&&e.session&&e.persist?e:e&&(e.styleMap||e.styleCache||e.nodeMap)?{session:e,persist:{snapshotKeyCache:Ft,defaultStyle:C.defaultStyle,baseStyle:C.baseStyle,image:C.image,resource:C.resource,background:C.background,font:C.font},options:t||{}}:{session:C.session,persist:{snapshotKeyCache:Ft,defaultStyle:C.defaultStyle,baseStyle:C.baseStyle,image:C.image,resource:C.resource,background:C.background,font:C.font},options:e||t||{}}}function Ii(e,t,n){if(!(!e.style||e.style.length===0))for(let r=0;r<e.style.length;r++){let i=e.style[r],o=n.getPropertyValue(i);o&&t.style.setProperty(i,o)}}async function Ee(e,t,n,r){if(e.tagName==="STYLE")return;let i=Di(n,r),o=i.options&&i.options.cache||"auto";o!=="disabled"&&Ri(document.documentElement),o==="disabled"&&!i.session.__bumpedForDisabled&&(Re(),Ft.clear(),i.session.__bumpedForDisabled=!0);let{session:a,persist:s}=i;a.styleCache.has(e)||a.styleCache.set(e,getComputedStyle(e));let l=a.styleCache.get(e);e.getAttribute?.("style")&&Ii(e,t,l);let c=Fi(e,l,i.options),u=Pi(c),d=s.snapshotKeyCache.get(u);if(!d){let f=e.tagName?.toLowerCase()||"div";d=Rt(c,f),s.snapshotKeyCache.set(u,d)}a.styleMap.set(t,d)}function Oi(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLIFrameElement||e instanceof SVGElement||e instanceof HTMLObjectElement||e instanceof HTMLEmbedElement}function Hi(e){return e.backgroundImage&&e.backgroundImage!=="none"||e.backgroundColor&&e.backgroundColor!=="rgba(0, 0, 0, 0)"&&e.backgroundColor!=="transparent"||(parseFloat(e.borderTopWidth)||0)>0||(parseFloat(e.borderBottomWidth)||0)>0||(parseFloat(e.paddingTop)||0)>0||(parseFloat(e.paddingBottom)||0)>0?!0:(e.overflowBlock||e.overflowY||"visible")!=="visible"}function Wi(e){let t=e.parentElement;if(!t)return!1;let n=getComputedStyle(t).display||"";return n.includes("flex")||n.includes("grid")}function Bi(e,t){if(e.textContent&&/\S/.test(e.textContent))return!0;let n=e.firstElementChild,r=e.lastElementChild;if(n&&n.tagName==="BR"||r&&r.tagName==="BR")return!0;let i=e.scrollHeight;if(i===0)return!1;let o=parseFloat(t.paddingTop)||0,a=parseFloat(t.paddingBottom)||0;return i>o+a}function Ui(e,t,n){if(e instanceof HTMLElement&&e.style&&e.style.height)return;let r=e.tagName&&e.tagName.toLowerCase();if(!r||!["div","section","article","main","aside","header","footer","nav"].includes(r))return;let i=parseFloat(t.height);if(Number.isFinite(i)&&e.scrollHeight>0&&Math.abs(i-e.scrollHeight)>2||t.aspectRatio&&t.aspectRatio!=="none"&&t.aspectRatio!=="auto")return;let o=t.display||"";if(o.includes("flex")||o.includes("grid")||Oi(e))return;let a=t.position;if(a==="absolute"||a==="fixed"||a==="sticky"||t.transform!=="none"||Hi(t)||Wi(e))return;let s=t.overflowX||t.overflow||"visible",l=t.overflowY||t.overflow||"visible";if(s!=="visible"||l!=="visible")return;let c=t.clip;c&&c!=="auto"&&c!=="rect(auto, auto, auto, auto)"||t.visibility==="hidden"||t.opacity==="0"||Bi(e,t)&&(delete n.height,delete n["block-size"])}nr();var dr=["fill","stroke","color","background-color","stop-color"],Fn=new Map;function qi(e,t){let n=t+"::"+e.toLowerCase(),r=Fn.get(n);if(r)return r;let i=document,o=t==="http://www.w3.org/2000/svg"?i.createElementNS(t,e):i.createElement(e),a=i.createElement("div");a.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",a.appendChild(o),i.documentElement.appendChild(a);let s=getComputedStyle(o),l={};for(let c of dr)l[c]=s.getPropertyValue(c)||"";return a.remove(),Fn.set(n,l),l}function ji(e,t){if(!(e instanceof Element)||!(t instanceof Element))return;let n=e.getAttribute?.("style"),r=!!(n&&n.includes("var("));if(!r&&e.attributes?.length){let o=e.attributes;for(let a=0;a<o.length;a++){let s=o[a];if(s&&typeof s.value=="string"&&s.value.includes("var(")){r=!0;break}}}let i=null;if(r)try{i=getComputedStyle(e)}catch{}if(r){let o=e.style;if(o&&o.length)for(let a=0;a<o.length;a++){let s=o[a],l=o.getPropertyValue(s);if(!l||!l.includes("var("))continue;let c=i&&i.getPropertyValue(s);if(c)try{t.style.setProperty(s,c.trim(),o.getPropertyPriority(s))}catch{}}}if(r&&e.attributes?.length){let o=e.attributes;for(let a=0;a<o.length;a++){let s=o[a];if(!s||typeof s.value!="string"||!s.value.includes("var("))continue;let l=s.name,c=i&&i.getPropertyValue(l);if(c)try{t.style.setProperty(l,c.trim())}catch{}}}if(!r){if(!i)try{i=getComputedStyle(e)}catch{i=null}if(!i)return;let o=e.namespaceURI||"html",a=qi(e.tagName,o);for(let s of dr){let l=i.getPropertyValue(s)||"",c=a[s]||"";if(l&&l!==c)try{t.style.setProperty(s,l.trim())}catch{}}}}J();J();K();ke();function Lt(e,t,n){return Promise.all(e.map(r=>new Promise(i=>{function o(){Se(a=>{!(a&&typeof a.timeRemaining=="function")||a.timeRemaining()>0?t(r,i):o()},{fast:n})}o()})))}function zi(e){return e=e.trim(),!e||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(e)?e:`${e}:not([data-sd-slotted])`}function Vi(e,t,n=!0){return e.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{if(r.startsWith(":where(")||r.startsWith("@"))return r;let i=n?zi(r):r;return`:where(${t} ${i})`}).join(", ")}function Yi(e,t){return e?(e=e.replace(/:host\(([^)]+)\)/g,(n,r)=>`:where(${t}:is(${r.trim()}))`),e=e.replace(/:host\b/g,`:where(${t})`),e=e.replace(/:host-context\(([^)]+)\)/g,(n,r)=>`:where(:where(${r.trim()}) ${t})`),e=e.replace(/::slotted\(([^)]+)\)/g,(n,r)=>`:where(${t} ${r.trim()})`),e=e.replace(/(^|})(\s*)([^@}{]+){/g,(n,r,i,o)=>{let a=Vi(o,t,!0);return`${r}${i}${a}{`}),e):""}function Xi(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}function Gi(e){let t="";try{e.querySelectorAll("style").forEach(r=>{t+=(r.textContent||"")+`
4
4
  `});let n=e.adoptedStyleSheets||[];for(let r of n)try{if(r&&r.cssRules)for(let i of r.cssRules)t+=i.cssText+`
5
5
  `}catch{}}catch{}return t}function Ki(e,t,n){if(!t)return;let r=document.createElement("style");r.setAttribute("data-sd",n),r.textContent=t,e.insertBefore(r,e.firstChild||null)}function Ji(e,t){try{let n=e.currentSrc||e.src||"";if(!n)return;t.setAttribute("src",n),t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.loading="eager",t.decoding="sync"}catch{}}function Zi(e){let t=new Set;if(!e)return t;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,r;for(;r=n.exec(e);)t.add(r[1]);return t}function Qi(e,t){try{let n=getComputedStyle(e).getPropertyValue(t).trim();if(n)return n}catch{}try{let n=getComputedStyle(document.documentElement).getPropertyValue(t).trim();if(n)return n}catch{}return""}function ea(e,t,n){let r=[];for(let i of t){let o=Qi(e,i);o&&r.push(`${i}: ${o};`)}return r.length?`${n}{${r.join("")}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/browser-agent",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
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": [