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

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

export type ScheduleCalendar = {
  second?: Array<ScheduleRange> | undefined;
  minute?: Array<ScheduleRange> | undefined;
  hour?: Array<ScheduleRange> | undefined;
  dayOfMonth?: Array<ScheduleRange> | undefined;
  month?: Array<ScheduleRange> | undefined;
  year?: Array<ScheduleRange> | undefined;
  dayOfWeek?: Array<ScheduleRange> | undefined;
  comment?: string | null | undefined;
};

/** @internal */
export const ScheduleCalendar$inboundSchema: z.ZodType<
  ScheduleCalendar,
  unknown
> = z.object({
  second: z.array(ScheduleRange$inboundSchema).optional(),
  minute: z.array(ScheduleRange$inboundSchema).optional(),
  hour: z.array(ScheduleRange$inboundSchema).optional(),
  day_of_month: z.array(ScheduleRange$inboundSchema).optional(),
  month: z.array(ScheduleRange$inboundSchema).optional(),
  year: z.array(ScheduleRange$inboundSchema).optional(),
  day_of_week: z.array(ScheduleRange$inboundSchema).optional(),
  comment: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "day_of_month": "dayOfMonth",
    "day_of_week": "dayOfWeek",
  });
});
/** @internal */
export type ScheduleCalendar$Outbound = {
  second?: Array<ScheduleRange$Outbound> | undefined;
  minute?: Array<ScheduleRange$Outbound> | undefined;
  hour?: Array<ScheduleRange$Outbound> | undefined;
  day_of_month?: Array<ScheduleRange$Outbound> | undefined;
  month?: Array<ScheduleRange$Outbound> | undefined;
  year?: Array<ScheduleRange$Outbound> | undefined;
  day_of_week?: Array<ScheduleRange$Outbound> | undefined;
  comment?: string | null | undefined;
};

/** @internal */
export const ScheduleCalendar$outboundSchema: z.ZodType<
  ScheduleCalendar$Outbound,
  ScheduleCalendar
> = z.object({
  second: z.array(ScheduleRange$outboundSchema).optional(),
  minute: z.array(ScheduleRange$outboundSchema).optional(),
  hour: z.array(ScheduleRange$outboundSchema).optional(),
  dayOfMonth: z.array(ScheduleRange$outboundSchema).optional(),
  month: z.array(ScheduleRange$outboundSchema).optional(),
  year: z.array(ScheduleRange$outboundSchema).optional(),
  dayOfWeek: z.array(ScheduleRange$outboundSchema).optional(),
  comment: z.nullable(z.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    dayOfMonth: "day_of_month",
    dayOfWeek: "day_of_week",
  });
});

export function scheduleCalendarToJSON(
  scheduleCalendar: ScheduleCalendar,
): string {
  return JSON.stringify(
    ScheduleCalendar$outboundSchema.parse(scheduleCalendar),
  );
}
export function scheduleCalendarFromJSON(
  jsonString: string,
): SafeParseResult<ScheduleCalendar, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ScheduleCalendar$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ScheduleCalendar' from JSON`,
  );
}
