import { $Fetch, CreateFetchOptions, FetchOptions } from "ofetch";

//#region src/contest.d.ts
/** General contest information. */
interface Contest<Problem = unknown, Format extends string | number | undefined = string | number | undefined> {
  id: string;
  title: string;
  description: string;
  format: Format;
  startTime?: Date;
  endTime?: Date;
  problems: Problem extends never ? never : Problem[];
}
//#endregion
//#region src/problem.d.ts
/** A sample input/output pair for a {@link Problem}. */
interface ProblemIOSample {
  input: string;
  output: string;
  hint?: string;
}
/** Well-classified {@link Problem} information. */
interface ProblemDescriptionObject {
  background: string;
  details: string;
  input: string;
  output: string;
  hint: string;
}
/** A tag for a {@link Problem}. */
interface TagInfo<Id extends string | number = string | number> {
  id: Id;
  name?: string;
}
/** General problem information. */
interface Problem$1<Desc extends string | ProblemDescriptionObject = string | ProblemDescriptionObject, Limits extends number | number[] | undefined = number | number[] | undefined, Difficulty extends string | number | undefined = string | number | undefined, Tags extends string[] | TagInfo[] | undefined = string[] | TagInfo[] | undefined, Type extends string = string> {
  id: string;
  type: Type;
  title: string;
  /** The problem description without the samples (unless otherwise specified). */
  description: Desc;
  link: string;
  samples: ProblemIOSample[];
  /** The time limit in milliseconds. */
  timeLimit: Limits;
  /** The memory limit in bytes. */
  memoryLimit: Limits;
  tags: Tags;
  difficulty: Difficulty;
}
//#endregion
//#region src/utils.d.ts
/** General error class for UnOJ. */
declare class UnOJError extends Error {}
//#endregion
//#region src/platform.d.ts
/** General platform constructor options. */
interface PlatformOptions<Locale extends string | never = never> {
  /**
   * [`ofetch`](https://npmjs.com/package/ofetch) instance to use.
   *
   * Overrides {@link ofetchDefaults} {@link ofetchCreateOptions} {@link baseURL}.
   */
  ofetch?: $Fetch;
  ofetchDefaults?: FetchOptions;
  ofetchCreateOptions?: CreateFetchOptions;
  baseURL?: string;
  /** I18n locale if the platform supports i18n. */
  locale?: Locale;
}
/**
 * The base class for all platforms.
 * Checkout the properties and methods to see what's available.
 *
 * ## Conventions
 *
 * - When a method is not implemented, it should throw an {@link UnsupportedError}.
 * - When a resource is not found, it should throw a {@link NotFoundError}.
 * - When the response is unexpected, it should throw an {@link UnexpectedResponseError}.
 */
declare abstract class Platform<Locale extends string | never = never> {
  readonly ofetch: $Fetch;
  readonly baseURL: string;
  /**
   * I18n locale if supported.
   *
   * Only platforms/methods that explicitly support i18n will use this, and the
   * format requirements are up to the platform.
   */
  locale?: Locale;
  constructor(options: PlatformOptions<Locale> | undefined, defaultBaseURL: string, defaultLocale?: Locale);
  /**
   * Fetch a problem from the platform.
   * @param _id The problem ID.
   * @returns The problem object.
   */
  getProblem(_id: string): Promise<Problem$1>;
  /**
   * Fetch a contest from the platform.
   * @param _id The contest ID.
   * @returns The contest object.
   */
  getContest(_id: string): Promise<Contest>;
}
/** An error that indicates a platform does not support a certain operation. */
declare class UnsupportedError extends UnOJError {
  constructor();
}
/** An error that indicates a platform does not have a certain resource. */
declare class NotFoundError extends UnOJError {
  thing: string;
  constructor(thing: string);
}
declare class UnexpectedResponseError extends UnOJError {
  data?: unknown | undefined;
  constructor(data?: unknown | undefined);
}
//#endregion
export { Contest, NotFoundError, Platform, PlatformOptions, Problem$1 as Problem, ProblemDescriptionObject, ProblemIOSample, TagInfo, UnexpectedResponseError, UnsupportedError };