"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeCookieExecutor = void 0;
const toolExecutor_types_1 = require("../toolExecutor-types");
const stepCapture_1 = require("../../background/capture/stepCapture");
const mablscript_step_types_1 = require("../../sharedUtils/mablscript-step-types");
exports.removeCookieExecutor = {
    needsFind: () => false,
    getStepType: () => mablscript_step_types_1.StepType.REMOVE_COOKIE,
    execute: async (payload, stateProvider, eventHandler, logger) => {
        const toolParams = payload.toolCall.toolParams;
        if (!toolParams?.name) {
            logger.error('Remove cookie executor requires a cookie name');
            return {
                success: false,
                errorMessage: 'Cookie name is required',
            };
        }
        const contextInfo = payload.contextInfo ?? (await stateProvider.getActiveContextInfo());
        const step = {
            action: 'record',
            listener: 'remove-cookie',
            cookie: { name: toolParams.name },
        };
        return (0, toolExecutor_types_1.recordStepAndTrackResult)(() => (0, stepCapture_1.recordTrainedStep)(step, contextInfo, true, undefined, stateProvider, eventHandler), 0, stateProvider, eventHandler, logger);
    },
};
