import { z } from 'zod';

export const GuildFullSchema = z.object({
  id: z
    .string()
    .regex(
      new RegExp(
        "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
      ),
    )
    .describe("Unique identifier (UUID v4 or v5 format)"),
  legacyId: z
    .string()
    .max(50)
    .describe("Legacy system unique identifier for backward compatibility")
    .optional(),
  createdAt: z
    .number()
    .int()
    .gte(1)
    .describe("Unix timestamp of creation date"),
  updatedAt: z.number().int().gte(1).describe("Unix timestamp of last update"),
  system: z
    .object({})
    .catchall(z.any())
    .describe("System-managed settings for internal classification")
    .optional(),
  name: z
    .string()
    .min(1)
    .max(255)
    .describe("Name of the template (1-255 characters)"),
  urlName: z
    .string()
    .max(255)
    .describe("URL-friendly name (optional, max 255 characters)")
    .optional(),
  description: z
    .string()
    .max(3000)
    .describe(
      "Detailed description of the template (optional, max 3000 characters)",
    )
    .optional(),
  imageUrl: z
    .string()
    .max(255)
    .describe("URL to the template's primary image")
    .optional(),
  backgroundImageUrl: z
    .string()
    .max(255)
    .describe("URL to the template's background image")
    .optional(),
  visibility: z
    .object({})
    .catchall(z.any())
    .describe("Conditions that determine template visibility")
    .optional(),
  settings: z
    .object({})
    .catchall(z.any())
    .describe("Template-specific settings")
    .optional(),
  searchTags: z
    .array(z.string().max(50))
    .max(20)
    .describe("Tags used for template search functionality")
    .optional(),
  categoryTags: z
    .array(z.string().max(30))
    .max(10)
    .describe("Category classification tags")
    .optional(),
  socialLinks: z.record(z.string()).optional(),
  owner: z
    .string()
    .regex(
      new RegExp(
        "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
      ),
    )
    .describe("User ID of the owner. Unique identifier (UUID v4 or v5 format)"),
  permissions: z
    .object({
      read: z
        .string()
        .regex(
          new RegExp(
            "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
          ),
        )
        .describe("TODO")
        .optional(),
      update: z
        .string()
        .regex(
          new RegExp(
            "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
          ),
        )
        .describe("TODO")
        .optional(),
      delete: z
        .string()
        .regex(
          new RegExp(
            "^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
          ),
        )
        .describe("TODO")
        .optional(),
    })
    .optional(),
  adminRoleId: z
    .string()
    .describe("An admin role that accumulates all the privileges."),
  adminRoleGroupId: z
    .string()
    .describe("An admin role group that accumulates all the privileges."),
  homeRoleGroupId: z.string().nullable().optional(),
  memberCount: z
    .number()
    .int()
    .gte(0)
    .describe("The number of members in the guild"),
  roleCount: z
    .number()
    .int()
    .gte(0)
    .describe("The number of roles in the guild"),
  platforms: z
    .array(
      z.object({
        platformId: z.string().describe("The ID of the platform"),
        externalId: z
          .string()
          .describe("The ID related to the external platform"),
      }),
    )
    .optional(),
})
  .strict()
  .describe("A guild represents a community or organization");

