/*
 * 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";

/**
 * The audio accessibility mode (0 = Prefer non-accessibility audio, 1 = Prefer accessibility audio, 2 = Only show accessibility audio, 3 = Only show non-accessibility audio)
 */
export enum DefaultAudioAccessibility {
  PreferNonAccessibility = 0,
  PreferAccessibility = 1,
  OnlyAccessibility = 2,
  OnlyNonAccessibility = 3,
}

/**
 * The auto-select subtitle mode (0 = Manually selected, 1 = Shown with foreign audio, 2 = Always enabled)
 */
export enum AutoSelectSubtitle {
  ManuallySelected = 0,
  ShownWithForeignAudio = 1,
  AlwaysEnabled = 2,
}

/**
 * The subtitles for the deaf or hard-of-hearing (SDH) searches mode (0 = Prefer non-SDH subtitles, 1 = Prefer SDH subtitles, 2 = Only show SDH subtitles, 3 = Only show non-SDH subtitles)
 */
export enum DefaultSubtitleAccessibility {
  PreferNonSdh = 0,
  PreferSdh = 1,
  OnlySdh = 2,
  OnlyNonSdh = 3,
}

/**
 * The forced subtitles searches mode (0 = Prefer non-forced subtitles, 1 = Prefer forced subtitles, 2 = Only show forced subtitles, 3 = Only show non-forced subtitles)
 */
export enum DefaultSubtitleForced {
  PreferNonForced = 0,
  PreferForced = 1,
  OnlyForced = 2,
  OnlyNonForced = 3,
}

/**
 * Whether or not media watched indicators are enabled (little orange dot on media)
 */
export enum WatchedIndicator {
  None = 0,
  MoviesAndTvShows = 1,
  Movies = 2,
  TvShows = 3,
}

/**
 * Whether or not the account has media reviews visibility enabled
 */
export enum MediaReviewsVisibility {
  NoOne = 0,
  CriticsOnly = 1,
  PlexUsersOnly = 2,
  PlexUsersAndCritics = 3,
}

export type UserProfile = {
  /**
   * If the account has automatically select audio and subtitle tracks enabled
   */
  autoSelectAudio?: boolean | undefined;
  /**
   * The preferred audio language for the account
   */
  defaultAudioLanguage: string | null;
  defaultAudioAccessibility?: DefaultAudioAccessibility | undefined;
  /**
   * The preferred audio languages for the account
   */
  defaultAudioLanguages?: Array<string> | null | undefined;
  /**
   * The preferred subtitle language for the account
   */
  defaultSubtitleLanguage: string | null;
  /**
   * The preferred subtitle languages for the account
   */
  defaultSubtitleLanguages?: Array<string> | null | undefined;
  autoSelectSubtitle?: AutoSelectSubtitle | undefined;
  defaultSubtitleAccessibility?: DefaultSubtitleAccessibility | undefined;
  defaultSubtitleForced?: DefaultSubtitleForced | undefined;
  watchedIndicator?: WatchedIndicator | undefined;
  mediaReviewsVisibility?: MediaReviewsVisibility | undefined;
  /**
   * The languages for media reviews visibility
   */
  mediaReviewsLanguages?: Array<string> | null | undefined;
};

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

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

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

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

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

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

/** @internal */
export const UserProfile$inboundSchema: z.ZodType<
  UserProfile,
  z.ZodTypeDef,
  unknown
> = z.object({
  autoSelectAudio: z.boolean().default(true),
  defaultAudioLanguage: z.nullable(z.string()),
  defaultAudioAccessibility: DefaultAudioAccessibility$inboundSchema.default(
    DefaultAudioAccessibility.PreferNonAccessibility,
  ),
  defaultAudioLanguages: z.nullable(z.array(z.string())).optional(),
  defaultSubtitleLanguage: z.nullable(z.string()),
  defaultSubtitleLanguages: z.nullable(z.array(z.string())).optional(),
  autoSelectSubtitle: AutoSelectSubtitle$inboundSchema.default(
    AutoSelectSubtitle.ManuallySelected,
  ),
  defaultSubtitleAccessibility: DefaultSubtitleAccessibility$inboundSchema
    .default(DefaultSubtitleAccessibility.PreferNonSdh),
  defaultSubtitleForced: DefaultSubtitleForced$inboundSchema.default(
    DefaultSubtitleForced.PreferNonForced,
  ),
  watchedIndicator: WatchedIndicator$inboundSchema.default(
    WatchedIndicator.None,
  ),
  mediaReviewsVisibility: MediaReviewsVisibility$inboundSchema.default(
    MediaReviewsVisibility.NoOne,
  ),
  mediaReviewsLanguages: z.nullable(z.array(z.string())).optional(),
});

export function userProfileFromJSON(
  jsonString: string,
): SafeParseResult<UserProfile, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => UserProfile$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'UserProfile' from JSON`,
  );
}
