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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  collectExtraKeys as collectExtraKeys$,
  safeParse,
} from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type TranscriptionStreamLanguage = {
  type?: "transcription.language" | undefined;
  audioLanguage: string;
  additionalProperties?: { [k: string]: any } | undefined;
};

/** @internal */
export const TranscriptionStreamLanguage$inboundSchema: z.ZodType<
  TranscriptionStreamLanguage,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    type: z.literal("transcription.language").default("transcription.language"),
    audio_language: z.string(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
).transform((v) => {
  return remap$(v, {
    "audio_language": "audioLanguage",
  });
});
/** @internal */
export type TranscriptionStreamLanguage$Outbound = {
  type: "transcription.language";
  audio_language: string;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const TranscriptionStreamLanguage$outboundSchema: z.ZodType<
  TranscriptionStreamLanguage$Outbound,
  z.ZodTypeDef,
  TranscriptionStreamLanguage
> = z.object({
  type: z.literal("transcription.language").default(
    "transcription.language" as const,
  ),
  audioLanguage: z.string(),
  additionalProperties: z.record(z.any()).optional(),
}).transform((v) => {
  return {
    ...v.additionalProperties,
    ...remap$(v, {
      audioLanguage: "audio_language",
      additionalProperties: null,
    }),
  };
});

export function transcriptionStreamLanguageToJSON(
  transcriptionStreamLanguage: TranscriptionStreamLanguage,
): string {
  return JSON.stringify(
    TranscriptionStreamLanguage$outboundSchema.parse(
      transcriptionStreamLanguage,
    ),
  );
}
export function transcriptionStreamLanguageFromJSON(
  jsonString: string,
): SafeParseResult<TranscriptionStreamLanguage, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => TranscriptionStreamLanguage$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'TranscriptionStreamLanguage' from JSON`,
  );
}
