"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerActionSteps = registerActionSteps;
function requirePage(ctx, op) {
    if (!ctx.ui || !ctx.ui.page) {
        throw new Error(`Missing UI page on context for op "${op}"`);
    }
    return ctx.ui.page;
}
function registerActionSteps(registry) {
    registry.register("ui.click", async (ctx, step) => {
        const page = requirePage(ctx, "ui.click");
        const input = (step.with ?? {});
        if (!input.selector) {
            throw new Error('Missing "selector" in step.with for op "ui.click"');
        }
        await page.click(input.selector);
    });
    registry.register("ui.press", async (ctx, step) => {
        const page = requirePage(ctx, "ui.press");
        const input = (step.with ?? {});
        if (!input.selector) {
            throw new Error('Missing "selector" in step.with for op "ui.press"');
        }
        if (!input.key) {
            throw new Error('Missing "key" in step.with for op "ui.press"');
        }
        await page.press(input.selector, input.key);
    });
}
//# sourceMappingURL=actions.step.js.map