/*
 * 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 { OpenAIContentItem$inboundSchema, OpenAIContentItem$outboundSchema, } from "./openaicontentitem.js";
import { OpenAIToolCall$inboundSchema, OpenAIToolCall$outboundSchema, } from "./openaitoolcall.js";
export const Visibility = {
    Private: "private",
    Public: "public",
};
export const CreateOpenAIConversationRole = {
    System: "system",
    User: "user",
    Assistant: "assistant",
};
export const CreateOpenAIConversationType1 = {
    Documentation: "documentation",
    Site: "site",
    DiscoursePost: "discourse_post",
    GithubIssue: "github_issue",
    GithubDiscussion: "github_discussion",
    StackoverflowQuestion: "stackoverflow_question",
    DiscordForumPost: "discord_forum_post",
    DiscordMessage: "discord_message",
    CustomQuestionAnswer: "custom_question_answer",
};
/** @internal */
export const Id$inboundSchema = z.union([
    z.string(),
    z.number(),
]);
/** @internal */
export const Id$outboundSchema = z
    .union([z.string(), z.number()]);
export function idToJSON(id) {
    return JSON.stringify(Id$outboundSchema.parse(id));
}
export function idFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Id$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Id' from JSON`);
}
/** @internal */
export const UserId$inboundSchema = z
    .union([z.string(), z.number()]);
