import BasePackage from "./base-package.mjs";
import * as fields from "../data/fields.mjs";
import AdditionalTypesField from "./sub-types.mjs";

/**
 * @import {SystemManifestData} from "./_types.mjs";
 */

/**
 * The data schema used to define System manifest files.
 * Extends the basic PackageData schema with some additional system-specific fields.
 * @extends BasePackage<SystemManifestData>
 */
export default class BaseSystem extends BasePackage {

  /** @inheritDoc */
  static defineSchema() {
    return Object.assign(super.defineSchema(), {
      type: new fields.StringField({required: true, choices: ["system"], initial: "system"}),
      documentTypes: new AdditionalTypesField(),
      background: new fields.StringField({required: false, blank: false}),
      initiative: new fields.StringField(),
      grid: new fields.SchemaField({
        type: new fields.NumberField({required: true, choices: Object.values(CONST.GRID_TYPES),
          initial: CONST.GRID_TYPES.SQUARE, validationError: "must be a value in CONST.GRID_TYPES"}),
        distance: new fields.NumberField({required: true, nullable: false, positive: true, initial: 1}),
        units: new fields.StringField({required: true}),
        diagonals: new fields.NumberField({required: true, choices: Object.values(CONST.GRID_DIAGONALS),
          initial: CONST.GRID_DIAGONALS.EQUIDISTANT, validationError: "must be a value in CONST.GRID_DIAGONALS"})
      }),
      primaryTokenAttribute: new fields.StringField(),
      secondaryTokenAttribute: new fields.StringField()
    });
  }

  /** @override */
  static type = "system";

  /**
   * The default icon used for this type of Package.
   * @type {string}
   */
  static icon = "fa-dice";

  /**
   * Does the system template request strict type checking of data compared to template.json inferred types.
   * @type {boolean}
   */
  strictDataCleaning = false;
}
