/*
 * 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 { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ToolConfiguration,
  ToolConfiguration$inboundSchema,
  ToolConfiguration$Outbound,
  ToolConfiguration$outboundSchema,
} from "./toolconfiguration.js";

export const WebSearchPremiumToolType = {
  WebSearchPremium: "web_search_premium",
} as const;
export type WebSearchPremiumToolType = ClosedEnum<
  typeof WebSearchPremiumToolType
>;

export type WebSearchPremiumTool = {
  toolConfiguration?: ToolConfiguration | null | undefined;
  type?: WebSearchPremiumToolType | undefined;
};

/** @internal */
export const WebSearchPremiumToolType$inboundSchema: z.ZodNativeEnum<
  typeof WebSearchPremiumToolType
> = z.nativeEnum(WebSearchPremiumToolType);
/** @internal */
export const WebSearchPremiumToolType$outboundSchema: z.ZodNativeEnum<
  typeof WebSearchPremiumToolType
> = WebSearchPremiumToolType$inboundSchema;

/** @internal */
export const WebSearchPremiumTool$inboundSchema: z.ZodType<
  WebSearchPremiumTool,
  z.ZodTypeDef,
  unknown
> = z.object({
  tool_configuration: z.nullable(ToolConfiguration$inboundSchema).optional(),
  type: WebSearchPremiumToolType$inboundSchema.default("web_search_premium"),
}).transform((v) => {
  return remap$(v, {
    "tool_configuration": "toolConfiguration",
  });
});
/** @internal */
export type WebSearchPremiumTool$Outbound = {
  tool_configuration?: ToolConfiguration$Outbound | null | undefined;
  type: string;
};

/** @internal */
export const WebSearchPremiumTool$outboundSchema: z.ZodType<
  WebSearchPremiumTool$Outbound,
  z.ZodTypeDef,
  WebSearchPremiumTool
> = z.object({
  toolConfiguration: z.nullable(ToolConfiguration$outboundSchema).optional(),
  type: WebSearchPremiumToolType$outboundSchema.default("web_search_premium"),
}).transform((v) => {
  return remap$(v, {
    toolConfiguration: "tool_configuration",
  });
});

export function webSearchPremiumToolToJSON(
  webSearchPremiumTool: WebSearchPremiumTool,
): string {
  return JSON.stringify(
    WebSearchPremiumTool$outboundSchema.parse(webSearchPremiumTool),
  );
}
export function webSearchPremiumToolFromJSON(
  jsonString: string,
): SafeParseResult<WebSearchPremiumTool, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => WebSearchPremiumTool$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'WebSearchPremiumTool' from JSON`,
  );
}
