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

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

export type UserMessageContent = string | Array<ContentChunk>;

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

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

/** @internal */
export const UserMessageContent$outboundSchema: z.ZodType<
  UserMessageContent$Outbound,
  UserMessageContent
> = smartUnion([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,
  UserMessage
> = z.object({
  role: z.literal("user"),
  content: z.nullable(
    smartUnion([z.string(), z.array(ContentChunk$outboundSchema)]),
  ),
});

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