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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  LegacyExperimentRep,
  LegacyExperimentRep$inboundSchema,
  LegacyExperimentRep$Outbound,
  LegacyExperimentRep$outboundSchema,
} from "./legacyexperimentrep.js";

export type ExperimentInfoRep = {
  baselineIdx: number;
  items: Array<LegacyExperimentRep>;
};

/** @internal */
export const ExperimentInfoRep$inboundSchema: z.ZodType<
  ExperimentInfoRep,
  z.ZodTypeDef,
  unknown
> = z.object({
  baselineIdx: z.number().int(),
  items: z.array(LegacyExperimentRep$inboundSchema),
});
/** @internal */
export type ExperimentInfoRep$Outbound = {
  baselineIdx: number;
  items: Array<LegacyExperimentRep$Outbound>;
};

/** @internal */
export const ExperimentInfoRep$outboundSchema: z.ZodType<
  ExperimentInfoRep$Outbound,
  z.ZodTypeDef,
  ExperimentInfoRep
> = z.object({
  baselineIdx: z.number().int(),
  items: z.array(LegacyExperimentRep$outboundSchema),
});

export function experimentInfoRepToJSON(
  experimentInfoRep: ExperimentInfoRep,
): string {
  return JSON.stringify(
    ExperimentInfoRep$outboundSchema.parse(experimentInfoRep),
  );
}
export function experimentInfoRepFromJSON(
  jsonString: string,
): SafeParseResult<ExperimentInfoRep, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ExperimentInfoRep$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ExperimentInfoRep' from JSON`,
  );
}
