"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateFrameShapeSchema = exports.createFrameShapeSchema = exports.frameShapeListQuerySchema = exports.frameShapeSlugParamSchema = exports.frameShapeIdParamSchema = void 0;
const zod_1 = require("zod");
const positiveId = zod_1.z.coerce.number().int().positive();
const slug = zod_1.z
    .string()
    .trim()
    .min(1)
    .max(140)
    .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "Use a URL-safe slug");
const mediaInputSchema = zod_1.z.object({
    url: zod_1.z.string().trim().min(1).max(512),
    storageKey: zod_1.z.string().trim().max(1024).nullable().optional(),
    fileName: zod_1.z.string().trim().max(255).nullable().optional(),
    mimeType: zod_1.z.string().trim().max(120).nullable().optional(),
    sizeBytes: zod_1.z.coerce.number().int().min(0).nullable().optional(),
    altText: zod_1.z.string().trim().max(255).nullable().optional(),
    sortOrder: zod_1.z.coerce.number().int().min(0).default(0),
    isPrimary: zod_1.z.boolean().default(false),
});
exports.frameShapeIdParamSchema = zod_1.z.object({
    id: positiveId,
});
exports.frameShapeSlugParamSchema = zod_1.z.object({
    slug,
});
exports.frameShapeListQuerySchema = zod_1.z.object({
    q: zod_1.z.string().trim().min(1).max(120).optional(),
    page: zod_1.z.coerce.number().int().min(1).default(1),
    perPage: zod_1.z.coerce.number().int().min(1).max(100).default(20),
    includeInactive: zod_1.z.preprocess((value) => {
        if (value === undefined)
            return undefined;
        if (typeof value === "boolean")
            return value;
        if (typeof value === "string") {
            if (["true", "1", "yes"].includes(value.toLowerCase()))
                return true;
            if (["false", "0", "no"].includes(value.toLowerCase()))
                return false;
        }
        return value;
    }, zod_1.z.boolean().optional()),
});
exports.createFrameShapeSchema = zod_1.z.object({
    name: zod_1.z.string().trim().min(2).max(120),
    slug: slug.optional(),
    media: zod_1.z.array(mediaInputSchema).default([]),
});
exports.updateFrameShapeSchema = exports.createFrameShapeSchema
    .partial()
    .extend({
    media: zod_1.z.array(mediaInputSchema).optional(),
    isActive: zod_1.z.boolean().optional(),
})
    .refine((value) => Object.keys(value).length > 0, "At least one field is required");
//# sourceMappingURL=frameShapeValidators.js.map