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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { smartUnion } from "../../types/smartUnion.js";
import {
  AssistantMessage,
  AssistantMessage$Outbound,
  AssistantMessage$outboundSchema,
} from "./assistantmessage.js";
import {
  SystemMessage,
  SystemMessage$Outbound,
  SystemMessage$outboundSchema,
} from "./systemmessage.js";
import {
  ToolMessage,
  ToolMessage$Outbound,
  ToolMessage$outboundSchema,
} from "./toolmessage.js";
import {
  UserMessage,
  UserMessage$Outbound,
  UserMessage$outboundSchema,
} from "./usermessage.js";

export type ChatModerationRequestInputs2 =
  | (AssistantMessage & { role: "assistant" })
  | SystemMessage
  | ToolMessage
  | UserMessage;

export type ChatModerationRequestInputs1 =
  | (AssistantMessage & { role: "assistant" })
  | SystemMessage
  | ToolMessage
  | UserMessage;

/**
 * Chat to classify
 */
export type ChatModerationRequestInputs3 =
  | Array<
    | (AssistantMessage & { role: "assistant" })
    | SystemMessage
    | ToolMessage
    | UserMessage
  >
  | Array<
    Array<
      | (AssistantMessage & { role: "assistant" })
      | SystemMessage
      | ToolMessage
      | UserMessage
    >
  >;

export type ChatModerationRequest = {
  /**
   * Chat to classify
   */
  inputs:
    | Array<
      | (AssistantMessage & { role: "assistant" })
      | SystemMessage
      | ToolMessage
      | UserMessage
    >
    | Array<
      Array<
        | (AssistantMessage & { role: "assistant" })
        | SystemMessage
        | ToolMessage
        | UserMessage
      >
    >;
  model: string;
};

/** @internal */
export type ChatModerationRequestInputs2$Outbound =
  | (AssistantMessage$Outbound & { role: "assistant" })
  | SystemMessage$Outbound
  | ToolMessage$Outbound
  | UserMessage$Outbound;

/** @internal */
export const ChatModerationRequestInputs2$outboundSchema: z.ZodType<
  ChatModerationRequestInputs2$Outbound,
  ChatModerationRequestInputs2
> = z.union([
  AssistantMessage$outboundSchema.and(
    z.object({ role: z.literal("assistant") }),
  ),
  SystemMessage$outboundSchema,
  ToolMessage$outboundSchema,
  UserMessage$outboundSchema,
]);

export function chatModerationRequestInputs2ToJSON(
  chatModerationRequestInputs2: ChatModerationRequestInputs2,
): string {
  return JSON.stringify(
    ChatModerationRequestInputs2$outboundSchema.parse(
      chatModerationRequestInputs2,
    ),
  );
}

/** @internal */
export type ChatModerationRequestInputs1$Outbound =
  | (AssistantMessage$Outbound & { role: "assistant" })
  | SystemMessage$Outbound
  | ToolMessage$Outbound
  | UserMessage$Outbound;

/** @internal */
export const ChatModerationRequestInputs1$outboundSchema: z.ZodType<
  ChatModerationRequestInputs1$Outbound,
  ChatModerationRequestInputs1
> = z.union([
  AssistantMessage$outboundSchema.and(
    z.object({ role: z.literal("assistant") }),
  ),
  SystemMessage$outboundSchema,
  ToolMessage$outboundSchema,
  UserMessage$outboundSchema,
]);

export function chatModerationRequestInputs1ToJSON(
  chatModerationRequestInputs1: ChatModerationRequestInputs1,
): string {
  return JSON.stringify(
    ChatModerationRequestInputs1$outboundSchema.parse(
      chatModerationRequestInputs1,
    ),
  );
}

/** @internal */
export type ChatModerationRequestInputs3$Outbound =
  | Array<
    | (AssistantMessage$Outbound & { role: "assistant" })
    | SystemMessage$Outbound
    | ToolMessage$Outbound
    | UserMessage$Outbound
  >
  | Array<
    Array<
      | (AssistantMessage$Outbound & { role: "assistant" })
      | SystemMessage$Outbound
      | ToolMessage$Outbound
      | UserMessage$Outbound
    >
  >;

/** @internal */
export const ChatModerationRequestInputs3$outboundSchema: z.ZodType<
  ChatModerationRequestInputs3$Outbound,
  ChatModerationRequestInputs3
> = smartUnion([
  z.array(
    z.union([
      AssistantMessage$outboundSchema.and(
        z.object({ role: z.literal("assistant") }),
      ),
      SystemMessage$outboundSchema,
      ToolMessage$outboundSchema,
      UserMessage$outboundSchema,
    ]),
  ),
  z.array(
    z.array(
      z.union([
        AssistantMessage$outboundSchema.and(
          z.object({ role: z.literal("assistant") }),
        ),
        SystemMessage$outboundSchema,
        ToolMessage$outboundSchema,
        UserMessage$outboundSchema,
      ]),
    ),
  ),
]);

export function chatModerationRequestInputs3ToJSON(
  chatModerationRequestInputs3: ChatModerationRequestInputs3,
): string {
  return JSON.stringify(
    ChatModerationRequestInputs3$outboundSchema.parse(
      chatModerationRequestInputs3,
    ),
  );
}

/** @internal */
export type ChatModerationRequest$Outbound = {
  input:
    | Array<
      | (AssistantMessage$Outbound & { role: "assistant" })
      | SystemMessage$Outbound
      | ToolMessage$Outbound
      | UserMessage$Outbound
    >
    | Array<
      Array<
        | (AssistantMessage$Outbound & { role: "assistant" })
        | SystemMessage$Outbound
        | ToolMessage$Outbound
        | UserMessage$Outbound
      >
    >;
  model: string;
};

/** @internal */
export const ChatModerationRequest$outboundSchema: z.ZodType<
  ChatModerationRequest$Outbound,
  ChatModerationRequest
> = z.object({
  inputs: smartUnion([
    z.array(
      z.union([
        AssistantMessage$outboundSchema.and(
          z.object({ role: z.literal("assistant") }),
        ),
        SystemMessage$outboundSchema,
        ToolMessage$outboundSchema,
        UserMessage$outboundSchema,
      ]),
    ),
    z.array(
      z.array(
        z.union([
          AssistantMessage$outboundSchema.and(
            z.object({ role: z.literal("assistant") }),
          ),
          SystemMessage$outboundSchema,
          ToolMessage$outboundSchema,
          UserMessage$outboundSchema,
        ]),
      ),
    ),
  ]),
  model: z.string(),
}).transform((v) => {
  return remap$(v, {
    inputs: "input",
  });
});

export function chatModerationRequestToJSON(
  chatModerationRequest: ChatModerationRequest,
): string {
  return JSON.stringify(
    ChatModerationRequest$outboundSchema.parse(chatModerationRequest),
  );
}
