@vitest/browser 4.0.12 → 4.0.14
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/context.d.ts +19 -0
- package/dist/client/__vitest__/assets/{index-VPnwgb7M.css → index-Cb3HQb77.css} +1 -1
- package/dist/client/__vitest__/assets/index-DnyN8l5D.js +57 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/context.js +11 -2
- package/dist/expect-element.js +2 -2
- package/dist/{index-hFpxawnd.js → index-CEutxZap.js} +1 -1
- package/dist/index.js +29 -9
- package/dist/locators.js +1 -1
- package/dist/shared/screenshotMatcher/types.d.ts +8 -2
- package/package.json +6 -6
- package/dist/client/__vitest__/assets/index-TGTX-jRo.js +0 -57
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
})();
|
|
24
24
|
</script>
|
|
25
25
|
<!-- !LOAD_METADATA! -->
|
|
26
|
-
<script type="module" src="./assets/index-
|
|
27
|
-
<link rel="stylesheet" href="./assets/index-
|
|
26
|
+
<script type="module" src="./assets/index-DnyN8l5D.js"></script>
|
|
27
|
+
<link rel="stylesheet" href="./assets/index-Cb3HQb77.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
30
|
<div id="app"></div>
|
package/dist/context.js
CHANGED
|
@@ -486,6 +486,7 @@ function getElementLocatorSelectors(element) {
|
|
|
486
486
|
}, {})
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
|
+
let defaultOptions;
|
|
489
490
|
function debug(el, maxLength, options) {
|
|
490
491
|
if (Array.isArray(el)) {
|
|
491
492
|
// eslint-disable-next-line no-console
|
|
@@ -495,7 +496,7 @@ function debug(el, maxLength, options) {
|
|
|
495
496
|
console.log(prettyDOM(el, maxLength, options));
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
|
-
function prettyDOM(dom, maxLength = Number(import.meta.env.DEBUG_PRINT_LIMIT ?? 7e3), prettyFormatOptions = {}) {
|
|
499
|
+
function prettyDOM(dom, maxLength = Number(defaultOptions?.maxLength ?? import.meta.env.DEBUG_PRINT_LIMIT ?? 7e3), prettyFormatOptions = {}) {
|
|
499
500
|
if (maxLength === 0) {
|
|
500
501
|
return "";
|
|
501
502
|
}
|
|
@@ -513,6 +514,7 @@ function prettyDOM(dom, maxLength = Number(import.meta.env.DEBUG_PRINT_LIMIT ??
|
|
|
513
514
|
const pretty = stringify(dom, Number.POSITIVE_INFINITY, {
|
|
514
515
|
maxLength,
|
|
515
516
|
highlight: true,
|
|
517
|
+
...defaultOptions,
|
|
516
518
|
...prettyFormatOptions
|
|
517
519
|
});
|
|
518
520
|
return dom.outerHTML.length > maxLength ? `${pretty.slice(0, maxLength)}...` : pretty;
|
|
@@ -522,11 +524,18 @@ function getElementError(selector, container) {
|
|
|
522
524
|
error.name = "VitestBrowserElementError";
|
|
523
525
|
return error;
|
|
524
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* @experimental
|
|
529
|
+
*/
|
|
530
|
+
function configurePrettyDOM(options) {
|
|
531
|
+
defaultOptions = options;
|
|
532
|
+
}
|
|
525
533
|
const utils = {
|
|
526
534
|
getElementError,
|
|
527
535
|
prettyDOM,
|
|
528
536
|
debug,
|
|
529
|
-
getElementLocatorSelectors
|
|
537
|
+
getElementLocatorSelectors,
|
|
538
|
+
configurePrettyDOM
|
|
530
539
|
};
|
|
531
540
|
|
|
532
541
|
export { cdp, createUserEvent, locators, page, utils };
|
package/dist/expect-element.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{expect,chai}from"vitest";import{getType}from"vitest/internal/browser";import{k as kAriaCheckedRoles,L as Locator,g as getAriaChecked,a as getAriaRole,b as getAriaDisabled,c as beginAriaCaches,e as endAriaCaches,i as isElementVisible$1,d as getElementAccessibleDescription,f as getElementAccessibleErrorMessage,h as getElementAccessibleName,j as cssEscape,l as
|
|
1
|
+
import{expect,chai}from"vitest";import{getType}from"vitest/internal/browser";import{k as kAriaCheckedRoles,L as Locator,g as getAriaChecked,a as getAriaRole,b as getAriaDisabled,c as beginAriaCaches,e as endAriaCaches,i as isElementVisible$1,d as getElementAccessibleDescription,f as getElementAccessibleErrorMessage,h as getElementAccessibleName,j as cssEscape,l as convertToSelector,m as getBrowserState,p as processTimeoutOptions}from"./index-CEutxZap.js";import{server}from"vitest/browser";import{recordArtifact}from"@vitest/runner";function getAriaCheckedRoles(){return[...kAriaCheckedRoles]}function queryElementFromUserInput(_,K,q){return _ instanceof Locator&&(_=_.query()),_==null?null:getElementFromUserInput(_,K,q)}function getElementFromUserInput(_,K,q){_ instanceof Locator&&(_=_.element());let J=_?.ownerDocument?.defaultView||window;if(_ instanceof J.HTMLElement||_ instanceof J.SVGElement)return _;throw new UserInputElementTypeError(_,K,q)}function getNodeFromUserInput(_,K,q){_ instanceof Locator&&(_=_.element());let J=_.ownerDocument?.defaultView||window;if(_ instanceof J.Node)return _;throw new UserInputNodeTypeError(_,K,q)}function getMessage(_,K,q,J,Y,X){return[`${K}\n`,`${q}:\n${_.utils.EXPECTED_COLOR(redent(display(_,J),2))}`,`${Y}:\n${_.utils.RECEIVED_COLOR(redent(display(_,X),2))}`].join(`
|
|
2
2
|
`)}function redent(_,K){return indentString(stripIndent(_),K)}function indentString(_,K){return _.replace(/^(?!\s*$)/gm,` `.repeat(K))}function minIndent(_){let K=_.match(/^[ \t]*(?=\S)/gm);return K?K.reduce((_,K)=>Math.min(_,K.length),1/0):0}function stripIndent(_){let K=minIndent(_);if(K===0)return _;let q=RegExp(`^[ \\t]{${K}}`,`gm`);return _.replace(q,``)}function display(_,K){return typeof K==`string`?K:_.utils.stringify(K)}function toSentence(_,{wordConnector:K=`, `,lastWordConnector:q=` and `}={}){return[_.slice(0,-1).join(K),_.at(-1)].join(_.length>1?q:``)}class GenericTypeError extends Error{constructor(_,K,q,J){super(),Error.captureStackTrace&&Error.captureStackTrace(this,q);let Y=``;try{Y=J.utils.printWithType(`Received`,K,J.utils.printReceived)}catch{}this.message=[J.utils.matcherHint(`${J.isNot?`.not`:``}.${q.name}`,`received`,``),``,`${J.utils.RECEIVED_COLOR(`received`)} value must ${_} or a Locator that returns ${_}.`,Y].join(`
|
|
3
3
|
`)}}class UserInputElementTypeError extends GenericTypeError{constructor(_,K,q){super(`an HTMLElement or an SVGElement`,_,K,q)}}class UserInputNodeTypeError extends GenericTypeError{constructor(_,K,q){super(`a Node`,_,K,q)}}function getTag(_){return _ instanceof HTMLFormElement?`FORM`:_.tagName.toUpperCase()}function isInputElement(_){return getTag(_)===`INPUT`}function getSingleElementValue(_){if(_)switch(getTag(_)){case`INPUT`:return getInputValue(_);case`SELECT`:return getSelectValue(_);default:return _.value??getAccessibleValue(_)}}function getSelectValue({multiple:_,options:K}){let q=[...K].filter(_=>_.selected);if(_)return[...q].map(_=>_.value);if(q.length!==0)return q[0].value}function getInputValue(_){switch(_.type){case`number`:return _.value===``?null:Number(_.value);case`checkbox`:return _.checked;default:return _.value}}const rolesSupportingValues=[`meter`,`progressbar`,`slider`,`spinbutton`];function getAccessibleValue(_){if(rolesSupportingValues.includes(_.getAttribute(`role`)||``))return Number(_.getAttribute(`aria-valuenow`))}function normalize(_){return _.replace(/\s+/g,` `).trim()}function matches(_,K){return K instanceof RegExp?K.test(_):_.includes(String(K))}function arrayAsSetComparison(_,K){if(Array.isArray(_)&&Array.isArray(K)){let q=new Set(K);for(let K of new Set(_))if(!q.has(K))return!1;return!0}}const supportedRoles=getAriaCheckedRoles();function toBeChecked(_){let K=getElementFromUserInput(_,toBeChecked,this);if(!(()=>isInputElement(K)&&[`checkbox`,`radio`].includes(K.type))()&&!(()=>supportedRoles.includes(getAriaRole(K)||``)&&[`true`,`false`].includes(K.getAttribute(`aria-checked`)||``))())return{pass:!1,message:()=>`only inputs with type="checkbox" or type="radio" or elements with ${supportedRolesSentence()} and a valid aria-checked attribute can be used with .toBeChecked(). Use .toHaveValue() instead`};let q=getAriaChecked(K)===!0;return{pass:q,message:()=>{let _=q?`is`:`is not`;return[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeChecked`,`element`,``),``,`Received element ${_} checked:`,` ${this.utils.printReceived(K.cloneNode(!1))}`].join(`
|
|
4
4
|
`)}}}function supportedRolesSentence(){return toSentence(supportedRoles.map(_=>`role="${_}"`),{lastWordConnector:` or `})}function toBeEmptyDOMElement(_){let K=getElementFromUserInput(_,toBeEmptyDOMElement,this);return{pass:isEmptyElement(K),message:()=>[this.utils.matcherHint(`${this.isNot?`.not`:``}.toBeEmptyDOMElement`,`element`,``),``,`Received:`,` ${this.utils.printReceived(K.innerHTML)}`].join(`
|
|
@@ -23,5 +23,5 @@ import{expect,chai}from"vitest";import{getType}from"vitest/internal/browser";imp
|
|
|
23
23
|
`)}}}function getMultiElementValue(_){let K=``;for(let q of _){if(K&&K!==q.type)throw Error(`Multiple form elements with the same name must be of the same type`);K=q.type}switch(K){case`radio`:{let K=_.find(_=>_.checked);return K?K.value:void 0}case`checkbox`:return _.filter(_=>_.checked).map(_=>_.value);default:return _.map(_=>_.value)}}function getFormValue(_,K){let q=[..._.querySelectorAll(`[name="${cssEscape(K)}"]`)];if(q.length!==0)switch(q.length){case 1:return getSingleElementValue(q[0]);default:return getMultiElementValue(q)}}function getPureName(_){return/\[\]$/.test(_)?_.slice(0,-2):_}function getAllFormValues(_){let K={};for(let q of _.elements){if(!(`name`in q))continue;let J=q.name;K[getPureName(J)]=getFormValue(_,J)}return K}function toHaveRole(_,K){let q=getElementFromUserInput(_,toHaveRole,this);beginAriaCaches();let J=getAriaRole(q);return endAriaCaches(),{pass:J===K,message:()=>{let _=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveRole`,`element`,``),`Expected element ${_} have role`,K,`Received`,J)}}}function toHaveSelection(_,K){let q=getElementFromUserInput(_,toHaveSelection,this),J=K!==void 0;if(J&&typeof K!=`string`)throw Error(`expected selection must be a string or undefined`);let Y=getSelection(q);return{pass:J?this.equals(Y,K,[arrayAsSetComparison,...this.customTesters]):!!Y,message:()=>{let _=this.isNot?`not to`:`to`,q=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveSelection`,`element`,K);return getMessage(this,q,`Expected the element ${_} have selection`,J?K:`(any)`,`Received`,Y)}}}function getSelection(_){let K=_.ownerDocument.getSelection();if(!K)return``;if([`INPUT`,`TEXTAREA`].includes(getTag(_))){let K=_;return[`radio`,`checkbox`].includes(K.type)||K.selectionStart==null||K.selectionEnd==null?``:K.value.toString().substring(K.selectionStart,K.selectionEnd)}if(K.anchorNode===null||K.focusNode===null)return``;let q=K.getRangeAt(0),J=_.ownerDocument.createRange();if(K.containsNode(_,!1))J.selectNodeContents(_),K.removeAllRanges(),K.addRange(J);else if(!(_.contains(K.anchorNode)&&_.contains(K.focusNode))){let Y=_===q.startContainer||_.contains(q.startContainer),X=_===q.endContainer||_.contains(q.endContainer);K.removeAllRanges(),(Y||X)&&(J.selectNodeContents(_),Y&&J.setStart(q.startContainer,q.startOffset),X&&J.setEnd(q.endContainer,q.endOffset),K.addRange(J))}let Y=K.toString();return K.removeAllRanges(),K.addRange(q),Y}const browser=server.config.browser.name,usedValuesProps=new Set(`backgroundPosition.background-position.bottom.left.right.top.height.width.margin-bottom.marginBottom.margin-left.marginLeft.margin-right.marginRight.margin-top.marginTop.min-height.minHeight.min-width.minWidth.padding-bottom.padding-left.padding-right.padding-top.text-indent.paddingBottom.paddingLeft.paddingRight.paddingTop.textIndent`.split(`.`));function toHaveStyle(_,K){let q=getElementFromUserInput(_,toHaveStyle,this),{getComputedStyle:J}=q.ownerDocument.defaultView,Y=typeof K==`object`?getStyleFromObjectCSS(K):computeCSSStyleDeclaration(K),X=J(q),Z=new Set(Array.from(q.style));return{pass:isSubset(Y,q,X,Z),message:()=>{let _=`${this.isNot?`.not`:``}.toHaveStyle`,K=new Set(Object.keys(Y)),J=printoutObjectStyles(Array.from(X).filter(_=>K.has(_)).reduce((_,K)=>(_[K]=(Z.has(K)&&usedValuesProps.has(K)?q.style:X)[K],_),{})),Q=J===``?`Expected styles could not be parsed by the browser. Did you make a typo?`:this.utils.diff(printoutObjectStyles(Y),J);return[this.utils.matcherHint(_,`element`,``),Q].join(`
|
|
24
24
|
|
|
25
25
|
`)}}}function getStyleFromObjectCSS(_){let K=browser===`chrome`||browser===`chromium`?document:document.implementation.createHTMLDocument(``),q=K.createElement(`div`);K.body.appendChild(q);let J=Object.keys(_);J.forEach(K=>{q.style[K]=_[K]});let Y={},X=window.getComputedStyle(q);return J.forEach(_=>{let K=(usedValuesProps.has(_)?q.style:X)[_];K!=null&&(Y[_]=K)}),q.remove(),Y}function computeCSSStyleDeclaration(_){let K=browser===`chrome`||browser===`chromium`||browser===`webkit`?document:document.implementation.createHTMLDocument(``),q=K.createElement(`div`);q.setAttribute(`style`,_.replace(/\n/g,``)),K.body.appendChild(q);let J=window.getComputedStyle(q),Y=Array.from(q.style).reduce((_,K)=>(_[K]=usedValuesProps.has(K)?q.style.getPropertyValue(K):J.getPropertyValue(K),_),{});return q.remove(),Y}function printoutObjectStyles(_){return Object.keys(_).sort().map(K=>`${K}: ${_[K]};`).join(`
|
|
26
|
-
`)}function isSubset(_,K,q,J){let Y=Object.keys(_);return Y.length?Y.every(Y=>{let X=_[Y],Z=Y.startsWith(`--`),Q=[Y];return Z||Q.push(Y.toLowerCase()),Q.some(_=>{let Z=J.has(Y)&&usedValuesProps.has(Y)?K.style:q;return Z[_]===X||Z.getPropertyValue(_)===X})}):!1}function toHaveTextContent(_,K,q={normalizeWhitespace:!0}){let J=getNodeFromUserInput(_,toHaveTextContent,this),Y=q.normalizeWhitespace?normalize(J.textContent||``):(J.textContent||``).replace(/\u00A0/g,` `),X=Y!==``&&K===``;return{pass:!X&&matches(Y,K),message:()=>{let _=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveTextContent`,`element`,``),X?`Checking with empty string will always match, use .toBeEmptyDOMElement() instead`:`Expected element ${_} have text content`,K,`Received`,Y)}}}function toHaveValue(_,K){let q=getElementFromUserInput(_,toHaveValue,this);if(isInputElement(q)&&[`checkbox`,`radio`].includes(q.type))throw Error(`input with type=checkbox or type=radio cannot be used with .toHaveValue(). Use .toBeChecked() for type=checkbox or .toHaveFormValues() instead`);let J=getSingleElementValue(q),Y=K!==void 0,X=K,Z=J;return K==J&&K!==J&&(X=`${K} (${typeof K})`,Z=`${J} (${typeof J})`),{pass:Y?this.equals(J,K,[arrayAsSetComparison,...this.customTesters]):!!J,message:()=>{let _=this.isNot?`not to`:`to`,q=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveValue`,`element`,K);return getMessage(this,q,`Expected the element ${_} have value`,Y?X:`(any)`,`Received`,Z)}}}const counters=new Map([]);async function toMatchScreenshot(_,K,q=typeof K==`object`?K:{}){if(this.isNot)throw Error(`'toMatchScreenshot' cannot be used with "not"`);
|
|
26
|
+
`)}function isSubset(_,K,q,J){let Y=Object.keys(_);return Y.length?Y.every(Y=>{let X=_[Y],Z=Y.startsWith(`--`),Q=[Y];return Z||Q.push(Y.toLowerCase()),Q.some(_=>{let Z=J.has(Y)&&usedValuesProps.has(Y)?K.style:q;return Z[_]===X||Z.getPropertyValue(_)===X})}):!1}function toHaveTextContent(_,K,q={normalizeWhitespace:!0}){let J=getNodeFromUserInput(_,toHaveTextContent,this),Y=q.normalizeWhitespace?normalize(J.textContent||``):(J.textContent||``).replace(/\u00A0/g,` `),X=Y!==``&&K===``;return{pass:!X&&matches(Y,K),message:()=>{let _=this.isNot?`not to`:`to`;return getMessage(this,this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveTextContent`,`element`,``),X?`Checking with empty string will always match, use .toBeEmptyDOMElement() instead`:`Expected element ${_} have text content`,K,`Received`,Y)}}}function toHaveValue(_,K){let q=getElementFromUserInput(_,toHaveValue,this);if(isInputElement(q)&&[`checkbox`,`radio`].includes(q.type))throw Error(`input with type=checkbox or type=radio cannot be used with .toHaveValue(). Use .toBeChecked() for type=checkbox or .toHaveFormValues() instead`);let J=getSingleElementValue(q),Y=K!==void 0,X=K,Z=J;return K==J&&K!==J&&(X=`${K} (${typeof K})`,Z=`${J} (${typeof J})`),{pass:Y?this.equals(J,K,[arrayAsSetComparison,...this.customTesters]):!!J,message:()=>{let _=this.isNot?`not to`:`to`,q=this.utils.matcherHint(`${this.isNot?`.not`:``}.toHaveValue`,`element`,K);return getMessage(this,q,`Expected the element ${_} have value`,Y?X:`(any)`,`Received`,Z)}}}const counters=new Map([]);async function toMatchScreenshot(_,K,q=typeof K==`object`?K:{}){if(this.isNot)throw Error(`'toMatchScreenshot' cannot be used with "not"`);if(this.task===void 0||this.currentTestName===void 0)throw Error(`'toMatchScreenshot' cannot be used without test context`);let J=`${this.task.result?.repeatCount??0}${this.testPath}${this.currentTestName}`,Y=counters.get(J);Y===void 0&&(Y={current:0},counters.set(J,Y)),Y.current+=1;let X=typeof K==`string`?K:`${this.currentTestName} ${Y.current}`,Z=q.screenshotOptions&&`mask`in q.screenshotOptions?{...q,screenshotOptions:{...q.screenshotOptions,mask:q.screenshotOptions.mask.map(convertToSelector)}}:q,Q=await getBrowserState().commands.triggerCommand(`__vitest_screenshotMatcher`,[X,this.currentTestName,{element:convertToSelector(_),...Z}]);if(Q.pass===!1){let _=[];Q.reference&&_.push({name:`reference`,...Q.reference}),Q.actual&&_.push({name:`actual`,...Q.actual}),Q.diff&&_.push({name:`diff`,path:Q.diff}),_.length>0&&await recordArtifact(this.task,{type:`internal:toMatchScreenshot`,kind:`visual-regression`,message:Q.message,attachments:_})}return{pass:Q.pass,message:()=>Q.pass?``:[this.utils.matcherHint(`toMatchScreenshot`,`element`,``),``,Q.message,Q.reference?`\nReference screenshot:\n ${this.utils.EXPECTED_COLOR(Q.reference.path)}`:null,Q.actual?`\nActual screenshot:\n ${this.utils.RECEIVED_COLOR(Q.actual.path)}`:null,Q.diff?this.utils.DIM_COLOR(`\nDiff image:\n ${Q.diff}`):null,``].filter(_=>_!==null).join(`
|
|
27
27
|
`)}}const matchers={toBeDisabled,toBeEnabled,toBeEmptyDOMElement,toBeInTheDocument,toBeInViewport,toBeInvalid,toBeRequired,toBeValid,toBeVisible,toContainElement,toContainHTML,toHaveAccessibleDescription,toHaveAccessibleErrorMessage,toHaveAccessibleName,toHaveAttribute,toHaveClass,toHaveFocus,toHaveFormValues,toHaveStyle,toHaveTextContent,toHaveValue,toHaveDisplayValue,toBeChecked,toBePartiallyChecked,toHaveRole,toHaveSelection,toMatchScreenshot},kLocator=Symbol.for(`$$vitest:locator`);function element(J,Y){if(J!=null&&!(J instanceof HTMLElement)&&!(J instanceof SVGElement)&&!(kLocator in J))throw Error(`Invalid element or locator: ${J}. Expected an instance of HTMLElement, SVGElement or Locator, received ${getType(J)}`);let X=expect.poll(function(){if(J instanceof Element||J==null)return J;let _=chai.util.flag(this,`negate`),q=chai.util.flag(this,`_name`);if(_&&q===`toBeInTheDocument`)return J.query();if(q===`toHaveLength`)return J.elements();if(chai.util.flag(this,`_isLastPollAttempt`))return J.element();let Y=J.query();if(!Y)throw Error(`Cannot find element with locator: ${JSON.stringify(J)}`);return Y},processTimeoutOptions(Y));return chai.util.flag(X,`_poll.element`,!0),X}expect.extend(matchers),expect.element=element;
|
|
@@ -3,4 +3,4 @@ import{server,page,utils}from"vitest/browser";import{__INTERNAL}from"vitest/inte
|
|
|
3
3
|
`).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function queryInAriaOwned(e,T){let E=[...e.querySelectorAll(T)];for(let D of getIdRefs(e,e.getAttribute(`aria-owns`)))D.matches(T)&&E.push(D),E.push(...D.querySelectorAll(T));return E}function getPseudoContent(e,T){let E=T===`::before`?cachePseudoContentBefore:cachePseudoContentAfter;if(E?.has(e))return E?.get(e)||``;let D=getPseudoContentImpl(getElementComputedStyle(e,T));return E&&E.set(e,D),D}function getPseudoContentImpl(e){if(!e)return``;let T=e.content;if(T[0]===`'`&&T[T.length-1]===`'`||T[0]===`"`&&T[T.length-1]===`"`){let E=T.substring(1,T.length-1);return(e.display||`inline`)===`inline`?E:` ${E} `}return``}function getAriaLabelledByElements(e){let T=e.getAttribute(`aria-labelledby`);return T===null?null:getIdRefs(e,T)}function allowsNameFromContent(e,T){let E=[`button`,`cell`,`checkbox`,`columnheader`,`gridcell`,`heading`,`link`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`row`,`rowheader`,`switch`,`tab`,`tooltip`,`treeitem`].includes(e),D=T&&[``,`caption`,`code`,`contentinfo`,`definition`,`deletion`,`emphasis`,`insertion`,`list`,`listitem`,`mark`,`none`,`paragraph`,`presentation`,`region`,`row`,`rowgroup`,`section`,`strong`,`subscript`,`superscript`,`table`,`term`,`time`].includes(e);return E||D}function getElementAccessibleName(e,T){let E=T?cacheAccessibleNameHidden:cacheAccessibleName,D=E?.get(e);return D===void 0&&(D=``,[`caption`,`code`,`definition`,`deletion`,`emphasis`,`generic`,`insertion`,`mark`,`paragraph`,`presentation`,`strong`,`subscript`,`suggestion`,`superscript`,`term`,`time`].includes(getAriaRole(e)||``)||(D=asFlatString(getTextAlternativeInternal(e,{includeHidden:T,visitedElements:new Set,embeddedInDescribedBy:void 0,embeddedInLabelledBy:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0,embeddedInTargetElement:`self`}))),E?.set(e,D)),D}function getElementAccessibleDescription(e,T){let E=cacheAccessibleDescription,D=E?.get(e);return D===void 0&&(D=``,D=e.hasAttribute(`aria-describedby`)?asFlatString(getIdRefs(e,e.getAttribute(`aria-describedby`)).map(e=>getTextAlternativeInternal(e,{includeHidden:T,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:isElementHiddenForAria(e)}})).join(` `)):e.hasAttribute(`aria-description`)?asFlatString(e.getAttribute(`aria-description`)||``):asFlatString(e.getAttribute(`title`)||``),E?.set(e,D)),D}var kAriaInvalidRoles=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function getAriaInvalid(e){let T=getAriaRole(e)||``;if(!T||!kAriaInvalidRoles.includes(T))return`false`;let E=e.getAttribute(`aria-invalid`);return!E||E.trim()===``||E.toLocaleLowerCase()===`false`?`false`:E===`true`||E===`grammar`||E===`spelling`?E:`true`}function getValidityInvalid(e){return`validity`in e?e.validity?.valid===!1:!1}function getElementAccessibleErrorMessage(e){let T=cacheAccessibleErrorMessage,E=cacheAccessibleErrorMessage?.get(e);if(E===void 0){E=``;let D=getAriaInvalid(e)!==`false`,O=getValidityInvalid(e);(D||O)&&(E=getIdRefs(e,e.getAttribute(`aria-errormessage`)).map(e=>asFlatString(getTextAlternativeInternal(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:isElementHiddenForAria(e)}}))).join(` `).trim()),T?.set(e,E)}return E}function getTextAlternativeInternal(e,T){if(T.visitedElements.has(e))return``;let E={...T,embeddedInTargetElement:T.embeddedInTargetElement===`self`?`descendant`:T.embeddedInTargetElement};if(!T.includeHidden){let E=!!T.embeddedInLabelledBy?.hidden||!!T.embeddedInDescribedBy?.hidden||!!T.embeddedInNativeTextAlternative?.hidden||!!T.embeddedInLabel?.hidden;if(isElementIgnoredForAria(e)||!E&&isElementHiddenForAria(e))return T.visitedElements.add(e),``}let D=getAriaLabelledByElements(e);if(!T.embeddedInLabelledBy){let e=(D||[]).map(e=>getTextAlternativeInternal(e,{...T,embeddedInLabelledBy:{element:e,hidden:isElementHiddenForAria(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let O=getAriaRole(e)||``,k=elementSafeTagName(e);if(T.embeddedInLabel||T.embeddedInLabelledBy||T.embeddedInTargetElement===`descendant`){let A=[...e.labels||[]].includes(e),j=(D||[]).includes(e);if(!A&&!j){if(O===`textbox`)return T.visitedElements.add(e),k===`INPUT`||k===`TEXTAREA`?e.value:e.textContent||``;if([`combobox`,`listbox`].includes(O)){T.visitedElements.add(e);let D;if(k===`SELECT`)D=[...e.selectedOptions],!D.length&&e.options.length&&D.push(e.options[0]);else{let T=O===`combobox`?queryInAriaOwned(e,`*`).find(e=>getAriaRole(e)===`listbox`):e;D=T?queryInAriaOwned(T,`[aria-selected="true"]`).filter(e=>getAriaRole(e)===`option`):[]}return!D.length&&k===`INPUT`?e.value:D.map(e=>getTextAlternativeInternal(e,E)).join(` `)}if([`progressbar`,`scrollbar`,`slider`,`spinbutton`,`meter`].includes(O))return T.visitedElements.add(e),e.hasAttribute(`aria-valuetext`)?e.getAttribute(`aria-valuetext`)||``:e.hasAttribute(`aria-valuenow`)?e.getAttribute(`aria-valuenow`)||``:e.getAttribute(`value`)||``;if([`menu`].includes(O))return T.visitedElements.add(e),``}}let A=e.getAttribute(`aria-label`)||``;if(trimFlatString(A))return T.visitedElements.add(e),A;if(![`presentation`,`none`].includes(O)){if(k===`INPUT`&&[`button`,`submit`,`reset`].includes(e.type)){T.visitedElements.add(e);let E=e.value||``;return trimFlatString(E)?E:e.type===`submit`?`Submit`:e.type===`reset`?`Reset`:e.getAttribute(`title`)||``}if(k===`INPUT`&&e.type===`image`){T.visitedElements.add(e);let E=e.labels||[];if(E.length&&!T.embeddedInLabelledBy)return getAccessibleNameFromAssociatedLabels(E,T);let D=e.getAttribute(`alt`)||``;if(trimFlatString(D))return D;let O=e.getAttribute(`title`)||``;return trimFlatString(O)?O:`Submit`}if(!D&&k===`BUTTON`){T.visitedElements.add(e);let E=e.labels||[];if(E.length)return getAccessibleNameFromAssociatedLabels(E,T)}if(!D&&k===`OUTPUT`){T.visitedElements.add(e);let E=e.labels||[];return E.length?getAccessibleNameFromAssociatedLabels(E,T):e.getAttribute(`title`)||``}if(!D&&(k===`TEXTAREA`||k===`SELECT`||k===`INPUT`)){T.visitedElements.add(e);let E=e.labels||[];if(E.length)return getAccessibleNameFromAssociatedLabels(E,T);let D=k===`INPUT`&&[`text`,`password`,`search`,`tel`,`email`,`url`].includes(e.type)||k===`TEXTAREA`,O=e.getAttribute(`placeholder`)||``,A=e.getAttribute(`title`)||``;return!D||A?A:O}if(!D&&k===`FIELDSET`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`LEGEND`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});return e.getAttribute(`title`)||``}if(!D&&k===`FIGURE`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`FIGCAPTION`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});return e.getAttribute(`title`)||``}if(k===`IMG`){T.visitedElements.add(e);let E=e.getAttribute(`alt`)||``;return trimFlatString(E)?E:e.getAttribute(`title`)||``}if(k===`TABLE`){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`CAPTION`)return getTextAlternativeInternal(T,{...E,embeddedInNativeTextAlternative:{element:T,hidden:isElementHiddenForAria(T)}});let D=e.getAttribute(`summary`)||``;if(D)return D}if(k===`AREA`){T.visitedElements.add(e);let E=e.getAttribute(`alt`)||``;return trimFlatString(E)?E:e.getAttribute(`title`)||``}if(k===`SVG`||e.ownerSVGElement){T.visitedElements.add(e);for(let T=e.firstElementChild;T;T=T.nextElementSibling)if(elementSafeTagName(T)===`TITLE`&&T.ownerSVGElement)return getTextAlternativeInternal(T,{...E,embeddedInLabelledBy:{element:T,hidden:isElementHiddenForAria(T)}})}if(e.ownerSVGElement&&k===`A`){let E=e.getAttribute(`xlink:title`)||``;if(trimFlatString(E))return T.visitedElements.add(e),E}}let j=k===`SUMMARY`&&![`presentation`,`none`].includes(O);if(allowsNameFromContent(O,T.embeddedInTargetElement===`descendant`)||j||T.embeddedInLabelledBy||T.embeddedInDescribedBy||T.embeddedInLabel||T.embeddedInNativeTextAlternative){T.visitedElements.add(e);let D=innerAccumulatedElementText(e,E);if(T.embeddedInTargetElement===`self`?trimFlatString(D):D)return D}if(![`presentation`,`none`].includes(O)||k===`IFRAME`){T.visitedElements.add(e);let E=e.getAttribute(`title`)||``;if(trimFlatString(E))return E}return T.visitedElements.add(e),``}function innerAccumulatedElementText(e,T){let E=[],D=(e,D)=>{if(!(D&&e.assignedSlot))if(e.nodeType===1){let D=getElementComputedStyle(e)?.display||`inline`,O=getTextAlternativeInternal(e,T);(D!==`inline`||e.nodeName===`BR`)&&(O=` `+O+` `),E.push(O)}else e.nodeType===3&&E.push(e.textContent||``)};E.push(getPseudoContent(e,`::before`));let O=e.nodeName===`SLOT`?e.assignedNodes():[];if(O.length)for(let e of O)D(e,!1);else{for(let T=e.firstChild;T;T=T.nextSibling)D(T,!0);if(e.shadowRoot)for(let T=e.shadowRoot.firstChild;T;T=T.nextSibling)D(T,!0);for(let T of getIdRefs(e,e.getAttribute(`aria-owns`)))D(T,!0)}return E.push(getPseudoContent(e,`::after`)),E.join(``)}var kAriaSelectedRoles=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function getAriaSelected(e){return elementSafeTagName(e)===`OPTION`?e.selected:kAriaSelectedRoles.includes(getAriaRole(e)||``)?getAriaBoolean(e.getAttribute(`aria-selected`))===!0:!1}var kAriaCheckedRoles=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function getAriaChecked(e){let T=getChecked(e);return T===`error`?!1:T}function getChecked(e,T){let E=elementSafeTagName(e);if(E===`INPUT`&&e.indeterminate)return`mixed`;if(E===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(kAriaCheckedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-checked`);return T===`true`?!0:T===`mixed`?`mixed`:!1}return`error`}var kAriaPressedRoles=[`button`];function getAriaPressed(e){if(kAriaPressedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-pressed`);if(T===`true`)return!0;if(T===`mixed`)return`mixed`}return!1}var kAriaExpandedRoles=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function getAriaExpanded(e){if(elementSafeTagName(e)===`DETAILS`)return e.open;if(kAriaExpandedRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-expanded`);return T===null?`none`:T===`true`}return`none`}var kAriaLevelRoles=[`heading`,`listitem`,`row`,`treeitem`];function getAriaLevel(e){let T={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[elementSafeTagName(e)];if(T)return T;if(kAriaLevelRoles.includes(getAriaRole(e)||``)){let T=e.getAttribute(`aria-level`),E=T===null?NaN:Number(T);if(Number.isInteger(E)&&E>=1)return E}return 0}var kAriaDisabledRoles=`application.button.composite.gridcell.group.input.link.menuitem.scrollbar.separator.tab.checkbox.columnheader.combobox.grid.listbox.menu.menubar.menuitemcheckbox.menuitemradio.option.radio.radiogroup.row.rowheader.searchbox.select.slider.spinbutton.switch.tablist.textbox.toolbar.tree.treegrid.treeitem`.split(`.`);function getAriaDisabled(e){return isNativelyDisabled(e)||hasExplicitAriaDisabled(e)}function isNativelyDisabled(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||belongsToDisabledFieldSet(e))}function belongsToDisabledFieldSet(e){let T=e?.closest(`FIELDSET[DISABLED]`);if(!T)return!1;let E=T.querySelector(`:scope > LEGEND`);return!E||!E.contains(e)}function hasExplicitAriaDisabled(e){if(!e)return!1;if(kAriaDisabledRoles.includes(getAriaRole(e)||``)){let T=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(T===`true`)return!0;if(T===`false`)return!1}return hasExplicitAriaDisabled(parentElementOrShadowHost(e))}function getAccessibleNameFromAssociatedLabels(e,T){return[...e].map(e=>getTextAlternativeInternal(e,{...T,embeddedInLabel:{element:e,hidden:isElementHiddenForAria(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}var cacheAccessibleName,cacheAccessibleNameHidden,cacheAccessibleErrorMessage,cacheAccessibleDescription,cacheIsHidden,cachePseudoContentBefore,cachePseudoContentAfter,cachesCounter=0;function beginAriaCaches(){++cachesCounter,cacheAccessibleName??=new Map,cacheAccessibleNameHidden??=new Map,cacheAccessibleDescription??=new Map,cacheAccessibleErrorMessage??=new Map,cacheIsHidden??=new Map,cachePseudoContentBefore??=new Map,cachePseudoContentAfter??=new Map}function endAriaCaches(){--cachesCounter||(cacheAccessibleName=void 0,cacheAccessibleNameHidden=void 0,cacheAccessibleDescription=void 0,cacheAccessibleErrorMessage=void 0,cacheIsHidden=void 0,cachePseudoContentBefore=void 0,cachePseudoContentAfter=void 0)}function matchesAttributePart(e,T){let E=typeof e==`string`&&!T.caseSensitive?e.toUpperCase():e,D=typeof T.value==`string`&&!T.caseSensitive?T.value.toUpperCase():T.value;return T.op===`<truthy>`?!!E:T.op===`=`?D instanceof RegExp?typeof E==`string`&&!!E.match(D):E===D:typeof E!=`string`||typeof D!=`string`?!1:T.op===`*=`?E.includes(D):T.op===`^=`?E.startsWith(D):T.op===`$=`?E.endsWith(D):T.op===`|=`?E===D||E.startsWith(`${D}-`):T.op===`~=`?E.split(` `).includes(D):!1}function shouldSkipForTextMatching(e){let T=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||T.head&&T.head.contains(e)}function elementText(e,T){let E=e.get(T);if(E===void 0){if(E={full:``,normalized:``,immediate:[]},!shouldSkipForTextMatching(T)){let D=``;if(T instanceof HTMLInputElement&&(T.type===`submit`||T.type===`button`))E={full:T.value,normalized:normalizeWhiteSpace(T.value),immediate:[T.value]};else{for(let O=T.firstChild;O;O=O.nextSibling)O.nodeType===Node.TEXT_NODE?(E.full+=O.nodeValue||``,D+=O.nodeValue||``):(D&&E.immediate.push(D),D=``,O.nodeType===Node.ELEMENT_NODE&&(E.full+=elementText(e,O).full));D&&E.immediate.push(D),T.shadowRoot&&(E.full+=elementText(e,T.shadowRoot).full),E.full&&(E.normalized=normalizeWhiteSpace(E.full))}}e.set(T,E)}return E}function elementMatchesText(e,T,E){if(shouldSkipForTextMatching(T)||!E(elementText(e,T)))return`none`;for(let D=T.firstChild;D;D=D.nextSibling)if(D.nodeType===Node.ELEMENT_NODE&&E(elementText(e,D)))return`selfAndChildren`;return T.shadowRoot&&E(elementText(e,T.shadowRoot))?`selfAndChildren`:`self`}function getElementLabels(e,T){let E=getAriaLabelledByElements(T);if(E)return E.map(T=>elementText(e,T));let D=T.getAttribute(`aria-label`);if(D!==null&&D.trim())return[{full:D,normalized:normalizeWhiteSpace(D),immediate:[D]}];let O=T.nodeName===`INPUT`&&T.type!==`hidden`;if([`BUTTON`,`METER`,`OUTPUT`,`PROGRESS`,`SELECT`,`TEXTAREA`].includes(T.nodeName)||O){let E=T.labels;if(E)return[...E].map(T=>elementText(e,T))}return[]}var kSupportedAttributes=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];kSupportedAttributes.sort();function validateSupportedRole(e,T,E){if(!T.includes(E))throw Error(`"${e}" attribute is only supported for roles: ${T.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function validateSupportedValues(e,T){if(e.op!==`<truthy>`&&!T.includes(e.value))throw Error(`"${e.name}" must be one of ${T.map(e=>JSON.stringify(e)).join(`, `)}`)}function validateSupportedOp(e,T){if(!T.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function validateAttributes(e,T){let E={role:T};for(let D of e)switch(D.name){case`checked`:validateSupportedRole(D.name,kAriaCheckedRoles,T),validateSupportedValues(D,[!0,!1,`mixed`]),validateSupportedOp(D,[`<truthy>`,`=`]),E.checked=D.op===`<truthy>`?!0:D.value;break;case`pressed`:validateSupportedRole(D.name,kAriaPressedRoles,T),validateSupportedValues(D,[!0,!1,`mixed`]),validateSupportedOp(D,[`<truthy>`,`=`]),E.pressed=D.op===`<truthy>`?!0:D.value;break;case`selected`:validateSupportedRole(D.name,kAriaSelectedRoles,T),validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.selected=D.op===`<truthy>`?!0:D.value;break;case`expanded`:validateSupportedRole(D.name,kAriaExpandedRoles,T),validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.expanded=D.op===`<truthy>`?!0:D.value;break;case`level`:if(validateSupportedRole(D.name,kAriaLevelRoles,T),typeof D.value==`string`&&(D.value=+D.value),D.op!==`=`||typeof D.value!=`number`||Number.isNaN(D.value))throw Error(`"level" attribute must be compared to a number`);E.level=D.value;break;case`disabled`:validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.disabled=D.op===`<truthy>`?!0:D.value;break;case`name`:if(D.op===`<truthy>`)throw Error(`"name" attribute must have a value`);if(typeof D.value!=`string`&&!(D.value instanceof RegExp))throw TypeError(`"name" attribute must be a string or a regular expression`);E.name=D.value,E.nameOp=D.op,E.exact=D.caseSensitive;break;case`include-hidden`:validateSupportedValues(D,[!0,!1]),validateSupportedOp(D,[`<truthy>`,`=`]),E.includeHidden=D.op===`<truthy>`?!0:D.value;break;default:throw Error(`Unknown attribute "${D.name}", must be one of ${kSupportedAttributes.map(e=>`"${e}"`).join(`, `)}.`)}return E}function queryRole(e,T,E){let D=[],O=e=>{if(getAriaRole(e)===T.role&&!(T.selected!==void 0&&getAriaSelected(e)!==T.selected)&&!(T.checked!==void 0&&getAriaChecked(e)!==T.checked)&&!(T.pressed!==void 0&&getAriaPressed(e)!==T.pressed)&&!(T.expanded!==void 0&&getAriaExpanded(e)!==T.expanded)&&!(T.level!==void 0&&getAriaLevel(e)!==T.level)&&!(T.disabled!==void 0&&getAriaDisabled(e)!==T.disabled)&&!(!T.includeHidden&&isElementHiddenForAria(e))){if(T.name!==void 0){let D=normalizeWhiteSpace(getElementAccessibleName(e,!!T.includeHidden));if(typeof T.name==`string`&&(T.name=normalizeWhiteSpace(T.name)),E&&!T.exact&&T.nameOp===`=`&&(T.nameOp=`*=`),!matchesAttributePart(D,{op:T.nameOp||`=`,value:T.name,caseSensitive:!!T.exact}))return}D.push(e)}},k=e=>{let T=[];e.shadowRoot&&T.push(e.shadowRoot);for(let E of e.querySelectorAll(`*`))O(E),E.shadowRoot&&T.push(E.shadowRoot);T.forEach(k)};return k(e),D}function createRoleEngine(e){return{queryAll:(T,E)=>{let D=parseAttributeSelector(E),O=D.name.toLowerCase();if(!O)throw Error(`Role must not be empty`);let k=validateAttributes(D.attributes,O);beginAriaCaches();try{return queryRole(T,k,e)}finally{endAriaCaches()}}}}function asLocator(e,T,E=!1){return asLocators(e,T,E)[0]}function asLocators(e,T,E=!1,D=20,O){try{return innerAsLocators(new generators[e](O),parseSelector(T),E,D)}catch{return[T]}}function innerAsLocators(e,T,E=!1,D=20){let O=[...T.parts];for(let e=0;e<O.length-1;e++)if(O[e].name===`nth`&&O[e+1].name===`internal:control`&&O[e+1].body===`enter-frame`){let[T]=O.splice(e,1);O.splice(e+1,0,T)}let k=[],A=E?`frame-locator`:`page`;for(let T=0;T<O.length;T++){let E=O[T],j=A;if(A=`locator`,E.name===`nth`){E.body===`0`?k.push([e.generateLocator(j,`first`,``),e.generateLocator(j,`nth`,`0`)]):E.body===`-1`?k.push([e.generateLocator(j,`last`,``),e.generateLocator(j,`nth`,`-1`)]):k.push([e.generateLocator(j,`nth`,E.body)]);continue}if(E.name===`internal:text`){let{exact:T,text:D}=detectExact(E.body);k.push([e.generateLocator(j,`text`,D,{exact:T})]);continue}if(E.name===`internal:has-text`){let{exact:T,text:D}=detectExact(E.body);if(!T){k.push([e.generateLocator(j,`has-text`,D,{exact:T})]);continue}}if(E.name===`internal:has-not-text`){let{exact:T,text:D}=detectExact(E.body);if(!T){k.push([e.generateLocator(j,`has-not-text`,D,{exact:T})]);continue}}if(E.name===`internal:has`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`has`,T)));continue}if(E.name===`internal:has-not`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`hasNot`,T)));continue}if(E.name===`internal:and`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`and`,T)));continue}if(E.name===`internal:or`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`or`,T)));continue}if(E.name===`internal:chain`){let T=innerAsLocators(e,E.body.parsed,!1,D);k.push(T.map(T=>e.generateLocator(j,`chain`,T)));continue}if(E.name===`internal:label`){let{exact:T,text:D}=detectExact(E.body);k.push([e.generateLocator(j,`label`,D,{exact:T})]);continue}if(E.name===`internal:role`){let T=parseAttributeSelector(E.body),D={attrs:[]};for(let e of T.attributes)e.name===`name`?(D.exact=e.caseSensitive,D.name=e.value):(e.name===`level`&&typeof e.value==`string`&&(e.value=+e.value),D.attrs.push({name:e.name===`include-hidden`?`includeHidden`:e.name,value:e.value}));k.push([e.generateLocator(j,`role`,T.name,D)]);continue}if(E.name===`internal:testid`){let{value:T}=parseAttributeSelector(E.body).attributes[0];k.push([e.generateLocator(j,`test-id`,T)]);continue}if(E.name===`internal:attr`){let{name:T,value:D,caseSensitive:O}=parseAttributeSelector(E.body).attributes[0],A=D,M=!!O;if(T===`placeholder`){k.push([e.generateLocator(j,`placeholder`,A,{exact:M})]);continue}if(T===`alt`){k.push([e.generateLocator(j,`alt`,A,{exact:M})]);continue}if(T===`title`){k.push([e.generateLocator(j,`title`,A,{exact:M})]);continue}}let M=`default`,N=O[T+1];N&&N.name===`internal:control`&&N.body===`enter-frame`&&(M=`frame`,A=`frame-locator`,T++);let P=stringifySelector({parts:[E]}),F=e.generateLocator(j,M,P);if(M===`default`&&N&&[`internal:has-text`,`internal:has-not-text`].includes(N.name)){let{exact:E,text:D}=detectExact(N.body);if(!E){let O=e.generateLocator(`locator`,N.name===`internal:has-text`?`has-text`:`has-not-text`,D,{exact:E}),A={};N.name===`internal:has-text`?A.hasText=D:A.hasNotText=D;let M=e.generateLocator(j,`default`,P,A);k.push([e.chainLocators([F,O]),M]),T++;continue}}let I;if([`xpath`,`css`].includes(E.name)){let T=stringifySelector({parts:[E]},!0);I=e.generateLocator(j,M,T)}k.push([F,I].filter(Boolean))}return combineTokens(e,k,D)}function combineTokens(e,T,E){let D=T.map(()=>``),O=[],k=A=>{if(A===T.length)return O.push(e.chainLocators(D)),D.length<E;for(let e of T[A])if(D[A]=e,!k(A+1))return!1;return!0};return k(0),O}function detectExact(e){let T=!1,E=e.match(/^\/(.*)\/([igm]*)$/);return E?{text:new RegExp(E[1],E[2])}:(e.endsWith(`"`)?(e=JSON.parse(e),T=!0):e.endsWith(`"s`)?(e=JSON.parse(e.substring(0,e.length-1)),T=!0):e.endsWith(`"i`)&&(e=JSON.parse(e.substring(0,e.length-1)),T=!1),{exact:T,text:e})}var JavaScriptLocatorFactory=class{constructor(e){this.preferredQuote=e}generateLocator(e,T,E,D={}){switch(T){case`default`:return D.hasText===void 0?D.hasNotText===void 0?`locator(${this.quote(E)})`:`locator(${this.quote(E)}, { hasNotText: ${this.toHasText(D.hasNotText)} })`:`locator(${this.quote(E)}, { hasText: ${this.toHasText(D.hasText)} })`;case`frame`:return`frameLocator(${this.quote(E)})`;case`nth`:return`nth(${E})`;case`first`:return`first()`;case`last`:return`last()`;case`role`:{let e=[];isRegExp(D.name)?e.push(`name: ${this.regexToSourceString(D.name)}`):typeof D.name==`string`&&(e.push(`name: ${this.quote(D.name)}`),D.exact&&e.push(`exact: true`));for(let{name:T,value:E}of D.attrs)e.push(`${T}: ${typeof E==`string`?this.quote(E):E}`);let T=e.length?`, { ${e.join(`, `)} }`:``;return`getByRole(${this.quote(E)}${T})`}case`has-text`:return`filter({ hasText: ${this.toHasText(E)} })`;case`has-not-text`:return`filter({ hasNotText: ${this.toHasText(E)} })`;case`has`:return`filter({ has: ${E} })`;case`hasNot`:return`filter({ hasNot: ${E} })`;case`and`:return`and(${E})`;case`or`:return`or(${E})`;case`chain`:return`locator(${E})`;case`test-id`:return`getByTestId(${this.toTestIdValue(E)})`;case`text`:return this.toCallWithExact(`getByText`,E,!!D.exact);case`alt`:return this.toCallWithExact(`getByAltText`,E,!!D.exact);case`placeholder`:return this.toCallWithExact(`getByPlaceholder`,E,!!D.exact);case`label`:return this.toCallWithExact(`getByLabel`,E,!!D.exact);case`title`:return this.toCallWithExact(`getByTitle`,E,!!D.exact);default:throw Error(`Unknown selector kind ${T}`)}}chainLocators(e){return e.join(`.`)}regexToSourceString(e){return normalizeEscapedRegexQuotes(String(e))}toCallWithExact(e,T,E){return isRegExp(T)?`${e}(${this.regexToSourceString(T)})`:E?`${e}(${this.quote(T)}, { exact: true })`:`${e}(${this.quote(T)})`}toHasText(e){return isRegExp(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return isRegExp(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return escapeWithQuotes(e,this.preferredQuote??`'`)}},generators={javascript:JavaScriptLocatorFactory};function isRegExp(e){return e instanceof RegExp}var cacheAllowText=new Map,cacheDisallowText=new Map,kTextScoreRange=10,kExactPenalty=kTextScoreRange/2,kTestIdScore=1,kOtherTestIdScore=2,kIframeByAttributeScore=10,kBeginPenalizedScore=50,kPlaceholderScore=100,kLabelScore=120,kRoleWithNameScore=140,kAltTextScore=160,kTextScore=180,kTitleScore=200,kTextScoreRegex=250,kPlaceholderScoreExact=kPlaceholderScore+kExactPenalty,kLabelScoreExact=kLabelScore+kExactPenalty,kRoleWithNameScoreExact=kRoleWithNameScore+kExactPenalty,kAltTextScoreExact=kAltTextScore+kExactPenalty,kTextScoreExact=kTextScore+kExactPenalty,kTitleScoreExact=kTitleScore+kExactPenalty,kEndPenalizedScore=300,kCSSIdScore=500,kRoleWithoutNameScore=510,kCSSInputTypeNameScore=520,kCSSTagNameScore=530,kNthScore=1e4,kCSSFallbackScore=1e7;function generateSelector(e,T,E){e._evaluator.begin(),beginAriaCaches();try{return joinTokens(generateSelectorFor(e,T,E)||cssFallback(e,T,E))}finally{cacheAllowText.clear(),cacheDisallowText.clear(),endAriaCaches(),e._evaluator.end()}}function filterRegexTokens(e){return e.filter(e=>e[0].selector[0]!==`/`)}function generateSelectorFor(e,T,E){if(T.ownerDocument.documentElement===T)return[{engine:`css`,selector:`html`,score:1}];let D=(D,k)=>{let A=D===T,j=k?buildTextCandidates(e,D,D===T):[];D!==T&&(j=filterRegexTokens(j));let M=buildNoTextCandidates(e,D,E).map(e=>[e]),N=chooseFirstSelector(e,T.ownerDocument,D,[...j,...M],A);j=filterRegexTokens(j);let P=T=>{let E=k&&!T.length,j=[...T,...M].filter(e=>N?combineScores(e)<combineScores(N):!0),P=j[0];if(P)for(let T=parentElementOrShadowHost(D);T;T=parentElementOrShadowHost(T)){let k=O(T,E);if(!k||N&&combineScores([...k,...P])>=combineScores(N))continue;if(P=chooseFirstSelector(e,T,D,j,A),!P)return;let M=[...k,...P];(!N||combineScores(M)<combineScores(N))&&(N=M)}};return P(j),D===T&&j.length&&P([]),N},O=(e,T)=>{let E=T?cacheAllowText:cacheDisallowText,O=E.get(e);return O===void 0&&(O=D(e,T),E.set(e,O)),O};return D(T,!E.noText)}function buildNoTextCandidates(e,T,E){let D=[];for(let e of[`data-testid`,`data-test-id`,`data-test`])e!==E.testIdAttributeName&&T.getAttribute(e)&&D.push({engine:`css`,selector:`[${e}=${quoteCSSAttributeValue(T.getAttribute(e))}]`,score:kOtherTestIdScore});if(!E.noCSSId){let e=T.getAttribute(`id`);e&&!isGuidLike(e)&&D.push({engine:`css`,selector:makeSelectorForId(e),score:kCSSIdScore})}if(D.push({engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSTagNameScore}),T.nodeName===`IFRAME`){for(let e of[`name`,`title`])T.getAttribute(e)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[${e}=${quoteCSSAttributeValue(T.getAttribute(e))}]`,score:kIframeByAttributeScore});return T.getAttribute(E.testIdAttributeName)&&D.push({engine:`css`,selector:`[${E.testIdAttributeName}=${quoteCSSAttributeValue(T.getAttribute(E.testIdAttributeName))}]`,score:kTestIdScore}),penalizeScoreForLength([D]),D}if(T.getAttribute(E.testIdAttributeName)&&D.push({engine:`internal:testid`,selector:`[${E.testIdAttributeName}=${escapeForAttributeSelector(T.getAttribute(E.testIdAttributeName),!0)}]`,score:kTestIdScore}),T.nodeName===`INPUT`||T.nodeName===`TEXTAREA`){let e=T;if(e.placeholder){D.push({engine:`internal:attr`,selector:`[placeholder=${escapeForAttributeSelector(e.placeholder,!0)}]`,score:kPlaceholderScoreExact});for(let T of suitableTextAlternatives(e.placeholder))D.push({engine:`internal:attr`,selector:`[placeholder=${escapeForAttributeSelector(T.text,!1)}]`,score:kPlaceholderScore-T.scoreBouns})}}let O=getElementLabels(e._evaluator._cacheText,T);for(let e of O){let T=e.normalized;D.push({engine:`internal:label`,selector:escapeForTextSelector$1(T,!0),score:kLabelScoreExact});for(let e of suitableTextAlternatives(T))D.push({engine:`internal:label`,selector:escapeForTextSelector$1(e.text,!1),score:kLabelScore-e.scoreBouns})}let k=getAriaRole(T);return k&&![`none`,`presentation`].includes(k)&&D.push({engine:`internal:role`,selector:k,score:kRoleWithoutNameScore}),T.getAttribute(`name`)&&[`BUTTON`,`FORM`,`FIELDSET`,`FRAME`,`IFRAME`,`INPUT`,`KEYGEN`,`OBJECT`,`OUTPUT`,`SELECT`,`TEXTAREA`,`MAP`,`META`,`PARAM`].includes(T.nodeName)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[name=${quoteCSSAttributeValue(T.getAttribute(`name`))}]`,score:kCSSInputTypeNameScore}),[`INPUT`,`TEXTAREA`].includes(T.nodeName)&&T.getAttribute(`type`)!==`hidden`&&T.getAttribute(`type`)&&D.push({engine:`css`,selector:`${cssEscape(T.nodeName.toLowerCase())}[type=${quoteCSSAttributeValue(T.getAttribute(`type`))}]`,score:kCSSInputTypeNameScore}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(T.nodeName)&&T.getAttribute(`type`)!==`hidden`&&D.push({engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSInputTypeNameScore+1}),penalizeScoreForLength([D]),D}function buildTextCandidates(e,T,E){if(T.nodeName===`SELECT`)return[];let D=[],O=T.getAttribute(`title`);if(O){D.push([{engine:`internal:attr`,selector:`[title=${escapeForAttributeSelector(O,!0)}]`,score:kTitleScoreExact}]);for(let e of suitableTextAlternatives(O))D.push([{engine:`internal:attr`,selector:`[title=${escapeForAttributeSelector(e.text,!1)}]`,score:kTitleScore-e.scoreBouns}])}let k=T.getAttribute(`alt`);if(k&&[`APPLET`,`AREA`,`IMG`,`INPUT`].includes(T.nodeName)){D.push([{engine:`internal:attr`,selector:`[alt=${escapeForAttributeSelector(k,!0)}]`,score:kAltTextScoreExact}]);for(let e of suitableTextAlternatives(k))D.push([{engine:`internal:attr`,selector:`[alt=${escapeForAttributeSelector(e.text,!1)}]`,score:kAltTextScore-e.scoreBouns}])}let A=elementText(e._evaluator._cacheText,T).normalized;if(A){let e=suitableTextAlternatives(A);if(E){A.length<=80&&D.push([{engine:`internal:text`,selector:escapeForTextSelector$1(A,!0),score:kTextScoreExact}]);for(let T of e)D.push([{engine:`internal:text`,selector:escapeForTextSelector$1(T.text,!1),score:kTextScore-T.scoreBouns}])}let O={engine:`css`,selector:cssEscape(T.nodeName.toLowerCase()),score:kCSSTagNameScore};for(let T of e)D.push([O,{engine:`internal:has-text`,selector:escapeForTextSelector$1(T.text,!1),score:kTextScore-T.scoreBouns}]);if(A.length<=80){let e=RegExp(`^${escapeRegExp(A)}$`);D.push([O,{engine:`internal:has-text`,selector:escapeForTextSelector$1(e,!1),score:kTextScoreRegex}])}}let j=getAriaRole(T);if(j&&![`none`,`presentation`].includes(j)){let e=getElementAccessibleName(T,!1);if(e){D.push([{engine:`internal:role`,selector:`${j}[name=${escapeForAttributeSelector(e,!0)}]`,score:kRoleWithNameScoreExact}]);for(let T of suitableTextAlternatives(e))D.push([{engine:`internal:role`,selector:`${j}[name=${escapeForAttributeSelector(T.text,!1)}]`,score:kRoleWithNameScore-T.scoreBouns}])}}return penalizeScoreForLength(D),D}function makeSelectorForId(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${cssEscape(e)}"]`}function cssFallback(e,T,E){let D=T.ownerDocument,O=[];function k(E){let k=O.slice();E&&k.unshift(E);let A=k.join(` > `),j=e.parseSelector(A);return e.querySelector(j,D,!1)===T?A:void 0}function A(E){let O={engine:`css`,selector:E,score:kCSSFallbackScore},k=e.parseSelector(E),A=e.querySelectorAll(k,D);return A.length===1?[O]:[O,{engine:`nth`,selector:String(A.indexOf(T)),score:kNthScore}]}for(let e=T;e&&e!==D;e=parentElementOrShadowHost(e)){let T=e.nodeName.toLowerCase(),D=``;if(e.id&&!E.noCSSId){let T=makeSelectorForId(e.id),E=k(T);if(E)return A(E);D=T}let j=e.parentNode,N=[...e.classList];for(let e=0;e<N.length;++e){let T=`.${cssEscape(N.slice(0,e+1).join(`.`))}`,E=k(T);if(E)return A(E);!D&&j&&j.querySelectorAll(T).length===1&&(D=T)}if(j){let E=[...j.children],O=E.filter(e=>e.nodeName.toLowerCase()===T).indexOf(e)===0?cssEscape(T):`${cssEscape(T)}:nth-child(${1+E.indexOf(e)})`,N=k(O);if(N)return A(N);D||=O}else D||=cssEscape(T);O.unshift(D)}return A(k())}function penalizeScoreForLength(e){for(let T of e)for(let e of T)e.score>kBeginPenalizedScore&&e.score<kEndPenalizedScore&&(e.score+=Math.min(kTextScoreRange,e.selector.length/10|0))}function joinTokens(e){let T=[],E=``;for(let{engine:D,selector:O}of e)T.length&&(E!==`css`||D!==`css`||O.startsWith(`:nth-match(`))&&T.push(`>>`),E=D,D===`css`?T.push(O):T.push(`${D}=${O}`);return T.join(` `)}function combineScores(e){let T=0;for(let E=0;E<e.length;E++)T+=e[E].score*(e.length-E);return T}function chooseFirstSelector(e,T,E,D,O){let k=D.map(e=>({tokens:e,score:combineScores(e)}));k.sort((e,T)=>e.score-T.score);let A=null;for(let{tokens:D}of k){let k=e.parseSelector(joinTokens(D)),j=e.querySelectorAll(k,T);if(j[0]===E&&j.length===1)return D;let M=j.indexOf(E);if(!O||A||M===-1||j.length>5)continue;let N={engine:`nth`,selector:String(M),score:kNthScore};A=[...D,N]}return A}function isGuidLike(e){let T,E=0;for(let D=0;D<e.length;++D){let O=e[D],k;if(!(O===`-`||O===`_`)){if(k=O>=`a`&&O<=`z`?`lower`:O>=`A`&&O<=`Z`?`upper`:O>=`0`&&O<=`9`?`digit`:`other`,k===`lower`&&T===`upper`){T=k;continue}T&&T!==k&&++E,T=k}}return E>=e.length/4}function trimWordBoundary(e,T){if(e.length<=T)return e;e=e.substring(0,T);let E=e.match(/^(.*)\b(.+)$/);return E?E[1].trimEnd():``}function suitableTextAlternatives(e){let T=[];{let E=e.match(/^([\d.,]+)[^.,\w]/),D=E?E[1].length:0;if(D){let E=trimWordBoundary(e.substring(D).trimStart(),80);T.push({text:E,scoreBouns:E.length<=30?2:1})}}{let E=e.match(/[^.,\w]([\d.,]+)$/),D=E?E[1].length:0;if(D){let E=trimWordBoundary(e.substring(0,e.length-D).trimEnd(),80);T.push({text:E,scoreBouns:E.length<=30?2:1})}}return e.length<=30?T.push({text:e,scoreBouns:0}):(T.push({text:trimWordBoundary(e,80),scoreBouns:0}),T.push({text:trimWordBoundary(e,30),scoreBouns:1})),T=T.filter(e=>e.text),T.length||T.push({text:e.substring(0,80),scoreBouns:0}),T}function boxRightOf(e,T,E){let D=e.left-T.right;if(!(D<0||E!==void 0&&D>E))return D+Math.max(T.bottom-e.bottom,0)+Math.max(e.top-T.top,0)}function boxLeftOf(e,T,E){let D=T.left-e.right;if(!(D<0||E!==void 0&&D>E))return D+Math.max(T.bottom-e.bottom,0)+Math.max(e.top-T.top,0)}function boxAbove(e,T,E){let D=T.top-e.bottom;if(!(D<0||E!==void 0&&D>E))return D+Math.max(e.left-T.left,0)+Math.max(T.right-e.right,0)}function boxBelow(e,T,E){let D=e.top-T.bottom;if(!(D<0||E!==void 0&&D>E))return D+Math.max(e.left-T.left,0)+Math.max(T.right-e.right,0)}function boxNear(e,T,E){let D=E===void 0?50:E,O=0;return e.left-T.right>=0&&(O+=e.left-T.right),T.left-e.right>=0&&(O+=T.left-e.right),T.top-e.bottom>=0&&(O+=T.top-e.bottom),e.top-T.bottom>=0&&(O+=e.top-T.bottom),O>D?void 0:O}var kLayoutSelectorNames=[`left-of`,`right-of`,`above`,`below`,`near`];function layoutSelectorScore(e,T,E,D){let O=T.getBoundingClientRect(),k={"left-of":boxLeftOf,"right-of":boxRightOf,above:boxAbove,below:boxBelow,near:boxNear}[e],A;for(let e of E){if(e===T)continue;let E=k(O,e.getBoundingClientRect(),D);E!==void 0&&(A===void 0||E<A)&&(A=E)}return A}var SelectorEvaluatorImpl=class{constructor(e){__publicField(this,`_engines`,new Map),__publicField(this,`_cacheQueryCSS`,new Map),__publicField(this,`_cacheMatches`,new Map),__publicField(this,`_cacheQuery`,new Map),__publicField(this,`_cacheMatchesSimple`,new Map),__publicField(this,`_cacheMatchesParents`,new Map),__publicField(this,`_cacheCallMatches`,new Map),__publicField(this,`_cacheCallQuery`,new Map),__publicField(this,`_cacheQuerySimple`,new Map),__publicField(this,`_cacheText`,new Map),__publicField(this,`_scoreMap`),__publicField(this,`_retainCacheCounter`,0);for(let[T,E]of e)this._engines.set(T,E);this._engines.set(`not`,notEngine),this._engines.set(`is`,isEngine),this._engines.set(`where`,isEngine),this._engines.set(`has`,hasEngine),this._engines.set(`scope`,scopeEngine),this._engines.set(`light`,lightEngine),this._engines.set(`visible`,visibleEngine),this._engines.set(`text`,textEngine),this._engines.set(`text-is`,textIsEngine),this._engines.set(`text-matches`,textMatchesEngine),this._engines.set(`has-text`,hasTextEngine),this._engines.set(`right-of`,createLayoutEngine(`right-of`)),this._engines.set(`left-of`,createLayoutEngine(`left-of`)),this._engines.set(`above`,createLayoutEngine(`above`)),this._engines.set(`below`,createLayoutEngine(`below`)),this._engines.set(`near`,createLayoutEngine(`near`)),this._engines.set(`nth-match`,nthMatchEngine);let T=[...this._engines.keys()];T.sort();let E=[...customCSSNames];if(E.sort(),T.join(`|`)!==E.join(`|`))throw Error(`Please keep customCSSNames in sync with evaluator engines: ${T.join(`|`)} vs ${E.join(`|`)}`)}begin(){++this._retainCacheCounter}end(){--this._retainCacheCounter,this._retainCacheCounter||(this._cacheQueryCSS.clear(),this._cacheMatches.clear(),this._cacheQuery.clear(),this._cacheMatchesSimple.clear(),this._cacheMatchesParents.clear(),this._cacheCallMatches.clear(),this._cacheCallQuery.clear(),this._cacheQuerySimple.clear(),this._cacheText.clear())}_cached(e,T,E,D){e.has(T)||e.set(T,[]);let O=e.get(T),k=O.find(e=>E.every((T,E)=>e.rest[E]===T));if(k)return k.result;let A=D();return O.push({rest:E,result:A}),A}_checkSelector(e){if(!(typeof e==`object`&&e&&(Array.isArray(e)||`simples`in e&&e.simples.length)))throw Error(`Malformed selector "${e}"`);return e}matches(e,T,E){let D=this._checkSelector(T);this.begin();try{return this._cached(this._cacheMatches,e,[D,E.scope,E.pierceShadow,E.originalScope],()=>Array.isArray(D)?this._matchesEngine(isEngine,e,D,E):(this._hasScopeClause(D)&&(E=this._expandContextForScopeMatching(E)),this._matchesSimple(e,D.simples[D.simples.length-1].selector,E)?this._matchesParents(e,D,D.simples.length-2,E):!1))}finally{this.end()}}query(e,T){let E=this._checkSelector(T);this.begin();try{return this._cached(this._cacheQuery,E,[e.scope,e.pierceShadow,e.originalScope],()=>{if(Array.isArray(E))return this._queryEngine(isEngine,e,E);this._hasScopeClause(E)&&(e=this._expandContextForScopeMatching(e));let T=this._scoreMap;this._scoreMap=new Map;let D=this._querySimple(e,E.simples[E.simples.length-1].selector);return D=D.filter(T=>this._matchesParents(T,E,E.simples.length-2,e)),this._scoreMap.size&&D.sort((e,T)=>{let E=this._scoreMap.get(e),D=this._scoreMap.get(T);return E===D?0:E===void 0?1:D===void 0?-1:E-D}),this._scoreMap=T,D})}finally{this.end()}}_markScore(e,T){this._scoreMap&&this._scoreMap.set(e,T)}_hasScopeClause(e){return e.simples.some(e=>e.selector.functions.some(e=>e.name===`scope`))}_expandContextForScopeMatching(e){if(e.scope.nodeType!==1)return e;let T=parentElementOrShadowHost(e.scope);return T?{...e,scope:T,originalScope:e.originalScope||e.scope}:e}_matchesSimple(e,T,E){return this._cached(this._cacheMatchesSimple,e,[T,E.scope,E.pierceShadow,E.originalScope],()=>{if(e===E.scope||T.css&&!this._matchesCSS(e,T.css))return!1;for(let D of T.functions)if(!this._matchesEngine(this._getEngine(D.name),e,D.args,E))return!1;return!0})}_querySimple(e,T){return T.functions.length?this._cached(this._cacheQuerySimple,T,[e.scope,e.pierceShadow,e.originalScope],()=>{let E=T.css,D=T.functions;E===`*`&&D.length&&(E=void 0);let O,k=-1;E===void 0?(k=D.findIndex(e=>this._getEngine(e.name).query!==void 0),k===-1&&(k=0),O=this._queryEngine(this._getEngine(D[k].name),e,D[k].args)):O=this._queryCSS(e,E);for(let T=0;T<D.length;T++){if(T===k)continue;let E=this._getEngine(D[T].name);E.matches!==void 0&&(O=O.filter(O=>this._matchesEngine(E,O,D[T].args,e)))}for(let T=0;T<D.length;T++){if(T===k)continue;let E=this._getEngine(D[T].name);E.matches===void 0&&(O=O.filter(O=>this._matchesEngine(E,O,D[T].args,e)))}return O}):this._queryCSS(e,T.css||`*`)}_matchesParents(e,T,E,D){return E<0?!0:this._cached(this._cacheMatchesParents,e,[T,E,D.scope,D.pierceShadow,D.originalScope],()=>{let{selector:O,combinator:k}=T.simples[E];if(k===`>`){let k=parentElementOrShadowHostInContext(e,D);return!k||!this._matchesSimple(k,O,D)?!1:this._matchesParents(k,T,E-1,D)}if(k===`+`){let k=previousSiblingInContext(e,D);return!k||!this._matchesSimple(k,O,D)?!1:this._matchesParents(k,T,E-1,D)}if(k===``){let k=parentElementOrShadowHostInContext(e,D);for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===``)break}k=parentElementOrShadowHostInContext(k,D)}return!1}if(k===`~`){let k=previousSiblingInContext(e,D);for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===`~`)break}k=previousSiblingInContext(k,D)}return!1}if(k===`>=`){let k=e;for(;k;){if(this._matchesSimple(k,O,D)){if(this._matchesParents(k,T,E-1,D))return!0;if(T.simples[E-1].combinator===``)break}k=parentElementOrShadowHostInContext(k,D)}return!1}throw Error(`Unsupported combinator "${k}"`)})}_matchesEngine(e,T,E,D){if(e.matches)return this._callMatches(e,T,E,D);if(e.query)return this._callQuery(e,E,D).includes(T);throw Error(`Selector engine should implement "matches" or "query"`)}_queryEngine(e,T,E){if(e.query)return this._callQuery(e,E,T);if(e.matches)return this._queryCSS(T,`*`).filter(D=>this._callMatches(e,D,E,T));throw Error(`Selector engine should implement "matches" or "query"`)}_callMatches(e,T,E,D){return this._cached(this._cacheCallMatches,T,[e,D.scope,D.pierceShadow,D.originalScope,...E],()=>e.matches(T,E,D,this))}_callQuery(e,T,E){return this._cached(this._cacheCallQuery,e,[E.scope,E.pierceShadow,E.originalScope,...T],()=>e.query(E,T,this))}_matchesCSS(e,T){return e.matches(T)}_queryCSS(e,T){return this._cached(this._cacheQueryCSS,T,[e.scope,e.pierceShadow,e.originalScope],()=>{let E=[];function D(O){if(E=E.concat([...O.querySelectorAll(T)]),e.pierceShadow){O.shadowRoot&&D(O.shadowRoot);for(let e of O.querySelectorAll(`*`))e.shadowRoot&&D(e.shadowRoot)}}return D(e.scope),E})}_getEngine(e){let T=this._engines.get(e);if(!T)throw Error(`Unknown selector engine "${e}"`);return T}},isEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"is" engine expects non-empty selector list`);return T.some(T=>D.matches(e,T,E))},query(e,T,E){if(T.length===0)throw Error(`"is" engine expects non-empty selector list`);let D=[];for(let O of T)D=D.concat(E.query(e,O));return T.length===1?D:sortInDOMOrder(D)}},hasEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"has" engine expects non-empty selector list`);return D.query({...E,scope:e},T).length>0}},scopeEngine={matches(e,T,E,D){if(T.length!==0)throw Error(`"scope" engine expects no arguments`);let O=E.originalScope||E.scope;return O.nodeType===9?e===O.documentElement:e===O},query(e,T,E){if(T.length!==0)throw Error(`"scope" engine expects no arguments`);let D=e.originalScope||e.scope;if(D.nodeType===9){let e=D.documentElement;return e?[e]:[]}return D.nodeType===1?[D]:[]}},notEngine={matches(e,T,E,D){if(T.length===0)throw Error(`"not" engine expects non-empty selector list`);return!D.matches(e,T,E)}},lightEngine={query(e,T,E){return E.query({...e,pierceShadow:!1},T)},matches(e,T,E,D){return D.matches(e,T,{...E,pierceShadow:!1})}},visibleEngine={matches(e,T,E,D){if(T.length)throw Error(`"visible" engine expects no arguments`);return isElementVisible(e)}},textEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"text" engine expects a single string`);let O=normalizeWhiteSpace(T[0]).toLowerCase();return elementMatchesText(D._cacheText,e,e=>e.normalized.toLowerCase().includes(O))===`self`}},textIsEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let O=normalizeWhiteSpace(T[0]);return elementMatchesText(D._cacheText,e,e=>!O&&!e.immediate.length?!0:e.immediate.some(e=>normalizeWhiteSpace(e)===O))!==`none`}},textMatchesEngine={matches(e,T,E,D){if(T.length===0||typeof T[0]!=`string`||T.length>2||T.length===2&&typeof T[1]!=`string`)throw Error(`"text-matches" engine expects a regexp body and optional regexp flags`);let O=new RegExp(T[0],T.length===2?T[1]:void 0);return elementMatchesText(D._cacheText,e,e=>O.test(e.full))===`self`}},hasTextEngine={matches(e,T,E,D){if(T.length!==1||typeof T[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(shouldSkipForTextMatching(e))return!1;let O=normalizeWhiteSpace(T[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(O))(elementText(D._cacheText,e))}};function createLayoutEngine(e){return{matches(T,E,D,O){let k=E.length&&typeof E[E.length-1]==`number`?E[E.length-1]:void 0,A=k===void 0?E:E.slice(0,E.length-1);if(E.length<1+(k===void 0?0:1))throw Error(`"${e}" engine expects a selector list and optional maximum distance in pixels`);let j=layoutSelectorScore(e,T,O.query(D,A),k);return j===void 0?!1:(O._markScore(T,j),!0)}}}var nthMatchEngine={query(e,T,E){let D=T[T.length-1];if(T.length<2)throw Error(`"nth-match" engine expects non-empty selector list and an index argument`);if(typeof D!=`number`||D<1)throw Error(`"nth-match" engine expects a one-based index as the last argument`);let O=isEngine.query(e,T.slice(0,T.length-1),E);return D--,D<O.length?[O[D]]:[]}};function parentElementOrShadowHostInContext(e,T){if(e!==T.scope)return T.pierceShadow?parentElementOrShadowHost(e):e.parentElement||void 0}function previousSiblingInContext(e,T){if(e!==T.scope)return e.previousElementSibling||void 0}function sortInDOMOrder(e){let T=new Map,E=[],D=[];function O(e){let D=T.get(e);if(D)return D;let k=parentElementOrShadowHost(e);return k?O(k).children.push(e):E.push(e),D={children:[],taken:!1},T.set(e,D),D}for(let T of e)O(T).taken=!0;function k(e){let E=T.get(e);if(E.taken&&D.push(e),E.children.length>1){let T=new Set(E.children);E.children=[];let D=e.firstElementChild;for(;D&&E.children.length<T.size;)T.has(D)&&E.children.push(D),D=D.nextElementSibling;for(D=e.shadowRoot?e.shadowRoot.firstElementChild:null;D&&E.children.length<T.size;)T.has(D)&&E.children.push(D),D=D.nextElementSibling}E.children.forEach(k)}return E.forEach(k),D}function getByAttributeTextSelector(e,T,E){return`internal:attr=[${e}=${escapeForAttributeSelector(T,E?.exact||!1)}]`}function getByTestIdSelector(e,T){return`internal:testid=[${e}=${escapeForAttributeSelector(T,!0)}]`}function getByLabelSelector(e,T){return`internal:label=${escapeForTextSelector$1(e,!!T?.exact)}`}function getByAltTextSelector(e,T){return getByAttributeTextSelector(`alt`,e,T)}function getByTitleSelector(e,T){return getByAttributeTextSelector(`title`,e,T)}function getByPlaceholderSelector(e,T){return getByAttributeTextSelector(`placeholder`,e,T)}function getByTextSelector(e,T){return`internal:text=${escapeForTextSelector$1(e,!!T?.exact)}`}function getByRoleSelector(e,T={}){let E=[];return T.checked!==void 0&&E.push([`checked`,String(T.checked)]),T.disabled!==void 0&&E.push([`disabled`,String(T.disabled)]),T.selected!==void 0&&E.push([`selected`,String(T.selected)]),T.expanded!==void 0&&E.push([`expanded`,String(T.expanded)]),T.includeHidden!==void 0&&E.push([`include-hidden`,String(T.includeHidden)]),T.level!==void 0&&E.push([`level`,String(T.level)]),T.name!==void 0&&E.push([`name`,escapeForAttributeSelector(T.name,!!T.exact)]),T.pressed!==void 0&&E.push([`pressed`,String(T.pressed)]),`internal:role=${e}${E.map(([e,T])=>`[${e}=${T}]`).join(``)}`}var _Ivya=class e{constructor(){__publicField(this,`_engines`),__publicField(this,`_evaluator`),this._evaluator=new SelectorEvaluatorImpl(new Map),this._engines=new Map,this._engines.set(`xpath`,XPathEngine),this._engines.set(`xpath:light`,XPathEngine),this._engines.set(`role`,createRoleEngine(!1)),this._engines.set(`text`,this._createTextEngine(!0,!1)),this._engines.set(`text:light`,this._createTextEngine(!1,!1)),this._engines.set(`id`,this._createAttributeEngine(`id`,!0)),this._engines.set(`id:light`,this._createAttributeEngine(`id`,!1)),this._engines.set(`data-testid`,this._createAttributeEngine(`data-testid`,!0)),this._engines.set(`data-testid:light`,this._createAttributeEngine(`data-testid`,!1)),this._engines.set(`data-test-id`,this._createAttributeEngine(`data-test-id`,!0)),this._engines.set(`data-test-id:light`,this._createAttributeEngine(`data-test-id`,!1)),this._engines.set(`data-test`,this._createAttributeEngine(`data-test`,!0)),this._engines.set(`data-test:light`,this._createAttributeEngine(`data-test`,!1)),this._engines.set(`css`,this._createCSSEngine()),this._engines.set(`nth`,{queryAll:()=>[]}),this._engines.set(`visible`,this._createVisibleEngine()),this._engines.set(`internal:control`,this._createControlEngine()),this._engines.set(`internal:has`,this._createHasEngine()),this._engines.set(`internal:has-not`,this._createHasNotEngine()),this._engines.set(`internal:and`,{queryAll:()=>[]}),this._engines.set(`internal:or`,{queryAll:()=>[]}),this._engines.set(`internal:chain`,this._createInternalChainEngine()),this._engines.set(`internal:label`,this._createInternalLabelEngine()),this._engines.set(`internal:text`,this._createTextEngine(!0,!0)),this._engines.set(`internal:has-text`,this._createInternalHasTextEngine()),this._engines.set(`internal:has-not-text`,this._createInternalHasNotTextEngine()),this._engines.set(`internal:attr`,this._createNamedAttributeEngine()),this._engines.set(`internal:testid`,this._createNamedAttributeEngine()),this._engines.set(`internal:role`,createRoleEngine(!0))}static create(T){return Object.assign(e.options,T),e.singleton||=new e}queryLocatorSelector(e,T=document.documentElement,E=!0){return this.querySelector(this.parseSelector(e),T,E)}queryLocatorSelectorAll(e,T=document.documentElement){return this.querySelectorAll(this.parseSelector(e),T)}querySelector(e,T,E=!0){let D=this.querySelectorAll(e,T);if(E&&D.length>1)throw this.strictModeViolationError(e,D);return D[0]||null}queryAllByRole(e,T,E=document.documentElement){let D=this.parseSelector(getByRoleSelector(e,T));return this.querySelectorAll(D,E)}queryAllByLabelText(e,T,E=document.documentElement){let D=this.parseSelector(getByLabelSelector(e,T));return this.querySelectorAll(D,E)}queryAllByTestId(T,E=document.documentElement){let D=this.parseSelector(getByTestIdSelector(e.options.testIdAttribute,T));return this.querySelectorAll(D,E)}queryAllByText(e,T,E=document.documentElement){let D=this.parseSelector(getByTextSelector(e,T));return this.querySelectorAll(D,E)}queryAllByTitle(e,T,E=document.documentElement){let D=this.parseSelector(getByTitleSelector(e,T));return this.querySelectorAll(D,E)}queryAllByPlaceholder(e,T,E=document.documentElement){let D=this.parseSelector(getByPlaceholderSelector(e,T));return this.querySelectorAll(D,E)}queryAllByAltText(e,T,E=document.documentElement){let D=this.parseSelector(getByAltTextSelector(e,T));return this.querySelectorAll(D,E)}queryByRole(e,T,E=document.documentElement){let D=this.parseSelector(getByRoleSelector(e,T));return this.querySelector(D,E,!1)}queryByLabelText(e,T,E=document.documentElement){let D=this.parseSelector(getByLabelSelector(e,T));return this.querySelector(D,E,!1)}queryByTestId(T,E=document.documentElement){let D=this.parseSelector(getByTestIdSelector(e.options.testIdAttribute,T));return this.querySelector(D,E,!1)}queryByText(e,T,E=document.documentElement){let D=this.parseSelector(getByTextSelector(e,T));return this.querySelector(D,E,!1)}queryByTitle(e,T,E=document.documentElement){let D=this.parseSelector(getByTitleSelector(e,T));return this.querySelector(D,E,!1)}queryByPlaceholder(e,T,E=document.documentElement){let D=this.parseSelector(getByPlaceholderSelector(e,T));return this.querySelector(D,E,!1)}queryByAltText(e,T,E=document.documentElement){let D=this.parseSelector(getByAltTextSelector(e,T));return this.querySelector(D,E,!1)}strictModeViolationError(e,T){let E=T.slice(0,10).map(e=>({preview:this.previewNode(e),selector:this.generateSelectorSimple(e)})),D=E.map((e,T)=>`
|
|
4
4
|
${T+1}) ${e.preview} aka ${asLocator(`javascript`,e.selector)}`);return E.length<T.length&&D.push(`
|
|
5
5
|
...`),this.createStacklessError(`strict mode violation: ${asLocator(`javascript`,stringifySelector(e))} resolved to ${T.length} elements:${D.join(``)}
|
|
6
|
-
`)}generateSelectorSimple(T,E){return generateSelector(this,T,{...E,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let T=parseSelector(e);return visitAllSelectorParts(T,T=>{if(!this._engines.has(T.name))throw this.createStacklessError(`Unknown engine "${T.name}" while parsing selector ${e}`)}),T}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return oneLine(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return oneLine(`<${e.nodeName.toLowerCase()} />`);let T=e,E=[];for(let e=0;e<T.attributes.length;e++){let{name:D,value:O}=T.attributes[e];D!==`style`&&(!O&&booleanAttributes.has(D)?E.push(` ${D}`):E.push(` ${D}="${O}"`))}E.sort((e,T)=>e.length-T.length);let D=trimStringWithEllipsis(E.join(``),500);if(autoClosingTags.has(T.nodeName))return oneLine(`<${T.nodeName.toLowerCase()}${D}/>`);let O=T.childNodes,k=!1;if(O.length<=5){k=!0;for(let e=0;e<O.length;e++)k&&=O[e].nodeType===Node.TEXT_NODE}let A=k?T.textContent||``:O.length?`…`:``;return oneLine(`<${T.nodeName.toLowerCase()}${D}>${trimStringWithEllipsis(A,50)}</${T.nodeName.toLowerCase()}>`)}querySelectorAll(e,T){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let E={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let T={parts:e.parts.slice(e.capture+1)},D={name:`internal:has`,body:{parsed:T},source:stringifySelector(T)};E.parts.push(D)}return this.querySelectorAll(E,T)}if(!T.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(T.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[T];this._evaluator.begin();try{let E=new Set([T]);for(let D of e.parts)if(D.name===`nth`)E=this._queryNth(E,D);else if(D.name===`internal:and`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(e.filter(e=>E.has(e)))}else if(D.name===`internal:or`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(sortInDOMOrder(new Set([...E,...e])))}else if(kLayoutSelectorNames.includes(D.name))E=this._queryLayoutSelector(E,D,T);else{let e=new Set;for(let T of E){let E=this._queryEngineAll(D,T);for(let T of E)e.add(T)}E=e}return[...E]}finally{this._evaluator.end()}}_queryEngineAll(e,T){let E=this._engines.get(e.name).queryAll(T,e.body);for(let e of E)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return E}_queryNth(e,T){let E=[...e],D=+T.body;return D===-1&&(D=E.length-1),new Set(E.slice(D,D+1))}_queryLayoutSelector(e,T,E){let D=T.name,O=T.body,k=[],A=this.querySelectorAll(O.parsed,E);for(let T of e){let e=layoutSelectorScore(D,T,A,O.distance);e!==void 0&&k.push({element:T,score:e})}return k.sort((e,T)=>e.score-T.score),new Set(k.map(e=>e.element))}createStacklessError(T){if(e.options.browser===`firefox`){let e=Error(`Error: ${T}`);return e.stack=``,e}let E=Error(T);return delete E.stack,E}_createTextEngine(e,T){return{queryAll:(E,D)=>{let{matcher:O,kind:k}=createTextMatcher(D,T),A=[],j=null,M=e=>{if(k===`lax`&&j&&j.contains(e))return!1;let E=elementMatchesText(this._evaluator._cacheText,e,O);E===`none`&&(j=e),(E===`self`||E===`selfAndChildren`&&k===`strict`&&!T)&&A.push(e)};E.nodeType===Node.ELEMENT_NODE&&M(E);let N=this._evaluator._queryCSS({scope:E,pierceShadow:e},`*`);for(let e of N)M(e);return A}}}_createAttributeEngine(e,T){let E=T=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(T)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,D)=>this._evaluator.query({scope:e,pierceShadow:T},E(D))}}_createCSSEngine(){return{queryAll:(e,T)=>this._evaluator.query({scope:e,pierceShadow:!0},T)}}_createNamedAttributeEngine(){return{queryAll:(e,T)=>{let E=parseAttributeSelector(T);if(E.name||E.attributes.length!==1)throw Error(`Malformed attribute selector: ${T}`);let{name:D,value:O,caseSensitive:k}=E.attributes[0],A=k?null:O.toLowerCase(),j;return j=O instanceof RegExp?e=>!!e.match(O):k?e=>e===O:e=>e.toLowerCase().includes(A),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${D}]`).filter(e=>j(e.getAttribute(D)))}}}_createVisibleEngine(){return{queryAll:(e,T)=>e.nodeType===1&&isElementVisible(e)===!!T?[e]:[]}}_createControlEngine(){return{queryAll:(e,T)=>{if(T===`enter-frame`&&e instanceof HTMLIFrameElement){let T=e.contentDocument?.documentElement;return T?[T]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,T)=>e.nodeType===1&&this.querySelector(T.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,T)=>e.nodeType===1?this.querySelector(T.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,T)=>this.querySelectorAll(T.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,T)=>{let{matcher:E}=createTextMatcher(T,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>getElementLabels(this._evaluator._cacheText,e).some(e=>E(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[E]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[]:[E]}}}};__publicField(_Ivya,`options`,{testIdAttribute:`data-testid`,browser:`chromium`}),__publicField(_Ivya,`singleton`,null);var Ivya=_Ivya;function oneLine(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}var booleanAttributes=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),autoClosingTags=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function cssUnquote(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let T=[],E=0;for(;E<e.length;)e[E]===`\\`&&E+1<e.length&&E++,T.push(e[E++]);return T.join(``)}function createTextMatcher(e,T){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let T=e.lastIndexOf(`/`),E=new RegExp(e.substring(1,T),e.substring(T+1));return{matcher:e=>E.test(e.full),kind:`regex`}}let E=T?JSON.parse.bind(JSON):cssUnquote,D=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=E(e),D=!0):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=E(e.substring(0,e.length-1)),D=!1):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=E(e.substring(0,e.length-1)),D=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=E(e),D=!0),e=normalizeWhiteSpace(e),D?T?{kind:`strict`,matcher:T=>T.normalized===e}:{matcher:T=>!e&&!T.immediate.length?!0:T.immediate.some(T=>normalizeWhiteSpace(T)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:T=>T.normalized.toLowerCase().includes(e)})}var XPathEngine={queryAll(e,T){T.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(T=`.${T}`);let E=[],D=e.ownerDocument||e;if(!D)return E;let O=D.evaluate(T,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=O.iterateNext();e;e=O.iterateNext())e.nodeType===Node.ELEMENT_NODE&&E.push(e);return E}};function parentElementOrShadowHost(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function enclosingShadowRootOrDocument(e){let T=e;for(;T.parentNode;)T=T.parentNode;if(T.nodeType===11||T.nodeType===9)return T}function enclosingShadowHost(e){for(;e.parentElement;)e=e.parentElement;return parentElementOrShadowHost(e)}function closestCrossShadow(e,T){for(;e;){let E=e.closest(T);if(E)return E;e=enclosingShadowHost(e)}}function getElementComputedStyle(e,T){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,T):void 0}function isElementStyleVisibilityVisible(e,T){if(T??=getElementComputedStyle(e),!T)return!0;if(Element.prototype.checkVisibility&&Ivya.options.browser!==`webkit`){if(!e.checkVisibility())return!1}else{let T=e.closest(`details,summary`);if(T!==e&&T?.nodeName===`DETAILS`&&!T.open)return!1}return T.visibility===`visible`}function isElementVisible(e){let T=getElementComputedStyle(e);if(!T)return!0;if(T.display===`contents`){for(let T=e.firstChild;T;T=T.nextSibling)if(T.nodeType===1&&isElementVisible(T)||T.nodeType===3&&isVisibleTextNode(T))return!0;return!1}if(!isElementStyleVisibilityVisible(e,T))return!1;let E=e.getBoundingClientRect();return E.width>0&&E.height>0}function isVisibleTextNode(e){let T=e.ownerDocument.createRange();T.selectNode(e);let E=T.getBoundingClientRect();return E.width>0&&E.height>0}function elementSafeTagName(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function ensureAwaited(e){let T=getWorkerState().current;if(!T||T.type!==`test`)return e();let E=!1,D=Error(`STACK_TRACE_ERROR`);T.onFinished??=[],T.onFinished.push(()=>{if(!E){let e=Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);throw e.stack=D.stack?.replace(D.message,e.message),e}});let O;return{then(T,k){return E=!0,(O||=e(D)).then(T,k)},catch(T){return(O||=e(D)).catch(T)},finally(T){return(O||=e(D)).finally(T)},[Symbol.toStringTag]:`Promise`}}function getBrowserState(){return window.__vitest_browser_runner__}function getWorkerState(){let e=window.__vitest_worker__;if(!e)throw Error(`Worker state is not found. This is an issue with Vitest. Please, open an issue.`);return e}const provider=getBrowserState().provider;function convertElementToCssSelector(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return getUniqueCssSelector(e)}function escapeIdForCSSSelector(e){return e.split(``).map(e=>{let T=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:T>=65536?`\\${T.toString(16).toUpperCase().padStart(6,`0`)} `:T<32||T===127||T>=128?`\\${T.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function getUniqueCssSelector(e){let T=[],E,D=!1;for(;E=getParent(e);){E.shadowRoot&&(D=!0);let O=e.tagName;if(e.id)T.push(`#${escapeIdForCSSSelector(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)T.push(O.toLowerCase());else{let D=0,k=0,A=0;for(let T of E.children)D++,T.tagName===O&&k++,T===e&&(A=D);k>1?T.push(`${O.toLowerCase()}:nth-child(${A})`):T.push(O.toLowerCase())}e=E}return`${getBrowserState().provider===`webdriverio`&&D?`>>>`:``}${T.reverse().join(` > `)}`}function getParent(e){let T=e.parentNode;return T instanceof ShadowRoot?T.host:T}const now=Date.now;function processTimeoutOptions(e){if(e&&e.timeout!=null||provider!==`playwright`||getWorkerState().config.browser.providerOptions.actionTimeout!=null)return e;let T=getBrowserState().runner,E=T._currentTaskStartTime;if(!E)return e;let D=T._currentTaskTimeout;if(D===0||D==null||D===1/0)return e;e||={};let O=now(),k=E+D-O;return k<=0||(e.timeout=k-100),e}function getIframeScale(){let e=window.parent.document.querySelector(`iframe[data-vitest]`)?.parentElement;if(!e)throw Error(`Cannot find Tester element. This is a bug in Vitest. Please, open a new issue with reproduction.`);let T=e.getAttribute(`data-scale`),E=Number(T);if(Number.isNaN(E))throw TypeError(`Cannot parse scale value from Tester element (${T}). This is a bug in Vitest. Please, open a new issue with reproduction.`);return E}function escapeRegexForSelector(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function escapeForTextSelector(e,T){return typeof e==`string`?`${JSON.stringify(e)}i`:escapeRegexForSelector(e)}function convertToSelector(e){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element)return convertElementToCssSelector(e);if(isLocator(e))return e.selector;throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const kLocator$1=Symbol.for(`$$vitest:locator`);function isLocator(e){return!!e&&typeof e==`object`&&kLocator$1 in e}__INTERNAL._asLocator=asLocator;const selectorEngine=Ivya.create({browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(server.config.browser.name),testIdAttribute:server.config.browser.locators.testIdAttribute}),kLocator=Symbol.for(`$$vitest:locator`);class Locator{_parsedSelector;_container;_pwSelector;constructor(){Object.defineProperty(this,kLocator,{enumerable:!1,writable:!1,configurable:!1,value:kLocator})}click(e){return this.triggerCommand(`__vitest_click`,this.selector,e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.selector,e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.selector,e)}clear(e){return this.triggerCommand(`__vitest_clear`,this.selector,e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.selector,e)}unhover(e){return this.triggerCommand(`__vitest_hover`,`html > body`,e)}fill(e,T){return this.triggerCommand(`__vitest_fill`,this.selector,e,T)}async upload(e,T){let E=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let T=await new Promise((T,E)=>{let D=new FileReader;D.onload=()=>T(D.result),D.onerror=()=>E(Error(`Failed to read file: ${e.name}`)),D.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:T}});return this.triggerCommand(`__vitest_upload`,this.selector,await Promise.all(E),T)}dropTo(e,T={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.selector,e.selector,T)}selectOptions(e,T){let E=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:isLocator(e)?e.selector:selectorEngine.generateSelectorSimple(e)});return this.triggerCommand(`__vitest_selectOptions`,this.selector,E,T)}screenshot(e){return page.screenshot({...e,element:this})}getByRole(e,T){return this.locator(getByRoleSelector(e,T))}getByAltText(e,T){return this.locator(getByAltTextSelector(e,T))}getByLabelText(e,T){return this.locator(getByLabelSelector(e,T))}getByPlaceholder(e,T){return this.locator(getByPlaceholderSelector(e,T))}getByTestId(T){return this.locator(getByTestIdSelector(server.config.browser.locators.testIdAttribute,T))}getByText(e,T){return this.locator(getByTextSelector(e,T))}getByTitle(e,T){return this.locator(getByTitleSelector(e,T))}filter(e){let T=[];if(e?.hasText&&T.push(`internal:has-text=${escapeForTextSelector(e.hasText)}`),e?.hasNotText&&T.push(`internal:has-not-text=${escapeForTextSelector(e.hasNotText)}`),e?.has){let E=e.has;T.push(`internal:has=${JSON.stringify(E._pwSelector||E.selector)}`)}if(e?.hasNot){let E=e.hasNot;T.push(`internal:has-not=${JSON.stringify(E._pwSelector||E.selector)}`)}if(!T.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(T.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw utils.getElementError(this._pwSelector||this.selector,this._container||document.body);return e}elements(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}toJSON(){return this.selector}triggerCommand(e,...T){let E=getBrowserState().commands;return ensureAwaited(D=>E.triggerCommand(e,T,D))}}export{Locator as L,getAriaRole as a,getAriaDisabled as b,beginAriaCaches as c,getElementAccessibleDescription as d,endAriaCaches as e,getElementAccessibleErrorMessage as f,getAriaChecked as g,getElementAccessibleName as h,isElementVisible as i,cssEscape as j,kAriaCheckedRoles as k,getWorkerState as l,convertToSelector as m,getBrowserState as n,convertElementToCssSelector as o,processTimeoutOptions as p,getIframeScale as q,getByAltTextSelector as r,selectorEngine as s,getByLabelSelector as t,getByPlaceholderSelector as u,getByRoleSelector as v,getByTestIdSelector as w,getByTextSelector as x,getByTitleSelector as y};
|
|
6
|
+
`)}generateSelectorSimple(T,E){return generateSelector(this,T,{...E,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let T=parseSelector(e);return visitAllSelectorParts(T,T=>{if(!this._engines.has(T.name))throw this.createStacklessError(`Unknown engine "${T.name}" while parsing selector ${e}`)}),T}previewNode(e){if(e.nodeType===Node.TEXT_NODE)return oneLine(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return oneLine(`<${e.nodeName.toLowerCase()} />`);let T=e,E=[];for(let e=0;e<T.attributes.length;e++){let{name:D,value:O}=T.attributes[e];D!==`style`&&(!O&&booleanAttributes.has(D)?E.push(` ${D}`):E.push(` ${D}="${O}"`))}E.sort((e,T)=>e.length-T.length);let D=trimStringWithEllipsis(E.join(``),500);if(autoClosingTags.has(T.nodeName))return oneLine(`<${T.nodeName.toLowerCase()}${D}/>`);let O=T.childNodes,k=!1;if(O.length<=5){k=!0;for(let e=0;e<O.length;e++)k&&=O[e].nodeType===Node.TEXT_NODE}let A=k?T.textContent||``:O.length?`…`:``;return oneLine(`<${T.nodeName.toLowerCase()}${D}>${trimStringWithEllipsis(A,50)}</${T.nodeName.toLowerCase()}>`)}querySelectorAll(e,T){if(e.capture!==void 0){if(e.parts.some(e=>e.name===`nth`))throw this.createStacklessError(`Can't query n-th element in a request with the capture.`);let E={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let T={parts:e.parts.slice(e.capture+1)},D={name:`internal:has`,body:{parsed:T},source:stringifySelector(T)};E.parts.push(D)}return this.querySelectorAll(E,T)}if(!T.querySelectorAll)throw this.createStacklessError(`Node is not queryable.`);if(e.capture!==void 0)throw this.createStacklessError(`Internal error: there should not be a capture in the selector.`);if(T.nodeType===11&&e.parts.length===1&&e.parts[0].name===`css`&&e.parts[0].source===`:scope`)return[T];this._evaluator.begin();try{let E=new Set([T]);for(let D of e.parts)if(D.name===`nth`)E=this._queryNth(E,D);else if(D.name===`internal:and`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(e.filter(e=>E.has(e)))}else if(D.name===`internal:or`){let e=this.querySelectorAll(D.body.parsed,T);E=new Set(sortInDOMOrder(new Set([...E,...e])))}else if(kLayoutSelectorNames.includes(D.name))E=this._queryLayoutSelector(E,D,T);else{let e=new Set;for(let T of E){let E=this._queryEngineAll(D,T);for(let T of E)e.add(T)}E=e}return[...E]}finally{this._evaluator.end()}}_queryEngineAll(e,T){let E=this._engines.get(e.name).queryAll(T,e.body);for(let e of E)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return E}_queryNth(e,T){let E=[...e],D=+T.body;return D===-1&&(D=E.length-1),new Set(E.slice(D,D+1))}_queryLayoutSelector(e,T,E){let D=T.name,O=T.body,k=[],A=this.querySelectorAll(O.parsed,E);for(let T of e){let e=layoutSelectorScore(D,T,A,O.distance);e!==void 0&&k.push({element:T,score:e})}return k.sort((e,T)=>e.score-T.score),new Set(k.map(e=>e.element))}createStacklessError(T){if(e.options.browser===`firefox`){let e=Error(`Error: ${T}`);return e.stack=``,e}let E=Error(T);return delete E.stack,E}_createTextEngine(e,T){return{queryAll:(E,D)=>{let{matcher:O,kind:k}=createTextMatcher(D,T),A=[],j=null,M=e=>{if(k===`lax`&&j&&j.contains(e))return!1;let E=elementMatchesText(this._evaluator._cacheText,e,O);E===`none`&&(j=e),(E===`self`||E===`selfAndChildren`&&k===`strict`&&!T)&&A.push(e)};E.nodeType===Node.ELEMENT_NODE&&M(E);let N=this._evaluator._queryCSS({scope:E,pierceShadow:e},`*`);for(let e of N)M(e);return A}}}_createAttributeEngine(e,T){let E=T=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(T)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,D)=>this._evaluator.query({scope:e,pierceShadow:T},E(D))}}_createCSSEngine(){return{queryAll:(e,T)=>this._evaluator.query({scope:e,pierceShadow:!0},T)}}_createNamedAttributeEngine(){return{queryAll:(e,T)=>{let E=parseAttributeSelector(T);if(E.name||E.attributes.length!==1)throw Error(`Malformed attribute selector: ${T}`);let{name:D,value:O,caseSensitive:k}=E.attributes[0],A=k?null:O.toLowerCase(),j;return j=O instanceof RegExp?e=>!!e.match(O):k?e=>e===O:e=>e.toLowerCase().includes(A),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${D}]`).filter(e=>j(e.getAttribute(D)))}}}_createVisibleEngine(){return{queryAll:(e,T)=>e.nodeType===1&&isElementVisible(e)===!!T?[e]:[]}}_createControlEngine(){return{queryAll:(e,T)=>{if(T===`enter-frame`&&e instanceof HTMLIFrameElement){let T=e.contentDocument?.documentElement;return T?[T]:[]}return[]}}}_createHasEngine(){return{queryAll:(e,T)=>e.nodeType===1&&this.querySelector(T.parsed,e,!1)?[e]:[]}}_createHasNotEngine(){return{queryAll:(e,T)=>e.nodeType===1?this.querySelector(T.parsed,e,!1)?[]:[e]:[]}}_createInternalChainEngine(){return{queryAll:(e,T)=>this.querySelectorAll(T.parsed,e)}}_createInternalLabelEngine(){return{queryAll:(e,T)=>{let{matcher:E}=createTextMatcher(T,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>getElementLabels(this._evaluator._cacheText,e).some(e=>E(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[E]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,T)=>{if(e.nodeType!==1)return[];let E=e,D=elementText(this._evaluator._cacheText,E),{matcher:O}=createTextMatcher(T,!0);return O(D)?[]:[E]}}}};__publicField(_Ivya,`options`,{testIdAttribute:`data-testid`,browser:`chromium`}),__publicField(_Ivya,`singleton`,null);var Ivya=_Ivya;function oneLine(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}var booleanAttributes=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),autoClosingTags=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function cssUnquote(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let T=[],E=0;for(;E<e.length;)e[E]===`\\`&&E+1<e.length&&E++,T.push(e[E++]);return T.join(``)}function createTextMatcher(e,T){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let T=e.lastIndexOf(`/`),E=new RegExp(e.substring(1,T),e.substring(T+1));return{matcher:e=>E.test(e.full),kind:`regex`}}let E=T?JSON.parse.bind(JSON):cssUnquote,D=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=E(e),D=!0):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=E(e.substring(0,e.length-1)),D=!1):T&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=E(e.substring(0,e.length-1)),D=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=E(e),D=!0),e=normalizeWhiteSpace(e),D?T?{kind:`strict`,matcher:T=>T.normalized===e}:{matcher:T=>!e&&!T.immediate.length?!0:T.immediate.some(T=>normalizeWhiteSpace(T)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:T=>T.normalized.toLowerCase().includes(e)})}var XPathEngine={queryAll(e,T){T.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(T=`.${T}`);let E=[],D=e.ownerDocument||e;if(!D)return E;let O=D.evaluate(T,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=O.iterateNext();e;e=O.iterateNext())e.nodeType===Node.ELEMENT_NODE&&E.push(e);return E}};function parentElementOrShadowHost(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function enclosingShadowRootOrDocument(e){let T=e;for(;T.parentNode;)T=T.parentNode;if(T.nodeType===11||T.nodeType===9)return T}function enclosingShadowHost(e){for(;e.parentElement;)e=e.parentElement;return parentElementOrShadowHost(e)}function closestCrossShadow(e,T){for(;e;){let E=e.closest(T);if(E)return E;e=enclosingShadowHost(e)}}function getElementComputedStyle(e,T){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,T):void 0}function isElementStyleVisibilityVisible(e,T){if(T??=getElementComputedStyle(e),!T)return!0;if(Element.prototype.checkVisibility&&Ivya.options.browser!==`webkit`){if(!e.checkVisibility())return!1}else{let T=e.closest(`details,summary`);if(T!==e&&T?.nodeName===`DETAILS`&&!T.open)return!1}return T.visibility===`visible`}function isElementVisible(e){let T=getElementComputedStyle(e);if(!T)return!0;if(T.display===`contents`){for(let T=e.firstChild;T;T=T.nextSibling)if(T.nodeType===1&&isElementVisible(T)||T.nodeType===3&&isVisibleTextNode(T))return!0;return!1}if(!isElementStyleVisibilityVisible(e,T))return!1;let E=e.getBoundingClientRect();return E.width>0&&E.height>0}function isVisibleTextNode(e){let T=e.ownerDocument.createRange();T.selectNode(e);let E=T.getBoundingClientRect();return E.width>0&&E.height>0}function elementSafeTagName(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function ensureAwaited(e){let T=getWorkerState().current;if(!T||T.type!==`test`)return e();let E=!1,D=Error(`STACK_TRACE_ERROR`);T.onFinished??=[],T.onFinished.push(()=>{if(!E){let e=Error(`The call was not awaited. This method is asynchronous and must be awaited; otherwise, the call will not start to avoid unhandled rejections.`);throw e.stack=D.stack?.replace(D.message,e.message),e}});let O;return{then(T,k){return E=!0,(O||=e(D)).then(T,k)},catch(T){return(O||=e(D)).catch(T)},finally(T){return(O||=e(D)).finally(T)},[Symbol.toStringTag]:`Promise`}}function getBrowserState(){return window.__vitest_browser_runner__}function getWorkerState(){let e=window.__vitest_worker__;if(!e)throw Error(`Worker state is not found. This is an issue with Vitest. Please, open an issue.`);return e}const provider=getBrowserState().provider;function convertElementToCssSelector(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return getUniqueCssSelector(e)}function escapeIdForCSSSelector(e){return e.split(``).map(e=>{let T=e.charCodeAt(0);return e===` `||e===`#`||e===`.`||e===`:`||e===`[`||e===`]`||e===`>`||e===`+`||e===`~`||e===`\\`?`\\${e}`:T>=65536?`\\${T.toString(16).toUpperCase().padStart(6,`0`)} `:T<32||T===127||T>=128?`\\${T.toString(16).toUpperCase().padStart(2,`0`)} `:e}).join(``)}function getUniqueCssSelector(e){let T=[],E,D=!1;for(;E=getParent(e);){E.shadowRoot&&(D=!0);let O=e.tagName;if(e.id)T.push(`#${escapeIdForCSSSelector(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)T.push(O.toLowerCase());else{let D=0,k=0,A=0;for(let T of E.children)D++,T.tagName===O&&k++,T===e&&(A=D);k>1?T.push(`${O.toLowerCase()}:nth-child(${A})`):T.push(O.toLowerCase())}e=E}return`${getBrowserState().provider===`webdriverio`&&D?`>>>`:``}${T.reverse().join(` > `)}`}function getParent(e){let T=e.parentNode;return T instanceof ShadowRoot?T.host:T}const now=Date.now;function processTimeoutOptions(e){if(e&&e.timeout!=null||provider!==`playwright`||getWorkerState().config.browser.providerOptions.actionTimeout!=null)return e;let T=getBrowserState().runner,E=T._currentTaskStartTime;if(!E)return e;let D=T._currentTaskTimeout;if(D===0||D==null||D===1/0)return e;e||={};let O=now(),k=E+D-O;return k<=0||(e.timeout=k-100),e}function getIframeScale(){let e=window.parent.document.querySelector(`iframe[data-vitest]`)?.parentElement;if(!e)throw Error(`Cannot find Tester element. This is a bug in Vitest. Please, open a new issue with reproduction.`);let T=e.getAttribute(`data-scale`),E=Number(T);if(Number.isNaN(E))throw TypeError(`Cannot parse scale value from Tester element (${T}). This is a bug in Vitest. Please, open a new issue with reproduction.`);return E}function escapeRegexForSelector(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function escapeForTextSelector(e,T){return typeof e==`string`?`${JSON.stringify(e)}i`:escapeRegexForSelector(e)}function convertToSelector(e){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element)return convertElementToCssSelector(e);if(isLocator(e))return e.selector;throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const kLocator$1=Symbol.for(`$$vitest:locator`);function isLocator(e){return!!e&&typeof e==`object`&&kLocator$1 in e}__INTERNAL._asLocator=asLocator;const selectorEngine=Ivya.create({browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(server.config.browser.name),testIdAttribute:server.config.browser.locators.testIdAttribute}),kLocator=Symbol.for(`$$vitest:locator`);class Locator{_parsedSelector;_container;_pwSelector;constructor(){Object.defineProperty(this,kLocator,{enumerable:!1,writable:!1,configurable:!1,value:kLocator})}click(e){return this.triggerCommand(`__vitest_click`,this.selector,e)}dblClick(e){return this.triggerCommand(`__vitest_dblClick`,this.selector,e)}tripleClick(e){return this.triggerCommand(`__vitest_tripleClick`,this.selector,e)}clear(e){return this.triggerCommand(`__vitest_clear`,this.selector,e)}hover(e){return this.triggerCommand(`__vitest_hover`,this.selector,e)}unhover(e){return this.triggerCommand(`__vitest_hover`,`html > body`,e)}fill(e,T){return this.triggerCommand(`__vitest_fill`,this.selector,e,T)}async upload(e,T){let E=(Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let T=await new Promise((T,E)=>{let D=new FileReader;D.onload=()=>T(D.result),D.onerror=()=>E(Error(`Failed to read file: ${e.name}`)),D.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:T}});return this.triggerCommand(`__vitest_upload`,this.selector,await Promise.all(E),T)}dropTo(e,T={}){return this.triggerCommand(`__vitest_dragAndDrop`,this.selector,e.selector,T)}selectOptions(e,T){let E=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:isLocator(e)?e.selector:selectorEngine.generateSelectorSimple(e)});return this.triggerCommand(`__vitest_selectOptions`,this.selector,E,T)}screenshot(e){return page.screenshot({...e,element:this})}getByRole(e,T){return this.locator(getByRoleSelector(e,T))}getByAltText(e,T){return this.locator(getByAltTextSelector(e,T))}getByLabelText(e,T){return this.locator(getByLabelSelector(e,T))}getByPlaceholder(e,T){return this.locator(getByPlaceholderSelector(e,T))}getByTestId(T){return this.locator(getByTestIdSelector(server.config.browser.locators.testIdAttribute,T))}getByText(e,T){return this.locator(getByTextSelector(e,T))}getByTitle(e,T){return this.locator(getByTitleSelector(e,T))}filter(e){let T=[];if(e?.hasText&&T.push(`internal:has-text=${escapeForTextSelector(e.hasText)}`),e?.hasNotText&&T.push(`internal:has-not-text=${escapeForTextSelector(e.hasNotText)}`),e?.has){let E=e.has;T.push(`internal:has=${JSON.stringify(E._pwSelector||E.selector)}`)}if(e?.hasNot){let E=e.hasNot;T.push(`internal:has-not=${JSON.stringify(E._pwSelector||E.selector)}`)}if(!T.length)throw Error(`Locator.filter expects at least one filter. None provided.`);return this.locator(T.join(` >> `))}and(e){return this.locator(`internal:and=${JSON.stringify(e._pwSelector||e.selector)}`)}or(e){return this.locator(`internal:or=${JSON.stringify(e._pwSelector||e.selector)}`)}query(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw utils.getElementError(this._pwSelector||this.selector,this._container||document.body);return e}elements(){let e=this._parsedSelector||=selectorEngine.parseSelector(this._pwSelector||this.selector);return selectorEngine.querySelectorAll(e,document.documentElement)}get length(){return this.elements().length}all(){return this.elements().map(e=>this.elementLocator(e))}nth(e){return this.locator(`nth=${e}`)}first(){return this.nth(0)}last(){return this.nth(-1)}toString(){return this.selector}toJSON(){return this.selector}triggerCommand(e,...T){let E=getBrowserState().commands;return ensureAwaited(D=>E.triggerCommand(e,T,D))}}export{Locator as L,getAriaRole as a,getAriaDisabled as b,beginAriaCaches as c,getElementAccessibleDescription as d,endAriaCaches as e,getElementAccessibleErrorMessage as f,getAriaChecked as g,getElementAccessibleName as h,isElementVisible as i,cssEscape as j,kAriaCheckedRoles as k,convertToSelector as l,getBrowserState as m,convertElementToCssSelector as n,getIframeScale as o,processTimeoutOptions as p,getByAltTextSelector as q,getByLabelSelector as r,selectorEngine as s,getByPlaceholderSelector as t,getByRoleSelector as u,getByTestIdSelector as v,getByTextSelector as w,getByTitleSelector as x};
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { PNG } from 'pngjs';
|
|
|
18
18
|
import pm from 'pixelmatch';
|
|
19
19
|
import { WebSocketServer } from 'ws';
|
|
20
20
|
|
|
21
|
-
var version = "4.0.
|
|
21
|
+
var version = "4.0.14";
|
|
22
22
|
|
|
23
23
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
24
24
|
function normalizeWindowsPath(input = "") {
|
|
@@ -2248,7 +2248,11 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2248
2248
|
if (value === null || value.actual === null) {
|
|
2249
2249
|
return {
|
|
2250
2250
|
pass: false,
|
|
2251
|
-
reference: referenceFile &&
|
|
2251
|
+
reference: referenceFile && {
|
|
2252
|
+
path: paths.reference,
|
|
2253
|
+
width: reference.metadata.width,
|
|
2254
|
+
height: reference.metadata.height
|
|
2255
|
+
},
|
|
2252
2256
|
actual: null,
|
|
2253
2257
|
diff: null,
|
|
2254
2258
|
message: `Could not capture a stable screenshot within ${timeout}ms.`
|
|
@@ -2266,7 +2270,11 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2266
2270
|
if (updateSnapshot !== "all") {
|
|
2267
2271
|
return {
|
|
2268
2272
|
pass: false,
|
|
2269
|
-
reference:
|
|
2273
|
+
reference: {
|
|
2274
|
+
path: referencePath,
|
|
2275
|
+
width: value.actual.metadata.width,
|
|
2276
|
+
height: value.actual.metadata.height
|
|
2277
|
+
},
|
|
2270
2278
|
actual: null,
|
|
2271
2279
|
diff: null,
|
|
2272
2280
|
message: `No existing reference screenshot found${shouldCreateReference ? "; a new one was created. Review it before running tests again." : "."}`
|
|
@@ -2310,8 +2318,16 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2310
2318
|
// - fail
|
|
2311
2319
|
return {
|
|
2312
2320
|
pass: false,
|
|
2313
|
-
reference:
|
|
2314
|
-
|
|
2321
|
+
reference: {
|
|
2322
|
+
path: paths.reference,
|
|
2323
|
+
width: reference.metadata.width,
|
|
2324
|
+
height: reference.metadata.height
|
|
2325
|
+
},
|
|
2326
|
+
actual: {
|
|
2327
|
+
path: paths.diffs.actual,
|
|
2328
|
+
width: value.actual.metadata.width,
|
|
2329
|
+
height: value.actual.metadata.height
|
|
2330
|
+
},
|
|
2315
2331
|
diff: finalResult.diff && paths.diffs.diff,
|
|
2316
2332
|
message: `Screenshot does not match the stored reference.${finalResult.message === null ? "" : `\n${finalResult.message}`}`
|
|
2317
2333
|
};
|
|
@@ -2442,8 +2458,8 @@ class ProjectBrowser {
|
|
|
2442
2458
|
if (this.provider.initScripts) {
|
|
2443
2459
|
this.parent.initScripts = this.provider.initScripts;
|
|
2444
2460
|
// make sure the script can be imported
|
|
2461
|
+
const allow = this.parent.vite.config.server.fs.allow;
|
|
2445
2462
|
this.provider.initScripts.forEach((script) => {
|
|
2446
|
-
const allow = this.parent.vite.config.server.fs.allow;
|
|
2447
2463
|
if (!allow.includes(script)) {
|
|
2448
2464
|
allow.push(script);
|
|
2449
2465
|
}
|
|
@@ -2927,13 +2943,14 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
2927
2943
|
}
|
|
2928
2944
|
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
2929
2945
|
wss.emit("connection", ws, request);
|
|
2930
|
-
const rpc = setupClient(project, rpcId, ws);
|
|
2946
|
+
const { rpc, offCancel } = setupClient(project, rpcId, ws);
|
|
2931
2947
|
const state = project.browser.state;
|
|
2932
2948
|
const clients = type === "tester" ? state.testers : state.orchestrators;
|
|
2933
2949
|
clients.set(rpcId, rpc);
|
|
2934
2950
|
debug?.("[%s] Browser API connected to %s", rpcId, type);
|
|
2935
2951
|
ws.on("close", () => {
|
|
2936
2952
|
debug?.("[%s] Browser API disconnected from %s", rpcId, type);
|
|
2953
|
+
offCancel();
|
|
2937
2954
|
clients.delete(rpcId);
|
|
2938
2955
|
globalServer.removeCDPHandler(rpcId);
|
|
2939
2956
|
if (type === "orchestrator") {
|
|
@@ -3164,8 +3181,11 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
3164
3181
|
deserialize: parse,
|
|
3165
3182
|
timeout: -1
|
|
3166
3183
|
});
|
|
3167
|
-
vitest.onCancel((reason) => rpc.onCancel(reason));
|
|
3168
|
-
return
|
|
3184
|
+
const offCancel = vitest.onCancel((reason) => rpc.onCancel(reason));
|
|
3185
|
+
return {
|
|
3186
|
+
rpc,
|
|
3187
|
+
offCancel
|
|
3188
|
+
};
|
|
3169
3189
|
}
|
|
3170
3190
|
}
|
|
3171
3191
|
function retrieveSourceMapURL(source) {
|
package/dist/locators.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{L as Locator,
|
|
1
|
+
export{L as Locator,n as convertElementToCssSelector,q as getByAltTextSelector,r as getByLabelSelector,t as getByPlaceholderSelector,u as getByRoleSelector,v as getByTestIdSelector,w as getByTextSelector,x as getByTitleSelector,o as getIframeScale,p as processTimeoutOptions,s as selectorEngine}from"./index-CEutxZap.js";import"vitest/browser";import"vitest/internal/browser";
|
|
@@ -5,12 +5,18 @@ export type ScreenshotMatcherArguments<ComparatorName extends keyof ScreenshotCo
|
|
|
5
5
|
mask?: readonly string[];
|
|
6
6
|
};
|
|
7
7
|
}];
|
|
8
|
+
interface ScreenshotData {
|
|
9
|
+
path: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
8
13
|
export type ScreenshotMatcherOutput = Promise<{
|
|
9
14
|
pass: false;
|
|
10
|
-
reference:
|
|
11
|
-
actual:
|
|
15
|
+
reference: ScreenshotData | null;
|
|
16
|
+
actual: ScreenshotData | null;
|
|
12
17
|
diff: string | null;
|
|
13
18
|
message: string;
|
|
14
19
|
} | {
|
|
15
20
|
pass: true;
|
|
16
21
|
}>;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.14",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"providers"
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"vitest": "4.0.
|
|
54
|
+
"vitest": "4.0.14"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"magic-string": "^0.30.21",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"sirv": "^3.0.2",
|
|
61
61
|
"tinyrainbow": "^3.0.3",
|
|
62
62
|
"ws": "^8.18.3",
|
|
63
|
-
"@vitest/
|
|
64
|
-
"@vitest/
|
|
63
|
+
"@vitest/utils": "4.0.14",
|
|
64
|
+
"@vitest/mocker": "4.0.14"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"ivya": "^1.7.0",
|
|
73
73
|
"mime": "^4.1.0",
|
|
74
74
|
"pathe": "^2.0.3",
|
|
75
|
-
"vitest": "4.0.
|
|
76
|
-
"
|
|
75
|
+
"@vitest/runner": "4.0.14",
|
|
76
|
+
"vitest": "4.0.14"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",
|