import { z } from "zod"

import { tempImageVaultAssetSchema } from "../imageVault"
import { buttonSchema } from "./utils/buttonLinkSchema"
import { linkConnectionRefsSchema } from "./utils/linkConnection"

import { BlocksEnums } from "@/types/enums/blocks"

export const joinScandicFriendsSchema = z.object({
  join_scandic_friends: z.object({
    show_header: z.boolean().default(false),
    scripted_top_title: z.string(),
    title: z.string(),
    preamble: z.string(),
    image: tempImageVaultAssetSchema,
    show_usp: z.boolean().default(false),
    usp: z.array(z.string()),
    has_primary_button: z.boolean().default(false),
    primary_button: buttonSchema,
  }),
})

export const joinScandicFriendsBlockSchema = z
  .object({
    typename: z
      .literal(BlocksEnums.block.JoinScandicFriends)
      .optional()
      .default(BlocksEnums.block.JoinScandicFriends),
  })
  .merge(joinScandicFriendsSchema)

export const joinScandicFriendsBlockRefsSchema = z.object({
  join_scandic_friends: z.object({
    primary_button: linkConnectionRefsSchema,
  }),
})
