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

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

export type SystemMessageContent = string | Array<SystemMessageContentChunks>;

export const Role = {
  System: "system",
} as const;
export type Role = ClosedEnum<typeof Role>;

export type SystemMessage = {
  content: string | Array<SystemMessageContentChunks>;
  role?: Role | undefined;
};

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

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

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

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

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

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

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