import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
import { TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS } from '../shared/constants.js';
import { customFindSchema } from '../shared/customFind.js';
export const executeAssertElementArgumentsSchema = z.object({
    elementDescription: z.string().meta({ description: TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS }),
    textToAssert: z.string().meta({
        description: 'The text that must be present within the element. This should be the current text within the element to ensure the assertion is stable.',
    }),
    conditionalType: z.enum(['IF', 'ELSEIF']).optional().meta({
        description: "When set, records this assertion as a conditional branch instead of a plain assertion. Use 'IF' to open a new conditional block (first condition only). Use 'ELSEIF' for every subsequent branch condition within the same block (after IF or another ELSEIF).",
    }),
    customFind: customFindSchema.optional(),
});
export const executeAssertElementServerResultSchema = z.object({
    elementDescription: z.string(),
    textToAssert: z.string(),
    elementBoundingBox: z
        .object({
        top: z.number(),
        left: z.number(),
        bottom: z.number(),
        right: z.number(),
    })
        .optional(),
    elementTargetPoint: z
        .object({
        x: z.number(),
        y: z.number(),
    })
        .optional(),
});
export const executeAssertElementClientResponseSchema = z.object({
    success: z.boolean(),
    message: z.string().optional(),
});
export const ExecuteAssertElementToolDefinition = defineTool({
    name: AgentToolNames.ExecuteAssertElement,
    description: 'Validates that a specific element exists on the page and contains the expected text. The elementDescription describes the element to look for. The textToAssert should be the text currently within the element to ensure the assertion remains stable. Use {{@variable_name}} syntax if the text depends on a variable. This tool deterministically expects the element to be on the page with exactly the specified text, so avoid using it for transient elements (loading indicators) or elements with unpredictable dynamic text. Note: This tool asserts against innerText, so it cannot be used for HTML input element values. To open a conditional block instead of asserting, set conditionalType="IF" (first condition in a block) or conditionalType="ELSEIF" (subsequent branch).',
    argumentsSchema: executeAssertElementArgumentsSchema,
    serverPrepareResultSchema: executeAssertElementServerResultSchema,
    responseSchema: executeAssertElementClientResponseSchema,
});
//# sourceMappingURL=ExecuteAssertElementDefinition.js.map