/** @internal */
export const UserId$outboundSchema = z.union([z.string(), z.number()]);
export function userIdToJSON(userId) {
    return JSON.stringify(UserId$outboundSchema.parse(userId));
}
export function userIdFromJSON(jsonString) {
    return safeParse(jsonString, (x) => UserId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UserId' from JSON`);
}
/** @internal */
export const UserProperties$inboundSchema = collectExtraKeys$(z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
}).catchall(z.any()), "additionalProperties", true);
/** @internal */
export const UserProperties$outboundSchema = z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
    additionalProperties: z.record(z.any()).optional(),
}).transform((v) => {
    return {
        ...v.additionalProperties,
        ...remap$(v, {
            additionalProperties: null,
        }),
    };
});
export function userPropertiesToJSON(userProperties) {
    return JSON.stringify(UserProperties$outboundSchema.parse(userProperties));
}
export function userPropertiesFromJSON(jsonString) {
    return safeParse(jsonString, (x) => UserProperties$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UserProperties' from JSON`);
}
/** @internal */
export const Visibility$inboundSchema = z
    .nativeEnum(Visibility);
/** @internal */
export const Visibility$outboundSchema = Visibility$inboundSchema;
/** @internal */
export const CreateOpenAIConversationRole$inboundSchema = z.nativeEnum(CreateOpenAIConversationRole);
/** @internal */
export const CreateOpenAIConversationRole$outboundSchema = CreateOpenAIConversationRole$inboundSchema;
/** @internal */
export const CreateOpenAIConversationContent$inboundSchema = z.union([z.string(), z.array(OpenAIContentItem$inboundSchema)]);
/** @internal */
export const CreateOpenAIConversationContent$outboundSchema = z.union([z.string(), z.array(OpenAIContentItem$outboundSchema)]);
export function createOpenAIConversationContentToJSON(createOpenAIConversationContent) {
    return JSON.stringify(CreateOpenAIConversationContent$outboundSchema.parse(createOpenAIConversationContent));
}
export function createOpenAIConversationContentFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationContent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationContent' from JSON`);
}
/** @internal */
export const CreateOpenAIConversationType1$inboundSchema = z.nativeEnum(CreateOpenAIConversationType1);
/** @internal */
export const CreateOpenAIConversationType1$outboundSchema = CreateOpenAIConversationType1$inboundSchema;
/** @internal */
export const CreateOpenAIConversationType$inboundSchema = z.union([CreateOpenAIConversationType1$inboundSchema, z.string()]);
/** @internal */
export const CreateOpenAIConversationType$outboundSchema = z.union([CreateOpenAIConversationType1$outboundSchema, z.string()]);
export function createOpenAIConversationTypeToJSON(createOpenAIConversationType) {
    return JSON.stringify(CreateOpenAIConversationType$outboundSchema.parse(createOpenAIConversationType));
}
export function createOpenAIConversationTypeFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationType$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationType' from JSON`);
}
/** @internal */
export const CreateOpenAIConversationLinks$inboundSchema = z.object({
    label: z.nullable(z.string()).optional(),
    url: z.string(),
    title: z.nullable(z.string()).optional(),
    description: z.nullable(z.string()).optional(),
    type: z.nullable(z.union([CreateOpenAIConversationType1$inboundSchema, z.string()])).optional(),
    breadcrumbs: z.nullable(z.array(z.string())).optional(),
});
/** @internal */
export const CreateOpenAIConversationLinks$outboundSchema = z.object({
    label: z.nullable(z.string()).optional(),
    url: z.string(),
    title: z.nullable(z.string()).optional(),
    description: z.nullable(z.string()).optional(),
    type: z.nullable(z.union([CreateOpenAIConversationType1$outboundSchema, z.string()])).optional(),
    breadcrumbs: z.nullable(z.array(z.string())).optional(),
});
export function createOpenAIConversationLinksToJSON(createOpenAIConversationLinks) {
    return JSON.stringify(CreateOpenAIConversationLinks$outboundSchema.parse(createOpenAIConversationLinks));
}
export function createOpenAIConversationLinksFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationLinks$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationLinks' from JSON`);
}
/** @internal */
export const CreateOpenAIConversationId$inboundSchema = z.union([z.string(), z.number()]);
/** @internal */
export const CreateOpenAIConversationId$outboundSchema = z.union([z.string(), z.number()]);
export function createOpenAIConversationIdToJSON(createOpenAIConversationId) {
    return JSON.stringify(CreateOpenAIConversationId$outboundSchema.parse(createOpenAIConversationId));
}
export function createOpenAIConversationIdFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationId' from JSON`);
}
/** @internal */
export const CreateOpenAIConversationUserId$inboundSchema = z.union([z.string(), z.number()]);
/** @internal */
export const CreateOpenAIConversationUserId$outboundSchema = z.union([z.string(), z.number()]);
export function createOpenAIConversationUserIdToJSON(createOpenAIConversationUserId) {
    return JSON.stringify(CreateOpenAIConversationUserId$outboundSchema.parse(createOpenAIConversationUserId));
}
export function createOpenAIConversationUserIdFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationUserId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationUserId' from JSON`);
}
/** @internal */
export const CreateOpenAIConversationUserProperties$inboundSchema = collectExtraKeys$(z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
}).catchall(z.any()), "additionalProperties", true);
/** @internal */
export const CreateOpenAIConversationUserProperties$outboundSchema = z.object({
    id: z.nullable(z.union([z.string(), z.number()])).optional(),
    identificationType: z.nullable(z.string()).optional(),
    userId: z.nullable(z.union([z.string(), z.number()])).optional(),
    supportAgentName: z.nullable(z.string()).optional(),
    userType: z.nullable(z.string()).optional(),
    additionalProperties: z.record(z.any()).optional(),
}).transform((v) => {
    return {
        ...v.additionalProperties,
        ...remap$(v, {
            additionalProperties: null,
        }),
    };
});
export function createOpenAIConversationUserPropertiesToJSON(createOpenAIConversationUserProperties) {
    return JSON.stringify(CreateOpenAIConversationUserProperties$outboundSchema.parse(createOpenAIConversationUserProperties));
}
export function createOpenAIConversationUserPropertiesFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversationUserProperties$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversationUserProperties' from JSON`);
}
/** @internal */
export const Messages$inboundSchema = z.object({
    id: z.string().optional(),
    externalId: z.nullable(z.string()).optional(),
    externalUrl: z.nullable(z.string()).optional(),
    createdAt: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    updatedAt: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    role: CreateOpenAIConversationRole$inboundSchema,
    content: z.union([z.string(), z.array(OpenAIContentItem$inboundSchema)]),
    name: z.nullable(z.string()).optional(),
    links: z.nullable(z.array(z.lazy(() => CreateOpenAIConversationLinks$inboundSchema))).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => CreateOpenAIConversationUserProperties$inboundSchema)).optional(),
    tool_calls: z.nullable(z.array(OpenAIToolCall$inboundSchema)).optional(),
}).transform((v) => {
    return remap$(v, {
        "tool_calls": "toolCalls",
    });
});
/** @internal */
export const Messages$outboundSchema = z.object({
    id: z.string().optional(),
    externalId: z.nullable(z.string()).optional(),
    externalUrl: z.nullable(z.string()).optional(),
    createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    role: CreateOpenAIConversationRole$outboundSchema,
    content: z.union([z.string(), z.array(OpenAIContentItem$outboundSchema)]),
    name: z.nullable(z.string()).optional(),
    links: z.nullable(z.array(z.lazy(() => CreateOpenAIConversationLinks$outboundSchema))).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => CreateOpenAIConversationUserProperties$outboundSchema)).optional(),
    toolCalls: z.nullable(z.array(OpenAIToolCall$outboundSchema)).optional(),
}).transform((v) => {
    return remap$(v, {
        toolCalls: "tool_calls",
    });
});
export function messagesToJSON(messages) {
    return JSON.stringify(Messages$outboundSchema.parse(messages));
}
export function messagesFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Messages$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Messages' from JSON`);
}
/** @internal */
export const CreateOpenAIConversation$inboundSchema = z.object({
    id: z.string().optional(),
    externalId: z.nullable(z.string()).optional(),
    externalUrl: z.nullable(z.string()).optional(),
    type: z.literal("openai"),
    supportTicketConversationId: z.nullable(z.string()).optional(),
    createdAt: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    updatedAt: z.nullable(z.string().datetime({ offset: true }).transform(v => new Date(v))).optional(),
    projectId: z.nullable(z.string()).optional(),
    integrationId: z.nullable(z.string()).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => UserProperties$inboundSchema))
        .optional(),
    tags: z.nullable(z.array(z.string())).optional(),
    visibility: z.nullable(Visibility$inboundSchema).optional(),
    messages: z.array(z.lazy(() => Messages$inboundSchema)),
});
/** @internal */
export const CreateOpenAIConversation$outboundSchema = z.object({
    id: z.string().optional(),
    externalId: z.nullable(z.string()).optional(),
    externalUrl: z.nullable(z.string()).optional(),
    type: z.literal("openai"),
    supportTicketConversationId: z.nullable(z.string()).optional(),
    createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(),
    projectId: z.nullable(z.string()).optional(),
    integrationId: z.nullable(z.string()).optional(),
    properties: z.nullable(z.record(z.any())).optional(),
    userProperties: z.nullable(z.lazy(() => UserProperties$outboundSchema))
        .optional(),
    tags: z.nullable(z.array(z.string())).optional(),
    visibility: z.nullable(Visibility$outboundSchema).optional(),
    messages: z.array(z.lazy(() => Messages$outboundSchema)),
});
export function createOpenAIConversationToJSON(createOpenAIConversation) {
    return JSON.stringify(CreateOpenAIConversation$outboundSchema.parse(createOpenAIConversation));
}
export function createOpenAIConversationFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CreateOpenAIConversation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateOpenAIConversation' from JSON`);
}
//# sourceMappingURL=createopenaiconversation.js.map