import { z } from 'zod';
// ─── Base Schema ─────────────────────────────────────────────────────
const responsiveOverridesSchema = z
    .object({
    mobile: z.record(z.unknown()).optional(),
    tablet: z.record(z.unknown()).optional(),
})
    .optional();
const baseNodeSchema = z.object({
    id: z.string().min(1),
    responsive: responsiveOverridesSchema,
});
// ─── Leaf Nodes ──────────────────────────────────────────────────────
export const blockNodeSchema = baseNodeSchema.extend({
    type: z.literal('block'),
    settings: z
        .object({
        blockType: z.string().min(1),
        variant: z.string().optional(),
    })
        .passthrough(),
    data: z.record(z.unknown()),
});
export const savedSectionRefSchema = baseNodeSchema.extend({
    type: z.literal('savedSectionRef'),
    settings: z
        .object({
        refId: z.string().min(1),
    })
        .passthrough(),
});
// ─── Recursive Nodes (lazy) ──────────────────────────────────────────
export const columnNodeSchema = z.lazy(() => baseNodeSchema.extend({
    type: z.literal('column'),
    settings: z
        .object({
        width: z.number().int().min(1).max(12),
        verticalAlign: z.enum(['top', 'center', 'bottom']).optional(),
        padding: z.string().optional(),
        background: z.string().optional(),
    })
        .passthrough(),
    children: z.array(z.union([blockNodeSchema, containerNodeSchema])),
}));
export const rowNodeSchema = z.lazy(() => baseNodeSchema.extend({
    type: z.literal('row'),
    settings: z
        .object({
        gap: z.string().optional(),
        verticalAlign: z.enum(['top', 'center', 'bottom', 'stretch']).optional(),
        reverseOnMobile: z.boolean().optional(),
        wrapOnMobile: z.boolean().optional(),
    })
        .passthrough(),
    children: z.array(columnNodeSchema).min(1),
}));
export const containerNodeSchema = z.lazy(() => baseNodeSchema.extend({
    type: z.literal('container'),
    settings: z
        .object({
        maxWidth: z.string().optional(),
        alignment: z.enum(['left', 'center', 'right']).optional(),
        padding: z.string().optional(),
    })
        .passthrough(),
    children: z.array(rowNodeSchema),
}));
export const sectionNodeSchema = z.lazy(() => baseNodeSchema.extend({
    type: z.literal('section'),
    settings: z
        .object({
        background: z.string().optional(),
        backgroundImage: z.string().optional(),
        backgroundGradient: z.string().optional(),
        paddingTop: z.string().optional(),
        paddingBottom: z.string().optional(),
        marginTop: z.string().optional(),
        marginBottom: z.string().optional(),
        visibility: z.enum(['visible', 'hidden']).optional(),
        htmlId: z.string().optional(),
        htmlClass: z.string().optional(),
    })
        .passthrough(),
    children: z.array(z.union([containerNodeSchema, rowNodeSchema])),
}));
export const pageNodeSchema = z.lazy(() => baseNodeSchema.extend({
    type: z.literal('page'),
    children: z.array(z.union([sectionNodeSchema, savedSectionRefSchema])),
}));
//# sourceMappingURL=schema.js.map