File size: 25,496 Bytes
f3e548c
 
 
 
 
1
2
3
4
5
/*! For license information please see htmlElement.js.LICENSE.txt */
(()=>{var e={"../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js"(e,t,n){e=n.nmd(e),function(){"use strict";var t="input is invalid type",o="object"==typeof window,r=o?window:{};r.JS_SHA256_NO_WINDOW&&(o=!1);var i=!o&&"object"==typeof self,a=!r.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;a?r=n.g:i&&(r=self);var s=!r.JS_SHA256_NO_COMMON_JS&&"object"==typeof e&&e.exports,l="function"==typeof define&&define.amd,h=!r.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),f=[-0x80000000,8388608,32768,128],c=[24,16,8,0],u=[0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2],m=["hex","array","digest","arrayBuffer"],p=[];(r.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),h&&(r.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var y=function(e,t){return function(n){return new N(t,!0).update(n)[e]()}},g=function(e){var t=y("hex",e);a&&(t=b(t,e)),t.create=function(){return new N(e)},t.update=function(e){return t.create().update(e)};for(var n=0;n<m.length;++n){var o=m[n];t[o]=y(o,e)}return t},b=function(e,o){var i,a=n("?c118"),s=n("?4999").Buffer,l=o?"sha224":"sha256";return i=s.from&&!r.JS_SHA256_NO_BUFFER_FROM?s.from:function(e){return new s(e)},function(n){if("string"==typeof n)return a.createHash(l).update(n,"utf8").digest("hex");if(null==n)throw Error(t);return(n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===s)?a.createHash(l).update(i(n)).digest("hex"):e(n)}},w=function(e,t){return function(n,o){return new T(n,t,!0).update(o)[e]()}},x=function(e){var t=w("hex",e);t.create=function(t){return new T(t,e)},t.update=function(e,n){return t.create(e).update(n)};for(var n=0;n<m.length;++n){var o=m[n];t[o]=w(o,e)}return t};function N(e,t){t?(p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e?(this.h0=0xc1059ed8,this.h1=0x367cd507,this.h2=0x3070dd17,this.h3=0xf70e5939,this.h4=0xffc00b31,this.h5=0x68581511,this.h6=0x64f98fa7,this.h7=0xbefa4fa4):(this.h0=0x6a09e667,this.h1=0xbb67ae85,this.h2=0x3c6ef372,this.h3=0xa54ff53a,this.h4=0x510e527f,this.h5=0x9b05688c,this.h6=0x1f83d9ab,this.h7=0x5be0cd19),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=e}function T(e,n,o){var r,i=typeof e;if("string"===i){var a,s=[],l=e.length,d=0;for(r=0;r<l;++r)(a=e.charCodeAt(r))<128?s[d++]=a:(a<2048?s[d++]=192|a>>>6:(a<55296||a>=57344?s[d++]=224|a>>>12:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++r)),s[d++]=240|a>>>18,s[d++]=128|a>>>12&63),s[d++]=128|a>>>6&63),s[d++]=128|63&a);e=s}else if("object"===i){if(null===e)throw Error(t);else if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!h||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);e.length>64&&(e=new N(n,!0).update(e).array());var f=[],c=[];for(r=0;r<64;++r){var u=e[r]||0;f[r]=92^u,c[r]=54^u}N.call(this,n,o),this.update(c),this.oKeyPad=f,this.inner=!0,this.sharedMemory=o}N.prototype.update=function(e){if(!this.finalized){var n,o=typeof e;if("string"!==o){if("object"===o){if(null===e)throw Error(t);else if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!h||!ArrayBuffer.isView(e)))throw Error(t)}else throw Error(t);n=!0}for(var r,i,a=0,s=e.length,l=this.blocks;a<s;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,this.block=l[16]=l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=0),n)for(i=this.start;a<s&&i<64;++a)l[i>>>2]|=e[a]<<c[3&i++];else for(i=this.start;a<s&&i<64;++a)(r=e.charCodeAt(a))<128?l[i>>>2]|=r<<c[3&i++]:(r<2048?l[i>>>2]|=(192|r>>>6)<<c[3&i++]:(r<55296||r>=57344?l[i>>>2]|=(224|r>>>12)<<c[3&i++]:(r=65536+((1023&r)<<10|1023&e.charCodeAt(++a)),l[i>>>2]|=(240|r>>>18)<<c[3&i++],l[i>>>2]|=(128|r>>>12&63)<<c[3&i++]),l[i>>>2]|=(128|r>>>6&63)<<c[3&i++]),l[i>>>2]|=(128|63&r)<<c[3&i++]);this.lastByteIndex=i,this.bytes+=i-this.start,i>=64?(this.block=l[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>0xffffffff&&(this.hBytes+=this.bytes/0x100000000|0,this.bytes=this.bytes%0x100000000),this}},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>>2]|=f[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},N.prototype.hash=function(){var e,t,n,o,r,i,a,s,l,h,d=this.h0,f=this.h1,c=this.h2,m=this.h3,p=this.h4,y=this.h5,g=this.h6,b=this.h7,w=this.blocks;for(e=16;e<64;++e)t=((r=w[e-15])>>>7|r<<25)^(r>>>18|r<<14)^r>>>3,n=((r=w[e-2])>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,w[e]=w[e-16]+t+w[e-7]+n|0;for(e=0,h=f&c;e<64;e+=4)this.first?(this.is224?(a=300032,b=(r=w[0]-0x543c9a5b)-0x8f1a6c7|0,m=r+0x170e9b5|0):(a=0x2a01a605,b=(r=w[0]-0xc881298)-0x5ab00ac6|0,m=r+0x8909ae5|0),this.first=!1):(t=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),o=(a=d&f)^d&c^h,r=b+n+(p&y^~p&g)+u[e]+w[e],i=t+o,b=m+r|0,m=r+i|0),t=(m>>>2|m<<30)^(m>>>13|m<<19)^(m>>>22|m<<10),n=(b>>>6|b<<26)^(b>>>11|b<<21)^(b>>>25|b<<7),o=(s=m&d)^m&f^a,r=g+n+(b&p^~b&y)+u[e+1]+w[e+1],i=t+o,g=c+r|0,t=((c=r+i|0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),n=(g>>>6|g<<26)^(g>>>11|g<<21)^(g>>>25|g<<7),o=(l=c&m)^c&d^s,r=y+n+(g&b^~g&p)+u[e+2]+w[e+2],i=t+o,y=f+r|0,t=((f=r+i|0)>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),n=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=(h=f&c)^f&m^l,r=p+n+(y&g^~y&b)+u[e+3]+w[e+3],i=t+o,p=d+r|0,d=r+i|0,this.chromeBugWorkAround=!0;this.h0=this.h0+d|0,this.h1=this.h1+f|0,this.h2=this.h2+c|0,this.h3=this.h3+m|0,this.h4=this.h4+p|0,this.h5=this.h5+y|0,this.h6=this.h6+g|0,this.h7=this.h7+b|0},N.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,o=this.h3,r=this.h4,i=this.h5,a=this.h6,s=this.h7,l=d[e>>>28&15]+d[e>>>24&15]+d[e>>>20&15]+d[e>>>16&15]+d[e>>>12&15]+d[e>>>8&15]+d[e>>>4&15]+d[15&e]+d[t>>>28&15]+d[t>>>24&15]+d[t>>>20&15]+d[t>>>16&15]+d[t>>>12&15]+d[t>>>8&15]+d[t>>>4&15]+d[15&t]+d[n>>>28&15]+d[n>>>24&15]+d[n>>>20&15]+d[n>>>16&15]+d[n>>>12&15]+d[n>>>8&15]+d[n>>>4&15]+d[15&n]+d[o>>>28&15]+d[o>>>24&15]+d[o>>>20&15]+d[o>>>16&15]+d[o>>>12&15]+d[o>>>8&15]+d[o>>>4&15]+d[15&o]+d[r>>>28&15]+d[r>>>24&15]+d[r>>>20&15]+d[r>>>16&15]+d[r>>>12&15]+d[r>>>8&15]+d[r>>>4&15]+d[15&r]+d[i>>>28&15]+d[i>>>24&15]+d[i>>>20&15]+d[i>>>16&15]+d[i>>>12&15]+d[i>>>8&15]+d[i>>>4&15]+d[15&i]+d[a>>>28&15]+d[a>>>24&15]+d[a>>>20&15]+d[a>>>16&15]+d[a>>>12&15]+d[a>>>8&15]+d[a>>>4&15]+d[15&a];return this.is224||(l+=d[s>>>28&15]+d[s>>>24&15]+d[s>>>20&15]+d[s>>>16&15]+d[s>>>12&15]+d[s>>>8&15]+d[s>>>4&15]+d[15&s]),l},N.prototype.toString=N.prototype.hex,N.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,o=this.h3,r=this.h4,i=this.h5,a=this.h6,s=this.h7,l=[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a];return this.is224||l.push(s>>>24&255,s>>>16&255,s>>>8&255,255&s),l},N.prototype.array=N.prototype.digest,N.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e},T.prototype=new N,T.prototype.finalize=function(){if(N.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();N.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),N.prototype.finalize.call(this)}};var E=g();E.sha256=E,E.sha224=g(!0),E.sha256.hmac=x(),E.sha224.hmac=x(!0),s?e.exports=E:(r.sha256=E.sha256,r.sha224=E.sha224,l&&define(function(){return E}))}()},"?4999"(){},"?c118"(){}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={id:o,loaded:!1,exports:{}};return e[o](i,i.exports,n),i.loaded=!0,i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var o={};(()=>{"use strict";function e(t,n=150){return void 0===t?"":("object"==typeof t&&(t=JSON.stringify(t)),"number"==typeof t)?t.toString():"string"==typeof t&&t.length>n?`${t.slice(0,n)}...`:"string"==typeof t?t.trim():""}function t(t,n){return Object.keys(t).reduce((o,r)=>{let i=t[r];return"style"===r||"htmlTagName"===r||"nodeType"===r||(o[r]=e(i,n)),o},{})}function r(n,o,i=!1,a=!0){let s=t=>Object.entries(t).map(([t,n])=>`${t}="${e(n,o)}"`).join(" ");return(function n(r,a=0,l=!0){let h="",d="",f="",c=!0,u="  ".repeat(a),m="";for(let e=0;e<(r.children||[]).length;e++){let t=n(r.children[e],a+1,l);t&&(m+=`
${t}`)}if(r.node&&r.node.rect.width>4&&r.node.rect.height>4&&(!i||i&&r.node.content)&&(!l||l&&r.node.isVisible)){let n;c=!1,n=r.node.attributes?.htmlTagName?r.node.attributes.htmlTagName.replace(/[<>]/g,""):r.node.attributes.nodeType.replace(/\sNode$/,"").toLowerCase();let i=r.node.rect?{left:r.node.rect.left,top:r.node.rect.top,width:r.node.rect.width,height:r.node.rect.height}:{};h=`<${n} id="${r.node.id}" ${s(t(r.node.attributes||{},o))} ${s(i)}>`;let a=e(r.node.content,o);d=a?`
${u}  ${a}`:"",f=`</${n}>`}else i||m.trim().startsWith("<>")||(h="<>",d="",f="</>");if(c&&!m.trim())return"";let p=`${u}${h}${d}${m}
${u}${f}`;return p.trim()?p:""})(n,0,a).replace(/^\s*\n/gm,"")}function i(e){let t=[];return!function e(n){for(let o of(n.node&&t.push(n.node),n.children))e(o)}(e),t}function a(e,t){return!function e(n){for(let o of(n.node&&(n.node=t(n.node)),n.children))e(o)}(e),e}function s(e){return e instanceof HTMLElement&&("input"===e.tagName.toLowerCase()||"textarea"===e.tagName.toLowerCase()||"select"===e.tagName.toLowerCase()||"option"===e.tagName.toLowerCase())}function l(e){return e instanceof HTMLElement&&"button"===e.tagName.toLowerCase()}function h(e){return e instanceof HTMLElement&&"a"===e.tagName.toLowerCase()}function d(e){return e instanceof SVGElement}function f(e){return!!(!p(e)&&e instanceof Element)&&"none"!==window.getComputedStyle(e).getPropertyValue("background-image")||!!c(e)||e instanceof HTMLElement&&"img"===e.tagName.toLowerCase()||e instanceof SVGElement&&"svg"===e.tagName.toLowerCase()}function c(e){return e instanceof Element&&(window.getComputedStyle(e).fontFamily||"").toLowerCase().indexOf("iconfont")>=0}function u(e){return m(e)||c(e)||f(e)||l(e)||h(e)||s(e)}function m(e){return!!(e instanceof Element&&e?.childNodes?.length===1&&e?.childNodes[0]instanceof Text)||e.nodeName?.toLowerCase?.()==="#text"&&!c(e)}function p(e){if(!(e instanceof HTMLElement))return!1;if(e.innerText)return!0;for(let t of["svg","button","input","textarea","select","option","img","a"])if(e.querySelectorAll(t).length>0)return!0;return!1}function y(e,t,n=8){let[o,r]=e,i=Math.ceil(n/2)-1;return{rect:{left:Math.max(o-i,0),top:Math.max(r-i,0),width:n,height:n},center:[o,r],description:t||""}}function g(e,t,n=8){let o=e.left+Math.floor((e.width-1)/2),r=e.top+Math.floor((e.height-1)/2);return{rect:e,center:[o,r],description:t||""}}n.r(o),n.d(o,{generateElementByPoint:()=>y,getNodeInfoByXpath:()=>U,getXpathsById:()=>F,trimAttributes:()=>t,webExtractNodeTreeAsString:()=>z,getElementXpath:()=>R,webExtractNodeTree:()=>H,generateElementByRect:()=>g,descriptionOfTree:()=>r,getXpathsByPoint:()=>P,webExtractTextWithPosition:()=>B,treeToList:()=>i,traverseTree:()=>a,isNotContainerElement:()=>u,truncateText:()=>e,getElementInfoByXpath:()=>W});var b=n("../../node_modules/.pnpm/js-sha256@0.11.0/node_modules/js-sha256/src/sha256.js");"undefined"!=typeof process&&process.versions?.node;let w={},x=!1;function N(...e){x&&console.log(...e)}function T(e,t,n,o=2/3){let r=e.height,i=e.width,a=M(e,{left:0,top:0,width:t.innerWidth||n.documentElement.clientWidth,height:t.innerHeight||n.documentElement.clientHeight,right:t.innerWidth||n.documentElement.clientWidth,bottom:t.innerHeight||n.documentElement.clientHeight,x:0,y:0,zoom:1});return!!a&&a.width*a.height/(r*i)>=o}function E(e,t){if(!(e instanceof t.HTMLElement))return{before:"",after:""};let n=t.getComputedStyle(e,"::before").getPropertyValue("content"),o=t.getComputedStyle(e,"::after").getPropertyValue("content");return{before:"none"===n?"":n.replace(/"/g,""),after:"none"===o?"":o.replace(/"/g,"")}}function M(e,t){let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top),r=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom);return n<r&&o<i?{left:n,top:o,right:r,bottom:i,width:r-n,height:i-o,x:n,y:o,zoom:1}:null}function v(e,t,n){let o,r=1;if(e instanceof Element)o=e.getBoundingClientRect(),e instanceof n.HTMLElement&&!("currentCSSZoom"in e)&&(r=Number.parseFloat(n.getComputedStyle(e).zoom)||1);else{let t=n.document.createRange();t.selectNodeContents(e),o=t.getBoundingClientRect()}let i=r*t;return{width:o.width*i,height:o.height*i,left:o.left*i,top:o.top*i,right:o.right*i,bottom:o.bottom*i,x:o.x*i,y:o.y*i,zoom:i}}function C(e,t,n,o=1){let r,i,a;if(!e||!(e instanceof t.HTMLElement)&&e.nodeType!==Node.TEXT_NODE&&"svg"!==e.nodeName.toLowerCase())return N(e,"Element is not in the DOM hierarchy"),!1;if(e instanceof t.HTMLElement){let n=t.getComputedStyle(e);if("none"===n.display||"hidden"===n.visibility||"0"===n.opacity&&"INPUT"!==e.tagName)return N(e,"Element is hidden"),!1}let s=v(e,o,t);if(0===s.width&&0===s.height)return N(e,"Element has no size"),!1;if(1===o&&(r=s.left+s.width/2,i=s.top+s.height/2,!(!(a=t.document.elementFromPoint(r,i))||a===e||e?.contains(a)||a?.contains(e))&&M(s,v(a,1,t))&&(N(e,"Element is covered by another element",{topElement:a,el:e,rect:s,x:r,y:i}),1)))return!1;let l=T(s,t,n),h=e,d=e=>{let n=e?.parentElement;for(;n;){if("static"!==t.getComputedStyle(n).position)return n;n=n.parentElement}return null};for(;h&&h!==n.body;){if(!(h instanceof t.HTMLElement)){h=h.parentElement;continue}let n=t.getComputedStyle(h);if("hidden"===n.overflow){let n=v(h,1,t);if(s.right<n.left-10||s.left>n.right+10||s.bottom<n.top-10||s.top>n.bottom+10)return N(e,"element is partially or totally hidden by an ancestor",{rect:s,parentRect:n}),!1}if("fixed"===n.position||"sticky"===n.position)break;h="absolute"===n.position?d(h):h.parentElement}return{left:Math.round(s.left),top:Math.round(s.top),width:Math.round(s.width),height:Math.round(s.height),zoom:s.zoom,isVisible:l}}function A(e,t){return e&&e instanceof t.HTMLElement&&e.attributes?Object.fromEntries(Array.from(e.attributes).map(e=>{if("class"===e.name)return[e.name,`.${e.value.split(" ").join(".")}`];let t=e.value;return t.startsWith("data:image")&&(t="image"),t.length>300&&(t=`${t.slice(0,300)}...`),[e.name,t]})):{}}function L(){if("undefined"!=typeof window)return window.midsceneNodeHashCache}function S(e,t,n){let o=function(e,t=""){let n=JSON.stringify({content:t,rect:e}),o=5,r="",i=b.sha256.create().update(n).hex().split("").map(e=>String.fromCharCode(97+Number.parseInt(e,16)%26)).join("");for(;o<i.length-1;){if(w[r=i.slice(0,o)]&&w[r]!==n){o++;continue}w[r]=n;break}return r}(n,t);return e&&("undefined"==typeof window||L()||"undefined"!=typeof window&&(window.midsceneNodeHashCache=new Map),!function(e,t){let n=L();if(n&&!n.has(t)){if(n.size>=2e3){let e=n.keys().next().value;void 0!==e&&n.delete(e)}n.set(t,e)}}(e,o)),o}let _=0;function O(e){let t="";if(e instanceof HTMLElement)t=e.tagName?.toLowerCase();else{let n=e.parentElement;n&&n instanceof HTMLElement&&(t=n.tagName?.toLowerCase())}return t?`<${t}>`:""}function $(e,t,n,o=1,r={left:0,top:0},i=!1){let a=C(e,t,n,o);if(!a||a.width<3||a.height<3||((0!==r.left||0!==r.top)&&(a.left+=r.left,a.top+=r.top),a.height>=window.innerHeight&&a.width>=window.innerWidth))return null;if(s(e)){let n=A(e,t),o=n.value||n.placeholder||e.textContent||"",r=S(e,o,a),i=e.tagName.toLowerCase();if("select"===e.tagName.toLowerCase()){let t=e.options[e.selectedIndex];o=t?.textContent||""}return("input"===e.tagName.toLowerCase()||"textarea"===e.tagName.toLowerCase())&&e.value&&(o=e.value),{id:r,nodeHashId:r,nodeType:"FORM_ITEM Node",indexId:_++,attributes:{...n,htmlTagName:`<${i}>`,nodeType:"FORM_ITEM Node"},content:o.trim(),rect:a,center:[Math.round(a.left+a.width/2),Math.round(a.top+a.height/2)],zoom:a.zoom,isVisible:a.isVisible}}if(l(e)){let r=function(e,t,n,o=1){let r=C(e,t,n,o);if(!r)return null;let i=r.left,a=r.top,s=r.left+r.width,l=r.top+r.height;return!function e(r){for(let h=0;h<r.childNodes.length;h++){let d=r.childNodes[h];if(1===d.nodeType){let r=C(d,t,n,o);r&&(i=Math.min(i,r.left),a=Math.min(a,r.top),s=Math.max(s,r.left+r.width),l=Math.max(l,r.top+r.height)),e(d)}}}(e),{...r,left:i,top:a,width:s-i,height:l-a}}(e,t,n,o);if(!r)return null;let i=A(e,t),a=E(e,t),s=e.innerText||a.before||a.after||"",l=S(e,s,r);return{id:l,indexId:_++,nodeHashId:l,nodeType:"BUTTON Node",attributes:{...i,htmlTagName:O(e),nodeType:"BUTTON Node"},content:s,rect:r,center:[Math.round(r.left+r.width/2),Math.round(r.top+r.height/2)],zoom:r.zoom,isVisible:r.isVisible}}if(f(e)){let n=A(e,t),o=S(e,"",a);return{id:o,indexId:_++,nodeHashId:o,attributes:{...n,...e.nodeName?.toLowerCase()==="svg"?{svgContent:"true"}:{},nodeType:"IMG Node",htmlTagName:O(e)},nodeType:"IMG Node",content:"",rect:a,center:[Math.round(a.left+a.width/2),Math.round(a.top+a.height/2)],zoom:a.zoom,isVisible:a.isVisible}}if(m(e)){let n=e.textContent?.trim().replace(/\n+/g," ");if(!n)return null;let o=A(e,t),r=Object.keys(o);if(!n.trim()&&0===r.length)return null;let i=S(e,n,a);return{id:i,indexId:_++,nodeHashId:i,nodeType:"TEXT Node",attributes:{...o,nodeType:"TEXT Node",htmlTagName:O(e)},center:[Math.round(a.left+a.width/2),Math.round(a.top+a.height/2)],content:n,rect:a,zoom:a.zoom,isVisible:a.isVisible}}if(h(e)){let n=A(e,t),o=E(e,t),r=e.innerText||o.before||o.after||"",i=S(e,r,a);return{id:i,indexId:_++,nodeHashId:i,nodeType:"Anchor Node",attributes:{...n,htmlTagName:O(e),nodeType:"Anchor Node"},content:r,rect:a,center:[Math.round(a.left+a.width/2),Math.round(a.top+a.height/2)],zoom:a.zoom,isVisible:a.isVisible}}if(!(!(e instanceof HTMLElement)||p(e))&&window.getComputedStyle(e).getPropertyValue("background-color")||i){let n=A(e,t),o=S(e,"",a);return{id:o,nodeHashId:o,indexId:_++,nodeType:"CONTAINER Node",attributes:{...n,nodeType:"CONTAINER Node",htmlTagName:O(e)},content:"",rect:a,center:[Math.round(a.left+a.width/2),Math.round(a.top+a.height/2)],zoom:a.zoom,isVisible:a.isVisible}}return null}function B(e,t=!1){let n=H(e,t),o=[];return!function e(t){t.node&&o.push(t.node);for(let n=0;n<t.children.length;n++)e(t.children[n])}({children:n.children,node:n.node}),o}function z(e,t=!1,n=!1){return r(H(e,n),void 0,!1,t)}function H(e,t=!1){x=t,_=0;let n=document.body||document,o=e||n,r=[];function i(e,t,n,o=1,r={left:0,top:0}){if(!e||e.nodeType&&10===e.nodeType)return null;let a=$(e,t,n,o,r);if(e instanceof t.HTMLIFrameElement&&e.contentWindow&&e.contentWindow)return null;let s={node:a,children:[]};if(a?.nodeType==="BUTTON Node"||a?.nodeType==="IMG Node"||a?.nodeType==="TEXT Node"||a?.nodeType==="FORM_ITEM Node"||a?.nodeType==="CONTAINER Node")return s;let l=v(e,o,t);for(let o=0;o<e.childNodes.length;o++){N("will dfs",e.childNodes[o]);let a=i(e.childNodes[o],t,n,l.zoom,r);Array.isArray(a)?s.children.push(...a):a&&s.children.push(a)}return null===s.node?0===s.children.length?null:s.children:s}let a=i(o,window,document,1,{left:0,top:0});if(Array.isArray(a)?r.push(...a):a&&r.push(a),o===n){let e=document.querySelectorAll("iframe");for(let t=0;t<e.length;t++){let n=e[t];if(n.contentDocument&&n.contentWindow){let e=$(n,window,document,1);if(e){let t=i(n.contentDocument.body,n.contentWindow,n.contentDocument,1,{left:e.rect.left,top:e.rect.top});Array.isArray(t)?r.push(...t):t&&r.push(t)}}}}return{node:null,children:r}}let V="|>>|";function D(e){return Number.parseFloat(e.zoom??"1")||1}let I=e=>{let t=1,n=e.previousElementSibling;for(;n;)n.nodeName.toLowerCase()===e.nodeName.toLowerCase()&&t++,n=n.previousElementSibling;return t},j=e=>"string"!=typeof e?"":e.replace(/\s+/g," ").trim(),k=(e,t,n,o=!1)=>{let r=e.parentNode?R(e.parentNode,t,!1,o):"",i=r?`${r}/`:"/",a=e.nodeName.toLowerCase(),s=e.textContent?.trim(),l="http://www.w3.org/2000/svg"===e.namespaceURI?`*[name()="${a}"]`:a;if(t){let t=I(e);return`${i}${l}[${t}]`}if(n&&s)return`${i}${l}[normalize-space()="${j(s)}"]`;let h=I(e);return`${i}${l}[${h}]`},R=(e,t=!1,n=!1,o=!1)=>{if(e.nodeType===Node.TEXT_NODE){let n=e.parentNode;if(n&&n.nodeType===Node.ELEMENT_NODE){let r=R(n,t,!0,o),i=e.textContent?.trim();return i?`${r}/text()[normalize-space()="${j(i)}"]`:`${r}/text()`}return""}if(e.nodeType!==Node.ELEMENT_NODE)return"";try{let n=e.nodeName.toLowerCase();if(e===e.ownerDocument?.documentElement||"html"===n){if(!o){let n=e.ownerDocument?.defaultView?.frameElement;if(n){let e=R(n,t,!1,o);return`${e}${V}/html`}}return"/html"}if(e===e.ownerDocument?.body||"body"===n){if(!o){let n=e.ownerDocument?.defaultView?.frameElement;if(n){let e=R(n,t,!1,o);return`${e}${V}/html/body`}}return"/html/body"}}catch(t){if(N("[midscene:locator] ownerDocument access failed:",t),"html"===e.nodeName.toLowerCase())return"/html";if("body"===e.nodeName.toLowerCase())return"/html/body"}if(d(e)){if("svg"===e.nodeName.toLowerCase())return k(e,t,n,o);let r=e.parentNode;for(;r&&r.nodeType===Node.ELEMENT_NODE;){let e=r;if(!d(e)||"svg"===e.nodeName.toLowerCase())return R(e,t,n,o);r=r.parentNode}let i=e.parentNode;return i&&i.nodeType===Node.ELEMENT_NODE?R(i,t,n,o):""}return k(e,t,n,o)};function F(e){let t=L()?.get(e);return t?[R(t,!1,!0,!0)]:null}function P(e,t){let n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof document?document:void 0,{left:r,top:i}=e,a=0,s="",l=null;for(;a<10;){a++;let e=o.elementFromPoint(r,i);if(!e){if(l)return[s+R(l,t,!0,!0)];return null}l=e;let h=e.tagName.toLowerCase();if("iframe"===h||"frame"===h)try{let a=e.contentWindow,l=e.contentDocument;if(a&&l){let h=function(e,t,n){let o=t.getBoundingClientRect(),r=n.getComputedStyle(t),i=t.clientLeft,a=t.clientTop,s=Number.parseFloat(r.paddingLeft)||0,l=Number.parseFloat(r.paddingTop)||0,h=D(r);return{left:(e.left-o.left-i-s)/h,top:(e.top-o.top-a-l)/h}}({left:r,top:i},e,n),d=R(e,t,!1,!0);s+=d+V,n=a,o=l,r=h.left,i=h.top;continue}}catch(e){N("[midscene:locator] iframe penetration failed (cross-origin?):",e)}return[s+R(e,t,!0,!0)]}return l?[s+R(l,t,!0,!0)]:null}function U(e){let t=e.split(V).map(e=>e.trim()).filter(Boolean);if(0===t.length)return null;let n="undefined"!=typeof document?document:void 0,o=null;for(let e=0;e<t.length;e++){let r=t[e],i=n.evaluate(r,n,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);if(1!==i.snapshotLength)return N(`[midscene:locator] XPath "${r}" matched ${i.snapshotLength} elements (expected 1), discarding.`),null;if(o=i.snapshotItem(0),e<t.length-1)if(!o||o.nodeType!==Node.ELEMENT_NODE||"iframe"!==o.tagName.toLowerCase())return null;else try{let e=o.contentDocument;if(!e)return N("[midscene:locator] iframe contentDocument is null (cross-origin?)"),null;n=e}catch(e){return N("[midscene:locator] iframe contentDocument access failed:",e),null}}return o}function W(e){let t=U(e);if(!t)return null;let n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof document?document:void 0;t.ownerDocument?.defaultView&&(n=t.ownerDocument.defaultView,o=t.ownerDocument);let r="undefined"!=typeof document?document:null,i=function(e,t){let n=0,o=0,r=e;for(;r&&r!==t;)try{let e=r.defaultView?.frameElement;if(!e)break;let t=e.getBoundingClientRect(),i=r.defaultView?.parent,a=0,s=0,l=1;try{if(i){let t=i.getComputedStyle(e);a=Number.parseFloat(t.borderLeftWidth)||0,s=Number.parseFloat(t.borderTopWidth)||0,l=D(t)}}catch{}n=n/l+t.left+a,o=o/l+t.top+s,r=e.ownerDocument}catch{break}return{left:n,top:o}}(t.ownerDocument??null,r),a=n,s=o;return t instanceof a.HTMLElement&&(T(v(t,1,a),a,s,1)||t.scrollIntoView({behavior:"instant",block:"center"})),$(t,a,s,1,i,!0)}})(),window.midscene_element_inspector=o})();