import { GROUP } from './constants.js'

/**
 * Default layout and groups
 */
export let DEFAULTS = null

Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
  const groups = GROUP
  Object.values(groups).forEach(group => {
    group.name = coreModule.api.Utils.i18n(group.name)
    group.listName = `Group: ${coreModule.api.Utils.i18n(group.listName ?? group.name)}`
  })
  const groupsArray = Object.values(groups)
  DEFAULTS = {
    layout: [
      {
        nestId: 'statistics',
        id: 'statistics',
        name: game.i18n.localize('CTHULHUETERNAL.Label.characteristics'),
        groups: [
          { ...groups.characteristics, nestId: 'statistics_characteristics' },
          { ...groups.other, nestId: 'statistics_other' },
          { ...groups.luck, nestId: 'statistics_luck' }
        ]
      },
      {
        nestId: 'skills',
        id: 'skills',
        name: game.i18n.localize('CTHULHUETERNAL.Label.skills'),
        groups: [
          { ...groups.skills, nestId: 'skills_skills' }
        ]
      },
      {
        nestId: 'equipment',
        id: 'equipment',
        name: game.i18n.localize('CTHULHUETERNAL.Label.gear'),
        groups: [
          { ...groups.weapons, nestId: 'equipment_weapons' },
          { ...groups.rituals, nestId: 'equipment_rituals' }
        ]
      }
    ],
    groups: groupsArray
  }
})
