import { z } from "zod";
import { MetadataLanguage } from "./language";

export const LibraryData = z.object({
	id: z.string(),
	path: z.string(),
	name: z.string(),
	type: z.enum(["MOVIE", "SERIES"]),
});
export type LibraryData = z.infer<typeof LibraryData>;

export const AccountData = z
	.object({
		email: z.string().min(3, "Email need at least 8 characters"),
		name: z.string().trim().min(3, "Name at least 3 characters"),
		password: z.string().min(8, "Passwords need at least 8 characters"),
		confirmPassword: z.string().min(8, "Passwords need at least 8 characters"),
	})
	.superRefine((data, ctx) => {
		if (data.password !== data.confirmPassword) {
			ctx.addIssue({
				code: "custom",
				message: "Passwords must match",
				path: ["confirmPassword"],
			});
		}
	});
export type AccountData = z.infer<typeof AccountData>;

export const OnboardStepType = z.enum([
	"ACCOUNT",
	"LIBRARIES",
	"LANGUAGE",
	"COMPLETE",
]);

export type OnboardStepType = z.infer<typeof OnboardStepType>;

export const OnboardConfigurationData = z.object({
	account: AccountData,
	libraries: z.array(LibraryData),
	languages: MetadataLanguage,
});
export type OnboardConfigurationData = z.infer<typeof OnboardConfigurationData>;

export const Path = z.object({
	path: z.string().array(),
});
export type Path = z.infer<typeof Path>;

export const Directory = z.object({
	type: z.enum(["FOLDER"]),
	name: z.string(),
});
export type Directory = z.infer<typeof Directory>;
