/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { ClosedEnum } from "../../types/enums.js";
import {
  ContentChunk,
  ContentChunk$Outbound,
  ContentChunk$outboundSchema,
} from "./contentchunk.js";

export type UserMessageContent = string | Array<ContentChunk>;

export const UserMessageRole = {
  User: "user",
} as const;
export type UserMessageRole = ClosedEnum<typeof UserMessageRole>;

export type UserMessage = {
  content: string | Array<ContentChunk> | null;
  role?: UserMessageRole | undefined;
};

/** @internal */
export type UserMessageContent$Outbound = string | Array<ContentChunk$Outbound>;

/** @internal */
export const UserMessageContent$outboundSchema: z.ZodType<
  UserMessageContent$Outbound,
  z.ZodTypeDef,
  UserMessageContent
> = z.union([z.string(), z.array(ContentChunk$outboundSchema)]);

export function userMessageContentToJSON(
  userMessageContent: UserMessageContent,
): string {
  return JSON.stringify(
    UserMessageContent$outboundSchema.parse(userMessageContent),
  );
}

/** @internal */
export const UserMessageRole$outboundSchema: z.ZodNativeEnum<
  typeof UserMessageRole
> = z.nativeEnum(UserMessageRole);

/** @internal */
export type UserMessage$Outbound = {
  content: string | Array<ContentChunk$Outbound> | null;
  role: string;
};

/** @internal */
export const UserMessage$outboundSchema: z.ZodType<
  UserMessage$Outbound,
  z.ZodTypeDef,
  UserMessage
> = z.object({
  content: z.nullable(
    z.union([z.string(), z.array(ContentChunk$outboundSchema)]),
  ),
  role: UserMessageRole$outboundSchema.default("user"),
});

export function userMessageToJSON(userMessage: UserMessage): string {
  return JSON.stringify(UserMessage$outboundSchema.parse(userMessage));
}
