import { z } from "zod/mini" import { WidgetKeySchema } from "../common/widgetKey" import { DynamicWidgetModelSchema, StaticWidgetModelSchema } from "./widget" // Tab export const StaticCustomTypeModelTabSchema = z.record(WidgetKeySchema, StaticWidgetModelSchema) export type StaticCustomTypeModelTab = z.infer export const DynamicCustomTypeModelTabSchema = z.record(WidgetKeySchema, DynamicWidgetModelSchema) export type DynamicCustomTypeModelTab = z.infer // Custom types export const CustomTypeFormatSchema = z.enum(["page", "custom"]) export type CustomTypeFormat = z.infer // Factory to create CustomType schema with configurable section type const createCustomTypeSchema = (sectionSchema: T) => z.object({ id: z.string(), label: z.nullish(z.string()), repeatable: z._default(z.boolean(), true), json: z.record(z.string(), sectionSchema), status: z._default(z.boolean(), true), format: z._default(CustomTypeFormatSchema, "custom"), }) export const StaticCustomTypeModelSchema = createCustomTypeSchema(StaticCustomTypeModelTabSchema) export type StaticCustomTypeModel = z.infer export const DynamicCustomTypeModelSchema = createCustomTypeSchema(DynamicCustomTypeModelTabSchema) export type DynamicCustomTypeModel = z.infer /** @deprecated Use DynamicCustomTypeModelSchema instead */ export const CustomTypeModelSchema = DynamicCustomTypeModelSchema /** @deprecated Use DynamicCustomTypeModel instead */ export type CustomTypeModel = DynamicCustomTypeModel