@mindstudio-ai/browser-agent 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var __MindStudioBrowserAgent=(()=>{var Gt=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var Ci=Object.prototype.hasOwnProperty;var ki=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})},Mi=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ei(t))!Ci.call(e,i)&&i!==n&&Gt(e,i,{get:()=>t[i],enumerable:!(r=Si(t,i))||r.enumerable});return e};var Ai=e=>Mi(Gt({},"__esModule",{value:!0}),e);var fc={};ki(fc,{executeSteps:()=>Ht,getRefMap:()=>Fe,resolveElement:()=>fe,takeSnapshot:()=>Ie,takeSnapshotSync:()=>nn});var Bn="/__mindstudio_dev__/logs";var Ee=[],_e=null,ht=!1,Xe=[],Un=null;function qn(e){Un=e}function jn(){if(Ee.length===0)return;let e=Ee;Ee=[];let t=Un?.();if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:"log",entries:e}));return}catch{}try{let n=new XMLHttpRequest;n.open("POST",Bn,!0),n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(e))}catch{}}function $i(){_e||(_e=setTimeout(()=>{_e=null,jn()},2e3))}function Li(){_e&&(clearTimeout(_e),_e=null),jn()}function Q(e){Ee.push(e),ht&&Xe.push(e),$i()}function Jt(e){Ee.push(e),ht&&Xe.push(e),Li()}function Kt(){ht=!0,Xe=[]}function Zt(){ht=!1;let e=Xe;return Xe=[],e}function zn(){window.addEventListener("beforeunload",()=>{Ee.length>0&&navigator.sendBeacon&&navigator.sendBeacon(Bn,JSON.stringify(Ee))})}var Ti={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 Ce(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 Ti[n]??null}function Vn(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 Pe(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?ke(l):""}).filter(Boolean).join(" ");if(a)return a}let r=e.tagName.toLowerCase();if(r==="input"||r==="textarea"||r==="select"){let a=Ni(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 ke(a)}let i=ke(e);if(i)return i;let o=e.getAttribute("title");return o?o.trim():""}function ke(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(_i(r))continue;let i=Ri(r),o=ke(r);o&&(i&&t.length>0&&t.push(" "),t.push(o),i&&t.push(" "))}return t.join("").replace(/\s+/g," ").trim()}function Ni(e){if(e.id){let n=document.querySelector(`label[for="${CSS.escape(e.id)}"]`);if(n)return ke(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 Ri(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 _i(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 Qt(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""}}var Ge=0;function gt(){Ge++}function Je(){Ge=Math.max(0,Ge-1)}function Yn(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}Ge===0?o||(o=setTimeout(()=>{Ge===0?n():(o=null,a())},t)):(o&&(clearTimeout(o),o=null),setTimeout(a,50))}a()})}var en=0,tn=new Map;function Fe(){return tn}async function Ie(){return await Yn(),nn()}function nn(){en=0,tn=new Map;let e=document.body;if(!e)return"(empty page)";let t=Xn(e);return rn(t,0).trimEnd()}function ee(e){let t=Ce(e),n=Pe(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 Xn(e){if(Fi(e))return[];let t=Ce(e),n=!t&&Vn(e),r=t||(n?"clickable":null),i="";if(r){i=Pe(e);let u=Qt(e,"::before"),d=Qt(e,"::after");(u||d)&&(i=[u,i,d].filter(Boolean).join(" ")),i.length>80&&(i=i.slice(0,77)+"...")}let o=Ii(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;(a||s)&&(en++,l=`e${en}`,tn.set(l,e));let c=Pi(e);if(r){let u=c.length===0?"":rn(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=ke(e);if(u)return[{tag:null,name:u.length>80?u.slice(0,77)+"...":u,attrs:[],ref:null,children:[],element:e}]}return c}function Pi(e){let t=[];for(let n of Array.from(e.childNodes))n.nodeType===Node.ELEMENT_NODE&&t.push(...Xn(n));return t}function Fi(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 Ii(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 rn(e,t){let n="";for(let r of e)n+=Di(r,t);return n}function Di(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+=rn(e.children,o),i}function Gn(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 q(e){return new Promise(t=>setTimeout(t,e))}var Oi=["log","info","warn","error","debug"];function Jn(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of Oi){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),Q({type:"console",level:e,args:n.map(Gn),url:location.href})}}}}function Kn(){window.addEventListener("error",e=>{Jt({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||{};Jt({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})})}function Zn(){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 gt(),e.apply(this,[t,n]).then(a=>{Je();let s={type:"network",method:r,url:i,status:a.status,statusText:a.statusText,duration:Date.now()-o,ok:a.ok};if(a.ok)Q(s);else try{a.clone().text().then(l=>{s.body=l.slice(0,1e3),Q(s)}).catch(()=>Q(s))}catch{Q(s)}return a},a=>{throw Je(),Q({type:"network",method:r,url:i,error:a.message||String(a),duration:Date.now()-o,ok:!1}),a})},window.fetch.__ms_patched=!0}function Qn(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target,n=(t?.textContent||"").trim().slice(0,100);Q({type:"interaction",event:"click",target:ee(t),text:n,url:location.href})},!0))}function er(){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 gt(),this.addEventListener("loadend",function(){Je(),Q({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 fe(e){let t=null;if(e.ref){let n=Fe(),r=n.get(e.ref);if(r&&r.isConnected)if(de(r))t={element:r,matched:`${ee(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${on(r)}). It may be inside a closed dialog or collapsed section.`);else{let i=[...n.entries()].filter(([,o])=>o.isConnected&&de(o)).slice(0,10).map(([o,a])=>`${ee(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=tr(n,r);if(i.length===0){let o=tr(n,r,!0);if(o.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${on(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=nr(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(rr),a=o.length===1?o[0]:i[0];t={element:a,matched:ee(a)}}else t={element:i[0],matched:ee(i[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=Hi(n);if(r.length===0){let i=nr(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:ee(r[0])}}if(!t&&e.label){let n=e.label,r=Wi(n);if(!r){let i=[...document.querySelectorAll("label")].filter(de).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:`${ee(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(!de(r))throw new Error(`Found element for selector "${n}" but it is hidden (${on(r)}).`);t={element:r,matched:`${ee(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function tr(e,t,n=!1){let r=[],i=e.toLowerCase();for(let o of document.querySelectorAll("*")){if(!n&&!de(o)||n&&!o.isConnected||t&&Ce(o)!==t)continue;if(Pe(o).toLowerCase().includes(i)){r.push(o);continue}o.children.length||(o.textContent||"").trim().toLowerCase().includes(i)&&r.push(o)}return r}function Hi(e){let t=[];for(let n of document.querySelectorAll("*"))de(n)&&Ce(n)===e&&t.push(n);return t}function Wi(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&&de(a))return a}let o=n.querySelector("input, textarea, select");if(o&&de(o))return o}return null}function de(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 rr(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 on(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 nr(e){let t=[];for(let n of document.querySelectorAll("*"))if(de(n)&&(e?Ce(n)===e&&t.push(n):rr(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${Pe(n).slice(0,40)||ee(n)}"`).join(", ")}function an(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 Bi=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,Ui=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function ar(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),an(e),n.clear&&(or(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})),or(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 q(qi(i))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function qi(e){let t=Math.random()*50-25;return e===" "?120+t:/[.,!?;:\-]/.test(e)?140+t:/[A-Z]/.test(e)?115+t:85+t}function or(e,t){let n=e instanceof HTMLTextAreaElement?Ui:Bi;n?n.call(e,t):e.value=t}async function lr(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...fe(e),elapsed:Date.now()-n}}catch{await q(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 ir=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function sr(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 ir?ir.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 cr(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 zi=Object.defineProperty,K=(e,t)=>()=>(e&&(t=e(e=0)),t),nt=(e,t)=>{for(var n in t)zi(e,n,{get:t[n],enumerable:!0})};function Vi(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 Yi(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 te(50),C.defaultStyle=new te(30),C.image=new te(100),C.background=new te(100),C.resource=new te(150),C.font=new Set;return}default:{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}}}var te,C,re=K(()=>{te=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 te(100),background:new te(100),resource:new te(150),defaultStyle:new te(30),baseStyle:new te(50),computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function Sn(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith("#")?null:n}function Xi(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 Ct(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function Gi(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 Mt=K(()=>{});function Ji(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 Ki(e){return/^data:|^blob:|^about:blank$/i.test(e)}function Zi(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 Qi(e,t){if(!t||Ki(e)||Zi(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 ea(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",Ct(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}${Ct(e)}`;let n=t.includes("?")?"&":"?";return`${t}${n}url=${encodeURIComponent(e)}`}function ur(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 ta(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function ne(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 ur(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=ta(e,{as:n,timeout:r,useProxy:i,errorTTL:o}),c=Ze.get(l);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Ze.delete(l);let u=wt.get(l);if(u)return u;let d=Qi(e,i)?ea(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&&Ze.set(l,{until:Date.now()+o,result:b}),!s){let w=`${m.status} ${m.statusText||""}`.trim();cn.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 ur(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&&Ze.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`;cn.errorOnce(b,w)}return t.onError&&t.onError(x),x}finally{clearTimeout(g),wt.delete(l)}})();return wt.set(l,h),h}var cn,wt,Ze,Ue=K(()=>{Mt(),cn=Ji("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),wt=new Map,Ze=new Map});async function Pr(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let n=Sn(e);if(!n)return e;let r=Gi(n),i=Ct(r);if(C.background.has(i)){let o=C.background.get(i);return o?`url("${o}")`:"none"}try{let o=await ne(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 na=K(()=>{re(),Mt(),Ue()});function ra(e){if(e=String(e).toLowerCase(),Cn.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(En(o))continue;let a=r.getPropertyValue(o);i[o]=a}return t.removeChild(n),C.defaultStyle.set(e,i),i}function En(e){let t=String(e).toLowerCase();return!!(Or.has(t)||Dr.test(t)||Ir.test(t))}function un(e,t){if(t=String(t||"").toLowerCase(),Cn.has(t))return"";let n=[],r=ra(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(En(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 oa(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 ia(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+=rn(e.children,o),i}function Gn(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 U(e){return new Promise(t=>setTimeout(t,e))}var Oi=["log","info","warn","error","debug"];function Jn(){if(!console.__ms_patched){console.__ms_patched=!0;for(let e of Oi){let t=console[e];console[e]=(...n)=>{t&&t.apply(console,n),Q({type:"console",level:e,args:n.map(Gn),url:location.href})}}}}function Kn(){window.addEventListener("error",e=>{Jt({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||{};Jt({type:"error",message:t.message||String(t),stack:t.stack||"",url:location.href})})}function Zn(){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 gt(),e.apply(this,[t,n]).then(a=>{Je();let s={type:"network",method:r,url:i,status:a.status,statusText:a.statusText,duration:Date.now()-o,ok:a.ok};if(a.ok)Q(s);else try{a.clone().text().then(l=>{s.body=l.slice(0,1e3),Q(s)}).catch(()=>Q(s))}catch{Q(s)}return a},a=>{throw Je(),Q({type:"network",method:r,url:i,error:a.message||String(a),duration:Date.now()-o,ok:!1}),a})},window.fetch.__ms_patched=!0}function Qn(){document.__ms_click_patched||(document.__ms_click_patched=!0,document.addEventListener("click",e=>{let t=e.target,n=(t?.textContent||"").trim().slice(0,100);Q({type:"interaction",event:"click",target:ee(t),text:n,url:location.href})},!0))}function er(){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 gt(),this.addEventListener("loadend",function(){Je(),Q({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 fe(e){let t=null;if(e.ref){let n=Fe(),r=n.get(e.ref);if(r&&r.isConnected)if(de(r))t={element:r,matched:`${ee(r)} [ref=${e.ref}]`};else throw new Error(`Element [ref=${e.ref}] exists but is hidden (${on(r)}). It may be inside a closed dialog or collapsed section.`);else{let i=[...n.entries()].filter(([,o])=>o.isConnected&&de(o)).slice(0,10).map(([o,a])=>`${ee(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=tr(n,r);if(i.length===0){let o=tr(n,r,!0);if(o.length>0)throw new Error(`Found ${r?r+" ":""}"${n}" but it is hidden (${on(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=nr(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(rr),a=o.length===1?o[0]:i[0];t={element:a,matched:ee(a)}}else t={element:i[0],matched:ee(i[0])}}if(!t&&e.role&&!e.text){let n=e.role,r=Hi(n);if(r.length===0){let i=nr(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:ee(r[0])}}if(!t&&e.label){let n=e.label,r=Wi(n);if(!r){let i=[...document.querySelectorAll("label")].filter(de).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:`${ee(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(!de(r))throw new Error(`Found element for selector "${n}" but it is hidden (${on(r)}).`);t={element:r,matched:`${ee(r)} via selector "${n}"`}}if(!t)throw new Error("No targeting field provided (need ref, text, role, label, or selector)");return t}function tr(e,t,n=!1){let r=[],i=e.toLowerCase();for(let o of document.querySelectorAll("*")){if(!n&&!de(o)||n&&!o.isConnected||t&&Ce(o)!==t)continue;if(Pe(o).toLowerCase().includes(i)){r.push(o);continue}o.children.length||(o.textContent||"").trim().toLowerCase().includes(i)&&r.push(o)}return r}function Hi(e){let t=[];for(let n of document.querySelectorAll("*"))de(n)&&Ce(n)===e&&t.push(n);return t}function Wi(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&&de(a))return a}let o=n.querySelector("input, textarea, select");if(o&&de(o))return o}return null}function de(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 rr(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 on(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 nr(e){let t=[];for(let n of document.querySelectorAll("*"))if(de(n)&&(e?Ce(n)===e&&t.push(n):rr(n)&&t.push(n),t.length>=10))break;return t.length===0?"":t.map(n=>`"${Pe(n).slice(0,40)||ee(n)}"`).join(", ")}function an(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 Bi=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set,Ui=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;async function ar(e,t,n={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("type command requires an input or textarea element");e.focus(),an(e),n.clear&&(or(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})),or(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 U(qi(i))}e.dispatchEvent(new Event("change",{bubbles:!0}))}function qi(e){let t=Math.random()*50-25;return e===" "?120+t:/[.,!?;:\-]/.test(e)?140+t:/[A-Z]/.test(e)?115+t:85+t}function or(e,t){let n=e instanceof HTMLTextAreaElement?Ui:Bi;n?n.call(e,t):e.value=t}async function lr(e){let t=e.timeout||5e3,n=Date.now(),r=n+t;for(;Date.now()<r;)try{return{...fe(e),elapsed:Date.now()-n}}catch{await U(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 ir=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;function sr(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 ir?ir.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 cr(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 zi=Object.defineProperty,K=(e,t)=>()=>(e&&(t=e(e=0)),t),nt=(e,t)=>{for(var n in t)zi(e,n,{get:t[n],enumerable:!0})};function Vi(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 Yi(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 te(50),C.defaultStyle=new te(30),C.image=new te(100),C.background=new te(100),C.resource=new te(150),C.font=new Set;return}default:{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}}}var te,C,re=K(()=>{te=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 te(100),background:new te(100),resource:new te(150),defaultStyle:new te(30),baseStyle:new te(50),computedStyle:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function Sn(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith("#")?null:n}function Xi(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 Ct(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function Gi(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 Mt=K(()=>{});function Ji(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 Ki(e){return/^data:|^blob:|^about:blank$/i.test(e)}function Zi(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 Qi(e,t){if(!t||Ki(e)||Zi(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 ea(e,t){if(!t)return e;if(t.includes("{url}"))return t.replace("{urlRaw}",Ct(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}${Ct(e)}`;let n=t.includes("?")?"&":"?";return`${t}${n}url=${encodeURIComponent(e)}`}function ur(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 ta(e,t){return[t.as||"blob",t.timeout??3e3,t.useProxy||"",t.errorTTL??8e3,e].join("|")}async function ne(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 ur(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=ta(e,{as:n,timeout:r,useProxy:i,errorTTL:o}),c=Ze.get(l);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Ze.delete(l);let u=wt.get(l);if(u)return u;let d=Qi(e,i)?ea(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&&Ze.set(l,{until:Date.now()+o,result:b}),!s){let w=`${m.status} ${m.statusText||""}`.trim();cn.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 ur(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&&Ze.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`;cn.errorOnce(b,w)}return t.onError&&t.onError(x),x}finally{clearTimeout(g),wt.delete(l)}})();return wt.set(l,h),h}var cn,wt,Ze,Ue=K(()=>{Mt(),cn=Ji("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),wt=new Map,Ze=new Map});async function Pr(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()==="none")return e;let n=Sn(e);if(!n)return e;let r=Gi(n),i=Ct(r);if(C.background.has(i)){let o=C.background.get(i);return o?`url("${o}")`:"none"}try{let o=await ne(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 na=K(()=>{re(),Mt(),Ue()});function ra(e){if(e=String(e).toLowerCase(),Cn.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(En(o))continue;let a=r.getPropertyValue(o);i[o]=a}return t.removeChild(n),C.defaultStyle.set(e,i),i}function En(e){let t=String(e).toLowerCase();return!!(Or.has(t)||Dr.test(t)||Ir.test(t))}function un(e,t){if(t=String(t||"").toLowerCase(),Cn.has(t))return"";let n=[],r=ra(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(En(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 oa(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 ia(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 aa(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 la(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 he(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=la(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 dr(e){let t={};for(let n of e)t[n]=e.getPropertyValue(n);return t}function dn(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 Fr,Cn,sa,Ir,Dr,Or,Hr=K(()=>{re(),Fr=new Set(["meta","script","noscript","title","link","template"]),Cn=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"]),sa=["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"],Ir=/(?:^|-)(animation|transition)(?:-|$)/i,Dr=/^(--.+|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,Or=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 He(e,{fast:t=!1}={}){if(t)return e();"requestIdleCallback"in window?requestIdleCallback(e,{timeout:50}):setTimeout(e,1)}function ca(){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 Me(){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 ua(){if(typeof navigator>"u")return!1;let e=(navigator.userAgent||"").toLowerCase();return e.includes("firefox")||e.includes("fxios")}var rt=K(()=>{});function F(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 Wr=K(()=>{}),ie=K(()=>{na(),Hr(),rt(),Mt(),Wr()}),Br={};nt(Br,{toCanvas:()=>At});function da(e){return typeof e=="string"&&/^data:image\/svg\+xml/i.test(e)}function fa(e){let t=e.indexOf(",");return t>=0?decodeURIComponent(e.slice(t+1)):""}function ma(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function pa(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 ha(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 Ur(e){let t=pa(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=ha(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 ga(e){return e.replace(/([^{}]+)\{([^}]*)\}/g,(t,n,r)=>`${n}{${Ur(r)}}`)}function ya(e){return e=e.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(t,n)=>t.replace(n,ga(n))),e=e.replace(/style=(['"])([\s\S]*?)\1/gi,(t,n,r)=>`style=${n}${Ur(r)}${n}`),e}function wa(e){if(!Me()||!da(e))return e;try{let t=fa(e),n=ya(t);return ma(n)}catch{return e}}async function At(e,t){let{width:n,height:r,scale:i=1,dpr:o=1,meta:a={},backgroundColor:s}=t;e=wa(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 $t=K(()=>{rt()}),bt={};nt(bt,{rasterize:()=>qr});async function qr(e,t){let n=await At(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 xt=K(()=>{$t()}),fn={};nt(fn,{toImg:()=>fr,toSvg:()=>fr});async function fr(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(Me()&&l)return await qr(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){F(t,"SVG width/height patch in toImg failed",f)}}return c}var mr=K(()=>{ie(),xt()}),jr={};nt(jr,{toBlob:()=>zr});async function zr(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 At(e,t);return new Promise(i=>r.toBlob(o=>i(o),`image/${n}`,t.quality))}var Vr=K(()=>{$t()}),Yr={};nt(Yr,{download:()=>ba});async function pr(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 ba(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=ca();if(r==="svg"){let c=await zr(e,{...o,type:"svg"});if(a&&await pr(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 At(e,o);if(a){let c=`image/${r}`,u=await new Promise(d=>s.toBlob(d,c,t?.quality));if(u&&await pr(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 xa=K(()=>{Vr(),$t(),rt()});ie();ie();re();var hr=new WeakMap,mn=new Map,pn=0;function Qe(){pn++}var gr=!1;function va(e=document.documentElement){if(!gr){gr=!0;try{new MutationObserver(()=>Qe()).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>Qe()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let t=document.fonts;t&&(t.addEventListener?.("loadingdone",Qe),t.ready?.then(()=>Qe()).catch(()=>{}))}catch{}}}function Sa(e,t={}){let n={},r=e.getPropertyValue("visibility"),i=t.excludeStyleProps;for(let d=0;d<e.length;d++){let f=e[d];if(En(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 yr=new WeakMap;function Ea(e){let t=yr.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(";"),yr.set(e,t),t)}function Ca(e,t=null,n={}){let r=hr.get(e);if(r&&r.epoch===pn)return r.snapshot;let i=t||getComputedStyle(e),o=Sa(i,n);return Na(e,i,o),hr.set(e,{epoch:pn,snapshot:o}),o}function ka(e,t){return e&&e.session&&e.persist?e:e&&(e.styleMap||e.styleCache||e.nodeMap)?{session:e,persist:{snapshotKeyCache:mn,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:mn,defaultStyle:C.defaultStyle,baseStyle:C.baseStyle,image:C.image,resource:C.resource,background:C.background,font:C.font},options:e||t||{}}}function Ma(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 We(e,t,n,r){if(e.tagName==="STYLE")return;let i=ka(n,r),o=i.options&&i.options.cache||"auto";o!=="disabled"&&va(document.documentElement),o==="disabled"&&!i.session.__bumpedForDisabled&&(Qe(),mn.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")&&Ma(e,t,l);let c=Ca(e,l,i.options),u=Ea(c),d=s.snapshotKeyCache.get(u);if(!d){let f=e.tagName?.toLowerCase()||"div";d=un(c,f),s.snapshotKeyCache.set(u,d)}a.styleMap.set(t,d)}function Aa(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLIFrameElement||e instanceof SVGElement||e instanceof HTMLObjectElement||e instanceof HTMLEmbedElement}function $a(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 La(e){let t=e.parentElement;if(!t)return!1;let n=getComputedStyle(t).display||"";return n.includes("flex")||n.includes("grid")}function Ta(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 Na(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")||Aa(e))return;let a=t.position;if(a==="absolute"||a==="fixed"||a==="sticky"||t.transform!=="none"||$a(t)||La(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"||Ta(e,t)&&(delete n.height,delete n["block-size"])}Hr();var Xr=["fill","stroke","color","background-color","stop-color"],wr=new Map;function Ra(e,t){let n=t+"::"+e.toLowerCase(),r=wr.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 Xr)l[c]=s.getPropertyValue(c)||"";return a.remove(),wr.set(n,l),l}function _a(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=Ra(e.tagName,o);for(let s of Xr){let l=i.getPropertyValue(s)||"",c=a[s]||"";if(l&&l!==c)try{t.style.setProperty(s,l.trim())}catch{}}}}ie();ie();re();Ue();function ln(e,t,n){return Promise.all(e.map(r=>new Promise(i=>{function o(){He(a=>{!(a&&typeof a.timeRemaining=="function")||a.timeRemaining()>0?t(r,i):o()},{fast:n})}o()})))}function Pa(e){return e=e.trim(),!e||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(e)?e:`${e}:not([data-sd-slotted])`}function Fa(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?Pa(r):r;return`:where(${t} ${i})`}).join(", ")}function Ia(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=Fa(o,t,!0);return`${r}${i}${a}{`}),e):""}function Da(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}function Oa(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 Ha(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 Wa(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 Ba(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 Ua(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 qa(e,t,n){let r=[];for(let i of t){let o=Ua(e,i);o&&r.push(`${i}: ${o};`)}return r.length?`${n}{${r.join("")}}
|
|
@@ -40,7 +40,7 @@ ${h}
|
|
|
40
40
|
white-space: nowrap;
|
|
41
41
|
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
|
42
42
|
">Remy</div>
|
|
43
|
-
`,e.style.cssText=["position: fixed","z-index: 2147483647","pointer-events: none","opacity: 0","transition: opacity 300ms ease, left 600ms cubic-bezier(0.4, 0, 0, 1), top 600ms cubic-bezier(0.4, 0, 0, 1)","will-change: left, top, opacity"].join("; ");let t=document.createElement("div");t.id=wo,t.style.cssText=["position: fixed","top: 0","left: 0","width: 100vw","height: 100vh","background: white","opacity: 0","z-index: 2147483646","pointer-events: none","transition: opacity 600ms ease-out"].join("; "),document.documentElement.appendChild(t),document.documentElement.appendChild(e),oe=e,xe=t}function Is(e,t){oe&&(oe.style.left=`${e}px`,oe.style.top=`${t}px`,oe.style.opacity="1")}function go(e,t){oe&&(oe.style.left=`${e}px`,oe.style.top=`${t}px`)}async function Ds(){xe&&(xe.style.transition="none",xe.style.opacity="0.7",xe.offsetWidth,xe.style.transition="opacity 600ms ease-out",xe.style.opacity="0",await
|
|
43
|
+
`,e.style.cssText=["position: fixed","z-index: 2147483647","pointer-events: none","opacity: 0","transition: opacity 300ms ease, left 600ms cubic-bezier(0.4, 0, 0, 1), top 600ms cubic-bezier(0.4, 0, 0, 1)","will-change: left, top, opacity"].join("; ");let t=document.createElement("div");t.id=wo,t.style.cssText=["position: fixed","top: 0","left: 0","width: 100vw","height: 100vh","background: white","opacity: 0","z-index: 2147483646","pointer-events: none","transition: opacity 600ms ease-out"].join("; "),document.documentElement.appendChild(t),document.documentElement.appendChild(e),oe=e,xe=t}function Is(e,t){oe&&(oe.style.left=`${e}px`,oe.style.top=`${t}px`,oe.style.opacity="1")}function go(e,t){oe&&(oe.style.left=`${e}px`,oe.style.top=`${t}px`)}async function Ds(){xe&&(xe.style.transition="none",xe.style.opacity="0.7",xe.offsetWidth,xe.style.transition="opacity 600ms ease-out",xe.style.opacity="0",await U(600))}function Os(){oe&&(oe.style.opacity="0")}function Hs(){document.getElementById(An)?.remove(),document.getElementById(wo)?.remove(),oe=null,xe=null}function Ws(e,t){return new Promise(n=>{let r=window.scrollY,i=e-r;if(Math.abs(i)<1){n();return}let o=Math.abs(i),s=Math.max(t,o/2),l=performance.now();function c(u){let d=u-l,f=Math.min(d/s,1),p=f<.5?4*f*f*f:1-Math.pow(-2*f+2,3)/2;window.scrollTo(0,r+i*p),f<1?requestAnimationFrame(c):n()}requestAnimationFrame(c)})}async function Tt(e){await ho();let t=window.innerWidth,n=window.innerHeight;if(e?.viewportOnly)return Bs(t,n);let r=window.scrollY,i=document.documentElement.style.scrollBehavior;document.documentElement.style.scrollBehavior="auto",Fs();try{let o=Math.random()<.5?t+30:-60,a=n*.3+Math.random()*n*.4;Is(o,a),await U(200);let s=t*.4+Math.random()*t*.15,l=n*.35+Math.random()*n*.15;go(s,l),await U(700);let c=[],u=0,d=()=>Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);for(;u<d();){let x=d()-n,b=Math.min(u,x);Math.abs(b-window.scrollY)>1&&(await Ws(b,Rs),go(s,l),await U(Ns));let E=d(),S=window.scrollY,v=Math.min(n,E-S);await Ds();try{let T=await(await _(document.body,{embedFonts:!0,exclude:yo,excludeMode:"remove"})).toCanvas({width:t});if(T){let W=T.height/E,D=Math.round(S*W),$=Math.round(v*W),A=T.width,O=document.createElement("canvas");O.width=A,O.height=$;let V=O.getContext("2d");V&&(V.drawImage(T,0,D,A,$,0,0,A,$),c.push({y:S,canvas:O}))}}catch{}u+=n}if(c.length===0)throw new Error("Screenshot capture produced no image data");let f=d(),p=c[0].canvas.width/t,g=document.createElement("canvas");g.width=c[0].canvas.width,g.height=Math.round(f*p);let h=g.getContext("2d");if(!h)throw new Error("Failed to create output canvas");for(let x of c)h.drawImage(x.canvas,0,Math.round(x.y*p));let y=g.toDataURL("image/jpeg",.85).replace(/^data:image\/jpeg;base64,/,"");if(!y)throw new Error("Canvas export produced no image data");return{image:y,width:g.width,height:g.height}}finally{Os(),Hs(),document.documentElement.style.scrollBehavior="auto",window.scrollTo(0,r),document.documentElement.style.scrollBehavior=i}}async function Bs(e,t){let r=await(await _(document.body,{embedFonts:!0,exclude:yo,excludeMode:"remove"})).toCanvas({width:e,scale:Ae});if(!r)throw new Error("SnapDOM viewport capture returned empty result");let i=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),o=document.createElement("canvas");o.width=e*Ae,o.height=t*Ae;let a=o.getContext("2d");if(!a)throw new Error("Failed to create canvas context");let s=window.scrollY/i*r.height,l=t/i*r.height;a.drawImage(r,0,s,r.width,l,0,0,e*Ae,t*Ae);let u=o.toDataURL("image/jpeg",.85).replace(/^data:image\/jpeg;base64,/,"");if(!u)throw new Error("Canvas export produced no image data");return{image:u,width:e*Ae,height:t*Ae}}var $n=!1;function bo(){$n=new URLSearchParams(window.location.search).get("display-mode")==="pip",window.addEventListener("message",t=>{!t.data||typeof t.data.command!="string"||(t.data.command==="display-mode-pip"?$n=!0:t.data.command==="display-mode-full"&&($n=!1))})}var xo="__mindstudio-cursor",Us="__mindstudio-cursor-ripple",vo=.07,qs=250,Rt=300,js=2e3,Nt=10,So=1,_t="#DD2590",zs=`<svg width="40" height="41" viewBox="0 0 31 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
44
44
|
<g filter="url(#filter0_d_4_78)">
|
|
45
45
|
<path d="M12.5448 26L6.72762 5.59339L26 14.8132L17.1816 17.9377L12.5448 26Z" fill="${_t}"/>
|
|
46
46
|
<path d="M6.9457 5.14539L26.2178 14.3651L27.2985 14.8826L26.1697 15.2813L17.5259 18.3444L12.9812 26.2464L12.3881 27.2792L12.0614 26.1349L6.24434 5.72851L5.94119 4.66488L6.9457 5.14539Z" stroke="${_t}"/>
|
|
@@ -75,7 +75,7 @@ ${h}
|
|
|
75
75
|
letter-spacing: 0.3px;
|
|
76
76
|
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
|
77
77
|
">${Vs}</div>
|
|
78
|
-
`,e.style.cssText=["position: fixed","top: 0","left: 0","z-index: 2147483647","pointer-events: none","will-change: left, top, transform, opacity","opacity: 0"].join("; ");let t=document.createElement("div");t.id=Us,t.style.cssText=["position: fixed","z-index: 2147483646","pointer-events: none","width: 0","height: 0","border-radius: 50%",`background: ${_t}`,"opacity: 0","transform: translate(-50%, -50%)","transition: width 400ms ease-out, height 400ms ease-out, opacity 400ms ease-out"].join("; "),document.documentElement.appendChild(t),document.documentElement.appendChild(e),N=e,Z=t}function Ys(){ot===null&&Lo()}function $o(){ot!==null&&(cancelAnimationFrame(ot),ot=null),ve=null}function Lo(){if(N){if(ve&&ve.isConnected){let e=ve.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=window.innerWidth,i=window.innerHeight,o=Math.max(Nt,Math.min(t,r-Nt)),a=Math.max(Nt,Math.min(n,i-Nt));if(ae=Co(ae,o,vo),le=Co(le,a,vo),N.style.transition="none",N.style.left=`${ae}px`,N.style.top=`${le}px`,Math.abs(ae-o)<So&&Math.abs(le-a)<So&&(ae=o,le=a,N.style.left=`${ae}px`,N.style.top=`${le}px`,$e)){let s=$e;$e=null,s()}}else if(ve&&!ve.isConnected&&$e){let e=$e;$e=null,e()}ot=requestAnimationFrame(Lo)}}async function Pt(e){if(N){if(j&&(clearTimeout(j),j=null),ve=e,!it){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;if(!Eo){let i=Math.max(window.innerWidth,100),o=Math.max(window.innerHeight,100);Math.random()<.5?(ae=i+20,le=r+(Math.random()-.5)*100):(ae=n+(Math.random()-.5)*100,le=o+20),N.style.transition="none",N.style.left=`${ae}px`,N.style.top=`${le}px`,N.style.opacity="0",N.offsetWidth}N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="1",it=!0,Eo=!0,await q(Rt)}return Ys(),new Promise(t=>{$e=t})}}async function To(){N&&(N.style.transform="scale(0.85) translateY(1px)",Z&&(Z.style.transition="none",Z.style.left=`${ae}px`,Z.style.top=`${le}px`,Z.style.width="0",Z.style.height="0",Z.style.opacity="0.35",Z.offsetWidth,Z.style.transition="width 400ms ease-out, height 400ms ease-out, opacity 400ms ease-out",Z.style.width="40px",Z.style.height="40px",Z.style.opacity="0"),await q(qs),N&&(N.style.transform="scale(1) translateY(0)"),await q(100))}function at(e){ko=e}function Tn(){j&&(clearTimeout(j),j=null)}function Ft(){N&&Ln!=="visible"&&(ve=null,j&&clearTimeout(j),j=setTimeout(()=>{Ln!=="visible"&&(N&&(N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="0",it=!1),$o(),j=null)},js))}function It(e){ko||(Ln=e,e==="visible"&&!N&&Ao(),N&&(e==="visible"?(j&&(clearTimeout(j),j=null),N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="1",it=!0):e==="hidden"?(j&&(clearTimeout(j),j=null),N.style.opacity="0",it=!1,$o()):Ft()))}var Gs=["backgroundColor","color","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textDecoration","textTransform","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","borderRadius","borderColor","borderWidth","borderStyle","boxShadow","opacity","width","height","display","flexDirection","justifyContent","alignItems","gap"];function Js(e,t){let n=t??Gs;if(e.ref||e.text||e.role||e.label||e.selector){let{element:o,matched:a}=fe(e);return{...No(o,e.ref,n),matched:a}}let r=Fe(),i=[];for(let[o,a]of r)a.isConnected&&i.push(No(a,o,n));return i}function No(e,t,n){let r=window.getComputedStyle(e),i={};t&&(i.ref=t),i.tag=e.tagName.toLowerCase();let o=e.textContent?.trim();o&&(i.text=o.length>60?o.slice(0,60)+"\u2026":o);for(let a of n){let s=r.getPropertyValue(a.replace(/([A-Z])/g,"-$1").toLowerCase());s&&(i[a]=s)}return i}var Ro=150,Ot=100,Dt="__mindstudio_pending_nav";async function Nn(e=300,t=2e3){return new Promise(n=>{let r=Date.now()+t,i=Date.now(),o=window.scrollY,a=window.scrollX,s=document.body.scrollTop,l=document.documentElement.scrollTop,c=document.body.scrollHeight,u=document.body.scrollWidth;function d(){if(Date.now()>r){n();return}let f=window.scrollY,p=window.scrollX,g=document.body.scrollTop,h=document.documentElement.scrollTop,m=document.body.scrollHeight,y=document.body.scrollWidth;(f!==o||p!==a||g!==s||h!==l||m!==c||y!==u)&&(o=f,a=p,s=g,l=h,c=m,u=y,i=Date.now()),Date.now()-i>=e?n():requestAnimationFrame(d)}requestAnimationFrame(d)})}var Ks=350;async function Rn(e){let t=Zs(e),n=t.map(a=>({el:a,top:a.scrollTop,left:a.scrollLeft})),r=document.documentElement.style.scrollBehavior;document.documentElement.style.scrollBehavior="auto",e.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),document.documentElement.style.scrollBehavior=r;let i=t.map(a=>({top:a.scrollTop,left:a.scrollLeft})),o=[];for(let a=0;a<t.length;a++)(n[a].top!==i[a].top||n[a].left!==i[a].left)&&o.push({el:t[a],fromTop:n[a].top,fromLeft:n[a].left,toTop:i[a].top,toLeft:i[a].left});if(o.length===0){await new Promise(a=>requestAnimationFrame(()=>a()));return}for(let a of o)a.el.scrollTop=a.fromTop,a.el.scrollLeft=a.fromLeft;await new Promise(a=>{let s=performance.now();function l(c){let u=c-s,d=Math.min(u/Ks,1),f=1-Math.pow(1-d,3);for(let p of o)p.el.scrollTop=p.fromTop+(p.toTop-p.fromTop)*f,p.el.scrollLeft=p.fromLeft+(p.toLeft-p.fromLeft)*f;d<1?requestAnimationFrame(l):a()}requestAnimationFrame(l)})}function Zs(e){let t=[],n=e.parentElement;for(;n;){let r=getComputedStyle(n),i=r.overflowY,o=r.overflowX;(i==="auto"||i==="scroll"||o==="auto"||o==="scroll")&&t.push(n),n=n.parentElement}return t.push(document.scrollingElement||document.documentElement),t}async function Ht(e,t){let n=Date.now(),r=[],i=[],o="",a=!1;at(!0),Tn(),Kt();try{for(let s=0;s<t.length;s++){let l=t[s],c=l.command;try{if(s>0&&await q(Ro+Math.random()*Ot-Ot/2),c==="navigate"){let d=l.url;if(!d)throw new Error('navigate command requires a "url" field');let f=t.slice(s+1);if(f.length>0)try{sessionStorage.setItem(Dt,JSON.stringify({id:e,startTime:n,completedSteps:r,remainingSteps:f,stepOffset:s+1}))}catch{}r.push({index:s,command:c,result:"ok"}),a=!0,window.location.href=d,await new Promise(()=>{})}let u=await Po(l);r.push({index:s,command:c,...u})}catch(u){r.push({index:s,command:c,error:u instanceof Error?u.message:String(u)});break}}i=Zt();try{o=await Ie()}catch{}}finally{at(!1),Ft()}return{id:e,steps:r,snapshot:o,logs:i,duration:Date.now()-n}}async function _o(){let e=null;try{let i=sessionStorage.getItem(Dt);if(!i)return null;sessionStorage.removeItem(Dt),e=JSON.parse(i)}catch{return null}if(!e)return null;let t=[...e.completedSteps],n=[],r="";at(!0),Tn(),Kt();try{for(let i=0;i<e.remainingSteps.length;i++){let o=e.remainingSteps[i],a=o.command,s=e.stepOffset+i;try{if(i>0&&await q(Ro+Math.random()*Ot-Ot/2),a==="navigate"){let c=o.url;if(!c)throw new Error('navigate command requires a "url" field');let u=e.remainingSteps.slice(i+1);if(u.length>0)try{sessionStorage.setItem(Dt,JSON.stringify({id:e.id,startTime:e.startTime,completedSteps:t,remainingSteps:u,stepOffset:s+1}))}catch{}t.push({index:s,command:a,result:"ok"}),window.location.href=c,await new Promise(()=>{})}let l=await Po(o);t.push({index:s,command:a,...l})}catch(l){t.push({index:s,command:a,error:l instanceof Error?l.message:String(l)});break}}n=Zt();try{r=await Ie()}catch{}}finally{at(!1),Ft()}return{id:e.id,steps:t,snapshot:r,logs:n,duration:Date.now()-e.startTime}}async function Po(e){switch(e.command){case"snapshot":return{result:await Ie()};case"click":{let{element:t,matched:n}=fe(e);return await Rn(t),await Pt(t),await To(),an(t),await Nn(),await q(1e3),{result:"ok",matched:n}}case"type":{let{element:t,matched:n}=fe(e),r=e.text;if(!r&&r!=="")throw new Error('type command requires a "text" field');return await Rn(t),await Pt(t),await ar(t,r,{clear:!!e.clear}),await Nn(),{result:"ok",matched:n}}case"select":{let{element:t,matched:n}=fe(e),r=e.option;if(!r)throw new Error('select command requires an "option" field');await Rn(t),await Pt(t);let i=sr(t,r);return await Nn(),{result:`selected "${i}"`,matched:n}}case"wait":{let{matched:t,elapsed:n}=await lr(e);return{result:"ok",matched:t,elapsed:n}}case"styles":{let t=e.properties;return{result:Js(e,t)}}case"evaluate":{let t=e.script;if(!t)throw new Error('evaluate command requires a "script" field');return{result:await cr(t)}}case"screenshot":{let t=e.fullPage===!0,{image:n,width:r,height:i}=await Tt({viewportOnly:!t}),o=e.uploadUrl,a=e.uploadFields;if(o&&a){let s=atob(n),l=new Uint8Array(s.length);for(let f=0;f<s.length;f++)l[f]=s.charCodeAt(f);let c=new FormData;for(let[f,p]of Object.entries(a))c.append(f,p);c.append("file",new Blob([l],{type:"image/jpeg"}),"screenshot.jpg");let u=await fetch(o,{method:"POST",body:c});if(!u.ok)throw new Error(`Screenshot upload failed: ${u.status}`);let d=e._publicUrl;return{result:{width:r,height:i,uploaded:!0,...d?{_publicUrl:d}:{}}}}return{result:{image:n,width:r,height:i}}}case"reload":return location.reload(),{result:"ok"};default:throw new Error(`Unknown command: ${e.command}`)}}var Qs="/__mindstudio_dev__/ws",Do=1e3,ec=1e4,G=null,Fo=null,Wt=Do,Ut=!1,_n=!1;function Oo(){G||(qn(Ho),window.addEventListener("beforeunload",()=>{Ut=!0,G&&G.close()}),Wo())}function Ho(){return G&&G.readyState===WebSocket.OPEN?G:null}function tc(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${Qs}`}function nc(){return window.location.search.includes("mode=iframe")?"iframe":"standalone"}function Wo(){if(!Ut){try{G=new WebSocket(tc())}catch{Io();return}G.onopen=()=>{try{G.send(JSON.stringify({type:"hello",mode:nc(),url:location.href,viewport:{w:window.innerWidth,h:window.innerHeight}}))}catch{G?.close()}},G.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case"ack":Fo=t.clientId,Wt=Do,oc();break;case"command":rc(t.id,t.steps);break;case"broadcast":ic(t.action,t.payload);break}},G.onclose=()=>{G=null,Fo=null,Ut||Io()},G.onerror=()=>{}}}function Io(){Ut||(setTimeout(()=>Wo(),Wt),Wt=Math.min(Wt*2,ec))}async function rc(e,t){if(_n){Bt({id:e,steps:[],snapshot:"",logs:[],duration:0,error:"Browser agent is busy"});return}_n=!0,Pn("command-started",{id:e,steps:t.map(n=>n.command)});try{let n=await Ht(e,t);Bt(n),Pn("command-completed",{id:e,success:!0})}catch{Bt({id:e,steps:[],snapshot:"",logs:[],duration:0}),Pn("command-completed",{id:e,success:!1})}finally{_n=!1}}function Bt(e){try{let t=Ho();t&&t.send(JSON.stringify({type:"result",...e}))}catch{}}async function oc(){let e=await _o();e&&Bt(e)}function Pn(e,t){window.parent!==window&&window.parent.postMessage({channel:"mindstudio-browser-agent",command:e,...t},"*")}function ic(e,t){e==="reload"&&location.reload()}var se="#DD2590";var Bo="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",ac=200,Uo=`
|
|
78
|
+
`,e.style.cssText=["position: fixed","top: 0","left: 0","z-index: 2147483647","pointer-events: none","will-change: left, top, transform, opacity","opacity: 0"].join("; ");let t=document.createElement("div");t.id=Us,t.style.cssText=["position: fixed","z-index: 2147483646","pointer-events: none","width: 0","height: 0","border-radius: 50%",`background: ${_t}`,"opacity: 0","transform: translate(-50%, -50%)","transition: width 400ms ease-out, height 400ms ease-out, opacity 400ms ease-out"].join("; "),document.documentElement.appendChild(t),document.documentElement.appendChild(e),N=e,Z=t}function Ys(){ot===null&&Lo()}function $o(){ot!==null&&(cancelAnimationFrame(ot),ot=null),ve=null}function Lo(){if(N){if(ve&&ve.isConnected){let e=ve.getBoundingClientRect(),t=e.left+e.width/2,n=e.top+e.height/2,r=window.innerWidth,i=window.innerHeight,o=Math.max(Nt,Math.min(t,r-Nt)),a=Math.max(Nt,Math.min(n,i-Nt));if(ae=Co(ae,o,vo),le=Co(le,a,vo),N.style.transition="none",N.style.left=`${ae}px`,N.style.top=`${le}px`,Math.abs(ae-o)<So&&Math.abs(le-a)<So&&(ae=o,le=a,N.style.left=`${ae}px`,N.style.top=`${le}px`,$e)){let s=$e;$e=null,s()}}else if(ve&&!ve.isConnected&&$e){let e=$e;$e=null,e()}ot=requestAnimationFrame(Lo)}}async function Pt(e){if(N){if(j&&(clearTimeout(j),j=null),ve=e,!it){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;if(!Eo){let i=Math.max(window.innerWidth,100),o=Math.max(window.innerHeight,100);Math.random()<.5?(ae=i+20,le=r+(Math.random()-.5)*100):(ae=n+(Math.random()-.5)*100,le=o+20),N.style.transition="none",N.style.left=`${ae}px`,N.style.top=`${le}px`,N.style.opacity="0",N.offsetWidth}N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="1",it=!0,Eo=!0,await U(Rt)}return Ys(),new Promise(t=>{$e=t})}}async function To(){N&&(N.style.transform="scale(0.85) translateY(1px)",Z&&(Z.style.transition="none",Z.style.left=`${ae}px`,Z.style.top=`${le}px`,Z.style.width="0",Z.style.height="0",Z.style.opacity="0.35",Z.offsetWidth,Z.style.transition="width 400ms ease-out, height 400ms ease-out, opacity 400ms ease-out",Z.style.width="40px",Z.style.height="40px",Z.style.opacity="0"),await U(qs),N&&(N.style.transform="scale(1) translateY(0)"),await U(100))}function at(e){ko=e}function Tn(){j&&(clearTimeout(j),j=null)}function Ft(){N&&Ln!=="visible"&&(ve=null,j&&clearTimeout(j),j=setTimeout(()=>{Ln!=="visible"&&(N&&(N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="0",it=!1),$o(),j=null)},js))}function It(e){ko||(Ln=e,e==="visible"&&!N&&Ao(),N&&(e==="visible"?(j&&(clearTimeout(j),j=null),N.style.transition=`opacity ${Rt}ms ease`,N.style.opacity="1",it=!0):e==="hidden"?(j&&(clearTimeout(j),j=null),N.style.opacity="0",it=!1,$o()):Ft()))}var Gs=["backgroundColor","color","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textDecoration","textTransform","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","borderRadius","borderColor","borderWidth","borderStyle","boxShadow","opacity","width","height","display","flexDirection","justifyContent","alignItems","gap"];function Js(e,t){let n=t??Gs;if(e.ref||e.text||e.role||e.label||e.selector){let{element:o,matched:a}=fe(e);return{...No(o,e.ref,n),matched:a}}let r=Fe(),i=[];for(let[o,a]of r)a.isConnected&&i.push(No(a,o,n));return i}function No(e,t,n){let r=window.getComputedStyle(e),i={};t&&(i.ref=t),i.tag=e.tagName.toLowerCase();let o=e.textContent?.trim();o&&(i.text=o.length>60?o.slice(0,60)+"\u2026":o);for(let a of n){let s=r.getPropertyValue(a.replace(/([A-Z])/g,"-$1").toLowerCase());s&&(i[a]=s)}return i}var Ro=150,Ot=100,Dt="__mindstudio_pending_nav";async function Nn(e=300,t=2e3){return new Promise(n=>{let r=Date.now()+t,i=Date.now(),o=window.scrollY,a=window.scrollX,s=document.body.scrollTop,l=document.documentElement.scrollTop,c=document.body.scrollHeight,u=document.body.scrollWidth;function d(){if(Date.now()>r){n();return}let f=window.scrollY,p=window.scrollX,g=document.body.scrollTop,h=document.documentElement.scrollTop,m=document.body.scrollHeight,y=document.body.scrollWidth;(f!==o||p!==a||g!==s||h!==l||m!==c||y!==u)&&(o=f,a=p,s=g,l=h,c=m,u=y,i=Date.now()),Date.now()-i>=e?n():requestAnimationFrame(d)}requestAnimationFrame(d)})}var Ks=350;async function Rn(e){let t=Zs(e),n=t.map(a=>({el:a,top:a.scrollTop,left:a.scrollLeft})),r=document.documentElement.style.scrollBehavior;document.documentElement.style.scrollBehavior="auto",e.scrollIntoView({block:"center",inline:"nearest",behavior:"instant"}),document.documentElement.style.scrollBehavior=r;let i=t.map(a=>({top:a.scrollTop,left:a.scrollLeft})),o=[];for(let a=0;a<t.length;a++)(n[a].top!==i[a].top||n[a].left!==i[a].left)&&o.push({el:t[a],fromTop:n[a].top,fromLeft:n[a].left,toTop:i[a].top,toLeft:i[a].left});if(o.length===0){await new Promise(a=>requestAnimationFrame(()=>a()));return}for(let a of o)a.el.scrollTop=a.fromTop,a.el.scrollLeft=a.fromLeft;await new Promise(a=>{let s=performance.now();function l(c){let u=c-s,d=Math.min(u/Ks,1),f=1-Math.pow(1-d,3);for(let p of o)p.el.scrollTop=p.fromTop+(p.toTop-p.fromTop)*f,p.el.scrollLeft=p.fromLeft+(p.toLeft-p.fromLeft)*f;d<1?requestAnimationFrame(l):a()}requestAnimationFrame(l)})}function Zs(e){let t=[],n=e.parentElement;for(;n;){let r=getComputedStyle(n),i=r.overflowY,o=r.overflowX;(i==="auto"||i==="scroll"||o==="auto"||o==="scroll")&&t.push(n),n=n.parentElement}return t.push(document.scrollingElement||document.documentElement),t}async function Ht(e,t){let n=Date.now(),r=[],i=[],o="",a=!1;at(!0),Tn(),Kt();try{for(let s=0;s<t.length;s++){let l=t[s],c=l.command;try{if(s>0&&await U(Ro+Math.random()*Ot-Ot/2),c==="navigate"){let d=l.url;if(!d)throw new Error('navigate command requires a "url" field');let f=t.slice(s+1);if(f.length>0)try{sessionStorage.setItem(Dt,JSON.stringify({id:e,startTime:n,completedSteps:r,remainingSteps:f,stepOffset:s+1}))}catch{}r.push({index:s,command:c,result:"ok"}),a=!0,window.location.href=d,await new Promise(()=>{})}let u=await Po(l);r.push({index:s,command:c,...u})}catch(u){r.push({index:s,command:c,error:u instanceof Error?u.message:String(u)});break}}i=Zt();try{o=await Ie()}catch{}}finally{at(!1),Ft()}return{id:e,steps:r,snapshot:o,logs:i,duration:Date.now()-n}}async function _o(){let e=null;try{let i=sessionStorage.getItem(Dt);if(!i)return null;sessionStorage.removeItem(Dt),e=JSON.parse(i)}catch{return null}if(!e)return null;let t=[...e.completedSteps],n=[],r="";at(!0),Tn(),Kt();try{for(let i=0;i<e.remainingSteps.length;i++){let o=e.remainingSteps[i],a=o.command,s=e.stepOffset+i;try{if(i>0&&await U(Ro+Math.random()*Ot-Ot/2),a==="navigate"){let c=o.url;if(!c)throw new Error('navigate command requires a "url" field');let u=e.remainingSteps.slice(i+1);if(u.length>0)try{sessionStorage.setItem(Dt,JSON.stringify({id:e.id,startTime:e.startTime,completedSteps:t,remainingSteps:u,stepOffset:s+1}))}catch{}t.push({index:s,command:a,result:"ok"}),window.location.href=c,await new Promise(()=>{})}let l=await Po(o);t.push({index:s,command:a,...l})}catch(l){t.push({index:s,command:a,error:l instanceof Error?l.message:String(l)});break}}n=Zt();try{r=await Ie()}catch{}}finally{at(!1),Ft()}return{id:e.id,steps:t,snapshot:r,logs:n,duration:Date.now()-e.startTime}}async function Po(e){switch(e.command){case"snapshot":return{result:await Ie()};case"click":{let{element:t,matched:n}=fe(e);return await Rn(t),await Pt(t),await To(),an(t),await Nn(),await U(1e3),{result:"ok",matched:n}}case"type":{let{element:t,matched:n}=fe(e),r=e.text;if(!r&&r!=="")throw new Error('type command requires a "text" field');return await Rn(t),await Pt(t),await ar(t,r,{clear:!!e.clear}),await Nn(),{result:"ok",matched:n}}case"select":{let{element:t,matched:n}=fe(e),r=e.option;if(!r)throw new Error('select command requires an "option" field');await Rn(t),await Pt(t);let i=sr(t,r);return await Nn(),{result:`selected "${i}"`,matched:n}}case"wait":{let{matched:t,elapsed:n}=await lr(e);return{result:"ok",matched:t,elapsed:n}}case"styles":{let t=e.properties;return{result:Js(e,t)}}case"evaluate":{let t=e.script;if(!t)throw new Error('evaluate command requires a "script" field');return{result:await cr(t)}}case"screenshot":{let t=e.fullPage===!0;e.scrollToTop&&(window.scrollTo({top:0,behavior:"instant"}),await U(500));let{image:n,width:r,height:i}=await Tt({viewportOnly:!t}),o=e.uploadUrl,a=e.uploadFields;if(o&&a){let s=atob(n),l=new Uint8Array(s.length);for(let f=0;f<s.length;f++)l[f]=s.charCodeAt(f);let c=new FormData;for(let[f,p]of Object.entries(a))c.append(f,p);c.append("file",new Blob([l],{type:"image/jpeg"}),"screenshot.jpg");let u=await fetch(o,{method:"POST",body:c});if(!u.ok)throw new Error(`Screenshot upload failed: ${u.status}`);let d=e._publicUrl;return{result:{width:r,height:i,uploaded:!0,...d?{_publicUrl:d}:{}}}}return{result:{image:n,width:r,height:i}}}case"reload":return location.reload(),{result:"ok"};default:throw new Error(`Unknown command: ${e.command}`)}}var Qs="/__mindstudio_dev__/ws",Do=1e3,ec=1e4,G=null,Fo=null,Wt=Do,Ut=!1,_n=!1;function Oo(){G||(qn(Ho),window.addEventListener("beforeunload",()=>{Ut=!0,G&&G.close()}),Wo())}function Ho(){return G&&G.readyState===WebSocket.OPEN?G:null}function tc(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${Qs}`}function nc(){return window.location.search.includes("mode=iframe")?"iframe":"standalone"}function Wo(){if(!Ut){try{G=new WebSocket(tc())}catch{Io();return}G.onopen=()=>{try{G.send(JSON.stringify({type:"hello",mode:nc(),url:location.href,viewport:{w:window.innerWidth,h:window.innerHeight}}))}catch{G?.close()}},G.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case"ack":Fo=t.clientId,Wt=Do,oc();break;case"command":rc(t.id,t.steps);break;case"broadcast":ic(t.action,t.payload);break}},G.onclose=()=>{G=null,Fo=null,Ut||Io()},G.onerror=()=>{}}}function Io(){Ut||(setTimeout(()=>Wo(),Wt),Wt=Math.min(Wt*2,ec))}async function rc(e,t){if(_n){Bt({id:e,steps:[],snapshot:"",logs:[],duration:0,error:"Browser agent is busy"});return}_n=!0,Pn("command-started",{id:e,steps:t.map(n=>n.command)});try{let n=await Ht(e,t);Bt(n),Pn("command-completed",{id:e,success:!0})}catch{Bt({id:e,steps:[],snapshot:"",logs:[],duration:0}),Pn("command-completed",{id:e,success:!1})}finally{_n=!1}}function Bt(e){try{let t=Ho();t&&t.send(JSON.stringify({type:"result",...e}))}catch{}}async function oc(){let e=await _o();e&&Bt(e)}function Pn(e,t){window.parent!==window&&window.parent.postMessage({channel:"mindstudio-browser-agent",command:e,...t},"*")}function ic(e,t){e==="reload"&&location.reload()}var se="#DD2590";var Bo="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",ac=200,Uo=`
|
|
79
79
|
width: ${ac}px;
|
|
80
80
|
background: ${se};
|
|
81
81
|
border-radius: 19px 120px 120px;
|
|
@@ -167,7 +167,7 @@ ${h}
|
|
|
167
167
|
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
|
|
168
168
|
</filter>
|
|
169
169
|
</defs>
|
|
170
|
-
</svg>`,I=null,z=null,Te=[],L=null,jt=!1,ze=0,Ve=0,zt=!1,st=!1,
|
|
170
|
+
</svg>`,I=null,z=null,Te=[],L=null,jt=!1,ze=0,Ve=0,zt=!1,st=!1,q=null,ce=null,Go=0,Jo=0;function Ko(){I||(I=document.createElement("div"),I.id=sc,I.style.cssText=`
|
|
171
171
|
position: fixed;
|
|
172
172
|
inset: 0;
|
|
173
173
|
z-index: 2147483646;
|
|
@@ -180,10 +180,10 @@ ${h}
|
|
|
180
180
|
z-index: 2147483647;
|
|
181
181
|
pointer-events: none;
|
|
182
182
|
will-change: left, top;
|
|
183
|
-
`,I.addEventListener("pointerdown",ti),I.addEventListener("pointermove",ei),document.addEventListener("pointermove",ni,{capture:!0}),document.addEventListener("pointerup",ri,{capture:!0}),document.addEventListener("pointercancel",oi,{capture:!0}),document.addEventListener("keydown",ii),document.body.appendChild(I),document.body.appendChild(z))}function Zo(){document.removeEventListener("pointermove",ni,{capture:!0}),document.removeEventListener("pointerup",ri,{capture:!0}),document.removeEventListener("pointercancel",oi,{capture:!0}),document.removeEventListener("keydown",ii),I&&(I.removeEventListener("pointerdown",ti),I.removeEventListener("pointermove",ei),I.remove(),I=null),z&&(z.remove(),z=null),Te=[],L=null,je()}function Qo(){z&&(z.style.display="none"),ce=null,st=!1,je()}function ei(e){if(!z||!I)return;z.style.left=`${e.clientX}px`,z.style.top=`${e.clientY}px`,ai(e.target)?(z.style.display="none",I.style.cursor=""):(z.style.display="",I.style.cursor="none")}function ti(e){if(!I)return;let t=e.target;if(t.dataset?.deleteBtn==="true"||t.closest("[data-delete-btn]")){let r=t.closest("[data-note-id]");if(r){let i=Te.find(o=>o.id===r.id);if(i){Le(i),e.preventDefault(),e.stopPropagation();return}}}I.setPointerCapture(e.pointerId);let n=ai(e.target);if(n){if(n.state==="editing")return;if(n.state==="selected"){let r=e.target;if(r.dataset?.bubble==="true"||r.closest("[data-bubble]")){qt(n),L=n,e.preventDefault();return}Xo(n,e),e.preventDefault();return}L&&L!==n&&(qe(L)||Le(L)),Yo(n),L=n,Xo(n,e),e.preventDefault();return}if(L&&(L.state==="editing"||L.state==="selected")){qe(L)||Le(L),L=null,st=!0,e.preventDefault();return}jt=!0,ze=e.clientX,Ve=e.clientY,zt=!1,st=!1,e.preventDefault()}function ni(e){if(ce){let r=e.clientX-Go,i=e.clientY-Jo;ce.x=r,ce.y=i,ce.element.style.left=`${r}px`,ce.element.style.top=`${i}px`;return}if(!jt||!I)return;let t=e.clientX-ze,n=e.clientY-Ve;Math.sqrt(t*t+n*n)>uc&&(zt=!0,
|
|
183
|
+
`,I.addEventListener("pointerdown",ti),I.addEventListener("pointermove",ei),document.addEventListener("pointermove",ni,{capture:!0}),document.addEventListener("pointerup",ri,{capture:!0}),document.addEventListener("pointercancel",oi,{capture:!0}),document.addEventListener("keydown",ii),document.body.appendChild(I),document.body.appendChild(z))}function Zo(){document.removeEventListener("pointermove",ni,{capture:!0}),document.removeEventListener("pointerup",ri,{capture:!0}),document.removeEventListener("pointercancel",oi,{capture:!0}),document.removeEventListener("keydown",ii),I&&(I.removeEventListener("pointerdown",ti),I.removeEventListener("pointermove",ei),I.remove(),I=null),z&&(z.remove(),z=null),Te=[],L=null,je()}function Qo(){z&&(z.style.display="none"),ce=null,st=!1,je()}function ei(e){if(!z||!I)return;z.style.left=`${e.clientX}px`,z.style.top=`${e.clientY}px`,ai(e.target)?(z.style.display="none",I.style.cursor=""):(z.style.display="",I.style.cursor="none")}function ti(e){if(!I)return;let t=e.target;if(t.dataset?.deleteBtn==="true"||t.closest("[data-delete-btn]")){let r=t.closest("[data-note-id]");if(r){let i=Te.find(o=>o.id===r.id);if(i){Le(i),e.preventDefault(),e.stopPropagation();return}}}I.setPointerCapture(e.pointerId);let n=ai(e.target);if(n){if(n.state==="editing")return;if(n.state==="selected"){let r=e.target;if(r.dataset?.bubble==="true"||r.closest("[data-bubble]")){qt(n),L=n,e.preventDefault();return}Xo(n,e),e.preventDefault();return}L&&L!==n&&(qe(L)||Le(L)),Yo(n),L=n,Xo(n,e),e.preventDefault();return}if(L&&(L.state==="editing"||L.state==="selected")){qe(L)||Le(L),L=null,st=!0,e.preventDefault();return}jt=!0,ze=e.clientX,Ve=e.clientY,zt=!1,st=!1,e.preventDefault()}function ni(e){if(ce){let r=e.clientX-Go,i=e.clientY-Jo;ce.x=r,ce.y=i,ce.element.style.left=`${r}px`,ce.element.style.top=`${i}px`;return}if(!jt||!I)return;let t=e.clientX-ze,n=e.clientY-Ve;Math.sqrt(t*t+n*n)>uc&&(zt=!0,q||(q=document.createElement("div"),q.style.cssText=`
|
|
184
184
|
position: fixed;
|
|
185
185
|
border: 4px dashed ${se};
|
|
186
186
|
border-radius: 12px;
|
|
187
187
|
pointer-events: none;
|
|
188
188
|
z-index: 2;
|
|
189
|
-
`,I.appendChild(
|
|
189
|
+
`,I.appendChild(q)),q.style.left=`${Math.min(ze,e.clientX)}px`,q.style.top=`${Math.min(Ve,e.clientY)}px`,q.style.width=`${Math.abs(t)}px`,q.style.height=`${Math.abs(n)}px`)}function ri(e){if(I)try{I.releasePointerCapture(e.pointerId)}catch{}if(ce){ce=null;return}if(st){st=!1,je();return}if(!jt||!I){je();return}if(zt){q&&(q.remove(),q=null);let t=Math.min(ze,e.clientX),n=Math.min(Ve,e.clientY),r=Math.abs(e.clientX-ze),i=Math.abs(e.clientY-Ve);if(r>10&&i>10){let o=Vo(t,n,r,i);I.appendChild(o.element),Te.push(o),qt(o),L=o}}else{let t=zo(e.clientX,e.clientY);I.appendChild(t.element),Te.push(t),qt(t),L=t}je()}function oi(){q&&(q.remove(),q=null),ce=null,je()}function ii(e){if(L){if(e.key==="Enter"&&!e.shiftKey&&L.state==="editing"){qe(L)||Le(L),L=null,e.preventDefault();return}if(e.key==="Escape"){L.state==="editing"?(qe(L)||Le(L),L=null):L.state==="selected"&&(qe(L),L=null),e.preventDefault();return}if(L.state==="selected"&&(e.key==="Delete"||e.key==="Backspace")){Le(L),L=null,e.preventDefault();return}L.state==="editing"&&(e.key==="Backspace"||e.key==="Delete")&&L.bubble.textContent?.trim()===""&&(Le(L),L=null,e.preventDefault())}}function Xo(e,t){ce=e,Go=t.clientX-e.x,Jo=t.clientY-e.y}function ai(e){for(let t of Te)if(t.element.contains(e))return t;return null}function Le(e){e.element.remove(),Te=Te.filter(t=>t.id!==e.id),L===e&&(L=null)}function je(){jt=!1,ze=0,Ve=0,zt=!1,q&&(q.remove(),q=null)}var Vt=!1;function li(){Vt||(Vt=!0,Ko())}function si(){Vt&&(Vt=!1,Zo())}async function ci(){let{image:e}=await Tt({viewportOnly:!0});return e}var Fn="mindstudio-browser-agent",In=null;function ui(){In||(In=async e=>{if(e.source===window)return;let t=e.data;if(!(!t||t.channel!==Fn))switch(t.command){case"notes-enter":li();break;case"notes-exit":si();break;case"notes-cursor-hide":Qo();break;case"cursor-show":It("visible");break;case"cursor-hide":It("hidden");break;case"cursor-auto":It(null);break;case"notes-screenshot":{try{let n=await ci();window.parent.postMessage({channel:Fn,command:"screenshot-result",image:n},"*")}catch(n){window.parent.postMessage({channel:Fn,command:"screenshot-result",error:n instanceof Error?n.message:"Screenshot failed"},"*")}break}}},window.addEventListener("message",In))}window.__MINDSTUDIO_BROWSER_AGENT__||(window.__MINDSTUDIO_BROWSER_AGENT__=!0,zn(),Jn(),Kn(),Zn(),er(),Qn(),Oo(),Mo(),ui(),po(),window.parent!==window&&window.parent.postMessage({channel:"mindstudio-browser-agent",command:"ready"},"*"));return Ai(fc);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindstudio-ai/browser-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
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": [
|