import { z } from "zod";

export const ActaLookupCompanyTypeSchema = z.enum([
  "SA_DE_CV",
  "SA",
  "S_DE_RL_DE_CV",
  "S_DE_RL",
  "SAS",
  "SAPI_DE_CV",
  "SC",
  "OTHER",
]);

export const ActaAdministrationTypeSchema = z.enum([
  "ADMIN_UNICO",
  "CONSEJO_ADMIN",
  "GERENTE_UNICO",
  "GERENTES",
  "OTHER",
]);

export const ActaForeignersClauseSchema = z.enum(["CLAUSULA_CALVO", "ADMITE_EXTRANJEROS", "NO_DETECTADO"]);

export const ActaFieldsSchema = z.object({
  name: z.string().nullable(),
  rfc: z.string().nullable(),
  legalRepresentative: z.string().nullable(),
  incorporationDate: z.string().nullable(),
  deedNumber: z.string().nullable(),
  notaryName: z.string().nullable(),
  fiscalAddress: z.string().nullable(),
  businessPurpose: z.string().nullable(),
  stateOfIncorporation: z.string().nullable(),
});

export const ActaLookupDictionarySchema = z.object({
  version: z.literal("mx_acta_constitutiva_reference_v1"),
  instrumentType: z.string().nullable(),
  instrumentNumber: z.string().nullable(),
  protocolVolumeBook: z.string().nullable(),
  instrumentDate: z.string().nullable(),
  placeOfGranting: z.string().nullable(),
  notaryName: z.string().nullable(),
  notaryNumber: z.string().nullable(),
  notaryState: z.string().nullable(),
  legalName: z.string().nullable(),
  normalizedName: z.string().nullable(),
  companyType: ActaLookupCompanyTypeSchema.nullable(),
  domicile: z.string().nullable(),
  duration: z.string().nullable(),
  corporatePurpose: z.string().nullable(),
  industry: z.string().nullable(),
  countryOfOperation: z.string().nullable(),
  stateOfIncorporation: z.string().nullable(),
  legalRepresentative: z.string().nullable(),
  rpcReference: z
    .object({
      folioMercantil: z.string().nullable(),
      registroPublico: z.string().nullable(),
      inscriptionDate: z.string().nullable(),
    })
    .nullable(),
  rfcCompany: z.string().nullable(),
  capitalTotal: z.string().nullable(),
  capitalFixed: z.string().nullable(),
  capitalVariable: z.string().nullable(),
  shareNominalValue: z.string().nullable(),
  administrationType: ActaAdministrationTypeSchema.nullable(),
  foreignersClause: ActaForeignersClauseSchema.nullable(),
  sreNameAuthorization: z.string().nullable(),
  derivedFields: z.object({
    isCompanyValidlyConstituted: z.boolean().nullable(),
    keySignersCandidates: z.array(z.string()).nullable(),
  }),
});

export type ActaFields = z.infer<typeof ActaFieldsSchema>;
export type ActaLookupDictionary = z.infer<typeof ActaLookupDictionarySchema>;
export type ActaLookupCompanyType = z.infer<typeof ActaLookupCompanyTypeSchema>;
export type ActaAdministrationType = z.infer<typeof ActaAdministrationTypeSchema>;
export type ActaForeignersClause = z.infer<typeof ActaForeignersClauseSchema>;
