import { z } from 'zod'
import { DescriptionSchema, LabelSchema } from './shared'

export const OrganizationModelBrandingSchema = z
  .object({
    /**
     * @deprecated Prefer `identity.organizationName`; branding retains it for back-compat.
     * Legacy tenants that have not set `identity.organizationName` fall back to this field.
     */
    organizationName: LabelSchema,
    /**
     * @deprecated Prefer `identity.productName`; branding retains it for back-compat.
     * Legacy tenants that have not set `identity.productName` fall back to this field.
     */
    productName: LabelSchema,
    /**
     * @deprecated Prefer `identity.shortName`; branding retains it for back-compat.
     * Legacy tenants that have not set `identity.shortName` fall back to this field.
     */
    shortName: z.string().trim().min(1).max(40),
    /**
     * @deprecated Prefer `identity.description`; branding retains it for back-compat.
     * Legacy tenants that have not set `identity.description` fall back to this field.
     */
    description: DescriptionSchema.optional(),
    logos: z
      .object({
        light: z.string().trim().min(1).max(2048).optional(),
        dark: z.string().trim().min(1).max(2048).optional()
      })
      .default({}),
    /**
     * Brand voice — how the organization communicates. Plain-language description
     * of tone, register, and personality (e.g. "Direct and human — no jargon").
     * Max 280 characters.
     */
    voice: z.string().trim().max(280).optional(),
    /**
     * Brand tagline or positioning statement — the memorable one-liner that
     * captures the brand's promise or differentiator. Max 200 characters.
     */
    tagline: z.string().trim().max(200).optional(),
    /**
     * Core brand values — an ordered list of principles the organization stands
     * for (e.g. ["Transparency", "Craftsmanship", "Velocity"]). Each entry must
     * be a non-empty trimmed string.
     */
    values: z.array(z.string().trim().min(1)).optional(),
    /**
     * ID of the active UI theme preset from the UI theme-presets registry.
     * The UI layer resolves this to colors and typography via `usePresetsContext()`.
     * Free-form string — validation and fallback state are handled at the UI layer.
     * Min 1, max 64 characters.
     */
    themePresetId: z.string().trim().min(1).max(64).optional()
  })
  .passthrough()

export const DEFAULT_ORGANIZATION_MODEL_BRANDING: z.infer<typeof OrganizationModelBrandingSchema> = {
  organizationName: 'Default Organization',
  productName: 'Organization OS',
  shortName: 'Org OS',
  logos: {}
}
