@vitest/browser 5.0.4 → 5.1.0-beta.1
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 +83 -0
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest_browser__/{defineProperty-DgkPJYVE.js → defineProperty-B-KFXNh3.js} +14 -1
- package/dist/client/__vitest_browser__/{orchestrator-Czo025Y6.js → orchestrator-BGLAewVw.js} +5 -4
- package/dist/client/__vitest_browser__/{tester-BH7uPfyB.js → tester-DStcqUww.js} +58 -35
- package/dist/client/esm-client-injector.js +1 -5
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client/tester/trace.d.ts +1 -0
- package/dist/context.js +102 -5
- package/dist/expect-element.js +1 -1
- package/dist/index.js +198 -72
- package/dist/locators-7Z9PPr-9.js +5 -0
- package/dist/locators.js +1 -1
- package/dist/types.d.ts +14 -2
- package/package.json +9 -9
- package/dist/locators-BHr21v4S.js +0 -5
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs, { promises, existsSync, readFileSync, createReadStream } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { ManualMockedModule, RedirectedModule, AutomockedModule, AutospiedModule, MockerRegistry } from '@vitest/mocker';
|
|
4
|
-
import { dynamicImportPlugin, ServerMockResolver, interceptorPlugin } from '@vitest/mocker/node';
|
|
4
|
+
import { dynamicImportPlugin, ServerMockResolver, getManualMockId, getManualMockUrl, interceptorPlugin, manualMockPlugin } from '@vitest/mocker/node';
|
|
5
5
|
import { distClientRoot } from '@vitest/ui';
|
|
6
6
|
import { slash as slash$1, deepMerge, cleanUrl as cleanUrl$1, toArray } from '@vitest/utils/helpers';
|
|
7
7
|
import sirv from 'sirv';
|
|
@@ -209,7 +209,7 @@ const basename = function(p, extension) {
|
|
|
209
209
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
var version = "5.0.
|
|
212
|
+
var version = "5.1.0-beta.1";
|
|
213
213
|
|
|
214
214
|
const pkgRoot = resolve(fileURLToPath(import.meta.url), "../..");
|
|
215
215
|
const distRoot = resolve(pkgRoot, "dist");
|
|
@@ -1498,7 +1498,8 @@ class Mime {
|
|
|
1498
1498
|
getAllExtensions(type) {
|
|
1499
1499
|
if (typeof type !== 'string')
|
|
1500
1500
|
return null;
|
|
1501
|
-
|
|
1501
|
+
type = type.split(';')[0].trim().toLowerCase();
|
|
1502
|
+
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type) ?? null;
|
|
1502
1503
|
}
|
|
1503
1504
|
_freeze() {
|
|
1504
1505
|
this.define = () => {
|
|
@@ -2194,7 +2195,7 @@ const _recordBrowserTrace = async ({ project }, { testId, data }) => {
|
|
|
2194
2195
|
if (!entry.stack || entry.location) {
|
|
2195
2196
|
return entry;
|
|
2196
2197
|
}
|
|
2197
|
-
const stacks = project.browser.parseStacktrace(entry.stack);
|
|
2198
|
+
const stacks = project.browser.parseStacktrace(entry.stack, { firstOnly: true });
|
|
2198
2199
|
if (stacks[0]) {
|
|
2199
2200
|
entry.location = stacks[0];
|
|
2200
2201
|
}
|
|
@@ -2226,6 +2227,17 @@ var builtinCommands = {
|
|
|
2226
2227
|
class BrowserServerState {
|
|
2227
2228
|
orchestrators = new Map();
|
|
2228
2229
|
testers = new Map();
|
|
2230
|
+
// reported by the orchestrator: whether the browser accepts an import map after a module loaded
|
|
2231
|
+
lateImportMaps;
|
|
2232
|
+
// a rule stays in the document until the run ends, and a non-isolated
|
|
2233
|
+
// run shares one document between its files
|
|
2234
|
+
usesImportMaps(config) {
|
|
2235
|
+
const option = config.browser.importMapMocks;
|
|
2236
|
+
if (option === true) {
|
|
2237
|
+
return true;
|
|
2238
|
+
}
|
|
2239
|
+
return option !== false && this.lateImportMaps === true && config.isolate;
|
|
2240
|
+
}
|
|
2229
2241
|
}
|
|
2230
2242
|
|
|
2231
2243
|
class ProjectBrowser {
|
|
@@ -2798,6 +2810,160 @@ function reviveUndefined(_key, value) {
|
|
|
2798
2810
|
return value === UNDEFINED_VALUE ? undefined : value;
|
|
2799
2811
|
}
|
|
2800
2812
|
|
|
2813
|
+
function createMockHandlers(project, { registry, factoryExportResolvers, checkFileAccess, rpc }) {
|
|
2814
|
+
const vite = project.vite;
|
|
2815
|
+
const mockResolver = new ServerMockResolver(vite, { moduleDirectories: project.config?.deps?.moduleDirectories });
|
|
2816
|
+
const mocker = project.browser?.provider?.mocker;
|
|
2817
|
+
return {
|
|
2818
|
+
resolveId(id, importer) {
|
|
2819
|
+
return mockResolver.resolveId(id, importer);
|
|
2820
|
+
},
|
|
2821
|
+
resolveMock(rawId, importer, options) {
|
|
2822
|
+
return mockResolver.resolveMock(rawId, importer, options);
|
|
2823
|
+
},
|
|
2824
|
+
invalidate(ids) {
|
|
2825
|
+
return mockResolver.invalidate(ids);
|
|
2826
|
+
},
|
|
2827
|
+
async registerMock(sessionId, module, { importer, testFile }) {
|
|
2828
|
+
const option = project.config.browser.importMapMocks;
|
|
2829
|
+
const state = project.browser.state;
|
|
2830
|
+
if (option === true && state.lateImportMaps === false) {
|
|
2831
|
+
throw new Error("\"browser.importMapMocks\" is enabled, but this browser does not accept an import map after a module has loaded. " + "Firefox needs the \"dom.multiple_import_maps.enabled\" preference.");
|
|
2832
|
+
}
|
|
2833
|
+
if (state.usesImportMaps(project.config)) {
|
|
2834
|
+
// a rule cannot be removed later, so a mock from another module, like
|
|
2835
|
+
// a setup file, is not added when the test file restores the module
|
|
2836
|
+
if (testFile && importer !== testFile && (await getStaticUnmocks(vite, mockResolver, testFile)).has(module.id)) {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (module.type !== "manual") {
|
|
2840
|
+
return resolveMockImportMap(vite, module);
|
|
2841
|
+
}
|
|
2842
|
+
// the shim reads the original only when it loads; until then the
|
|
2843
|
+
// server keeps a way to ask this session for the factory keys
|
|
2844
|
+
// this is a last resort check only if the transformation failed
|
|
2845
|
+
factoryExportResolvers.set(module.url, {
|
|
2846
|
+
sessionId,
|
|
2847
|
+
async resolve() {
|
|
2848
|
+
const { keys } = await rpc().resolveManualMock(module.url);
|
|
2849
|
+
return keys;
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
// the shim is not tied to the original file, so a changed original
|
|
2853
|
+
// would otherwise keep a stale export list
|
|
2854
|
+
const { moduleGraph } = vite.environments.client;
|
|
2855
|
+
const shim = moduleGraph.getModuleById(getManualMockId(module.url, module.id));
|
|
2856
|
+
if (shim) {
|
|
2857
|
+
moduleGraph.invalidateModule(shim);
|
|
2858
|
+
}
|
|
2859
|
+
return resolveMockImportMap(vite, module);
|
|
2860
|
+
}
|
|
2861
|
+
if (!mocker) {
|
|
2862
|
+
// make sure modules are not processed yet in case they were imported before
|
|
2863
|
+
// and were not mocked
|
|
2864
|
+
mockResolver.invalidate([module.id]);
|
|
2865
|
+
if (module.type === "manual") {
|
|
2866
|
+
const mock = ManualMockedModule.fromJSON(module, async () => {
|
|
2867
|
+
try {
|
|
2868
|
+
const { keys } = await rpc().resolveManualMock(module.url);
|
|
2869
|
+
return Object.fromEntries(keys.map((key) => [key, null]));
|
|
2870
|
+
} catch (err) {
|
|
2871
|
+
project.vitest.state.catchError(err, "Manual Mock Resolver Error");
|
|
2872
|
+
return {};
|
|
2873
|
+
}
|
|
2874
|
+
});
|
|
2875
|
+
registry.add(mock);
|
|
2876
|
+
} else {
|
|
2877
|
+
if (module.type === "redirect") {
|
|
2878
|
+
const redirectUrl = new URL(module.redirect);
|
|
2879
|
+
const redirect = join(vite.config.root, slash(decodeURI(redirectUrl.pathname)));
|
|
2880
|
+
checkFileAccess(redirect);
|
|
2881
|
+
module.redirect = redirect;
|
|
2882
|
+
}
|
|
2883
|
+
registry.register(module);
|
|
2884
|
+
}
|
|
2885
|
+
return;
|
|
2886
|
+
}
|
|
2887
|
+
if (module.type === "manual") {
|
|
2888
|
+
const manualModule = ManualMockedModule.fromJSON(module, async () => {
|
|
2889
|
+
const { keys } = await rpc().resolveManualMock(module.url);
|
|
2890
|
+
return Object.fromEntries(keys.map((key) => [key, null]));
|
|
2891
|
+
});
|
|
2892
|
+
await mocker.register(sessionId, manualModule);
|
|
2893
|
+
} else if (module.type === "redirect") {
|
|
2894
|
+
await mocker.register(sessionId, RedirectedModule.fromJSON(module));
|
|
2895
|
+
} else if (module.type === "automock") {
|
|
2896
|
+
await mocker.register(sessionId, AutomockedModule.fromJSON(module));
|
|
2897
|
+
} else if (module.type === "autospy") {
|
|
2898
|
+
await mocker.register(sessionId, AutospiedModule.fromJSON(module));
|
|
2899
|
+
}
|
|
2900
|
+
},
|
|
2901
|
+
clearMocks(sessionId) {
|
|
2902
|
+
for (const [url, resolver] of factoryExportResolvers) {
|
|
2903
|
+
if (resolver.sessionId === sessionId) {
|
|
2904
|
+
factoryExportResolvers.delete(url);
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
if (!mocker) {
|
|
2908
|
+
return registry.clear();
|
|
2909
|
+
}
|
|
2910
|
+
return mocker.clear(sessionId);
|
|
2911
|
+
},
|
|
2912
|
+
unregisterMock(sessionId, id) {
|
|
2913
|
+
if (!mocker) {
|
|
2914
|
+
return registry.delete(id);
|
|
2915
|
+
}
|
|
2916
|
+
return mocker.delete(sessionId, id);
|
|
2917
|
+
}
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2920
|
+
function injectQuery(url, query) {
|
|
2921
|
+
return url.includes("?") ? `${url}&${query}` : `${url}?${query}`;
|
|
2922
|
+
}
|
|
2923
|
+
// the key must be the exact URL that import analysis emits in the browser,
|
|
2924
|
+
// including the dependency version and the HMR timestamp
|
|
2925
|
+
function resolveMockImportMap(vite, module) {
|
|
2926
|
+
let url = module.url;
|
|
2927
|
+
const version = /[?&]v=(\w{8})/.exec(module.id)?.[1];
|
|
2928
|
+
if (version) {
|
|
2929
|
+
url = injectQuery(url, `v=${version}`);
|
|
2930
|
+
}
|
|
2931
|
+
const node = vite.environments.client.moduleGraph.getModuleById(module.id);
|
|
2932
|
+
if (node && node.lastHMRTimestamp > 0) {
|
|
2933
|
+
url = injectQuery(url, `t=${node.lastHMRTimestamp}`);
|
|
2934
|
+
}
|
|
2935
|
+
const base = vite.config.base.replace(/\/$/, "");
|
|
2936
|
+
const key = base + url;
|
|
2937
|
+
if (module.type === "redirect") {
|
|
2938
|
+
const redirect = new URL(module.redirect);
|
|
2939
|
+
return { imports: { [key]: base + redirect.pathname + redirect.search } };
|
|
2940
|
+
}
|
|
2941
|
+
if (module.type === "manual") {
|
|
2942
|
+
return { imports: { [key]: base + getManualMockUrl(module.url, module.id) } };
|
|
2943
|
+
}
|
|
2944
|
+
return { imports: { [key]: injectQuery(key, `mock=${module.type}`) } };
|
|
2945
|
+
}
|
|
2946
|
+
const staticUnmocks = new WeakMap();
|
|
2947
|
+
// resolved ids of the modules that a test file restores with a static `vi.unmock` call
|
|
2948
|
+
async function getStaticUnmocks(vite, resolver, testFile) {
|
|
2949
|
+
const environment = vite.environments.client;
|
|
2950
|
+
// the url the tester requests, so the transform is shared with the import
|
|
2951
|
+
const url = /^\w:/.test(testFile) ? `/@fs/${testFile}` : testFile;
|
|
2952
|
+
// a test file that fails to transform reports the error when it is imported
|
|
2953
|
+
const transformed = await environment.transformRequest(url).catch(() => null);
|
|
2954
|
+
const id = (await environment.moduleGraph.getModuleByUrl(url))?.id;
|
|
2955
|
+
if (!transformed || !id) {
|
|
2956
|
+
return new Set();
|
|
2957
|
+
}
|
|
2958
|
+
let unmocks = staticUnmocks.get(transformed);
|
|
2959
|
+
if (!unmocks) {
|
|
2960
|
+
const calls = environment.pluginContainer.getModuleInfo(id)?.meta?.vitestStaticMocks ?? [];
|
|
2961
|
+
unmocks = Promise.all(calls.filter((call) => call.method === "unmock").map((call) => resolver.resolveId(call.specifier, id).catch(() => null))).then((results) => new Set(results.flatMap((resolved) => resolved ? [resolved.id] : [])));
|
|
2962
|
+
staticUnmocks.set(transformed, unmocks);
|
|
2963
|
+
}
|
|
2964
|
+
return unmocks;
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2801
2967
|
const debug = createDebugger("vitest:browser:api");
|
|
2802
2968
|
const BROWSER_API_PATH = "/__vitest_browser_api__";
|
|
2803
2969
|
const DEFAULT_HEARTBEAT_INTERVAL = 15e3;
|
|
@@ -2818,7 +2984,7 @@ function resolveHeartbeatInterval(vitest) {
|
|
|
2818
2984
|
}
|
|
2819
2985
|
return interval;
|
|
2820
2986
|
}
|
|
2821
|
-
function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
2987
|
+
function setupBrowserRpc(globalServer, defaultMockerRegistry, factoryExportResolvers) {
|
|
2822
2988
|
const vite = globalServer.vite;
|
|
2823
2989
|
const vitest = globalServer.vitest;
|
|
2824
2990
|
const wss = new WebSocketServer({ noServer: true });
|
|
@@ -2846,6 +3012,11 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
2846
3012
|
}
|
|
2847
3013
|
const sessions = vitest._browserSessions;
|
|
2848
3014
|
if (!sessions.sessionIds.has(sessionId)) {
|
|
3015
|
+
if (sessions.closedSessionIds.has(sessionId)) {
|
|
3016
|
+
debug?.("[%s] ignoring the %s connection of a closed session", sessionId, type);
|
|
3017
|
+
socket.destroy();
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
2849
3020
|
const ids = [...sessions.sessionIds].join(", ");
|
|
2850
3021
|
return error(new Error(`[vitest] Unknown session id "${sessionId}". Expected one of ${ids}.`));
|
|
2851
3022
|
}
|
|
@@ -2932,10 +3103,9 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
2932
3103
|
}
|
|
2933
3104
|
}
|
|
2934
3105
|
function setupClient(project, rpcId, ws, options) {
|
|
2935
|
-
const mockResolver = new ServerMockResolver(globalServer.vite, { moduleDirectories: project.config?.deps?.moduleDirectories });
|
|
2936
|
-
const mocker = project.browser?.provider?.mocker;
|
|
2937
3106
|
const rpc = createBirpc({
|
|
2938
|
-
onOrchestratorReady() {
|
|
3107
|
+
onOrchestratorReady(capabilities) {
|
|
3108
|
+
project.browser.state.lateImportMaps = capabilities.lateImportMaps;
|
|
2939
3109
|
const sessions = vitest._browserSessions;
|
|
2940
3110
|
sessions.getSession(options.sessionId)?.ready();
|
|
2941
3111
|
},
|
|
@@ -3078,9 +3248,6 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
3078
3248
|
cancelCurrentRun(reason) {
|
|
3079
3249
|
vitest.cancelCurrentRun(reason);
|
|
3080
3250
|
},
|
|
3081
|
-
async resolveId(id, importer) {
|
|
3082
|
-
return mockResolver.resolveId(id, importer);
|
|
3083
|
-
},
|
|
3084
3251
|
debug(...args) {
|
|
3085
3252
|
vitest.logger.console.debug(...args);
|
|
3086
3253
|
},
|
|
@@ -3124,65 +3291,12 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
3124
3291
|
}, provider.getCommandsContext(sessionId));
|
|
3125
3292
|
return await project.browser.triggerCommand(command, context, ...payload);
|
|
3126
3293
|
},
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
},
|
|
3133
|
-
async registerMock(sessionId, module) {
|
|
3134
|
-
if (!mocker) {
|
|
3135
|
-
// make sure modules are not processed yet in case they were imported before
|
|
3136
|
-
// and were not mocked
|
|
3137
|
-
mockResolver.invalidate([module.id]);
|
|
3138
|
-
if (module.type === "manual") {
|
|
3139
|
-
const mock = ManualMockedModule.fromJSON(module, async () => {
|
|
3140
|
-
try {
|
|
3141
|
-
const { keys } = await rpc.resolveManualMock(module.url);
|
|
3142
|
-
return Object.fromEntries(keys.map((key) => [key, null]));
|
|
3143
|
-
} catch (err) {
|
|
3144
|
-
vitest.state.catchError(err, "Manual Mock Resolver Error");
|
|
3145
|
-
return {};
|
|
3146
|
-
}
|
|
3147
|
-
});
|
|
3148
|
-
defaultMockerRegistry.add(mock);
|
|
3149
|
-
} else {
|
|
3150
|
-
if (module.type === "redirect") {
|
|
3151
|
-
const redirectUrl = new URL(module.redirect);
|
|
3152
|
-
const redirect = join(vite.config.root, slash(decodeURI(redirectUrl.pathname)));
|
|
3153
|
-
checkFileAccess(redirect);
|
|
3154
|
-
module.redirect = redirect;
|
|
3155
|
-
}
|
|
3156
|
-
defaultMockerRegistry.register(module);
|
|
3157
|
-
}
|
|
3158
|
-
return;
|
|
3159
|
-
}
|
|
3160
|
-
if (module.type === "manual") {
|
|
3161
|
-
const manualModule = ManualMockedModule.fromJSON(module, async () => {
|
|
3162
|
-
const { keys } = await rpc.resolveManualMock(module.url);
|
|
3163
|
-
return Object.fromEntries(keys.map((key) => [key, null]));
|
|
3164
|
-
});
|
|
3165
|
-
await mocker.register(sessionId, manualModule);
|
|
3166
|
-
} else if (module.type === "redirect") {
|
|
3167
|
-
await mocker.register(sessionId, RedirectedModule.fromJSON(module));
|
|
3168
|
-
} else if (module.type === "automock") {
|
|
3169
|
-
await mocker.register(sessionId, AutomockedModule.fromJSON(module));
|
|
3170
|
-
} else if (module.type === "autospy") {
|
|
3171
|
-
await mocker.register(sessionId, AutospiedModule.fromJSON(module));
|
|
3172
|
-
}
|
|
3173
|
-
},
|
|
3174
|
-
clearMocks(sessionId) {
|
|
3175
|
-
if (!mocker) {
|
|
3176
|
-
return defaultMockerRegistry.clear();
|
|
3177
|
-
}
|
|
3178
|
-
return mocker.clear(sessionId);
|
|
3179
|
-
},
|
|
3180
|
-
unregisterMock(sessionId, id) {
|
|
3181
|
-
if (!mocker) {
|
|
3182
|
-
return defaultMockerRegistry.delete(id);
|
|
3183
|
-
}
|
|
3184
|
-
return mocker.delete(sessionId, id);
|
|
3185
|
-
},
|
|
3294
|
+
...createMockHandlers(project, {
|
|
3295
|
+
registry: defaultMockerRegistry,
|
|
3296
|
+
factoryExportResolvers,
|
|
3297
|
+
checkFileAccess,
|
|
3298
|
+
rpc: () => rpc
|
|
3299
|
+
}),
|
|
3186
3300
|
// CDP
|
|
3187
3301
|
async sendCdpEvent(sessionId, event, payload) {
|
|
3188
3302
|
assertCdpAllowed(project);
|
|
@@ -3260,6 +3374,7 @@ function pinCacheControl(res, value) {
|
|
|
3260
3374
|
*/
|
|
3261
3375
|
const createBrowserServer = async () => {
|
|
3262
3376
|
const mockerRegistry = new MockerRegistry();
|
|
3377
|
+
const factoryExportResolvers = new Map();
|
|
3263
3378
|
const contribution = {
|
|
3264
3379
|
async transformIndexHtml(ctx) {
|
|
3265
3380
|
const parentServer = contribution.parent;
|
|
@@ -3409,12 +3524,16 @@ body {
|
|
|
3409
3524
|
`/@fs${distDir}`,
|
|
3410
3525
|
`/@fs${distRoot}`
|
|
3411
3526
|
];
|
|
3527
|
+
// request interception serves a mocked dependency at the original URL,
|
|
3528
|
+
// so a cached original would never reach the mock; import map mocks
|
|
3529
|
+
// have their own URLs and keep Vite's immutable caching
|
|
3530
|
+
const interceptsMocks = () => Array.from(parentServer.children).some((child) => !child.state.usesImportMaps(child.config));
|
|
3412
3531
|
server.middlewares.use((req, res, next) => {
|
|
3413
3532
|
const url = req.url;
|
|
3414
3533
|
if (url) {
|
|
3415
3534
|
if (immutablePrefixes.some((prefix) => url.startsWith(prefix))) {
|
|
3416
3535
|
pinCacheControl(res, "public,max-age=31536000,immutable");
|
|
3417
|
-
} else if (versionRegexp.test(url) && !url.includes("chunk-")) {
|
|
3536
|
+
} else if (versionRegexp.test(url) && !url.includes("chunk-") && interceptsMocks()) {
|
|
3418
3537
|
pinCacheControl(res, "no-cache");
|
|
3419
3538
|
}
|
|
3420
3539
|
}
|
|
@@ -3499,7 +3618,7 @@ body {
|
|
|
3499
3618
|
}, "/");
|
|
3500
3619
|
},
|
|
3501
3620
|
setupRpc(parent) {
|
|
3502
|
-
setupBrowserRpc(parent, mockerRegistry);
|
|
3621
|
+
setupBrowserRpc(parent, mockerRegistry, factoryExportResolvers);
|
|
3503
3622
|
}
|
|
3504
3623
|
};
|
|
3505
3624
|
contribution.plugins = [
|
|
@@ -3508,6 +3627,13 @@ body {
|
|
|
3508
3627
|
registry: mockerRegistry,
|
|
3509
3628
|
registerWebSocketEvents: false
|
|
3510
3629
|
}),
|
|
3630
|
+
manualMockPlugin({ resolveFactoryExports(url) {
|
|
3631
|
+
const resolver = factoryExportResolvers.get(url);
|
|
3632
|
+
if (!resolver) {
|
|
3633
|
+
throw new Error(`[vitest] The factory mock "${url}" is not registered`);
|
|
3634
|
+
}
|
|
3635
|
+
return resolver.resolve();
|
|
3636
|
+
} }),
|
|
3511
3637
|
{
|
|
3512
3638
|
name: "vitest:browser:framework-sourcemaps",
|
|
3513
3639
|
enforce: "post",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{vi as e}from"vitest";import{server as t,page as n,utils as r}from"vitest/browser";import{getSafeTimers as i,__INTERNAL as a}from"vitest/internal/browser";const o=globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;function s(e){let t=l().current;if(!t||t.type!==`test`)return e();let n=!1,r=Error(`STACK_TRACE_ERROR`);t.onFinished??=[],t.onFinished.push(()=>{if(!n){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=r.stack?.replace(r.message,e.message),e}});let i;return{then(t,a){return n=!0,(i||=e(r)).then(t,a)},catch(t){return n=!0,(i||=e(r)).catch(t)},finally(t){return n=!0,(i||=e(r)).finally(t)},[Symbol.toStringTag]:`Promise`}}function c(){return window.__vitest_browser_runner__}function l(){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}function u(e){if(e?.timeout!=null)return e.timeout;if(l().config.browser.providerOptions.actionTimeout==null)return c().runner._deadline?.derive()}function d(e){let t=u(e);return t==null?e:{...e,timeout:t}}function f(t){if(!e.isFakeTimers())return t;let{setInterval:n,clearInterval:r}=i(),a=n(()=>{e.isFakeTimers()&&e.advanceTimersByTime(50)},50);return t.finally(()=>r(a))}class p{[Symbol.toStringTag]=`Action`;#e;#t;#n;#r;#i;#a=!1;constructor(e,t,n,r){this.#e=e,this.#t=t,this.#n=n,this.#r=r??Error(`STACK_TRACE_ERROR`);let i=l().current;if(r||!i||i.type!==`test`){this.#i=this.#o();return}i.onFinished??=[],i.onFinished.push(()=>{if(!this.#a){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=this.#r.stack?.replace(this.#r.message,e.message),e}})}async#o(){let e=u(this.#n),t=e==null?this.#n:{...this.#n,timeout:e},n=typeof this.#t==`function`?await this.#t(t):[...this.#t,t],r=f(c().commands.triggerCommand(this.#e,n,this.#r)),i=c().runner._deadline;return i&&e!=null?i.track(this.#e.slice(9),r,e,this.#r):r}#s(){return this.#a=!0,this.#i??=this.#o()}then(e,t){return this.#s().then(e,t)}catch(e){return this.#s().catch(e)}finally(e){return this.#s().finally(e)}}class m extends p{constructor(e,t,n,r,i){super(t,[e,...n],r,i)}}class h extends p{constructor(e,t,n,r){super(`__vitest_upload`,async n=>[e,await g(t),n],n,r)}}function g(e){return Promise.all((Array.isArray(e)?e:[e]).map(async e=>{if(typeof e==`string`)return e;let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(Error(`Failed to read file: ${e.name}`)),r.readAsDataURL(e)});return{name:e.name,mimeType:e.type,base64:t.slice(t.indexOf(`,`)+1)}}))}function _(e){"@babel/helpers - typeof";return _=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_(e)}function v(e,t){if(_(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(_(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function y(e){var t=v(e,`string`);return _(t)==`symbol`?t:t+``}function b(e,t,n){return(t=y(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const x=function(e,t,n){return e>=t&&e<=n};function S(e){return x(e,48,57)}function ee(e){return S(e)||x(e,65,70)||x(e,97,102)}function C(e){return x(e,65,90)}function te(e){return x(e,97,122)}function ne(e){return C(e)||te(e)}function re(e){return e>=128}function ie(e){return ne(e)||re(e)||e===95}function ae(e){return ie(e)||S(e)||e===45}function oe(e){return x(e,0,8)||e===11||x(e,14,31)||e===127}function se(e){return e===10}function w(e){return se(e)||e===9||e===32}var T=class extends Error{constructor(e){super(e),this.name=`InvalidCharacterError`}};function ce(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===13&&e.charCodeAt(n+1)===10&&(r=10,n++),(r===13||r===12)&&(r=10),r===0&&(r=65533),x(r,55296,56319)&&x(e.charCodeAt(n+1),56320,57343)){let t=r-55296,i=e.charCodeAt(n+1)-56320;r=2**16+t*1024+i,n++}t.push(r)}return t}function E(e){if(e<=65535)return String.fromCharCode(e);e-=2**16;let t=Math.floor(e/1024)+55296,n=e%1024+56320;return String.fromCharCode(t)+String.fromCharCode(n)}function le(e){let t=ce(e),n=-1,r=[],i,a=function(e){return e>=t.length?-1:t[e]},o=function(e){if(e===void 0&&(e=1),e>3)throw`Spec Error: no more than three codepoints of lookahead.`;return a(n+e)},s=function(e){return e===void 0&&(e=1),n+=e,i=a(n),!0},c=function(){return--n,!0},l=function(e){return e===void 0&&(e=i),e===-1},u=function(){if(d(),s(),w(i)){for(;w(o());)s();return new fe}if(i===34)return m();if(i===35){if(ae(o())||_(o(1),o(2))){let e=new Pe(``);return y(o(1),o(2),o(3))&&(e.type=`id`),e.value=te(),e}return new k(i)}return i===36?o()===61?(s(),new De):new k(i):i===39?m():i===40?new Se:i===41?new Ce:i===42?o()===61?(s(),new Oe):new k(i):i===43?C()?(c(),f()):new k(i):i===44?new _e:i===45?C()?(c(),f()):o(1)===45&&o(2)===62?(s(2),new me):b()?(c(),p()):new k(i):i===46?C()?(c(),f()):new k(i):i===58?new he:i===59?new ge:i===60?o(1)===33&&o(2)===45&&o(3)===45?(s(3),new pe):new k(i):i===64?y(o(1),o(2),o(3))?new Ne(te()):new k(i):i===91?new be:i===92?v()?(c(),p()):new k(i):i===93?new xe:i===94?o()===61?(s(),new Ee):new k(i):i===123?new ve:i===124?o()===61?(s(),new Te):o()===124?(s(),new ke):new k(i):i===125?new ye:i===126?o()===61?(s(),new we):new k(i):S(i)?(c(),f()):ie(i)?(c(),p()):l()?new Ae:new k(i)},d=function(){for(;o(1)===47&&o(2)===42;)for(s(2);;){if(s(),i===42&&o()===47){s();break}if(l())return}},f=function(){let e=ne();if(y(o(1),o(2),o(3))){let t=new ze;return t.value=e.value,t.repr=e.repr,t.type=e.type,t.unit=te(),t}if(o()===37){s();let t=new Re;return t.value=e.value,t.repr=e.repr,t}{let t=new Le;return t.value=e.value,t.repr=e.repr,t.type=e.type,t}},p=function(){let e=te();if(e.toLowerCase()===`url`&&o()===40){for(s();w(o(1))&&w(o(2));)s();return o()===34||o()===39||w(o())&&(o(2)===34||o(2)===39)?new Me(e):h()}return o()===40?(s(),new Me(e)):new je(e)},m=function(e){e===void 0&&(e=i);let t=``;for(;s();)if(i===e||l())return new Fe(t);else if(se(i))return c(),new ue;else i===92?l(o())||(se(o())?s():t+=E(g())):t+=E(i);throw Error(`Internal error`)},h=function(){let e=new Ie(``);for(;w(o());)s();if(l(o()))return e;for(;s();)if(i===41||l())return e;else if(w(i)){for(;w(o());)s();return o()===41||l(o())?(s(),e):(T(),new de)}else if(i===34||i===39||i===40||oe(i))return T(),new de;else if(i===92){if(v())e.value+=E(g());else return T(),new de}else e.value+=E(i);throw Error(`Internal error`)},g=function(){if(s(),ee(i)){let e=[i];for(let t=0;t<5&&ee(o());t++)s(),e.push(i);w(o())&&s();let t=Number.parseInt(e.map(e=>String.fromCharCode(e)).join(``),16);return t>1114111&&(t=65533),t}return l()?65533:i},_=function(e,t){return!(e!==92||se(t))},v=function(){return _(i,o())},y=function(e,t,n){return e===45?ie(t)||t===45||_(t,n):ie(e)?!0:e===92&&_(e,t)},b=function(){return y(i,o(1),o(2))},x=function(e,t,n){return e===43||e===45?!!(S(t)||t===46&&S(n)):e===46?!!S(t):!!S(e)},C=function(){return x(i,o(1),o(2))},te=function(){let e=``;for(;s();)if(ae(i))e+=E(i);else if(v())e+=E(g());else return c(),e;throw Error(`Internal parse error`)},ne=function(){let e=``,t=`integer`;for((o()===43||o()===45)&&(s(),e+=E(i));S(o());)s(),e+=E(i);if(o(1)===46&&S(o(2)))for(s(),e+=E(i),s(),e+=E(i),t=`number`;S(o());)s(),e+=E(i);let n=o(1),r=o(2),a=o(3);if((n===69||n===101)&&S(r))for(s(),e+=E(i),s(),e+=E(i),t=`number`;S(o());)s(),e+=E(i);else if((n===69||n===101)&&(r===43||r===45)&&S(a))for(s(),e+=E(i),s(),e+=E(i),s(),e+=E(i),t=`number`;S(o());)s(),e+=E(i);let c=re(e);return{type:t,value:c,repr:e}},re=function(e){return+e},T=function(){for(;s();)if(i===41||l())return;else v()&&g()},le=0;for(;!l(o());)if(r.push(u()),le++,le>t.length*2)throw Error(`I'm infinite-looping!`);return r}var D=class{constructor(){b(this,`tokenType`,``),b(this,`value`,void 0)}toJSON(){return{token:this.tokenType}}toString(){return this.tokenType}toSource(){return`${this}`}},ue=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`BADSTRING`)}},de=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`BADURL`)}},fe=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`WHITESPACE`)}toString(){return`WS`}toSource(){return` `}},pe=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`CDO`)}toSource(){return`<!--`}},me=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`CDC`)}toSource(){return`-->`}},he=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`:`)}},ge=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`;`)}},_e=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`,`)}},O=class extends D{constructor(...e){super(...e),b(this,`value`,``),b(this,`mirror`,``)}},ve=class extends O{constructor(){super(),b(this,`tokenType`,`{`),this.value=`{`,this.mirror=`}`}},ye=class extends O{constructor(){super(),b(this,`tokenType`,`}`),this.value=`}`,this.mirror=`{`}},be=class extends O{constructor(){super(),b(this,`tokenType`,`[`),this.value=`[`,this.mirror=`]`}},xe=class extends O{constructor(){super(),b(this,`tokenType`,`]`),this.value=`]`,this.mirror=`[`}},Se=class extends O{constructor(){super(),b(this,`tokenType`,`(`),this.value=`(`,this.mirror=`)`}},Ce=class extends O{constructor(){super(),b(this,`tokenType`,`)`),this.value=`)`,this.mirror=`(`}},we=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`~=`)}},Te=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`|=`)}},Ee=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`^=`)}},De=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`$=`)}},Oe=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`*=`)}},ke=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`||`)}},Ae=class extends D{constructor(...e){super(...e),b(this,`tokenType`,`EOF`)}toSource(){return``}},k=class extends D{constructor(e){super(),b(this,`tokenType`,`DELIM`),b(this,`value`,``),this.value=E(e)}toString(){return`DELIM(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}toSource(){return this.value===`\\`?`\\
|
|
2
|
+
`:this.value}},A=class extends D{constructor(...e){super(...e),b(this,`value`,``)}ASCIIMatch(e){return this.value.toLowerCase()===e.toLowerCase()}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e}},je=class extends A{constructor(e){super(),b(this,`tokenType`,`IDENT`),this.value=e}toString(){return`IDENT(${this.value})`}toSource(){return Be(this.value)}},Me=class extends A{constructor(e){super(),b(this,`tokenType`,`FUNCTION`),b(this,`mirror`,void 0),this.value=e,this.mirror=`)`}toString(){return`FUNCTION(${this.value})`}toSource(){return`${Be(this.value)}(`}},Ne=class extends A{constructor(e){super(),b(this,`tokenType`,`AT-KEYWORD`),this.value=e}toString(){return`AT(${this.value})`}toSource(){return`@${Be(this.value)}`}},Pe=class extends A{constructor(e){super(),b(this,`tokenType`,`HASH`),b(this,`type`,void 0),this.value=e,this.type=`unrestricted`}toString(){return`HASH(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e}toSource(){return this.type===`id`?`#${Be(this.value)}`:`#${Ve(this.value)}`}},Fe=class extends A{constructor(e){super(),b(this,`tokenType`,`STRING`),this.value=e}toString(){return`"${He(this.value)}"`}},Ie=class extends A{constructor(e){super(),b(this,`tokenType`,`URL`),this.value=e}toString(){return`URL(${this.value})`}toSource(){return`url("${He(this.value)}")`}},Le=class extends D{constructor(){super(),b(this,`tokenType`,`NUMBER`),b(this,`type`,void 0),b(this,`repr`,void 0),this.type=`integer`,this.repr=``}toString(){return this.type===`integer`?`INT(${this.value})`:`NUMBER(${this.value})`}toJSON(){let e=super.toJSON();return e.value=this.value,e.type=this.type,e.repr=this.repr,e}toSource(){return this.repr}},Re=class extends D{constructor(){super(),b(this,`tokenType`,`PERCENTAGE`),b(this,`repr`,void 0),this.repr=``}toString(){return`PERCENTAGE(${this.value})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.repr=this.repr,e}toSource(){return`${this.repr}%`}},ze=class extends D{constructor(){super(),b(this,`tokenType`,`DIMENSION`),b(this,`type`,void 0),b(this,`repr`,void 0),b(this,`unit`,void 0),this.type=`integer`,this.repr=``,this.unit=``}toString(){return`DIM(${this.value},${this.unit})`}toJSON(){let e=this.constructor.prototype.constructor.prototype.toJSON.call(this);return e.value=this.value,e.type=this.type,e.repr=this.repr,e.unit=this.unit,e}toSource(){let e=this.repr,t=Be(this.unit);return t[0].toLowerCase()===`e`&&(t[1]===`-`||x(t.charCodeAt(1),48,57))&&(t=`\\65 ${t.slice(1,t.length)}`),e+t}};function Be(e){e=`${e}`;let t=``,n=e.charCodeAt(0);for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i===0)throw new T(`Invalid character: the input contains U+0000.`);x(i,1,31)||i===127||r===0&&x(i,48,57)||r===1&&x(i,48,57)&&n===45?t+=`\\${i.toString(16)} `:i>=128||i===45||i===95||x(i,48,57)||x(i,65,90)||x(i,97,122)?t+=e[r]:t+=`\\${e[r]}`}return t}function Ve(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new T(`Invalid character: the input contains U+0000.`);r>=128||r===45||r===95||x(r,48,57)||x(r,65,90)||x(r,97,122)?t+=e[n]:t+=`\\${r.toString(16)} `}return t}function He(e){e=`${e}`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===0)throw new T(`Invalid character: the input contains U+0000.`);x(r,1,31)||r===127?t+=`\\${r.toString(16)} `:t+=r===34||r===92?`\\${e[n]}`:e[n]}return t}var j=class extends Error{};function Ue(e,t){let n;try{n=le(e),n[n.length-1]instanceof Ae||n.push(new Ae)}catch(t){let n=`${t.message} while parsing selector "${e}"`,r=(t.stack||``).indexOf(t.message);throw r!==-1&&(t.stack=t.stack.substring(0,r)+n+t.stack.substring(r+t.message.length)),t.message=n,t}let r=n.find(e=>e instanceof Ne||e instanceof ue||e instanceof de||e instanceof ke||e instanceof pe||e instanceof me||e instanceof ge||e instanceof ve||e instanceof ye||e instanceof Ie||e instanceof Re);if(r)throw new j(`Unsupported token "${r.toSource()}" while parsing selector "${e}"`);let i=0,a=new Set;function o(){return new j(`Unexpected token "${n[i].toSource()}" while parsing selector "${e}"`)}function s(){for(;n[i]instanceof fe;)i++}function c(e=i){return n[e]instanceof je}function l(e=i){return n[e]instanceof Fe}function u(e=i){return n[e]instanceof Le}function d(e=i){return n[e]instanceof _e}function f(e=i){return n[e]instanceof Se}function p(e=i){return n[e]instanceof Ce}function m(e=i){return n[e]instanceof Me}function h(e=i){return n[e]instanceof k&&n[e].value===`*`}function g(e=i){return n[e]instanceof Ae}function _(e=i){return n[e]instanceof k&&[`>`,`+`,`~`].includes(n[e].value)}function v(e=i){return d(e)||p(e)||g(e)||_(e)||n[e]instanceof fe}function y(){let e=[b()];for(;s(),d();)i++,e.push(b());return e}function b(){return s(),u()||l()?n[i++].value:x()}function x(){let e={simples:[]};for(s(),_()?e.simples.push({selector:{functions:[{name:`scope`,args:[]}]},combinator:``}):e.simples.push({selector:S(),combinator:``});;){if(s(),_())e.simples[e.simples.length-1].combinator=n[i++].value,s();else if(v())break;e.simples.push({combinator:``,selector:S()})}return e}function S(){let e=``,r=[];for(;!v();)if(c()||h())e+=n[i++].toSource();else if(n[i]instanceof Pe)e+=n[i++].toSource();else if(n[i]instanceof k&&n[i].value===`.`){if(i++,c())e+=`.${n[i++].toSource()}`;else throw o()}else if(n[i]instanceof he){if(i++,c()){if(!t.has(n[i].value.toLowerCase()))e+=`:${n[i++].toSource()}`;else{let e=n[i++].value.toLowerCase();r.push({name:e,args:[]}),a.add(e)}}else if(m()){let c=n[i++].value.toLowerCase();if(t.has(c)?(r.push({name:c,args:y()}),a.add(c)):e+=`:${c}(${ee()})`,s(),!p())throw o();i++}else throw o()}else if(n[i]instanceof be){for(e+=`[`,i++;!(n[i]instanceof xe)&&!g();)e+=n[i++].toSource();if(!(n[i]instanceof xe))throw o();e+=`]`,i++}else throw o();if(!e&&!r.length)throw o();return{css:e||void 0,functions:r}}function ee(){let e=``,t=1;for(;!g()&&((f()||m())&&t++,p()&&t--,t);)e+=n[i++].toSource();return e}let C=y();if(!g())throw o();if(C.some(e=>typeof e!=`object`||!(`simples`in e)))throw new j(`Error while parsing selector "${e}"`);return{selector:C,names:Array.from(a)}}const We=new Set([`internal:has`,`internal:has-not`,`internal:and`,`internal:or`,`internal:chain`,`left-of`,`right-of`,`above`,`below`,`near`]),Ge=new Set([`left-of`,`right-of`,`above`,`below`,`near`]),Ke=new Set([`not`,`is`,`where`,`has`,`scope`,`light`,`visible`,`text`,`text-matches`,`text-is`,`has-text`,`above`,`below`,`right-of`,`left-of`,`near`,`nth-match`]);function qe(e){let t=Xe(e),n=[];for(let e of t.parts){if(e.name===`css`||e.name===`css:light`){e.name===`css:light`&&(e.body=`:light(${e.body})`);let t=Ue(e.body,Ke);n.push({name:`css`,body:t.selector,source:e.body});continue}if(We.has(e.name)){let t,r;try{let n=JSON.parse(`[${e.body}]`);if(!Array.isArray(n)||n.length<1||n.length>2||typeof n[0]!=`string`)throw new j(`Malformed selector: ${e.name}=${e.body}`);if(t=n[0],n.length===2){if(typeof n[1]!=`number`||!Ge.has(e.name))throw new j(`Malformed selector: ${e.name}=${e.body}`);r=n[1]}}catch{throw new j(`Malformed selector: ${e.name}=${e.body}`)}let i={name:e.name,source:e.body,body:{parsed:qe(t),distance:r}},a=[...i.body.parsed.parts].reverse().find(e=>e.name===`internal:control`&&e.body===`enter-frame`),o=a?i.body.parsed.parts.indexOf(a):-1;o!==-1&&Je(i.body.parsed.parts.slice(0,o+1),n.slice(0,o+1))&&i.body.parsed.parts.splice(0,o+1),n.push(i);continue}n.push({...e,source:e.body})}if(We.has(n[0].name))throw new j(`"${n[0].name}" selector cannot be first`);return{capture:t.capture,parts:n}}function Je(e,t){return M({parts:e})===M({parts:t})}function M(e,t){return typeof e==`string`?e:e.parts.map((n,r)=>{let i=!0;!t&&r!==e.capture&&(n.name===`css`||n.name===`xpath`&&n.source.startsWith(`//`)||n.source.startsWith(`..`))&&(i=!1);let a=i?`${n.name}=`:``;return`${r===e.capture?`*`:``}${a}${n.source}`}).join(` >> `)}function Ye(e,t){let n=(e,r)=>{for(let i of e.parts)t(i,r),We.has(i.name)&&n(i.body.parsed,!0)};n(e,!1)}function Xe(e){let t=0,n,r=0,i={parts:[]},a=()=>{let n=e.substring(r,t).trim(),a=n.indexOf(`=`),o,s;a!==-1&&n.substring(0,a).trim().match(/^[\w\-+:*]+$/)?(o=n.substring(0,a).trim(),s=n.substring(a+1)):n.length>1&&n[0]===`"`&&n[n.length-1]===`"`||n.length>1&&n[0]===`'`&&n[n.length-1]===`'`?(o=`text`,s=n):/^\(*\/\//.test(n)||n.startsWith(`..`)?(o=`xpath`,s=n):(o=`css`,s=n);let c=!1;if(o[0]===`*`&&(c=!0,o=o.substring(1)),i.parts.push({name:o,body:s}),c){if(i.capture!==void 0)throw new j(`Only one of the selectors can capture using * modifier`);i.capture=i.parts.length-1}};if(!e.includes(`>>`))return t=e.length,a(),i;let o=()=>{let n=e.substring(r,t).match(/^\s*text\s*=(.*)$/);return!!n&&!!n[1]};for(;t<e.length;){let i=e[t];i===`\\`&&t+1<e.length?t+=2:i===n?(n=void 0,t++):!n&&(i===`"`||i===`'`||i==="`")&&!o()?(n=i,t++):!n&&i===`>`&&e[t+1]===`>`?(a(),t+=2,r=t):t++}return a(),i}function Ze(e,t){let n=0,r=e.length===0,i=()=>e[n]||``,a=()=>{let t=i();return++n,r=n>=e.length,t},o=t=>{throw r?new j(`Unexpected end of selector while parsing selector \`${e}\``):new j(`Error while parsing selector \`${e}\` - unexpected symbol "${i()}" at position ${n}${t?` during ${t}`:``}`)};function s(){for(;!r&&/\s/.test(i());)a()}function c(e){return e>=``||e>=`0`&&e<=`9`||e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`_`||e===`-`}function l(){let e=``;for(s();!r&&c(i());)e+=a();return e}function u(e){let t=a();for(t!==e&&o(`parsing quoted string`);!r&&i()!==e;)i()===`\\`&&a(),t+=a();return i()!==e&&o(`parsing quoted string`),t+=a(),t}function d(){a()!==`/`&&o(`parsing regular expression`);let t=``,n=!1;for(;!r;){if(i()===`\\`)t+=a(),r&&o(`parsing regular expression`);else if(n&&i()===`]`)n=!1;else if(!n&&i()===`[`)n=!0;else if(!n&&i()===`/`)break;t+=a()}a()!==`/`&&o(`parsing regular expression`);let s=``;for(;!r&&i().match(/[dgimsuy]/);)s+=a();try{return new RegExp(t,s)}catch(t){throw new j(`Error while parsing selector \`${e}\`: ${t.message}`)}}function f(){let e=``;return s(),e=i()===`'`||i()===`"`?u(i()).slice(1,-1):l(),e||o(`parsing property path`),e}function p(){s();let e=``;return r||(e+=a()),!r&&e!==`=`&&(e+=a()),[`=`,`*=`,`^=`,`$=`,`|=`,`~=`].includes(e)||o(`parsing operator`),e}function m(){a();let t=[];for(t.push(f()),s();i()===`.`;)a(),t.push(f()),s();if(i()===`]`)return a(),{name:t.join(`.`),jsonPath:t,op:`<truthy>`,value:null,caseSensitive:!1};let n=p(),l,m=!0;if(s(),i()===`/`){if(n!==`=`)throw new j(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with regular expression`);l=d()}else if(i()===`'`||i()===`"`)l=u(i()).slice(1,-1),s(),i()===`i`||i()===`I`?(m=!1,a()):(i()===`s`||i()===`S`)&&(m=!0,a());else{for(l=``;!r&&(c(i())||i()===`+`||i()===`.`);)l+=a();l===`true`?l=!0:l===`false`&&(l=!1)}if(s(),i()!==`]`&&o(`parsing attribute value`),a(),n!==`=`&&typeof l!=`string`)throw new j(`Error while parsing selector \`${e}\` - cannot use ${n} in attribute with non-string matching value - ${l}`);return{name:t.join(`.`),jsonPath:t,op:n,value:l,caseSensitive:m}}let h={name:``,attributes:[]};for(h.name=l(),s();i()===`[`;)h.attributes.push(m()),s();if(r||o(void 0),!h.name&&!h.attributes.length)throw new j(`Error while parsing selector \`${e}\` - selector cannot be empty`);return h}function Qe(e,t=`'`){let n=JSON.stringify(e),r=n.substring(1,n.length-1).replace(/\\"/g,`"`);if(t===`'`)return t+r.replace(/'/g,`\\'`)+t;if(t===`"`)return t+r.replace(/"/g,`\\"`)+t;if(t==="`")return t+r.replace(/`/g,"`")+t;throw Error(`Invalid escape char`)}function N(e){let t=``;for(let n=0;n<e.length;n++)t+=et(e,n);return t}function $e(e){return`"${N(e).replace(/\\ /g,` `)}"`}function et(e,t){let n=e.charCodeAt(t);return n===0?`�`:n>=1&&n<=31||n>=48&&n<=57&&(t===0||t===1&&e.charCodeAt(0)===45)?`\\${n.toString(16)} `:t===0&&n===45&&e.length===1?`\\${e.charAt(t)}`:n>=128||n===45||n===95||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122?e.charAt(t):`\\${e.charAt(t)}`}function P(e){return e.replace(/[\u200b\u00ad]/g,``).trim().replace(/\s+/g,` `)}function tt(e){return e.replace(/(^|[^\\])(\\\\)*\\(['"`])/g,`$1$2$3`)}function nt(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function F(e,t){return typeof e==`string`?`${JSON.stringify(e)}${t?`s`:`i`}`:nt(e)}function I(e,t){return typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"${t?`s`:`i`}`:nt(e)}function rt(e,t,n=``){if(e.length<=t)return e;let r=[...e];return r.length>t?r.slice(0,t-n.length).join(``)+n:r.join(``)}function it(e,t){return rt(e,t,`…`)}function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function L(e){if(e.parentElement)return e.parentElement;if(e.parentNode&&e.parentNode.nodeType===11&&e.parentNode.host)return e.parentNode.host}function ot(e){let t=e;for(;t.parentNode;)t=t.parentNode;if(t.nodeType===11||t.nodeType===9)return t}function st(e){for(;e.parentElement;)e=e.parentElement;return L(e)}function ct(e,t){for(;e;){let n=e.closest(t);if(n)return n;e=st(e)}}function R(e,t){return e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,t):void 0}function lt(e,t){if(t??=R(e),!t)return!0;if(Element.prototype.checkVisibility&&Q.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 ut(e){let t=R(e);if(!t)return!0;if(t.display===`contents`){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&ut(t)||t.nodeType===3&&dt(t))return!0;return!1}if(!lt(e,t))return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0}function dt(e){let t=e.ownerDocument.createRange();t.selectNode(e);let n=t.getBoundingClientRect();return n.width>0&&n.height>0}function z(e){return e instanceof HTMLFormElement?`FORM`:e.tagName.toUpperCase()}function ft(e){return e.hasAttribute(`aria-label`)||e.hasAttribute(`aria-labelledby`)}const pt=`article:not([role]), aside:not([role]), main:not([role]), nav:not([role]), section:not([role]), [role=article], [role=complementary], [role=main], [role=navigation], [role=region]`,mt=new Map([[`aria-atomic`,void 0],[`aria-busy`,void 0],[`aria-controls`,void 0],[`aria-current`,void 0],[`aria-describedby`,void 0],[`aria-details`,void 0],[`aria-dropeffect`,void 0],[`aria-flowto`,void 0],[`aria-grabbed`,void 0],[`aria-hidden`,void 0],[`aria-keyshortcuts`,void 0],[`aria-label`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-labelledby`,new Set([`caption`,`code`,`deletion`,`emphasis`,`generic`,`insertion`,`paragraph`,`presentation`,`strong`,`subscript`,`superscript`])],[`aria-live`,void 0],[`aria-owns`,void 0],[`aria-relevant`,void 0],[`aria-roledescription`,new Set([`generic`])]]);function ht(e,t){return[...mt].some(([n,r])=>!r?.has(t||``)&&e.hasAttribute(n))}function gt(e){return!Number.isNaN(Number(String(e.getAttribute(`tabindex`))))}function _t(e){return!nn(e)&&(vt(e)||gt(e))}function vt(e){let t=z(e);return[`BUTTON`,`DETAILS`,`SELECT`,`TEXTAREA`].includes(t)?!0:t===`A`||t===`AREA`?e.hasAttribute(`href`):t===`INPUT`&&!e.hidden}const yt={A:e=>e.hasAttribute(`href`)?`link`:null,AREA:e=>e.hasAttribute(`href`)?`link`:null,ARTICLE:()=>`article`,ASIDE:()=>`complementary`,BLOCKQUOTE:()=>`blockquote`,BUTTON:()=>`button`,CAPTION:()=>`caption`,CODE:()=>`code`,DATALIST:()=>`listbox`,DD:()=>`definition`,DEL:()=>`deletion`,DETAILS:()=>`group`,DFN:()=>`term`,DIALOG:()=>`dialog`,DT:()=>`term`,EM:()=>`emphasis`,FIELDSET:()=>`group`,FIGURE:()=>`figure`,FOOTER:e=>ct(e,pt)?null:`contentinfo`,FORM:e=>ft(e)?`form`:null,H1:()=>`heading`,H2:()=>`heading`,H3:()=>`heading`,H4:()=>`heading`,H5:()=>`heading`,H6:()=>`heading`,HEADER:e=>ct(e,pt)?null:`banner`,HR:()=>`separator`,HTML:()=>`document`,IMG:e=>e.getAttribute(`alt`)===``&&!e.getAttribute(`title`)&&!ht(e)&&!gt(e)?`presentation`:`img`,INPUT:e=>{let t=e.type.toLowerCase();if(t===`search`)return e.hasAttribute(`list`)?`combobox`:`searchbox`;if([`email`,`tel`,`text`,`url`,``].includes(t)){let t=H(e,e.getAttribute(`list`))[0];return t&&z(t)===`DATALIST`?`combobox`:`textbox`}return t===`hidden`?``:t===`file`?`button`:{button:`button`,checkbox:`checkbox`,image:`button`,number:`spinbutton`,radio:`radio`,range:`slider`,reset:`button`,submit:`button`}[t]||`textbox`},INS:()=>`insertion`,LI:()=>`listitem`,MAIN:()=>`main`,MARK:()=>`mark`,MATH:()=>`math`,MENU:()=>`list`,METER:()=>`meter`,NAV:()=>`navigation`,OL:()=>`list`,OPTGROUP:()=>`group`,OPTION:()=>`option`,OUTPUT:()=>`status`,P:()=>`paragraph`,PROGRESS:()=>`progressbar`,SECTION:e=>ft(e)?`region`:null,SELECT:e=>e.hasAttribute(`multiple`)||e.size>1?`listbox`:`combobox`,STRONG:()=>`strong`,SUB:()=>`subscript`,SUP:()=>`superscript`,SVG:()=>`img`,TABLE:()=>`table`,TBODY:()=>`rowgroup`,TD:e=>{let t=ct(e,`table`),n=t?Tt(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},TEXTAREA:()=>`textbox`,TFOOT:()=>`rowgroup`,TH:e=>{if(e.getAttribute(`scope`)===`col`)return`columnheader`;if(e.getAttribute(`scope`)===`row`)return`rowheader`;let t=ct(e,`table`),n=t?Tt(t):``;return n===`grid`||n===`treegrid`?`gridcell`:`cell`},THEAD:()=>`rowgroup`,TIME:()=>`time`,TR:()=>`row`,UL:()=>`list`},bt={DD:[`DL`,`DIV`],DIV:[`DL`],DT:[`DL`,`DIV`],LI:[`OL`,`UL`],TBODY:[`TABLE`],TD:[`TR`],TFOOT:[`TABLE`],TH:[`TR`],THEAD:[`TABLE`],TR:[`THEAD`,`TBODY`,`TFOOT`,`TABLE`]};function xt(e){let t=yt[z(e)]?.call(yt,e)||``;if(!t)return null;let n=e;for(;n;){let e=L(n),t=bt[z(n)];if(!t||!e||!t.includes(z(e)))break;let r=Tt(e);if((r===`none`||r===`presentation`)&&!Et(e,r))return r;n=e}return t}const St=`alert.alertdialog.application.article.banner.blockquote.button.caption.cell.checkbox.code.columnheader.combobox.command.complementary.composite.contentinfo.definition.deletion.dialog.directory.document.emphasis.feed.figure.form.generic.grid.gridcell.group.heading.img.input.insertion.landmark.link.list.listbox.listitem.log.main.marquee.math.meter.menu.menubar.menuitem.menuitemcheckbox.menuitemradio.navigation.none.note.option.paragraph.presentation.progressbar.radio.radiogroup.range.region.roletype.row.rowgroup.rowheader.scrollbar.search.searchbox.section.sectionhead.select.separator.slider.spinbutton.status.strong.structure.subscript.superscript.switch.tab.table.tablist.tabpanel.term.textbox.time.timer.toolbar.tooltip.tree.treegrid.treeitem.widget.window`.split(`.`),Ct=[`command`,`composite`,`input`,`landmark`,`range`,`roletype`,`section`,`sectionhead`,`select`,`structure`,`widget`,`window`],wt=St.filter(e=>!Ct.includes(e));function Tt(e){return(e.getAttribute(`role`)||``).split(` `).map(e=>e.trim()).find(e=>wt.includes(e))||null}function Et(e,t){return ht(e,t)||_t(e)}function B(e){let t=Tt(e);if(!t)return xt(e);if(t===`none`||t===`presentation`){let t=xt(e);if(Et(e,t))return t}return t}function Dt(e){return e===null?void 0:e.toLowerCase()===`true`}function Ot(e){return[`STYLE`,`SCRIPT`,`NOSCRIPT`,`TEMPLATE`].includes(z(e))}function V(e){if(Ot(e))return!0;let t=R(e),n=e.nodeName===`SLOT`;if(t?.display===`contents`&&!n){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType===1&&!V(t)||t.nodeType===3&&dt(t))return!1;return!0}return!(e.nodeName===`OPTION`&&e.closest(`select`))&&!n&&!lt(e,t)||kt(e)}function kt(e){let t=dn?.get(e);if(t===void 0){if(t=!1,e.parentElement&&e.parentElement.shadowRoot&&!e.assignedSlot&&(t=!0),!t){let n=R(e);t=!n||n.display===`none`||Dt(e.getAttribute(`aria-hidden`))===!0}if(!t){let n=L(e);n&&(t=kt(n))}dn?.set(e,t)}return t}function H(e,t){if(!t)return[];let n=ot(e);if(!n)return[];try{let e=t.split(` `).filter(e=>!!e),r=new Set;for(let t of e){let e=n.querySelector(`#${CSS.escape(t)}`);e&&r.add(e)}return[...r]}catch{return[]}}function U(e){return e.trim()}function At(e){return e.split(`\xA0`).map(e=>e.replace(/\r\n/g,`
|
|
3
|
+
`).replace(/[\u200b\u00ad]/g,``).replace(/\s\s*/g,` `)).join(`\xA0`).trim()}function jt(e,t){let n=[...e.querySelectorAll(t)];for(let r of H(e,e.getAttribute(`aria-owns`)))r.matches(t)&&n.push(r),n.push(...r.querySelectorAll(t));return n}function Mt(e,t){let n=t===`::before`?fn:pn;if(n?.has(e))return n?.get(e)||``;let r=Nt(R(e,t));return n&&n.set(e,r),r}function Nt(e){if(!e)return``;let t=e.content;if(t[0]===`'`&&t[t.length-1]===`'`||t[0]===`"`&&t[t.length-1]===`"`){let n=t.substring(1,t.length-1);return(e.display||`inline`)===`inline`?n:` ${n} `}return``}function Pt(e){let t=e.getAttribute(`aria-labelledby`);return t===null?null:H(e,t)}function Ft(e,t){let n=[`button`,`cell`,`checkbox`,`columnheader`,`gridcell`,`heading`,`link`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`option`,`radio`,`row`,`rowheader`,`switch`,`tab`,`tooltip`,`treeitem`].includes(e),r=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 n||r}function It(e,t){let n=t?cn:sn,r=n?.get(e);return r===void 0&&(r=``,[`caption`,`code`,`definition`,`deletion`,`emphasis`,`generic`,`insertion`,`mark`,`paragraph`,`presentation`,`strong`,`subscript`,`suggestion`,`superscript`,`term`,`time`].includes(B(e)||``)||(r=At(W(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:void 0,embeddedInLabelledBy:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0,embeddedInTargetElement:`self`}))),n?.set(e,r)),r}function Lt(e,t){let n=un,r=n?.get(e);return r===void 0&&(r=``,r=e.hasAttribute(`aria-describedby`)?At(H(e,e.getAttribute(`aria-describedby`)).map(e=>W(e,{includeHidden:t,visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:V(e)}})).join(` `)):e.hasAttribute(`aria-description`)?At(e.getAttribute(`aria-description`)||``):At(e.getAttribute(`title`)||``),n?.set(e,r)),r}const Rt=[`application`,`checkbox`,`combobox`,`gridcell`,`listbox`,`radiogroup`,`slider`,`spinbutton`,`textbox`,`tree`,`columnheader`,`rowheader`,`searchbox`,`switch`,`treegrid`];function zt(e){let t=B(e)||``;if(!t||!Rt.includes(t))return`false`;let n=e.getAttribute(`aria-invalid`);return!n||n.trim()===``||n.toLocaleLowerCase()===`false`?`false`:n===`true`||n===`grammar`||n===`spelling`?n:`true`}function Bt(e){return`validity`in e&&e.validity?.valid===!1}function Vt(e){let t=ln,n=ln?.get(e);if(n===void 0){n=``;let r=zt(e)!==`false`,i=Bt(e);(r||i)&&(n=H(e,e.getAttribute(`aria-errormessage`)).map(e=>At(W(e,{visitedElements:new Set,embeddedInDescribedBy:{element:e,hidden:V(e)}}))).join(` `).trim()),t?.set(e,n)}return n}function W(e,t){if(t.visitedElements.has(e))return``;let n={...t,embeddedInTargetElement:t.embeddedInTargetElement===`self`?`descendant`:t.embeddedInTargetElement};if(!t.includeHidden){let n=!!t.embeddedInLabelledBy?.hidden||!!t.embeddedInDescribedBy?.hidden||!!t.embeddedInNativeTextAlternative?.hidden||!!t.embeddedInLabel?.hidden;if(Ot(e)||!n&&V(e))return t.visitedElements.add(e),``}let r=Pt(e);if(!t.embeddedInLabelledBy){let e=(r||[]).map(e=>W(e,{...t,embeddedInLabelledBy:{element:e,hidden:V(e)},embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0,embeddedInLabel:void 0,embeddedInNativeTextAlternative:void 0})).join(` `);if(e)return e}let i=B(e)||``,a=z(e);if(t.embeddedInLabel||t.embeddedInLabelledBy||t.embeddedInTargetElement===`descendant`){let o=[...e.labels||[]].includes(e),s=(r||[]).includes(e);if(!o&&!s){if(i===`textbox`)return t.visitedElements.add(e),a===`INPUT`||a===`TEXTAREA`?e.value:e.textContent||``;if([`combobox`,`listbox`].includes(i)){t.visitedElements.add(e);let r;if(a===`SELECT`)r=[...e.selectedOptions],!r.length&&e.options.length&&r.push(e.options[0]);else{let t=i===`combobox`?jt(e,`*`).find(e=>B(e)===`listbox`):e;r=t?jt(t,`[aria-selected="true"]`).filter(e=>B(e)===`option`):[]}return!r.length&&a===`INPUT`?e.value:r.map(e=>W(e,n)).join(` `)}if([`progressbar`,`scrollbar`,`slider`,`spinbutton`,`meter`].includes(i))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(i))return t.visitedElements.add(e),``}}let o=e.getAttribute(`aria-label`)||``;if(U(o))return t.visitedElements.add(e),o;if(![`presentation`,`none`].includes(i)){if(a===`INPUT`&&[`button`,`submit`,`reset`].includes(e.type)){t.visitedElements.add(e);let n=e.value||``;return U(n)?n:e.type===`submit`?`Submit`:e.type===`reset`?`Reset`:e.getAttribute(`title`)||``}if(a===`INPUT`&&e.type===`image`){t.visitedElements.add(e);let n=e.labels||[];if(n.length&&!t.embeddedInLabelledBy)return on(n,t);let r=e.getAttribute(`alt`)||``;if(U(r))return r;let i=e.getAttribute(`title`)||``;return U(i)?i:`Submit`}if(!r&&a===`BUTTON`){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return on(n,t)}if(!r&&a===`OUTPUT`){t.visitedElements.add(e);let n=e.labels||[];return n.length?on(n,t):e.getAttribute(`title`)||``}if(!r&&(a===`TEXTAREA`||a===`SELECT`||a===`INPUT`)){t.visitedElements.add(e);let n=e.labels||[];if(n.length)return on(n,t);let r=a===`INPUT`&&[`text`,`password`,`search`,`tel`,`email`,`url`].includes(e.type)||a===`TEXTAREA`,i=e.getAttribute(`placeholder`)||``,o=e.getAttribute(`title`)||``;return!r||o?o:i}if(!r&&a===`FIELDSET`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`LEGEND`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});return e.getAttribute(`title`)||``}if(!r&&a===`FIGURE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`FIGCAPTION`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});return e.getAttribute(`title`)||``}if(a===`IMG`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return U(n)?n:e.getAttribute(`title`)||``}if(a===`TABLE`){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`CAPTION`)return W(t,{...n,embeddedInNativeTextAlternative:{element:t,hidden:V(t)}});let r=e.getAttribute(`summary`)||``;if(r)return r}if(a===`AREA`){t.visitedElements.add(e);let n=e.getAttribute(`alt`)||``;return U(n)?n:e.getAttribute(`title`)||``}if(a===`SVG`||e.ownerSVGElement){t.visitedElements.add(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(z(t)===`TITLE`&&t.ownerSVGElement)return W(t,{...n,embeddedInLabelledBy:{element:t,hidden:V(t)}})}if(e.ownerSVGElement&&a===`A`){let n=e.getAttribute(`xlink:title`)||``;if(U(n))return t.visitedElements.add(e),n}}let s=a===`SUMMARY`&&![`presentation`,`none`].includes(i);if(Ft(i,t.embeddedInTargetElement===`descendant`)||s||t.embeddedInLabelledBy||t.embeddedInDescribedBy||t.embeddedInLabel||t.embeddedInNativeTextAlternative){t.visitedElements.add(e);let r=Ht(e,n);if(t.embeddedInTargetElement===`self`?U(r):r)return r}if(![`presentation`,`none`].includes(i)||a===`IFRAME`){t.visitedElements.add(e);let n=e.getAttribute(`title`)||``;if(U(n))return n}return t.visitedElements.add(e),``}function Ht(e,t){let n=[],r=(e,r)=>{if(!(r&&e.assignedSlot)){if(e.nodeType===1){let r=R(e)?.display||`inline`,i=W(e,t);(r!==`inline`||e.nodeName===`BR`)&&(i=` `+i+` `),n.push(i)}else e.nodeType===3&&n.push(e.textContent||``)}};n.push(Mt(e,`::before`));let i=e.nodeName===`SLOT`?e.assignedNodes():[];if(i.length)for(let e of i)r(e,!1);else{for(let t=e.firstChild;t;t=t.nextSibling)r(t,!0);if(e.shadowRoot)for(let t=e.shadowRoot.firstChild;t;t=t.nextSibling)r(t,!0);for(let t of H(e,e.getAttribute(`aria-owns`)))r(t,!0)}return n.push(Mt(e,`::after`)),n.join(``)}const Ut=[`gridcell`,`option`,`row`,`tab`,`rowheader`,`columnheader`,`treeitem`];function Wt(e){return z(e)===`OPTION`?e.selected:Ut.includes(B(e)||``)?Dt(e.getAttribute(`aria-selected`))===!0:!1}const Gt=[`checkbox`,`menuitemcheckbox`,`option`,`radio`,`switch`,`menuitemradio`,`treeitem`];function Kt(e){let t=qt(e);return t!==`error`&&t}function qt(e,t){let n=z(e);if(n===`INPUT`&&e.indeterminate)return`mixed`;if(n===`INPUT`&&[`checkbox`,`radio`].includes(e.type))return e.checked;if(Gt.includes(B(e)||``)){let t=e.getAttribute(`aria-checked`);return t===`true`||t===`mixed`&&`mixed`}return`error`}const Jt=[`button`];function Yt(e){if(Jt.includes(B(e)||``)){let t=e.getAttribute(`aria-pressed`);if(t===`true`)return!0;if(t===`mixed`)return`mixed`}return!1}const Xt=[`application`,`button`,`checkbox`,`combobox`,`gridcell`,`link`,`listbox`,`menuitem`,`row`,`rowheader`,`tab`,`treeitem`,`columnheader`,`menuitemcheckbox`,`menuitemradio`,`rowheader`,`switch`];function Zt(e){if(z(e)===`DETAILS`)return e.open;if(Xt.includes(B(e)||``)){let t=e.getAttribute(`aria-expanded`);return t===null?`none`:t===`true`}return`none`}const Qt=[`heading`,`listitem`,`row`,`treeitem`];function $t(e){let t={H1:1,H2:2,H3:3,H4:4,H5:5,H6:6}[z(e)];if(t)return t;if(Qt.includes(B(e)||``)){let t=e.getAttribute(`aria-level`),n=t===null?NaN:Number(t);if(Number.isInteger(n)&&n>=1)return n}return 0}const en=`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 tn(e){return nn(e)||an(e)}function nn(e){return[`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`OPTION`,`OPTGROUP`].includes(e.tagName)&&(e.hasAttribute(`disabled`)||rn(e))}function rn(e){let t=e?.closest(`FIELDSET[DISABLED]`);if(!t)return!1;let n=t.querySelector(`:scope > LEGEND`);return!n||!n.contains(e)}function an(e){if(!e)return!1;if(en.includes(B(e)||``)){let t=(e.getAttribute(`aria-disabled`)||``).toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return an(L(e))}function on(e,t){return[...e].map(e=>W(e,{...t,embeddedInLabel:{element:e,hidden:V(e)},embeddedInNativeTextAlternative:void 0,embeddedInLabelledBy:void 0,embeddedInDescribedBy:void 0,embeddedInTargetElement:void 0})).filter(e=>!!e).join(` `)}let sn,cn,ln,un,dn,fn,pn,mn=0;function hn(){++mn,sn??=new Map,cn??=new Map,un??=new Map,ln??=new Map,dn??=new Map,fn??=new Map,pn??=new Map}function gn(){--mn||(sn=void 0,cn=void 0,un=void 0,ln=void 0,dn=void 0,fn=void 0,pn=void 0)}function _n(e,t){let n=typeof e==`string`&&!t.caseSensitive?e.toUpperCase():e,r=typeof t.value==`string`&&!t.caseSensitive?t.value.toUpperCase():t.value;return t.op===`<truthy>`?!!n:t.op===`=`?r instanceof RegExp?typeof n==`string`&&!!n.match(r):n===r:typeof n!=`string`||typeof r!=`string`?!1:t.op===`*=`?n.includes(r):t.op===`^=`?n.startsWith(r):t.op===`$=`?n.endsWith(r):t.op===`|=`?n===r||n.startsWith(`${r}-`):t.op===`~=`&&n.split(` `).includes(r)}function vn(e){let t=e.ownerDocument;return e.nodeName===`SCRIPT`||e.nodeName===`NOSCRIPT`||e.nodeName===`STYLE`||t.head&&t.head.contains(e)}function G(e,t){let n=e.get(t);if(n===void 0){if(n={full:``,normalized:``,immediate:[]},!vn(t)){let r=``;if(t instanceof HTMLInputElement&&(t.type===`submit`||t.type===`button`))n={full:t.value,normalized:P(t.value),immediate:[t.value]};else{for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.TEXT_NODE?(n.full+=i.nodeValue||``,r+=i.nodeValue||``):(r&&n.immediate.push(r),r=``,i.nodeType===Node.ELEMENT_NODE&&(n.full+=G(e,i).full));r&&n.immediate.push(r),t.shadowRoot&&(n.full+=G(e,t.shadowRoot).full),n.full&&(n.normalized=P(n.full))}}e.set(t,n)}return n}function yn(e,t,n){if(vn(t)||!n(G(e,t)))return`none`;for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===Node.ELEMENT_NODE&&n(G(e,r)))return`selfAndChildren`;return t.shadowRoot&&n(G(e,t.shadowRoot))?`selfAndChildren`:`self`}function bn(e,t){let n=Pt(t);if(n)return n.map(t=>G(e,t));let r=t.getAttribute(`aria-label`);if(r!==null&&r.trim())return[{full:r,normalized:P(r),immediate:[r]}];let i=t.nodeName===`INPUT`&&t.type!==`hidden`;if([`BUTTON`,`METER`,`OUTPUT`,`PROGRESS`,`SELECT`,`TEXTAREA`].includes(t.nodeName)||i){let n=t.labels;if(n)return[...n].map(t=>G(e,t))}return[]}const xn=[`selected`,`checked`,`pressed`,`expanded`,`level`,`disabled`,`name`,`include-hidden`];xn.sort();function Sn(e,t,n){if(!t.includes(n))throw Error(`"${e}" attribute is only supported for roles: ${t.slice().sort().map(e=>`"${e}"`).join(`, `)}`)}function K(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 q(e,t){if(!t.includes(e.op))throw Error(`"${e.name}" does not support "${e.op}" matcher`)}function Cn(e,t){let n={role:t};for(let r of e)switch(r.name){case`checked`:Sn(r.name,Gt,t),K(r,[!0,!1,`mixed`]),q(r,[`<truthy>`,`=`]),n.checked=r.op===`<truthy>`||r.value;break;case`pressed`:Sn(r.name,Jt,t),K(r,[!0,!1,`mixed`]),q(r,[`<truthy>`,`=`]),n.pressed=r.op===`<truthy>`||r.value;break;case`selected`:Sn(r.name,Ut,t),K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.selected=r.op===`<truthy>`||r.value;break;case`expanded`:Sn(r.name,Xt,t),K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.expanded=r.op===`<truthy>`||r.value;break;case`level`:if(Sn(r.name,Qt,t),typeof r.value==`string`&&(r.value=+r.value),r.op!==`=`||typeof r.value!=`number`||Number.isNaN(r.value))throw Error(`"level" attribute must be compared to a number`);n.level=r.value;break;case`disabled`:K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.disabled=r.op===`<truthy>`||r.value;break;case`name`:if(r.op===`<truthy>`)throw Error(`"name" attribute must have a value`);if(typeof r.value!=`string`&&!(r.value instanceof RegExp))throw TypeError(`"name" attribute must be a string or a regular expression`);n.name=r.value,n.nameOp=r.op,n.exact=r.caseSensitive;break;case`include-hidden`:K(r,[!0,!1]),q(r,[`<truthy>`,`=`]),n.includeHidden=r.op===`<truthy>`||r.value;break;default:throw Error(`Unknown attribute "${r.name}", must be one of ${xn.map(e=>`"${e}"`).join(`, `)}.`)}return n}function wn(e,t,n){let r=[],i=e=>{if(B(e)===t.role&&(t.selected===void 0||Wt(e)===t.selected)&&(t.checked===void 0||Kt(e)===t.checked)&&(t.pressed===void 0||Yt(e)===t.pressed)&&(t.expanded===void 0||Zt(e)===t.expanded)&&(t.level===void 0||$t(e)===t.level)&&(t.disabled===void 0||tn(e)===t.disabled)&&(t.includeHidden||!V(e))){if(t.name!==void 0){let r=P(It(e,!!t.includeHidden));if(typeof t.name==`string`&&(t.name=P(t.name)),n&&!t.exact&&t.nameOp===`=`&&(t.nameOp=`*=`),!_n(r,{op:t.nameOp||`=`,value:t.name,caseSensitive:!!t.exact}))return}r.push(e)}},a=e=>{let t=[];e.shadowRoot&&t.push(e.shadowRoot);for(let n of e.querySelectorAll(`*`))i(n),n.shadowRoot&&t.push(n.shadowRoot);t.forEach(a)};return a(e),r}function Tn(e){return{queryAll:(t,n)=>{let r=Ze(n),i=r.name.toLowerCase();if(!i)throw Error(`Role must not be empty`);let a=Cn(r.attributes,i);hn();try{return wn(t,a,e)}finally{gn()}}}}function En(e,t,n=!1){return Dn(e,t,n)[0]}function Dn(e,t,n=!1,r=20,i){try{return J(new kn[e](i),qe(t),n,r)}catch{return[t]}}function J(e,t,n=!1,r=20){let i=[...t.parts];for(let e=0;e<i.length-1;e++)if(i[e].name===`nth`&&i[e+1].name===`internal:control`&&i[e+1].body===`enter-frame`){let[t]=i.splice(e,1);i.splice(e+1,0,t)}let a=[],o=n?`frame-locator`:`page`;for(let t=0;t<i.length;t++){let n=i[t],s=o;if(o=`locator`,n.name===`nth`){n.body===`0`?a.push([e.generateLocator(s,`first`,``),e.generateLocator(s,`nth`,`0`)]):n.body===`-1`?a.push([e.generateLocator(s,`last`,``),e.generateLocator(s,`nth`,`-1`)]):a.push([e.generateLocator(s,`nth`,n.body)]);continue}if(n.name===`internal:text`){let{exact:t,text:r}=Y(n.body);a.push([e.generateLocator(s,`text`,r,{exact:t})]);continue}if(n.name===`internal:has-text`){let{exact:t,text:r}=Y(n.body);if(!t){a.push([e.generateLocator(s,`has-text`,r,{exact:t})]);continue}}if(n.name===`internal:has-not-text`){let{exact:t,text:r}=Y(n.body);if(!t){a.push([e.generateLocator(s,`has-not-text`,r,{exact:t})]);continue}}if(n.name===`internal:has`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`has`,t)));continue}if(n.name===`internal:has-not`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`hasNot`,t)));continue}if(n.name===`internal:and`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`and`,t)));continue}if(n.name===`internal:or`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`or`,t)));continue}if(n.name===`internal:chain`){let t=J(e,n.body.parsed,!1,r);a.push(t.map(t=>e.generateLocator(s,`chain`,t)));continue}if(n.name===`internal:label`){let{exact:t,text:r}=Y(n.body);a.push([e.generateLocator(s,`label`,r,{exact:t})]);continue}if(n.name===`internal:role`){let t=Ze(n.body),r={attrs:[]};for(let e of t.attributes)e.name===`name`?(r.exact=e.caseSensitive,r.name=e.value):(e.name===`level`&&typeof e.value==`string`&&(e.value=+e.value),r.attrs.push({name:e.name===`include-hidden`?`includeHidden`:e.name,value:e.value}));a.push([e.generateLocator(s,`role`,t.name,r)]);continue}if(n.name===`internal:testid`){let{value:t}=Ze(n.body).attributes[0];a.push([e.generateLocator(s,`test-id`,t)]);continue}if(n.name===`internal:attr`){let{name:t,value:r,caseSensitive:i}=Ze(n.body).attributes[0],o=r,c=!!i;if(t===`placeholder`){a.push([e.generateLocator(s,`placeholder`,o,{exact:c})]);continue}if(t===`alt`){a.push([e.generateLocator(s,`alt`,o,{exact:c})]);continue}if(t===`title`){a.push([e.generateLocator(s,`title`,o,{exact:c})]);continue}}let c=`default`,l=i[t+1];l&&l.name===`internal:control`&&l.body===`enter-frame`&&(c=`frame`,o=`frame-locator`,t++);let u=M({parts:[n]}),d=e.generateLocator(s,c,u);if(c==="default"&&l&&[`internal:has-text`,`internal:has-not-text`].includes(l.name)){let{exact:n,text:r}=Y(l.body);if(!n){let i=e.generateLocator(`locator`,l.name===`internal:has-text`?`has-text`:`has-not-text`,r,{exact:n}),o={};l.name===`internal:has-text`?o.hasText=r:o.hasNotText=r;let c=e.generateLocator(s,`default`,u,o);a.push([e.chainLocators([d,i]),c]),t++;continue}}let f;if([`xpath`,`css`].includes(n.name)){let t=M({parts:[n]},!0);f=e.generateLocator(s,c,t)}a.push([d,f].filter(Boolean))}return On(e,a,r)}function On(e,t,n){let r=t.map(()=>``),i=[],a=o=>{if(o===t.length)return i.push(e.chainLocators(r)),r.length<n;for(let e of t[o])if(r[o]=e,!a(o+1))return!1;return!0};return a(0),i}function Y(e){let t=!1,n=e.match(/^\/(.*)\/([igm]*)$/);return n?{text:new RegExp(n[1],n[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})}const kn={javascript:class{constructor(e){this.preferredQuote=e}generateLocator(e,t,n,r={}){switch(t){case`default`:return r.hasText===void 0?r.hasNotText===void 0?`locator(${this.quote(n)})`:`locator(${this.quote(n)}, { hasNotText: ${this.toHasText(r.hasNotText)} })`:`locator(${this.quote(n)}, { hasText: ${this.toHasText(r.hasText)} })`;case`frame`:return`frameLocator(${this.quote(n)})`;case`nth`:return`nth(${n})`;case`first`:return`first()`;case`last`:return`last()`;case`role`:{let e=[];An(r.name)?e.push(`name: ${this.regexToSourceString(r.name)}`):typeof r.name==`string`&&(e.push(`name: ${this.quote(r.name)}`),r.exact!=null&&Q.options.exact!==r.exact&&e.push(`exact: ${r.exact}`));for(let{name:t,value:n}of r.attrs)e.push(`${t}: ${typeof n==`string`?this.quote(n):n}`);let t=e.length?`, { ${e.join(`, `)} }`:``;return`getByRole(${this.quote(n)}${t})`}case`has-text`:return`filter({ hasText: ${this.toHasText(n)} })`;case`has-not-text`:return`filter({ hasNotText: ${this.toHasText(n)} })`;case`has`:return`filter({ has: ${n} })`;case`hasNot`:return`filter({ hasNot: ${n} })`;case`and`:return`and(${n})`;case`or`:return`or(${n})`;case`chain`:return`locator(${n})`;case`test-id`:{let e=this.toTestIdValue(n);return e.startsWith(`'__vitest_`)&&e.endsWith(`__'`)?`page`:`getByTestId(${e})`}case`text`:return this.toCallWithExact(`getByText`,n,!!r.exact);case`alt`:return this.toCallWithExact(`getByAltText`,n,!!r.exact);case`placeholder`:return this.toCallWithExact(`getByPlaceholder`,n,!!r.exact);case`label`:return this.toCallWithExact(`getByLabel`,n,!!r.exact);case`title`:return this.toCallWithExact(`getByTitle`,n,!!r.exact);default:throw Error(`Unknown selector kind ${t}`)}}chainLocators(e){return e.join(`.`)}regexToSourceString(e){return tt(String(e))}toCallWithExact(e,t,n){return An(t)?`${e}(${this.regexToSourceString(t)})`:n!=null&&Q.options.exact!==n?`${e}(${this.quote(t)}, { exact: ${n} })`:`${e}(${this.quote(t)})`}toHasText(e){return An(e)?this.regexToSourceString(e):this.quote(e)}toTestIdValue(e){return An(e)?this.regexToSourceString(e):this.quote(e)}quote(e){return Qe(e,this.preferredQuote??`'`)}}};function An(e){return e instanceof RegExp}const jn=new Map,Mn=new Map,Nn=1e4;function Pn(e,t,n){e._evaluator.begin(),hn();try{return Hn(In(e,t,n)||Bn(e,t,n))}finally{jn.clear(),Mn.clear(),gn(),e._evaluator.end()}}function Fn(e){return e.filter(e=>e[0].selector[0]!==`/`)}function In(e,t,n){if(t.ownerDocument.documentElement===t)return[{engine:`css`,selector:`html`,score:1}];let r=(r,a)=>{let o=r===t,s=a?Rn(e,r,r===t):[];r!==t&&(s=Fn(s));let c=Ln(e,r,n).map(e=>[e]),l=Un(e,t.ownerDocument,r,[...s,...c],o);s=Fn(s);let u=t=>{let n=a&&!t.length,s=[...t,...c].filter(e=>!l||X(e)<X(l)),u=s[0];if(u)for(let t=L(r);t;t=L(t)){let a=i(t,n);if(!a||l&&X([...a,...u])>=X(l))continue;if(u=Un(e,t,r,s,o),!u)return;let c=[...a,...u];(!l||X(c)<X(l))&&(l=c)}};return u(s),r===t&&s.length&&u([]),l},i=(e,t)=>{let n=t?jn:Mn,i=n.get(e);return i===void 0&&(i=r(e,t),n.set(e,i)),i};return r(t,!n.noText)}function Ln(e,t,n){let r=[];for(let e of[`data-testid`,`data-test-id`,`data-test`])e!==n.testIdAttributeName&&t.getAttribute(e)&&r.push({engine:`css`,selector:`[${e}=${$e(t.getAttribute(e))}]`,score:2});if(!n.noCSSId){let e=t.getAttribute(`id`);e&&!Wn(e)&&r.push({engine:`css`,selector:zn(e),score:500})}if(r.push({engine:`css`,selector:N(t.nodeName.toLowerCase()),score:530}),t.nodeName===`IFRAME`){for(let e of[`name`,`title`])t.getAttribute(e)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[${e}=${$e(t.getAttribute(e))}]`,score:10});return t.getAttribute(n.testIdAttributeName)&&r.push({engine:`css`,selector:`[${n.testIdAttributeName}=${$e(t.getAttribute(n.testIdAttributeName))}]`,score:1}),Vn([r]),r}if(t.getAttribute(n.testIdAttributeName)&&r.push({engine:`internal:testid`,selector:`[${n.testIdAttributeName}=${I(t.getAttribute(n.testIdAttributeName),!0)}]`,score:1}),t.nodeName===`INPUT`||t.nodeName===`TEXTAREA`){let e=t;if(e.placeholder){r.push({engine:`internal:attr`,selector:`[placeholder=${I(e.placeholder,!0)}]`,score:105});for(let t of Z(e.placeholder))r.push({engine:`internal:attr`,selector:`[placeholder=${I(t.text,!1)}]`,score:100-t.scoreBouns})}}let i=bn(e._evaluator._cacheText,t);for(let e of i){let t=e.normalized;r.push({engine:`internal:label`,selector:F(t,!0),score:125});for(let e of Z(t))r.push({engine:`internal:label`,selector:F(e.text,!1),score:120-e.scoreBouns})}let a=B(t);return a&&![`none`,`presentation`].includes(a)&&r.push({engine:`internal:role`,selector:a,score:510}),t.getAttribute(`name`)&&[`BUTTON`,`FORM`,`FIELDSET`,`FRAME`,`IFRAME`,`INPUT`,`KEYGEN`,`OBJECT`,`OUTPUT`,`SELECT`,`TEXTAREA`,`MAP`,`META`,`PARAM`].includes(t.nodeName)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[name=${$e(t.getAttribute(`name`))}]`,score:520}),[`INPUT`,`TEXTAREA`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&t.getAttribute(`type`)&&r.push({engine:`css`,selector:`${N(t.nodeName.toLowerCase())}[type=${$e(t.getAttribute(`type`))}]`,score:520}),[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.nodeName)&&t.getAttribute(`type`)!==`hidden`&&r.push({engine:`css`,selector:N(t.nodeName.toLowerCase()),score:521}),Vn([r]),r}function Rn(e,t,n){if(t.nodeName===`SELECT`)return[];let r=[],i=t.getAttribute(`title`);if(i){r.push([{engine:`internal:attr`,selector:`[title=${I(i,!0)}]`,score:205}]);for(let e of Z(i))r.push([{engine:`internal:attr`,selector:`[title=${I(e.text,!1)}]`,score:200-e.scoreBouns}])}let a=t.getAttribute(`alt`);if(a&&[`APPLET`,`AREA`,`IMG`,`INPUT`].includes(t.nodeName)){r.push([{engine:`internal:attr`,selector:`[alt=${I(a,!0)}]`,score:165}]);for(let e of Z(a))r.push([{engine:`internal:attr`,selector:`[alt=${I(e.text,!1)}]`,score:160-e.scoreBouns}])}let o=G(e._evaluator._cacheText,t).normalized;if(o){let e=Z(o);if(n){o.length<=80&&r.push([{engine:`internal:text`,selector:F(o,!0),score:185}]);for(let t of e)r.push([{engine:`internal:text`,selector:F(t.text,!1),score:180-t.scoreBouns}])}let i={engine:`css`,selector:N(t.nodeName.toLowerCase()),score:530};for(let t of e)r.push([i,{engine:`internal:has-text`,selector:F(t.text,!1),score:180-t.scoreBouns}]);if(o.length<=80){let e=RegExp(`^${at(o)}$`);r.push([i,{engine:`internal:has-text`,selector:F(e,!1),score:250}])}}let s=B(t);if(s&&![`none`,`presentation`].includes(s)){let e=It(t,!1);if(e){r.push([{engine:`internal:role`,selector:`${s}[name=${I(e,!0)}]`,score:145}]);for(let t of Z(e))r.push([{engine:`internal:role`,selector:`${s}[name=${I(t.text,!1)}]`,score:140-t.scoreBouns}])}}return Vn(r),r}function zn(e){return/^[a-z][\w\-]+$/i.test(e)?`#${e}`:`[id="${N(e)}"]`}function Bn(e,t,n){let r=t.ownerDocument,i=[];function a(n){let a=i.slice();n&&a.unshift(n);let o=a.join(` > `),s=e.parseSelector(o);return e.querySelector(s,r,!1)===t?o:void 0}function o(n){let i={engine:`css`,selector:n,score:1e7},a=e.parseSelector(n),o=e.querySelectorAll(a,r);return o.length===1?[i]:[i,{engine:`nth`,selector:String(o.indexOf(t)),score:Nn}]}for(let e=t;e&&e!==r;e=L(e)){let t=e.nodeName.toLowerCase(),r=``;if(e.id&&!n.noCSSId){let t=zn(e.id),n=a(t);if(n)return o(n);r=t}let s=e.parentNode,c=[...e.classList];for(let e=0;e<c.length;++e){let t=`.${N(c.slice(0,e+1).join(`.`))}`,n=a(t);if(n)return o(n);!r&&s&&s.querySelectorAll(t).length===1&&(r=t)}if(s){let n=[...s.children],i=n.filter(e=>e.nodeName.toLowerCase()===t).indexOf(e)===0?N(t):`${N(t)}:nth-child(${1+n.indexOf(e)})`,c=a(i);if(c)return o(c);r||=i}else r||=N(t);i.unshift(r)}return o(a())}function Vn(e){for(let t of e)for(let e of t)e.score>50&&e.score<300&&(e.score+=Math.min(10,e.selector.length/10|0))}function Hn(e){let t=[],n=``;for(let{engine:r,selector:i}of e)t.length&&(n!==`css`||r!==`css`||i.startsWith(`:nth-match(`))&&t.push(`>>`),n=r,r===`css`?t.push(i):t.push(`${r}=${i}`);return t.join(` `)}function X(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].score*(e.length-n);return t}function Un(e,t,n,r,i){let a=r.map(e=>({tokens:e,score:X(e)}));a.sort((e,t)=>e.score-t.score);let o=null;for(let{tokens:r}of a){let a=e.parseSelector(Hn(r)),s=e.querySelectorAll(a,t);if(s[0]===n&&s.length===1)return r;let c=s.indexOf(n);if(!i||o||c===-1||s.length>5)continue;let l={engine:`nth`,selector:String(c),score:Nn};o=[...r,l]}return o}function Wn(e){let t,n=0;for(let r=0;r<e.length;++r){let i=e[r],a;if(i!==`-`&&i!==`_`){if(a=i>=`a`&&i<=`z`?`lower`:i>=`A`&&i<=`Z`?`upper`:i>=`0`&&i<=`9`?`digit`:`other`,a===`lower`&&t===`upper`){t=a;continue}t&&t!==a&&++n,t=a}}return n>=e.length/4}function Gn(e,t){if(e.length<=t)return e;e=e.substring(0,t);let n=e.match(/^(.*)\b(.+)$/);return n?n[1].trimEnd():``}function Z(e){let t=[];{let n=e.match(/^([\d.,]+)[^.,\w]/),r=n?n[1].length:0;if(r){let n=Gn(e.substring(r).trimStart(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}{let n=e.match(/[^.,\w]([\d.,]+)$/),r=n?n[1].length:0;if(r){let n=Gn(e.substring(0,e.length-r).trimEnd(),80);t.push({text:n,scoreBouns:n.length<=30?2:1})}}return e.length<=30?t.push({text:e,scoreBouns:0}):(t.push({text:Gn(e,80),scoreBouns:0}),t.push({text:Gn(e,30),scoreBouns:1})),t=t.filter(e=>e.text),t.length||t.push({text:e.substring(0,80),scoreBouns:0}),t}function Kn(e,t,n){let r=e.left-t.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function qn(e,t,n){let r=t.left-e.right;if(!(r<0||n!==void 0&&r>n))return r+Math.max(t.bottom-e.bottom,0)+Math.max(e.top-t.top,0)}function Jn(e,t,n){let r=t.top-e.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function Yn(e,t,n){let r=e.top-t.bottom;if(!(r<0||n!==void 0&&r>n))return r+Math.max(e.left-t.left,0)+Math.max(t.right-e.right,0)}function Xn(e,t,n){let r=n===void 0?50:n,i=0;return e.left-t.right>=0&&(i+=e.left-t.right),t.left-e.right>=0&&(i+=t.left-e.right),t.top-e.bottom>=0&&(i+=t.top-e.bottom),e.top-t.bottom>=0&&(i+=e.top-t.bottom),i>r?void 0:i}const Zn=[`left-of`,`right-of`,`above`,`below`,`near`];function Qn(e,t,n,r){let i=t.getBoundingClientRect(),a={"left-of":qn,"right-of":Kn,above:Jn,below:Yn,near:Xn}[e],o;for(let e of n){if(e===t)continue;let n=a(i,e.getBoundingClientRect(),r);n!==void 0&&(o===void 0||n<o)&&(o=n)}return o}var $n=class{constructor(e){b(this,`_engines`,new Map),b(this,`_cacheQueryCSS`,new Map),b(this,`_cacheMatches`,new Map),b(this,`_cacheQuery`,new Map),b(this,`_cacheMatchesSimple`,new Map),b(this,`_cacheMatchesParents`,new Map),b(this,`_cacheCallMatches`,new Map),b(this,`_cacheCallQuery`,new Map),b(this,`_cacheQuerySimple`,new Map),b(this,`_cacheText`,new Map),b(this,`_scoreMap`,void 0),b(this,`_retainCacheCounter`,0);for(let[t,n]of e)this._engines.set(t,n);this._engines.set(`not`,rr),this._engines.set(`is`,er),this._engines.set(`where`,er),this._engines.set(`has`,tr),this._engines.set(`scope`,nr),this._engines.set(`light`,ir),this._engines.set(`visible`,ar),this._engines.set(`text`,or),this._engines.set(`text-is`,sr),this._engines.set(`text-matches`,cr),this._engines.set(`has-text`,lr),this._engines.set(`right-of`,ur(`right-of`)),this._engines.set(`left-of`,ur(`left-of`)),this._engines.set(`above`,ur(`above`)),this._engines.set(`below`,ur(`below`)),this._engines.set(`near`,ur(`near`)),this._engines.set(`nth-match`,dr);let t=[...this._engines.keys()];t.sort();let n=[...Ke];if(n.sort(),t.join(`|`)!==n.join(`|`))throw Error(`Please keep customCSSNames in sync with evaluator engines: ${t.join(`|`)} vs ${n.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,n,r){e.has(t)||e.set(t,[]);let i=e.get(t),a=i.find(e=>n.every((t,n)=>e.rest[n]===t));if(a)return a.result;let o=r();return i.push({rest:n,result:o}),o}_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,n){let r=this._checkSelector(t);this.begin();try{return this._cached(this._cacheMatches,e,[r,n.scope,n.pierceShadow,n.originalScope],()=>Array.isArray(r)?this._matchesEngine(er,e,r,n):(this._hasScopeClause(r)&&(n=this._expandContextForScopeMatching(n)),this._matchesSimple(e,r.simples[r.simples.length-1].selector,n)?this._matchesParents(e,r,r.simples.length-2,n):!1))}finally{this.end()}}query(e,t){let n=this._checkSelector(t);this.begin();try{return this._cached(this._cacheQuery,n,[e.scope,e.pierceShadow,e.originalScope],()=>{if(Array.isArray(n))return this._queryEngine(er,e,n);this._hasScopeClause(n)&&(e=this._expandContextForScopeMatching(e));let t=this._scoreMap;this._scoreMap=new Map;let r=this._querySimple(e,n.simples[n.simples.length-1].selector);return r=r.filter(t=>this._matchesParents(t,n,n.simples.length-2,e)),this._scoreMap.size&&r.sort((e,t)=>{let n=this._scoreMap.get(e),r=this._scoreMap.get(t);return n===r?0:n===void 0?1:r===void 0?-1:n-r}),this._scoreMap=t,r})}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=L(e.scope);return t?{...e,scope:t,originalScope:e.originalScope||e.scope}:e}_matchesSimple(e,t,n){return this._cached(this._cacheMatchesSimple,e,[t,n.scope,n.pierceShadow,n.originalScope],()=>{if(e===n.scope||t.css&&!this._matchesCSS(e,t.css))return!1;for(let r of t.functions)if(!this._matchesEngine(this._getEngine(r.name),e,r.args,n))return!1;return!0})}_querySimple(e,t){return t.functions.length?this._cached(this._cacheQuerySimple,t,[e.scope,e.pierceShadow,e.originalScope],()=>{let n=t.css,r=t.functions;n===`*`&&r.length&&(n=void 0);let i,a=-1;n===void 0?(a=r.findIndex(e=>this._getEngine(e.name).query!==void 0),a===-1&&(a=0),i=this._queryEngine(this._getEngine(r[a].name),e,r[a].args)):i=this._queryCSS(e,n);for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches!==void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}for(let t=0;t<r.length;t++){if(t===a)continue;let n=this._getEngine(r[t].name);n.matches===void 0&&(i=i.filter(i=>this._matchesEngine(n,i,r[t].args,e)))}return i}):this._queryCSS(e,t.css||`*`)}_matchesParents(e,t,n,r){return n<0||this._cached(this._cacheMatchesParents,e,[t,n,r.scope,r.pierceShadow,r.originalScope],()=>{let{selector:i,combinator:a}=t.simples[n];if(a===`>`){let a=fr(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===`+`){let a=pr(e,r);return!a||!this._matchesSimple(a,i,r)?!1:this._matchesParents(a,t,n-1,r)}if(a===``){let a=fr(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=fr(a,r)}return!1}if(a===`~`){let a=pr(e,r);for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===`~`)break}a=pr(a,r)}return!1}if(a===`>=`){let a=e;for(;a;){if(this._matchesSimple(a,i,r)){if(this._matchesParents(a,t,n-1,r))return!0;if(t.simples[n-1].combinator===``)break}a=fr(a,r)}return!1}throw Error(`Unsupported combinator "${a}"`)})}_matchesEngine(e,t,n,r){if(e.matches)return this._callMatches(e,t,n,r);if(e.query)return this._callQuery(e,n,r).includes(t);throw Error(`Selector engine should implement "matches" or "query"`)}_queryEngine(e,t,n){if(e.query)return this._callQuery(e,n,t);if(e.matches)return this._queryCSS(t,`*`).filter(r=>this._callMatches(e,r,n,t));throw Error(`Selector engine should implement "matches" or "query"`)}_callMatches(e,t,n,r){return this._cached(this._cacheCallMatches,t,[e,r.scope,r.pierceShadow,r.originalScope,...n],()=>e.matches(t,n,r,this))}_callQuery(e,t,n){return this._cached(this._cacheCallQuery,e,[n.scope,n.pierceShadow,n.originalScope,...t],()=>e.query(n,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 n=[];function r(i){if(n=n.concat([...i.querySelectorAll(t)]),e.pierceShadow){i.shadowRoot&&r(i.shadowRoot);for(let e of i.querySelectorAll(`*`))e.shadowRoot&&r(e.shadowRoot)}}return r(e.scope),n})}_getEngine(e){let t=this._engines.get(e);if(!t)throw Error(`Unknown selector engine "${e}"`);return t}};const er={matches(e,t,n,r){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);return t.some(t=>r.matches(e,t,n))},query(e,t,n){if(t.length===0)throw Error(`"is" engine expects non-empty selector list`);let r=[];for(let i of t)r=r.concat(n.query(e,i));return t.length===1?r:mr(r)}},tr={matches(e,t,n,r){if(t.length===0)throw Error(`"has" engine expects non-empty selector list`);return r.query({...n,scope:e},t).length>0}},nr={matches(e,t,n,r){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let i=n.originalScope||n.scope;return i.nodeType===9?e===i.documentElement:e===i},query(e,t,n){if(t.length!==0)throw Error(`"scope" engine expects no arguments`);let r=e.originalScope||e.scope;if(r.nodeType===9){let e=r.documentElement;return e?[e]:[]}return r.nodeType===1?[r]:[]}},rr={matches(e,t,n,r){if(t.length===0)throw Error(`"not" engine expects non-empty selector list`);return!r.matches(e,t,n)}},ir={query(e,t,n){return n.query({...e,pierceShadow:!1},t)},matches(e,t,n,r){return r.matches(e,t,{...n,pierceShadow:!1})}},ar={matches(e,t,n,r){if(t.length)throw Error(`"visible" engine expects no arguments`);return ut(e)}},or={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text" engine expects a single string`);let i=P(t[0]).toLowerCase();return yn(r._cacheText,e,e=>e.normalized.toLowerCase().includes(i))===`self`}},sr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"text-is" engine expects a single string`);let i=P(t[0]);return yn(r._cacheText,e,e=>!i&&!e.immediate.length||e.immediate.some(e=>P(e)===i))!==`none`}},cr={matches(e,t,n,r){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 i=new RegExp(t[0],t.length===2?t[1]:void 0);return yn(r._cacheText,e,e=>i.test(e.full))===`self`}},lr={matches(e,t,n,r){if(t.length!==1||typeof t[0]!=`string`)throw Error(`"has-text" engine expects a single string`);if(vn(e))return!1;let i=P(t[0]).toLowerCase();return(e=>e.normalized.toLowerCase().includes(i))(G(r._cacheText,e))}};function ur(e){return{matches(t,n,r,i){let a=n.length&&typeof n[n.length-1]==`number`?n[n.length-1]:void 0,o=a===void 0?n:n.slice(0,n.length-1);if(n.length<1+(a===void 0?0:1))throw Error(`"${e}" engine expects a selector list and optional maximum distance in pixels`);let s=Qn(e,t,i.query(r,o),a);return s!==void 0&&(i._markScore(t,s),!0)}}}const dr={query(e,t,n){let r=t[t.length-1];if(t.length<2)throw Error(`"nth-match" engine expects non-empty selector list and an index argument`);if(typeof r!=`number`||r<1)throw Error(`"nth-match" engine expects a one-based index as the last argument`);let i=er.query(e,t.slice(0,t.length-1),n);return r--,r<i.length?[i[r]]:[]}};function fr(e,t){if(e!==t.scope)return t.pierceShadow?L(e):e.parentElement||void 0}function pr(e,t){if(e!==t.scope)return e.previousElementSibling||void 0}function mr(e){let t=new Map,n=[],r=[];function i(e){let r=t.get(e);if(r)return r;let a=L(e);return a?i(a).children.push(e):n.push(e),r={children:[],taken:!1},t.set(e,r),r}for(let t of e)i(t).taken=!0;function a(e){let n=t.get(e);if(n.taken&&r.push(e),n.children.length>1){let t=new Set(n.children);n.children=[];let r=e.firstElementChild;for(;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling;for(r=e.shadowRoot?e.shadowRoot.firstElementChild:null;r&&n.children.length<t.size;)t.has(r)&&n.children.push(r),r=r.nextElementSibling}n.children.forEach(a)}return n.forEach(a),r}function hr(e,t,n){return`internal:attr=[${e}=${I(t,n?.exact??Q.options.exact)}]`}function gr(e,t){return`internal:testid=[${e}=${I(t,!0)}]`}function _r(e,t){return`internal:label=${F(e,t?.exact??Q.options.exact)}`}function vr(e,t){return hr(`alt`,e,t)}function yr(e,t){return hr(`title`,e,t)}function br(e,t){return hr(`placeholder`,e,t)}function xr(e,t){return`internal:text=${F(e,t?.exact??Q.options.exact)}`}function Sr(e,t={}){let n=[];return t.checked!==void 0&&n.push([`checked`,String(t.checked)]),t.disabled!==void 0&&n.push([`disabled`,String(t.disabled)]),t.selected!==void 0&&n.push([`selected`,String(t.selected)]),t.expanded!==void 0&&n.push([`expanded`,String(t.expanded)]),t.includeHidden!==void 0&&n.push([`include-hidden`,String(t.includeHidden)]),t.level!==void 0&&n.push([`level`,String(t.level)]),t.name!==void 0&&n.push([`name`,I(t.name,t.exact??Q.options.exact)]),t.pressed!==void 0&&n.push([`pressed`,String(t.pressed)]),`internal:role=${e}${n.map(([e,t])=>`[${e}=${t}]`).join(``)}`}var Q=class e{static create(t){return Object.assign(e.options,t),e.singleton||=new e}constructor(){b(this,`_engines`,void 0),b(this,`_evaluator`,void 0),this._evaluator=new $n(new Map),this._engines=new Map,this._engines.set(`xpath`,Or),this._engines.set(`xpath:light`,Or),this._engines.set(`role`,Tn(!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`,Tn(!0))}queryLocatorSelector(e,t=document.documentElement,n=!0){return this.querySelector(this.parseSelector(e),t,n)}queryLocatorSelectorAll(e,t=document.documentElement){return this.querySelectorAll(this.parseSelector(e),t)}querySelector(e,t,n=!0){let r=this.querySelectorAll(e,t);if(n&&r.length>1)throw this.strictModeViolationError(e,r);return r[0]||null}queryAllByRole(e,t,n=document.documentElement){let r=this.parseSelector(Sr(e,t));return this.querySelectorAll(r,n)}queryAllByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(_r(e,t));return this.querySelectorAll(r,n)}queryAllByTestId(t,n=document.documentElement){let r=this.parseSelector(gr(e.options.testIdAttribute,t));return this.querySelectorAll(r,n)}queryAllByText(e,t,n=document.documentElement){let r=this.parseSelector(xr(e,t));return this.querySelectorAll(r,n)}queryAllByTitle(e,t,n=document.documentElement){let r=this.parseSelector(yr(e,t));return this.querySelectorAll(r,n)}queryAllByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(br(e,t));return this.querySelectorAll(r,n)}queryAllByAltText(e,t,n=document.documentElement){let r=this.parseSelector(vr(e,t));return this.querySelectorAll(r,n)}queryByRole(e,t,n=document.documentElement){let r=this.parseSelector(Sr(e,t));return this.querySelector(r,n,!1)}queryByLabelText(e,t,n=document.documentElement){let r=this.parseSelector(_r(e,t));return this.querySelector(r,n,!1)}queryByTestId(t,n=document.documentElement){let r=this.parseSelector(gr(e.options.testIdAttribute,t));return this.querySelector(r,n,!1)}queryByText(e,t,n=document.documentElement){let r=this.parseSelector(xr(e,t));return this.querySelector(r,n,!1)}queryByTitle(e,t,n=document.documentElement){let r=this.parseSelector(yr(e,t));return this.querySelector(r,n,!1)}queryByPlaceholder(e,t,n=document.documentElement){let r=this.parseSelector(br(e,t));return this.querySelector(r,n,!1)}queryByAltText(e,t,n=document.documentElement){let r=this.parseSelector(vr(e,t));return this.querySelector(r,n,!1)}strictModeViolationError(e,t){let n=t.slice(0,10).map(e=>({preview:this.previewNode(e),selector:this.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${En(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
|
|
4
|
+
...`),this.createStacklessError(`strict mode violation: ${En(`javascript`,M(e))} resolved to ${t.length} elements:${r.join(``)}\n`)}generateSelectorSimple(t,n){return Pn(this,t,{...n,testIdAttributeName:e.options.testIdAttribute})}parseSelector(e){let t=qe(e);return Ye(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 Cr(`#text=${e.nodeValue||``}`);if(e.nodeType!==Node.ELEMENT_NODE)return Cr(`<${e.nodeName.toLowerCase()} />`);let t=e,n=[];for(let e=0;e<t.attributes.length;e++){let{name:r,value:i}=t.attributes[e];r!==`style`&&(!i&&wr.has(r)?n.push(` ${r}`):n.push(` ${r}="${i}"`))}n.sort((e,t)=>e.length-t.length);let r=it(n.join(``),500);if(Tr.has(t.nodeName))return Cr(`<${t.nodeName.toLowerCase()}${r}/>`);let i=t.childNodes,a=!1;if(i.length<=5){a=!0;for(let e=0;e<i.length;e++)a&&=i[e].nodeType===Node.TEXT_NODE}let o=a?t.textContent||``:i.length?`…`:``;return Cr(`<${t.nodeName.toLowerCase()}${r}>${it(o,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 n={parts:e.parts.slice(0,e.capture+1)};if(e.capture<e.parts.length-1){let t={parts:e.parts.slice(e.capture+1)},r={name:`internal:has`,body:{parsed:t},source:M(t)};n.parts.push(r)}return this.querySelectorAll(n,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 n=new Set([t]);for(let r of e.parts)if(r.name===`nth`)n=this._queryNth(n,r);else if(r.name===`internal:and`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(e.filter(e=>n.has(e)))}else if(r.name===`internal:or`){let e=this.querySelectorAll(r.body.parsed,t);n=new Set(mr(new Set([...n,...e])))}else if(Zn.includes(r.name))n=this._queryLayoutSelector(n,r,t);else{let e=new Set;for(let t of n){let n=this._queryEngineAll(r,t);for(let t of n)e.add(t)}n=e}return[...n]}finally{this._evaluator.end()}}_queryEngineAll(e,t){let n=this._engines.get(e.name).queryAll(t,e.body);for(let e of n)if(!(`nodeName`in e))throw this.createStacklessError(`Expected a Node but got ${Object.prototype.toString.call(e)}`);return n}_queryNth(e,t){let n=[...e],r=+t.body;return r===-1&&(r=n.length-1),new Set(n.slice(r,r+1))}_queryLayoutSelector(e,t,n){let r=t.name,i=t.body,a=[],o=this.querySelectorAll(i.parsed,n);for(let t of e){let e=Qn(r,t,o,i.distance);e!==void 0&&a.push({element:t,score:e})}return a.sort((e,t)=>e.score-t.score),new Set(a.map(e=>e.element))}createStacklessError(t){if(e.options.browser===`firefox`){let e=Error(`Error: ${t}`);return e.stack=``,e}let n=Error(t);return delete n.stack,n}_createTextEngine(e,t){return{queryAll:(n,r)=>{let{matcher:i,kind:a}=Dr(r,t),o=[],s=null,c=e=>{if(a===`lax`&&s&&s.contains(e))return!1;let n=yn(this._evaluator._cacheText,e,i);n===`none`&&(s=e),(n===`self`||n===`selfAndChildren`&&a===`strict`&&!t)&&o.push(e)};n.nodeType===Node.ELEMENT_NODE&&c(n);let l=this._evaluator._queryCSS({scope:n,pierceShadow:e},`*`);for(let e of l)c(e);return o}}}_createAttributeEngine(e,t){let n=t=>[{simples:[{selector:{css:`[${e}=${JSON.stringify(t)}]`,functions:[]},combinator:``}]}];return{queryAll:(e,r)=>this._evaluator.query({scope:e,pierceShadow:t},n(r))}}_createCSSEngine(){return{queryAll:(e,t)=>this._evaluator.query({scope:e,pierceShadow:!0},t)}}_createNamedAttributeEngine(){return{queryAll:(e,t)=>{let n=Ze(t);if(n.name||n.attributes.length!==1)throw Error(`Malformed attribute selector: ${t}`);let{name:r,value:i,caseSensitive:a}=n.attributes[0],o=a?null:i.toLowerCase(),s;return s=i instanceof RegExp?e=>!!e.match(i):a?e=>e===i:e=>e.toLowerCase().includes(o),this._evaluator._queryCSS({scope:e,pierceShadow:!0},`[${r}]`).filter(e=>s(e.getAttribute(r)))}}}_createVisibleEngine(){return{queryAll:(e,t)=>e.nodeType===1&&ut(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:n}=Dr(t,!0);return this._evaluator._queryCSS({scope:e,pierceShadow:!0},`*`).filter(e=>bn(this._evaluator._cacheText,e).some(e=>n(e)))}}}_createInternalHasTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=G(this._evaluator._cacheText,n),{matcher:i}=Dr(t,!0);return i(r)?[n]:[]}}}_createInternalHasNotTextEngine(){return{queryAll:(e,t)=>{if(e.nodeType!==1)return[];let n=e,r=G(this._evaluator._cacheText,n),{matcher:i}=Dr(t,!0);return i(r)?[]:[n]}}}};b(Q,`options`,{testIdAttribute:`data-testid`,browser:`chromium`,exact:!1}),b(Q,`singleton`,null);function Cr(e){return e.replace(/\n/g,`↵`).replace(/\t/g,`⇆`)}const wr=new Set([`checked`,`selected`,`disabled`,`readonly`,`multiple`]),Tr=new Set([`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`MENUITEM`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`]);function Er(e){if(e=e.substring(1,e.length-1),!e.includes(`\\`))return e;let t=[],n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length&&n++,t.push(e[n++]);return t.join(``)}function Dr(e,t){if(e[0]===`/`&&e.lastIndexOf(`/`)>0){let t=e.lastIndexOf(`/`),n=new RegExp(e.substring(1,t),e.substring(t+1));return{matcher:e=>n.test(e.full),kind:`regex`}}let n=t?JSON.parse.bind(JSON):Er,r=!1;return e.length>1&&e[0]===`"`&&e[e.length-1]===`"`?(e=n(e),r=!0):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`i`?(e=n(e.substring(0,e.length-1)),r=!1):t&&e.length>1&&e[0]===`"`&&e[e.length-2]===`"`&&e[e.length-1]===`s`?(e=n(e.substring(0,e.length-1)),r=!0):e.length>1&&e[0]===`'`&&e[e.length-1]===`'`&&(e=n(e),r=!0),e=P(e),r?t?{kind:`strict`,matcher:t=>t.normalized===e}:{matcher:t=>!e&&!t.immediate.length||t.immediate.some(t=>P(t)===e),kind:`strict`}:(e=e.toLowerCase(),{kind:`lax`,matcher:t=>t.normalized.toLowerCase().includes(e)})}const Or={queryAll(e,t){t.startsWith(`/`)&&e.nodeType!==Node.DOCUMENT_NODE&&(t=`.${t}`);let n=[],r=e.ownerDocument||e;if(!r)return n;let i=r.evaluate(t,e,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE);for(let e=i.iterateNext();e;e=i.iterateNext())e.nodeType===Node.ELEMENT_NODE&&n.push(e);return n}},kr=[`:hover`,`:active`,`:focus`,`:focus-visible`,`:focus-within`,`:popover-open`];function Ar(){return Math.random().toString(36).slice(2)}async function jr(e,t){let n=c().browserTraceAttempts.get(e.id),r=o()-n.startTime,i=Mr(t.element),a={...t,startTime:r,snapshot:i},{retry:s,repeats:u}=n,{recordCanvas:d}=c().config.browser.traceView,f={retry:s,repeats:u,recordCanvas:d,entries:[a]};await l().rpc.triggerCommand(c().sessionId,`__vitest_recordBrowserTrace`,void 0,[{testId:e.id,data:f}])}function Mr(e){let{snapshot:t,createMirror:n}=c().browserTraceDomSnapshot,r=c().config.browser.traceView,i=c().selectorEngine,a=n(),o={serialized:t(document,{mirror:a,inlineImages:r.inlineImages,recordCanvas:r.recordCanvas}),viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{x:window.scrollX,y:window.scrollY},pseudoClassIds:{}};if(r.ariaSnapshot){let{generateAriaTree:e,renderAriaTree:t}=c().aria;o.ariaSnapshot=t(e(document.body))}for(let e of kr){let t=document.querySelectorAll(e),n=Array.from(t,e=>a.getId(e)).filter(e=>e!==-1);o.pseudoClassIds[e]=n}if(e)try{let t=i.querySelectorAll(i.parseSelector(e._pwSelector??e.selector),document.documentElement).map(e=>a.getId(e)).filter(e=>e!==-1);t.length>0?(o.selectorIds=t,o.selectorResolution=`matched`):o.selectorResolution=`missing`}catch(e){o.selectorResolution=`error`,o.selectorError=e instanceof Error?e.message:String(e)}return o}function Nr(e){if(!e||!(e instanceof Element))throw Error(`Expected DOM element to be an instance of Element, received ${typeof e}`);return Fr(e)}function Pr(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 Fr(e){let t=[],n,r=!1;for(;n=Ir(e);){n.shadowRoot&&(r=!0);let i=e.tagName;if(e.id)t.push(`#${Pr(e.id)}`);else if(!e.nextElementSibling&&!e.previousElementSibling)t.push(i.toLowerCase());else{let r=0,a=0,o=0;for(let t of n.children)r++,t.tagName===i&&a++,t===e&&(o=r);a>1?t.push(`${i.toLowerCase()}:nth-child(${o})`):t.push(i.toLowerCase())}e=n}return`${c().provider===`webdriverio`&&r?`>>>`:``}${t.reverse().join(` > `)}`}function Ir(e){let t=e.parentNode;return t instanceof ShadowRoot?t.host:t}function Lr(){let e=window.frameElement;if(!e)throw Error(`Cannot find iframe element. This is a bug in Vitest. Please, open a new issue with reproduction.`);return e}function Rr(){let e=Lr();return new DOMMatrix(getComputedStyle(e).transform).a}function zr(e){return e.unicode||e.unicodeSets?String(e):String(e).replace(/(^|[^\\])(\\\\)*(["'`])/g,`$1$2\\$3`).replace(/>>/g,`\\>\\>`)}function Br(e,t){return typeof e==`string`?`${JSON.stringify(e)}i`:zr(e)}const Vr=c().provider,Hr=Symbol.for(`$$vitest:locator-resolved`);async function Ur(e,t){if(!e)throw Error(`Expected element or locator to be defined.`);if(e instanceof Element){let t=Nr(e);return{selector:t,locator:a._asLocator(`javascript`,t)}}if(Gr(e)){if(Vr===`playwright`||Hr in e)return e.serialize();let n=Nr(await e.findElement(t));return{selector:n,locator:a._asLocator(`javascript`,n)}}throw Error(`Expected element or locator to be an instance of Element or Locator.`)}const Wr=Symbol.for(`$$vitest:locator`);function Gr(e){return!!e&&typeof e==`object`&&Wr in e}function Kr(e){let t;if(e.delta)t=e.delta;else switch(e.direction){case`up`:t={y:-100};break;case`down`:t={y:100};break;case`left`:t={x:-100};break;case`right`:t={x:100}}return{delta:t,times:e.times}}a._asLocator=En;const qr=Date.now,Jr=[0,20,50,100,100,500];function Yr(e){let{setTimeout:t}=i();return new Promise(n=>t(n,e))}const $=Q.create({exact:t.config.browser.locators.exact,browser:(e=>{switch(e){case`edge`:case`chrome`:return`chromium`;case`safari`:return`webkit`;default:return e}})(t.config.browser.name),testIdAttribute:t.config.browser.locators.testIdAttribute});c().selectorEngine=$;const Xr=Symbol.for(`$$vitest:locator`);class Zr{_parsedSelector;_container;_pwSelector;_pwLocator;_errorSource;constructor(){Object.defineProperty(this,Xr,{enumerable:!1,writable:!1,configurable:!1,value:Xr})}click(e){return this.action(`__vitest_click`,[],e)}dblClick(e){return this.action(`__vitest_dblClick`,[],e)}tripleClick(e){return this.action(`__vitest_tripleClick`,[],e)}wheel(e){return s(async t=>{await f(c().commands.triggerCommand(`__vitest_wheel`,[this.serialize(),Kr(e)],t));let n=c().config.browser.name;if(n===`chromium`||n===`chrome`)return f(new Promise(e=>{requestAnimationFrame(()=>{e()})}))})}clear(e){return this.action(`__vitest_clear`,[],e)}hover(e){return this.action(`__vitest_hover`,[],e)}unhover(e){return this.action(`__vitest_hover`,[],e,{selector:`html > body`,locator:`locator('body')`})}fill(e,t){return this.action(`__vitest_fill`,[e],t)}upload(e,t){return new h(this.serialize(),e,t,this._errorSource)}dropTo(e,t={}){return this.action(`__vitest_dragAndDrop`,[e.toJSON()],t,this.toJSON())}selectOptions(e,t){let n=(Array.isArray(e)?e:[e]).map(e=>typeof e==`string`?e:{element:Gr(e)?e.serialize():{selector:Nr(e),locator:a._asLocator(`javascript`,$.generateSelectorSimple(e))}});return this.action(`__vitest_selectOptions`,[n],t)}screenshot(e){return n.screenshot({...e,element:this})}mark(e,t){let n=l().current,r=!!n&&c().activeTraceTaskIds.has(n.id),i=!!n&&c().browserTraceAttempts.has(n.id);return!n||!r&&!i?Promise.resolve():s(async a=>(i&&await jr(n,{name:e,kind:t?.kind??`mark`,element:this.serialize(),stack:t?.stack??a?.stack}),r?c().commands.triggerCommand(`__vitest_markTrace`,[{name:e,element:this.serialize(),stack:t?.stack??a?.stack}],a):Promise.resolve()))}getByRole(e,t){return this.locator(Sr(e,t))}getByAltText(e,t){return this.locator(vr(e,t))}getByLabelText(e,t){return this.locator(_r(e,t))}getByPlaceholder(e,t){return this.locator(br(e,t))}getByTestId(e){return this.locator(gr(t.config.browser.locators.testIdAttribute,e))}getByText(e,t){return this.locator(xr(e,t))}getByTitle(e,t){return this.locator(yr(e,t))}filter(e){let t=[];if(e?.hasText&&t.push(`internal:has-text=${Br(e.hasText)}`),e?.hasNotText&&t.push(`internal:has-not-text=${Br(e.hasNotText)}`),e?.has){let n=e.has;t.push(`internal:has=${JSON.stringify(n._pwSelector||n.selector)}`)}if(e?.hasNot){let n=e.hasNot;t.push(`internal:has-not=${JSON.stringify(n._pwSelector||n.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||=$.parseSelector(this._pwSelector||this.selector);return $.querySelector(e,document.documentElement,!0)}element(){let e=this.query();if(!e)throw r.getElementError(this,this._container||document.body);return e}elements(){let e=this._parsedSelector||=$.parseSelector(this._pwSelector||this.selector);return $.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}serialize(){return{selector:this.selector,locator:this.asLocator(),_pwSelector:this._pwSelector}}asLocator(){return this._pwLocator||=En(`javascript`,this._pwSelector||this.selector)}toJSON(){return this.serialize()}async findElement(t={}){let n=u(t),i=t?.strict??!0,a=qr(),o=0;for(;;){let t=this.elements();if(t.length===1)return t[0];if(t.length>1){if(i)throw $r(this,t);return t[0]}let s=qr()-a;if(n!=null&&s>=n)throw r.getElementError(this,this._container||document.body);let c=Jr[Math.min(o++,Jr.length-1)],l=n==null?c:Math.min(c,n-s);e.isFakeTimers()&&e.advanceTimersByTime(l),await Yr(l)}}action(e,t,n,r=this.serialize()){return new m(r,e,t,n,this._errorSource)}}function Qr(e){return c().commands.triggerCommand(e.name,e.arguments,e.errorSource)}function $r(e,t){let n=t.slice(0,10).map(e=>({preview:$.previewNode(e),selector:$.generateSelectorSimple(e)})),r=n.map((e,t)=>`\n ${t+1}) ${e.preview} aka ${En(`javascript`,e.selector)}`);return n.length<t.length&&r.push(`
|
|
5
|
+
...`),Error(`strict mode violation: ${e.asLocator()} resolved to ${t.length} elements:${r.join(``)}\n`)}export{u as A,o as B,l as C,Ar as D,jr as E,Nr as F,s as G,vr as H,_r as I,br as J,Sr as K,Zr as L,gr as M,xr as N,yr as O,Rr as P,d as Q,$ as R,Qr as S,b as _,It as a,Kt as b,en as c,tn as d,Xt as e,Zt as f,B as g,Qt as h,V as i,$t as j,Gt as k,Jt as l,Yt as m,P as n,Ut as o,Wt as p,R as q,Mt as r,hn as s,gn as t,c as u,ut as v,Lt as w,Vt as x,N as y,Ur as z};
|
package/dist/locators.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{L as Locator,F as convertElementToCssSelector,G as ensureAwaited,H as getByAltTextSelector,I as getByLabelSelector,J as getByPlaceholderSelector,K as getByRoleSelector,M as getByTestIdSelector,N as getByTextSelector,O as getByTitleSelector,P as getIframeScale,Q as processTimeoutOptions,R as selectorEngine,S as triggerCommandWithTrace}from"./locators-
|
|
1
|
+
export{L as Locator,F as convertElementToCssSelector,G as ensureAwaited,H as getByAltTextSelector,I as getByLabelSelector,J as getByPlaceholderSelector,K as getByRoleSelector,M as getByTestIdSelector,N as getByTextSelector,O as getByTitleSelector,P as getIframeScale,Q as processTimeoutOptions,R as selectorEngine,S as triggerCommandWithTrace}from"./locators-7Z9PPr-9.js";import"vitest";import"vitest/browser";import"vitest/internal/browser";
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import type { MockedModuleSerialized, ServerIdResolution, ServerMockResolution }
|
|
|
2
2
|
import type { BirpcReturn } from "birpc";
|
|
3
3
|
import type { AfterSuiteRunMeta, BaselineData, BrowserTesterOptions, CancelReason, RunnerTestFile, SnapshotResult, RunnerTaskEventPack as TaskEventPack, RunnerTaskResultPack as TaskResultPack, TestArtifact, TestBenchmark, TestExecutionMethod, UserConsoleLog } from "vitest";
|
|
4
4
|
import type { MarkOptions } from "vitest/browser";
|
|
5
|
+
interface OrchestratorCapabilities {
|
|
6
|
+
/** the browser accepts an import map after a module has loaded */
|
|
7
|
+
lateImportMaps: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MockImportMap {
|
|
10
|
+
imports: Record<string, string>;
|
|
11
|
+
}
|
|
5
12
|
export interface WebSocketBrowserHandlers {
|
|
6
13
|
resolveSnapshotPath: (testPath: string) => string;
|
|
7
14
|
resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
|
|
@@ -14,7 +21,7 @@ export interface WebSocketBrowserHandlers {
|
|
|
14
21
|
readBenchmarkResult: (relativePath: string) => Promise<BaselineData | null>;
|
|
15
22
|
writeBenchmarkResult: (relativePath: string, data: BaselineData) => Promise<void>;
|
|
16
23
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
17
|
-
onOrchestratorReady: () => void;
|
|
24
|
+
onOrchestratorReady: (capabilities: OrchestratorCapabilities) => void;
|
|
18
25
|
cancelCurrentRun: (reason: CancelReason) => void;
|
|
19
26
|
getCountOfFailedTests: () => number;
|
|
20
27
|
readSnapshotFile: (id: string) => Promise<string | null>;
|
|
@@ -34,7 +41,12 @@ export interface WebSocketBrowserHandlers {
|
|
|
34
41
|
mappings: "";
|
|
35
42
|
} | undefined;
|
|
36
43
|
wdioSwitchContext: (direction: "iframe" | "parent") => void;
|
|
37
|
-
registerMock: (sessionId: string, mock: MockedModuleSerialized
|
|
44
|
+
registerMock: (sessionId: string, mock: MockedModuleSerialized, context: {
|
|
45
|
+
/** the module that called `vi.mock` */
|
|
46
|
+
importer: string;
|
|
47
|
+
/** the test file that is running; its static `vi.unmock` calls cancel mocks from other modules */
|
|
48
|
+
testFile?: string;
|
|
49
|
+
}) => Promise<MockImportMap | undefined>;
|
|
38
50
|
unregisterMock: (sessionId: string, id: string) => void;
|
|
39
51
|
clearMocks: (sessionId: string) => void;
|
|
40
52
|
sendCdpEvent: (sessionId: string, event: string, payload?: Record<string, unknown>) => unknown;
|