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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  MessageInputEntry,
  MessageInputEntry$inboundSchema,
} from "./messageinputentry.js";
import {
  MessageOutputEntry,
  MessageOutputEntry$inboundSchema,
} from "./messageoutputentry.js";

export type MessageEntries = MessageInputEntry | MessageOutputEntry;

/** @internal */
export const MessageEntries$inboundSchema: z.ZodType<MessageEntries, unknown> =
  smartUnion([
    MessageInputEntry$inboundSchema,
    MessageOutputEntry$inboundSchema,
  ]);

export function messageEntriesFromJSON(
  jsonString: string,
): SafeParseResult<MessageEntries, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => MessageEntries$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'MessageEntries' from JSON`,
  );
}
