"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnauthorizedResponse$inboundSchema = exports.UnauthorizedResponseDetail$inboundSchema = exports.Two$inboundSchema = exports.Debug$inboundSchema = exports.ResponseT$inboundSchema = exports.RequestT$inboundSchema = exports.UnauthorizedResponse = void 0;
exports.requestFromJSON = requestFromJSON;
exports.responseFromJSON = responseFromJSON;
exports.debugFromJSON = debugFromJSON;
exports.twoFromJSON = twoFromJSON;
exports.unauthorizedResponseDetailFromJSON = unauthorizedResponseDetailFromJSON;
const z = __importStar(require("zod/v3"));
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const apideckerror_js_1 = require("./apideckerror.js");
/**
 * Unauthorized
 */
class UnauthorizedResponse extends apideckerror_js_1.ApideckError {
    constructor(err, httpMeta) {
        const message = err.message || `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        if (err.statusCode != null)
            this.statusCode = err.statusCode;
        if (err.error != null)
            this.error = err.error;
        if (err.typeName != null)
            this.typeName = err.typeName;
        if (err.detail != null)
            this.detail = err.detail;
        if (err.ref != null)
            this.ref = err.ref;
        this.name = "UnauthorizedResponse";
    }
}
exports.UnauthorizedResponse = UnauthorizedResponse;
/** @internal */
exports.RequestT$inboundSchema = z.object({});
function requestFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.RequestT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RequestT' from JSON`);
}
/** @internal */
exports.ResponseT$inboundSchema = z.object({});
function responseFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.ResponseT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseT' from JSON`);
}
/** @internal */
exports.Debug$inboundSchema = z
    .object({
    request: z.lazy(() => exports.RequestT$inboundSchema).optional(),
    response: z.lazy(() => exports.ResponseT$inboundSchema).optional(),
    message: z.string().optional(),
    code: z.string().optional(),
    credentials_expire_at_ms: z.number().optional(),
    retry_after_ms: z.number().optional(),
    cooldown_remaining_ms: z.number().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "credentials_expire_at_ms": "credentialsExpireAtMs",
        "retry_after_ms": "retryAfterMs",
        "cooldown_remaining_ms": "cooldownRemainingMs",
    });
});
function debugFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Debug$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Debug' from JSON`);
}
/** @internal */
exports.Two$inboundSchema = (0, schemas_js_1.collectExtraKeys)(z.object({
    type: z.string().optional(),
    message: z.string().optional(),
    debug: z.lazy(() => exports.Debug$inboundSchema).optional(),
}).catchall(z.any()), "additionalProperties", true);
function twoFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Two$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Two' from JSON`);
}
/** @internal */
exports.UnauthorizedResponseDetail$inboundSchema = z.union([z.string(), z.lazy(() => exports.Two$inboundSchema)]);
function unauthorizedResponseDetailFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.UnauthorizedResponseDetail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UnauthorizedResponseDetail' from JSON`);
}
/** @internal */
exports.UnauthorizedResponse$inboundSchema = z.object({
    status_code: z.number().optional(),
    error: z.string().optional(),
    type_name: z.string().optional(),
    message: z.string().optional(),
    detail: z.union([z.string(), z.lazy(() => exports.Two$inboundSchema)]).optional(),
    ref: z.string().optional(),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    const remapped = (0, primitives_js_1.remap)(v, {
        "status_code": "statusCode",
        "type_name": "typeName",
    });
    return new UnauthorizedResponse(remapped, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
//# sourceMappingURL=unauthorizedresponse.js.map