import HamalronItemSheet from "./base-item-sheet.mjs"

export default class HamalronFactionSheet extends HamalronItemSheet {
  /** @override */
  static DEFAULT_OPTIONS = {
    classes: ["faction"],
    position: {
      width: 620,
    },
    window: {
      contentClasses: ["faction-content"],
    },
  }

  /** @override */
  static PARTS = {
    tabs: {
      template: "templates/generic/tab-navigation.hbs",
    },
    main: {
      template: "systems/fvtt-hamalron/templates/faction.hbs",
    },
  }

  /** @override */
  tabGroups = {
    sheet: "main",
  }

  /**
   * Prepare an array of form header tabs.
   * @returns {Record<string, Partial<ApplicationTab>>}
   */
  #getTabs() {
    const tabs = {
      main: { id: "main", group: "sheet", icon: "fa-solid fa-circle-info", label: "HAMALRON.Label.Details" },
    }
    for (const v of Object.values(tabs)) {
      v.active = this.tabGroups[v.group] === v.id
      v.cssClass = v.active ? "active" : ""
    }
    return tabs
  }

  /** @override */
  async _prepareContext() {
    const context = await super._prepareContext()
    context.tabs = this.#getTabs()
    context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
    return context
  }
}
