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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  RealtimeTranscriptionErrorDetail,
  RealtimeTranscriptionErrorDetail$inboundSchema,
  RealtimeTranscriptionErrorDetail$Outbound,
  RealtimeTranscriptionErrorDetail$outboundSchema,
} from "./realtimetranscriptionerrordetail.js";

export type RealtimeTranscriptionError = {
  type?: "error" | undefined;
  error: RealtimeTranscriptionErrorDetail;
};

/** @internal */
export const RealtimeTranscriptionError$inboundSchema: z.ZodType<
  RealtimeTranscriptionError,
  unknown
> = z.object({
  type: z.literal("error").default("error"),
  error: RealtimeTranscriptionErrorDetail$inboundSchema,
});
/** @internal */
export type RealtimeTranscriptionError$Outbound = {
  type: "error";
  error: RealtimeTranscriptionErrorDetail$Outbound;
};

/** @internal */
export const RealtimeTranscriptionError$outboundSchema: z.ZodType<
  RealtimeTranscriptionError$Outbound,
  RealtimeTranscriptionError
> = z.object({
  type: z.literal("error").default("error" as const),
  error: RealtimeTranscriptionErrorDetail$outboundSchema,
});

export function realtimeTranscriptionErrorToJSON(
  realtimeTranscriptionError: RealtimeTranscriptionError,
): string {
  return JSON.stringify(
    RealtimeTranscriptionError$outboundSchema.parse(realtimeTranscriptionError),
  );
}
export function realtimeTranscriptionErrorFromJSON(
  jsonString: string,
): SafeParseResult<RealtimeTranscriptionError, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => RealtimeTranscriptionError$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'RealtimeTranscriptionError' from JSON`,
  );
}
