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

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

export type UserMessageContent = string | Array<ContentChunk>;

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

/** @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 type UserMessage$Outbound = {
  role: "user";
  content: string | Array<ContentChunk$Outbound> | null;
};

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

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