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

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

export type SystemMessageContent = string | Array<SystemMessageContentChunks>;

export type SystemMessage = {
  role: "system";
  content: string | Array<SystemMessageContentChunks>;
};

/** @internal */
export type SystemMessageContent$Outbound =
  | string
  | Array<SystemMessageContentChunks$Outbound>;

/** @internal */
export const SystemMessageContent$outboundSchema: z.ZodType<
  SystemMessageContent$Outbound,
  SystemMessageContent
> = smartUnion([
  z.string(),
  z.array(SystemMessageContentChunks$outboundSchema),
]);

export function systemMessageContentToJSON(
  systemMessageContent: SystemMessageContent,
): string {
  return JSON.stringify(
    SystemMessageContent$outboundSchema.parse(systemMessageContent),
  );
}

/** @internal */
export type SystemMessage$Outbound = {
  role: "system";
  content: string | Array<SystemMessageContentChunks$Outbound>;
};

/** @internal */
export const SystemMessage$outboundSchema: z.ZodType<
  SystemMessage$Outbound,
  SystemMessage
> = z.object({
  role: z.literal("system"),
  content: smartUnion([
    z.string(),
    z.array(SystemMessageContentChunks$outboundSchema),
  ]),
});

export function systemMessageToJSON(systemMessage: SystemMessage): string {
  return JSON.stringify(SystemMessage$outboundSchema.parse(systemMessage));
}
