ff-dom 3.0.0-beta.3 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +1 -1
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cdn.js +1 -1
- package/dist/types/browser/utils/xpathHelpers.d.ts +1 -0
- package/dist/types/node/utils/xpathHelpers.d.ts +1 -0
- package/dist/xpath.mjs +1 -1
- package/dist/xpath.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/^[\S]+( [\S]+)*$/i;let t=new WeakMap;const n=e=>{e?(e=>{const t=[],n=e=>{e&&!t.includes(e)&&t.push(e)};n(e);const a=e.getRootNode?.();return(a instanceof Document||a instanceof ShadowRoot)&&n(a),n(e.nodeType===Node.DOCUMENT_NODE?e:e.ownerDocument),t})(e).forEach(e=>{t.delete(e)}):t=new WeakMap},a=(e,n)=>{const{owner:a,contextNode:r}=(e=>{const t=9===e.nodeType?e:e.ownerDocument||document;return{owner:t,contextNode:1===e.nodeType||9===e.nodeType||11===e.nodeType?e:t}})(n);let o=t.get(r);o||(o=new Map,t.set(r,o));const l=o.get(e);if(l)return l;const s=a.evaluate(e,r,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),i={first:s.iterateNext(),second:s.iterateNext()};return o.set(e,i),i};let r,o=new Map,l=[];const s=new Set(["marked-element-temp","removePointers"]),i=e=>(e||"").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!s.has(e)).sort(),c=e=>/\d/.test(e||""),u=(e,t,n,a=!1)=>{const r=i(t),o=r.filter(e=>!!a||!c(e));return o.length?1===r.length&&1===o.length?[`@class=${v(o[0])}`]:o.map(t=>{const a=h(`contains(@class,${v(t)})`,D(e),e.tagName.toLowerCase());return{token:t,count:U(a,e,n)}}).sort((e,t)=>e.token.length!==t.token.length?e.token.length-t.token.length:e.count-t.count).map(({token:e})=>`contains(@class,${v(e)})`):[]},f=new Set(["data-testid","data-test-id","data-test","data-cy","testid"]),m=(e,t)=>t?"class"===e||"className"===e?i(t).join(" "):t.replace("removePointers","").trim():"",d=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(D(e.target)&&e.oldValue?.trim()===e.target.classList.value?.trim())return!0;const t=i(e.oldValue),n=i(e.target.getAttribute("class"));return t.join(" ")===n.join(" ")},g=e=>/\d/.test(e),h=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,p=e=>{const t=e?.textContent;return t},$=e=>e?.childNodes[0]?.nodeValue||"",y=(e,t,n,r=!1)=>{try{if(C(n)){const{owner:a,contextNode:o,cloneElement:l,cloneElements:s}=R(n,t),i=a.evaluate(e,o,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),c=i.iterateNext(),u=i.iterateNext();if(!c)return 0;if(!u)return c===l?1:0;if(r&&Array.isArray(t)){let e,t=0;if(s.includes(c)&&t++,s.includes(u)&&t++,2===t)return 2;for(;e=i.iterateNext();)if(s.includes(e)&&(t++,2===t))return 2;return 0}return 2}const{first:o,second:l}=a(e,n);if(!o)return 0;if(!l)return o===t?1:0;if(r&&Array.isArray(t)){let a=0;if(t.includes(o)&&a++,t.includes(l)&&a++,2===a)return 2;const r=(9===n.nodeType?n:n.ownerDocument).evaluate(e,n,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let s;for(;s=r.iterateNext();)if(t.includes(s)&&(a++,2===a))return 2;return 0}return 2}catch(t){return console.error(`Error evaluating XPath: ${e}`,t),0}},v=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},N=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let r="";for(let e=0;e<a.length;e++)r+=a[e];const o=r.length+2;let l=e.slice(0,e.length-o);return l=l.startsWith("(")&&l.endsWith(")")?l.slice(1,-1):e,l},b=(e,t,n,a)=>{try{const r=9===n.nodeType?n:n.ownerDocument;let o=0;if(a){if(1===y(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===y(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const l=r.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s=null;for(;s=l.iterateNext();)if(o++,s.isSameNode(t))return 1===y(`${e}[${o}]`,t,n)?`${e}[${o}]`:1===y(`(${e})[${o}]`,t,n)?`(${e})[${o}]`:void 0}catch(e){console.log(e)}},x=e=>(e=(e=(e=>(e&&=e.split("\n")[0].length>0?e.split("\n")[0]:e.split("\n")[1],e))(e)).split(/[^\u0000-\u00ff]/).reduce((e,t)=>e.length>t.length?e:t,"").trim()).split("/")[0].trim(),E=e=>e?e.replace(/\s\s+/g," ").trim():e,w=(e,t)=>{const n=E((t||"").trim());if(!e.children.length||n.length<=50)return"";const a=n.split(/\s+/).slice(0,3).join(" ");return a.length>2?`contains(normalize-space(.),${v(a)})`:""},k=e=>{const t=E((e||"").trim());if(!t||!c(t))return{prefix:t,fragment:t};const n=t.split(/[0-9]/)[0].replace(/[₹$€£¥₫₽₩₦₱₲₴₵₡₭₮₺฿៛]+/g,"").trim(),a=n.split(/[^a-zA-Z]+/).map(e=>E(e).trim()).filter(e=>e.length>2&&/[a-zA-Z]/.test(e)).join(" ").trim();return{prefix:n.length>2&&/[a-zA-Z]/.test(n)?n:"",fragment:a.length>2?a:""}},S=e=>k(e).fragment,A=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},C=e=>e?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e,R=(e,t)=>{const n=e.ownerDocument.implementation.createHTMLDocument("shadow-xpath"),a=n.createElement("div");a.innerHTML=e.innerHTML,n.body.appendChild(a);const r=t=>{if(!(t&&t instanceof e.ownerDocument.defaultView.Element))return null;const n=((e,t)=>{const n=[];let a=t;for(;a&&a.parentElement;){const e=a.parentElement;n.unshift(Array.from(e.children).indexOf(a)),a=e}return a&&a.parentNode===e?(n.unshift(Array.from(e.children).indexOf(a)),n):null})(e,t);return n?((e,t)=>{let n=e;for(const e of t){const t=n.children.item(e);if(!t)return null;n=t}return n})(a,n):null},o=Array.isArray(t)?t.map(e=>r(e)).filter(Boolean):[],l=Array.isArray(t)?null:r(t??null);return{owner:n,contextNode:a,cloneElement:l,cloneElements:o}},O=(e,t,n)=>{const a=m(e.name,e.value);if(!a||"boolean"==typeof e?.value)return!1;if(["true","false","on","off","flntooltip","flutter-highlight-overlay"].some(e=>e===a))return!1;if(["style","locator-data-tooltip","value"].some(t=>t===e.name))return!1;const r=l?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return!r&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(o=e.name,s=a,(!f.has(o.toLowerCase())||!(e=>/(?:^|[-_:])\d{4,}(?:$|[-_:])/.test(e))(s))&&("class"===e.name||!c(a)))));var o,s},D=e=>e instanceof SVGElement,T=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,P=(t,n,a,r,o,l)=>{if(r){const{tagName:s}=t;let i,f="";const m=[];let d;const p=a.startsWith("@"),$="."===a||"text()"===a,N=$?".":a,b=$&&/\s/.test(r.trim()),x=$?S(r):r,k=$&&c(r)?x:r,A=$?w(t,k):"";if("@class"===a){for(const e of u(t,r,n))if(d=h(e,D(t),t.tagName.toLowerCase()),i=y(d,t,n),1===i&&!o)return d;return}if($&&c(r)&&!x)return;if(r&&(!p||!g(r))&&(d=A?h(A,D(t),t.tagName.toLowerCase()):b?h(`normalize-space(${N})=${v(E(k)).trim()}`,D(t),t.tagName.toLowerCase()):e.test(r)?`//${s}[${a}=${v(k)}]`:h(`normalize-space(${a})=${v(E(k)).trim()}`,D(t),t.tagName.toLowerCase()),i=y(d,t,n),1===i&&!o))return d;if(p&&c(r))return;if(r&&l){const l=r.split(" ");if(l?.length)if(1===l.length){const c=[...new Set(l[0].match(/([^0-9]+)/g))];if(c?.length>=1&&c[0]&&E(c[0].trim())?.length>1&&r.startsWith(c[0])&&(f=e.test(c[0])?`starts-with(${a},${v(c[0]).trim()})`:`starts-with(${a},${v(E(c[0])).trim()})`),c?.length>1&&c[c.length-1]&&E(c[c.length-1].trim())?.length>1&&r.endsWith(c[c.length-1])&&(f=e.test(c[c.length-1])?`ends-with(${a},${v(c[c.length-1]).trim()})`:`ends-with(${a},${v(E(c[c.length-1])).trim()})`),f?.length&&(d=D(t)?`//*[local-name()='${s}' and ${f}]`:`//${s}[${f}]`,i=y(d,t,n),1===i&&!o))return d}else{const c=l.length%2==0?l.length/2:l.length%2,u=l.slice(0,c).join(" ");let m=[...new Set(u.match(/([^0-9]+)/g))];if(m?.length&&m[0]&&E(m[0].trim())?.length&&r.startsWith(m[0])&&(f=e.test(m[0])?`starts-with(${a},${v(m[0]).trim()})`:`starts-with(${a},${v(E(m[0])).trim()})`),f?.length&&(d=D(t)?`//*[local-name()='${s}' and ${f}]`:`//${s}[${f}]`,i=y(d,t,n),1===i&&!o))return d;const g=l.slice(c,l.length-1).join(" ");if(m=[...new Set(g.match(/([^0-9]+)/g))],m?.length&&m[0]&&E(m[0].trim())?.length>3&&r.endsWith(m[0])&&(f=e.test(m[0])?`ends-with(${a},${v(m[0]).trim()})`:`ends-with(${a},${v(E(m[0])).trim()})`),f?.length&&(d=D(t)?`//*[local-name()='${s}' and ${f}]`:`//${s}[${f}]`,i=y(d,t,n),1===i&&!o))return d}}if(r&&l&&g(r)){const l=[...new Set(r.match(/([^0-9]+)/g))];if(l?.length)for(let t=0;t<l?.length;t++)l[t]&&E(l[t].trim())?.length>1&&(e.test(l[t])?m.push(`contains(${a},${v(l[t].trim()).trim()})`):m.push(`contains(${a},${v(E(l[t])).trim()})`));if(m?.length&&(d=D(t)?`//*[local-name()='${s}' and ${m.join(" and ")}]`:`//${s}[${m.join(" and ")}]`,i=y(d,t,n),1===i&&!o))return d}if(d=D(t)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=y(d,t,n),1===i&&!o)return d}},X=(e,t)=>{try{if(!e)return"";let n=D(e)?`/*[local-name()='${e.tagName}']`:`/${e.tagName}`;if(e.parentElement){const t=Array.prototype.slice.call(e.parentElement.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}else if(e instanceof HTMLElement&&e.offsetParent){const t=Array.prototype.slice.call(e.offsetParent.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}return X(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},_=(e,t,n,a=!1,r)=>{try{if(o.has(e))return o.get(e);const l=[];let s=e;for(;s;){let o="",i=!1,c=e===s?r??s.attributes:s.attributes;for(const e of Array.from(c))if(O(e,s)){const a=m(e.name,e.nodeValue),r=e.name;for(const e of ee(s,r,a)){o=e;let a=0;if(a=y(o,s,t),1===a){l.unshift(T(o)),i=!0;break}if(a>1&&n&&(o=b(o,s,t,a),o)){l.unshift(T(o)),i=!0;break}}}if(s.textContent)if(!a||a&&!g(s.textContent)){let e=new RegExp(/^[\S]+( [\S]+)*$/gi);const a=$(s),r=w(s,a);o=r?h(r,D(s),s.tagName||"*"):e.test(s.textContent)?D(s)?`//*[local-name()='${s.tagName}' and .=${v(a)}]`:`//${s.tagName||"*"}[.=${v(a)}]`:D(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${v(a)}]`:`//${s.tagName||"*"}[normalize-space(.)=${v(a)}]`;let l=y(o,s,t);if(1===l)return o;if(l>1&&n)return o=b(o,s,t,l),o}else{let e=[];const a=[...new Set($(s).match(/([^0-9]+)/g))];let r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&E(a[t].trim())&&(r.test(a[t])?e.push(`contains(.,${v(a[t].trim()).trim()})`):e.push(`contains(.,${v(E(a[t])).trim()})`));if(e?.length){o=D(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=y(o,s,t);if(1===a)return o;if(a>1&&n)return o=b(o,s,t,a),o}}if(i)break;{let e=D(s)?`/*[local-name()='${s.tagName}']`:`/${s.tagName}`;if(s.parentElement){const t=Array.from(s.parentElement.children).filter(e=>e.tagName===s.tagName);if(t.length>1){e+=`[${t.indexOf(s)+1}]`}}l.unshift(e)}s=s.parentElement}const i=`${l.join("")}`;return o.set(e,i),i}catch(e){return console.log(e),null}},L=(t,n)=>{const a=[];let r="";if(t&&"function"!=typeof t.nodeValue){if("class"===t.name){const e=n.getRootNode?.()??n.ownerDocument,a=u(n,t.value,e);for(const e of a)if(r=D(n)?`//*[local-name()='${n.tagName}' and ${e}]`:`//${n.tagName}[${e}]`,r)return r;return}if(g(t.value))return;const o=[...new Set(t.value.match(/([^0-9]+)/g))];if(o?.length)for(let n=0;n<o?.length;n++)o[n]&&E(o[n].trim())?.length>2&&(e.test(o[n])?a.push(`contains(@${t.name},${v(o[n].trim())})`):a.push(`contains(@${t.name},${v(E(o[n])).trim()})`));if(a?.length)return r=D(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,r}},I=(t,n,a,r)=>{try{const r=a.filter(e=>O(e,t)),o=a=>{const r=m(a.name,a.nodeValue);return r?"class"===a.name?u(t,r,n):c(r)?[]:e.test(r)?[`@${a.name}="${r}"`]:[`normalize-space(@${a.name})="${r}"`]:[]},l=e=>{const t=o(e);return"class"===e.name?t.map(e=>[e]):t.length?[t]:[]},s=e=>e.reduce((e,t)=>{const n=l(t);return n.length?e.flatMap(e=>n.map(t=>[...e,...t])):[]},[[]]),i=()=>{const n=E(p(t)?.trim()||""),a=S(n);if(c(n))return a?[`contains(normalize-space(.),${v(a)})`]:[];if(!n||n.length>80||/^\d+$/.test(n)){const e=w(t,n);return e?[e]:[]}const r=new Set,o=w(t,n);return o?(r.add(o),Array.from(r)):(e.test(n)&&n.length<=40&&!n.includes(" ")&&r.add(`text()=${v(n)}`),n.includes(" ")&&r.add(`normalize-space(.)=${v(E(n))}`),r.add(`contains(text(),${v(n)})`),Array.from(r))},f=(e,t)=>{const n=[],a=(r,o)=>{if(o.length!==t)for(let t=r;t<e.length;t++)o.push(e[t]),a(t+1,o),o.pop();else n.push([...o])};return a(0,[]),n},d=e=>D(t)?`//*[local-name()='${t.tagName}' and ${e.join(" and ")}]`:`//${t.tagName}[${e.join(" and ")}]`,g=()=>{if(!(r.length<2))for(let e=2;e<=r.length;e++){const a=f(r,e);for(const e of a){const a=s(e);for(const e of a){if(e.length<2)continue;const a=d(e);let r;try{r=y(a,t,n)}catch{continue}if(1===r)return a}}}},h=g();if(h)return h;const $=i();if(!$.length||!r.length)return;for(let e=1;e<=r.length;e++){const a=f(r,e);for(const e of a){const a=s(e);for(const e of a)if(e.length)for(const a of $){const r=[...e,a],o=d(r);try{if(1===y(o,t,n))return o}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},z=(e,t,n)=>M(e,t)[0]||"",M=(t,n,a)=>{let r=D(t),o="";if(O(n,t)){let a=m(n.name,n.value);const l=n.name;if("class"===l){const e=t.getRootNode?.()??t.ownerDocument;return u(t,a,e).map(e=>r?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName||"*"}[${e}]`)}if(c(a))return[];o=e.test(a)?r?`*[local-name()='${t.tagName}' and @${l}=${v(a)}]`:`${t.tagName||"*"}[@${l}=${v(a)}]`:r?`*[local-name()='${t.tagName}' and normalize-space(@${l})=${v(a)}]`:`${t.tagName||"*"}[normalize-space(@${l})=${v(a)}]`}return o?[o]:[]},j=(t,n)=>{if(!t.textContent)return"";const a=$(t),r=S(a);if(c(a)&&!r)return"";const o=c(a)?r:a,l=w(t,o);let s;return s=l?h(l,D(t),t.tagName||"*"):c(a)?h(`contains(normalize-space(.),${v(o)})`,D(t),t.tagName||"*"):!e.test(a)||/\s/.test(a.trim())?h(`normalize-space(.)=${v(o)}`,D(t),t.tagName||"*"):D(t)?`//*[local-name()='${t.tagName}' and .=${v(o)}]`:`//${t.tagName||"*"}[.=${v(o)}]`,s},Y=(e,t,n)=>{if(("."===t||"text()"===t)&&c(n)){const{fragment:t}=k(n);return t?h(`contains(normalize-space(.),${v(t)})`,D(e),e.tagName.toLowerCase()):""}return h(`normalize-space(${t})=${v(E(n)).trim()}`,D(e),e.tagName.toLowerCase())},V=(e,t,n)=>{if(("."===t||"text()"===t)&&c(n)){const{prefix:t,fragment:a}=k(n),r=t||a;return r?h(`starts-with(normalize-space(.),${v(r)})`,D(e),e.tagName.toLowerCase()):""}return h(`starts-with(${t},${v(E(n)).trim()})`,D(e),e.tagName.toLowerCase())},q=(e,t,n)=>{if(("."===t||"text()"===t)&&c(n)){const{fragment:t}=k(n);return t?h(`contains(normalize-space(.),${v(t)})`,D(e),e.tagName.toLowerCase()):""}return h(`contains(${t},${v(E(n)).trim()})`,D(e),e.tagName.toLowerCase())},W=(t,n)=>{const a=n.flatMap(n=>(n=>{const a=m(n.name,n.value);if(!a)return[];if("class"===n.name){const e=t.getRootNode?.()??t.ownerDocument;return u(t,a,e)}return c(a)?[]:e.test(a)?[`@${n.name}=${v(a)}`]:[`normalize-space(@${n.name})=${v(a)}`]})(n)).filter(Boolean);if(a.length>=2)return h(`${a[0]} or ${a[1]}`,D(t),t.tagName.toLowerCase());const r=(()=>{const n=E(p(t)?.trim()||""),a=S(n);if(c(n))return a?`contains(normalize-space(.),${v(a)})`:null;const r=w(t,n);return r||(!n||n.length>80||/^\d+$/.test(n)?null:e.test(n)&&n.length<=40&&!n.includes(" ")?`text()=${v(n)}`:n.includes(" ")?`normalize-space(.)=${v(n)}`:`contains(text(),${v(n)})`)})();return 1===a.length&&r?h(`${a[0]} or ${r}`,D(t),t.tagName.toLowerCase()):""},U=(e,t,n)=>{try{return y(e,t,n)}catch(e){return 0}},F=(e,t)=>{const n=[],a=new Set,r=Array.from(e.attributes||[]),o=["id","data-testid","data-test","data-qa","name","aria-label","role"],l=[...o.map(e=>r.find(t=>t.name===e)).filter(Boolean),...r.filter(e=>!o.includes(e.name))],s=r=>{r&&!a.has(r)&&Z(r,e,t)&&(a.add(r),n.push(r))};l.forEach(t=>{if(O(t,e))for(const n of ee(e,t.name,t.value))s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=j(e);t&&s(t)}if(r.length>1){const n=I(e,t,r);n&&s(n)}return n},H=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(J(a)),a=a.parentElement;return a===e?n.join("/"):""},G=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=J(e),r=D(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const r=F(t,n);for(const o of r){console.log(`Trying ancestor XPath: ${o}`);const r=`${o}/descendant::${a}`;console.log(`Trying descendant XPath: ${r}`);const l=U(r,e,n);if(console.log(`Match count: ${l}`),1===l&&B(r,n)===e)return console.log(`Selected XPath: ${r}`),r;const s=H(t,e);if(s){const t=`${o}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=U(t,e,n);if(console.log(`Match count: ${a}`),1===a&&B(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${r}`);const o=U(r,e,n);return console.log(`Match count: ${o}`),1===o&&B(r,n)===e?(console.log(`Selected XPath: ${r}`),r):(console.log("Selected XPath: "),"")},B=(e,t)=>{try{if(C(t)){const{owner:n,contextNode:a,cloneElement:r}=R(t);return n.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue||r}return t.evaluate(e,t,null,t.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch(e){return null}},Z=(e,t,n)=>{try{const{first:r,second:o}=a(e,n);return!!r&&!o&&r===t}catch{return!1}},J=e=>D(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),K=(e,t,n)=>{if(!(e instanceof Element))return[];const a=new Set,r=[],o=Array.from(e.attributes||[]).filter(t=>{return t?.value&&(n=t.value,!/\d/.test(n))&&O(t,e);var n}),l=(e,t)=>{t&&!a.has(t)&&(a.add(t),r.push({key:e,value:t}))},s=["id","data-testid","data-test","data-qa","name","aria-label","role"];s.forEach(n=>{const a=o.find(e=>e.name===n);if(a)for(const n of ee(e,a.name,a.value))n&&Z(n,e,t)&&l(`anchor by ${a.name}`,n)}),o.forEach(n=>{if(!s.includes(n.name))for(const a of ee(e,n.name,n.value))a&&Z(a,e,t)&&l(`anchor by ${n.name}`,a)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const n=j(e);n&&Z(n,e,t)&&l("anchor by text",n)}if(o.length>1){const n=I(e,t,o);n&&Z(n,e,t)&&l("anchor by combination",n)}const c=G(e,t);return c&&Z(c,e,t)&&l("anchor by tag",c),r},Q=e=>{const t=p(e)?.trim(),n=S(t);if(t&&c(t))return n?`contains(normalize-space(.),${v(n)})`:void 0;const a=w(e,t);if(a)return a;const r=t?v(x(t)):t;return r?r!==`'${t}'`?`contains(.,${r})`:/\s/.test(t)?`normalize-space(.)='${E(t)}'`:`normalize-space(.)='${t}'`:void 0},ee=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let r="";if(n=m(t,n)){if("class"===t){const t=e.getRootNode?.()??e.ownerDocument;return u(e,n,t).map(t=>D(e)?`//*[local-name()='${e.tagName}' and ${t}]`:`//${e.tagName||"*"}[${t}]`)}if(c(n))return[];r=a.test(n)?D(e)?`//*[local-name()='${e.tagName}' and @${t}=${v(n)}]`:`//${e.tagName||"*"}[@${t}=${v(n)}]`:D(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${v(n)})]`:`//${e.tagName||"*"}[contains(@${t},${v(n)})]`}return r?[r]:[]},te=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,ne=(t,n,a)=>{let r;const o=[];if(t.textContent&&a&&g(t.textContent)){const{prefix:e,fragment:n}=k(p(t)),a=[e?`starts-with(normalize-space(.),${v(e)})`:"",n?`contains(normalize-space(.),${v(n)})`:""].filter((e,t,n)=>e&&n.indexOf(e)===t);for(const e of a)r=D(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r})}if(t.textContent&&(!a||a&&!g(t.textContent)))if(e.test(t.textContent)){const e=p(t),n=w(t,e),a=n||(/\s/.test(e.trim())?`normalize-space(.)=${v(E(e))}`:`.=${v(e)}`);r=D(t)?`*[local-name()='${t.tagName}' and ${a}]`:`${t.tagName}[${a}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}else{const e=Q(t);e&&(r=D(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r}))}if(t.attributes){const e="IMG"===t.tagName?Array.from(t.attributes).sort((e,t)=>"alt"===e.name?-1:"alt"===t.name?1:0):Array.from(t.attributes);for(const a of e)if(O(a,t)){let e=a.nodeValue;if(e){e=m(a.name,e);const l=a.name;if("class"!==l&&c(e))continue;if("class"===l){const a=u(t,e,n);if(!a.length)continue;for(const e of a)r=D(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r});continue}r=D(t)?`*[local-name()='${t.tagName}' and @${l}=${v(e)}]`:`${t.tagName}[@${l}=${v(e)}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}}}if(!o?.length){const e=Array.prototype.slice.call(t.attributes);if(e?.length>1){const e=I(t,n,Array.prototype.slice.call(t.attributes));e&&o.push({key:"getReferenceElementsXpath",value:e})}}if(!o?.length){const e=[];let n;const r=t.tagName;if(t.textContent&&a&&g(t.textContent)){const a=E(p(t)).trim();a?.length>1&&e.push(`contains(text(),${v(a)})`),e?.length&&(n=D(t)?`*[local-name()='${r}' and ${e.join(" and ")}]`:`${r}[${e.join(" and ")}]`,n&&o.push({key:"getReferenceElementsXpath",value:n}))}}if(!o?.length){const e=((e,t)=>{const n=Array.prototype.slice.call(e),a=[];try{n.map(e=>{if(O(e,t)){const n=L(e,t);n&&a.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return a})(t.attributes,t);e?.length&&o.concat(e)}return o},ae=e=>e=(e=e.replace(/text\(\)\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1")).replace(/\.\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1"),re=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function oe(e){const t=function(e){return e.toLowerCase().replace(/'[^']*'/g,"?").replace(/"[^"]*"/g,"?").replace(/\[\d+\]/g,"[?]").replace(/\/\/[a-z0-9_-]+/g,"//node").replace(/\/[a-z0-9_-]+/g,"/node")}(e),n=function(e){const t=e.toLowerCase(),n=t.match(/(ancestor-or-self|ancestor|descendant-or-self|descendant|following-sibling|preceding-sibling|following|preceding|parent|child|self)::/),a=n?.[1]??"none",r=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:r?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function le(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function se(e,t,n,a){const r=a?.getRootNode?.()??e,o=e=>{try{return Array.from(r.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===o(`#${le(n)}`).length;case"name":return 1===o(`[name="${le(n)}"]`).length;case"className":return 1===o(`.${n}`).length;case"tagName":case"cssSelector":return 1===o(n).length;case"linkText":return 1===o("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===o("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const ie={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:ne,getAbsoluteXPath:X,getRelativeXPath:_,getCombinationXpath:L,getAttributeCombinationXpath:I,getElementFromXpath:(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const r=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?r.evaluate(e,a,null,XPathResult.ANY_TYPE,null):r.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},isSvg:D,findXpathWithIndex:b,isNumberExist:g,getTextContent:p,getCountOfXPath:y,normalizeXPath:ae,getShadowRoot:A,escapeCharacters:v,removeParenthesis:N,checkBlockedAttributes:O,getRelationship:(e,t)=>{let n=e.compareDocumentPosition(t);return 2===n?"preceding":4===n?"following":8===n?"ancestor":16===n?"descendant":32===n?"self":""},findMatchingParenthesis:re,deleteGarbageFromInnerText:x,replaceTempAttributes:T,createObserver:e=>{r=new MutationObserver(t=>{t.forEach(t=>{("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!d(t))&&n(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&(d(t)||"attributes"!==t?.type||["flndisabled"].includes(t.attributeName)||l.push({url:t.target.baseURI,attributeName:t.attributeName,element:t.target,doc:t.target.ownerDocument}))})})},startObserver:(e,t)=>{r?.observe(e,t)},stopObserver:()=>{r?.disconnect()},modifiedElementAttributes:l,cspEnabled:!1,getXPathPattern:oe,getNormalizedPropertyXPath:Y,getStartsWithPropertyXPath:V,getContainsPropertyXPath:q,getOrAttributesXPath:W,getTagOnlyXPath:G,getFirstMatchedNode:B,isExactUniqueXpath:Z,getAxisNodeTest:J,getUniqueNodeAnchorXpaths:K,escapeAttrValue:le,isUniqueInDOM:se,sanitizeAttributeValue:m,getClassTokenCondition:(e,t,n,a=!1)=>u(e,t,n,a)[0]||null,getClassTokenConditions:u,getXpathStrings:ee,intermediateXpathSteps:M,getContainerTextCondition:w};let ce=[],ue=[],fe=new Map,me=new Map;const de=new Map,ge={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},he=e=>ge[e]||e,pe=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),$e=(e,t)=>t?e:e.filter(e=>!(e=>{let t=null;for(let n=0;n<e.length;n++){const a=e[n];if(t){a===t&&(t=null);continue}if("'"===a||'"'===a){t=a;continue}if("["!==a)continue;const r=e.indexOf("]",n+1);if(-1===r)return!1;if(/^\s*\d+\s*$/.test(e.slice(n+1,r)))return!0}return!1})(e.value)),ye=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",ve=e=>{if(!(e&&e instanceof Element))return[];const t=[],n=Array.from(e.children||[]);for(;n.length;){const e=n.shift();e.classList?.contains("flntooltip")||(t.push(e),n.push(...Array.from(e.children||[])))}return t},Ne=(e,t)=>{const n=[];let a="previous"===t?e.previousElementSibling:e.nextElementSibling;for(;a;)a.classList?.contains("flntooltip")||n.push(a),a="previous"===t?a.previousElementSibling:a.nextElementSibling;return n},be=(e,t)=>{const n=[];for(let a=e;a?.parentElement;a=a.parentElement){let e="previous"===t?a.previousElementSibling:a.nextElementSibling;for(;e;)e.classList?.contains("flntooltip")||(n.push(e),n.push({node:e,expand:()=>ve(e)})),e="previous"===t?e.previousElementSibling:e.nextElementSibling}return n},xe=e=>{if(!(e instanceof Element))return!0;const t=e.textContent?.trim();return!e.id&&!e.className&&0===e.attributes.length&&(!t||t.length>60)&&e.children.length>2},Ee=e=>{let t=0;e.id&&(t+=100),e.getAttribute("data-testid")&&(t+=90),e.className&&(t+=50),0===e.children.length&&(t+=30);const n=e.textContent?.trim();return n&&n.length<40&&(t+=40),t},we=(e,t,n,a,r,o,l)=>{const s=J(n),i=[];let c=0;const u=t.includes("descendant")?10:20;for(const r of e){if(c++>u)break;if(i.length>=5)break;const e="node"in r?r.node:r;if(!(e instanceof Element))continue;if(xe(e))continue;const f=[()=>K(e,a),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&!/\d/.test(t.value)&&O(t,e));for(const a of n){const n=a.value;if(!n)continue;const r=q(e,`@${a.name}`,n);r&&t.push({key:"contains",value:r});const o=V(e,`@${a.name}`,n);o&&t.push({key:"starts-with",value:o})}return t},()=>[{key:"tag",value:G(e,a)}]];for(let r=0;r<f.length;r++){let c=f[r]();if(!c.length)continue;l||(c=c.filter(e=>!/\[\d+\]/.test(e.value)));const u=new Set;c=c.filter(e=>!u.has(e.value)&&(u.add(e.value),!0)),c=c.slice(0,5);for(const e of c){const r=`${e.value}/${t}::${s}`;if(Z(r,n,a)){if(i.push({key:o,value:r}),i.length>=2)return i;if(i.length>=5)return i}}if(l&&r===f.length-1)for(const r of c){const l=y(r.value,e,a);for(let e=1;e<=Math.min(l,3);e++){const l=`(${r.value})[${e}]/${t}::${s}`;if(Z(l,n,a)){if(i.push({key:o,value:l}),i.length>=2)return i;if(i.length>=5)return i}}}}if("expand"in r&&r.expand){const e=r.expand();let l=0;for(const r of e){if(l++>15)break;if(i.length>=5)break;if(!(r instanceof Element))continue;if(xe(r))continue;const e=K(r,a);for(const r of e.slice(0,5)){const e=`${r.value}/${t}::${s}`;if(Z(e,n,a)){if(i.push({key:o,value:e}),i.length>=2)return i;if(i.length>=5)return i}}}}}return i},ke=(e,t)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},Se=(e,t)=>{for(let n=e.nextElementSibling;n;n=n.nextElementSibling)if(n===t)return"following-sibling";for(let n=e.previousElementSibling;n;n=n.previousElementSibling)if(n===t)return"preceding-sibling";return""},Ae=(e,t)=>{const n=[];for(let a=e;a&&a!==t;a=a.parentElement){const e=a.parentElement;if(!e)return"";n.push(`/parent::${J(e)}`)}return n.join("")},Ce=(e,t)=>{const n=J(t);return t.parentElement===e?[`/${n}`,`/descendant::${n}`]:[`/descendant::${n}`]},Re=(e,t,n)=>{const a=[],r=new Set,o=(e=>{const t=[],n=new Set,a=a=>{a&&a!==e&&!n.has(a)&&(a.contains(e)||e.contains(a)||(n.add(a),t.push(a)))};for(let n=e.parentElement,r=0;n&&r<4&&t.length<20;n=n.parentElement,r++){const e=[Ne(n,"previous").slice(0,4),Ne(n,"next").slice(0,4)];for(const t of e)for(const e of t){a(e);let t=0;for(const n of ve(e).sort((e,t)=>Ee(t)-Ee(e))){if(t++>=8)break;a(n)}}}return t.sort((e,t)=>Ee(t)-Ee(e)).slice(0,20)})(e),l=ke(e.parentElement,3);for(const n of o){const o=K(n,t).filter(e=>"anchor by tag"!==e.key).slice(0,2);if(!o.length)continue;const s=ke(n,3);for(const i of o)for(const o of s){const s=Ae(n,o);if(o===n||s)for(const n of l){if(!n||!n.contains(e))continue;const l=Se(o,n);if(!l)continue;const c=`/${l}::${J(n)}`;for(const o of Ce(n,e)){const n=`${i.value}${s}${c}${o}`;if(!r.has(n)&&(r.add(n),Z(n,e,t)&&(a.push({key:"chained axes fallback",value:n}),a.length>=2)))return a}}}}return a},Oe=(e,t)=>{const n=[];for(let a=t;a&&a!==e;a=a.parentElement)n.unshift(J(a));if(!n.length)return"";const a=n.pop();return`${n.length?`/${n.join("/")}`:""}/child::${a}`},De=(e,t,n,a)=>{const r=new Set,o=[],l=(e,t)=>{t&&!r.has(t)&&(!a&&/\[\d+\]/.test(t)||(r.add(t),o.push({key:e,value:t})))};return K(e,t).filter(e=>"anchor by tag"!==e.key).forEach(e=>l(e.key,e.value)),Array.from(e.attributes||[]).forEach(t=>{if(!(e=>!(!e?.value||["style","locator-data-tooltip","value"].includes(e.name)||0===e.name.indexOf("on")&&e.name.length>3))(t)||!c(t.value)||"class"===t.name)return;const n=(e=>{const t=(e.split(/\d/)[0]||"").replace(/[-_:\s.]+$/g,"").trim();return t.length>2&&/[a-zA-Z]/.test(t)?t:""})(t.value);if(!n)return;const a=q(e,`@${t.name}`,n);l(`anchor by stable ${t.name}`,a)}),o},Te=(e,t,n,a)=>{const r=[];for(let t=e.parentElement;t;t=t.parentElement)r.push(t);const o=ve(e),l=Ne(e,"previous"),s=Ne(e,"next"),i=be(e,"previous"),c=be(e,"next"),u=(e,t=20)=>e.length>t?e.slice(0,t):e,f=[[{nodes:u(s),axis:"preceding-sibling",key:"preceding-sibling"},{nodes:u(l),axis:"following-sibling",key:"following-sibling"}],[{nodes:u(r),axis:"child",key:"child"},{nodes:u(o,15),axis:"parent",key:"parent"}],[{nodes:u(r),axis:"descendant",key:"descendant"},{nodes:u(r),axis:"descendant-or-self",key:"descendant-or-self"},{nodes:u(o,10),axis:"ancestor",key:"ancestor"},{nodes:u(o,10),axis:"ancestor-or-self",key:"ancestor-or-self"}],[{nodes:u(i),axis:"following",key:"following"},{nodes:u(c),axis:"preceding",key:"preceding"}]],m=((e,t,n,a)=>{const r=[],o=new Set;for(let n=e.parentElement,l=0;n&&l<8;n=n.parentElement,l++){const l=Oe(n,e);if(!l)continue;const s=De(n,t,0,a);for(const n of s.slice(0,3)){const a=`${n.value}${l}`;if(!o.has(a)&&(o.add(a),Z(a,e,t)&&(r.push({key:"child chain",value:a}),r.length>=2)))return r}}return r})(e,t,0,a);if(m.length)return m;for(const n of f)for(const r of n){const n=we(r.nodes,r.axis,e,t,0,r.key,a);if(n.length>0)return n}return Re(e,t)||[]},Pe=(e,t,n,a,r)=>{const o=he(a);return"text"===o?pe(a,((e,t,n)=>{if(!ye(e))return[];if("text"===n){const n=j(e)||qe(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,o)):["contains","startsWith","normalizeSpace"].includes(o)?pe(a,((e,t,n)=>{const a=[],r=Array.from(e.attributes||[]).filter(t=>t?.value&&O(t,e)),o=ye(e),l="contains"===n?q:"startsWith"===n?V:"normalizeSpace"===n?Y:null;if(!l)return a;if(r.forEach(t=>{const r=l(e,`@${t.name}`,t.value);r&&a.push({key:`xpath by ${n} ${t.name}`,value:r})}),o){const t=l(e,".",o);t&&a.push({key:`xpath by ${n} text`,value:t})}return a})(e,0,o)):["and","or"].includes(o)?pe(a,((e,t,n,a)=>{const r=Array.from(e.attributes||[]).filter(t=>t?.value&&O(t,e));if("and"===a){const n=I(e,t,r);return n?[{key:"xpath by combination",value:n}]:[]}if("or"===a&&r.length>=1){const t=W(e,r);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,0,o)):"axes"===o?pe(a,Te(e,t,0,!1)):"index"===o?pe(a,((e,t)=>{const n=[],a=e.tagName.toLowerCase(),r=Array.from(t.querySelectorAll(a)).indexOf(e)+1;if(r<=0)return[];n.push({key:"xpath by index",value:`(//${a})[${r}]`});let o=e.parentElement;for(;o&&o!==t.body;){if(o.id||o.className){const t=o.id?ee(o,"id",o.id):ee(o,"class",o.className.toString());for(const r of t){const t=Array.from(o.querySelectorAll(a)).indexOf(e)+1;if(t>0){n.push({key:"xpath by index",value:`(${r}//${a})[${t}]`});break}}if(n.length>1)break}o=o.parentElement}return n})(e,t)):"tag"===o?pe(a,[{key:"xpath till tag",value:G(e,t)}]):[]},Xe=(e,t,n,a,r,o)=>{if(e){let l;l="parent"===o?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of l){fe?.get(e)||fe.set(e,y(e,n,a));const t=fe?.get(e);if(1===t)return e;if(t>1&&(ue.length?t<ue[0].count&&(ue.pop(),ue.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})):ue.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})),t>1&&r&&!ce.length){const o=b(e,n,a,t);o&&1===y(o,n,a)&&ce.push({key:"relative xpath by unique parent "+(r?"index":""),value:o})}}}return null},_e=(t,n,a,r,o,l)=>{try{if(de.has(t))return de.get(t);const s=[];let i=t;for(;i&&1===i.nodeType;){const t=!1;for(const e of Array.from(i.attributes))if(O(e,i)){const t=m(e.name,e.nodeValue),r=e.name;for(const e of ee(i,r,t)){let t;try{t=Xe(e,o,a,n,l,"parent")}catch(e){continue}if(t)return t}}if(i.textContent&&!i.textContent)if(!r||r&&!g(i.textContent)){let t;t=e.test(i.textContent)?D(i)?`//*[local-name()='${i.tagName}' and .=${v($(i))}]`:`//${i.tagName||"*"}[.=${v($(i))}]`:D(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${v($(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${v($(i))}]`;const r=Xe(t,o,a,n,l,"parent");if(r)return r}else{const e=[],t=[...new Set($(i).match(/([^0-9]+)/g))],r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&E(t[n].trim())&&(r.test(t[n])?e.push(`contains(.,${v(t[n].trim()).trim()})`):e.push(`contains(.,${v(E(t[n])).trim()})`));if(e?.length){const t=D(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,r=Xe(t,o,a,n,l,"parent");if(r)return r}}if(!t){const e=D(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+o;if(1===y(c,t,n))return de.set(t,c),c}catch(e){return console.error(e),null}},Le=(e,t,n,a)=>{const r=new Map;if(r.has(e))return r.get(e);const o=[];let l=e;try{for(;l&&1===l.nodeType;){if(!l.tagName)return"";let e=!1;for(const n of Array.from(l.attributes)){if(O(n,l)){const a=m(n.name,n.nodeValue),r=n.name;for(const n of ee(l,r,a)){let a;try{a=y(n,l,t)}catch(e){continue}if(1===a){o.unshift(n),e=!0;break}}}if(e)break}if(!e&&l.textContent&&!n.textContent){const n=j(l);if(n){if(1===y(n,l,t)){e=!0,o.unshift(n);break}}}if(e)break;{const e=D(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;o.unshift(e)}l=l.parentElement}const a=o.join("");return r.set(e,a),a}catch(e){return console.log(e),null}},Ie=(e,t,n)=>{const a=[];let r;const o=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?o.unshift(e.firstElementChild):null!=e.nextElementSibling&&o.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&o.unshift(t.nextElementSibling);try{do{let e=!1;for(r=o.pop();null!==r;){for(const n of Array.from(r.attributes)){if(O(n,r)){const o=m(n.name,n.nodeValue),l=n.name;for(const n of ee(r,l,o)){let o;try{o=y(n,r,t)}catch(e){continue}if(1===o){e=!0,a.push(n);break}}}if(e)break}if(!e&&r.textContent&&!n.textContent){const n=j(r);if(n){if(1===y(n,r,t)){e=!0,a.push(n);break}}}if(e)break;{const e=D(r)?`/*[local-name()='${r.tagName}']`:`/${r.tagName}`;a.push(e),null!=r.firstElementChild?(o.push(r.nextElementSibling),r=r.firstElementChild):r=r.nextElementSibling}}}while(o.length>0);const l=a.join("");return me.set(e,l),l}catch(e){return console.log(e),null}},ze=(e,t,n,a)=>{try{const r=document.querySelector(".flntooltip");for(let o=e.nextElementSibling;null!==o&&o!==r;o=o.nextElementSibling)Me(o,e,t,a,"preceding-sibling",n);for(let o=e.previousElementSibling;null!==o&&o!==r;o=o.previousElementSibling)Me(o,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},Me=(e,t,n,a,r,o)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){const l=M(e,{name:t.name,value:t.value},o);for(let t of l){t+=`/${r}::${a}`;const o=y(t,e,n);if(1===o)return void ce.push({key:`xpath by ${r}`,value:t});o>1&&(ue.length?o<ue[0].count&&(ue.pop(),ue.push({key:`relative xpath by ${r}`,value:t,count:o})):ue.push({key:`relative xpath by ${r}`,value:t,count:o}))}}if(!o){let t;if(t=z(e,{name:"text",value:e.textContent}),t){const a=y(t,e,n);if(1===a)return void ce.push({key:`xpath by ${r}`,value:t});a>1&&(ue.length?a<ue[0].count&&(ue.pop(),ue.push({key:`relative xpath by ${r}`,value:t,count:a})):ue.push({key:`relative xpath by ${r}`,value:t,count:a}))}}}catch(e){console.log(`${r} xpath-error`,e)}};function je(e,t,n,a){const{tagName:r}=t,o=t.textContent.trim();if(!o)return;const l=E(o),s=S(l);if(c(l)&&!s)return;const i=c(l)?s:l,u=w(t,i);for(const a of e)if(O(a,t)){let e=m(a.name,a.nodeValue);const s=`//${r}[@${a.name}='${e}' and ${u||(c(l)?`contains(normalize-space(.),${v(i)})`:/\s/.test(o)?`normalize-space(.)=${v(i)}`:`text()=${v(i)}`)}]`;if(s){if(1==y(s,t,n))return s}}}const Ye=(e,t,n,a,r)=>{let o;if(o=e.name,O(e,t))return P(t,n,`@${o}`,e.value,a,r)},Ve=(e,t,n,a)=>{let r=e.className;if("string"!=typeof r&&(r=""),r=r?.replace("flndisabled","disabled"),r=m("class",r),r=r?.trim(),r&&O({name:"class",value:r},e))return P(e,t,"@class",r,n,a)},qe=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const r=p(e);if(r)return P(e,t,".",r,n,a)}},We=(e,t,n,a,r)=>{const o=e;try{o.map(e=>{if("className"!==e.name&&"class"!==e.name&&O(e,t)){const o=Ye(e,t,n,a,r);o&&ce.push({key:`xpath by ${e.name}${a?" index":""}`,value:o})}});const l=qe(t,n,a,r);if(l&&ce.push({key:"xpath by text"+(a?" index":""),value:l}),o.find(e=>"className"===e.name)&&O(o?.find(e=>"className"===e.name),t)){let e=Ve(t,n,a,r);e&&ce.push({key:"xpath by class",value:e})}if(!ce.length&&o.length>1){const e=I(t,n,o);e&&ce.push({key:"xpath by combination",value:e})}if(!ce.length){const a=je(e,t,n);a&&ce.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},Ue=(e,t,n,a,r=[],o=[])=>{ce=[],console.log(e);const l=e,s=l?.getRootNode?.(),i=s?.nodeType===Node.DOCUMENT_FRAGMENT_NODE,c=i?s:l?.ownerDocument||t,u=l.tagName,{attributes:f}=l,m=r.length>0?r:Array.from(f);if(We(m,l,c,n,a),o.length){const e=n||((e=[])=>e.some(e=>"index"===he(e)))(o),t=o.flatMap(e=>Pe(l,c,0,e));return ce=(e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value)||(t.add(e.value),0)))})(t.filter(e=>1===y(e.value,l,c))),$e(ce,e)}if(ce.length){const t=ce.length;for(let n=0;n<t;n++){let t=ce[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===y(t,e,c)&&ce.push({key:`${ce[n].key} regex`,value:t})}}return ce.length||i||(ce=Te(l,c,0,n)),$e(ce,n)},Fe={parseDOM:Ue,getTextXPath:qe,getUniqueClassName:Ve,attributesBasedXPath:Ye,addAllXPathAttributes:We,addRelativeXpaths:(e,t,n,a,r)=>{try{let o,l,s=[];if(ce=[],console.log(r),r)for(const t of r){const n=M(e,{name:t.name,value:t.value},a);console.log(n[0]||"");for(const e of n)e&&s.push(e)}if(e.textContent){let t=z(e,{name:"text",value:e.textContent});console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let r=0;r<s.length;r++)if(!ce.length){if(ze(e,t,a,s[r]),!ce.length&&(o||(o=Le(e.parentElement,t,e)),console.log(o),o&&(o.includes("@")||o.includes("text()")||o.includes(".="))&&o.match(/\//g)?.length-2<5)){const a=o+`/${s[r]}`,l=y(a,e,t);if(1===l)ce.push({key:"relative xpath by relative parent",value:a});else if(l>1&&n){const r=b(a,e,t,l);r&&1===y(r,e,t)&&ce.push({key:"relative xpath by relative parent "+(n?"index":""),value:r})}}if(!ce.length&&(l||(l=Ie(e,t,e)),l&&(l.includes("@")||l.includes("text()")||l.includes(".=")))){const a=l.replace(/^\/+/,""),o=`/${s[r]}/${a}`,i=y(o,e,t);if(1===i)ce.push({key:"relative xpath by relative child",value:o});else if(i>1&&n){const a=b(o,e,t,i);a&&1===y(a,e,t)&&ce.push({key:"relative xpath by relative parent "+(n?"index":""),value:a})}}if(1===ce?.length&&ce?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=qe(e,t,n,!1);a&&ce.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!ce.length){let o=_e(e.parentElement,t,e,a,s[r],n);o&&ce.push({key:"xpath by unique parent",value:o})}}return ce}catch(e){console.log(e)}},getXPathUsingAttributeAndText:je,getSiblingRelativeXPath:ze,getChildRelativeXpath:Ie,getParentRelativeXpath:Le,getUniqueParentXpath:_e,checkRelativeXpathRelation:Xe,buildAxesStrategyXpaths:Te};let He=[],Ge=[];const Be=/^[\S]+( [\S]+)*$/gi,Ze=(e,t,n,a,r,o,l,s=0,i=!1)=>{let c="";if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=o.length){const c=[],u=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=o.length;e++)c.unshift(e===o.length?o[o.length-e]:u[u.length-e]);const f=xt(`${l+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,r,i);if(f)return f}else{c=`//${l+(s?"]".repeat(s):"")}/${n}::${te(t,e[e.length-1])}`;let o=y(c,e[e.length-1],a);if(1===o)return[{key:`dynamic ${n}`,value:T(c)}];if(o>1&&r&&(c=b(c,e[e.length-1],a,o),c&&(o=y(c,e[e.length-1],a),1===o)))return[{key:`dynamic ${n} ${r?" index":""}`,value:T(c)}]}},Je=(e,t,n,a,r,o=!1,l=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=A(i)??i.ownerDocument,u=n.find(e=>e?.key?.includes("absolute"))?.value||X(s,s.ownerDocument),f=[],d=[];u.split("/").map(e=>f.push(e)),f.map(e=>d.push(e.replace(/\[([0-9]+)\]/gm,"")));const g=a.find(e=>e?.key?.includes("absolute"))?.value||X(i,i.ownerDocument),h=[],$=[];g.split("/").map(e=>h.push(e)),h.map(e=>$.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var y=0;y<f.length&&f[y]==h[y];y++);const N=[];for(let e=y-1;e<f.length;e++)f[e]&&N.push(d[e]);const b=[];for(let e="descendant"===r?y:y-1;e<h.length;e++)h[e]&&(b.length?b.push($[e]):b.push($[e].replace(/\[([0-9]+)\]/gm,"")));let x;if(Ge=(e=>{const t=e=>{const t=e.value||"",n=/(?:contains\s*\(\s*normalize-space\s*\(\s*\.\s*\)|normalize-space\s*\(\s*\.\s*\)|contains\s*\(\s*text\s*\(\s*\)|text\s*\(\s*\)|\.\s*=)/.test(t),a=/@/.test(t);return n&&!a?0:n?1:2};return[...e].sort((e,n)=>t(e)-t(n))})(a),e[e.length-2].textContent){if(Be.test(e[e.length-2].textContent)){const t=e[e.length-2],n=p(t),a=w(t,n),r=a||(/\s/.test(n.trim())?`normalize-space(.)=${v(E(n))}`:`.=${v(n)}`);x=D(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${r}]`:`${e[e.length-2].tagName}[${r}]`}else x=D(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${Q(e[e.length-2])})]`:`${e[e.length-2].tagName}[${Q(e[e.length-2])}]`;N[N.length-1]=x;const n=N.join("["),a=N.length-1,s=n;for(let n=0;n<Ge.length;n++){let i;if(i=Ge[n].value.startsWith("//")?Ge[n].value.substring(Ge[n].value.indexOf("//")+2):Ge[n].value,i){const n=Ze(e,i,r,c||t,o,b,s,a,l);if(n?.length)return n}}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(O(n,e[e.length-2])){let a=n.nodeValue;if(a){a=m(n.name,a);const s=n.name;x=D(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${v(a)}]`:`${e[e.length-2].tagName}[@${s}=${v(a)}]`,N[N.length-1]=x;const i=N.join("["),u=N.length-1,f=i;for(let n=0;n<Ge.length;n++){let a;a=Ge[n].value.startsWith("//")?Ge[n].value.substring(Ge[n].value.indexOf("//")+2):Ge[n].value;const s=Ze(e,a,r,c||t,o,b,f,u,l);if(s?.length)return s}}}for(const n of Array.from(e[e.length-2].attributes))if(O(n,e[e.length-2])){let a=n.nodeValue;if(a){a=m(n.name,a);const s=L(n,e[e.length-2]);if(s){x=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,N[N.length-1]=x;const n=N.join("["),a=N.length-1,i=n;for(let n=0;n<Ge.length;n++){let s;s=Ge[n].value.startsWith("//")?Ge[n].value.substring(Ge[n].value.indexOf("//")+2):Ge[n].value;const u=Ze(e,s,r,c||t,o,b,i,a,l);if(u?.length)return u}}}}}const k=N.join("["),S=N.length-1,C=xt(`${k+(S?"]".repeat(S):"")}`,b,e[e.length-1],e,t,r,o,l);if(C)return C},Ke=(e,t,n,a,r,o,l)=>{let s,i;console.log("getXpathRelationExpression",n);const c=[];try{s=a.filter(e=>!e?.key?.includes("absolute")).filter(t=>$t(t.value,e)),i=r.filter(e=>!e?.key?.includes("absolute"));for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const l=0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2),u=lt(s[a].value,e);let f=`//${u}/${n}::${te(l)}`;console.log("getXpathRelationExpression",f);const m=y(f,t,t.ownerDocument);if(m>1){const a=dt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=mt(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:T(r)}),c;const l=gt(u,n,t,i,t.ownerDocument);if(l)return c.push({key:`dynamic ${n}`,value:T(l)}),c;if(o){if(f=b(f,t,t.ownerDocument,m),f)return c.push({key:`dynamic ${n}${o?" index":""}`,value:T(f)}),c}else m>1&&(He.length?m<He[0].count&&(He.pop(),He.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m})):He.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m}))}else if(1===m){if(ot(l)){const a=dt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=mt(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:T(r)}),c}return c.push({key:`dynamic ${n}`,value:T(f)}),c}}if(!c.length){const a=dt(e,t,n,s,i);if(a.length)return c.push(...a),c;for(let a=0;a<s.length;a++){const r=lt(s[a].value,e),o=mt(r,e,t,n,i);if(o)return c.push({key:`dynamic ${n} bridge`,value:T(o)}),c}for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const u=`${0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(u.length>1){const r=lt(s[a].value,e),f=mt(r,e,t,n,i);if(f)return c.push({key:`dynamic ${n} bridge`,value:T(f)}),c;const m=xt(r,u,t,[e,t],t.ownerDocument,n,o,l);if(console.log("getXpathRelationExpression traverseXpath",m),m)return c.push(...m),c}}}}catch(e){console.log(e)}return c},Qe=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,et=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,tt=(e,t)=>nt(e,t)[0]||"",nt=(e,t)=>{const n=[];let a="";const r=e=>{e&&!n.includes(e)&&n.push(e)};for(const n of t){const t=et(n.value);if(t&&1===t.split(Qe).length){if(t===e.tagName||t===e.tagName.toLowerCase()){a=t;continue}r(te(t))}}for(const t of at){const n=e.getAttribute(t);if(!n)continue;const a=rt(t,n);a&&r(D(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`)}if(e.textContent){const t=Q(e);t&&r(D(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`)}const o=u(e,e.getAttribute("class"),e.getRootNode?.()??e.ownerDocument,!1);for(const t of o)r(D(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`);if(e.attributes)for(const t of Array.from(e.attributes))"class"!==t.name&&O(t,e)&&t.nodeValue&&r(D(e)?`*[local-name()='${e.tagName}' and @${t.name}=${v(m(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${v(m(t.name,t.nodeValue))}]`);return a&&r(a),r(D(e)?`*[local-name()='${e.tagName}']`:e.tagName),n},at=["aria-labelledby","aria-label","role","name","data-testid","data-test","data-qa","data-id","id"],rt=(e,t)=>{const n=m(e,t);return n?/\d/.test(n)?"":`@${e}=${v(n)}`:""},ot=e=>e.split(Qe).length>1||/\[\d+\]/.test(e),lt=(e,t)=>0!==e.indexOf("//")?te(e):te(e.substring(e.indexOf("//")+2)),st=e=>{const t=[];for(const n of at){const a=e.getAttribute(n);if(!a)continue;const r=rt(n,a);if(r){t.push(D(e)?`*[local-name()='${e.tagName}' and ${r}]`:`${e.tagName}[${r}]`);break}}return t},it=(e,t=6)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},ct=(e,t)=>{const n=rt(e,t);if(n)return n;const a=m(e,t);if("id"!==e||!a)return"";const r=a.match(/^(.+?)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),o=r?.[1]?.trim();return!o||o.length<=2||!/[a-zA-Z]/.test(o)?"":`contains(@${e},${v(o)})`},ut=(e,t,n,a,r,o,l)=>{let s=n.parentElement,i=0;for(;s&&s!==a&&i<6;){i++;for(const t of at){const a=s.getAttribute(t);if(!a)continue;const i=rt(t,a);if(!i)continue;const c=D(s)?`*[local-name()='${s.tagName}' and ${i}]`:`${s.tagName}[${i}]`,u=`//${te(e)}/${r}::${o}/descendant::${c}/descendant::${te(l)}`;if(1===y(u,n,n.ownerDocument))return u}s=s.parentElement}return""},ft=["title",...at],mt=(e,t,n,a,r)=>((e,t,n,a,r)=>{if("following"!==a&&"preceding"!==a)return"";const o=nt(n,r);if(!o.length)return"";const l=pt(`//${te(e)}`,t.ownerDocument)||t;let s=n.parentElement,i=0;for(;s&&i<6;)if(i++,l.compareDocumentPosition(s)&("following"===a?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)){for(const t of ft){const r=s.getAttribute(t);if(!r)continue;const l=rt(t,r);if(!l)continue;const i=D(s)?`*[local-name()='${s.tagName}' and ${l}]`:`${s.tagName}[${l}]`;for(const t of o){const r=`//${te(e)}/${a}::${i}/descendant::${te(t)}`;if(1===y(r,n,n.ownerDocument))return r}}s=s.parentElement}else s=s.parentElement;return""})(e,t,n,a,r)||((e,t,n,a,r)=>{if("following-sibling"!==a&&"preceding-sibling"!==a)return"";const o=nt(n,r);if(!o.length)return"";const l=it(t),s=it(n);for(const t of l){const r=st(t);if(r.length)for(const l of s){const s=st(l);if(!s.length)continue;const i="following-sibling"===a?t.nextElementSibling===l||Array.from(t.parentElement?.children||[]).indexOf(l)>Array.from(t.parentElement?.children||[]).indexOf(t):t.previousElementSibling===l||Array.from(t.parentElement?.children||[]).indexOf(l)<Array.from(t.parentElement?.children||[]).indexOf(t);if(t.parentElement&&t.parentElement===l.parentElement&&i)for(const t of r)for(const r of s)for(const l of o){const o=`//${te(e)}/ancestor-or-self::${t}/${a}::${r}/descendant-or-self::${te(l)}`;if(1===y(o,n,n.ownerDocument))return o}}}return""})(e,t,n,a,r)||((e,t,n,a,r)=>{if("child"!==a)return"";const o=nt(n,r);if(!o.length)return"";const l=it(n).filter(e=>e.parentElement===t);for(const t of l){const a=st(t);if(a.length)for(const t of a)for(const a of o){const r=`//${te(e)}/child::${t}/descendant-or-self::${te(a)}`;if(1===y(r,n,n.ownerDocument))return r}}return""})(e,t,n,a,r),dt=(e,t,n,a,r)=>"ancestor"!==n&&"ancestor-or-self"!==n?[]:bt(e,t,n,a,r,!1),gt=(e,t,n,a,r)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";for(const o of a){const a=et(o.value);if(!a||a.split(Qe).length>1||/\[\d+\]/.test(a))continue;const l=`//${e}/${t}::${te(a)}`;if(1===y(l,n,r))return l}return""},ht=(e,t,n,a)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";const r=nt(n,[...Ue(n,n.ownerDocument,!1,!1)||[],...ne(n,n.ownerDocument,!0)||[],{key:"tag",value:n.tagName}]);if(!r.length)return"";let o=n.parentElement,l=0;for(;o&&l<10;){l++;for(const l of at){const s=o.getAttribute(l);if(!s)continue;const i=ct(l,s);if(!i)continue;const c=D(o)?`*[local-name()='${o.tagName}' and ${i}]`:`${o.tagName}[${i}]`;for(const o of r){const r=`//${e}/${t}::${c}/descendant::${te(o)}`;if(1===y(r,n,a))return r}}o=o.parentElement}return""},pt=(e,t)=>{try{const n=t.evaluate(e,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return n instanceof Element?n:null}catch{return null}},$t=(e,t)=>{const n=et(e);if(!n)return!1;try{const e=t.ownerDocument.evaluate(`//${te(n)}`,t.ownerDocument,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let a=e.iterateNext();for(;a;){if(a===t)return!0;a=e.iterateNext()}}catch{return!1}return!1},yt=e=>{const t=e.getAttribute("fill"),n=e.getAttribute("stroke");if(/\d/.test(t||"")||/\d/.test(n||""))return"";const a=t?`@fill=${v(t)}`:n?`@stroke=${v(n)}`:"";return a?`*[local-name()='${e.tagName.toLowerCase()}' and ${a}]`:""},vt=(e,t,n)=>{const a=t.getAttribute("fill"),r=t.getAttribute("stroke"),o=Array.from(e.querySelectorAll(t.tagName.toLowerCase())).slice(0,30);let l=0;for(const e of o){if(a&&e.getAttribute("fill")!==a||!a&&r&&e.getAttribute("stroke")!==r)continue;const t=e.closest(n.tagName.toLowerCase());if(t&&(l++,t!==n||l>1))return!1}return 1===l},Nt=(e,t,n,a,r)=>{const o=Array.from(n.querySelectorAll("path,use,circle,rect,polygon,polyline,line")).slice(0,25);if(!o.length)return"";const l=[...(s=a,u(s,s.getAttribute("class"),s.getRootNode?.()??s.ownerDocument).map(e=>`${s.tagName.toLowerCase()}[${e}]`)),a.tagName];var s;for(const t of o){const o=yt(t);if(o&&vt(a,t,n))for(const t of l)return`//${te(e)}/${r}::${t}/descendant::${o}/ancestor::${n.tagName.toLowerCase()}`}return""},bt=(e,t,n,a,r,o)=>{const l=[],s=((e,t)=>{let n=e;for(;n;){if(n.contains(t))return n;n=n.parentElement}return null})(e,t);if(!s||s===t)return l;const i=D(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let r=t;for(;r&&r!==e;){const e=r===t?tt(t,n):D(r)?`*[local-name()='${r.tagName}']`:r.tagName;a.unshift(e),r=r.parentElement}return r===e?a.join("/"):""})(s,t,r);if(!c)return l;const u=c.split(Qe).length>1?tt(t,r):"",f=u?((e,t)=>{let n=e,a=0;const r=[],o=new Set(["SECTION","FIELDSET","FORM","ARTICLE","MAIN"]);for(;n&&n.contains(t)&&a<6;){a++;for(const e of at){const t=n.getAttribute(e);if(!t)continue;const l=rt(e,t);if(!l)continue;const s=D(n)?`*[local-name()='${n.tagName}' and ${l}]`:`${n.tagName}[${l}]`,i=(o.has(n.tagName)?100:0)+("data-testid"===e?20:0)-a;r.push({nodeTest:s,score:i});break}n=n.parentElement}return r.sort((e,t)=>t.score-e.score)[0]?.nodeTest||""})(s,t):"";for(const e of a){const a=et(e.value);if(!a)continue;if(f){const e=`//${te(a)}/${n}::${f}/descendant::${te(u)}`;if(1===y(e,t,t.ownerDocument))return l.push({key:`dynamic ${n} bridge`,value:T(e)}),l}let r=u?`//${te(a)}/${n}::${i}/descendant::${te(u)}`:`//${te(a)}/${n}::${i}/${c}`,m=y(r,t,t.ownerDocument);const d=Nt(a,0,t,s,n);if(d)return l.push({key:`dynamic ${n} icon bridge`,value:T(d)}),l;if(1===m)return l.push({key:`dynamic ${n} bridge`,value:T(r)}),l;if(u&&m>1){const e=ut(a,0,t,s,n,i,u);if(e)return l.push({key:`dynamic ${n} bridge`,value:T(e)}),l;if(r=`//${te(a)}/${n}::${i}/${c}`,m=y(r,t,t.ownerDocument),1===m)return l.push({key:`dynamic ${n} bridge`,value:T(r)}),l}if(m>1&&o&&(r=b(r,t,t.ownerDocument,m),m=r?y(r,t,t.ownerDocument):0,r&&1===m))return l.push({key:`dynamic ${n} bridge index`,value:T(r)}),l}return l},xt=(e,t,n,a,r,o,l,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${o}::${te(s)}`;const c=y(i,n,r);if(1===c)return[{key:`dynamic ${o}`,value:T(i)}];if(c>1&&l&&(i=b(i,a[a.length-1],r,c),i))return[{key:`dynamic ${o}${l?" index":""}`,value:T(i)}]}else for(let s=1;s<=t.length;s++){const c=Et(t.slice(t.length-s,t.length).join("/"),n);for(const t of c){i=`//${e}/${o}::${te(t)}`;const s=y(i,n,r);if(1===s){if(t.split(Qe).length>1||/\[\d+\]/.test(t)){const t=ht(e,o,n,r);if(t)return[{key:`dynamic ${o}`,value:T(t)}]}return[{key:`dynamic ${o}`,value:T(i)}]}if(s>1){const t=gt(e,o,n,Ue(n,n.ownerDocument,!1,!1)||[],r);if(t)return[{key:`dynamic ${o}`,value:T(t)}];const c=ht(e,o,n,r);if(c)return[{key:`dynamic ${o}`,value:T(c)}];if(l&&(i=b(i,a[a.length-1],r,s),i))return[{key:`dynamic ${o}${l?" index":""}`,value:T(i)}]}}}},Et=(e,t)=>{const n=t.getAttribute("class")||"",a=u(t,n,t.getRootNode?.()??t.ownerDocument);if(!a.length)return[e];const r=`${t.tagName}[@class=${v(n)}]`;return e.endsWith(r)?a.map(n=>{const a=`${t.tagName}[${n}]`;return`${e.slice(0,-r.length)}${a}`}):[e]},wt={findRelativeXpath:(e,t,n,a,r,o,l=!1,s=null)=>{let i=[];const c=s||[],u=(o,s)=>{let c=[];c="descendant"===o||"descendant-or-self"===o?Je([e,t],n,a,r,o,s,l)||[]:Ke(e,t,o,a,r,s,l)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,o);return i},getDescendantXpath:Je,getAncestorBridgeXpath:bt,getXpathRelationExpression:Ke,getTraverseXpathExpression:xt,getReferenceElementXpath:e=>{let t=[];t=Ue(e,e.ownerDocument,!1,!1);const n=ne(e,e.ownerDocument,!1);if(n?.length&&(t=t?.length?t.concat(n):n),t?.length){let n=Ue(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:N(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=Ue(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:N(e.value)}:{key:"",value:e.value});t?.length||(t=[{key:"",value:_(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:_(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&re(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:N(e.value)}:{key:"",value:e.value}));const a=Array.from(e.children||[]).map(t=>{const n=p(t)?.trim();if(!n||n!==p(e)?.trim())return null;const a=w(t,n),r=a||(/\s/.test(n)?`normalize-space(.)=${v(E(n))}`:`.=${v(n)}`);return{key:"reference child text",value:`${t.tagName}[${r}]`}}).filter(e=>!!e);a.length&&(t=a.concat(t));const r=X(e,e.ownerDocument);return t=t.filter(e=>e.value!==r),t.push({key:"absolute xpath",value:r.slice(1)}),t},getSmartRelations:(e,t)=>{const n=e.compareDocumentPosition(t),a=[],r=[],o=[];n&Node.DOCUMENT_POSITION_CONTAINS&&a.push("ancestor","ancestor-or-self","parent"),n&Node.DOCUMENT_POSITION_CONTAINED_BY&&a.push("child"),e.parentElement===t.parentElement&&a.push("following-sibling","preceding-sibling"),n&Node.DOCUMENT_POSITION_FOLLOWING&&r.push("following"),n&Node.DOCUMENT_POSITION_PRECEDING&&r.push("preceding"),o.push("descendant","descendant-or-self");const l=[...a,...r,...o];return[...new Set(l)]}};let kt=[];const St=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},At=(e,t="single")=>{const n=[],a=e.getRootNode();try{const r=Ct(e);if(r&&St(r,e,a)&&(n.push({key:"cssSelector by id",value:r}),"single"===t))return n;const o=Tt(e);o&&St(o,e,a)&&n.push({key:"cssSelector by class",value:o});const l=Dt(e);l&&n.push({key:"cssSelector by name",value:l})}catch(e){console.error(e)}return n},Ct=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if(e.id&&!g(e.id)){t+=`#${CSS.escape(e.id)}`,a.unshift(t);break}{let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}a.unshift(t),e=e.parentElement}return a.join(" > ")},Rt=new Set(["id","class","style"]);function Ot(e){return Array.from(e.attributes).filter(e=>!Rt.has(e?.name?.toLowerCase())&&e.value&&!g(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const Dt=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.getRootNode(),a=e.tagName.toLowerCase();if("style"===a||"script"===a)return;const r=Ot(e);for(const t of r){const r=`${a}${t}`;if(St(r,e,n))return r}},Tt=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=e.tagName.toLowerCase();if(n.includes("style")||n.includes("script"))return;const a=[];for(;e?.nodeType===Node.ELEMENT_NODE;){let t=e.nodeName?.toLowerCase();if("string"!=typeof e.className||!e.className||g(e.className)||kt?.find(t=>t.element===e&&"class"===t.attributeName)){let n=e,a=1;if(n.previousElementSibling)for(;n=n.previousElementSibling;)n.nodeName?.toLowerCase()===t&&a++;1!==a&&(t+=`:nth-of-type(${a})`),1===a&&n?.parentElement?.childElementCount>1&&(t+=`:nth-child(${a})`)}else if(e.classList.remove("marked-element-temp"),e.classList.remove("removePointers"),e.className){t+=`.${e.className.trim().replace(/\s+/g,".")}`,a.unshift(t);break}a.unshift(t),e=e.parentElement}return a.join(" > ")},Pt={parseCssSelectors:At,getIdCssPath:Ct,getAttributeCssPath:Dt,getClassCssPath:Tt,getAbsoluteCssPath:e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=[];for(;e&&e.nodeType===Node.ELEMENT_NODE;){const t=e.tagName.toLowerCase();if("style"===t||"script"===t)return;let a=t;const r=e.parentNode;if(r){const t=Array.from(r.children).filter(t=>t.tagName===e.tagName);t.length>1&&(a+=`:nth-of-type(${t.indexOf(e)+1})`)}n.unshift(a),e=e.parentElement}return n.join(" > ")}},Xt=(e,t,n)=>{const a=ae(e);if(Wt(t,a)===n)return!0;if(function(e){return/\[(?:\s*\.|\s*contains\s*\(\s*\.|\s*normalize-space\s*\(\s*\.)/.test(e)}(a)){const e=t.evaluate(a,t,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let t=0;t<e.snapshotLength;t++)if(e.snapshotItem(t)===n)return!0}return!1},_t=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return zt(e.body,t)},Lt=(e,t,n)=>_t(t,e)===n,It=e=>e.name?.toLowerCase().includes("cssselector")??!1,zt=(e,t)=>{const n=Array.from(e.querySelectorAll("*"));try{for(let e=0;e<n.length;e++)if(n[e].shadowRoot){const{shadowRoot:a}=n[e];if(a){const e=zt(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},Mt=e=>e?.id||null,jt=e=>e.className||null,Yt=e=>e.textContent?.trim()||null,Vt=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},qt=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function Wt(e,t){const n=e.defaultView;if(!n)return null;return(new n.XPathEvaluator).evaluate(t,e,null,n.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}function Ut(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),r=n.defaultView;if(!r)return null;if(!e.includes("dynamic")){const t=new r.XPathEvaluator;if(t.evaluate(a,n,null,r.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,r.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue?(a=e,a):(console.error("Complete Locator is Invalid:",e),a=e,a)}console.error("Source Locator Not Found:",a)}}return null}const Ft=(e,t)=>{const n=t.querySelectorAll("script, style, link[rel='stylesheet'], meta, noscript, embed, object, param, source, svg");n&&n.forEach(e=>{e.remove()});const a=new Set;let r=[];function o(e,t={}){const n=e?.value,o=t.value??e?.value,l={name:t.name??e?.name,type:t.type??e?.type,value:t.value??e?.value,reference:t.reference??e?.reference,status:t.status??e?.status,isRecorded:t.isRecorded??e?.isRecorded},s="Y"===e?.isSelfHealed;l.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(l.name,n,o),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),r.push(e))}(l)}function l(e,t,n){if(It(t))return _t(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+le(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=le(n);return e.querySelector(`[name="${t}"]`)}if("tagName"===t.name)return e.querySelector(n);if("linkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.trim()===n)||null;if("partialLinkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.includes(n))||null;if(!t.name.includes("xpath")&&!n.startsWith("//")||t.type.match("dynamic"))return e.querySelector(n);{const a=Wt(e,ae(n));return a&&o(t,{value:n,isRecorded:String(t.isRecorded).includes("N")?"N":"Y"}),a}}function s(e,t,n){const a=e.querySelectorAll("iframe");for(const e of a)try{const a=e.contentDocument||e.contentWindow?.document;if(!a)continue;const r=l(a,t,n);if(r)return r}catch{continue}return null}const i=(e,t,n)=>{if(!e)return null;let a=e.trim();return a&&"null"!==a.toLowerCase()?(a=a.replace(/\\"/g,'"').replace(/\\'/g,"'"),a=a.replace(/^['"](.+?)['"]$/,"$1"),a=a.replace(/''/g,"'"),a=a.replace(/\[@(id|name)=['"]{2}(.+?)['"]{2}\]/g,"[@$1='$2']"),"id"!==t&&"name"!==t||(a=a.replace(/['"]/g,"").trim()),"xpath"!==t||"Y"!==n||e.startsWith("//")?!a||/^['"]{2}$/.test(a)?null:a:null):null};e:for(const n of e.locators)try{String(n.isRecorded||"");const c=e.locators.filter(e=>"N"===e.isRecorded);if(c.length>0)for(const e of c)o(e);const u=String(n.value||n.type||"");if(u.includes("dynamic")||u.match("dynamic")||u.includes("{")||u.includes("}")){o(n);continue}if(e.isShared.includes("Y"))break e;try{let c=null;const u=n.value.split(">>>");for(const e of u){if(!t){console.error("Element not found at:",e);break}const a=e.trim();if(c=l(t,n,a),c||(c=s(t,n,a)),c||(c=zt(t.body,a)),!c){console.error("Element not found at:",a);break}}const f=(e,t)=>{const n=`${e}:${t}`;return a.has(n)};if(c){const n=e.locators.filter(e=>"xpath"===e.name&&e.value),a=e.locators.filter(e=>It(e)&&e.value);for(const e of n)Xt(e.value,t,c)&&o(e,{isSelfHealed:null});for(const e of a)Lt(e.value,t,c)&&o(e,{isSelfHealed:null});const l=r.filter(e=>"xpath"===e.name&&e.value),s=new Set(l.map(e=>oe(e.value))),u=[],m=Mt(c);if(m&&!f("id",m)&&!g(m)){const n=e.locators.find(e=>"id"===e.name);se(t,"id",m,c)&&(u.push("id"),o(n,{name:"id",type:"static",isRecorded:"Y",value:m}))}const d=c.tagName;if(d&&!f("tagName",d)){const n=e.locators.find(e=>"tagName"===e.name);se(t,"tagName",d,c)&&(u.push("tagName"),o(n,{name:"tagName",type:"static",isRecorded:"Y",value:d}))}const h=Yt(c);if(h&&!g(h)){const n=e.locators.find(e=>"linkText"===e.name);se(t,"linkText",h,c)&&(u.push("linkText"),o(n,{name:"linkText",type:"static",isRecorded:"Y",value:h}))}const p=Vt(c);if(p&&!f("name",p)&&!g(p)){const n=e.locators.find(e=>"name"===e.name);se(t,"name",p,c)&&(u.push("name"),o(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=jt(c);if($&&""!==$.trim()&&!$.includes(" ")&&!f("className",$)&&!g($)){const n=e.locators.find(e=>"className"===e.name);se(t,"className",$,c)&&(u.push("className"),o(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}At(c,"single").forEach(e=>{e.value&&!f("cssSelector",e.value)&&o(void 0,{name:"cssSelector",value:e.value,type:"static",isRecorded:"Y"})});const y=Array.from(c.attributes).filter(e=>!u.includes(e.name));let v=[];try{v=Ue(c,t,!1,!0,y)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==v?.length){const e=n.filter(e=>!Xt(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=oe(t.value);if(s.has(n))continue;const r=v.find(e=>e.value&&oe(e.value)===n);r?.value&&(o(t,{name:"xpath",value:r.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}if(a<e.length)for(const t of v){if(a>=e.length)break;if(!t.value)continue;const n=oe(t.value);s.has(n)||(o(t,{name:"xpath",value:t.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}}for(const n of e.locators)try{for(const a of e.locators)if(a.value)for(const e of qt)if(a.value.includes(e)){const r=Ut(a.value,e,t);if(r){o(a,{name:"xpath",value:r,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(r.length<5){const e=[{name:"id",value:Mt(c)},{name:"name",value:Vt(c)},{name:"className",value:jt(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:Yt(c)}];for(const n of e){if(r.length>4)break;const{name:e,value:a}=n;a&&(g(a)||f(e,a)||"className"===e&&a.includes(" ")||se(t,e,a,c)&&o(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}r.length<5&&At(c,"multiple").forEach(e=>{r.length>4||e.value&&(f("cssSelector",e.value)||se(t,"cssSelector",e.value,c)&&o(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const N=r.map(e=>({...e,value:i(e.value,e.name,e.isRecorded)})),b=[{name:`${e.name}`,desc:`${e.desc}`,type:`${e.type}`,locators:N.filter(e=>null!=e?.value&&""!==e.value),isShared:`${e.isShared}`,projectId:`${e.projectId}`,projectType:`${e.projectType}`,isRecorded:`${e.isRecorded}`,folder:`${e.folder}`,parentId:`${e.parentId}`,parentName:`${e.parentName}`,platform:`${e.platform}`,licenseId:`${e.licenseId}`,licenseType:`${e.licenseType}`,userId:`${e.userId}`}];return b}}catch(e){console.error("Error processing locator:",n,e);continue}}catch(e){console.error("Error processing locator:",n,e);continue}return null};const Ht={getOptimalClassChain:function e(t,n,a){try{if(!n||1!==n.nodeType||!n.tagName||"XCUIElementTypeApplication"===n.tagName)return"";const r=n.tagName,o=["name","label","value"];for(const e of o){const o=a.find(t=>t.name===e);if(!o)continue;let l=o.value;if(!l)continue;if(l=l.trim().replace(/\s+/g," "),g(l))continue;const s=`//${r}[@${e}="${l}"]`;let i=0;try{i=y(s,n,t)}catch(e){console.log(e);continue}const c=/\s/.test(l);if(1===i)return c?`/${r}[\`${e} CONTAINS "${l}"\`]`:`/${r}[\`${e} == "${l}"\`]`;if(i>1&&n.parentElement){const t=Array.from(n.parentElement.children).filter(e=>e.tagName===r).indexOf(n)+1;return c?`/${r}[\`${e} CONTAINS "${l}"\`][${t}]`:`/${r}[\`${e} == "${l}"\`][${t}]`}}let l=`/${r}`;if(n.parentElement){const e=Array.from(n.parentElement.children).filter(e=>e.tagName===r);if(e.length>1){l+=`[${e.indexOf(n)+1}]`}}return e(t,n.parentElement,a)+l}catch(e){return console.log(`Unable to generate optimal -ios class chain : ${JSON.stringify(e)}`),null}},getOptimalPredicateString:function(e,t,n){try{if(!t?.tagName||1!==t?.nodeType||"XCUIElementTypeApplication"===t?.tagName)return"";let a=[],r=[];for(let o of n){const n=o.value,l=o.name;if(0!==n.length&&(n&&!g(n))){a.push(`@${l}="${n}"`);const o=`//*[${a.join(" and ")}]`;let s;r.push(`${l} == "${n}"`);try{s=y(o,t,e)}catch(e){console.log(e);continue}if(1===s)return r.join(" AND ")}}}catch(e){console.log(`The most optimal '-ios predicate string' could not be determined because an error was thrown: '${JSON.stringify(e,null,2)}'`)}return null}},Gt=()=>({xpath:Fe,referenceXpaths:wt,xpathUtils:ie,getElementsFromHTML:Ft,cssSelectors:Pt,iosSelectors:Ht});exports.createXPathAPI=Gt,exports.default=Gt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/^[\S]+( [\S]+)*$/i;let t=new WeakMap;const n=e=>{e?(e=>{const t=[],n=e=>{e&&!t.includes(e)&&t.push(e)};n(e);const a=e.getRootNode?.();return(a instanceof Document||a instanceof ShadowRoot)&&n(a),n(e.nodeType===Node.DOCUMENT_NODE?e:e.ownerDocument),t})(e).forEach(e=>{t.delete(e)}):t=new WeakMap},a=(e,n)=>{const{owner:a,contextNode:r}=(e=>{const t=9===e.nodeType?e:e.ownerDocument||document;return{owner:t,contextNode:1===e.nodeType||9===e.nodeType||11===e.nodeType?e:t}})(n);let o=t.get(r);o||(o=new Map,t.set(r,o));const l=o.get(e);if(l)return l;const s=a.evaluate(e,r,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),i={first:s.iterateNext(),second:s.iterateNext()};return o.set(e,i),i};let r=new Map,o=[];const l=new WeakMap,s=new WeakMap;let i;const c=new Set(["marked-element-temp","marked-element","mark-successfully","flntooltip","flntooltip-bottom","fln-shield","removePointers"]),u=new Set(["flntooltip","flntooltip-bottom","fln-shield"]),f=/^(?:(?:ng|ion)-(?:pristine|dirty|valid|invalid|touched|untouched|pending|submitted|focused)|(?:item-)?has-(?:focus|value)|ng-star-inserted|hydrated|md|ios)$/,m=e=>(e||"").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!c.has(e)).sort(),g=e=>/\d/.test(e||""),d=e=>f.test(e),h=(e,t,n,a=!1)=>{const r=m(t),o=p(e,t,a);return o.length?1===r.length&&1===o.length?[`@class=${S(o[0])}`]:o.map(t=>{const a=x(`contains(@class,${S(t)})`,I(e),e.tagName.toLowerCase());return{token:t,count:K(a,e,n)}}).sort((e,t)=>e.token.length!==t.token.length?e.token.length-t.token.length:e.count-t.count).map(({token:e})=>`contains(@class,${S(e)})`):[]},p=(e,t,n=!1)=>{const a=s.get(e);return m(t).filter(e=>!(a?.has(e)||d(e)||!n&&g(e)))},$=new Set(["data-testid","data-test-id","data-test","data-cy","testid"]),y=(e,t)=>t?"class"===e||"className"===e?m(t).join(" "):t.replace("removePointers","").trim():"",v=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(I(e.target)&&e.oldValue?.trim()===e.target.classList.value?.trim())return!0;const t=m(e.oldValue),n=m(e.target.getAttribute("class"));return t.join(" ")===n.join(" ")},N=e=>(e||"").split(/\s+/).some(e=>u.has(e)),b=e=>/\d/.test(e),x=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,E=e=>{const t=e?.textContent;return t},w=e=>e?.childNodes[0]?.nodeValue||"",k=(e,t,n,r=!1)=>{try{if(_(n)){const{owner:a,contextNode:o,cloneElement:l,cloneElements:s}=L(n,t),i=a.evaluate(e,o,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),c=i.iterateNext(),u=i.iterateNext();if(!c)return 0;if(!u)return c===l?1:0;if(r&&Array.isArray(t)){let e,t=0;if(s.includes(c)&&t++,s.includes(u)&&t++,2===t)return 2;for(;e=i.iterateNext();)if(s.includes(e)&&(t++,2===t))return 2;return 0}return 2}const{first:o,second:l}=a(e,n);if(!o)return 0;if(!l)return o===t?1:0;if(r&&Array.isArray(t)){let a=0;if(t.includes(o)&&a++,t.includes(l)&&a++,2===a)return 2;const r=(9===n.nodeType?n:n.ownerDocument).evaluate(e,n,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let s;for(;s=r.iterateNext();)if(t.includes(s)&&(a++,2===a))return 2;return 0}return 2}catch(t){return console.error(`Error evaluating XPath: ${e}`,t),0}},S=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},A=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let r="";for(let e=0;e<a.length;e++)r+=a[e];const o=r.length+2;let l=e.slice(0,e.length-o);return l=l.startsWith("(")&&l.endsWith(")")?l.slice(1,-1):e,l},C=(e,t,n,a)=>{try{const r=9===n.nodeType?n:n.ownerDocument;let o=0;if(a){if(1===k(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===k(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const l=r.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s=null;for(;s=l.iterateNext();)if(o++,s.isSameNode(t))return 1===k(`${e}[${o}]`,t,n)?`${e}[${o}]`:1===k(`(${e})[${o}]`,t,n)?`(${e})[${o}]`:void 0}catch(e){console.log(e)}},R=e=>(e=(e=(e=>(e&&=e.split("\n")[0].length>0?e.split("\n")[0]:e.split("\n")[1],e))(e)).split(/[^\u0000-\u00ff]/).reduce((e,t)=>e.length>t.length?e:t,"").trim()).split("/")[0].trim(),O=e=>e?e.replace(/\s\s+/g," ").trim():e,T=(e,t)=>{const n=O((t||"").trim());if(!e.children.length||n.length<=50)return"";const a=n.split(/\s+/).slice(0,3).join(" ");return a.length>2?`contains(normalize-space(.),${S(a)})`:""},D=e=>{const t=O((e||"").trim());if(!t||!g(t))return{prefix:t,fragment:t};const n=t.split(/[0-9]/)[0].replace(/[₹$€£¥₫₽₩₦₱₲₴₵₡₭₮₺฿៛]+/g,"").trim(),a=n.split(/[^a-zA-Z]+/).map(e=>O(e).trim()).filter(e=>e.length>2&&/[a-zA-Z]/.test(e)).join(" ").trim();return{prefix:n.length>2&&/[a-zA-Z]/.test(n)?n:"",fragment:a.length>2?a:""}},P=e=>D(e).fragment,X=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},_=e=>e?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e,L=(e,t)=>{const n=e.ownerDocument.implementation.createHTMLDocument("shadow-xpath"),a=n.createElement("div");a.innerHTML=e.innerHTML,n.body.appendChild(a);const r=t=>{if(!(t&&t instanceof e.ownerDocument.defaultView.Element))return null;const n=((e,t)=>{const n=[];let a=t;for(;a&&a.parentElement;){const e=a.parentElement;n.unshift(Array.from(e.children).indexOf(a)),a=e}return a&&a.parentNode===e?(n.unshift(Array.from(e.children).indexOf(a)),n):null})(e,t);return n?((e,t)=>{let n=e;for(const e of t){const t=n.children.item(e);if(!t)return null;n=t}return n})(a,n):null},o=Array.isArray(t)?t.map(e=>r(e)).filter(Boolean):[],l=Array.isArray(t)?null:r(t??null);return{owner:n,contextNode:a,cloneElement:l,cloneElements:o}},z=(e,t,n)=>{const a=y(e.name,e.value);if(!a||"boolean"==typeof e?.value)return!1;if(["true","false","on","off","flntooltip","flutter-highlight-overlay"].some(e=>e===a))return!1;if(["style","locator-data-tooltip","value"].some(t=>t===e.name))return!1;if("class"===e.name||"className"===e.name){const n=s.get(t);return m(e.value).filter(e=>!n?.has(e)&&!d(e)&&!g(e)).length>0}const r=o?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return console.log("[ff-dom] checking attribute",o,{attribute:e,isModified:r}),!r&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(l=e.name,i=a,(!$.has(l.toLowerCase())||!(e=>/(?:^|[-_:])\d{4,}(?:$|[-_:])/.test(e))(i))&&("class"===e.name||!g(a)))));var l,i},I=e=>e instanceof SVGElement,M=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,j=(t,n,a,r,o,l)=>{if(r){const{tagName:s}=t;let i,c="";const u=[];let f;const m=a.startsWith("@"),d="."===a||"text()"===a,p=d?".":a,$=d&&/\s/.test(r.trim()),y=d?P(r):r,v=d&&g(r)?y:r,N=d?T(t,v):"";if("@class"===a){for(const e of h(t,r,n))if(f=x(e,I(t),t.tagName.toLowerCase()),i=k(f,t,n),1===i&&!o)return f;return}if(d&&g(r)&&!y)return;if(r&&(!m||!b(r))&&(f=N?x(N,I(t),t.tagName.toLowerCase()):$?x(`normalize-space(${p})=${S(O(v)).trim()}`,I(t),t.tagName.toLowerCase()):e.test(r)?`//${s}[${a}=${S(v)}]`:x(`normalize-space(${a})=${S(O(v)).trim()}`,I(t),t.tagName.toLowerCase()),i=k(f,t,n),1===i&&!o))return f;if(m&&g(r))return;if(r&&l){const l=r.split(" ");if(l?.length)if(1===l.length){const u=[...new Set(l[0].match(/([^0-9]+)/g))];if(u?.length>=1&&u[0]&&O(u[0].trim())?.length>1&&r.startsWith(u[0])&&(c=e.test(u[0])?`starts-with(${a},${S(u[0]).trim()})`:`starts-with(${a},${S(O(u[0])).trim()})`),u?.length>1&&u[u.length-1]&&O(u[u.length-1].trim())?.length>1&&r.endsWith(u[u.length-1])&&(c=e.test(u[u.length-1])?`ends-with(${a},${S(u[u.length-1]).trim()})`:`ends-with(${a},${S(O(u[u.length-1])).trim()})`),c?.length&&(f=I(t)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=k(f,t,n),1===i&&!o))return f}else{const u=l.length%2==0?l.length/2:l.length%2,m=l.slice(0,u).join(" ");let g=[...new Set(m.match(/([^0-9]+)/g))];if(g?.length&&g[0]&&O(g[0].trim())?.length&&r.startsWith(g[0])&&(c=e.test(g[0])?`starts-with(${a},${S(g[0]).trim()})`:`starts-with(${a},${S(O(g[0])).trim()})`),c?.length&&(f=I(t)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=k(f,t,n),1===i&&!o))return f;const d=l.slice(u,l.length-1).join(" ");if(g=[...new Set(d.match(/([^0-9]+)/g))],g?.length&&g[0]&&O(g[0].trim())?.length>3&&r.endsWith(g[0])&&(c=e.test(g[0])?`ends-with(${a},${S(g[0]).trim()})`:`ends-with(${a},${S(O(g[0])).trim()})`),c?.length&&(f=I(t)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=k(f,t,n),1===i&&!o))return f}}if(r&&l&&b(r)){const l=[...new Set(r.match(/([^0-9]+)/g))];if(l?.length)for(let t=0;t<l?.length;t++)l[t]&&O(l[t].trim())?.length>1&&(e.test(l[t])?u.push(`contains(${a},${S(l[t].trim()).trim()})`):u.push(`contains(${a},${S(O(l[t])).trim()})`));if(u?.length&&(f=I(t)?`//*[local-name()='${s}' and ${u.join(" and ")}]`:`//${s}[${u.join(" and ")}]`,i=k(f,t,n),1===i&&!o))return f}if(f=I(t)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=k(f,t,n),1===i&&!o)return f}},Y=(e,t)=>{try{if(!e)return"";let n=I(e)?`/*[local-name()='${e.tagName}']`:`/${e.tagName}`;if(e.parentElement){const t=Array.prototype.slice.call(e.parentElement.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}else if(e instanceof HTMLElement&&e.offsetParent){const t=Array.prototype.slice.call(e.offsetParent.children,0).filter(t=>t.tagName===e.tagName);if(t.length>1){n+=`[${t.indexOf(e)+1}]`}}return Y(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},V=(e,t,n,a=!1,o)=>{try{if(r.has(e))return r.get(e);const l=[];let s=e;for(;s;){let r="",i=!1,c=e===s?o??s.attributes:s.attributes;for(const e of Array.from(c))if(z(e,s)){const a=y(e.name,e.nodeValue),o=e.name;for(const e of se(s,o,a)){r=e;let a=0;if(a=k(r,s,t),1===a){l.unshift(M(r)),i=!0;break}if(a>1&&n&&(r=C(r,s,t,a),r)){l.unshift(M(r)),i=!0;break}}}if(s.textContent)if(!a||a&&!b(s.textContent)){let e=new RegExp(/^[\S]+( [\S]+)*$/gi);const a=w(s),o=T(s,a);r=o?x(o,I(s),s.tagName||"*"):e.test(s.textContent)?I(s)?`//*[local-name()='${s.tagName}' and .=${S(a)}]`:`//${s.tagName||"*"}[.=${S(a)}]`:I(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${S(a)}]`:`//${s.tagName||"*"}[normalize-space(.)=${S(a)}]`;let l=k(r,s,t);if(1===l)return r;if(l>1&&n)return r=C(r,s,t,l),r}else{let e=[];const a=[...new Set(w(s).match(/([^0-9]+)/g))];let o=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&O(a[t].trim())&&(o.test(a[t])?e.push(`contains(.,${S(a[t].trim()).trim()})`):e.push(`contains(.,${S(O(a[t])).trim()})`));if(e?.length){r=I(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=k(r,s,t);if(1===a)return r;if(a>1&&n)return r=C(r,s,t,a),r}}if(i)break;{let e=I(s)?`/*[local-name()='${s.tagName}']`:`/${s.tagName}`;if(s.parentElement){const t=Array.from(s.parentElement.children).filter(e=>e.tagName===s.tagName);if(t.length>1){e+=`[${t.indexOf(s)+1}]`}}l.unshift(e)}s=s.parentElement}const i=`${l.join("")}`;return r.set(e,i),i}catch(e){return console.log(e),null}},q=(t,n)=>{const a=[];let r="";if(t&&"function"!=typeof t.nodeValue){if("class"===t.name){const e=n.getRootNode?.()??n.ownerDocument,a=h(n,t.value,e);for(const e of a)if(r=I(n)?`//*[local-name()='${n.tagName}' and ${e}]`:`//${n.tagName}[${e}]`,r)return r;return}if(b(t.value))return;const o=[...new Set(t.value.match(/([^0-9]+)/g))];if(o?.length)for(let n=0;n<o?.length;n++)o[n]&&O(o[n].trim())?.length>2&&(e.test(o[n])?a.push(`contains(@${t.name},${S(o[n].trim())})`):a.push(`contains(@${t.name},${S(O(o[n])).trim()})`));if(a?.length)return r=I(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,r}},W=(t,n,a,r)=>{try{const r=a.filter(e=>z(e,t)),o=a=>{const r=y(a.name,a.nodeValue);return r?"class"===a.name?h(t,r,n):g(r)?[]:e.test(r)?[`@${a.name}="${r}"`]:[`normalize-space(@${a.name})="${r}"`]:[]},l=e=>{const t=o(e);return"class"===e.name?t.map(e=>[e]):t.length?[t]:[]},s=e=>e.reduce((e,t)=>{const n=l(t);return n.length?e.flatMap(e=>n.map(t=>[...e,...t])):[]},[[]]),i=()=>{const n=O(E(t)?.trim()||""),a=P(n);if(g(n))return a?[`contains(normalize-space(.),${S(a)})`]:[];if(!n||n.length>80||/^\d+$/.test(n)){const e=T(t,n);return e?[e]:[]}const r=new Set,o=T(t,n);return o?(r.add(o),Array.from(r)):(e.test(n)&&n.length<=40&&!n.includes(" ")&&r.add(`text()=${S(n)}`),n.includes(" ")&&r.add(`normalize-space(.)=${S(O(n))}`),r.add(`contains(text(),${S(n)})`),Array.from(r))},c=(e,t)=>{const n=[],a=(r,o)=>{if(o.length!==t)for(let t=r;t<e.length;t++)o.push(e[t]),a(t+1,o),o.pop();else n.push([...o])};return a(0,[]),n},u=e=>I(t)?`//*[local-name()='${t.tagName}' and ${e.join(" and ")}]`:`//${t.tagName}[${e.join(" and ")}]`,f=()=>{if(!(r.length<2))for(let e=2;e<=r.length;e++){const a=c(r,e);for(const e of a){const a=s(e);for(const e of a){if(e.length<2)continue;const a=u(e);let r;try{r=k(a,t,n)}catch{continue}if(1===r)return a}}}},m=f();if(m)return m;const d=i();if(!d.length||!r.length)return;for(let e=1;e<=r.length;e++){const a=c(r,e);for(const e of a){const a=s(e);for(const e of a)if(e.length)for(const a of d){const r=[...e,a],o=u(r);try{if(1===k(o,t,n))return o}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},U=(e,t,n)=>F(e,t)[0]||"",F=(t,n,a)=>{let r=I(t),o="";if(z(n,t)){let a=y(n.name,n.value);const l=n.name;if("class"===l){const e=t.getRootNode?.()??t.ownerDocument;return h(t,a,e).map(e=>r?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName||"*"}[${e}]`)}if(g(a))return[];o=e.test(a)?r?`*[local-name()='${t.tagName}' and @${l}=${S(a)}]`:`${t.tagName||"*"}[@${l}=${S(a)}]`:r?`*[local-name()='${t.tagName}' and normalize-space(@${l})=${S(a)}]`:`${t.tagName||"*"}[normalize-space(@${l})=${S(a)}]`}return o?[o]:[]},H=(t,n)=>{if(!t.textContent)return"";const a=w(t),r=P(a);if(g(a)&&!r)return"";const o=g(a)?r:a,l=T(t,o);let s;return s=l?x(l,I(t),t.tagName||"*"):g(a)?x(`contains(normalize-space(.),${S(o)})`,I(t),t.tagName||"*"):!e.test(a)||/\s/.test(a.trim())?x(`normalize-space(.)=${S(o)}`,I(t),t.tagName||"*"):I(t)?`//*[local-name()='${t.tagName}' and .=${S(o)}]`:`//${t.tagName||"*"}[.=${S(o)}]`,s},G=(e,t,n)=>{if("@class"===t){const t=p(e,n);return 1===m(n).length&&1===t.length?x(`normalize-space(@class)=${S(t[0])}`,I(e),e.tagName.toLowerCase()):""}if(t.startsWith("@")&&g(n))return"";if(("."===t||"text()"===t)&&g(n)){const{fragment:t}=D(n);return t?x(`contains(normalize-space(.),${S(t)})`,I(e),e.tagName.toLowerCase()):""}return x(`normalize-space(${t})=${S(O(n)).trim()}`,I(e),e.tagName.toLowerCase())},B=(e,t,n)=>{if("@class"===t){const t=p(e,n);return 1===t.length?x(`starts-with(normalize-space(@class),${S(t[0])})`,I(e),e.tagName.toLowerCase()):""}if(t.startsWith("@")&&g(n))return"";if(("."===t||"text()"===t)&&g(n)){const{prefix:t,fragment:a}=D(n),r=t||a;return r?x(`starts-with(normalize-space(.),${S(r)})`,I(e),e.tagName.toLowerCase()):""}return x(`starts-with(${t},${S(O(n)).trim()})`,I(e),e.tagName.toLowerCase())},Z=(e,t,n)=>{if("@class"===t){const t=p(e,n);return 1===t.length?x(`contains(@class,${S(t[0])})`,I(e),e.tagName.toLowerCase()):""}if(t.startsWith("@")&&g(n))return"";if(("."===t||"text()"===t)&&g(n)){const{fragment:t}=D(n);return t?x(`contains(normalize-space(.),${S(t)})`,I(e),e.tagName.toLowerCase()):""}return x(`contains(${t},${S(O(n)).trim()})`,I(e),e.tagName.toLowerCase())},J=(t,n)=>{const a=n.flatMap(n=>(n=>{const a=y(n.name,n.value);if(!a)return[];if("class"===n.name){const e=t.getRootNode?.()??t.ownerDocument;return h(t,a,e)}return g(a)?[]:e.test(a)?[`@${n.name}=${S(a)}`]:[`normalize-space(@${n.name})=${S(a)}`]})(n)).filter(Boolean);if(a.length>=2)return x(`${a[0]} or ${a[1]}`,I(t),t.tagName.toLowerCase());const r=(()=>{const n=O(E(t)?.trim()||""),a=P(n);if(g(n))return a?`contains(normalize-space(.),${S(a)})`:null;const r=T(t,n);return r||(!n||n.length>80||/^\d+$/.test(n)?null:e.test(n)&&n.length<=40&&!n.includes(" ")?`text()=${S(n)}`:n.includes(" ")?`normalize-space(.)=${S(n)}`:`contains(text(),${S(n)})`)})();return 1===a.length&&r?x(`${a[0]} or ${r}`,I(t),t.tagName.toLowerCase()):""},K=(e,t,n)=>{try{return k(e,t,n)}catch(e){return 0}},Q=(e,t)=>{const n=[],a=new Set,r=Array.from(e.attributes||[]),o=["id","data-testid","data-test","data-qa","name","formcontrolname","aria-label","role"],l=[...o.map(e=>r.find(t=>t.name===e)).filter(Boolean),...r.filter(e=>!o.includes(e.name))],s=r=>{r&&!a.has(r)&&ae(r,e,t)&&(a.add(r),n.push(r))};l.forEach(t=>{if(z(t,e))for(const n of se(e,t.name,t.value))s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=H(e);t&&s(t)}if(r.length>1){const n=W(e,t,r);n&&s(n)}return n},ee=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(re(a)),a=a.parentElement;return a===e?n.join("/"):""},te=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=re(e),r=I(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const r=Q(t,n);for(const o of r){console.log(`Trying ancestor XPath: ${o}`);const r=`${o}/descendant::${a}`;console.log(`Trying descendant XPath: ${r}`);const l=K(r,e,n);if(console.log(`Match count: ${l}`),1===l&&ne(r,n)===e)return console.log(`Selected XPath: ${r}`),r;const s=ee(t,e);if(s){const t=`${o}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=K(t,e,n);if(console.log(`Match count: ${a}`),1===a&&ne(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${r}`);const o=K(r,e,n);return console.log(`Match count: ${o}`),1===o&&ne(r,n)===e?(console.log(`Selected XPath: ${r}`),r):(console.log("Selected XPath: "),"")},ne=(e,t)=>{try{if(_(t)){const{owner:n,contextNode:a,cloneElement:r}=L(t);return n.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue||r}return t.evaluate(e,t,null,t.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch(e){return null}},ae=(e,t,n)=>{try{const{first:r,second:o}=a(e,n);return!!r&&!o&&r===t}catch{return!1}},re=e=>I(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),oe=(e,t,n)=>{if(!(e instanceof Element))return[];const a=new Set,r=[],o=Array.from(e.attributes||[]).filter(t=>{return t?.value&&(n=t.value,!/\d/.test(n))&&z(t,e);var n}),l=(e,t)=>{t&&!a.has(t)&&(a.add(t),r.push({key:e,value:t}))},s=["id","data-testid","data-test","data-qa","name","formcontrolname","aria-label","role"];s.forEach(n=>{const a=o.find(e=>e.name===n);if(a)for(const n of se(e,a.name,a.value))n&&ae(n,e,t)&&l(`anchor by ${a.name}`,n)}),o.forEach(n=>{if(!s.includes(n.name))for(const a of se(e,n.name,n.value))a&&ae(a,e,t)&&l(`anchor by ${n.name}`,a)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const n=H(e);n&&ae(n,e,t)&&l("anchor by text",n)}if(o.length>1){const n=W(e,t,o);n&&ae(n,e,t)&&l("anchor by combination",n)}const c=te(e,t);return c&&ae(c,e,t)&&l("anchor by tag",c),r},le=e=>{const t=E(e)?.trim(),n=P(t);if(t&&g(t))return n?`contains(normalize-space(.),${S(n)})`:void 0;const a=T(e,t);if(a)return a;const r=t?S(R(t)):t;return r?r!==`'${t}'`?`contains(.,${r})`:/\s/.test(t)?`normalize-space(.)='${O(t)}'`:`normalize-space(.)='${t}'`:void 0},se=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let r="";if(n=y(t,n)){if("class"===t){const t=e.getRootNode?.()??e.ownerDocument;return h(e,n,t).map(t=>I(e)?`//*[local-name()='${e.tagName}' and ${t}]`:`//${e.tagName||"*"}[${t}]`)}if(g(n))return[];r=a.test(n)?I(e)?`//*[local-name()='${e.tagName}' and @${t}=${S(n)}]`:`//${e.tagName||"*"}[@${t}=${S(n)}]`:I(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${S(n)})]`:`//${e.tagName||"*"}[contains(@${t},${S(n)})]`}return r?[r]:[]},ie=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,ce=(t,n,a)=>{let r;const o=[];if(t.textContent&&a&&b(t.textContent)){const{prefix:e,fragment:n}=D(E(t)),a=[e?`starts-with(normalize-space(.),${S(e)})`:"",n?`contains(normalize-space(.),${S(n)})`:""].filter((e,t,n)=>e&&n.indexOf(e)===t);for(const e of a)r=I(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r})}if(t.textContent&&(!a||a&&!b(t.textContent)))if(e.test(t.textContent)){const e=E(t),n=T(t,e),a=n||(/\s/.test(e.trim())?`normalize-space(.)=${S(O(e))}`:`.=${S(e)}`);r=I(t)?`*[local-name()='${t.tagName}' and ${a}]`:`${t.tagName}[${a}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}else{const e=le(t);e&&(r=I(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r}))}if(t.attributes){const e="IMG"===t.tagName?Array.from(t.attributes).sort((e,t)=>"alt"===e.name?-1:"alt"===t.name?1:0):Array.from(t.attributes);for(const a of e)if(z(a,t)){let e=a.nodeValue;if(e){e=y(a.name,e);const l=a.name;if("class"!==l&&g(e))continue;if("class"===l){const a=h(t,e,n);if(!a.length)continue;for(const e of a)r=I(t)?`*[local-name()='${t.tagName}' and ${e}]`:`${t.tagName}[${e}]`,o.push({key:"getReferenceElementsXpath",value:r});continue}r=I(t)?`*[local-name()='${t.tagName}' and @${l}=${S(e)}]`:`${t.tagName}[@${l}=${S(e)}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}}}if(!o?.length){const e=Array.prototype.slice.call(t.attributes);if(e?.length>1){const e=W(t,n,Array.prototype.slice.call(t.attributes));e&&o.push({key:"getReferenceElementsXpath",value:e})}}if(!o?.length){const e=[];let n;const r=t.tagName;if(t.textContent&&a&&b(t.textContent)){const a=O(E(t)).trim();a?.length>1&&e.push(`contains(text(),${S(a)})`),e?.length&&(n=I(t)?`*[local-name()='${r}' and ${e.join(" and ")}]`:`${r}[${e.join(" and ")}]`,n&&o.push({key:"getReferenceElementsXpath",value:n}))}}if(!o?.length){const e=((e,t)=>{const n=Array.prototype.slice.call(e),a=[];try{n.map(e=>{if(z(e,t)){const n=q(e,t);n&&a.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return a})(t.attributes,t);e?.length&&o.concat(e)}return o},ue=e=>e=(e=e.replace(/text\(\)\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1")).replace(/\.\s*=\s*(['"])(.*?)\1/g,"normalize-space(.)=$1$2$1"),fe=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function me(e){const t=function(e){return e.toLowerCase().replace(/'[^']*'/g,"?").replace(/"[^"]*"/g,"?").replace(/\[\d+\]/g,"[?]").replace(/\/\/[a-z0-9_-]+/g,"//node").replace(/\/[a-z0-9_-]+/g,"/node")}(e),n=function(e){const t=e.toLowerCase(),n=t.match(/(ancestor-or-self|ancestor|descendant-or-self|descendant|following-sibling|preceding-sibling|following|preceding|parent|child|self)::/),a=n?.[1]??"none",r=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:r?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function ge(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function de(e,t,n,a){const r=a?.getRootNode?.()??e,o=e=>{try{return Array.from(r.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===o(`#${ge(n)}`).length;case"name":return 1===o(`[name="${ge(n)}"]`).length;case"className":return 1===o(`.${n}`).length;case"tagName":case"cssSelector":return 1===o(n).length;case"linkText":return 1===o("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===o("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const he={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:ce,getAbsoluteXPath:Y,getRelativeXPath:V,getCombinationXpath:q,getAttributeCombinationXpath:W,getElementFromXpath:(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const r=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?r.evaluate(e,a,null,XPathResult.ANY_TYPE,null):r.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},isSvg:I,findXpathWithIndex:C,isNumberExist:b,getTextContent:E,getCountOfXPath:k,normalizeXPath:ue,getShadowRoot:X,escapeCharacters:S,removeParenthesis:A,checkBlockedAttributes:z,getRelationship:(e,t)=>{let n=e.compareDocumentPosition(t);return 2===n?"preceding":4===n?"following":8===n?"ancestor":16===n?"descendant":32===n?"self":""},findMatchingParenthesis:fe,deleteGarbageFromInnerText:R,replaceTempAttributes:M,createObserver:e=>{i=new MutationObserver(t=>{t.forEach(t=>{if(("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!v(t))&&n(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement)if(v(t)||(e=>"attributes"===e.type&&e.target instanceof Element&&(N(e.oldValue)||N(e.target.getAttribute("class"))||e.target.hasAttribute("locator-data-tooltip")))(t));else if("attributes"===t?.type&&"class"===t.attributeName)(e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return;const t=new Set(m(e.oldValue)),n=m(e.target.getAttribute("class")).filter(e=>!t.has(e));if(!n.length)return;let a=s.get(e.target);a||(a=new Set,s.set(e.target,a));const r=n.filter(e=>!a?.has(e));r.length&&(r.forEach(e=>a?.add(e)),console.log("[ff-dom] blocked modified class tokens",{tokens:r,element:e.target,currentValue:e.target.getAttribute("class"),url:e.target.baseURI}))})(t);else if("attributes"===t?.type&&!["flndisabled"].includes(t.attributeName)){const e={url:t.target.baseURI,attributeName:t.attributeName,element:t.target,doc:t.target.ownerDocument};let n=l.get(t.target);n||(n=new Set,l.set(t.target,n)),n.has(t.attributeName)||(n.add(t.attributeName),o.push(e),console.log("[ff-dom] blocked modified attribute",{...e,currentValue:t.attributeName?t.target.getAttribute(t.attributeName):null}))}})})},startObserver:(e,t)=>{i?.observe(e,t)},stopObserver:()=>{i?.disconnect()},modifiedElementAttributes:o,cspEnabled:!1,getXPathPattern:me,getNormalizedPropertyXPath:G,getStartsWithPropertyXPath:B,getContainsPropertyXPath:Z,getOrAttributesXPath:J,getTagOnlyXPath:te,getFirstMatchedNode:ne,isExactUniqueXpath:ae,getAxisNodeTest:re,getUniqueNodeAnchorXpaths:oe,escapeAttrValue:ge,isUniqueInDOM:de,sanitizeAttributeValue:y,getClassTokenCondition:(e,t,n,a=!1)=>h(e,t,n,a)[0]||null,getClassTokenConditions:h,getXpathStrings:se,intermediateXpathSteps:F,getContainerTextCondition:T};let pe=[],$e=[],ye=new Map,ve=new Map;const Ne=new Map,be={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},xe=e=>be[e]||e,Ee=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),we=e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value))&&(t.add(e.value),!0))},ke=(e,t)=>t?e:e.filter(e=>!(e=>{let t=null;for(let n=0;n<e.length;n++){const a=e[n];if(t){a===t&&(t=null);continue}if("'"===a||'"'===a){t=a;continue}if("["!==a)continue;const r=e.indexOf("]",n+1);if(-1===r)return!1;if(/^\s*\d+\s*$/.test(e.slice(n+1,r)))return!0}return!1})(e.value)),Se=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",Ae=e=>{if(!(e&&e instanceof Element))return[];const t=[],n=Array.from(e.children||[]);for(;n.length;){const e=n.shift();e.classList?.contains("flntooltip")||(t.push(e),n.push(...Array.from(e.children||[])))}return t},Ce=(e,t)=>{const n=[];let a="previous"===t?e.previousElementSibling:e.nextElementSibling;for(;a;)a.classList?.contains("flntooltip")||n.push(a),a="previous"===t?a.previousElementSibling:a.nextElementSibling;return n},Re=(e,t)=>{const n=[];for(let a=e;a?.parentElement;a=a.parentElement){let e="previous"===t?a.previousElementSibling:a.nextElementSibling;for(;e;)e.classList?.contains("flntooltip")||(n.push(e),n.push({node:e,expand:()=>Ae(e)})),e="previous"===t?e.previousElementSibling:e.nextElementSibling}return n},Oe=e=>{if(!(e instanceof Element))return!0;const t=e.textContent?.trim();return!e.id&&!e.className&&0===e.attributes.length&&(!t||t.length>60)&&e.children.length>2},Te=e=>{let t=0;e.id&&(t+=100),e.getAttribute("data-testid")&&(t+=90),e.className&&(t+=50),0===e.children.length&&(t+=30);const n=e.textContent?.trim();return n&&n.length<40&&(t+=40),t},De=(e,t,n,a,r,o,l)=>{const s=le(n),i=s?`${re(n)}[${s}]`:re(n),c=[];let u=0;const f=t.includes("descendant")?10:20;for(const r of e){if(u++>f)break;if(c.length>=5)break;const e="node"in r?r.node:r;if(!(e instanceof Element))continue;if(Oe(e))continue;const s=[()=>oe(e,a),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&z(t,e));for(const a of n){const n=a.value;if(!n)continue;const r=Z(e,`@${a.name}`,n);r&&t.push({key:"contains",value:r});const o=B(e,`@${a.name}`,n);o&&t.push({key:"starts-with",value:o})}return t},()=>[{key:"tag",value:te(e,a)}]];for(let r=0;r<s.length;r++){let u=s[r]();if(!u.length)continue;l||(u=u.filter(e=>!/\[\d+\]/.test(e.value)));const f=new Set;u=u.filter(e=>!f.has(e.value)&&(f.add(e.value),!0)),u=u.slice(0,5);for(const e of u){const r=`${e.value}/${t}::${i}`;if(ae(r,n,a)){if(c.push({key:o,value:r}),c.length>=2)return c;if(c.length>=5)return c}}if(l&&r===s.length-1)for(const r of u){const l=k(r.value,e,a);for(let e=1;e<=Math.min(l,3);e++){const l=`(${r.value})[${e}]/${t}::${i}`;if(ae(l,n,a)){if(c.push({key:o,value:l}),c.length>=2)return c;if(c.length>=5)return c}}}}if("expand"in r&&r.expand){const e=r.expand();let l=0;for(const r of e){if(l++>15)break;if(c.length>=5)break;if(!(r instanceof Element))continue;if(Oe(r))continue;const e=oe(r,a);for(const r of e.slice(0,5)){const e=`${r.value}/${t}::${i}`;if(ae(e,n,a)){if(c.push({key:o,value:e}),c.length>=2)return c;if(c.length>=5)return c}}}}}return c},Pe=(e,t)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},Xe=(e,t)=>{for(let n=e.nextElementSibling;n;n=n.nextElementSibling)if(n===t)return"following-sibling";for(let n=e.previousElementSibling;n;n=n.previousElementSibling)if(n===t)return"preceding-sibling";return""},_e=(e,t)=>{const n=[];for(let a=e;a&&a!==t;a=a.parentElement){const e=a.parentElement;if(!e)return"";n.push(`/parent::${re(e)}`)}return n.join("")},Le=(e,t)=>{const n=re(t);return t.parentElement===e?[`/${n}`,`/descendant::${n}`]:[`/descendant::${n}`]},ze=(e,t,n)=>{const a=[],r=new Set,o=(e=>{const t=[],n=new Set,a=a=>{a&&a!==e&&!n.has(a)&&(a.contains(e)||e.contains(a)||(n.add(a),t.push(a)))};for(let n=e.parentElement,r=0;n&&r<4&&t.length<20;n=n.parentElement,r++){const e=[Ce(n,"previous").slice(0,4),Ce(n,"next").slice(0,4)];for(const t of e)for(const e of t){a(e);let t=0;for(const n of Ae(e).sort((e,t)=>Te(t)-Te(e))){if(t++>=8)break;a(n)}}}return t.sort((e,t)=>Te(t)-Te(e)).slice(0,20)})(e),l=Pe(e.parentElement,3);for(const n of o){const o=oe(n,t).filter(e=>"anchor by tag"!==e.key).slice(0,2);if(!o.length)continue;const s=Pe(n,3);for(const i of o)for(const o of s){const s=_e(n,o);if(o===n||s)for(const n of l){if(!n||!n.contains(e))continue;const l=Xe(o,n);if(!l)continue;const c=`/${l}::${re(n)}`;for(const o of Le(n,e)){const n=`${i.value}${s}${c}${o}`;if(!r.has(n)&&(r.add(n),ae(n,e,t)&&(a.push({key:"chained axes fallback",value:n}),a.length>=2)))return a}}}}return a},Ie=e=>{const t=re(e),n=e.textContent?.trim(),a=(e=>{const t=P(e);return t||(e||"").split(/[^a-zA-Z]+/).map(e=>e.trim()).filter(e=>e.length>2).pop()})(n),r=le(e),o=[];return a&&a!==n&&o.push(`${t}[contains(text(),${S(a)})]`),r&&o.push(`${t}[${r}]`),o.push(t),Array.from(new Set(o))},Me=(e,t,n)=>{const a=E(e)?.trim(),r=[];if(a&&a.length>2&&a.length<40&&!g(a)){const t=`//${e.tagName}[.=${S(a)}]`;r.push({key:"anchor by text",value:t})}return[...r,...oe(e,t).filter(e=>"anchor by tag"!==e.key)]},je=(e,t,n)=>{const a=[],r=new Set,o=(e=>{const t=[],n=new Set,a=a=>{a&&a!==e&&!n.has(a)&&(a.contains(e)||e.contains(a)||(n.add(a),t.push(a)))},r=e=>{for(const t of[e,...Ae(e)]){const e=E(t)?.trim();e&&e.length<40&&!g(e)&&0===t.children.length&&a(t)}};for(let n=e.parentElement,o=0;n&&o<4&&t.length<30;n=n.parentElement,o++){const e=Ce(n,"previous").reverse(),t=Ce(n,"next");for(const n of[...e,...t])r(n),a(n)}return t.slice(0,30)})(e),l=Ie(e);for(const n of o){const o=Me(n,t).slice(0,2);if(o.length)for(const s of o)for(const o of Pe(n.parentElement,5)){if(!o.contains(e))continue;const n=`/ancestor::${re(o)}`;for(const o of l){const l=`${s.value}${n}/descendant::${o}`;if(!r.has(l)&&(r.add(l),ae(l,e,t)&&(a.push({key:"ancestor descendant bridge",value:l}),a.length>=1)))return a}}}return a},Ye=(e,t)=>{const n=[];for(let a=t;a&&a!==e;a=a.parentElement)n.unshift(re(a));if(!n.length)return"";const a=n.pop();return`${n.length?`/${n.join("/")}`:""}/child::${a}`},Ve=(e,t,n,a)=>{const r=new Set,o=[],l=(e,t)=>{t&&!r.has(t)&&(!a&&/\[\d+\]/.test(t)||(r.add(t),o.push({key:e,value:t})))};return oe(e,t).filter(e=>"anchor by tag"!==e.key).forEach(e=>l(e.key,e.value)),Array.from(e.attributes||[]).forEach(t=>{if(!(e=>!(!e?.value||["style","locator-data-tooltip","value"].includes(e.name)||0===e.name.indexOf("on")&&e.name.length>3))(t)||!g(t.value)||"class"===t.name)return;const n=(e=>{const t=(e.split(/\d/)[0]||"").replace(/[-_:\s.]+$/g,"").trim();return t.length>2&&/[a-zA-Z]/.test(t)?t:""})(t.value);if(!n)return;const a=Z(e,`@${t.name}`,n);l(`anchor by stable ${t.name}`,a)}),o},qe=(e,t,n,a)=>{const r=[];for(let t=e.parentElement;t;t=t.parentElement)r.push(t);const o=Ae(e),l=Ce(e,"previous"),s=Ce(e,"next"),i=Re(e,"previous"),c=Re(e,"next"),u=(e,t=20)=>e.length>t?e.slice(0,t):e,f=[[{nodes:u(s),axis:"preceding-sibling",key:"preceding-sibling"},{nodes:u(l),axis:"following-sibling",key:"following-sibling"}],[{nodes:u(r),axis:"child",key:"child"},{nodes:u(o,15),axis:"parent",key:"parent"}],[{nodes:u(r),axis:"descendant",key:"descendant"},{nodes:u(r),axis:"descendant-or-self",key:"descendant-or-self"},{nodes:u(o,10),axis:"ancestor",key:"ancestor"},{nodes:u(o,10),axis:"ancestor-or-self",key:"ancestor-or-self"}],[{nodes:u(i),axis:"following",key:"following"},{nodes:u(c),axis:"preceding",key:"preceding"}]],m=((e,t,n,a)=>{const r=[],o=new Set;for(let n=e.parentElement,l=0;n&&l<8;n=n.parentElement,l++){const l=Ye(n,e);if(!l)continue;const s=Ve(n,t,0,a);for(const n of s.slice(0,3)){const a=`${n.value}${l}`;if(!o.has(a)&&(o.add(a),ae(a,e,t)&&(r.push({key:"child chain",value:a}),r.length>=2)))return r}}return r})(e,t,0,a);if(m.length)return m;for(const n of f)for(const r of n){const n=De(r.nodes,r.axis,e,t,0,r.key,a);if(n.length>0)return n}const g=je(e,t);return g.length?g:ze(e,t)||[]},We=(e,t,n,a,r)=>{const o=xe(a);return"text"===o?Ee(a,((e,t,n)=>{if(!Se(e))return[];if("text"===n){const n=H(e)||et(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,o)):["contains","startsWith","normalizeSpace"].includes(o)?Ee(a,((e,t,n,a)=>{const r=[],o=Array.from(e.attributes||[]).filter(t=>t?.value&&z(t,e)),l=Se(e),s="contains"===a?Z:"startsWith"===a?B:"normalizeSpace"===a?G:null;if(!s)return r;if("contains"===a&&l)for(const n of["text()","."]){const r=s(e,n,l);if(r&&1===k(r,e,t))return[{key:`xpath by ${a} text`,value:r}]}if(o.forEach(n=>{if("class"===n.name)return void h(e,n.value,t).forEach(t=>{const n=x(t,I(e),e.tagName.toLowerCase());n&&r.push({key:`xpath by ${a} class`,value:n})});const o=s(e,`@${n.name}`,n.value);o&&r.push({key:`xpath by ${a} ${n.name}`,value:o})}),"contains"===a&&r.length){const n=r.find(n=>1===k(n.value,e,t));return n?[n]:[]}if(l){const t=s(e,".",l);t&&r.push({key:`xpath by ${a} text`,value:t})}return r})(e,t,0,o)):["and","or"].includes(o)?Ee(a,((e,t,n,a)=>{const r=Array.from(e.attributes||[]).filter(t=>t?.value&&z(t,e));if("and"===a){const n=W(e,t,r);return n?[{key:"xpath by combination",value:n}]:[]}if("or"===a&&r.length>=1){const t=J(e,r);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,0,o)):"axes"===o?Ee(a,qe(e,t,0,!1)):"index"===o?Ee(a,((e,t)=>{const n=[],a=e.tagName.toLowerCase(),r=Array.from(t.querySelectorAll(a)).indexOf(e)+1;if(r<=0)return[];n.push({key:"xpath by index",value:`(//${a})[${r}]`});let o=e.parentElement;for(;o&&o!==t.body;){if(o.id||o.className){const t=o.id?se(o,"id",o.id):se(o,"class",o.className.toString());for(const r of t){const t=Array.from(o.querySelectorAll(a)).indexOf(e)+1;if(t>0){n.push({key:"xpath by index",value:`(${r}//${a})[${t}]`});break}}if(n.length>1)break}o=o.parentElement}return n})(e,t)):"tag"===o?Ee(a,[{key:"xpath till tag",value:te(e,t)}]):[]},Ue=(e,t,n,a,r,o)=>{if(e){let l;l="parent"===o?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of l){ye?.get(e)||ye.set(e,k(e,n,a));const t=ye?.get(e);if(1===t)return e;if(t>1&&($e.length?t<$e[0].count&&($e.pop(),$e.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})):$e.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})),t>1&&r&&!pe.length){const o=C(e,n,a,t);o&&1===k(o,n,a)&&pe.push({key:"relative xpath by unique parent "+(r?"index":""),value:o})}}}return null},Fe=(t,n,a,r,o,l)=>{try{if(Ne.has(t))return Ne.get(t);const s=[];let i=t;for(;i&&1===i.nodeType;){const t=!1;for(const e of Array.from(i.attributes))if(z(e,i)){const t=y(e.name,e.nodeValue),r=e.name;for(const e of se(i,r,t)){let t;try{t=Ue(e,o,a,n,l,"parent")}catch(e){continue}if(t)return t}}if(i.textContent&&!i.textContent)if(!r||r&&!b(i.textContent)){let t;t=e.test(i.textContent)?I(i)?`//*[local-name()='${i.tagName}' and .=${S(w(i))}]`:`//${i.tagName||"*"}[.=${S(w(i))}]`:I(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${S(w(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${S(w(i))}]`;const r=Ue(t,o,a,n,l,"parent");if(r)return r}else{const e=[],t=[...new Set(w(i).match(/([^0-9]+)/g))],r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&O(t[n].trim())&&(r.test(t[n])?e.push(`contains(.,${S(t[n].trim()).trim()})`):e.push(`contains(.,${S(O(t[n])).trim()})`));if(e?.length){const t=I(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,r=Ue(t,o,a,n,l,"parent");if(r)return r}}if(!t){const e=I(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+o;if(1===k(c,t,n))return Ne.set(t,c),c}catch(e){return console.error(e),null}},He=(e,t,n,a)=>{const r=new Map;if(r.has(e))return r.get(e);const o=[];let l=e;try{for(;l&&1===l.nodeType;){if(!l.tagName)return"";let e=!1;for(const n of Array.from(l.attributes)){if(z(n,l)){const a=y(n.name,n.nodeValue),r=n.name;for(const n of se(l,r,a)){let a;try{a=k(n,l,t)}catch(e){continue}if(1===a){o.unshift(n),e=!0;break}}}if(e)break}if(!e&&l.textContent&&!n.textContent){const n=H(l);if(n){if(1===k(n,l,t)){e=!0,o.unshift(n);break}}}if(e)break;{const e=I(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;o.unshift(e)}l=l.parentElement}const a=o.join("");return r.set(e,a),a}catch(e){return console.log(e),null}},Ge=(e,t,n)=>{const a=[];let r;const o=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?o.unshift(e.firstElementChild):null!=e.nextElementSibling&&o.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&o.unshift(t.nextElementSibling);try{do{let e=!1;for(r=o.pop();null!==r;){for(const n of Array.from(r.attributes)){if(z(n,r)){const o=y(n.name,n.nodeValue),l=n.name;for(const n of se(r,l,o)){let o;try{o=k(n,r,t)}catch(e){continue}if(1===o){e=!0,a.push(n);break}}}if(e)break}if(!e&&r.textContent&&!n.textContent){const n=H(r);if(n){if(1===k(n,r,t)){e=!0,a.push(n);break}}}if(e)break;{const e=I(r)?`/*[local-name()='${r.tagName}']`:`/${r.tagName}`;a.push(e),null!=r.firstElementChild?(o.push(r.nextElementSibling),r=r.firstElementChild):r=r.nextElementSibling}}}while(o.length>0);const l=a.join("");return ve.set(e,l),l}catch(e){return console.log(e),null}},Be=(e,t,n,a)=>{try{const r=document.querySelector(".flntooltip");for(let o=e.nextElementSibling;null!==o&&o!==r;o=o.nextElementSibling)Ze(o,e,t,a,"preceding-sibling",n);for(let o=e.previousElementSibling;null!==o&&o!==r;o=o.previousElementSibling)Ze(o,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},Ze=(e,t,n,a,r,o)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){const l=F(e,{name:t.name,value:t.value},o);for(let t of l){t+=`/${r}::${a}`;const o=k(t,e,n);if(1===o)return void pe.push({key:`xpath by ${r}`,value:t});o>1&&($e.length?o<$e[0].count&&($e.pop(),$e.push({key:`relative xpath by ${r}`,value:t,count:o})):$e.push({key:`relative xpath by ${r}`,value:t,count:o}))}}if(!o){let t;if(t=U(e,{name:"text",value:e.textContent}),t){const a=k(t,e,n);if(1===a)return void pe.push({key:`xpath by ${r}`,value:t});a>1&&($e.length?a<$e[0].count&&($e.pop(),$e.push({key:`relative xpath by ${r}`,value:t,count:a})):$e.push({key:`relative xpath by ${r}`,value:t,count:a}))}}}catch(e){console.log(`${r} xpath-error`,e)}};function Je(e,t,n,a){const{tagName:r}=t,o=t.textContent.trim();if(!o)return;const l=O(o),s=P(l);if(g(l)&&!s)return;const i=g(l)?s:l,c=T(t,i);for(const a of e)if(z(a,t)){let e=y(a.name,a.nodeValue);const s=`//${r}[@${a.name}='${e}' and ${c||(g(l)?`contains(normalize-space(.),${S(i)})`:/\s/.test(o)?`normalize-space(.)=${S(i)}`:`text()=${S(i)}`)}]`;if(s){if(1==k(s,t,n))return s}}}const Ke=(e,t,n,a,r)=>{let o;if(o=e.name,z(e,t))return j(t,n,`@${o}`,e.value,a,r)},Qe=(e,t,n,a)=>{let r=e.className;if("string"!=typeof r&&(r=""),r=r?.replace("flndisabled","disabled"),r=y("class",r),r=r?.trim(),r&&z({name:"class",value:r},e))return j(e,t,"@class",r,n,a)},et=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const r=E(e);if(r)return j(e,t,"text()",r,n,a)||j(e,t,".",r,n,a)}},tt=(e,t,n,a,r)=>{const o=e;try{o.map(e=>{if("className"!==e.name&&"class"!==e.name&&z(e,t)){const o=Ke(e,t,n,a,r);o&&pe.push({key:`xpath by ${e.name}${a?" index":""}`,value:o})}});const l=et(t,n,a,r);if(l&&pe.push({key:"xpath by text"+(a?" index":""),value:l}),o.find(e=>["className","class"].includes(e.name))&&z(o?.find(e=>["className","class"].includes(e.name)),t)){let e=Qe(t,n,a,r);e&&pe.push({key:"xpath by class",value:e})}if(!pe.length&&o.length>1){const e=W(t,n,o);e&&pe.push({key:"xpath by combination",value:e})}if(!pe.length){const a=Je(e,t,n);a&&pe.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},nt=(e,t,n,a,r=[],o=[])=>{pe=[],console.log(e);const l=e,s=l?.getRootNode?.(),i=s?.nodeType===Node.DOCUMENT_FRAGMENT_NODE,c=i?s:l?.ownerDocument||t,u=l.tagName,{attributes:f}=l,m=r.length>0?r:Array.from(f);if(tt(m,l,c,n,a),o.length){const e=n||((e=[])=>e.some(e=>"index"===xe(e)))(o),t=o.flatMap(e=>We(l,c,0,e));return pe=we(t.filter(e=>1===k(e.value,l,c))),ke(pe,e)}if(pe.length){const t=pe.length;for(let n=0;n<t;n++){let t=pe[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===k(t,e,c)&&pe.push({key:`${pe[n].key} regex`,value:t})}}return pe.length||i||(pe=qe(l,c,0,n)),ke(we(pe),n)},at={parseDOM:nt,getTextXPath:et,getUniqueClassName:Qe,attributesBasedXPath:Ke,addAllXPathAttributes:tt,addRelativeXpaths:(e,t,n,a,r)=>{try{let o,l,s=[];if(pe=[],console.log(r),r)for(const t of r){const n=F(e,{name:t.name,value:t.value},a);console.log(n[0]||"");for(const e of n)e&&s.push(e)}if(e.textContent){let t=U(e,{name:"text",value:e.textContent});console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let r=0;r<s.length;r++)if(!pe.length){if(Be(e,t,a,s[r]),!pe.length&&(o||(o=He(e.parentElement,t,e)),console.log(o),o&&(o.includes("@")||o.includes("text()")||o.includes(".="))&&o.match(/\//g)?.length-2<5)){const a=o+`/${s[r]}`,l=k(a,e,t);if(1===l)pe.push({key:"relative xpath by relative parent",value:a});else if(l>1&&n){const r=C(a,e,t,l);r&&1===k(r,e,t)&&pe.push({key:"relative xpath by relative parent "+(n?"index":""),value:r})}}if(!pe.length&&(l||(l=Ge(e,t,e)),l&&(l.includes("@")||l.includes("text()")||l.includes(".=")))){const a=l.replace(/^\/+/,""),o=`/${s[r]}/${a}`,i=k(o,e,t);if(1===i)pe.push({key:"relative xpath by relative child",value:o});else if(i>1&&n){const a=C(o,e,t,i);a&&1===k(a,e,t)&&pe.push({key:"relative xpath by relative parent "+(n?"index":""),value:a})}}if(1===pe?.length&&pe?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=et(e,t,n,!1);a&&pe.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!pe.length){let o=Fe(e.parentElement,t,e,a,s[r],n);o&&pe.push({key:"xpath by unique parent",value:o})}}return pe}catch(e){console.log(e)}},getXPathUsingAttributeAndText:Je,getSiblingRelativeXPath:Be,getChildRelativeXpath:Ge,getParentRelativeXpath:He,getUniqueParentXpath:Fe,checkRelativeXpathRelation:Ue,buildAxesStrategyXpaths:qe};let rt=[],ot=[];const lt=/^[\S]+( [\S]+)*$/gi,st=(e,t,n,a,r,o,l,s=0,i=!1)=>{let c="";const u=()=>{const t=e[e.length-1],r=P(E(t)?.trim());if(!r||r.length<=1)return"";const o=`//${(t=>{for(const n of e){const e=E(n)?.trim();if(!e)continue;const a=`normalize-space(.)=${S(O(e))}`,r=`${n.tagName}[${a}]`;if(!t.includes(r))continue;const o=Array.from(n.children||[]).find(t=>E(t)?.trim()===e);if(o)return t.replace(r,`${n.tagName}[${o.tagName}[${a}]]`)}return t})(l+(s?"]".repeat(s):""))}/${n}::${t.tagName.toLowerCase()}[contains(text(),${S(r)})]`,i=k(o,t,a),c=C(o,t,a,i);return c&&1===k(c,t,a)?c:""};if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=o.length){const c=[],f=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=o.length;e++)c.unshift(e===o.length?o[o.length-e]:f[f.length-e]);if(r){const e=u();if(e)return[{key:`dynamic ${n} ${r?" index":""}`,value:M(e)}]}const m=Pt(`${l+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,r,i);if(m)return m}else{c=`//${l+(s?"]".repeat(s):"")}/${n}::${ie(t,e[e.length-1])}`;let o=k(c,e[e.length-1],a);if(1===o)return[{key:`dynamic ${n}`,value:M(c)}];if(o>1&&r){const t=u();if(t)return[{key:`dynamic ${n} ${r?" index":""}`,value:M(t)}];if(c=C(c,e[e.length-1],a,o),c&&(o=k(c,e[e.length-1],a),1===o))return[{key:`dynamic ${n} ${r?" index":""}`,value:M(c)}]}}},it=(e,t,n,a,r,o=!1,l=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=X(i)??i.ownerDocument,u=n.find(e=>e?.key?.includes("absolute"))?.value||Y(s,s.ownerDocument),f=[],m=[];u.split("/").map(e=>f.push(e)),f.map(e=>m.push(e.replace(/\[([0-9]+)\]/gm,"")));const g=a.find(e=>e?.key?.includes("absolute"))?.value||Y(i,i.ownerDocument),d=[],h=[];g.split("/").map(e=>d.push(e)),d.map(e=>h.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var p=0;p<f.length&&f[p]==d[p];p++);const $=[];for(let e=p-1;e<f.length;e++)f[e]&&$.push(m[e]);const v=[];for(let e="descendant"===r?p:p-1;e<d.length;e++)d[e]&&(v.length?v.push(h[e]):v.push(h[e].replace(/\[([0-9]+)\]/gm,"")));let N;if(ot=(e=>{const t=e=>{const t=e.value||"",n=/(?:contains\s*\(\s*normalize-space\s*\(\s*\.\s*\)|normalize-space\s*\(\s*\.\s*\)|contains\s*\(\s*text\s*\(\s*\)|text\s*\(\s*\)|\.\s*=)/.test(t),a=/@/.test(t);return n&&!a?0:n?1:2};return[...e].sort((e,n)=>t(e)-t(n))})(a),e[e.length-2].textContent){if(lt.test(e[e.length-2].textContent)){const t=e[e.length-2],n=E(t),a=T(t,n),r=a||(/\s/.test(n.trim())?`normalize-space(.)=${S(O(n))}`:`.=${S(n)}`);N=I(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${r}]`:`${e[e.length-2].tagName}[${r}]`}else N=I(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${le(e[e.length-2])})]`:`${e[e.length-2].tagName}[${le(e[e.length-2])}]`;$[$.length-1]=N;const n=$.join("["),a=$.length-1,s=n;for(let n=0;n<ot.length;n++){let i;if(i=ot[n].value.startsWith("//")?ot[n].value.substring(ot[n].value.indexOf("//")+2):ot[n].value,i){const n=st(e,i,r,c||t,o,v,s,a,l);if(n?.length)return n}}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(z(n,e[e.length-2])){let a=n.nodeValue;if(a){a=y(n.name,a);const s=n.name;N=I(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${S(a)}]`:`${e[e.length-2].tagName}[@${s}=${S(a)}]`,$[$.length-1]=N;const i=$.join("["),u=$.length-1,f=i;for(let n=0;n<ot.length;n++){let a;a=ot[n].value.startsWith("//")?ot[n].value.substring(ot[n].value.indexOf("//")+2):ot[n].value;const s=st(e,a,r,c||t,o,v,f,u,l);if(s?.length)return s}}}for(const n of Array.from(e[e.length-2].attributes))if(z(n,e[e.length-2])){let a=n.nodeValue;if(a){a=y(n.name,a);const s=q(n,e[e.length-2]);if(s){N=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,$[$.length-1]=N;const n=$.join("["),a=$.length-1,i=n;for(let n=0;n<ot.length;n++){let s;s=ot[n].value.startsWith("//")?ot[n].value.substring(ot[n].value.indexOf("//")+2):ot[n].value;const u=st(e,s,r,c||t,o,v,i,a,l);if(u?.length)return u}}}}}const b=$.join("["),x=$.length-1,w=Pt(`${b+(x?"]".repeat(x):"")}`,v,e[e.length-1],e,t,r,o,l);if(w)return w},ct=(e,t,n,a,r,o,l)=>{let s,i;console.log("getXpathRelationExpression",n);const c=[];try{s=a.filter(e=>!e?.key?.includes("absolute")).filter(t=>Ct(t.value,e)),i=r.filter(e=>!e?.key?.includes("absolute"));for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const l=0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2),u=$t(s[a].value,e);let f=`//${u}/${n}::${ie(l)}`;console.log("getXpathRelationExpression",f);const m=k(f,t,t.ownerDocument);if(m>1){const a=wt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=Et(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:M(r)}),c;const l=kt(u,n,t,i,t.ownerDocument);if(l)return c.push({key:`dynamic ${n}`,value:M(l)}),c;if(o){if(f=C(f,t,t.ownerDocument,m),f)return c.push({key:`dynamic ${n}${o?" index":""}`,value:M(f)}),c}else m>1&&(rt.length?m<rt[0].count&&(rt.pop(),rt.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m})):rt.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m}))}else if(1===m){if(pt(l)){const a=wt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=Et(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:M(r)}),c}return c.push({key:`dynamic ${n}`,value:M(f)}),c}}if(!c.length){const a=wt(e,t,n,s,i);if(a.length)return c.push(...a),c;for(let a=0;a<s.length;a++){const r=$t(s[a].value,e),o=Et(r,e,t,n,i);if(o)return c.push({key:`dynamic ${n} bridge`,value:M(o)}),c}for(let a=0;a<s.length;a++)for(let r=0;r<i.length;r++){const u=`${0!==i[r].value.indexOf("//")?i[r].value:i[r].value.substring(i[r].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(u.length>1){const r=$t(s[a].value,e),f=Et(r,e,t,n,i);if(f)return c.push({key:`dynamic ${n} bridge`,value:M(f)}),c;const m=Pt(r,u,t,[e,t],t.ownerDocument,n,o,l);if(console.log("getXpathRelationExpression traverseXpath",m),m)return c.push(...m),c}}}}catch(e){console.log(e)}return c},ut=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,ft=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,mt=(e,t)=>gt(e,t)[0]||"",gt=(e,t)=>{const n=[];let a="";const r=e=>{e&&!n.includes(e)&&n.push(e)};for(const n of t){const t=ft(n.value);if(t&&1===t.split(ut).length){if(t===e.tagName||t===e.tagName.toLowerCase()){a=t;continue}r(ie(t))}}for(const t of dt){const n=e.getAttribute(t);if(!n)continue;const a=ht(t,n);a&&r(I(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`)}if(e.textContent){const t=le(e);t&&r(I(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`)}const o=h(e,e.getAttribute("class"),e.getRootNode?.()??e.ownerDocument,!1);for(const t of o)r(I(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`);if(e.attributes)for(const t of Array.from(e.attributes))"class"!==t.name&&z(t,e)&&t.nodeValue&&r(I(e)?`*[local-name()='${e.tagName}' and @${t.name}=${S(y(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${S(y(t.name,t.nodeValue))}]`);return a&&r(a),r(I(e)?`*[local-name()='${e.tagName}']`:e.tagName),n},dt=["aria-labelledby","aria-label","role","name","formcontrolname","data-testid","data-test","data-qa","data-id","id"],ht=(e,t)=>{const n=y(e,t);return n?/\d/.test(n)?"":`@${e}=${S(n)}`:""},pt=e=>e.split(ut).length>1||/\[\d+\]/.test(e),$t=(e,t)=>0!==e.indexOf("//")?ie(e):ie(e.substring(e.indexOf("//")+2)),yt=e=>{const t=[];for(const n of dt){const a=e.getAttribute(n);if(!a)continue;const r=ht(n,a);if(r){t.push(I(e)?`*[local-name()='${e.tagName}' and ${r}]`:`${e.tagName}[${r}]`);break}}return t},vt=(e,t=6)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},Nt=(e,t)=>{const n=ht(e,t);if(n)return n;const a=y(e,t);if("id"!==e||!a)return"";const r=a.match(/^(.+?)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),o=r?.[1]?.trim();return!o||o.length<=2||!/[a-zA-Z]/.test(o)?"":`contains(@${e},${S(o)})`},bt=(e,t,n,a,r,o,l)=>{let s=n.parentElement,i=0;for(;s&&s!==a&&i<6;){i++;for(const t of dt){const a=s.getAttribute(t);if(!a)continue;const i=ht(t,a);if(!i)continue;const c=I(s)?`*[local-name()='${s.tagName}' and ${i}]`:`${s.tagName}[${i}]`,u=`//${ie(e)}/${r}::${o}/descendant::${c}/descendant::${ie(l)}`;if(1===k(u,n,n.ownerDocument))return u}s=s.parentElement}return""},xt=["title",...dt],Et=(e,t,n,a,r)=>((e,t,n,a,r)=>{if("following"!==a&&"preceding"!==a)return"";const o=gt(n,r);if(!o.length)return"";const l=At(`//${ie(e)}`,t.ownerDocument)||t;let s=n.parentElement,i=0;for(;s&&i<6;)if(i++,l.compareDocumentPosition(s)&("following"===a?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)){for(const t of xt){const r=s.getAttribute(t);if(!r)continue;const l=ht(t,r);if(!l)continue;const i=I(s)?`*[local-name()='${s.tagName}' and ${l}]`:`${s.tagName}[${l}]`;for(const t of o){const r=`//${ie(e)}/${a}::${i}/descendant::${ie(t)}`;if(1===k(r,n,n.ownerDocument))return r}}s=s.parentElement}else s=s.parentElement;return""})(e,t,n,a,r)||((e,t,n,a,r)=>{if("following-sibling"!==a&&"preceding-sibling"!==a)return"";const o=gt(n,r);if(!o.length)return"";const l=vt(t),s=vt(n);for(const t of l){const r=yt(t);if(r.length)for(const l of s){const s=yt(l);if(!s.length)continue;const i="following-sibling"===a?t.nextElementSibling===l||Array.from(t.parentElement?.children||[]).indexOf(l)>Array.from(t.parentElement?.children||[]).indexOf(t):t.previousElementSibling===l||Array.from(t.parentElement?.children||[]).indexOf(l)<Array.from(t.parentElement?.children||[]).indexOf(t);if(t.parentElement&&t.parentElement===l.parentElement&&i)for(const t of r)for(const r of s)for(const l of o){const o=`//${ie(e)}/ancestor-or-self::${t}/${a}::${r}/descendant-or-self::${ie(l)}`;if(1===k(o,n,n.ownerDocument))return o}}}return""})(e,t,n,a,r)||((e,t,n,a,r)=>{if("child"!==a)return"";const o=gt(n,r);if(!o.length)return"";const l=vt(n).filter(e=>e.parentElement===t);for(const t of l){const a=yt(t);if(a.length)for(const t of a)for(const a of o){const r=`//${ie(e)}/child::${t}/descendant-or-self::${ie(a)}`;if(1===k(r,n,n.ownerDocument))return r}}return""})(e,t,n,a,r),wt=(e,t,n,a,r)=>"ancestor"!==n&&"ancestor-or-self"!==n?[]:Dt(e,t,n,a,r,!1),kt=(e,t,n,a,r)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";for(const o of a){const a=ft(o.value);if(!a||a.split(ut).length>1||/\[\d+\]/.test(a))continue;const l=`//${e}/${t}::${ie(a)}`;if(1===k(l,n,r))return l}return""},St=(e,t,n,a)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";const r=gt(n,[...nt(n,n.ownerDocument,!1,!1)||[],...ce(n,n.ownerDocument,!0)||[],{key:"tag",value:n.tagName}]);if(!r.length)return"";let o=n.parentElement,l=0;for(;o&&l<10;){l++;for(const l of dt){const s=o.getAttribute(l);if(!s)continue;const i=Nt(l,s);if(!i)continue;const c=I(o)?`*[local-name()='${o.tagName}' and ${i}]`:`${o.tagName}[${i}]`;for(const o of r){const r=`//${e}/${t}::${c}/descendant::${ie(o)}`;if(1===k(r,n,a))return r}}o=o.parentElement}return""},At=(e,t)=>{try{const n=t.evaluate(e,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return n instanceof Element?n:null}catch{return null}},Ct=(e,t)=>{const n=ft(e);if(!n)return!1;try{const e=t.ownerDocument.evaluate(`//${ie(n)}`,t.ownerDocument,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let a=e.iterateNext();for(;a;){if(a===t)return!0;a=e.iterateNext()}}catch{return!1}return!1},Rt=e=>{const t=e.getAttribute("fill"),n=e.getAttribute("stroke");if(/\d/.test(t||"")||/\d/.test(n||""))return"";const a=t?`@fill=${S(t)}`:n?`@stroke=${S(n)}`:"";return a?`*[local-name()='${e.tagName.toLowerCase()}' and ${a}]`:""},Ot=(e,t,n)=>{const a=t.getAttribute("fill"),r=t.getAttribute("stroke"),o=Array.from(e.querySelectorAll(t.tagName.toLowerCase())).slice(0,30);let l=0;for(const e of o){if(a&&e.getAttribute("fill")!==a||!a&&r&&e.getAttribute("stroke")!==r)continue;const t=e.closest(n.tagName.toLowerCase());if(t&&(l++,t!==n||l>1))return!1}return 1===l},Tt=(e,t,n,a,r)=>{const o=Array.from(n.querySelectorAll("path,use,circle,rect,polygon,polyline,line")).slice(0,25);if(!o.length)return"";const l=[...(s=a,h(s,s.getAttribute("class"),s.getRootNode?.()??s.ownerDocument).map(e=>`${s.tagName.toLowerCase()}[${e}]`)),a.tagName];var s;for(const t of o){const o=Rt(t);if(o&&Ot(a,t,n))for(const t of l)return`//${ie(e)}/${r}::${t}/descendant::${o}/ancestor::${n.tagName.toLowerCase()}`}return""},Dt=(e,t,n,a,r,o)=>{const l=[],s=((e,t)=>{let n=e;for(;n;){if(n.contains(t))return n;n=n.parentElement}return null})(e,t);if(!s||s===t)return l;const i=I(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let r=t;for(;r&&r!==e;){const e=r===t?mt(t,n):I(r)?`*[local-name()='${r.tagName}']`:r.tagName;a.unshift(e),r=r.parentElement}return r===e?a.join("/"):""})(s,t,r);if(!c)return l;const u=c.split(ut).length>1?mt(t,r):"",f=u?((e,t)=>{let n=e,a=0;const r=[],o=new Set(["SECTION","FIELDSET","FORM","ARTICLE","MAIN"]);for(;n&&n.contains(t)&&a<6;){a++;for(const e of dt){const t=n.getAttribute(e);if(!t)continue;const l=ht(e,t);if(!l)continue;const s=I(n)?`*[local-name()='${n.tagName}' and ${l}]`:`${n.tagName}[${l}]`,i=(o.has(n.tagName)?100:0)+("data-testid"===e?20:0)-a;r.push({nodeTest:s,score:i});break}n=n.parentElement}return r.sort((e,t)=>t.score-e.score)[0]?.nodeTest||""})(s,t):"";for(const e of a){const a=ft(e.value);if(!a)continue;if(f){const e=`//${ie(a)}/${n}::${f}/descendant::${ie(u)}`;if(1===k(e,t,t.ownerDocument))return l.push({key:`dynamic ${n} bridge`,value:M(e)}),l}let r=u?`//${ie(a)}/${n}::${i}/descendant::${ie(u)}`:`//${ie(a)}/${n}::${i}/${c}`,m=k(r,t,t.ownerDocument);const g=Tt(a,0,t,s,n);if(g)return l.push({key:`dynamic ${n} icon bridge`,value:M(g)}),l;if(1===m)return l.push({key:`dynamic ${n} bridge`,value:M(r)}),l;if(u&&m>1){const e=bt(a,0,t,s,n,i,u);if(e)return l.push({key:`dynamic ${n} bridge`,value:M(e)}),l;if(r=`//${ie(a)}/${n}::${i}/${c}`,m=k(r,t,t.ownerDocument),1===m)return l.push({key:`dynamic ${n} bridge`,value:M(r)}),l}if(m>1&&o&&(r=C(r,t,t.ownerDocument,m),m=r?k(r,t,t.ownerDocument):0,r&&1===m))return l.push({key:`dynamic ${n} bridge index`,value:M(r)}),l}return l},Pt=(e,t,n,a,r,o,l,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${o}::${ie(s)}`;const c=k(i,n,r);if(1===c)return[{key:`dynamic ${o}`,value:M(i)}];if(c>1&&l&&(i=C(i,a[a.length-1],r,c),i))return[{key:`dynamic ${o}${l?" index":""}`,value:M(i)}]}else for(let s=1;s<=t.length;s++){const c=Xt(t.slice(t.length-s,t.length).join("/"),n);for(const t of c){i=`//${e}/${o}::${ie(t)}`;const s=k(i,n,r);if(1===s){if(t.split(ut).length>1||/\[\d+\]/.test(t)){const t=St(e,o,n,r);if(t)return[{key:`dynamic ${o}`,value:M(t)}]}if(!l&&/\[\d+\]/.test(t))continue;return[{key:`dynamic ${o}`,value:M(i)}]}if(s>1){const t=kt(e,o,n,nt(n,n.ownerDocument,!1,!1)||[],r);if(t)return[{key:`dynamic ${o}`,value:M(t)}];const c=St(e,o,n,r);if(c)return[{key:`dynamic ${o}`,value:M(c)}];if(l&&(i=C(i,a[a.length-1],r,s),i))return[{key:`dynamic ${o}${l?" index":""}`,value:M(i)}]}}}},Xt=(e,t)=>{const n=t.getAttribute("class")||"",a=h(t,n,t.getRootNode?.()??t.ownerDocument);if(!a.length)return[e];const r=`${t.tagName}[@class=${S(n)}]`;return e.endsWith(r)?a.map(n=>{const a=`${t.tagName}[${n}]`;return`${e.slice(0,-r.length)}${a}`}):[e]},_t={findRelativeXpath:(e,t,n,a,r,o,l=!1,s=null)=>{let i=[];const c=s||[],u=(o,s)=>{let c=[];c="descendant"===o||"descendant-or-self"===o?it([e,t],n,a,r,o,s,l)||[]:ct(e,t,o,a,r,s,l)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,o);return i},getDescendantXpath:it,getAncestorBridgeXpath:Dt,getXpathRelationExpression:ct,getTraverseXpathExpression:Pt,getReferenceElementXpath:e=>{let t=[];t=nt(e,e.ownerDocument,!1,!1);const n=ce(e,e.ownerDocument,!1);if(n?.length&&(t=t?.length?t.concat(n):n),t?.length){let n=nt(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&fe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:A(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=nt(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&fe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:A(e.value)}:{key:"",value:e.value});t?.length||(t=[{key:"",value:V(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:V(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&fe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:A(e.value)}:{key:"",value:e.value}));const a=Array.from(e.children||[]).map(t=>{const n=E(t)?.trim();if(!n||n!==E(e)?.trim())return null;const a=T(t,n),r=a||(/\s/.test(n)?`normalize-space(.)=${S(O(n))}`:`.=${S(n)}`);return{key:"reference child text",value:`${t.tagName}[${r}]`}}).filter(e=>!!e);a.length&&(t=a.concat(t));const r=Y(e,e.ownerDocument);return t=t.filter(e=>e.value!==r),t.push({key:"absolute xpath",value:r.slice(1)}),t},getSmartRelations:(e,t)=>{const n=e.compareDocumentPosition(t),a=[],r=[],o=[];n&Node.DOCUMENT_POSITION_CONTAINS&&a.push("ancestor","ancestor-or-self","parent"),n&Node.DOCUMENT_POSITION_CONTAINED_BY&&a.push("child"),e.parentElement===t.parentElement&&a.push("following-sibling","preceding-sibling"),n&Node.DOCUMENT_POSITION_FOLLOWING&&r.push("following"),n&Node.DOCUMENT_POSITION_PRECEDING&&r.push("preceding"),o.push("descendant","descendant-or-self");const l=[...a,...r,...o];return[...new Set(l)]}},Lt=["data-testid","data-test-id","data-test","data-cy","data-qa","name","aria-label","aria-labelledby","placeholder","title","alt","role"],zt=new Set(["id","class","style"]),It=(e,t)=>{const n=t?.ownerDocument?.defaultView?.CSS??globalThis.CSS;return n?.escape?n.escape(e):String(e).replace(/[^a-zA-Z0-9_-]/g,"\\$&")},Mt=e=>{if(!e)return!1;const t=e.ownerDocument?.defaultView;return Boolean(t&&e instanceof t.Element)},jt=e=>{const t=e.tagName.toLowerCase();return"style"===t||"script"===t},Yt=e=>{const t=e.trim();return Boolean(t)&&t.length<=120&&!/^\d+$/.test(t)},Vt=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},qt=(e,t,n)=>{n&&!e.some(e=>e.value===n)&&e.push({key:t,value:n})},Wt=(e,t="single")=>{const n=[],a=e.getRootNode();try{const r=Ut(e);if(r&&Vt(r,e,a)&&(qt(n,"cssSelector by id",r),"single"===t))return n;const o=Ht(e);if(o&&(qt(n,"cssSelector by attribute",o),"single"===t))return n;const l=Gt(e);if(l&&Vt(l,e,a)&&(qt(n,"cssSelector by class",l),"single"===t))return n;const s=Jt(e);if(s&&Vt(s,e,a)&&(qt(n,"cssSelector by stable parent",s),"single"===t))return n;if("multiple"===t&&0===n.length){const t=Qt(e);t&&Vt(t,e,a)&&qt(n,"cssSelector by position fallback",t)}}catch(e){console.error(e)}return n},Ut=e=>{if(!Mt(e)||jt(e))return;const t=e.getAttributeNode("id");return t&&Yt(t.value)&&z(t,e)?`#${It(e.id,e)}`:void 0};function Ft(e,t=!1){const n=Array.from(e.attributes).filter(n=>{const a=n.name.toLowerCase();return!zt.has(a)&&(!(t&&!Lt.includes(a))&&(Yt(n.value)&&z(n,e)))});return n.sort((e,t)=>{const n=Lt.indexOf(e.name.toLowerCase()),a=Lt.indexOf(t.name.toLowerCase());return(-1===n?999:n)-(-1===a?999:a)}),n.map(e=>{return`[${e.name}="${t=e.value.trim(),String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const Ht=e=>{if(!Mt(e)||jt(e))return;const t=e.getRootNode(),n=e.tagName.toLowerCase(),a=Ft(e);for(const r of a){if(Vt(r,e,t))return r;const a=`${n}${r}`;if(Vt(a,e,t))return a}},Gt=e=>{if(!Mt(e)||jt(e))return;const t=Bt(e);if(!t)return;const n=e.getRootNode(),a=`${e.tagName.toLowerCase()}${t}`;return Vt(t,e,n)?t:Vt(a,e,n)?a:void 0},Bt=e=>{if("string"!=typeof e.className||!e.className||o?.find(t=>t.element===e&&"class"===t.attributeName))return;const t=p(e,e.className).filter(Yt);return t.length?t.slice(0,3).map(t=>`.${It(t,e)}`).join(""):void 0},Zt=(e,t={})=>{if(!Mt(e)||jt(e))return[];const n=[],a=e.tagName.toLowerCase(),r=Ut(e);r&&n.push(r);for(const r of Ft(e,t.preferredAttributesOnly))n.push(r),t.includeTag&&n.push(`${a}${r}`);const o=Bt(e);return o&&(n.push(o),t.includeTag&&n.push(`${a}${o}`)),Array.from(new Set(n))},Jt=e=>{if(!Mt(e)||jt(e))return;const t=e.getRootNode(),n=Zt(e,{includeTag:!0,preferredAttributesOnly:!1});let a=e.parentElement;for(;a&&Mt(a)&&!jt(a);){const r=Zt(a,{includeTag:!0,preferredAttributesOnly:!0});for(const o of r)if(Vt(o,a,t))for(const a of n){const n=`${o} ${a}`;if(Vt(n,e,t))return n;const r=`${o} > ${a}`;if(Vt(r,e,t))return r}a=a.parentElement}},Kt=e=>{let t=1,n=e.previousElementSibling;for(;n;)n.tagName===e.tagName&&t++,n=n.previousElementSibling;return t},Qt=e=>{if(!Mt(e)||jt(e))return;const t=e.getRootNode(),n=e.tagName.toLowerCase();let a=e.parentElement;for(;a&&Mt(a)&&!jt(a);){const r=Zt(a,{includeTag:!0,preferredAttributesOnly:!0});for(const o of r){if(!Vt(o,a,t))continue;const r=`${o} > ${n}:nth-of-type(${Kt(e)})`;if(Vt(r,e,t))return r}a=a.parentElement}return en(e)},en=e=>{const t=e.ownerDocument?.defaultView;if(!(t&&e instanceof t.Element))return;const n=[];for(;e&&e.nodeType===t.Node.ELEMENT_NODE;){const t=e.tagName.toLowerCase();if("style"===t||"script"===t)return;let a=t;const r=e.parentNode;if(r){const t=Array.from(r.children).filter(t=>t.tagName===e.tagName);t.length>1&&(a+=`:nth-of-type(${t.indexOf(e)+1})`)}n.unshift(a),e=e.parentElement}return n.join(" > ")},tn={parseCssSelectors:Wt,getIdCssPath:Ut,getAttributeCssPath:Ht,getClassCssPath:Gt,getAbsoluteCssPath:en},nn=(e,t,n)=>{const a=ue(e);if(gn(t,a)===n)return!0;if(function(e){return/\[(?:\s*\.|\s*contains\s*\(\s*\.|\s*normalize-space\s*\(\s*\.)/.test(e)}(a)){const e=t.evaluate(a,t,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let t=0;t<e.snapshotLength;t++)if(e.snapshotItem(t)===n)return!0}return!1},an=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return ln(e.body,t)},rn=(e,t,n)=>an(t,e)===n,on=e=>e.name?.toLowerCase().includes("cssselector")??!1,ln=(e,t)=>{const n=Array.from(e.querySelectorAll("*"));try{for(let e=0;e<n.length;e++)if(n[e].shadowRoot){const{shadowRoot:a}=n[e];if(a){const e=ln(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},sn=e=>e?.id||null,cn=e=>e.className||null,un=e=>e.textContent?.trim()||null,fn=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},mn=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function gn(e,t){const n=e.defaultView;if(!n)return null;return(new n.XPathEvaluator).evaluate(t,e,null,n.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}function dn(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),r=n.defaultView;if(!r)return null;if(!e.includes("dynamic")){const t=new r.XPathEvaluator;if(t.evaluate(a,n,null,r.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,r.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue?(a=e,a):(console.error("Complete Locator is Invalid:",e),a=e,a)}console.error("Source Locator Not Found:",a)}}return null}const hn=(e,t)=>{const n=t.querySelectorAll("script, style, link[rel='stylesheet'], meta, noscript, embed, object, param, source, svg");n&&n.forEach(e=>{e.remove()});const a=new Set;let r=[];function o(e,t={}){const n=e?.value,o=t.value??e?.value,l={name:t.name??e?.name,type:t.type??e?.type,value:t.value??e?.value,reference:t.reference??e?.reference,status:t.status??e?.status,isRecorded:t.isRecorded??e?.isRecorded},s="Y"===e?.isSelfHealed;l.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(l.name,n,o),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),r.push(e))}(l)}function l(e,t,n){if(on(t))return an(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+ge(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=ge(n);return e.querySelector(`[name="${t}"]`)}if("tagName"===t.name)return e.querySelector(n);if("linkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.trim()===n)||null;if("partialLinkText"===t.name)return Array.from(e.querySelectorAll("a")).find(e=>e.textContent?.includes(n))||null;if(!t.name.includes("xpath")&&!n.startsWith("//")||t.type.match("dynamic"))return e.querySelector(n);{const a=gn(e,ue(n));return a&&o(t,{value:n,isRecorded:String(t.isRecorded).includes("N")?"N":"Y"}),a}}function s(e,t,n){const a=e.querySelectorAll("iframe");for(const e of a)try{const a=e.contentDocument||e.contentWindow?.document;if(!a)continue;const r=l(a,t,n);if(r)return r}catch{continue}return null}const i=(e,t,n)=>{if(!e)return null;let a=e.trim();return a&&"null"!==a.toLowerCase()?(a=a.replace(/\\"/g,'"').replace(/\\'/g,"'"),a=a.replace(/^['"](.+?)['"]$/,"$1"),a=a.replace(/''/g,"'"),a=a.replace(/\[@(id|name)=['"]{2}(.+?)['"]{2}\]/g,"[@$1='$2']"),"id"!==t&&"name"!==t||(a=a.replace(/['"]/g,"").trim()),"xpath"!==t||"Y"!==n||e.startsWith("//")?!a||/^['"]{2}$/.test(a)?null:a:null):null};e:for(const n of e.locators)try{String(n.isRecorded||"");const c=e.locators.filter(e=>"N"===e.isRecorded);if(c.length>0)for(const e of c)o(e);const u=String(n.value||n.type||"");if(u.includes("dynamic")||u.match("dynamic")||u.includes("{")||u.includes("}")){o(n);continue}if(e.isShared.includes("Y"))break e;try{let c=null;const u=n.value.split(">>>");for(const e of u){if(!t){console.error("Element not found at:",e);break}const a=e.trim();if(c=l(t,n,a),c||(c=s(t,n,a)),c||(c=ln(t.body,a)),!c){console.error("Element not found at:",a);break}}const f=(e,t)=>{const n=`${e}:${t}`;return a.has(n)};if(c){const n=e.locators.filter(e=>"xpath"===e.name&&e.value),a=e.locators.filter(e=>on(e)&&e.value);for(const e of n)nn(e.value,t,c)&&o(e,{isSelfHealed:null});for(const e of a)rn(e.value,t,c)&&o(e,{isSelfHealed:null});const l=r.filter(e=>"xpath"===e.name&&e.value),s=new Set(l.map(e=>me(e.value))),u=[],m=sn(c);if(m&&!f("id",m)&&!b(m)){const n=e.locators.find(e=>"id"===e.name);de(t,"id",m,c)&&(u.push("id"),o(n,{name:"id",type:"static",isRecorded:"Y",value:m}))}const g=c.tagName;if(g&&!f("tagName",g)){const n=e.locators.find(e=>"tagName"===e.name);de(t,"tagName",g,c)&&(u.push("tagName"),o(n,{name:"tagName",type:"static",isRecorded:"Y",value:g}))}const d=un(c);if(d&&!b(d)){const n=e.locators.find(e=>"linkText"===e.name);de(t,"linkText",d,c)&&(u.push("linkText"),o(n,{name:"linkText",type:"static",isRecorded:"Y",value:d}))}const h=fn(c);if(h&&!f("name",h)&&!b(h)){const n=e.locators.find(e=>"name"===e.name);de(t,"name",h,c)&&(u.push("name"),o(n,{name:"name",type:"static",isRecorded:"Y",value:h}))}const p=cn(c);if(p&&""!==p.trim()&&!p.includes(" ")&&!f("className",p)&&!b(p)){const n=e.locators.find(e=>"className"===e.name);de(t,"className",p,c)&&(u.push("className"),o(n,{name:"className",type:"static",isRecorded:"Y",value:p}))}Wt(c,"single").forEach(e=>{e.value&&!f("cssSelector",e.value)&&o(void 0,{name:"cssSelector",value:e.value,type:"static",isRecorded:"Y"})});const $=Array.from(c.attributes).filter(e=>!u.includes(e.name));let y=[];try{y=nt(c,t,!1,!0,$)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==y?.length){const e=n.filter(e=>!nn(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=me(t.value);if(s.has(n))continue;const r=y.find(e=>e.value&&me(e.value)===n);r?.value&&(o(t,{name:"xpath",value:r.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}if(a<e.length)for(const t of y){if(a>=e.length)break;if(!t.value)continue;const n=me(t.value);s.has(n)||(o(t,{name:"xpath",value:t.value,type:"static",isRecorded:"Y",isSelfHealed:"Y"}),s.add(n),a++)}}for(const n of e.locators)try{for(const a of e.locators)if(a.value)for(const e of mn)if(a.value.includes(e)){const r=dn(a.value,e,t);if(r){o(a,{name:"xpath",value:r,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(r.length<5){const e=[{name:"id",value:sn(c)},{name:"name",value:fn(c)},{name:"className",value:cn(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:un(c)}];for(const n of e){if(r.length>4)break;const{name:e,value:a}=n;a&&(b(a)||f(e,a)||"className"===e&&a.includes(" ")||de(t,e,a,c)&&o(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}r.length<5&&Wt(c,"multiple").forEach(e=>{r.length>4||e.value&&(f("cssSelector",e.value)||de(t,"cssSelector",e.value,c)&&o(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const v=r.map(e=>({...e,value:i(e.value,e.name,e.isRecorded)})),N=[{name:`${e.name}`,desc:`${e.desc}`,type:`${e.type}`,locators:v.filter(e=>null!=e?.value&&""!==e.value),isShared:`${e.isShared}`,projectId:`${e.projectId}`,projectType:`${e.projectType}`,isRecorded:`${e.isRecorded}`,folder:`${e.folder}`,parentId:`${e.parentId}`,parentName:`${e.parentName}`,platform:`${e.platform}`,licenseId:`${e.licenseId}`,licenseType:`${e.licenseType}`,userId:`${e.userId}`}];return N}}catch(e){console.error("Error processing locator:",n,e);continue}}catch(e){console.error("Error processing locator:",n,e);continue}return null};const pn={getOptimalClassChain:function e(t,n,a){try{if(!n||1!==n.nodeType||!n.tagName||"XCUIElementTypeApplication"===n.tagName)return"";const r=n.tagName,o=["name","label","value"];for(const e of o){const o=a.find(t=>t.name===e);if(!o)continue;let l=o.value;if(!l)continue;if(l=l.trim().replace(/\s+/g," "),b(l))continue;const s=`//${r}[@${e}="${l}"]`;let i=0;try{i=k(s,n,t)}catch(e){console.log(e);continue}const c=/\s/.test(l);if(1===i)return c?`/${r}[\`${e} CONTAINS "${l}"\`]`:`/${r}[\`${e} == "${l}"\`]`;if(i>1&&n.parentElement){const t=Array.from(n.parentElement.children).filter(e=>e.tagName===r).indexOf(n)+1;return c?`/${r}[\`${e} CONTAINS "${l}"\`][${t}]`:`/${r}[\`${e} == "${l}"\`][${t}]`}}let l=`/${r}`;if(n.parentElement){const e=Array.from(n.parentElement.children).filter(e=>e.tagName===r);if(e.length>1){l+=`[${e.indexOf(n)+1}]`}}return e(t,n.parentElement,a)+l}catch(e){return console.log(`Unable to generate optimal -ios class chain : ${JSON.stringify(e)}`),null}},getOptimalPredicateString:function(e,t,n){try{if(!t?.tagName||1!==t?.nodeType||"XCUIElementTypeApplication"===t?.tagName)return"";let a=[],r=[];for(let o of n){const n=o.value,l=o.name;if(0!==n.length&&(n&&!b(n))){a.push(`@${l}="${n}"`);const o=`//*[${a.join(" and ")}]`;let s;r.push(`${l} == "${n}"`);try{s=k(o,t,e)}catch(e){console.log(e);continue}if(1===s)return r.join(" AND ")}}}catch(e){console.log(`The most optimal '-ios predicate string' could not be determined because an error was thrown: '${JSON.stringify(e,null,2)}'`)}return null}},$n=()=>({xpath:at,referenceXpaths:_t,xpathUtils:he,getElementsFromHTML:hn,cssSelectors:tn,iosSelectors:pn});exports.createXPathAPI=$n,exports.default=$n;
|
|
2
2
|
//# sourceMappingURL=index.browser.cjs.map
|