"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.conditionDescriptorSchema = exports.aiPromptConditionSchema = exports.truthyConditionSchema = exports.presenceConditionSchema = exports.comparisonConditionSchema = exports.presenceEvaluationTypeEnum = exports.comparisonTypeEnum = exports.conditionTypeEnum = void 0;
const zod_1 = require("zod");
const common_1 = require("./common");
exports.conditionTypeEnum = zod_1.z.enum([
    'ai_prompt',
    'comparison',
    'presence',
    'truthy',
]);
exports.comparisonTypeEnum = zod_1.z.enum([
    'equals',
    'does_not_equal',
    'contains',
    'does_not_contain',
    'starts_with',
    'starts_without',
    'ends_with',
    'ends_without',
    'greater_than',
    'less_than',
    'greater_than_or_equals',
    'less_than_or_equals',
    'matches_regex',
]);
exports.presenceEvaluationTypeEnum = zod_1.z.enum(['present', 'not_present']);
exports.comparisonConditionSchema = zod_1.z
    .object({
    conditionType: zod_1.z.literal('comparison'),
    comparisonType: exports.comparisonTypeEnum,
    comparatorValue: zod_1.z
        .union([zod_1.z.string(), common_1.mablSymbolObjectSchema])
        .describe('The value to compare against'),
    caseInsensitive: zod_1.z
        .boolean()
        .optional()
        .describe('When true, comparison ignores case'),
})
    .describe('Compare a value using an operator (equals, contains, starts_with, etc.)');
exports.presenceConditionSchema = zod_1.z
    .object({
    conditionType: zod_1.z.literal('presence'),
    presenceType: exports.presenceEvaluationTypeEnum,
})
    .describe('Check if an element is present or not present in the DOM');
exports.truthyConditionSchema = zod_1.z
    .object({
    conditionType: zod_1.z.literal('truthy'),
})
    .describe('Check if a value is truthy (non-empty, non-zero, non-null)');
exports.aiPromptConditionSchema = zod_1.z
    .object({
    conditionType: zod_1.z.literal('ai_prompt'),
    userPrompt: zod_1.z
        .string()
        .describe('The natural language prompt for the AI to evaluate'),
    metaPrompt: zod_1.z.string().optional(),
    criteria: zod_1.z.array(zod_1.z.string()).optional(),
})
    .describe('Use an AI prompt to evaluate a condition');
exports.conditionDescriptorSchema = zod_1.z
    .discriminatedUnion('conditionType', [
    exports.comparisonConditionSchema,
    exports.presenceConditionSchema,
    exports.truthyConditionSchema,
    exports.aiPromptConditionSchema,
])
    .describe('Condition to evaluate -- comparison, presence check, truthy check, or AI prompt');
