/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod/v3";
import { safeParse } from "../../../lib/schemas.js";
import * as shared from "../shared/index.js";
import { UnstructuredClientError } from "./unstructuredclienterror.js";
export class HTTPValidationError extends UnstructuredClientError {
    constructor(err, httpMeta) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        if (err.detail != null)
            this.detail = err.detail;
        this.name = "HTTPValidationError";
    }
}
/** @internal */
export const Detail$inboundSchema = z
    .union([z.array(shared.ValidationError$inboundSchema), z.string()]);
/** @internal */
export const Detail$outboundSchema = z.union([z.array(shared.ValidationError$outboundSchema), z.string()]);
export function detailToJSON(detail) {
    return JSON.stringify(Detail$outboundSchema.parse(detail));
}
export function detailFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Detail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Detail' from JSON`);
}
/** @internal */
export const HTTPValidationError$inboundSchema = z.object({
    detail: z.union([z.array(shared.ValidationError$inboundSchema), z.string()])
        .optional(),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new HTTPValidationError(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const HTTPValidationError$outboundSchema = z.instanceof(HTTPValidationError)
    .transform(v => v.data$)
    .pipe(z.object({
    detail: z.union([
        z.array(shared.ValidationError$outboundSchema),
        z.string(),
    ]).optional(),
}));
//# sourceMappingURL=httpvalidationerror.js.map