"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cucumber_1 = require("@cucumber/cucumber");
const locator_1 = require("../runtime/locator");
(0, cucumber_1.When)('I wait for {int} seconds', async function (seconds) {
    await this.page.waitForTimeout(seconds * 1000);
});
(0, cucumber_1.When)('I wait for text {string}', async function (text) {
    await this.page.getByText(text).waitFor();
});
(0, cucumber_1.When)('I wait for element {string}', async function (target) {
    await (0, locator_1.locatorByAny)(this.page, target, this.config.selectors).first().waitFor();
});
(0, cucumber_1.When)('I wait for element {string} at index {int}', async function (target, index) {
    await (0, locator_1.atIndex)((0, locator_1.locatorByAny)(this.page, target, this.config.selectors), index).waitFor();
});
(0, cucumber_1.When)('I wait for URL containing {string}', async function (value) {
    await this.page.waitForURL(new RegExp(escapeRegExp(value)));
});
function escapeRegExp(value) {
    return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
