ff-dom 3.0.0-beta.1 → 3.0.0-beta.3

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.cdn.js CHANGED
@@ -1 +1 @@
1
- !function(e){"use strict";const t=/^[\S]+( [\S]+)*$/i;let n=new WeakMap;const a=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=>{n.delete(e)}):n=new WeakMap},l=(e,t)=>{const{owner:a,contextNode:l}=(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}})(t);let r=n.get(l);r||(r=new Map,n.set(l,r));const o=r.get(e);if(o)return o;const s=a.evaluate(e,l,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),i={first:s.iterateNext(),second:s.iterateNext()};return r.set(e,i),i};let r,o=new Map,s=[];const i=new Set(["marked-element-temp","removePointers"]),c=e=>(e||"").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!i.has(e)).sort(),u=(e,t)=>t?"class"===e||"className"===e?c(t).join(" "):t.replace("removePointers","").trim():"",f=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(S(e.target)&&e.oldValue?.trim()===e.target.classList.value?.trim())return!0;const t=c(e.oldValue),n=c(e.target.getAttribute("class"));return t.join(" ")===n.join(" ")},m=e=>/\d/.test(e),h=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,d=e=>{const t=e?.textContent;return t},g=e=>e?.childNodes[0]?.nodeValue||"",p=(e,t,n,a=!1)=>{try{const{first:r,second:o}=l(e,n);if(!r)return 0;if(!o)return r===t?1:0;if(a&&Array.isArray(t)){let a=0;if(t.includes(r)&&a++,t.includes(o)&&a++,2===a)return 2;const l=(9===n.nodeType?n:n.ownerDocument).evaluate(e,n,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);let s;for(;s=l.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}},$=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},y=e=>{const t=e.split("");let n=t.length;const a=[];for(;"["!==t[n-2];)a.push(t[n-2]),n--;a.reverse();let l="";for(let e=0;e<a.length;e++)l+=a[e];const r=l.length+2;let o=e.slice(0,e.length-r);return o=o.startsWith("(")&&o.endsWith(")")?o.slice(1,-1):e,o},v=(e,t,n,a)=>{try{const l=9===n.nodeType?n:n.ownerDocument;let r=0;if(a){if(1===p(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===p(`(${e})[${a}]`,t,n))return`(${e})[${a}]`}const o=l.evaluate(e,n,null,XPathResult.ANY_TYPE,null);let s=null;for(;s=o.iterateNext();)if(r++,s.isSameNode(t))return 1===p(`${e}[${r}]`,t,n)?`${e}[${r}]`:1===p(`(${e})[${r}]`,t,n)?`(${e})[${r}]`:void 0}catch(e){console.log(e)}},N=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(),x=e=>e?e.replace(/\s\s+/g," ").trim():e,b=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},E=(e,t)=>{const n=e.ownerDocument.implementation.createHTMLDocument("shadow-xpath"),a=n.createElement("div");a.innerHTML=e.innerHTML,n.body.appendChild(a);const l=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},r=Array.isArray(t)?t.map(e=>l(e)).filter(Boolean):[],o=Array.isArray(t)?null:l(null);return{owner:n,contextNode:a,cloneElement:o,cloneElements:r}},w=(e,t,n)=>{const a=u(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 l=s?.find(n=>n.doc===t.ownerDocument&&n.element===t&&n.attributeName===e.name);return!l&&(!(0===e?.name?.indexOf("on")&&e?.name?.length>3)&&("function"!=typeof e.value&&(!n||!m(a))))},S=e=>e instanceof SVGElement,k=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,C=(e,n,a,l,r,o)=>{if(l){const{tagName:s}=e;let i,c="";const u=[];let f;if(l&&(!o||!m(l))&&(f=t.test(l)?`//${s}[${a}=${$(l)}]`:h(`normalize-space(${a})=${$(x(l)).trim()}`,S(e),e.tagName.toLowerCase()),i=p(f,e,n),1===i&&!r))return f;if(l&&o){const o=l.split(" ");if(o?.length)if(1===o.length){const u=[...new Set(o[0].match(/([^0-9]+)/g))];if(u?.length>=1&&u[0]&&x(u[0].trim())?.length>1&&l.startsWith(u[0])&&(c=t.test(u[0])?`starts-with(${a},${$(u[0]).trim()})`:`starts-with(${a},${$(x(u[0])).trim()})`),u?.length>1&&u[u.length-1]&&x(u[u.length-1].trim())?.length>1&&l.endsWith(u[u.length-1])&&(c=t.test(u[u.length-1])?`ends-with(${a},${$(u[u.length-1]).trim()})`:`ends-with(${a},${$(x(u[u.length-1])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f}else{const u=o.length%2==0?o.length/2:o.length%2,m=o.slice(0,u).join(" ");let h=[...new Set(m.match(/([^0-9]+)/g))];if(h?.length&&h[0]&&x(h[0].trim())?.length&&l.startsWith(h[0])&&(c=t.test(h[0])?`starts-with(${a},${$(h[0]).trim()})`:`starts-with(${a},${$(x(h[0])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f;const d=o.slice(u,o.length-1).join(" ");if(h=[...new Set(d.match(/([^0-9]+)/g))],h?.length&&h[0]&&x(h[0].trim())?.length>3&&l.endsWith(h[0])&&(c=t.test(h[0])?`ends-with(${a},${$(h[0]).trim()})`:`ends-with(${a},${$(x(h[0])).trim()})`),c?.length&&(f=S(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=p(f,e,n),1===i&&!r))return f}}if(l&&o&&m(l)){const o=[...new Set(l.match(/([^0-9]+)/g))];if(o?.length)for(let e=0;e<o?.length;e++)o[e]&&x(o[e].trim())?.length>1&&(t.test(o[e])?u.push(`contains(${a},${$(o[e].trim()).trim()})`):u.push(`contains(${a},${$(x(o[e])).trim()})`));if(u?.length&&(f=S(e)?`//*[local-name()='${s}' and ${u.join(" and ")}]`:`//${s}[${u.join(" and ")}]`,i=p(f,e,n),1===i&&!r))return f}if(f=S(e)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=p(f,e,n),1===i&&!r)return f}},R=(e,t)=>{try{if(!e)return"";let n=S(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 R(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},O=(e,t,n,a=!1,l)=>{try{if(o.has(e))return o.get(e);const r=[];let s=e;for(;s;){let o="",i=!1,c=e===s?l??s.attributes:s.attributes;for(const e of Array.from(c))if(w(e,s,a)){const a=u(e.name,e.nodeValue),l=e.name;o=F(s,l,a);let c=0;if(o&&(c=p(o,s,t),1===c)){r.unshift(k(o)),i=!0;break}if(c>1&&n&&(o=v(o,s,t,c),o)){r.unshift(k(o)),i=!0;break}}if(s.textContent)if(!a||a&&!m(s.textContent)){o=new RegExp(/^[\S]+( [\S]+)*$/gi).test(s.textContent)?S(s)?`//*[local-name()='${s.tagName}' and .=${$(g(s))}]`:`//${s.tagName||"*"}[.=${$(g(s))}]`:S(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${$(g(s))}]`:`//${s.tagName||"*"}[normalize-space(.)=${$(g(s))}]`;let e=p(o,s,t);if(1===e)return o;if(e>1&&n)return o=v(o,s,t,e),o}else{let e=[];const a=[...new Set(g(s).match(/([^0-9]+)/g))];let l=new RegExp(/^[\S]+( [\S]+)*$/gi);if(a?.length)for(let t=0;t<a?.length;t++)a[t]&&x(a[t].trim())&&(l.test(a[t])?e.push(`contains(.,${$(a[t].trim()).trim()})`):e.push(`contains(.,${$(x(a[t])).trim()})`));if(e?.length){o=S(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=p(o,s,t);if(1===a)return o;if(a>1&&n)return o=v(o,s,t,a),o}}if(i)break;{let e=S(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}]`}}r.unshift(e)}s=s.parentElement}const i=`${r.join("")}`;return o.set(e,i),i}catch(e){return console.log(e),null}},T=(e,n)=>{const a=[];let l="";if(e&&!m(e.value)&&"function"!=typeof e.nodeValue){const r=[...new Set(e.value.match(/([^0-9]+)/g))];if(r?.length)for(let n=0;n<r?.length;n++)r[n]&&x(r[n].trim())?.length>2&&(t.test(r[n])?a.push(`contains(@${e.name},${$(r[n].trim())})`):a.push(`contains(@${e.name},${$(x(r[n])).trim()})`));if(a?.length)return l=S(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,l}},A=(e,n,a,l)=>{try{const r=a.filter(t=>w(t,e,l)),o=a=>{const l=u(a.name,a.nodeValue);if(!l)return[];if("class"===a.name){const t=l.split(/\s+/).map(e=>e.trim()).filter(Boolean);if(!t.length)return[];const a=t.map(t=>{const a=h(`contains(@class,${$(t)})`,S(e),e.tagName.toLowerCase());return{token:t,count:M(a,e,n)}}).sort((e,t)=>e.count!==t.count?e.count-t.count:t.token.length-e.token.length);return a[0]?.token?[`contains(@class,${$(a[0].token)})`]:[]}return t.test(l)?[`@${a.name}="${l}"`]:[`normalize-space(@${a.name})="${l}"`]},s=()=>{const n=x(d(e)?.trim()||"");if(!n||n.length>80||/^\d+$/.test(n))return[];const a=new Set;return t.test(n)&&n.length<=40&&a.add(`text()=${$(n)}`),n.includes(" ")&&a.add(`normalize-space(text())=${$(x(n))}`),a.add(`contains(text(),${$(n)})`),Array.from(a)},i=(e,t)=>{const n=[],a=(l,r)=>{if(r.length!==t)for(let t=l;t<e.length;t++)r.push(e[t]),a(t+1,r),r.pop();else n.push([...r])};return a(0,[]),n},c=t=>S(e)?`//*[local-name()='${e.tagName}' and ${t.join(" and ")}]`:`//${e.tagName}[${t.join(" and ")}]`,f=()=>{if(!(r.length<2))for(let t=2;t<=r.length;t++){const a=i(r,t);for(const t of a){let a=[];for(const e of t){const t=o(e);t.length&&a.push(...t)}if(a.length<2)continue;const l=c(a);let r;try{r=p(l,e,n)}catch{continue}if(1===r)return l}}},m=f();if(m)return m;const g=s();if(!g.length||!r.length)return;for(let t=1;t<=r.length;t++){const a=i(r,t);for(const t of a){let a=[];for(const e of t)a.push(...o(e));if(a.length)for(const t of g){const l=[...a,t],r=c(l);try{if(1===p(r,e,n))return r}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},D=(e,n,a)=>{let l=S(e),r="";if(w(n,e,a)){let a=u(n.name,n.value);const o=n.name;r=t.test(a)?l?`*[local-name()='${e.tagName}' and @${o}=${$(a)}]`:`${e.tagName||"*"}[@${o}=${$(a)}]`:l?`*[local-name()='${e.tagName}' and normalize-space(@${o})=${$(a)}]`:`${e.tagName||"*"}[normalize-space(@${o})=${$(a)}]`}return r},P=(e,n)=>{if(!e.textContent)return"";const a=g(e);let l;return l=t.test(a)?S(e)?`//*[local-name()='${e.tagName}' and .=${$(a)}]`:`//${e.tagName||"*"}[.=${$(a)}]`:S(e)?`//*[local-name()='${e.tagName}' and normalize-space(.)=${$(a)}]`:`//${e.tagName||"*"}[normalize-space(.)=${$(a)}]`,l},X=(e,t,n)=>h(`normalize-space(${t})=${$(x(n)).trim()}`,S(e),e.tagName.toLowerCase()),L=(e,t,n)=>h(`starts-with(${t},${$(x(n)).trim()})`,S(e),e.tagName.toLowerCase()),_=(e,t,n)=>h(`contains(${t},${$(x(n)).trim()})`,S(e),e.tagName.toLowerCase()),I=(e,n)=>{const a=n.map(n=>(n=>{const a=u(n.name,n.value);if(!a)return null;if("class"===n.name){const t=a.split(/\s+/).map(e=>e.trim()).filter(Boolean),n=e.getRootNode?.()??e.ownerDocument,l=t.map(t=>{const a=h(`contains(@class,${$(t)})`,S(e),e.tagName.toLowerCase());return{token:t,count:M(a,e,n)}}).sort((e,t)=>e.count!==t.count?e.count-t.count:t.token.length-e.token.length)[0]?.token;return l?`contains(@class,${$(l)})`:null}return t.test(a)?`@${n.name}=${$(a)}`:`normalize-space(@${n.name})=${$(a)}`})(n)).filter(Boolean);if(a.length>=2)return h(`${a[0]} or ${a[1]}`,S(e),e.tagName.toLowerCase());const l=(()=>{const n=x(d(e)?.trim()||"");return!n||n.length>80||/^\d+$/.test(n)?null:t.test(n)&&n.length<=40?`text()=${$(n)}`:n.includes(" ")?`normalize-space(text())=${$(n)}`:`contains(text(),${$(n)})`})();return 1===a.length&&l?h(`${a[0]} or ${l}`,S(e),e.tagName.toLowerCase()):""},M=(e,t,n)=>{try{return p(e,t,n)}catch(e){return 0}},j=(e,t)=>{const n=[],a=new Set,l=Array.from(e.attributes||[]),r=["id","data-testid","data-test","data-qa","name","aria-label","role"],o=[...r.map(e=>l.find(t=>t.name===e)).filter(Boolean),...l.filter(e=>!r.includes(e.name))],s=l=>{l&&!a.has(l)&&q(l,e,t)&&(a.add(l),n.push(l))};o.forEach(t=>{if(!w(t,e,!1))return;const n="id"===t.name?`//*[@id=${$(u(t.name,t.value))}]`:F(e,t.name,t.value);n&&s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=P(e);t&&s(t)}if(l.length>1){const n=A(e,t,l,!1);n&&s(n)}return n},Y=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(W(a)),a=a.parentElement;return a===e?n.join("/"):""},z=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=W(e),l=S(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const l=j(t,n);for(const r of l){console.log(`Trying ancestor XPath: ${r}`);const l=`${r}/descendant::${a}`;console.log(`Trying descendant XPath: ${l}`);const o=M(l,e,n);if(console.log(`Match count: ${o}`),1===o&&V(l,n)===e)return console.log(`Selected XPath: ${l}`),l;const s=Y(t,e);if(s){const t=`${r}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=M(t,e,n);if(console.log(`Match count: ${a}`),1===a&&V(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${l}`);const r=M(l,e,n);return console.log(`Match count: ${r}`),1===r&&V(l,n)===e?(console.log(`Selected XPath: ${l}`),l):(console.log("Selected XPath: "),"")},V=(e,t)=>{try{if(n=t,n?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in n){const{owner:n,contextNode:a,cloneElement:l}=E(t);return n.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue||l}return t.evaluate(e,t,null,t.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}catch(e){return null}var n},q=(e,t,n)=>{try{const{first:a,second:r}=l(e,n);return!!a&&!r&&a===t}catch{return!1}},W=e=>S(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),U=(e,t,n)=>{if(!(e instanceof Element))return[];const a=new Set,l=[],r=Array.from(e.attributes||[]).filter(t=>{return t?.value&&(a=t.value,!/\d/.test(a))&&w(t,e,n);var a}),o=(e,t)=>{t&&!a.has(t)&&(a.add(t),l.push({key:e,value:t}))},s=["id","data-testid","data-test","data-qa","name","aria-label","role"];s.forEach(n=>{const a=r.find(e=>e.name===n);if(!a)return;const l="id"===n?`//*[@id='${a.value}']`:F(e,a.name,a.value);l&&q(l,e,t)&&o(`anchor by ${a.name}`,l)}),r.forEach(n=>{if(s.includes(n.name))return;const a=F(e,n.name,n.value);a&&q(a,e,t)&&o(`anchor by ${n.name}`,a)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const n=P(e);n&&q(n,e,t)&&o("anchor by text",n)}if(r.length>1){const a=A(e,t,r,n);a&&q(a,e,t)&&o("anchor by combination",a)}const c=z(e,t);return c&&q(c,e,t)&&o("anchor by tag",c),l},H=e=>{const t=d(e)?.trim(),n=t?$(N(t)):t;if(n)return n!==`'${t}'`?`contains(.,${n})`:`normalize-space(.)='${t}'`},F=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let l="";return(n=u(t,n))&&(l=a.test(n)?"class"===t?S(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${$(n)})]`:`//${e.tagName||"*"}[contains(@${t},${$(n)})]`:S(e)?`//*[local-name()='${e.tagName}' and @${t}=${$(n)}]`:`//${e.tagName||"*"}[@${t}=${$(n)}]`:S(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${$(n)})]`:`//${e.tagName||"*"}[contains(@${t},${$(n)})]`),l},B=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,G=(e,n,a)=>{let l;const r=[];if(e.textContent&&(!a||a&&!m(e.textContent))&&(t.test(e.textContent)?(l=S(e)?`*[local-name()='${e.tagName}' and .=${$(d(e))}]`:`${e.tagName}[.=${$(d(e))}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})):(l=S(e)?`*[local-name()='${e.tagName}' and ${H(e)})]`:`${e.tagName}[${H(e)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))),e.attributes)for(const t of Array.from(e.attributes))if(w(t,e,a)){let n=t.nodeValue;if(n){n=u(t.name,n);const a=t.name;l="class"===a?S(e)?`*[local-name()='${e.tagName}' and contains(@${a},${$(n)})]`:`${e.tagName}[contains(@${a},${$(n)})]`:S(e)?`*[local-name()='${e.tagName}' and @${a}=${$(n)}]`:`${e.tagName}[@${a}=${$(n)}]`,l&&r.push({key:"getReferenceElementsXpath",value:l})}}if(!r?.length){const t=Array.prototype.slice.call(e.attributes);if(t?.length>1){const t=A(e,n,Array.prototype.slice.call(e.attributes),a);t&&r.push({key:"getReferenceElementsXpath",value:t})}}if(!r?.length){const n=[];let l;const o=S(e);if(e.textContent&&a&&m(e.textContent)){const a=[...new Set(e.textContent.match(/([^0-9]+)/g))];if(a?.length)for(let e=0;e<a?.length;e++)a[e]&&x(a[e].trim())?.length>1&&(t.test(a[e])?n.push(`contains(.,${$(a[e]).trim()})`):n.push(`contains(.,${$(x(a[e])).trim()})`));n?.length&&(l=o?`//*[local-name()='${o}' and ${n.join(" and ")}]`:`//${o}[${n.join(" and ")}]`,l&&r.push({key:"getReferenceElementsXpath",value:l}))}}if(!r?.length){const t=((e,t,n,a)=>{const l=Array.prototype.slice.call(e),r=[];try{l.map(e=>{if(w(e,t,a)){const n=T(e,t);n&&r.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return r})(e.attributes,e,0,a);t?.length&&r.concat(t)}return r},J=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"),Z=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function K(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",l=t.match(/@([a-z0-9:-]+)/);return{axis:a,attribute:l?.[1]??"none",usesNormalize:t.includes("normalize-space")}}(e);return["XPATH",`axis:${n.axis}`,`attr:${n.attribute}`,`normalize:${n.usesNormalize}`,`shape:${t}`].join("|")}function Q(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function ee(e,t,n,a){const l=a?.getRootNode?.()??e,r=e=>{try{return Array.from(l.querySelectorAll(e))}catch{return[]}};try{switch(t){case"id":return 1===r(`#${Q(n)}`).length;case"name":return 1===r(`[name="${Q(n)}"]`).length;case"className":return 1===r(`.${n}`).length;case"tagName":case"cssSelector":return 1===r(n).length;case"linkText":return 1===r("a").filter(e=>e.textContent?.trim()===n).length;case"partialLinkText":return 1===r("a").filter(e=>e.textContent?.includes(n)).length;default:return!1}}catch{return!1}}const te={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:G,getAbsoluteXPath:R,getRelativeXPath:O,getCombinationXpath:T,getAttributeCombinationXpath:A,getElementFromXpath:(e,t,n=!1)=>{let a=t;t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(a=t.host??t);const l=a.nodeType===Node.DOCUMENT_NODE?a:a.ownerDocument;return n?l.evaluate(e,a,null,XPathResult.ANY_TYPE,null):l.evaluate(e,a,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},isSvg:S,findXpathWithIndex:v,isNumberExist:m,getTextContent:d,getCountOfXPath:p,normalizeXPath:J,getShadowRoot:b,escapeCharacters:$,removeParenthesis:y,checkBlockedAttributes:w,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:Z,deleteGarbageFromInnerText:N,replaceTempAttributes:k,createObserver:e=>{r=new MutationObserver(t=>{t.forEach(t=>{("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!f(t))&&a(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&(f(t)||"attributes"!==t?.type||["flndisabled"].includes(t.attributeName)||s.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:s,cspEnabled:!1,getXPathPattern:K,getNormalizedPropertyXPath:X,getStartsWithPropertyXPath:L,getContainsPropertyXPath:_,getOrAttributesXPath:I,getTagOnlyXPath:z,getFirstMatchedNode:V,isExactUniqueXpath:q,getAxisNodeTest:W,getUniqueNodeAnchorXpaths:U,escapeAttrValue:Q,isUniqueInDOM:ee,sanitizeAttributeValue:u};let ne=[],ae=[],le=new Map,re=new Map;const oe=new Map,se={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},ie=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),ce=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",ue=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},fe=(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},me=(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:()=>ue(e)})),e="previous"===t?e.previousElementSibling:e.nextElementSibling}return n},he=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},de=(e,t,n,a,l,r,o)=>{const s=W(n),i=[];let c=0;const u=t.includes("descendant")?10:20;for(const f of e){if(c++>u)break;if(i.length>=5)break;const e="node"in f?f.node:f;if(!(e instanceof Element))continue;if(he(e))continue;const m=[()=>U(e,a,l),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&!/\d/.test(t.value)&&w(t,e,l));for(const a of n){const n=a.value;if(!n)continue;const l=_(e,`@${a.name}`,n);l&&t.push({key:"contains",value:l});const r=L(e,`@${a.name}`,n);r&&t.push({key:"starts-with",value:r})}return t},()=>[{key:"tag",value:z(e,a)}]];for(let l=0;l<m.length;l++){let c=m[l]();if(!c.length)continue;o||(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 l=`${e.value}/${t}::${s}`;if(q(l,n,a)){if(i.push({key:r,value:l}),i.length>=2)return i;if(i.length>=5)return i}}if(o&&l===m.length-1)for(const l of c){const o=p(l.value,e,a);for(let e=1;e<=Math.min(o,3);e++){const o=`(${l.value})[${e}]/${t}::${s}`;if(q(o,n,a)){if(i.push({key:r,value:o}),i.length>=2)return i;if(i.length>=5)return i}}}}if("expand"in f&&f.expand){const e=f.expand();let o=0;for(const c of e){if(o++>15)break;if(i.length>=5)break;if(!(c instanceof Element))continue;if(he(c))continue;const e=U(c,a,l);for(const l of e.slice(0,5)){const e=`${l.value}/${t}::${s}`;if(q(e,n,a)){if(i.push({key:r,value:e}),i.length>=2)return i;if(i.length>=5)return i}}}}}return i},ge=(e,t,n,a)=>{const l=[];for(let t=e.parentElement;t;t=t.parentElement)l.push(t);const r=ue(e),o=fe(e,"previous"),s=fe(e,"next"),i=me(e,"previous"),c=me(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(o),axis:"following-sibling",key:"following-sibling"}],[{nodes:u(l),axis:"child",key:"child"},{nodes:u(r,15),axis:"parent",key:"parent"}],[{nodes:u(l),axis:"descendant",key:"descendant"},{nodes:u(l),axis:"descendant-or-self",key:"descendant-or-self"},{nodes:u(r,10),axis:"ancestor",key:"ancestor"},{nodes:u(r,10),axis:"ancestor-or-self",key:"ancestor-or-self"}],[{nodes:u(i),axis:"following",key:"following"},{nodes:u(c),axis:"preceding",key:"preceding"}]];for(const l of f)for(const r of l){const l=de(r.nodes,r.axis,e,t,n,r.key,a);if(l.length>0)return l}return[]},pe=(e,t,n,a,l)=>{const r=(e=>se[e]||e)(a);return"text"===r?ie(a,((e,t,n)=>{if(!ce(e))return[];if("text"===n){const n=P(e)||ke(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,r)):["contains","startsWith","normalizeSpace"].includes(r)?ie(a,((e,t,n)=>{const a=[],l=Array.from(e.attributes||[]).filter(n=>n?.value&&w(n,e,t)),r=ce(e),o="contains"===n?_:"startsWith"===n?L:"normalizeSpace"===n?X:null;if(!o)return a;if(l.forEach(t=>{const l=o(e,`@${t.name}`,t.value);l&&a.push({key:`xpath by ${n} ${t.name}`,value:l})}),r){const t=o(e,".",r);t&&a.push({key:`xpath by ${n} text`,value:t})}return a})(e,n,r)):["and","or"].includes(r)?ie(a,((e,t,n,a)=>{const l=Array.from(e.attributes||[]).filter(t=>t?.value&&w(t,e,n));if("and"===a){const a=A(e,t,l,n);return a?[{key:"xpath by combination",value:a}]:[]}if("or"===a&&l.length>=1){const t=I(e,l);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,n,r)):"axes"===r?ie(a,ge(e,t,n,!1)):"index"===r?ie(a,((e,t)=>{const n=[],a=e.tagName.toLowerCase(),l=Array.from(t.querySelectorAll(a)).indexOf(e)+1;if(l<=0)return[];n.push({key:"xpath by index",value:`(//${a})[${l}]`});let r=e.parentElement;for(;r&&r!==t.body;){if(r.id||r.className){const t=r.className?.toString().split(" ").map(e=>e.trim()).find(Boolean),l=r.id?`//${r.tagName.toLowerCase()}[@id='${r.id}']`:t?`//${r.tagName.toLowerCase()}[contains(@class,'${t}')]`:"";if(!l){r=r.parentElement;continue}const o=Array.from(r.querySelectorAll(a)).indexOf(e)+1;if(o>0){n.push({key:"xpath by index",value:`(${l}//${a})[${o}]`});break}}r=r.parentElement}return n})(e,t)):"tag"===r?ie(a,[{key:"xpath till tag",value:z(e,t)}]):[]},$e=(e,t,n,a,l,r)=>{if(e){let o;o="parent"===r?[`${e}/descendant-or-self::${t}`,`${e}/following::${t}`]:[`${e}/ancestor-or-self::${t}`,`${e}/preceding::${t}`];for(const e of o){le?.get(e)||le.set(e,p(e,n,a));const t=le?.get(e);if(1===t)return e;if(t>1&&(ae.length?t<ae[0].count&&(ae.pop(),ae.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})):ae.push({key:"relative xpath by unique parent "+(l?"index":""),value:e,count:t})),t>1&&l&&!ne.length){const r=v(e,n,a,t);r&&1===p(r,n,a)&&ne.push({key:"relative xpath by unique parent "+(l?"index":""),value:r})}}}return null},ye=(e,n,a,l,r,o)=>{try{if(oe.has(e))return oe.get(e);const s=[];let i=e;for(;i&&1===i.nodeType;){const e=!1;for(const e of Array.from(i.attributes))if(w(e,i,l)){const t=u(e.name,e.nodeValue),l=e.name,s=F(i,l,t);let c;try{c=$e(s,r,a,n,o,"parent")}catch(e){continue}if(c)return c}if(i.textContent&&!i.textContent)if(!l||l&&!m(i.textContent)){let e;e=t.test(i.textContent)?S(i)?`//*[local-name()='${i.tagName}' and .=${$(g(i))}]`:`//${i.tagName||"*"}[.=${$(g(i))}]`:S(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${$(g(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${$(g(i))}]`;const l=$e(e,r,a,n,o,"parent");if(l)return l}else{const e=[],t=[...new Set(g(i).match(/([^0-9]+)/g))],l=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&x(t[n].trim())&&(l.test(t[n])?e.push(`contains(.,${$(t[n].trim()).trim()})`):e.push(`contains(.,${$(x(t[n])).trim()})`));if(e?.length){const t=S(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,l=$e(t,r,a,n,o,"parent");if(l)return l}}if(!e){const e=S(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+r;if(1===p(c,e,n))return oe.set(e,c),c}catch(e){return console.error(e),null}},ve=(e,t,n,a)=>{const l=new Map;if(l.has(e))return l.get(e);const r=[];let o=e;try{for(;o&&1===o.nodeType;){if(!o.tagName)return"";let e=!1;for(const n of Array.from(o.attributes))if(w(n,o,a)){const a=u(n.name,n.nodeValue),l=n.name,s=F(o,l,a);let i;try{i=p(s,o,t)}catch(e){continue}if(1===i){r.unshift(s),e=!0;break}}if(!e&&o.textContent&&!n.textContent){const n=P(o);if(n){if(1===p(n,o,t)){e=!0,r.unshift(n);break}}}if(e)break;{const e=S(o)?`/*[local-name()='${o.tagName}']`:`/${o.tagName}`;r.unshift(e)}o=o.parentElement}const s=r.join("");return l.set(e,s),s}catch(e){return console.log(e),null}},Ne=(e,t,n)=>{const a=[];let l;const r=[];null!=e.firstElementChild&&e.firstElementChild.classList.contains("flntooltip")?r.unshift(e.firstElementChild):null!=e.nextElementSibling&&r.unshift(e.nextElementSibling);for(let t=e.parentElement;null!=t&&1===t.nodeType;t=t.parentElement)t.nextElementSibling&&r.unshift(t.nextElementSibling);try{do{let e=!1;for(l=r.pop();null!==l;){for(const n of Array.from(l.attributes))if(w(n,l,!0)){const r=u(n.name,n.nodeValue),o=n.name,s=F(l,o,r);let i;try{i=p(s,l,t)}catch(e){continue}if(1===i){e=!0,a.push(s);break}}if(!e&&l.textContent&&!n.textContent){const n=P(l);if(n){if(1===p(n,l,t)){e=!0,a.push(n);break}}}if(e)break;{const e=S(l)?`/*[local-name()='${l.tagName}']`:`/${l.tagName}`;a.push(e),null!=l.firstElementChild?(r.push(l.nextElementSibling),l=l.firstElementChild):l=l.nextElementSibling}}}while(r.length>0);const o=a.join("");return re.set(e,o),o}catch(e){return console.log(e),null}},xe=(e,t,n,a)=>{try{const l=document.querySelector(".flntooltip");for(let r=e.nextElementSibling;null!==r&&r!==l;r=r.nextElementSibling)be(r,e,t,a,"preceding-sibling",n);for(let r=e.previousElementSibling;null!==r&&r!==l;r=r.previousElementSibling)be(r,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},be=(e,t,n,a,l,r)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){let o=D(e,{name:t.name,value:t.value},r);if(o){o+=`/${l}::${a}`;const t=p(o,e,n);if(1===t)return void ne.push({key:`xpath by ${l}`,value:o});t>1&&(ae.length?t<ae[0].count&&(ae.pop(),ae.push({key:`relative xpath by ${l}`,value:o,count:t})):ae.push({key:`relative xpath by ${l}`,value:o,count:t}))}}if(!r){let t;if(t=D(e,{name:"text",value:e.textContent},r),t){const a=p(t,e,n);if(1===a)return void ne.push({key:`xpath by ${l}`,value:t});a>1&&(ae.length?a<ae[0].count&&(ae.pop(),ae.push({key:`relative xpath by ${l}`,value:t,count:a})):ae.push({key:`relative xpath by ${l}`,value:t,count:a}))}}}catch(e){console.log(`${l} xpath-error`,e)}};function Ee(e,t,n,a){const{tagName:l}=t,r=t.textContent.trim();if(r)for(const o of e)if(w(o,t,a)){let e=u(o.name,o.nodeValue);const a=`//${l}[@${o.name}='${e}' and text()='${r}']`;if(a){if(1==p(a,t,n))return a}}}const we=(e,t,n,a,l)=>{let r;return r=e.name,C(t,n,`@${r}`,e.value,a,l)},Se=(e,t,n,a)=>{let l=e.className;if("string"!=typeof l&&(l=""),l=l?.replace("flndisabled","disabled"),l=u("class",l),l=l?.trim(),l)return C(e,t,"@class",l,n,a)},ke=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const l=d(e);if(l)return C(e,t,".",l,n,a)}},Ce=(e,t,n,a,l)=>{const r=e;try{r.map(e=>{if("className"!==e.name&&"class"!==e.name&&w(e,t,l)){const r=we(e,t,n,a,l);r&&ne.push({key:`xpath by ${e.name}${a?" index":""}`,value:r})}});const o=ke(t,n,a,l);if(o&&ne.push({key:"xpath by text"+(a?" index":""),value:o}),r.find(e=>"className"===e.name)&&w(r?.find(e=>"className"===e.name),t,l)){let e=Se(t,n,a,l);e&&ne.push({key:"xpath by class",value:e})}if(!ne.length&&r.length>1){const e=A(t,n,r,l);e&&ne.push({key:"xpath by combination",value:e})}if(!ne.length){const a=Ee(e,t,n,l);a&&ne.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},Re=(e,t,n,a,l=[],r=[])=>{ne=[],console.log(e);const o=e,s=o?.getRootNode?.(),i=s?.nodeType===Node.DOCUMENT_FRAGMENT_NODE,c=i?s:o?.ownerDocument||t,u=o.tagName,{attributes:f}=o,m=l.length>0?l:Array.from(f);if(Ce(m,o,c,n,a),r.length){const e=r.flatMap(e=>pe(o,c,a,e));return ne=(e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value)||(t.add(e.value),0)))})(e.filter(e=>1===p(e.value,o,c))),ne}if(ne.length){const t=ne.length;for(let n=0;n<t;n++){let t=ne[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===p(t,e,c)&&ne.push({key:`${ne[n].key} regex`,value:t})}}return ne.length||i||(ne=ge(o,c,a,n)),ne},Oe={parseDOM:Re,getTextXPath:ke,getUniqueClassName:Se,attributesBasedXPath:we,addAllXPathAttributes:Ce,addRelativeXpaths:(e,t,n,a,l)=>{try{let r,o,s=[];if(ne=[],console.log(l),l)for(const t of l){let n=D(e,{name:t.name,value:t.value},a);console.log(n),n&&s.push(n)}if(e.textContent){let t=D(e,{name:"text",value:e.textContent},a);console.log(t),t&&s.push(t)}if(s.push(e.tagName),s?.length)for(let l=0;l<s.length;l++)if(!ne.length){if(xe(e,t,a,s[l]),!ne.length&&(r||(r=ve(e.parentElement,t,e,a)),console.log(r),r&&(r.includes("@")||r.includes("text()")||r.includes(".="))&&r.match(/\//g)?.length-2<5)){const a=r+`/${s[l]}`,o=p(a,e,t);if(1===o)ne.push({key:"relative xpath by relative parent",value:a});else if(o>1&&n){const l=v(a,e,t,o);l&&1===p(l,e,t)&&ne.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(!ne.length&&(o||(o=Ne(e,t,e)),o&&(o.includes("@")||o.includes("text()")||o.includes(".=")))){const a=`/${s[l]+o.substring(1)}`,r=p(a,e,t);if(1===r)ne.push({key:"relative xpath by relative child",value:a});else if(r>1&&n){const l=v(a,e,t,r);l&&1===p(l,e,t)&&ne.push({key:"relative xpath by relative parent "+(n?"index":""),value:l})}}if(1===ne?.length&&ne?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=ke(e,t,n,!1);a&&ne.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!ne.length){let r=ye(e.parentElement,t,e,a,s[l],n);r&&ne.push({key:"xpath by unique parent",value:r})}}return ne}catch(e){console.log(e)}},getXPathUsingAttributeAndText:Ee,getSiblingRelativeXPath:xe,getChildRelativeXpath:Ne,getParentRelativeXpath:ve,getUniqueParentXpath:ye,checkRelativeXpathRelation:$e,buildAxesStrategyXpaths:ge};let Te=[],Ae=[];const De=/^[\S]+( [\S]+)*$/gi,Pe=(e,t,n,a,l,r,o,s=0,i=!1)=>{let c="";if(t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g)?.length>=r.length){const c=[],u=t.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);for(let e=1;e<=r.length;e++)c.unshift(e===r.length?r[r.length-e]:u[u.length-e]);const f=Ye(`${o+(s?"]".repeat(s):"")}`,c,e[e.length-1],e,a,n,l,i);if(f)return f}else{c=`//${o+(s?"]".repeat(s):"")}/${n}::${B(t,e[e.length-1])}`;let r=p(c,e[e.length-1],a);if(1===r)return[{key:`dynamic ${n}`,value:k(c)}];if(r>1&&l&&(c=v(c,e[e.length-1],a,r),c&&(r=p(c,e[e.length-1],a),1===r)))return[{key:`dynamic ${n} ${l?" index":""}`,value:k(c)}]}},Xe=(e,t,n,a,l,r=!1,o=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=b(i)??i.ownerDocument,f=n.find(e=>e?.key?.includes("absolute"))?.value||R(s,s.ownerDocument),m=[],h=[];f.split("/").map(e=>m.push(e)),m.map(e=>h.push(e.replace(/\[([0-9]+)\]/gm,"")));const g=a.find(e=>e?.key?.includes("absolute"))?.value||R(i,i.ownerDocument),p=[],y=[];g.split("/").map(e=>p.push(e)),p.map(e=>y.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var v=0;v<m.length&&m[v]==p[v];v++);const N=[];for(let e=v-1;e<m.length;e++)m[e]&&N.push(h[e]);const x=[];for(let e="descendant"===l?v:v-1;e<p.length;e++)p[e]&&(x.length?x.push(y[e]):x.push(y[e].replace(/\[([0-9]+)\]/gm,"")));let E;if(Ae=a,e[e.length-2].textContent){E=De.test(e[e.length-2].textContent)?S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and .=${$(d(e[e.length-2]))}]`:`${e[e.length-2].tagName}[.=${$(d(e[e.length-2]))}]`:S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${H(e[e.length-2])})]`:`${e[e.length-2].tagName}[${H(e[e.length-2])}]`,N[N.length-1]=E;const n=N.join("["),a=N.length-1,s=n;for(let n=0;n<Ae.length;n++){let i;if(i=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,i)return Pe(e,i,l,c||t,r,x,s,a,o)}}if(e[e.length-2].attributes){for(const n of Array.from(e[e.length-2].attributes))if(w(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=u(n.name,a);const s=n.name;E=S(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${$(a)}]`:`${e[e.length-2].tagName}[@${s}=${$(a)}]`,N[N.length-1]=E;const i=N.join("["),f=N.length-1,m=i;for(let n=0;n<Ae.length;n++){let a;return a=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,Pe(e,a,l,c||t,r,x,m,f,o)}}}for(const n of Array.from(e[e.length-2].attributes))if(w(n,e[e.length-2],!1)){let a=n.nodeValue;if(a){a=u(n.name,a);const s=T(n,e[e.length-2]);if(s){E=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,N[N.length-1]=E;const n=N.join("["),a=N.length-1,i=n;for(let n=0;n<Ae.length;n++){let s;return s=Ae[n].value.startsWith("//")?Ae[n].value.substring(Ae[n].value.indexOf("//")+2):Ae[n].value,Pe(e,s,l,c||t,r,x,i,a,o)}}}}}const k=N.join("["),C=N.length-1,O=Ye(`${k+(C?"]".repeat(C):"")}`,x,e[e.length-1],e,t,l,r,o);if(O)return O},Le=(e,t,n,a,l,r,o)=>{let s,i;console.log("getXpathRelationExpression",n);const c=[];try{if(s=a.filter(e=>!e?.key?.includes("absolute")),i=l.filter(e=>!e?.key?.includes("absolute")),"ancestor"===n||"ancestor-or-self"===n){const a=je(e,t,n,s,i,r);if(a.length)return a}for(let e=0;e<s.length;e++)for(let a=0;a<i.length;a++){let l=`//${0!==s[e].value.indexOf("//")?B(s[e].value):B(s[e].value.substring(s[e].value.indexOf("//")+2))}/${n}::${0!==i[a].value.indexOf("//")?B(i[a].value):B(i[a].value.substring(i[a].value.indexOf("//")+2))}`;console.log("getXpathRelationExpression",l);const o=p(l,t,t.ownerDocument);if(o>1)if(r){if(l=v(l,t,t.ownerDocument,o),l)return c.push({key:`dynamic ${n}${r?" index":""}`,value:k(l)}),c}else o>1&&(Te.length?o<Te[0].count&&(Te.pop(),Te.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o})):Te.push({key:"relative xpath by relative child "+(r?"index":""),value:l,count:o}));else if(1===o)return c.push({key:`dynamic ${n}`,value:k(l)}),c}if(!c.length)for(let a=0;a<s.length;a++)for(let l=0;l<i.length;l++){const u=`${0!==i[l].value.indexOf("//")?i[l].value:i[l].value.substring(i[l].value.indexOf("//")+2)}`.split(/\/(?=(?:[^']*\'[^\']*\')*[^\']*$)/g);if(u.length>1){const l=Ye(`${0!==s[a].value.indexOf("//")?B(s[a].value):B(s[a].value.substring(s[a].value.indexOf("//")+2))}`,u,t,[e,t],t.ownerDocument,n,r,o);if(console.log("getXpathRelationExpression traverseXpath",l),l)return c.push(...l),c}}}catch(e){console.log(e)}return c},_e=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,Ie=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,Me=(e,t)=>{for(const e of t){const t=Ie(e.value);if(t&&1===t.split(_e).length)return B(t)}if(e.textContent){const t=H(e);if(t)return S(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`}if(e.attributes)for(const t of Array.from(e.attributes))if(w(t,e,!1)&&t.nodeValue)return S(e)?`*[local-name()='${e.tagName}' and @${t.name}=${$(u(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${$(u(t.name,t.nodeValue))}]`;return S(e)?`*[local-name()='${e.tagName}']`:e.tagName},je=(e,t,n,a,l,r)=>{const o=[],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 o;const i=S(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let l=t;for(;l&&l!==e;){const e=l===t?Me(t,n):S(l)?`*[local-name()='${l.tagName}']`:l.tagName;a.unshift(e),l=l.parentElement}return l===e?a.join("/"):""})(s,t,l);if(!c)return o;for(const e of a){const a=Ie(e.value);if(!a)continue;let l=`//${B(a)}/${n}::${i}/${c}`,s=p(l,t,t.ownerDocument);if(1===s)return o.push({key:`dynamic ${n} bridge`,value:k(l)}),o;if(s>1&&r&&(l=v(l,t,t.ownerDocument,s),s=l?p(l,t,t.ownerDocument):0,l&&1===s))return o.push({key:`dynamic ${n} bridge index`,value:k(l)}),o}return o},Ye=(e,t,n,a,l,r,o,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${r}::${B(s)}`;const c=p(i,n,l);if(1===c)return[{key:`dynamic ${r}`,value:k(i)}];if(c>1&&o&&(i=v(i,a[a.length-1],l,c),i))return[{key:`dynamic ${r}${o?" index":""}`,value:k(i)}]}else for(let s=1;s<=t.length;s++){const c=t.slice(t.length-s,t.length).join("/");i=`//${e}/${r}::${B(c)}`;const u=p(i,n,l);if(1===u)return[{key:`dynamic ${r}`,value:k(i)}];if(u>1&&o&&(i=v(i,a[a.length-1],l,u),i))return[{key:`dynamic ${r}${o?" index":""}`,value:k(i)}]}},ze={findRelativeXpath:(e,t,n,a,l,r,o=!1,s=null)=>{let i=[];const c=s||[],u=(r,s)=>{let c=[];c="descendant"===r||"descendant-or-self"===r?Xe([e,t],n,a,l,r,s,o)||[]:Le(e,t,r,a,l,s,o)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,r);return i},getDescendantXpath:Xe,getAncestorBridgeXpath:je,getXpathRelationExpression:Le,getTraverseXpathExpression:Ye,getReferenceElementXpath:e=>{let t=[];if(t=Re(e,e.ownerDocument,!1,!1),t?.length){let n=Re(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=Re(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value});if(t?.length||(t=[{key:"",value:O(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:O(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&Z(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:y(e.value)}:{key:"",value:e.value})),t?.length){const n=G(e,e.ownerDocument,!1);n?.length&&(t=t.concat(n))}else t=G(e,e.ownerDocument,!1);const n=R(e,e.ownerDocument);return t=t.filter(e=>e.value!==n),t.push({key:"absolute xpath",value:n.slice(1)}),t},getSmartRelations:(e,t)=>{const n=e.compareDocumentPosition(t),a=[],l=[],r=[];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&&l.push("following"),n&Node.DOCUMENT_POSITION_PRECEDING&&l.push("preceding"),r.push("descendant","descendant-or-self");const o=[...a,...l,...r];return[...new Set(o)]}};let Ve=[];const qe=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},We=(e,t="single")=>{const n=[],a=e.getRootNode();try{const l=Ue(e);if(l&&qe(l,e,a)&&(n.push({key:"cssSelector by id",value:l}),"single"===t))return n;const r=Ge(e);r&&qe(r,e,a)&&n.push({key:"cssSelector by class",value:r});const o=Be(e);o&&n.push({key:"cssSelector by name",value:o})}catch(e){console.error(e)}return n},Ue=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&&!m(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(" > ")},He=new Set(["id","class","style"]);function Fe(e){return Array.from(e.attributes).filter(e=>!He.has(e?.name?.toLowerCase())&&e.value&&!m(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const Be=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 l=Fe(e);for(const t of l){const l=`${a}${t}`;if(qe(l,e,n))return l}},Ge=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||m(e.className)||Ve?.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(" > ")},Je={parseCssSelectors:We,getIdCssPath:Ue,getAttributeCssPath:Be,getClassCssPath:Ge,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 l=e.parentNode;if(l){const t=Array.from(l.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(" > ")}},Ze=(e,t,n)=>{const a=J(e);if(st(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},Ke=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return tt(e.body,t)},Qe=(e,t,n)=>Ke(t,e)===n,et=e=>e.name?.toLowerCase().includes("cssselector")??!1,tt=(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=tt(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},nt=e=>e?.id||null,at=e=>e.className||null,lt=e=>e.textContent?.trim()||null,rt=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},ot=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function st(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 it(e,t,n){if(e.includes(t)){const a=e.split(t)[0].trim(),l=n.defaultView;if(!l)return null;if(!e.includes("dynamic")){const t=new l.XPathEvaluator;if(t.evaluate(a,n,null,l.XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue){let a;return t.evaluate(e,n,null,l.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 ct=(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 l=[];function r(e,t={}){const n=e?.value,r=t.value??e?.value,o={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;o.isSelfHealed=s?"Y":t.hasOwnProperty("isSelfHealed")?t.isSelfHealed:((e,t,n)=>t&&n&&t===n?null:"Y")(o.name,n,r),function(e){const t=`${e.name}:${e.value}`;a.has(t)||(a.add(t),l.push(e))}(o)}function o(e,t,n){if(et(t))return Ke(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+Q(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=Q(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=st(e,J(n));return a&&r(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 l=o(a,t,n);if(l)return l}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)r(e);const u=String(n.value||n.type||"");if(u.includes("dynamic")||u.match("dynamic")||u.includes("{")||u.includes("}")){r(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=o(t,n,a),c||(c=s(t,n,a)),c||(c=tt(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=>et(e)&&e.value);for(const e of n)Ze(e.value,t,c)&&r(e,{isSelfHealed:null});for(const e of a)Qe(e.value,t,c)&&r(e,{isSelfHealed:null});const o=l.filter(e=>"xpath"===e.name&&e.value),s=new Set(o.map(e=>K(e.value))),u=[],h=nt(c);if(h&&!f("id",h)&&!m(h)){const n=e.locators.find(e=>"id"===e.name);ee(t,"id",h,c)&&(u.push("id"),r(n,{name:"id",type:"static",isRecorded:"Y",value:h}))}const d=c.tagName;if(d&&!f("tagName",d)){const n=e.locators.find(e=>"tagName"===e.name);ee(t,"tagName",d,c)&&(u.push("tagName"),r(n,{name:"tagName",type:"static",isRecorded:"Y",value:d}))}const g=lt(c);if(g&&!m(g)){const n=e.locators.find(e=>"linkText"===e.name);ee(t,"linkText",g,c)&&(u.push("linkText"),r(n,{name:"linkText",type:"static",isRecorded:"Y",value:g}))}const p=rt(c);if(p&&!f("name",p)&&!m(p)){const n=e.locators.find(e=>"name"===e.name);ee(t,"name",p,c)&&(u.push("name"),r(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=at(c);if($&&""!==$.trim()&&!$.includes(" ")&&!f("className",$)&&!m($)){const n=e.locators.find(e=>"className"===e.name);ee(t,"className",$,c)&&(u.push("className"),r(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}We(c,"single").forEach(e=>{e.value&&!f("cssSelector",e.value)&&r(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=Re(c,t,!1,!0,y)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==v?.length){const e=n.filter(e=>!Ze(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=K(t.value);if(s.has(n))continue;const l=v.find(e=>e.value&&K(e.value)===n);l?.value&&(r(t,{name:"xpath",value:l.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=K(t.value);s.has(n)||(r(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 ot)if(a.value.includes(e)){const l=it(a.value,e,t);if(l){r(a,{name:"xpath",value:l,isRecorded:""!==n.isRecorded&&null!==n.isRecorded?n.isRecorded:"Y"});break}}}catch(e){console.error("Error processing locator:",n,e)}if(l.length<5){const e=[{name:"id",value:nt(c)},{name:"name",value:rt(c)},{name:"className",value:at(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:lt(c)}];for(const n of e){if(l.length>4)break;const{name:e,value:a}=n;a&&(m(a)||f(e,a)||"className"===e&&a.includes(" ")||ee(t,e,a,c)&&r(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}l.length<5&&We(c,"multiple").forEach(e=>{l.length>4||e.value&&(f("cssSelector",e.value)||ee(t,"cssSelector",e.value,c)&&r(void 0,{name:"cssSelector",type:"static",value:e.value,isRecorded:"Y",isSelfHealed:"Y"}))})}const N=l.map(e=>({...e,value:i(e.value,e.name,e.isRecorded)})),x=[{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 x}}catch(e){console.error("Error processing locator:",n,e);continue}}catch(e){console.error("Error processing locator:",n,e);continue}return null};const ut={getOptimalClassChain:function e(t,n,a){try{if(!n||1!==n.nodeType||!n.tagName||"XCUIElementTypeApplication"===n.tagName)return"";const l=n.tagName,r=["name","label","value"];for(const e of r){const r=a.find(t=>t.name===e);if(!r)continue;let o=r.value;if(!o)continue;if(o=o.trim().replace(/\s+/g," "),m(o))continue;const s=`//${l}[@${e}="${o}"]`;let i=0;try{i=p(s,n,t)}catch(e){console.log(e);continue}const c=/\s/.test(o);if(1===i)return c?`/${l}[\`${e} CONTAINS "${o}"\`]`:`/${l}[\`${e} == "${o}"\`]`;if(i>1&&n.parentElement){const t=Array.from(n.parentElement.children).filter(e=>e.tagName===l).indexOf(n)+1;return c?`/${l}[\`${e} CONTAINS "${o}"\`][${t}]`:`/${l}[\`${e} == "${o}"\`][${t}]`}}let o=`/${l}`;if(n.parentElement){const e=Array.from(n.parentElement.children).filter(e=>e.tagName===l);if(e.length>1){o+=`[${e.indexOf(n)+1}]`}}return e(t,n.parentElement,a)+o}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=[],l=[];for(let r of n){const n=r.value,o=r.name;if(0!==n.length&&(n&&!m(n))){a.push(`@${o}="${n}"`);const r=`//*[${a.join(" and ")}]`;let s;l.push(`${o} == "${n}"`);try{s=p(r,t,e)}catch(e){console.log(e);continue}if(1===s)return l.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}},ft=()=>({xpath:Oe,referenceXpaths:ze,xpathUtils:te,getElementsFromHTML:ct,cssSelectors:Je,iosSelectors:ut});e.createXPathAPI=ft,e.default=ft,Object.defineProperty(e,"__esModule",{value:!0})}(this.XpathLib=this.XpathLib||{});
1
+ !function(e){"use strict";const t=/^[\S]+( [\S]+)*$/i;let n=new WeakMap;const a=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=>{n.delete(e)}):n=new WeakMap},r=(e,t)=>{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}})(t);let o=n.get(r);o||(o=new Map,n.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 o,l=new Map,s=[];const i=new Set(["marked-element-temp","removePointers"]),c=e=>(e||"").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!i.has(e)).sort(),u=e=>/\d/.test(e||""),f=(e,t,n,a=!1)=>{const r=c(t),o=r.filter(e=>!!a||!u(e));return o.length?1===r.length&&1===o.length?[`@class=${N(o[0])}`]:o.map(t=>{const a=p(`contains(@class,${N(t)})`,T(e),e.tagName.toLowerCase());return{token:t,count:F(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,${N(e)})`):[]},m=new Set(["data-testid","data-test-id","data-test","data-cy","testid"]),d=(e,t)=>t?"class"===e||"className"===e?c(t).join(" "):t.replace("removePointers","").trim():"",g=e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof Element))return!1;if(T(e.target)&&e.oldValue?.trim()===e.target.classList.value?.trim())return!0;const t=c(e.oldValue),n=c(e.target.getAttribute("class"));return t.join(" ")===n.join(" ")},h=e=>/\d/.test(e),p=(e,t,n)=>t?`//*[local-name()='${n}' and ${e}]`:`//${n}[${e}]`,$=e=>{const t=e?.textContent;return t},y=e=>e?.childNodes[0]?.nodeValue||"",v=(e,t,n,a=!1)=>{try{if(R(n)){const{owner:r,contextNode:o,cloneElement:l,cloneElements:s}=O(n,t),i=r.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(a&&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}=r(e,n);if(!o)return 0;if(!l)return o===t?1:0;if(a&&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}},N=e=>{if(e){if(-1!==e.indexOf('"'))return`'${e}'`;if(-1!==e.indexOf("'"))return`"${e}"`}return`'${e}'`},b=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},E=(e,t,n,a)=>{try{const r=9===n.nodeType?n:n.ownerDocument;let o=0;if(a){if(1===v(`${e}[${a}]`,t,n))return`${e}[${a}]`;if(1===v(`(${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===v(`${e}[${o}]`,t,n)?`${e}[${o}]`:1===v(`(${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(),w=e=>e?e.replace(/\s\s+/g," ").trim():e,k=(e,t)=>{const n=w((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(.),${N(a)})`:""},S=e=>{const t=w((e||"").trim());if(!t||!u(t))return{prefix:t,fragment:t};const n=t.split(/[0-9]/)[0].replace(/[₹$€£¥₫₽₩₦₱₲₴₵₡₭₮₺฿៛]+/g,"").trim(),a=n.split(/[^a-zA-Z]+/).map(e=>w(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:""}},A=e=>S(e).fragment,C=e=>{if(!e||!e?.getRootNode)return null;const t=e.getRootNode();return t&&t?.host?t:null},R=e=>e?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e,O=(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}},D=(e,t,n)=>{const a=d(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=s?.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,l=a,(!m.has(o.toLowerCase())||!(e=>/(?:^|[-_:])\d{4,}(?:$|[-_:])/.test(e))(l))&&("class"===e.name||!u(a)))));var o,l},T=e=>e instanceof SVGElement,P=e=>e?e.replace(/\b[a-zA-Z_]*disabled\b/gi,"disabled"):e,X=(e,n,a,r,o,l)=>{if(r){const{tagName:s}=e;let i,c="";const m=[];let d;const g=a.startsWith("@"),$="."===a||"text()"===a,y=$?".":a,b=$&&/\s/.test(r.trim()),E=$?A(r):r,x=$&&u(r)?E:r,S=$?k(e,x):"";if("@class"===a){for(const t of f(e,r,n))if(d=p(t,T(e),e.tagName.toLowerCase()),i=v(d,e,n),1===i&&!o)return d;return}if($&&u(r)&&!E)return;if(r&&(!g||!h(r))&&(d=S?p(S,T(e),e.tagName.toLowerCase()):b?p(`normalize-space(${y})=${N(w(x)).trim()}`,T(e),e.tagName.toLowerCase()):t.test(r)?`//${s}[${a}=${N(x)}]`:p(`normalize-space(${a})=${N(w(x)).trim()}`,T(e),e.tagName.toLowerCase()),i=v(d,e,n),1===i&&!o))return d;if(g&&u(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]&&w(u[0].trim())?.length>1&&r.startsWith(u[0])&&(c=t.test(u[0])?`starts-with(${a},${N(u[0]).trim()})`:`starts-with(${a},${N(w(u[0])).trim()})`),u?.length>1&&u[u.length-1]&&w(u[u.length-1].trim())?.length>1&&r.endsWith(u[u.length-1])&&(c=t.test(u[u.length-1])?`ends-with(${a},${N(u[u.length-1]).trim()})`:`ends-with(${a},${N(w(u[u.length-1])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d}else{const u=l.length%2==0?l.length/2:l.length%2,f=l.slice(0,u).join(" ");let m=[...new Set(f.match(/([^0-9]+)/g))];if(m?.length&&m[0]&&w(m[0].trim())?.length&&r.startsWith(m[0])&&(c=t.test(m[0])?`starts-with(${a},${N(m[0]).trim()})`:`starts-with(${a},${N(w(m[0])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d;const g=l.slice(u,l.length-1).join(" ");if(m=[...new Set(g.match(/([^0-9]+)/g))],m?.length&&m[0]&&w(m[0].trim())?.length>3&&r.endsWith(m[0])&&(c=t.test(m[0])?`ends-with(${a},${N(m[0]).trim()})`:`ends-with(${a},${N(w(m[0])).trim()})`),c?.length&&(d=T(e)?`//*[local-name()='${s}' and ${c}]`:`//${s}[${c}]`,i=v(d,e,n),1===i&&!o))return d}}if(r&&l&&h(r)){const l=[...new Set(r.match(/([^0-9]+)/g))];if(l?.length)for(let e=0;e<l?.length;e++)l[e]&&w(l[e].trim())?.length>1&&(t.test(l[e])?m.push(`contains(${a},${N(l[e].trim()).trim()})`):m.push(`contains(${a},${N(w(l[e])).trim()})`));if(m?.length&&(d=T(e)?`//*[local-name()='${s}' and ${m.join(" and ")}]`:`//${s}[${m.join(" and ")}]`,i=v(d,e,n),1===i&&!o))return d}if(d=T(e)?`//*[local-name()='${s}' and text()]`:`//${s}[text()]`,i=v(d,e,n),1===i&&!o)return d}},_=(e,t)=>{try{if(!e)return"";let n=T(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 _(e?.parentElement,t)+n}catch(e){return console.log("xpath",e),""}},L=(e,t,n,a=!1,r)=>{try{if(l.has(e))return l.get(e);const o=[];let s=e;for(;s;){let l="",i=!1,c=e===s?r??s.attributes:s.attributes;for(const e of Array.from(c))if(D(e,s)){const a=d(e.name,e.nodeValue),r=e.name;for(const e of te(s,r,a)){l=e;let a=0;if(a=v(l,s,t),1===a){o.unshift(P(l)),i=!0;break}if(a>1&&n&&(l=E(l,s,t,a),l)){o.unshift(P(l)),i=!0;break}}}if(s.textContent)if(!a||a&&!h(s.textContent)){let e=new RegExp(/^[\S]+( [\S]+)*$/gi);const a=y(s),r=k(s,a);l=r?p(r,T(s),s.tagName||"*"):e.test(s.textContent)?T(s)?`//*[local-name()='${s.tagName}' and .=${N(a)}]`:`//${s.tagName||"*"}[.=${N(a)}]`:T(s)?`//*[local-name()='${s.tagName}' and normalize-space(.)=${N(a)}]`:`//${s.tagName||"*"}[normalize-space(.)=${N(a)}]`;let o=v(l,s,t);if(1===o)return l;if(o>1&&n)return l=E(l,s,t,o),l}else{let e=[];const a=[...new Set(y(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]&&w(a[t].trim())&&(r.test(a[t])?e.push(`contains(.,${N(a[t].trim()).trim()})`):e.push(`contains(.,${N(w(a[t])).trim()})`));if(e?.length){l=T(s)?`//*[local-name()='${s.tagName}' and ${e.join(" and ")}]`:`//${s.tagName||"*"}[${e.join(" and ")}]`;let a=v(l,s,t);if(1===a)return l;if(a>1&&n)return l=E(l,s,t,a),l}}if(i)break;{let e=T(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}]`}}o.unshift(e)}s=s.parentElement}const i=`${o.join("")}`;return l.set(e,i),i}catch(e){return console.log(e),null}},I=(e,n)=>{const a=[];let r="";if(e&&"function"!=typeof e.nodeValue){if("class"===e.name){const t=n.getRootNode?.()??n.ownerDocument,a=f(n,e.value,t);for(const e of a)if(r=T(n)?`//*[local-name()='${n.tagName}' and ${e}]`:`//${n.tagName}[${e}]`,r)return r;return}if(h(e.value))return;const o=[...new Set(e.value.match(/([^0-9]+)/g))];if(o?.length)for(let n=0;n<o?.length;n++)o[n]&&w(o[n].trim())?.length>2&&(t.test(o[n])?a.push(`contains(@${e.name},${N(o[n].trim())})`):a.push(`contains(@${e.name},${N(w(o[n])).trim()})`));if(a?.length)return r=T(n)?`//*[local-name()='${n.tagName}' and ${a.join(" and ")}]`:`//${n.tagName}[${a.join(" and ")}]`,r}},z=(e,n,a,r)=>{try{const r=a.filter(t=>D(t,e)),o=a=>{const r=d(a.name,a.nodeValue);return r?"class"===a.name?f(e,r,n):u(r)?[]:t.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=w($(e)?.trim()||""),a=A(n);if(u(n))return a?[`contains(normalize-space(.),${N(a)})`]:[];if(!n||n.length>80||/^\d+$/.test(n)){const t=k(e,n);return t?[t]:[]}const r=new Set,o=k(e,n);return o?(r.add(o),Array.from(r)):(t.test(n)&&n.length<=40&&!n.includes(" ")&&r.add(`text()=${N(n)}`),n.includes(" ")&&r.add(`normalize-space(.)=${N(w(n))}`),r.add(`contains(text(),${N(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},m=t=>T(e)?`//*[local-name()='${e.tagName}' and ${t.join(" and ")}]`:`//${e.tagName}[${t.join(" and ")}]`,g=()=>{if(!(r.length<2))for(let t=2;t<=r.length;t++){const a=c(r,t);for(const t of a){const a=s(t);for(const t of a){if(t.length<2)continue;const a=m(t);let r;try{r=v(a,e,n)}catch{continue}if(1===r)return a}}}},h=g();if(h)return h;const p=i();if(!p.length||!r.length)return;for(let t=1;t<=r.length;t++){const a=c(r,t);for(const t of a){const a=s(t);for(const t of a)if(t.length)for(const a of p){const r=[...t,a],o=m(r);try{if(1===v(o,e,n))return o}catch{continue}}}}}catch(e){console.log(`XPath generation error: ${JSON.stringify(e,null,2)}`)}},M=(e,t,n)=>j(e,t)[0]||"",j=(e,n,a)=>{let r=T(e),o="";if(D(n,e)){let a=d(n.name,n.value);const l=n.name;if("class"===l){const t=e.getRootNode?.()??e.ownerDocument;return f(e,a,t).map(t=>r?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName||"*"}[${t}]`)}if(u(a))return[];o=t.test(a)?r?`*[local-name()='${e.tagName}' and @${l}=${N(a)}]`:`${e.tagName||"*"}[@${l}=${N(a)}]`:r?`*[local-name()='${e.tagName}' and normalize-space(@${l})=${N(a)}]`:`${e.tagName||"*"}[normalize-space(@${l})=${N(a)}]`}return o?[o]:[]},Y=(e,n)=>{if(!e.textContent)return"";const a=y(e),r=A(a);if(u(a)&&!r)return"";const o=u(a)?r:a,l=k(e,o);let s;return s=l?p(l,T(e),e.tagName||"*"):u(a)?p(`contains(normalize-space(.),${N(o)})`,T(e),e.tagName||"*"):!t.test(a)||/\s/.test(a.trim())?p(`normalize-space(.)=${N(o)}`,T(e),e.tagName||"*"):T(e)?`//*[local-name()='${e.tagName}' and .=${N(o)}]`:`//${e.tagName||"*"}[.=${N(o)}]`,s},V=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{fragment:t}=S(n);return t?p(`contains(normalize-space(.),${N(t)})`,T(e),e.tagName.toLowerCase()):""}return p(`normalize-space(${t})=${N(w(n)).trim()}`,T(e),e.tagName.toLowerCase())},q=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{prefix:t,fragment:a}=S(n),r=t||a;return r?p(`starts-with(normalize-space(.),${N(r)})`,T(e),e.tagName.toLowerCase()):""}return p(`starts-with(${t},${N(w(n)).trim()})`,T(e),e.tagName.toLowerCase())},W=(e,t,n)=>{if(("."===t||"text()"===t)&&u(n)){const{fragment:t}=S(n);return t?p(`contains(normalize-space(.),${N(t)})`,T(e),e.tagName.toLowerCase()):""}return p(`contains(${t},${N(w(n)).trim()})`,T(e),e.tagName.toLowerCase())},U=(e,n)=>{const a=n.flatMap(n=>(n=>{const a=d(n.name,n.value);if(!a)return[];if("class"===n.name){const t=e.getRootNode?.()??e.ownerDocument;return f(e,a,t)}return u(a)?[]:t.test(a)?[`@${n.name}=${N(a)}`]:[`normalize-space(@${n.name})=${N(a)}`]})(n)).filter(Boolean);if(a.length>=2)return p(`${a[0]} or ${a[1]}`,T(e),e.tagName.toLowerCase());const r=(()=>{const n=w($(e)?.trim()||""),a=A(n);if(u(n))return a?`contains(normalize-space(.),${N(a)})`:null;const r=k(e,n);return r||(!n||n.length>80||/^\d+$/.test(n)?null:t.test(n)&&n.length<=40&&!n.includes(" ")?`text()=${N(n)}`:n.includes(" ")?`normalize-space(.)=${N(n)}`:`contains(text(),${N(n)})`)})();return 1===a.length&&r?p(`${a[0]} or ${r}`,T(e),e.tagName.toLowerCase()):""},F=(e,t,n)=>{try{return v(e,t,n)}catch(e){return 0}},H=(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)&&J(r,e,t)&&(a.add(r),n.push(r))};l.forEach(t=>{if(D(t,e))for(const n of te(e,t.name,t.value))s(n)});const i=e.textContent?.trim();if(i&&i.length<40&&0===e.children.length){const t=Y(e);t&&s(t)}if(r.length>1){const n=z(e,t,r);n&&s(n)}return n},G=(e,t)=>{const n=[];let a=t;for(;a&&a!==e;)n.unshift(K(a)),a=a.parentElement;return a===e?n.join("/"):""},B=(e,t)=>{const n=t??(e.getRootNode?.()||e.ownerDocument),a=K(e),r=T(e)?`//*[local-name()='${e.tagName.toLowerCase()}']`:`//${e.tagName.toLowerCase()}`;for(let t=e.parentElement;t;t=t.parentElement){const r=H(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=F(r,e,n);if(console.log(`Match count: ${l}`),1===l&&Z(r,n)===e)return console.log(`Selected XPath: ${r}`),r;const s=G(t,e);if(s){const t=`${o}/${s}`;console.log(`Trying descendant XPath: ${t}`);const a=F(t,e,n);if(console.log(`Match count: ${a}`),1===a&&Z(t,n)===e)return console.log(`Selected XPath: ${t}`),t}}}console.log(`Trying descendant XPath: ${r}`);const o=F(r,e,n);return console.log(`Match count: ${o}`),1===o&&Z(r,n)===e?(console.log(`Selected XPath: ${r}`),r):(console.log("Selected XPath: "),"")},Z=(e,t)=>{try{if(R(t)){const{owner:n,contextNode:a,cloneElement:r}=O(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}},J=(e,t,n)=>{try{const{first:a,second:o}=r(e,n);return!!a&&!o&&a===t}catch{return!1}},K=e=>T(e)?`*[local-name()='${e.tagName.toLowerCase()}']`:e.tagName.toLowerCase(),Q=(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))&&D(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 te(e,a.name,a.value))n&&J(n,e,t)&&l(`anchor by ${a.name}`,n)}),o.forEach(n=>{if(!s.includes(n.name))for(const a of te(e,n.name,n.value))a&&J(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=Y(e);n&&J(n,e,t)&&l("anchor by text",n)}if(o.length>1){const n=z(e,t,o);n&&J(n,e,t)&&l("anchor by combination",n)}const c=B(e,t);return c&&J(c,e,t)&&l("anchor by tag",c),r},ee=e=>{const t=$(e)?.trim(),n=A(t);if(t&&u(t))return n?`contains(normalize-space(.),${N(n)})`:void 0;const a=k(e,t);if(a)return a;const r=t?N(x(t)):t;return r?r!==`'${t}'`?`contains(.,${r})`:/\s/.test(t)?`normalize-space(.)='${w(t)}'`:`normalize-space(.)='${t}'`:void 0},te=(e,t,n)=>{const a=new RegExp(/^[\S]+( [\S]+)*$/gi);let r="";if(n=d(t,n)){if("class"===t){const t=e.getRootNode?.()??e.ownerDocument;return f(e,n,t).map(t=>T(e)?`//*[local-name()='${e.tagName}' and ${t}]`:`//${e.tagName||"*"}[${t}]`)}if(u(n))return[];r=a.test(n)?T(e)?`//*[local-name()='${e.tagName}' and @${t}=${N(n)}]`:`//${e.tagName||"*"}[@${t}=${N(n)}]`:T(e)?`//*[local-name()='${e.tagName}' and contains(@${t},${N(n)})]`:`//${e.tagName||"*"}[contains(@${t},${N(n)})]`}return r?[r]:[]},ne=(e,t)=>e?e.replace(/\bdisabled\b/gi,"flndisabled"):e,ae=(e,n,a)=>{let r;const o=[];if(e.textContent&&a&&h(e.textContent)){const{prefix:t,fragment:n}=S($(e)),a=[t?`starts-with(normalize-space(.),${N(t)})`:"",n?`contains(normalize-space(.),${N(n)})`:""].filter((e,t,n)=>e&&n.indexOf(e)===t);for(const t of a)r=T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`,o.push({key:"getReferenceElementsXpath",value:r})}if(e.textContent&&(!a||a&&!h(e.textContent)))if(t.test(e.textContent)){const t=$(e),n=k(e,t),a=n||(/\s/.test(t.trim())?`normalize-space(.)=${N(w(t))}`:`.=${N(t)}`);r=T(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}else{const t=ee(e);t&&(r=T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`,o.push({key:"getReferenceElementsXpath",value:r}))}if(e.attributes){const t="IMG"===e.tagName?Array.from(e.attributes).sort((e,t)=>"alt"===e.name?-1:"alt"===t.name?1:0):Array.from(e.attributes);for(const a of t)if(D(a,e)){let t=a.nodeValue;if(t){t=d(a.name,t);const l=a.name;if("class"!==l&&u(t))continue;if("class"===l){const a=f(e,t,n);if(!a.length)continue;for(const t of a)r=T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`,o.push({key:"getReferenceElementsXpath",value:r});continue}r=T(e)?`*[local-name()='${e.tagName}' and @${l}=${N(t)}]`:`${e.tagName}[@${l}=${N(t)}]`,r&&o.push({key:"getReferenceElementsXpath",value:r})}}}if(!o?.length){const t=Array.prototype.slice.call(e.attributes);if(t?.length>1){const t=z(e,n,Array.prototype.slice.call(e.attributes));t&&o.push({key:"getReferenceElementsXpath",value:t})}}if(!o?.length){const t=[];let n;const r=e.tagName;if(e.textContent&&a&&h(e.textContent)){const a=w($(e)).trim();a?.length>1&&t.push(`contains(text(),${N(a)})`),t?.length&&(n=T(e)?`*[local-name()='${r}' and ${t.join(" and ")}]`:`${r}[${t.join(" and ")}]`,n&&o.push({key:"getReferenceElementsXpath",value:n}))}}if(!o?.length){const t=((e,t)=>{const n=Array.prototype.slice.call(e),a=[];try{n.map(e=>{if(D(e,t)){const n=I(e,t);n&&a.push({key:`split xpath by ${e.name}`,value:n})}})}catch(e){console.log(e)}return a})(e.attributes,e);t?.length&&o.concat(t)}return o},re=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"),oe=(e,t)=>{let n=t,a=1;for(;a>0;){const t=e[++n];"("==t?a++:")"==t&&a--}return n};function le(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 se(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/ /g,"\\ ")}function ie(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(`#${se(n)}`).length;case"name":return 1===o(`[name="${se(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 ce={parseXml:(e,t)=>window.DOMParser?(new window.DOMParser).parseFromString(e,t):null,getReferenceElementsXpath:ae,getAbsoluteXPath:_,getRelativeXPath:L,getCombinationXpath:I,getAttributeCombinationXpath:z,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:T,findXpathWithIndex:E,isNumberExist:h,getTextContent:$,getCountOfXPath:v,normalizeXPath:re,getShadowRoot:C,escapeCharacters:N,removeParenthesis:b,checkBlockedAttributes:D,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:oe,deleteGarbageFromInnerText:x,replaceTempAttributes:P,createObserver:e=>{o=new MutationObserver(t=>{t.forEach(t=>{("childList"===t.type||"characterData"===t.type||"attributes"===t.type&&"flndisabled"!==t.attributeName&&!g(t))&&a(t.target),t?.addedNodes?.length&&e(t?.addedNodes),t.target instanceof HTMLElement&&(g(t)||"attributes"!==t?.type||["flndisabled"].includes(t.attributeName)||s.push({url:t.target.baseURI,attributeName:t.attributeName,element:t.target,doc:t.target.ownerDocument}))})})},startObserver:(e,t)=>{o?.observe(e,t)},stopObserver:()=>{o?.disconnect()},modifiedElementAttributes:s,cspEnabled:!1,getXPathPattern:le,getNormalizedPropertyXPath:V,getStartsWithPropertyXPath:q,getContainsPropertyXPath:W,getOrAttributesXPath:U,getTagOnlyXPath:B,getFirstMatchedNode:Z,isExactUniqueXpath:J,getAxisNodeTest:K,getUniqueNodeAnchorXpaths:Q,escapeAttrValue:se,isUniqueInDOM:ie,sanitizeAttributeValue:d,getClassTokenCondition:(e,t,n,a=!1)=>f(e,t,n,a)[0]||null,getClassTokenConditions:f,getXpathStrings:te,intermediateXpathSteps:j,getContainerTextCondition:k};let ue=[],fe=[],me=new Map,de=new Map;const ge=new Map,he={andConditions:"and",orConditions:"or",contains:"contains",startsWith:"startsWith",normalizeSpace:"normalizeSpace",axes:"axes",index:"index",hardCodedText:"text",tillTag:"tag"},pe=e=>he[e]||e,$e=(e,t)=>t.map(t=>({...t,key:t?.key?.includes(e)?t.key:`${e} ${t.key}`.trim()})),ye=(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)),ve=e=>e?.textContent?.replace(/\s+/g," ")?.trim()||"",Ne=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},be=(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},Ee=(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:()=>Ne(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},we=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},ke=(e,t,n,a,r,o,l)=>{const s=K(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=[()=>Q(e,a),()=>{const t=[],n=Array.from(e.attributes||[]).filter(t=>t?.value&&!/\d/.test(t.value)&&D(t,e));for(const a of n){const n=a.value;if(!n)continue;const r=W(e,`@${a.name}`,n);r&&t.push({key:"contains",value:r});const o=q(e,`@${a.name}`,n);o&&t.push({key:"starts-with",value:o})}return t},()=>[{key:"tag",value:B(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(J(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=v(r.value,e,a);for(let e=1;e<=Math.min(l,3);e++){const l=`(${r.value})[${e}]/${t}::${s}`;if(J(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=Q(r,a);for(const r of e.slice(0,5)){const e=`${r.value}/${t}::${s}`;if(J(e,n,a)){if(i.push({key:o,value:e}),i.length>=2)return i;if(i.length>=5)return i}}}}}return i},Se=(e,t)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},Ae=(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""},Ce=(e,t)=>{const n=[];for(let a=e;a&&a!==t;a=a.parentElement){const e=a.parentElement;if(!e)return"";n.push(`/parent::${K(e)}`)}return n.join("")},Re=(e,t)=>{const n=K(t);return t.parentElement===e?[`/${n}`,`/descendant::${n}`]:[`/descendant::${n}`]},Oe=(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=[be(n,"previous").slice(0,4),be(n,"next").slice(0,4)];for(const t of e)for(const e of t){a(e);let t=0;for(const n of Ne(e).sort((e,t)=>we(t)-we(e))){if(t++>=8)break;a(n)}}}return t.sort((e,t)=>we(t)-we(e)).slice(0,20)})(e),l=Se(e.parentElement,3);for(const n of o){const o=Q(n,t).filter(e=>"anchor by tag"!==e.key).slice(0,2);if(!o.length)continue;const s=Se(n,3);for(const i of o)for(const o of s){const s=Ce(n,o);if(o===n||s)for(const n of l){if(!n||!n.contains(e))continue;const l=Ae(o,n);if(!l)continue;const c=`/${l}::${K(n)}`;for(const o of Re(n,e)){const n=`${i.value}${s}${c}${o}`;if(!r.has(n)&&(r.add(n),J(n,e,t)&&(a.push({key:"chained axes fallback",value:n}),a.length>=2)))return a}}}}return a},De=(e,t)=>{const n=[];for(let a=t;a&&a!==e;a=a.parentElement)n.unshift(K(a));if(!n.length)return"";const a=n.pop();return`${n.length?`/${n.join("/")}`:""}/child::${a}`},Te=(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 Q(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)||!u(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=W(e,`@${t.name}`,n);l(`anchor by stable ${t.name}`,a)}),o},Pe=(e,t,n,a)=>{const r=[];for(let t=e.parentElement;t;t=t.parentElement)r.push(t);const o=Ne(e),l=be(e,"previous"),s=be(e,"next"),i=Ee(e,"previous"),c=Ee(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=De(n,e);if(!l)continue;const s=Te(n,t,0,a);for(const n of s.slice(0,3)){const a=`${n.value}${l}`;if(!o.has(a)&&(o.add(a),J(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=ke(r.nodes,r.axis,e,t,0,r.key,a);if(n.length>0)return n}return Oe(e,t)||[]},Xe=(e,t,n,a,r)=>{const o=pe(a);return"text"===o?$e(a,((e,t,n)=>{if(!ve(e))return[];if("text"===n){const n=Y(e)||We(e,t,!1,!1);return n?[{key:"xpath by text",value:n}]:[]}return[]})(e,t,o)):["contains","startsWith","normalizeSpace"].includes(o)?$e(a,((e,t,n)=>{const a=[],r=Array.from(e.attributes||[]).filter(t=>t?.value&&D(t,e)),o=ve(e),l="contains"===n?W:"startsWith"===n?q:"normalizeSpace"===n?V: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)?$e(a,((e,t,n,a)=>{const r=Array.from(e.attributes||[]).filter(t=>t?.value&&D(t,e));if("and"===a){const n=z(e,t,r);return n?[{key:"xpath by combination",value:n}]:[]}if("or"===a&&r.length>=1){const t=U(e,r);return t?[{key:"xpath by or",value:t}]:[]}return[]})(e,t,0,o)):"axes"===o?$e(a,Pe(e,t,0,!1)):"index"===o?$e(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?te(o,"id",o.id):te(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?$e(a,[{key:"xpath till tag",value:B(e,t)}]):[]},_e=(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){me?.get(e)||me.set(e,v(e,n,a));const t=me?.get(e);if(1===t)return e;if(t>1&&(fe.length?t<fe[0].count&&(fe.pop(),fe.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})):fe.push({key:"relative xpath by unique parent "+(r?"index":""),value:e,count:t})),t>1&&r&&!ue.length){const o=E(e,n,a,t);o&&1===v(o,n,a)&&ue.push({key:"relative xpath by unique parent "+(r?"index":""),value:o})}}}return null},Le=(e,n,a,r,o,l)=>{try{if(ge.has(e))return ge.get(e);const s=[];let i=e;for(;i&&1===i.nodeType;){const e=!1;for(const e of Array.from(i.attributes))if(D(e,i)){const t=d(e.name,e.nodeValue),r=e.name;for(const e of te(i,r,t)){let t;try{t=_e(e,o,a,n,l,"parent")}catch(e){continue}if(t)return t}}if(i.textContent&&!i.textContent)if(!r||r&&!h(i.textContent)){let e;e=t.test(i.textContent)?T(i)?`//*[local-name()='${i.tagName}' and .=${N(y(i))}]`:`//${i.tagName||"*"}[.=${N(y(i))}]`:T(i)?`//*[local-name()='${i.tagName}' and normalize-space(.)=${N(y(i))}]`:`//${i.tagName||"*"}[normalize-space(.)=${N(y(i))}]`;const r=_e(e,o,a,n,l,"parent");if(r)return r}else{const e=[],t=[...new Set(y(i).match(/([^0-9]+)/g))],r=new RegExp(/^[\S]+( [\S]+)*$/gi);if(t?.length)for(let n=0;n<t?.length;n++)t[n]&&w(t[n].trim())&&(r.test(t[n])?e.push(`contains(.,${N(t[n].trim()).trim()})`):e.push(`contains(.,${N(w(t[n])).trim()})`));if(e?.length){const t=T(i)?`//*[local-name()='${i.tagName}' and ${e.join(" and ")}]`:`//${i.tagName||"*"}[${e.join(" and ")}]`,r=_e(t,o,a,n,l,"parent");if(r)return r}}if(!e){const e=T(i)?`/*[local-name()='${i.tagName}']`:`/${i.tagName}`;s.unshift(e)}i=i.parentElement}const c=s.join("")+o;if(1===v(c,e,n))return ge.set(e,c),c}catch(e){return console.error(e),null}},Ie=(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(D(n,l)){const a=d(n.name,n.nodeValue),r=n.name;for(const n of te(l,r,a)){let a;try{a=v(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=Y(l);if(n){if(1===v(n,l,t)){e=!0,o.unshift(n);break}}}if(e)break;{const e=T(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}},ze=(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(D(n,r)){const o=d(n.name,n.nodeValue),l=n.name;for(const n of te(r,l,o)){let o;try{o=v(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=Y(r);if(n){if(1===v(n,r,t)){e=!0,a.push(n);break}}}if(e)break;{const e=T(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 de.set(e,l),l}catch(e){return console.log(e),null}},Me=(e,t,n,a)=>{try{const r=document.querySelector(".flntooltip");for(let o=e.nextElementSibling;null!==o&&o!==r;o=o.nextElementSibling)je(o,e,t,a,"preceding-sibling",n);for(let o=e.previousElementSibling;null!==o&&o!==r;o=o.previousElementSibling)je(o,e,t,a,"following-sibling",n)}catch(e){return console.error("sibling error",e),null}},je=(e,t,n,a,r,o)=>{try{if(e.hasAttributes())for(const t of Array.from(e.attributes)){const l=j(e,{name:t.name,value:t.value},o);for(let t of l){t+=`/${r}::${a}`;const o=v(t,e,n);if(1===o)return void ue.push({key:`xpath by ${r}`,value:t});o>1&&(fe.length?o<fe[0].count&&(fe.pop(),fe.push({key:`relative xpath by ${r}`,value:t,count:o})):fe.push({key:`relative xpath by ${r}`,value:t,count:o}))}}if(!o){let t;if(t=M(e,{name:"text",value:e.textContent}),t){const a=v(t,e,n);if(1===a)return void ue.push({key:`xpath by ${r}`,value:t});a>1&&(fe.length?a<fe[0].count&&(fe.pop(),fe.push({key:`relative xpath by ${r}`,value:t,count:a})):fe.push({key:`relative xpath by ${r}`,value:t,count:a}))}}}catch(e){console.log(`${r} xpath-error`,e)}};function Ye(e,t,n,a){const{tagName:r}=t,o=t.textContent.trim();if(!o)return;const l=w(o),s=A(l);if(u(l)&&!s)return;const i=u(l)?s:l,c=k(t,i);for(const a of e)if(D(a,t)){let e=d(a.name,a.nodeValue);const s=`//${r}[@${a.name}='${e}' and ${c||(u(l)?`contains(normalize-space(.),${N(i)})`:/\s/.test(o)?`normalize-space(.)=${N(i)}`:`text()=${N(i)}`)}]`;if(s){if(1==v(s,t,n))return s}}}const Ve=(e,t,n,a,r)=>{let o;if(o=e.name,D(e,t))return X(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=d("class",r),r=r?.trim(),r&&D({name:"class",value:r},e))return X(e,t,"@class",r,n,a)},We=(e,t,n,a)=>{if(""!=(e.textContent??"").trim()){const r=$(e);if(r)return X(e,t,".",r,n,a)}},Ue=(e,t,n,a,r)=>{const o=e;try{o.map(e=>{if("className"!==e.name&&"class"!==e.name&&D(e,t)){const o=Ve(e,t,n,a,r);o&&ue.push({key:`xpath by ${e.name}${a?" index":""}`,value:o})}});const l=We(t,n,a,r);if(l&&ue.push({key:"xpath by text"+(a?" index":""),value:l}),o.find(e=>"className"===e.name)&&D(o?.find(e=>"className"===e.name),t)){let e=qe(t,n,a,r);e&&ue.push({key:"xpath by class",value:e})}if(!ue.length&&o.length>1){const e=z(t,n,o);e&&ue.push({key:"xpath by combination",value:e})}if(!ue.length){const a=Ye(e,t,n);a&&ue.push({key:"xpath by textAttribute",value:a})}}catch(e){console.log(e)}},Fe=(e,t,n,a,r=[],o=[])=>{ue=[],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(Ue(m,l,c,n,a),o.length){const e=n||((e=[])=>e.some(e=>"index"===pe(e)))(o),t=o.flatMap(e=>Xe(l,c,0,e));return ue=(e=>{const t=new Set;return e.filter(e=>!(!e?.value||t.has(e.value)||(t.add(e.value),0)))})(t.filter(e=>1===v(e.value,l,c))),ye(ue,e)}if(ue.length){const t=ue.length;for(let n=0;n<t;n++){let t=ue[n].value;t="//*"+t.substring(t.indexOf("//")+2+u.length);1===v(t,e,c)&&ue.push({key:`${ue[n].key} regex`,value:t})}}return ue.length||i||(ue=Pe(l,c,0,n)),ye(ue,n)},He={parseDOM:Fe,getTextXPath:We,getUniqueClassName:qe,attributesBasedXPath:Ve,addAllXPathAttributes:Ue,addRelativeXpaths:(e,t,n,a,r)=>{try{let o,l,s=[];if(ue=[],console.log(r),r)for(const t of r){const n=j(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=M(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(!ue.length){if(Me(e,t,a,s[r]),!ue.length&&(o||(o=Ie(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=v(a,e,t);if(1===l)ue.push({key:"relative xpath by relative parent",value:a});else if(l>1&&n){const r=E(a,e,t,l);r&&1===v(r,e,t)&&ue.push({key:"relative xpath by relative parent "+(n?"index":""),value:r})}}if(!ue.length&&(l||(l=ze(e,t,e)),l&&(l.includes("@")||l.includes("text()")||l.includes(".=")))){const a=l.replace(/^\/+/,""),o=`/${s[r]}/${a}`,i=v(o,e,t);if(1===i)ue.push({key:"relative xpath by relative child",value:o});else if(i>1&&n){const a=E(o,e,t,i);a&&1===v(a,e,t)&&ue.push({key:"relative xpath by relative parent "+(n?"index":""),value:a})}}if(1===ue?.length&&ue?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length>3&&e.textContent){const a=We(e,t,n,!1);a&&ue.unshift({key:"xpath by text"+(n?"index":""),value:a})}if(!ue.length){let o=Le(e.parentElement,t,e,a,s[r],n);o&&ue.push({key:"xpath by unique parent",value:o})}}return ue}catch(e){console.log(e)}},getXPathUsingAttributeAndText:Ye,getSiblingRelativeXPath:Me,getChildRelativeXpath:ze,getParentRelativeXpath:Ie,getUniqueParentXpath:Le,checkRelativeXpathRelation:_e,buildAxesStrategyXpaths:Pe};let Ge=[],Be=[];const Ze=/^[\S]+( [\S]+)*$/gi,Je=(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}::${ne(t,e[e.length-1])}`;let o=v(c,e[e.length-1],a);if(1===o)return[{key:`dynamic ${n}`,value:P(c)}];if(o>1&&r&&(c=E(c,e[e.length-1],a,o),c&&(o=v(c,e[e.length-1],a),1===o)))return[{key:`dynamic ${n} ${r?" index":""}`,value:P(c)}]}},Ke=(e,t,n,a,r,o=!1,l=!1)=>{const s=e[e.length-2],i=e[e.length-1],c=C(i)??i.ownerDocument,u=n.find(e=>e?.key?.includes("absolute"))?.value||_(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||_(i,i.ownerDocument),h=[],p=[];g.split("/").map(e=>h.push(e)),h.map(e=>p.push(e.replace(/\[([0-9]+)\]/gm,"")));for(var y=0;y<f.length&&f[y]==h[y];y++);const v=[];for(let e=y-1;e<f.length;e++)f[e]&&v.push(m[e]);const b=[];for(let e="descendant"===r?y:y-1;e<h.length;e++)h[e]&&(b.length?b.push(p[e]):b.push(p[e].replace(/\[([0-9]+)\]/gm,"")));let E;if(Be=(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(Ze.test(e[e.length-2].textContent)){const t=e[e.length-2],n=$(t),a=k(t,n),r=a||(/\s/.test(n.trim())?`normalize-space(.)=${N(w(n))}`:`.=${N(n)}`);E=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${r}]`:`${e[e.length-2].tagName}[${r}]`}else E=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and ${ee(e[e.length-2])})]`:`${e[e.length-2].tagName}[${ee(e[e.length-2])}]`;v[v.length-1]=E;const n=v.join("["),a=v.length-1,s=n;for(let n=0;n<Be.length;n++){let i;if(i=Be[n].value.startsWith("//")?Be[n].value.substring(Be[n].value.indexOf("//")+2):Be[n].value,i){const n=Je(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(D(n,e[e.length-2])){let a=n.nodeValue;if(a){a=d(n.name,a);const s=n.name;E=T(e[e.length-2])?`*[local-name()='${e[e.length-2].tagName}' and @${s}=${N(a)}]`:`${e[e.length-2].tagName}[@${s}=${N(a)}]`,v[v.length-1]=E;const i=v.join("["),u=v.length-1,f=i;for(let n=0;n<Be.length;n++){let a;a=Be[n].value.startsWith("//")?Be[n].value.substring(Be[n].value.indexOf("//")+2):Be[n].value;const s=Je(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(D(n,e[e.length-2])){let a=n.nodeValue;if(a){a=d(n.name,a);const s=I(n,e[e.length-2]);if(s){E=s.startsWith("//")?s.substring(s.indexOf("//")+2):s,v[v.length-1]=E;const n=v.join("["),a=v.length-1,i=n;for(let n=0;n<Be.length;n++){let s;s=Be[n].value.startsWith("//")?Be[n].value.substring(Be[n].value.indexOf("//")+2):Be[n].value;const u=Je(e,s,r,c||t,o,b,i,a,l);if(u?.length)return u}}}}}const x=v.join("["),S=v.length-1,A=xt(`${x+(S?"]".repeat(S):"")}`,b,e[e.length-1],e,t,r,o,l);if(A)return A},Qe=(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=>yt(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=st(s[a].value,e);let f=`//${u}/${n}::${ne(l)}`;console.log("getXpathRelationExpression",f);const m=v(f,t,t.ownerDocument);if(m>1){const a=gt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=dt(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:P(r)}),c;const l=ht(u,n,t,i,t.ownerDocument);if(l)return c.push({key:`dynamic ${n}`,value:P(l)}),c;if(o){if(f=E(f,t,t.ownerDocument,m),f)return c.push({key:`dynamic ${n}${o?" index":""}`,value:P(f)}),c}else m>1&&(Ge.length?m<Ge[0].count&&(Ge.pop(),Ge.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m})):Ge.push({key:"relative xpath by relative child "+(o?"index":""),value:f,count:m}))}else if(1===m){if(lt(l)){const a=gt(e,t,n,s,i);if(a.length)return c.push(...a),c;const r=dt(u,e,t,n,i);if(r)return c.push({key:`dynamic ${n} bridge`,value:P(r)}),c}return c.push({key:`dynamic ${n}`,value:P(f)}),c}}if(!c.length){const a=gt(e,t,n,s,i);if(a.length)return c.push(...a),c;for(let a=0;a<s.length;a++){const r=st(s[a].value,e),o=dt(r,e,t,n,i);if(o)return c.push({key:`dynamic ${n} bridge`,value:P(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=st(s[a].value,e),f=dt(r,e,t,n,i);if(f)return c.push({key:`dynamic ${n} bridge`,value:P(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},et=/\/(?=(?:[^']*'[^']*')*[^']*$)/g,tt=e=>0===e.indexOf("//")?e.substring(e.indexOf("//")+2):e,nt=(e,t)=>at(e,t)[0]||"",at=(e,t)=>{const n=[];let a="";const r=e=>{e&&!n.includes(e)&&n.push(e)};for(const n of t){const t=tt(n.value);if(t&&1===t.split(et).length){if(t===e.tagName||t===e.tagName.toLowerCase()){a=t;continue}r(ne(t))}}for(const t of rt){const n=e.getAttribute(t);if(!n)continue;const a=ot(t,n);a&&r(T(e)?`*[local-name()='${e.tagName}' and ${a}]`:`${e.tagName}[${a}]`)}if(e.textContent){const t=ee(e);t&&r(T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`)}const o=f(e,e.getAttribute("class"),e.getRootNode?.()??e.ownerDocument,!1);for(const t of o)r(T(e)?`*[local-name()='${e.tagName}' and ${t}]`:`${e.tagName}[${t}]`);if(e.attributes)for(const t of Array.from(e.attributes))"class"!==t.name&&D(t,e)&&t.nodeValue&&r(T(e)?`*[local-name()='${e.tagName}' and @${t.name}=${N(d(t.name,t.nodeValue))}]`:`${e.tagName}[@${t.name}=${N(d(t.name,t.nodeValue))}]`);return a&&r(a),r(T(e)?`*[local-name()='${e.tagName}']`:e.tagName),n},rt=["aria-labelledby","aria-label","role","name","data-testid","data-test","data-qa","data-id","id"],ot=(e,t)=>{const n=d(e,t);return n?/\d/.test(n)?"":`@${e}=${N(n)}`:""},lt=e=>e.split(et).length>1||/\[\d+\]/.test(e),st=(e,t)=>0!==e.indexOf("//")?ne(e):ne(e.substring(e.indexOf("//")+2)),it=e=>{const t=[];for(const n of rt){const a=e.getAttribute(n);if(!a)continue;const r=ot(n,a);if(r){t.push(T(e)?`*[local-name()='${e.tagName}' and ${r}]`:`${e.tagName}[${r}]`);break}}return t},ct=(e,t=6)=>{const n=[];let a=e;for(;a&&n.length<t;)n.push(a),a=a.parentElement;return n},ut=(e,t)=>{const n=ot(e,t);if(n)return n;const a=d(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},${N(o)})`},ft=(e,t,n,a,r,o,l)=>{let s=n.parentElement,i=0;for(;s&&s!==a&&i<6;){i++;for(const t of rt){const a=s.getAttribute(t);if(!a)continue;const i=ot(t,a);if(!i)continue;const c=T(s)?`*[local-name()='${s.tagName}' and ${i}]`:`${s.tagName}[${i}]`,u=`//${ne(e)}/${r}::${o}/descendant::${c}/descendant::${ne(l)}`;if(1===v(u,n,n.ownerDocument))return u}s=s.parentElement}return""},mt=["title",...rt],dt=(e,t,n,a,r)=>((e,t,n,a,r)=>{if("following"!==a&&"preceding"!==a)return"";const o=at(n,r);if(!o.length)return"";const l=$t(`//${ne(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 mt){const r=s.getAttribute(t);if(!r)continue;const l=ot(t,r);if(!l)continue;const i=T(s)?`*[local-name()='${s.tagName}' and ${l}]`:`${s.tagName}[${l}]`;for(const t of o){const r=`//${ne(e)}/${a}::${i}/descendant::${ne(t)}`;if(1===v(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=at(n,r);if(!o.length)return"";const l=ct(t),s=ct(n);for(const t of l){const r=it(t);if(r.length)for(const l of s){const s=it(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=`//${ne(e)}/ancestor-or-self::${t}/${a}::${r}/descendant-or-self::${ne(l)}`;if(1===v(o,n,n.ownerDocument))return o}}}return""})(e,t,n,a,r)||((e,t,n,a,r)=>{if("child"!==a)return"";const o=at(n,r);if(!o.length)return"";const l=ct(n).filter(e=>e.parentElement===t);for(const t of l){const a=it(t);if(a.length)for(const t of a)for(const a of o){const r=`//${ne(e)}/child::${t}/descendant-or-self::${ne(a)}`;if(1===v(r,n,n.ownerDocument))return r}}return""})(e,t,n,a,r),gt=(e,t,n,a,r)=>"ancestor"!==n&&"ancestor-or-self"!==n?[]:Et(e,t,n,a,r,!1),ht=(e,t,n,a,r)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";for(const o of a){const a=tt(o.value);if(!a||a.split(et).length>1||/\[\d+\]/.test(a))continue;const l=`//${e}/${t}::${ne(a)}`;if(1===v(l,n,r))return l}return""},pt=(e,t,n,a)=>{if("descendant"!==t&&"descendant-or-self"!==t)return"";const r=at(n,[...Fe(n,n.ownerDocument,!1,!1)||[],...ae(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 rt){const s=o.getAttribute(l);if(!s)continue;const i=ut(l,s);if(!i)continue;const c=T(o)?`*[local-name()='${o.tagName}' and ${i}]`:`${o.tagName}[${i}]`;for(const o of r){const r=`//${e}/${t}::${c}/descendant::${ne(o)}`;if(1===v(r,n,a))return r}}o=o.parentElement}return""},$t=(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}},yt=(e,t)=>{const n=tt(e);if(!n)return!1;try{const e=t.ownerDocument.evaluate(`//${ne(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},vt=e=>{const t=e.getAttribute("fill"),n=e.getAttribute("stroke");if(/\d/.test(t||"")||/\d/.test(n||""))return"";const a=t?`@fill=${N(t)}`:n?`@stroke=${N(n)}`:"";return a?`*[local-name()='${e.tagName.toLowerCase()}' and ${a}]`:""},Nt=(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},bt=(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,f(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=vt(t);if(o&&Nt(a,t,n))for(const t of l)return`//${ne(e)}/${r}::${t}/descendant::${o}/ancestor::${n.tagName.toLowerCase()}`}return""},Et=(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=T(s)?`*[local-name()='${s.tagName}']`:s.tagName,c=((e,t,n)=>{const a=[];let r=t;for(;r&&r!==e;){const e=r===t?nt(t,n):T(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(et).length>1?nt(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 rt){const t=n.getAttribute(e);if(!t)continue;const l=ot(e,t);if(!l)continue;const s=T(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=tt(e.value);if(!a)continue;if(f){const e=`//${ne(a)}/${n}::${f}/descendant::${ne(u)}`;if(1===v(e,t,t.ownerDocument))return l.push({key:`dynamic ${n} bridge`,value:P(e)}),l}let r=u?`//${ne(a)}/${n}::${i}/descendant::${ne(u)}`:`//${ne(a)}/${n}::${i}/${c}`,m=v(r,t,t.ownerDocument);const d=bt(a,0,t,s,n);if(d)return l.push({key:`dynamic ${n} icon bridge`,value:P(d)}),l;if(1===m)return l.push({key:`dynamic ${n} bridge`,value:P(r)}),l;if(u&&m>1){const e=ft(a,0,t,s,n,i,u);if(e)return l.push({key:`dynamic ${n} bridge`,value:P(e)}),l;if(r=`//${ne(a)}/${n}::${i}/${c}`,m=v(r,t,t.ownerDocument),1===m)return l.push({key:`dynamic ${n} bridge`,value:P(r)}),l}if(m>1&&o&&(r=E(r,t,t.ownerDocument,m),m=r?v(r,t,t.ownerDocument):0,r&&1===m))return l.push({key:`dynamic ${n} bridge index`,value:P(r)}),l}return l},xt=(e,t,n,a,r,o,l,s)=>{let i;if(s){const s=t.join("/");i=`//${e}/${o}::${ne(s)}`;const c=v(i,n,r);if(1===c)return[{key:`dynamic ${o}`,value:P(i)}];if(c>1&&l&&(i=E(i,a[a.length-1],r,c),i))return[{key:`dynamic ${o}${l?" index":""}`,value:P(i)}]}else for(let s=1;s<=t.length;s++){const c=wt(t.slice(t.length-s,t.length).join("/"),n);for(const t of c){i=`//${e}/${o}::${ne(t)}`;const s=v(i,n,r);if(1===s){if(t.split(et).length>1||/\[\d+\]/.test(t)){const t=pt(e,o,n,r);if(t)return[{key:`dynamic ${o}`,value:P(t)}]}return[{key:`dynamic ${o}`,value:P(i)}]}if(s>1){const t=ht(e,o,n,Fe(n,n.ownerDocument,!1,!1)||[],r);if(t)return[{key:`dynamic ${o}`,value:P(t)}];const c=pt(e,o,n,r);if(c)return[{key:`dynamic ${o}`,value:P(c)}];if(l&&(i=E(i,a[a.length-1],r,s),i))return[{key:`dynamic ${o}${l?" index":""}`,value:P(i)}]}}}},wt=(e,t)=>{const n=t.getAttribute("class")||"",a=f(t,n,t.getRootNode?.()??t.ownerDocument);if(!a.length)return[e];const r=`${t.tagName}[@class=${N(n)}]`;return e.endsWith(r)?a.map(n=>{const a=`${t.tagName}[${n}]`;return`${e.slice(0,-r.length)}${a}`}):[e]},kt={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?Ke([e,t],n,a,r,o,s,l)||[]:Qe(e,t,o,a,r,s,l)||[],c.length&&(i=i.concat(c))};for(const e of c)u(e,o);return i},getDescendantXpath:Ke,getAncestorBridgeXpath:Et,getXpathRelationExpression:Qe,getTraverseXpathExpression:xt,getReferenceElementXpath:e=>{let t=[];t=Fe(e,e.ownerDocument,!1,!1);const n=ae(e,e.ownerDocument,!1);if(n?.length&&(t=t?.length?t.concat(n):n),t?.length){let n=Fe(e,e.ownerDocument,!0,!1);n?.length&&(n=n?.map(e=>"("==e.value.charAt(0)&&oe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value}),t=t.concat(n))}else t=Fe(e,e.ownerDocument,!0,!1),t=t?.map(e=>"("==e.value.charAt(0)&&oe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value});t?.length||(t=[{key:"",value:L(e,e.ownerDocument,!1,!1,Array.from(e.attributes))}]),t?.length||(t=[{key:"",value:L(e,e.ownerDocument,!0,!1,Array.from(e.attributes))}],t=t?.map(e=>"("==e.value.charAt(0)&&oe(e.value,0)+1===e.value.lastIndexOf("[")?{key:"",value:b(e.value)}:{key:"",value:e.value}));const a=Array.from(e.children||[]).map(t=>{const n=$(t)?.trim();if(!n||n!==$(e)?.trim())return null;const a=k(t,n),r=a||(/\s/.test(n)?`normalize-space(.)=${N(w(n))}`:`.=${N(n)}`);return{key:"reference child text",value:`${t.tagName}[${r}]`}}).filter(e=>!!e);a.length&&(t=a.concat(t));const r=_(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 St=[];const At=(e,t,n)=>{try{const a=n.querySelectorAll(e);return 1===a.length&&a[0]===t}catch{return!1}},Ct=(e,t="single")=>{const n=[],a=e.getRootNode();try{const r=Rt(e);if(r&&At(r,e,a)&&(n.push({key:"cssSelector by id",value:r}),"single"===t))return n;const o=Pt(e);o&&At(o,e,a)&&n.push({key:"cssSelector by class",value:o});const l=Tt(e);l&&n.push({key:"cssSelector by name",value:l})}catch(e){console.error(e)}return n},Rt=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&&!h(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(" > ")},Ot=new Set(["id","class","style"]);function Dt(e){return Array.from(e.attributes).filter(e=>!Ot.has(e?.name?.toLowerCase())&&e.value&&!h(e.value)).map(e=>{return`[${e.name}="${t=e.value,String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"]`;var t})}const Tt=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=Dt(e);for(const t of r){const r=`${a}${t}`;if(At(r,e,n))return r}},Pt=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||h(e.className)||St?.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(" > ")},Xt={parseCssSelectors:Ct,getIdCssPath:Rt,getAttributeCssPath:Tt,getClassCssPath:Pt,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(" > ")}},_t=(e,t,n)=>{const a=re(e);if(Ut(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},Lt=(e,t)=>{try{const n=e.querySelector(t);if(n)return n}catch(e){return console.error("Invalid CSS selector:",t,e),null}return Mt(e.body,t)},It=(e,t,n)=>Lt(t,e)===n,zt=e=>e.name?.toLowerCase().includes("cssselector")??!1,Mt=(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=Mt(a,t);if(e)return e;if(a&&!t.includes("dynamic"))return a.querySelector(t)}}}catch(e){console.log(e)}return null},jt=e=>e?.id||null,Yt=e=>e.className||null,Vt=e=>e.textContent?.trim()||null,qt=e=>{const t=e;if(t.hasAttribute("name")){return`${t.getAttribute("name")}`||null}return null},Wt=["/preceding-sibling","/following-sibling","/parent","/descendant","/ancestor","/self","/ancestor-or-self","/child","/preceding","/following"];function Ut(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 Ft(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 Ht=(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(zt(t))return Lt(e,n);if(t.name.includes("id")||n.startsWith("#"))return e.querySelector("#"+se(n));if(t.name.includes("className")||n.startsWith("."))return e.querySelector("."+n);if("name"===t.name){const t=se(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=Ut(e,re(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=Mt(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=>zt(e)&&e.value);for(const e of n)_t(e.value,t,c)&&o(e,{isSelfHealed:null});for(const e of a)It(e.value,t,c)&&o(e,{isSelfHealed:null});const l=r.filter(e=>"xpath"===e.name&&e.value),s=new Set(l.map(e=>le(e.value))),u=[],m=jt(c);if(m&&!f("id",m)&&!h(m)){const n=e.locators.find(e=>"id"===e.name);ie(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);ie(t,"tagName",d,c)&&(u.push("tagName"),o(n,{name:"tagName",type:"static",isRecorded:"Y",value:d}))}const g=Vt(c);if(g&&!h(g)){const n=e.locators.find(e=>"linkText"===e.name);ie(t,"linkText",g,c)&&(u.push("linkText"),o(n,{name:"linkText",type:"static",isRecorded:"Y",value:g}))}const p=qt(c);if(p&&!f("name",p)&&!h(p)){const n=e.locators.find(e=>"name"===e.name);ie(t,"name",p,c)&&(u.push("name"),o(n,{name:"name",type:"static",isRecorded:"Y",value:p}))}const $=Yt(c);if($&&""!==$.trim()&&!$.includes(" ")&&!f("className",$)&&!h($)){const n=e.locators.find(e=>"className"===e.name);ie(t,"className",$,c)&&(u.push("className"),o(n,{name:"className",type:"static",isRecorded:"Y",value:$}))}Ct(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=Fe(c,t,!1,!0,y)??[]}catch(e){console.error("Error generating XPath candidates:",e)}if(0!==v?.length){const e=n.filter(e=>!_t(e.value,t,c));let a=0;for(const t of e){if(a>=e.length)break;const n=le(t.value);if(s.has(n))continue;const r=v.find(e=>e.value&&le(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=le(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 Wt)if(a.value.includes(e)){const r=Ft(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:jt(c)},{name:"name",value:qt(c)},{name:"className",value:Yt(c)},{name:"tagName",value:c.tagName},{name:"linkText",value:Vt(c)}];for(const n of e){if(r.length>4)break;const{name:e,value:a}=n;a&&(h(a)||f(e,a)||"className"===e&&a.includes(" ")||ie(t,e,a,c)&&o(void 0,{name:e,type:"static",value:a,isRecorded:"Y",isSelfHealed:"Y"}))}r.length<5&&Ct(c,"multiple").forEach(e=>{r.length>4||e.value&&(f("cssSelector",e.value)||ie(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 Gt={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," "),h(l))continue;const s=`//${r}[@${e}="${l}"]`;let i=0;try{i=v(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&&!h(n))){a.push(`@${l}="${n}"`);const o=`//*[${a.join(" and ")}]`;let s;r.push(`${l} == "${n}"`);try{s=v(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}},Bt=()=>({xpath:He,referenceXpaths:kt,xpathUtils:ce,getElementsFromHTML:Ht,cssSelectors:Xt,iosSelectors:Gt});e.createXPathAPI=Bt,e.default=Bt,Object.defineProperty(e,"__esModule",{value:!0})}(this.XpathLib=this.XpathLib||{});
@@ -113,6 +113,14 @@ export declare const createXPathAPI: () => {
113
113
  escapeAttrValue: typeof import("../utils/xpathHelpers.ts").escapeAttrValue;
114
114
  isUniqueInDOM: typeof import("../utils/xpathHelpers.ts").isUniqueInDOM;
115
115
  sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
116
+ getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
117
+ getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
118
+ getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
119
+ intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
120
+ name: string;
121
+ value: string;
122
+ }, isTarget: boolean) => string[];
123
+ getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
116
124
  };
117
125
  getElementsFromHTML: (record: import("../types/locator.ts").ElementRecord, docmt: Document) => {
118
126
  [key: string]: any;
@@ -13,6 +13,9 @@ export declare let modifiedElementAttributes: {
13
13
  element: HTMLElement | Element;
14
14
  doc: Document;
15
15
  }[];
16
+ export declare const hasNumericAttributeValue: (value: string | null | undefined) => boolean;
17
+ export declare const getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
18
+ export declare const getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
16
19
  export declare const sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
17
20
  export declare const createObserver: (addedNodeCallBack: Function) => void;
18
21
  export declare const startObserver: (target: Node, options: MutationObserverInit | undefined) => void;
@@ -26,6 +29,12 @@ export declare const escapeCharacters: (text: string) => string;
26
29
  export declare const removeParenthesis: (xpath: string) => string;
27
30
  export declare const findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
28
31
  export declare const replaceWhiteSpaces: (str: string) => string;
32
+ export declare const getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
33
+ export declare const getStableTargetTextCandidates: (text: string | null | undefined) => {
34
+ prefix: string;
35
+ fragment: string;
36
+ };
37
+ export declare const getStableTargetText: (text: string | null | undefined) => string;
29
38
  export declare const getShadowRoot: (el: HTMLElement | Element) => Element | null;
30
39
  export declare const createShadowEvaluationContext: (root: ShadowRoot, element?: HTMLElement | Element | (HTMLElement | Element)[]) => {
31
40
  owner: Document;
@@ -49,6 +58,10 @@ export declare const intermediateXpathStep: (targetElemt: HTMLElement | Element,
49
58
  name: string;
50
59
  value: string;
51
60
  }, isTarget: boolean) => string;
61
+ export declare const intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
62
+ name: string;
63
+ value: string;
64
+ }, isTarget: boolean) => string[];
52
65
  export declare const getFilteredTextXPath: (node: HTMLElement | Element, docmt: Document | ShadowRoot) => string;
53
66
  export declare const getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
54
67
  export declare const getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
@@ -64,6 +77,7 @@ export declare const getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, do
64
77
  }[];
65
78
  export declare const getTextXpathFunction: (domNode: HTMLElement | Element) => string | undefined;
66
79
  export declare const getXpathString: (node: HTMLElement | Element, attrName: string, attrValue: string) => string;
80
+ export declare const getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
67
81
  export declare const replaceActualAttributes: (str: string, element: {
68
82
  attributes: any;
69
83
  }) => string;
@@ -138,5 +152,13 @@ export declare const xpathUtils: {
138
152
  escapeAttrValue: typeof escapeAttrValue;
139
153
  isUniqueInDOM: typeof isUniqueInDOM;
140
154
  sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
155
+ getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
156
+ getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
157
+ getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
158
+ intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
159
+ name: string;
160
+ value: string;
161
+ }, isTarget: boolean) => string[];
162
+ getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
141
163
  };
142
164
  export {};
@@ -13,6 +13,9 @@ export declare let modifiedElementAttributes: {
13
13
  element: HTMLElement | Element;
14
14
  doc: Document;
15
15
  }[];
16
+ export declare const hasNumericAttributeValue: (value: string | null | undefined) => boolean;
17
+ export declare const getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
18
+ export declare const getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
16
19
  export declare const sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
17
20
  export declare const createObserver: (addedNodeCallBack: Function) => void;
18
21
  export declare const startObserver: (target: Node, options: MutationObserverInit | undefined) => void;
@@ -26,6 +29,12 @@ export declare const escapeCharacters: (text: string) => string;
26
29
  export declare const removeParenthesis: (xpath: string) => string;
27
30
  export declare const findXpathWithIndex: (val: string, node: HTMLElement | Element, docmt: Node, count: number) => string | undefined;
28
31
  export declare const replaceWhiteSpaces: (str: string) => string;
32
+ export declare const getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
33
+ export declare const getStableTargetTextCandidates: (text: string | null | undefined) => {
34
+ prefix: string;
35
+ fragment: string;
36
+ };
37
+ export declare const getStableTargetText: (text: string | null | undefined) => string;
29
38
  export declare const getShadowRoot: (el: HTMLElement | Element) => Element | null;
30
39
  export declare const createShadowEvaluationContext: (root: ShadowRoot, element?: HTMLElement | Element | (HTMLElement | Element)[]) => {
31
40
  owner: Document;
@@ -49,6 +58,10 @@ export declare const intermediateXpathStep: (targetElemt: HTMLElement | Element,
49
58
  name: string;
50
59
  value: string;
51
60
  }, isTarget: boolean) => string;
61
+ export declare const intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
62
+ name: string;
63
+ value: string;
64
+ }, isTarget: boolean) => string[];
52
65
  export declare const getFilteredTextXPath: (node: HTMLElement | Element, docmt: Document | ShadowRoot) => string;
53
66
  export declare const getNormalizedPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
54
67
  export declare const getStartsWithPropertyXPath: (element: HTMLElement | Element, prop: string, value: string) => string;
@@ -64,6 +77,7 @@ export declare const getUniqueNodeAnchorXpaths: (node: HTMLElement | Element, do
64
77
  }[];
65
78
  export declare const getTextXpathFunction: (domNode: HTMLElement | Element) => string | undefined;
66
79
  export declare const getXpathString: (node: HTMLElement | Element, attrName: string, attrValue: string) => string;
80
+ export declare const getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
67
81
  export declare const replaceActualAttributes: (str: string, element: {
68
82
  attributes: any;
69
83
  }) => string;
@@ -138,5 +152,13 @@ export declare const xpathUtils: {
138
152
  escapeAttrValue: typeof escapeAttrValue;
139
153
  isUniqueInDOM: typeof isUniqueInDOM;
140
154
  sanitizeAttributeValue: (attributeName: string, attributeValue: string | null | undefined) => string;
155
+ getClassTokenCondition: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string | null;
156
+ getClassTokenConditions: (element: HTMLElement | Element, classValue: string | null | undefined, docmt: Document | ShadowRoot, allowNumericToken?: boolean) => string[];
157
+ getXpathStrings: (node: HTMLElement | Element, attrName: string, attrValue: string) => string[];
158
+ intermediateXpathSteps: (targetElemt: HTMLElement | Element, attr: {
159
+ name: string;
160
+ value: string;
161
+ }, isTarget: boolean) => string[];
162
+ getContainerTextCondition: (element: HTMLElement | Element, text: string | null | undefined) => string;
141
163
  };
142
164
  export {};