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

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

/**
 * The data schema used to define Module manifest files.
 * Extends the basic PackageData schema with some additional module-specific fields.
 * @extends BasePackage<ModuleManifestData>
 */
export default class BaseModule extends BasePackage {

  /** @inheritDoc */
  static defineSchema() {
    return Object.assign(super.defineSchema(), {
      type: new fields.StringField({required: true, choices: ["module"], initial: "module"}),
      coreTranslation: new fields.BooleanField(),
      library: new fields.BooleanField(),
      documentTypes: new AdditionalTypesField(),
      quickstart: new fields.SchemaField({
        adventures: new fields.TypedObjectField(new fields.SchemaField({
          uuid: new fields.StringField({ required: true, blank: false })
        }), { expandKeys: false, validateKey: BasePackage.validateId }),
        postImport: new fields.BooleanField(),
        world: new fields.SchemaField({
          background: new fields.FilePathField({ categories: ["IMAGE"], required: false }),
          cover: new fields.FilePathField({ categories: ["IMAGE"], required: false }),
          description: new fields.HTMLField({ required: false })
        })
      }, { required: false, initial: undefined })
    });
  }

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

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