/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: c9beefa1092d
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ImageDetail,
  ImageDetail$inboundSchema,
  ImageDetail$outboundSchema,
} from "./imagedetail.js";

export type ImageURL = {
  url: string;
  detail?: ImageDetail | null | undefined;
};

/** @internal */
export const ImageURL$inboundSchema: z.ZodType<ImageURL, unknown> = z.object({
  url: z.string(),
  detail: z.nullable(ImageDetail$inboundSchema).optional(),
});
/** @internal */
export type ImageURL$Outbound = {
  url: string;
  detail?: string | null | undefined;
};

/** @internal */
export const ImageURL$outboundSchema: z.ZodType<ImageURL$Outbound, ImageURL> = z
  .object({
    url: z.string(),
    detail: z.nullable(ImageDetail$outboundSchema).optional(),
  });

export function imageURLToJSON(imageURL: ImageURL): string {
  return JSON.stringify(ImageURL$outboundSchema.parse(imageURL));
}
export function imageURLFromJSON(
  jsonString: string,
): SafeParseResult<ImageURL, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ImageURL$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ImageURL' from JSON`,
  );
}
