/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { PingEventData$inboundSchema, PingEventData$outboundSchema, } from "./pingeventdata.js";
import { ReadBatch$inboundSchema, ReadBatch$outboundSchema, } from "./readbatch.js";
export const ReadEvent3Event = {
    Ping: "ping",
};
export const ReadEventEvent = {
    Error: "error",
};
export const Event = {
    Batch: "batch",
};
/** @internal */
export const ReadEvent3Event$inboundSchema = z.nativeEnum(ReadEvent3Event);
/** @internal */
export const ReadEvent3Event$outboundSchema = ReadEvent3Event$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ReadEvent3Event$;
(function (ReadEvent3Event$) {
    /** @deprecated use `ReadEvent3Event$inboundSchema` instead. */
    ReadEvent3Event$.inboundSchema = ReadEvent3Event$inboundSchema;
    /** @deprecated use `ReadEvent3Event$outboundSchema` instead. */
    ReadEvent3Event$.outboundSchema = ReadEvent3Event$outboundSchema;
})(ReadEvent3Event$ || (ReadEvent3Event$ = {}));
/** @internal */
export const Ping$inboundSchema = z
    .object({
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({
                code: z.ZodIssueCode.custom,
                message: `malformed json: ${err}`,
            });
            return z.NEVER;
        }
    }).pipe(PingEventData$inboundSchema),
    event: ReadEvent3Event$inboundSchema,
});
/** @internal */
export const Ping$outboundSchema = z.object({
    data: PingEventData$outboundSchema,
    event: ReadEvent3Event$outboundSchema,
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var Ping$;
(function (Ping$) {
    /** @deprecated use `Ping$inboundSchema` instead. */
    Ping$.inboundSchema = Ping$inboundSchema;
    /** @deprecated use `Ping$outboundSchema` instead. */
    Ping$.outboundSchema = Ping$outboundSchema;
})(Ping$ || (Ping$ = {}));
export function pingToJSON(ping) {
    return JSON.stringify(Ping$outboundSchema.parse(ping));
}
export function pingFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Ping$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Ping' from JSON`);
}
/** @internal */
export const ReadEventEvent$inboundSchema = z.nativeEnum(ReadEventEvent);
/** @internal */
export const ReadEventEvent$outboundSchema = ReadEventEvent$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ReadEventEvent$;
(function (ReadEventEvent$) {
    /** @deprecated use `ReadEventEvent$inboundSchema` instead. */
    ReadEventEvent$.inboundSchema = ReadEventEvent$inboundSchema;
    /** @deprecated use `ReadEventEvent$outboundSchema` instead. */
    ReadEventEvent$.outboundSchema = ReadEventEvent$outboundSchema;
})(ReadEventEvent$ || (ReadEventEvent$ = {}));
/** @internal */
export const ErrorT$inboundSchema = z
    .object({
    data: z.string(),
    event: ReadEventEvent$inboundSchema,
});
/** @internal */
export const ErrorT$outboundSchema = z.object({
    data: z.string(),
    event: ReadEventEvent$outboundSchema,
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ErrorT$;
(function (ErrorT$) {
    /** @deprecated use `ErrorT$inboundSchema` instead. */
    ErrorT$.inboundSchema = ErrorT$inboundSchema;
    /** @deprecated use `ErrorT$outboundSchema` instead. */
    ErrorT$.outboundSchema = ErrorT$outboundSchema;
})(ErrorT$ || (ErrorT$ = {}));
export function errorToJSON(errorT) {
    return JSON.stringify(ErrorT$outboundSchema.parse(errorT));
}
export function errorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => ErrorT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ErrorT' from JSON`);
}
/** @internal */
export const Event$inboundSchema = z.nativeEnum(Event);
/** @internal */
export const Event$outboundSchema = Event$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var Event$;
(function (Event$) {
    /** @deprecated use `Event$inboundSchema` instead. */
    Event$.inboundSchema = Event$inboundSchema;
    /** @deprecated use `Event$outboundSchema` instead. */
    Event$.outboundSchema = Event$outboundSchema;
})(Event$ || (Event$ = {}));
/** @internal */
export const Batch$inboundSchema = z
    .object({
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({
                code: z.ZodIssueCode.custom,
                message: `malformed json: ${err}`,
            });
            return z.NEVER;
        }
    }).pipe(ReadBatch$inboundSchema),
    event: Event$inboundSchema,
    id: z.string(),
});
/** @internal */
export const Batch$outboundSchema = z.object({
    data: ReadBatch$outboundSchema,
    event: Event$outboundSchema,
    id: z.string(),
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var Batch$;
(function (Batch$) {
    /** @deprecated use `Batch$inboundSchema` instead. */
    Batch$.inboundSchema = Batch$inboundSchema;
    /** @deprecated use `Batch$outboundSchema` instead. */
    Batch$.outboundSchema = Batch$outboundSchema;
})(Batch$ || (Batch$ = {}));
export function batchToJSON(batch) {
    return JSON.stringify(Batch$outboundSchema.parse(batch));
}
export function batchFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Batch$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Batch' from JSON`);
}
/** @internal */
export const ReadEvent$inboundSchema = z.union([
    z.lazy(() => Batch$inboundSchema),
    z.lazy(() => ErrorT$inboundSchema),
    z.lazy(() => Ping$inboundSchema),
]);
/** @internal */
export const ReadEvent$outboundSchema = z.union([
    z.lazy(() => Batch$outboundSchema),
    z.lazy(() => ErrorT$outboundSchema),
    z.lazy(() => Ping$outboundSchema),
]);
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ReadEvent$;
(function (ReadEvent$) {
    /** @deprecated use `ReadEvent$inboundSchema` instead. */
    ReadEvent$.inboundSchema = ReadEvent$inboundSchema;
    /** @deprecated use `ReadEvent$outboundSchema` instead. */
    ReadEvent$.outboundSchema = ReadEvent$outboundSchema;
})(ReadEvent$ || (ReadEvent$ = {}));
export function readEventToJSON(readEvent) {
    return JSON.stringify(ReadEvent$outboundSchema.parse(readEvent));
}
export function readEventFromJSON(jsonString) {
    return safeParse(jsonString, (x) => ReadEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReadEvent' from JSON`);
}
//# sourceMappingURL=readevent.js.map