diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43258ce..299be83 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: # Create a "module.zip" archive containing all the module's required files. # If you have other directories or files that will need to be added to # your packaged module, add them here. - - run: zip -r ./module.zip module.json readme.md LICENSE languages/ scripts/token-action-hud-dnd5e.min.js styles/ + - run: zip -r ./module.zip module.json readme.md LICENSE icons/ languages/ scripts/token-action-hud-dnd5e.min.js styles/ # Update the GitHub release with the manifest and module archive files. - name: Update Release with Files diff --git a/icons/exhaustion.svg b/icons/exhaustion.svg new file mode 100644 index 0000000..898c31d --- /dev/null +++ b/icons/exhaustion.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/module.json b/module.json index 9b90fa4..4da148e 100644 --- a/module.json +++ b/module.json @@ -19,7 +19,7 @@ "version": "This is auto replaced", "compatibility": { "minimum": "10", - "verified": "11.307" + "verified": "11.308" }, "esmodules": [ "./scripts/token-action-hud-dnd5e.min.js" @@ -90,7 +90,7 @@ "compatibility": [ { "minimum": "2.1.0", - "verified": "2.2.3" + "verified": "2.3.1" } ] } @@ -103,7 +103,7 @@ { "minimum": "1.4.8", "maximum": "1.4", - "verified": "1.4.18" + "verified": "1.4.19" } ] } diff --git a/scripts/action-handler.js b/scripts/action-handler.js index 0e37e55..e09bd81 100644 --- a/scripts/action-handler.js +++ b/scripts/action-handler.js @@ -161,6 +161,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { this.#buildAbilities('check', 'checks') this.#buildAbilities('save', 'saves') this.#buildCombat() + this.#buildExhaustion() this.#buildRests() this.#buildSkills() this.#buildUtility() @@ -450,6 +451,48 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { ]) } + /** + * Build exhaustion + * @private + */ + #buildExhaustion () { + // Exit if every actor is not the character type + if (this.actors.length === 0) return + if (!this.actors.every(actor => actor.type === 'character')) return + + const actionType = 'exhaustion' + + const id = 'exhaustion' + const name = coreModule.api.Utils.i18n('DND5E.Exhaustion') + const actionTypeName = `${coreModule.api.Utils.i18n(ACTION_TYPE[actionType])}: ` ?? '' + const listName = `${actionTypeName}${name}` + const encodedValue = [actionType, id].join(this.delimiter) + const img = coreModule.api.Utils.getImage('modules/token-action-hud-dnd5e/icons/exhaustion.svg') + const info1 = { text: this.actor.system.attributes.exhaustion } + let cssClass = '' + const active = this.actor.system.attributes.exhaustion > 0 + ? ' active' + : '' + cssClass = `toggle${active}` + + // Get actions + const actions = [{ + cssClass, + id, + name, + encodedValue, + img, + info1, + listName + }] + + // Create group data + const groupData = { id: 'exhaustion', type: 'system' } + + // Add actions to HUD + this.addActions(actions, groupData) + } + /** * Build features * @private @@ -1042,7 +1085,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { const activationTypes = Object.keys(game.dnd5e.config.abilityActivationTypes).filter((at) => at !== 'none') const activation = item.system.activation const activationType = activation?.type - if (activation && activationTypes.includes(activationType)) return true + if ((activation && activationTypes.includes(activationType)) || item.type === 'tool') return true return false } diff --git a/scripts/constants.js b/scripts/constants.js index c5a74c4..eee6afe 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -25,6 +25,7 @@ export const ACTION_TYPE = { check: 'tokenActionHud.dnd5e.check', condition: 'tokenActionHud.dnd5e.condition', effect: 'DND5E.Effect', + exhaustion: 'DND5E.Exhaustion', feature: 'ITEM.TypeFeat', item: 'tokenActionHud.dnd5e.item', save: 'DND5E.ActionSave', @@ -134,6 +135,7 @@ export const GROUP = { elementalDisciplines: { id: 'elemental-disciplines', name: 'tokenActionHud.dnd5e.elementalDisciplines', type: 'system' }, equipment: { id: 'equipment', name: 'ITEM.TypeEquipmentPl', type: 'system' }, equipped: { id: 'equipped', name: 'DND5E.Equipped', type: 'system' }, + exhaustion: { id: 'exhaustion', name: 'DND5E.Exhaustion', type: 'system' }, feats: { id: 'feats', name: 'tokenActionHud.dnd5e.feats', type: 'system' }, fightingStyles: { id: 'fighting-styles', name: 'tokenActionHud.dnd5e.fightingStyles', type: 'system' }, huntersPrey: { id: 'hunters-prey', name: 'tokenActionHud.dnd5e.huntersPrey', type: 'system' }, diff --git a/scripts/roll-handler.js b/scripts/roll-handler.js index 4301a4b..28fc8c4 100644 --- a/scripts/roll-handler.js +++ b/scripts/roll-handler.js @@ -55,6 +55,9 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { case 'effect': await this.#toggleEffect(event, actor, actionId) break + case 'exhaustion': + await this.#modifyExhaustion(event, actor) + break case 'feature': case 'item': case 'spell': @@ -76,6 +79,21 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { } } + /** + * Modify Exhaustion + * @private + * @param {object} event The event + * @param {object} actor The actor + */ + async #modifyExhaustion (event, actor) { + const isRightClick = this.isRightClick(event) + const exhaustion = actor.system.attributes.exhaustion + const update = (isRightClick) ? exhaustion - 1 : exhaustion + 1 + if (update >= 0) { + actor.update({ 'system.attributes.exhaustion': update }) + } + } + /** * Roll Ability * @private @@ -204,7 +222,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => { break case 'inspiration': { const update = !actor.system.attributes.inspiration - actor.update({ 'data.attributes.inspiration': update }) + actor.update({ 'system.attributes.inspiration': update }) break } case 'longRest': diff --git a/scripts/token-action-hud-dnd5e.min.js b/scripts/token-action-hud-dnd5e.min.js index de6723d..b84ec7a 100644 --- a/scripts/token-action-hud-dnd5e.min.js +++ b/scripts/token-action-hud-dnd5e.min.js @@ -1 +1 @@ -const e={ID:"token-action-hud-dnd5e"},t={ID:"token-action-hud-core"},s="1.4",i={ability:"DND5E.Ability",check:"tokenActionHud.dnd5e.check",condition:"tokenActionHud.dnd5e.condition",effect:"DND5E.Effect",feature:"ITEM.TypeFeat",item:"tokenActionHud.dnd5e.item",save:"DND5E.ActionSave",skill:"tokenActionHud.dnd5e.skill",spell:"ITEM.TypeSpell",utility:"DND5E.ActionUtil"},n={bonus:"fas fa-plus",crew:"fas fa-users",day:"fas fa-hourglass-end",hour:"fas fa-hourglass-half",lair:"fas fa-home",minute:"fas fa-hourglass-start",legendary:"fas fas fa-dragon",reaction:"fas fa-bolt",special:"fas fa-star"},a="fas fa-circle-c",l={blind:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},blinded:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},"Convenient Effect: Blinded":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},charmed:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.zZaEBrKkr66OWJvD"},"Convenient Effect: Charmed":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.zZaEBrKkr66OWJvD"},deaf:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},deafened:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},"Convenient Effect: Deafened":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},fear:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},"Convenient Effect: Frightened":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},frightened:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},grappled:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.gYDAhd02ryUmtwZn"},"Convenient Effect: Grappled":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.gYDAhd02ryUmtwZn"},incapacitated:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.TpkZgLfxCmSndmpb"},"Convenient Effect: Incapacitated":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.TpkZgLfxCmSndmpb"},invisible:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.3UU5GCTVeRDbZy9u"},"Convenient Effect: Invisible":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.3UU5GCTVeRDbZy9u"},paralysis:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},paralyzed:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},"Convenient Effect: Paralyzed":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},petrified:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xaNDaW6NwQTgHSmi"},"Convenient Effect: Petrified":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xaNDaW6NwQTgHSmi"},poison:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},poisoned:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},"Convenient Effect: Poisoned":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},prone:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.y0TkcdyoZlOTmAFT"},"Convenient Effect: Prone":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.y0TkcdyoZlOTmAFT"},restrain:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},restrained:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},"Convenient Effect: Restrained":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},stun:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},stunned:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},"Convenient Effect: Stunned":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},unconscious:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.UWw13ISmMxDzmwbd"},"Convenient Effect: Unconscious":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.UWw13ISmMxDzmwbd"},exhaustion:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 1":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 2":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 3":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 4":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 5":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"}},o={_1stLevelSpells:{id:"1st-level-spells",name:"tokenActionHud.dnd5e.1stLevelSpells",type:"system"},_2ndLevelSpells:{id:"2nd-level-spells",name:"tokenActionHud.dnd5e.2ndLevelSpells",type:"system"},_3rdLevelSpells:{id:"3rd-level-spells",name:"tokenActionHud.dnd5e.3rdLevelSpells",type:"system"},_4thLevelSpells:{id:"4th-level-spells",name:"tokenActionHud.dnd5e.4thLevelSpells",type:"system"},_5thLevelSpells:{id:"5th-level-spells",name:"tokenActionHud.dnd5e.5thLevelSpells",type:"system"},_6thLevelSpells:{id:"6th-level-spells",name:"tokenActionHud.dnd5e.6thLevelSpells",type:"system"},_7thLevelSpells:{id:"7th-level-spells",name:"tokenActionHud.dnd5e.7thLevelSpells",type:"system"},_8thLevelSpells:{id:"8th-level-spells",name:"tokenActionHud.dnd5e.8thLevelSpells",type:"system"},_9thLevelSpells:{id:"9th-level-spells",name:"tokenActionHud.dnd5e.9thLevelSpells",type:"system"},abilities:{id:"abilities",name:"tokenActionHud.dnd5e.abilities",type:"system"},actions:{id:"actions",name:"DND5E.ActionPl",type:"system"},activeFeatures:{id:"active-features",name:"tokenActionHud.dnd5e.activeFeatures",type:"system"},artificerInfusions:{id:"artificer-infusions",name:"tokenActionHud.dnd5e.artificerInfusions",type:"system"},atWillSpells:{id:"at-will-spells",name:"tokenActionHud.dnd5e.atWillSpells",type:"system"},backgroundFeatures:{id:"background-features",name:"tokenActionHud.dnd5e.backgroundFeatures",type:"system"},bonusActions:{id:"bonus-actions",name:"tokenActionHud.dnd5e.bonusActions",type:"system"},cantrips:{id:"cantrips",name:"tokenActionHud.dnd5e.cantrips",type:"system"},channelDivinity:{id:"channel-divinity",name:"tokenActionHud.dnd5e.channelDivinity",type:"system"},checks:{id:"checks",name:"tokenActionHud.dnd5e.checks",type:"system"},classFeatures:{id:"class-features",name:"tokenActionHud.dnd5e.classFeatures",type:"system"},combat:{id:"combat",name:"tokenActionHud.combat",type:"system"},conditions:{id:"conditions",name:"tokenActionHud.dnd5e.conditions",type:"system"},consumables:{id:"consumables",name:"ITEM.TypeConsumablePl",type:"system"},containers:{id:"containers",name:"ITEM.TypeContainerPl",type:"system"},crewActions:{id:"crew-actions",name:"tokenActionHud.dnd5e.crewActions",type:"system"},defensiveTactics:{id:"defensive-tactics",name:"tokenActionHud.dnd5e.defensiveTactics",type:"system"},eldritchInvocations:{id:"eldritch-invocations",name:"tokenActionHud.dnd5e.eldritchInvocations",type:"system"},elementalDisciplines:{id:"elemental-disciplines",name:"tokenActionHud.dnd5e.elementalDisciplines",type:"system"},equipment:{id:"equipment",name:"ITEM.TypeEquipmentPl",type:"system"},equipped:{id:"equipped",name:"DND5E.Equipped",type:"system"},feats:{id:"feats",name:"tokenActionHud.dnd5e.feats",type:"system"},fightingStyles:{id:"fighting-styles",name:"tokenActionHud.dnd5e.fightingStyles",type:"system"},huntersPrey:{id:"hunters-prey",name:"tokenActionHud.dnd5e.huntersPrey",type:"system"},innateSpells:{id:"innate-spells",name:"tokenActionHud.dnd5e.innateSpells",type:"system"},kiAbilities:{id:"ki-abilities",name:"tokenActionHud.dnd5e.kiAbilities",type:"system"},lairActions:{id:"lair-actions",name:"tokenActionHud.dnd5e.lairActions",type:"system"},legendaryActions:{id:"legendary-actions",name:"tokenActionHud.dnd5e.legendaryActions",type:"system"},loot:{id:"loot",name:"ITEM.TypeLootPl",type:"system"},maneuvers:{id:"maneuvers",name:"tokenActionHud.dnd5e.maneuvers",type:"system"},metamagicOptions:{id:"metamagic-options",name:"tokenActionHud.dnd5e.metamagicOptions",type:"system"},monsterFeatures:{id:"monster-features",name:"tokenActionHud.dnd5e.monsterFeatures",type:"system"},multiattacks:{id:"multiattacks",name:"tokenActionHud.dnd5e.multiattacks",type:"system"},otherActions:{id:"other-actions",name:"tokenActionHud.dnd5e.otherActions",type:"system"},pactBoons:{id:"pact-boons",name:"tokenActionHud.dnd5e.pactBoons",type:"system"},pactSpells:{id:"pact-spells",name:"tokenActionHud.dnd5e.pactSpells",type:"system"},passiveEffects:{id:"passive-effects",name:"DND5E.EffectPassive",type:"system"},passiveFeatures:{id:"passive-features",name:"tokenActionHud.dnd5e.passiveFeatures",type:"system"},psionicPowers:{id:"psionic-powers",name:"tokenActionHud.dnd5e.psionicPowers",type:"system"},raceFeatures:{id:"race-features",name:"tokenActionHud.dnd5e.raceFeatures",type:"system"},reactions:{id:"reactions",name:"DND5E.ReactionPl",type:"system"},rests:{id:"rests",name:"tokenActionHud.dnd5e.rests",type:"system"},runes:{id:"runes",name:"tokenActionHud.dnd5e.runes",type:"system"},saves:{id:"saves",name:"DND5E.ClassSaves",type:"system"},skills:{id:"skills",name:"tokenActionHud.dnd5e.skills",type:"system"},superiorHuntersDefense:{id:"superior-hunters-defense",name:"tokenActionHud.dnd5e.superiorHuntersDefense",type:"system"},temporaryEffects:{id:"temporary-effects",name:"DND5E.EffectTemporary",type:"system"},token:{id:"token",name:"tokenActionHud.token",type:"system"},tools:{id:"tools",name:"ITEM.TypeToolPl",type:"system"},unequipped:{id:"unequipped",name:"DND5E.Unequipped",type:"system"},utility:{id:"utility",name:"tokenActionHud.utility",type:"system"},weapons:{id:"weapons",name:"ITEM.TypeWeaponPl",type:"system"}},r="fas fa-sun",d={.5:"fas fa-adjust",1:"fas fa-check",2:"fas fa-check-double"},c={common:"tokenActionHud.dnd5e.common",uncommon:"tokenActionHud.dnd5e.uncommon",rare:"tokenActionHud.dnd5e.rare",veryRare:"tokenActionHud.dnd5e.veryRare",legendary:"tokenActionHud.dnd5e.legendary",artifact:"tokenActionHud.dnd5e.artifact"},p="fas fa-circle-r",u={ada:"DND5E.WeaponPropertiesAda",amm:"DND5E.WeaponPropertiesAmm",fin:"DND5E.WeaponPropertiesFin",fir:"DND5E.WeaponPropertiesFir",foc:"DND5E.WeaponPropertiesFoc",hvy:"DND5E.WeaponPropertiesHvy",lgt:"DND5E.WeaponPropertiesLgt",lod:"DND5E.WeaponPropertiesLod",mgc:"DND5E.WeaponPropertiesMgc",rch:"DND5E.WeaponPropertiesRch",rel:"DND5E.WeaponPropertiesRel",ret:"DND5E.WeaponPropertiesRet",sil:"DND5E.WeaponPropertiesSil",spc:"DND5E.WeaponPropertiesSpc",thr:"DND5E.WeaponPropertiesThr",two:"DND5E.WeaponPropertiesTwo",ver:"DND5E.WeaponPropertiesVer"};let m=null;Hooks.once("tokenActionHudCoreApiReady",(async t=>{m=class Utils{static getSetting(s,i=null){let n=i??null;try{n=game.settings.get(e.ID,s)}catch{t.api.Logger.debug(`Setting '${s}' not found`)}return n}static async setSetting(s,i){try{i=await game.settings.set(e.ID,s,i),t.api.Logger.debug(`Setting '${s}' set to '${i}'`)}catch{t.api.Logger.debug(`Setting '${s}' not found`)}}}}));let y=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{y=class ActionHandler extends e.api.ActionHandler{actors=null;tokens=null;actorType=null;items=null;abbreviateSkills=null;displaySpellInfo=null;showItemsWithoutActivationCosts=null;showUnchargedItems=null;showUnequippedItems=null;showUnpreparedSpells=null;activationgroupIds=null;featuregroupIds=null;inventorygroupIds=null;spellgroupIds=null;featureActions=null;inventoryActions=null;spellActions=null;systemVersion=game.dnd5e.version;async buildSystemActions(t){if(this.actors=this.actor?[this.actor]:this.#e(),this.tokens=this.token?[this.token]:this.#t(),this.actorType=this.actor?.type,this.actor){let t=this.actor.items;t=this.#s(t),t=e.api.Utils.sortItemsByName(t),this.items=t}this.abbreviateSkills=m.getSetting("abbreviateSkills"),this.displaySpellInfo=m.getSetting("displaySpellInfo"),this.showItemsWithoutActivationCosts=m.getSetting("showItemsWithoutActivationCosts"),this.showUnchargedItems=m.getSetting("showUnchargedItems"),this.showUnequippedItems=m.getSetting("showUnequippedItems"),"npc"!==this.actorType||this.showUnequippedItems||(this.showUnequippedItems=m.getSetting("showUnequippedItemsNpcs")),this.showUnpreparedSpells=m.getSetting("showUnpreparedSpells"),this.activationgroupIds=["actions","bonus-actions","crew-actions","lair-actions","legendary-actions","reactions","other-actions"],this.featuregroupIds=["active-features","passive-features","background-features","class-features","feats","monster-features","race-features","artificer-infusions","channel-divinity","defensive-tactics","eldritch-invocations","elemental-disciplines","fighting-styles","hunters-prey","ki-abilities","maneuvers","metamagic-options","multiattacks","pact-boons","psionic-powers","runes","superior-hunters-defense"],this.spellgroupIds=["cantrips","1st-level-spells","2nd-level-spells","3rd-level-spells","4th-level-spells","5th-level-spells","6th-level-spells","7th-level-spells","8th-level-spells","9th-level-spells","at-will-spells","innate-spells","pact-spells"],"character"===this.actorType||"npc"===this.actorType?(this.inventorygroupIds=["equipped","consumables","containers","equipment","loot","tools","weapons","unequipped"],await this.#i()):"vehicle"===this.actorType?(this.inventorygroupIds=["consumables","equipment","tools","weapons"],await this.#n()):this.actor||await this.#a()}async#i(){await Promise.all([this.#l(),this.#o(),this.#r(),this.#d(),this.#c()]),this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),this.#m(),this.#y(),this.#h()}async#n(){await Promise.all([this.#l(),this.#o(),this.#r(),this.#d()]),this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),this.#h()}async#a(){this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),await this.#l(),this.#m(),this.#y(),this.#h()}#p(t,s){const n=this.actor?this.actor.system.abilities:game.dnd5e.config.abilities;if(0===n.length)return;const a=Object.entries(n).filter((e=>0!==n[e[0]].value)).map((a=>{const l=a[0],o=`${t}-${a[0]}`,r=l.charAt(0).toUpperCase()+l.slice(1),d=this.systemVersion.startsWith("2.2")?game.dnd5e.config.abilities[l].label:game.dnd5e.config.abilities[l],c=this.abbreviateSkills?r:d,p=`${`${e.api.Utils.i18n(i[t])}: `??""}${d}`;return{id:o,name:c,encodedValue:[t,l].join(this.delimiter),icon1:"checks"!==s?this.#g(n[l].proficient):"",listName:p}})),l={id:s,type:"system"};this.addActions(a,l)}async#f(e,t,s="item"){const i=new Map,n={action:"actions",bonus:"bonus-actions",crew:"crew-actions",lair:"lair-actions",legendary:"legendary-actions",reaction:"reactions",reactiondamage:"reactions",reactionmanual:"reactions",other:"other-actions"};for(const[t,s]of e){const e=s.system?.activation?.type,a=n[Object.keys(n).includes(e)?e:"other"];i.has(a)||i.set(a,new Map),i.get(a).set(t,s)}for(const e of this.activationgroupIds){if(!i.has(e))continue;const n={...t,id:`${e}+${t.id}`,type:"system-derived"};["equipped","unequipped"].includes(t.id)&&(n.defaultSelected=!1);const a={id:e,type:"system"};await this.addGroup(n,a),this.addGroupInfo(t),await this.#v(i.get(e),n,s)}}#u(){const t="utility",s={initiative:{id:"initiative",name:e.api.Utils.i18n("tokenActionHud.dnd5e.rollInitiative")},endTurn:{id:"endTurn",name:e.api.Utils.i18n("tokenActionHud.endTurn")}};game.combat?.current?.tokenId!==this.token?.id&&delete s.endTurn;const n=Object.entries(s).map((s=>{const n=s[1].id,a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter),r={};let d="";if("initiative"===s[0]&&game.combat){const e=canvas.tokens.controlled.map((e=>e.id)),t=game.combat.combatants.filter((t=>e.includes(t.tokenId)));if(1===t.length){const e=t[0].initiative;r.class="tah-spotlight",r.text=e}d=`toggle${t.length>0&&t.every((e=>e?.initiative))?" active":""}`}return{id:n,name:a,encodedValue:o,info1:r,cssClass:d,listName:l}}));this.addActions(n,{id:"combat",type:"system"})}async#l(){if(0===this.tokens?.length)return;const t="condition",s=CONFIG.statusEffects.filter((e=>""!==e.id));if(0===s.length)return;const n=await Promise.all(s.map((async s=>{const n=s.id,a=e.api.Utils.i18n(s.label)??s.name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter),r=`toggle${this.actors.every((e=>game.version.startsWith("11")?e.effects.some((e=>e.statuses.some((e=>e===n))&&!e?.disabled)):e.effects.some((e=>e.flags?.core?.statusId===n&&!e?.disabled))))?" active":""}`,d=e.api.Utils.getImage(s),c=await this.#k(n,a),p=await this.#b(c);return{id:n,name:a,encodedValue:o,img:d,cssClass:r,listName:l,tooltip:p}})));this.addActions(n,{id:"conditions",type:"system"})}async#o(){const e="effect",t=this.actor.effects;if(0===t.size)return;const s=new Map,i=new Map;for(const[e,n]of t.entries()){n.isTemporary?i.set(e,n):s.set(e,n)}await Promise.all([this.#v(s,{id:"passive-effects",type:"system"},e),this.#v(i,{id:"temporary-effects",type:"system"},e)])}async#r(){const t="feature",s=new Map;for(const[e,t]of this.items){"feat"===t.type&&s.set(e,t)}if(0===s.size)return;const i=new Map,n=[{type:"background",groupId:"background-features"},{type:"class",groupId:"class-features"},{type:"monster",groupId:"monster-features"},{type:"race",groupId:"race-features"},{type:"feats",groupId:"feats"}],a=[{type:"artificerInfusion",groupId:"artificer-infusions"},{type:"channelDivinity",groupId:"channel-divinity"},{type:"defensiveTactic",groupId:"defensive-tactics"},{type:"eldritchInvocation",groupId:"eldritch-invocations"},{type:"elementalDiscipline",groupId:"elemental-disciplines"},{type:"fightingStyle",groupId:"fighting-styles"},{type:"huntersPrey",groupId:"hunters-prey"},{type:"ki",groupId:"ki-abilities"},{type:"maneuver",groupId:"maneuvers"},{type:"metamagic",groupId:"metamagic-options"},{type:"multiattack",groupId:"multiattacks"},{type:"pact",groupId:"pact-boons"},{type:"psionicPower",groupId:"psionic-powers"},{type:"rune",groupId:"runes"},{type:"superiorHuntersDefense",groupId:"superior-hunters-defense"}];for(const[e,t]of s){const s=t.system.activation?.type,l=t.system.type.value,o=t.system.type?.subtype;s&&(i.has("active-features")||i.set("active-features",new Map),i.get("active-features").set(e,t)),s&&""!==s||(i.has("passive-features")||i.set("passive-features",new Map),i.get("passive-features").set(e,t));for(const s of n){const n=s.groupId;s.type===l&&(i.has(n)||i.set(n,new Map),i.get(n).set(e,t))}for(const s of a){const n=s.groupId;o&&s.type===o&&(i.has(n)||i.set(n,new Map),i.get(n).set(e,t))}}const l={"active-features":e.api.Utils.i18n("tokenActionHud.dnd5e.activeFeatures"),"passive-features":e.api.Utils.i18n("tokenActionHud.dnd5e.passiveFeatures")};for(const e of this.featuregroupIds){if(!i.has(e))continue;const s={id:e,name:l[e]??"",type:"system"},n=i.get(e);await this.#v(n,s,t),l[e]&&await this.#f(n,s,t)}}async#d(){if(0===this.items.size)return;const t=new Map;for(const[e,s]of this.items){const i=s.system.equipped,n=s.system?.quantity>0,a=this.#A(s),l=this.#I(s),o=this.#w(s),r=s.type;n&&a&&(i&&(t.has("equipped")||t.set("equipped",new Map),t.get("equipped").set(e,s)),i||(t.has("unequipped")||t.set("unequipped",new Map),t.get("unequipped").set(e,s)),l&&"consumable"===r&&(t.has("consumables")||t.set("consumables",new Map),t.get("consumables").set(e,s)),o&&("backpack"===r&&(t.has("containers")||t.set("containers",new Map),t.get("containers").set(e,s)),"equipment"===r&&(t.has("equipment")||t.set("equipment",new Map),t.get("equipment").set(e,s)),"loot"===r&&(t.has("loot")||t.set("loot",new Map),t.get("loot").set(e,s)),"tool"===r&&(t.has("tools")||t.set("tools",new Map),t.get("tools").set(e,s)),"weapon"===r&&(t.has("weapons")||t.set("weapons",new Map),t.get("weapons").set(e,s))))}const s={equipped:e.api.Utils.i18n("DND5E.Equipped"),unequipped:e.api.Utils.i18n("DND5E.Unequipped"),consumables:e.api.Utils.i18n("ITEM.TypeConsumablePl"),containers:e.api.Utils.i18n("ITEM.TypeContainerPl"),equipment:e.api.Utils.i18n("ITEM.TypeEquipmentPl"),loot:e.api.Utils.i18n("ITEM.TypeLootPl"),tools:e.api.Utils.i18n("ITEM.TypeToolPl"),weapons:e.api.Utils.i18n("ITEM.TypeWeaponPl")};for(const e of this.inventorygroupIds){if(!t.has(e))continue;const i={id:e,name:s[e],type:"system"},n=t.get(e);await this.#v(n,i),this.activationgroupIds&&await this.#f(n,i)}}#m(){if(0===this.actors.length)return;if(!this.actors.every((e=>"character"===e.type)))return;const t="utility",s={shortRest:{name:e.api.Utils.i18n("DND5E.ShortRest")},longRest:{name:e.api.Utils.i18n("DND5E.LongRest")}},n=Object.entries(s).map((s=>{const n=s[0],a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter);return{id:n,name:a,encodedValue:o,listName:l}}));this.addActions(n,{id:"rests",type:"system"})}#y(){const t="skill",s=this.actor?this.actor.system.skills:game.dnd5e.config.skills;if(0===s.length)return;const n=Object.entries(s).map((n=>{try{const a=n[0],l=a.charAt(0).toUpperCase()+a.slice(1),o=this.abbreviateSkills?l:game.dnd5e.config.skills[a].label,r=`${`${e.api.Utils.i18n(i[t])}: `??""}${game.dnd5e.config.skills[a].label}`,d=[t,a].join(this.delimiter),c=this.#g(s[a].value),p=s[a].total;return{id:a,name:o,encodedValue:d,icon1:c,info1:this.actor?{text:p||0===p?`${p>=0?"+":""}${p}`:""}:"",listName:r}}catch(t){return e.api.Logger.error(n),null}})).filter((e=>!!e));this.addActions(n,{id:"skills",type:"system"})}async#c(){const t="spell",s=new Map;for(const[e,t]of this.items){if("spell"===t.type){const i=this.#I(t),n=this.#E(t);if(i&&n){switch(t.system.preparation.mode){case"atwill":s.has("at-will-spells")||s.set("at-will-spells",new Map),s.get("at-will-spells").set(e,t);break;case"innate":s.has("innate-spells")||s.set("innate-spells",new Map),s.get("innate-spells").set(e,t);break;case"pact":s.has("pact-spells")||s.set("pact-spells",new Map),s.get("pact-spells").set(e,t);break;default:switch(t.system.level){case 0:s.has("cantrips")||s.set("cantrips",new Map),s.get("cantrips").set(e,t);break;case 1:s.has("1st-level-spells")||s.set("1st-level-spells",new Map),s.get("1st-level-spells").set(e,t);break;case 2:s.has("2nd-level-spells")||s.set("2nd-level-spells",new Map),s.get("2nd-level-spells").set(e,t);break;case 3:s.has("3rd-level-spells")||s.set("3rd-level-spells",new Map),s.get("3rd-level-spells").set(e,t);break;case 4:s.has("4th-level-spells")||s.set("4th-level-spells",new Map),s.get("4th-level-spells").set(e,t);break;case 5:s.has("5th-level-spells")||s.set("5th-level-spells",new Map),s.get("5th-level-spells").set(e,t);break;case 6:s.has("6th-level-spells")||s.set("6th-level-spells",new Map),s.get("6th-level-spells").set(e,t);break;case 7:s.has("7th-level-spells")||s.set("7th-level-spells",new Map),s.get("7th-level-spells").set(e,t);break;case 8:s.has("8th-level-spells")||s.set("8th-level-spells",new Map),s.get("8th-level-spells").set(e,t);break;case 9:s.has("9th-level-spells")||s.set("9th-level-spells",new Map),s.get("9th-level-spells").set(e,t)}}}}}const i=Object.entries(this.actor.system.spells).reverse();let n=null;const a=[];let l=this.showUnchargedItems,o=this.showUnchargedItems;for(const[e,t]of i){const s=t.value>0,i=t.max>0,r=t.level>0;"pact"===e&&(!o&&s&&i&&r&&(o=!0),r||(o=!1),t.slotAvailable=o,n=[e,t]),e.startsWith("spell")&&"spell0"!==e?(!l&&s&&i&&(l=!0),t.slotAvailable=l,a.push([e,t])):s&&(t.slotsAvailable=!0,a.push(e,t))}if(n[1].slotAvailable){const e=a.findIndex((e=>e[0]==="spell"+n[1].level));a[e][1].slotsAvailable=!0}const r={"1st-level-spells":{spellMode:1,name:e.api.Utils.i18n("tokenActionHud.dnd5e.1stLevelSpells")},"2nd-level-spells":{spellMode:2,name:e.api.Utils.i18n("tokenActionHud.dnd5e.2ndLevelSpells")},"3rd-level-spells":{spellMode:3,name:e.api.Utils.i18n("tokenActionHud.dnd5e.3rdLevelSpells")},"4th-level-spells":{spellMode:4,name:e.api.Utils.i18n("tokenActionHud.dnd5e.4thLevelSpells")},"5th-level-spells":{spellMode:5,name:e.api.Utils.i18n("tokenActionHud.dnd5e.5thLevelSpells")},"6th-level-spells":{spellMode:6,name:e.api.Utils.i18n("tokenActionHud.dnd5e.6thLevelSpells")},"7th-level-spells":{spellMode:7,name:e.api.Utils.i18n("tokenActionHud.dnd5e.7thLevelSpells")},"8th-level-spells":{spellMode:8,name:e.api.Utils.i18n("tokenActionHud.dnd5e.8thLevelSpells")},"9th-level-spells":{spellMode:9,name:e.api.Utils.i18n("tokenActionHud.dnd5e.9thLevelSpells")},"at-will-spells":{spellMode:"atwill",name:e.api.Utils.i18n("tokenActionHud.dnd5e.atWillSpells")},cantrips:{spellMode:0,name:e.api.Utils.i18n("tokenActionHud.dnd5e.cantrips")},"innate-spells":{spellMode:"innate",name:e.api.Utils.i18n("tokenActionHud.dnd5e.innateSpells")},"pact-spells":{spellMode:"pact",name:e.api.Utils.i18n("tokenActionHud.dnd5e.pactSpells")}},d=["1","2","3","4","5","6","7","8","9","pact"];for(const e of this.spellgroupIds){const i=r[e].spellMode,l=r[e].name;if(!s.has(e))continue;const o="pact"===i?n[1]:a.find((e=>e[0]===`spell${i}`))?.[1],c=o?.value,p=o?.max,u=o?.slotAvailable;if(!u&&d.includes(i))continue;const m={};m.info1={class:"tah-spotlight",text:p>=0?`${c}/${p}`:""};const y={id:e,name:l,type:"system",info:m};this.addGroupInfo(y);const h=s.get(e);await this.#v(h,y,t),this.activationgroupIds&&await this.#f(h,y,t)}}#h(){if(0===this.actors.length)return;if(!this.actors.every((e=>"character"===e.type)))return;const t="utility",s={deathSave:{name:e.api.Utils.i18n("DND5E.DeathSave")},inspiration:{name:e.api.Utils.i18n("DND5E.Inspiration")}};(!this.actor||this.actor.system.attributes.hp.value>0)&&delete s.deathSave;const n=Object.entries(s).map((s=>{const n=s[0],a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter);let r="";if("inspiration"===s[0]){r=`toggle${this.actors.every((e=>e.system.attributes?.inspiration))?" active":""}`}return{id:n,name:a,encodedValue:o,cssClass:r,listName:l}}));this.addActions(n,{id:"utility",type:"system"})}async#v(e,t,s="item"){if(0===e.size)return;if(!("string"==typeof t?t:t?.id))return;const i=await Promise.all([...e].map((async e=>await this.#D(s,e[1]))));this.addActions(i,t)}async#D(t,s){const n=s.id??s._id;let a=s?.name??s?.label;s?.system?.recharge&&!s?.system?.recharge?.charged&&s?.system?.recharge?.value&&(a+=` (${e.api.Utils.i18n("DND5E.Recharge")})`);const l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`;let o="";if(Object.hasOwn(s,"disabled")){o=`toggle${s.disabled?"":" active"}`}const r=[t,n].join(this.delimiter),d=e.api.Utils.getImage(s),c=this.#S(s?.system?.activation?.type);let p=null,u=null;"spell"===s.type?(p=this.#U(s),this.displaySpellInfo&&(u=this.#C(s))):u=this.#H(s);const m=u?.info1,y=u?.info2,h=u?.info3,g=await this.#T(s);return{id:n,name:a,encodedValue:r,cssClass:o,img:d,icon1:c,icon2:p,info1:m,info2:y,info3:h,listName:l,tooltip:await this.#b(g)}}#A(e){if(this.showItemsWithoutActivationCosts)return!0;const t=Object.keys(game.dnd5e.config.abilityActivationTypes).filter((e=>"none"!==e)),s=e.system.activation,i=s?.type;return!(!s||!t.includes(i))}#w(e){const t=e.type;if(this.showUnequippedItems&&!["consumable","spell","feat"].includes(t))return!0;return!(!e.system.equipped||"consumable"===t)}#I(e){if(this.showUnchargedItems)return!0;return!!e.system.uses}#E(e){if("character"!==this.actorType&&this.showUnequippedItems)return!0;const t=e.system.preparation.prepared;if(this.showUnpreparedSpells)return!0;const s=e.system.level,i=Object.keys(game.dnd5e.config.spellPreparationModes).filter((e=>"prepared"!==e)),n=e.system.preparation.mode;return!(0!==s&&!i.includes(n)&&!t)}#H(e){return{info1:{text:this.#P(e)},info2:{text:this.#M(e)},info3:{text:this.#J(e)}}}#C(t){const s=t.system.components,i=[],n={},a={},l={};if(s?.vocal&&i.push(e.api.Utils.i18n("DND5E.ComponentVerbal")),s?.somatic&&i.push(e.api.Utils.i18n("DND5E.ComponentSomatic")),s?.material&&i.push(e.api.Utils.i18n("DND5E.ComponentMaterial")),i.length&&(n.title=i.join(", "),n.text=i.map((e=>e.charAt(0).toUpperCase())).join("")),s?.concentration){const t=e.api.Utils.i18n("DND5E.Concentration");a.title=t,a.text=t.charAt(0).toUpperCase()}if(s?.ritual){const t=e.api.Utils.i18n("DND5E.Ritual");l.title=t,l.text=t.charAt(0).toUpperCase()}return{info1:n,info2:a,info3:l}}#e(){const e=["character","npc"],t=canvas.tokens.controlled.filter((e=>e.actor)).map((e=>e.actor));return t.every((t=>e.includes(t.type)))?t:[]}#t(){const e=["character","npc"],t=canvas.tokens.controlled;return t.filter((e=>e.actor)).map((e=>e.actor)).every((t=>e.includes(t.type)))?t:[]}#P(e){const t=e?.system?.quantity??0;return t>1?t:""}#M(e){const t=e?.system?.uses;return t&&(t.value>0||t.max>0)?`${t.value??"0"}${t.max>0?`/${t.max}`:""}`:""}#J(e){const t=e?.system?.consume?.target,s=e?.system?.consume?.type;if(t===e.id)return"";if("attribute"===s){if(!t)return"";const e=t.substr(0,t.lastIndexOf(".")),s=this.actor.system[e];return s?`${s.value??"0"}${s.max?`/${s.max}`:""}`:""}const i=this.items.get(t);if("charges"===s){const e=i?.system.uses;return e?.value?`${e.value}${e.max?`/${e.max}`:""}`:""}return i?.system?.quantity??""}#s(e){if(m.getSetting("showSlowActions"))return e;const t=["minute","hour","day"],s=new Map;for(const[i,n]of e.entries()){const e=n.system?.activation?.type;t.includes(e)||s.set(i,n)}return s}#g(e){const t=CONFIG.DND5E.proficiencyLevels[e]??"",s=d[e];if(s)return``}#S(e){const t=CONFIG.DND5E.abilityActivationTypes[e]??"",s=n[e];if(s)return``}#U(t){const s=t.system.level,i=t.system.preparation.mode,n=t.system.preparation.prepared,a=n?"fas fa-sun":"fas fa-sun tah-icon-disabled",l=n?e.api.Utils.i18n("DND5E.SpellPrepared"):e.api.Utils.i18n("DND5E.SpellUnprepared");return"prepared"===i&&0!==s?``:""}async#T(e){if("none"===this.tooltipsSetting)return"";const t=e?.name??"";if("nameOnly"===this.tooltipsSetting)return t;return{name:t,description:"string"==typeof e?.system?.description?e?.system?.description:e?.system?.description?.value??"",modifiers:e?.modifiers??null,properties:[...e.system?.chatProperties??[],...e.system?.equippableItemChatProperties??[],...e.system?.activatedEffectChatProperties??[]].filter((e=>e)),rarity:e?.rarity??null,traits:"weapon"===e?.type?this.#Q(e?.system?.properties):null}}async#k(e,t){if("none"===this.tooltipsSetting)return"";if("nameOnly"===this.tooltipsSetting)return t;return{name:t,description:(l[e]&&l[e]?.uuid?await fromUuid(l[e].uuid):null)?.text?.content??""}}async#b(t){if("none"===this.tooltipsSetting)return"";if("string"==typeof t)return t;const s=e.api.Utils.i18n(t.name);if("nameOnly"===this.tooltipsSetting)return s;const i=`

${s}

`,n=t?.descriptionLocalised??await TextEditor.enrichHTML(e.api.Utils.i18n(t?.description??""),{async:!0}),a=t?.rarity?`${e.api.Utils.i18n(c[t.rarity])}`:"",l=t?.properties?`
${t.properties.map((t=>`${e.api.Utils.i18n(t)}`)).join("")}
`:"",o=t?.traits?t.traits.map((t=>`${e.api.Utils.i18n(t.label??t)}`)).join(""):"",r=t?.traits2?t.traits2.map((t=>`${e.api.Utils.i18n(t.label??t)}`)).join(""):"",d=t?.traitsAlt?t.traitsAlt.map((t=>`${e.api.Utils.i18n(t.label)}`)).join(""):"",p=t?.modifiers?`
${t.modifiers.filter((e=>e.enabled)).map((t=>`${e.api.Utils.i18n(t.label)} ${`${t.modifier>=0?"+":""}${t.modifier??""}`}`)).join("")}
`:"",u=[a,o,r,d].join(""),m=u?`
${u}
`:"";return n||m||p?`
${i}${m||p?`
${m}${p}
`:""}${n}${l}
`:s}#Q(t){return t?Object.entries(t).filter((([e,t])=>t&&u[e])).map((([t,s])=>e.api.Utils.i18n(u[t]))):null}}}));let h=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{const t=o;Object.values(t).forEach((t=>{t.name=e.api.Utils.i18n(t.name),t.listName=`Group: ${e.api.Utils.i18n(t.name)}`}));const s=Object.values(t);h={layout:[{nestId:"inventory",id:"inventory",name:e.api.Utils.i18n("DND5E.Inventory"),groups:[{...t.weapons,nestId:"inventory_weapons"},{...t.equipment,nestId:"inventory_equipment"},{...t.consumables,nestId:"inventory_consumables"},{...t.tools,nestId:"inventory_tools"},{...t.containers,nestId:"inventory_containers"},{...t.loot,nestId:"inventory_loot"}]},{nestId:"features",id:"features",name:e.api.Utils.i18n("DND5E.Features"),groups:[{...t.activeFeatures,nestId:"features_active-features"},{...t.passiveFeatures,nestId:"features_passive-features"}]},{nestId:"spells",id:"spells",name:e.api.Utils.i18n("ITEM.TypeSpellPl"),groups:[{...t.atWillSpells,nestId:"spells_at-will-spells"},{...t.innateSpells,nestId:"spells_innate-spells"},{...t.pactSpells,nestId:"spells_pact-spells"},{...t.cantrips,nestId:"spells_cantrips"},{...t._1stLevelSpells,nestId:"spells_1st-level-spells"},{...t._2ndLevelSpells,nestId:"spells_2nd-level-spells"},{...t._3rdLevelSpells,nestId:"spells_3rd-level-spells"},{...t._4thLevelSpells,nestId:"spells_4th-level-spells"},{...t._5thLevelSpells,nestId:"spells_5th-level-spells"},{...t._6thLevelSpells,nestId:"spells_6th-level-spells"},{...t._7thLevelSpells,nestId:"spells_7th-level-spells"},{...t._8thLevelSpells,nestId:"spells_8th-level-spells"},{...t._9thLevelSpells,nestId:"spells_9th-level-spells"}]},{nestId:"attributes",id:"attributes",name:e.api.Utils.i18n("DND5E.Attributes"),groups:[{...t.abilities,nestId:"attributes_abilities"},{...t.skills,nestId:"attributes_skills"}]},{nestId:"effects",id:"effects",name:e.api.Utils.i18n("DND5E.Effects"),groups:[{...t.temporaryEffects,nestId:"effects_temporary-effects"},{...t.passiveEffects,nestId:"effects_passive-effects"}]},{nestId:"conditions",id:"conditions",name:e.api.Utils.i18n("tokenActionHud.dnd5e.conditions"),groups:[{...t.conditions,nestId:"conditions_conditions"}]},{nestId:"utility",id:"utility",name:e.api.Utils.i18n("tokenActionHud.utility"),groups:[{...t.combat,nestId:"utility_combat"},{...t.token,nestId:"utility_token"},{...t.rests,nestId:"utility_rests"},{...t.utility,nestId:"utility_utility"}]}],groups:s}}));let g=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{g=class MagicItemActionListExtender extends e.api.ActionListExtender{constructor(e){super(e.categoryManager),this.actionHandler=e,this.categoryManager=e.categoryManager,this.actor=null}extendActionList(){if(this.actor=this.actionHandler.actor,!this.actor)return;const t=MagicItems.actor(this.actor.id);if(!t)return;const s=t.items??[];if(0===s.length)return;const i={id:"magic-items",type:"system"};s.forEach((t=>{if(t.attuned&&!this._isItemAttuned(t))return;if(t.equipped&&!this._isItemEquipped(t))return;const s={id:`magic-items_${t.id}`,name:t.name,type:"system-derived",info1:`${t.uses}/${t.charges}`};this.actionHandler.addGroup(s,i);const n=t.ownedEntries.map((s=>{const i=s.item,n=i.id;return{id:n,name:i.name,encodedValue:["magicItem",`${t.id}>${n}`].join("|"),img:e.api.Utils.getImage(i),info1:i.consumption,info2:i.baseLevel?`${e.api.Utils.i18n("DND5E.AbbreviationLevel")} ${i.baseLevel}`:"",selected:!0}}));this.actionHandler.addActions(n,s)}))}_isItemEquipped(e){return e.item.system.equipped}_isItemAttuned(e){return e.item.system.attunment!==(CONFIG.DND5E.attunementTypes?.REQUIRED??1)}}}));let f=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{f=class RollHandler extends e.api.RollHandler{async doHandleActionEvent(e,t){const s=t.split("|");2!==s.length&&super.throwInvalidValueErr();const i=s[0],n=s[1];if(this.actor)await this.#N(e,i,this.actor,this.token,n);else for(const t of canvas.tokens.controlled){const s=t.actor;await this.#N(e,i,s,t,n)}}async#N(e,t,s,i,n){switch(t){case"ability":this.#$(e,s,n);break;case"check":this.#j(e,s,n);break;case"save":this.#B(e,s,n);break;case"condition":if(!i)return;await this.#q(e,s,i,n);break;case"effect":await this.#L(e,s,n);break;case"feature":case"item":case"spell":case"weapon":this.isRenderItem()?this.doRenderItem(s,n):this.#_(e,s,n);break;case"magicItem":this.#R(s,n);break;case"skill":this.#x(e,s,n);break;case"utility":await this.#W(e,s,i,n)}}#$(e,t,s){t&&t.system?.abilities&&t.rollAbility(s,{event:e})}#B(e,t,s){t&&t.system?.abilities&&t.rollAbilitySave(s,{event:e})}#j(e,t,s){t&&t.system?.abilities&&t.rollAbilityTest(s,{event:e})}#R(e,t){const s=t.split(">"),i=s[0],n=s[1];MagicItems.actor(e.id).roll(i,n),Hooks.callAll("forceUpdateTokenActionHud")}#x(e,t,s){t&&t.system?.skills&&t.rollSkill(s,{event:e})}#_(t,s,i){const n=e.api.Utils.getItem(s,i);if(!this.#O(n))return n.use({event:t});n.rollRecharge()}#O(e){return e.system.recharge&&!e.system.recharge.charged&&e.system.recharge.value}async#W(e,t,s,i){switch(i){case"deathSave":t.rollDeathSave({event:e});break;case"endTurn":if(!s)break;game.combat?.current?.tokenId===s.id&&await(game.combat?.nextTurn());break;case"initiative":await this.#F(t);break;case"inspiration":{const e=!t.system.attributes.inspiration;t.update({"data.attributes.inspiration":e});break}case"longRest":t.longRest();break;case"shortRest":t.shortRest()}Hooks.callAll("forceUpdateTokenActionHud")}async#F(e){e&&(await e.rollInitiative({createCombatants:!0}),Hooks.callAll("forceUpdateTokenActionHud"))}async#q(e,t,s,i){if(!s)return;const n=this.isRightClick(e),a=CONFIG.statusEffects.find((e=>e.id===i)),l=a?.flags?Object.hasOwn(a.flags,"dfreds-convenient-effects")?a.flags["dfreds-convenient-effects"].isConvenient:null:i.startsWith("Convenient Effect");if(game.dfreds&&l)n?await game.dfreds.effectInterface.toggleEffect(a.name??a.label,{overlay:!0}):await game.dfreds.effectInterface.toggleEffect(a.name??a.label);else{const e=this.#Z(i);if(!e)return;const a=this.#G(t,i);a?.disabled&&await a.delete(),n?await s.toggleEffect(e,{overlay:!0}):await s.toggleEffect(e)}Hooks.callAll("forceUpdateTokenActionHud")}#Z(e){return CONFIG.statusEffects.find((t=>t.id===e))}#G(e,t){return game.version.startsWith("11")?e.effects.find((e=>e.statuses.every((e=>e===t)))):e.effects.find((e=>e.flags?.core?.statusId===t))}async#L(e,t,s){const i=("find"in t.effects.entries?t.effects.entries:t.effects).find((e=>e.id===s));if(!i)return;this.isRightClick(e)?await i.delete():await i.update({disabled:!i.disabled}),Hooks.callAll("forceUpdateTokenActionHud")}}}));class RollHandlerObsidian extends f{_rollAbilityTest(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"abl",abl:t})}_rollAbilitySave(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"save",save:t})}_rollSkill(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"skl",skl:t})}_useItem(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"item",id:t})}}function register(t){game.settings.register(e.ID,"abbreviateSkills",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.abbreviateSkills.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.abbreviateSkills.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showSlowActions",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showSlowActions.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showSlowActions.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"displaySpellInfo",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.displaySpellInfo.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.displaySpellInfo.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnchargedItems",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnchargedItems.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnchargedItems.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnequippedItems",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItems.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItems.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnequippedItemsNpcs",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItemsNpcs.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItemsNpcs.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnpreparedSpells",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnpreparedSpells.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnpreparedSpells.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showItemsWithoutActivationCosts",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showItemsWithoutActivationCosts.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showItemsWithoutActivationCosts.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}})}let v=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{v=class SystemManager extends e.api.SystemManager{doGetCategoryManager(){return new e.api.CategoryManager}doGetActionHandler(t){const s=new y(t);return(e.api.Utils.isModuleActive("magic-items-2")||e.api.Utils.isModuleActive("magicitems"))&&s.addFurtherActionHandler(new g(s)),s}getAvailableRollHandlers(){let t="Core D&D5e";e.api.Utils.isModuleActive("midi-qol")&&(t+=` [supports ${e.api.Utils.getModuleTitle("midi-qol")}]`);const s={core:t};return e.api.SystemManager.addHandler(s,"obsidian"),s}doGetRollHandler(e){let t;if("obsidian"===e)t=new RollHandlerObsidian;else t=new f;return t}doRegisterSettings(e){register(e)}async doRegisterDefaultFlags(){const t=h;if(game.modules.get("magicitems")?.active||game.modules.get("magic-items-2")?.active){const s=e.api.Utils.i18n("tokenActionHud.dnd5e.magicItems");t.groups.push({id:"magic-items",name:s,listName:`Group: ${s}`,type:"system"}),t.groups.sort(((e,t)=>e.id.localeCompare(t.id)))}return t}}})),Hooks.on("tokenActionHudCoreApiReady",(async()=>{const t=game.modules.get(e.ID);t.api={requiredCoreModuleVersion:"1.4",SystemManager:v},Hooks.call("tokenActionHudSystemReady",t)}));export{i as ACTION_TYPE,n as ACTIVATION_TYPE_ICON,y as ActionHandler,a as CONCENTRATION_ICON,l as CONDITION,t as CORE_MODULE,h as DEFAULTS,o as GROUP,e as MODULE,g as MagicItemActionListExtender,r as PREPARED_ICON,d as PROFICIENCY_LEVEL_ICON,c as RARITY,s as REQUIRED_CORE_MODULE_VERSION,p as RITUAL_ICON,f as RollHandler,RollHandlerObsidian,v as SystemManager,m as Utils,u as WEAPON_PROPERTY,register}; +const e={ID:"token-action-hud-dnd5e"},t={ID:"token-action-hud-core"},s="1.4",i={ability:"DND5E.Ability",check:"tokenActionHud.dnd5e.check",condition:"tokenActionHud.dnd5e.condition",effect:"DND5E.Effect",exhaustion:"DND5E.Exhaustion",feature:"ITEM.TypeFeat",item:"tokenActionHud.dnd5e.item",save:"DND5E.ActionSave",skill:"tokenActionHud.dnd5e.skill",spell:"ITEM.TypeSpell",utility:"DND5E.ActionUtil"},n={bonus:"fas fa-plus",crew:"fas fa-users",day:"fas fa-hourglass-end",hour:"fas fa-hourglass-half",lair:"fas fa-home",minute:"fas fa-hourglass-start",legendary:"fas fas fa-dragon",reaction:"fas fa-bolt",special:"fas fa-star"},a="fas fa-circle-c",l={blind:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},blinded:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},"Convenient Effect: Blinded":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.0b8N4FymGGfbZGpJ"},charmed:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.zZaEBrKkr66OWJvD"},"Convenient Effect: Charmed":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.zZaEBrKkr66OWJvD"},deaf:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},deafened:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},"Convenient Effect: Deafened":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.6G8JSjhn701cBITY"},fear:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},"Convenient Effect: Frightened":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},frightened:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.oreoyaFKnvZCrgij"},grappled:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.gYDAhd02ryUmtwZn"},"Convenient Effect: Grappled":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.gYDAhd02ryUmtwZn"},incapacitated:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.TpkZgLfxCmSndmpb"},"Convenient Effect: Incapacitated":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.TpkZgLfxCmSndmpb"},invisible:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.3UU5GCTVeRDbZy9u"},"Convenient Effect: Invisible":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.3UU5GCTVeRDbZy9u"},paralysis:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},paralyzed:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},"Convenient Effect: Paralyzed":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xnSV5hLJIMaTABXP"},petrified:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xaNDaW6NwQTgHSmi"},"Convenient Effect: Petrified":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.xaNDaW6NwQTgHSmi"},poison:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},poisoned:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},"Convenient Effect: Poisoned":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.lq3TRI6ZlED8ABMx"},prone:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.y0TkcdyoZlOTmAFT"},"Convenient Effect: Prone":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.y0TkcdyoZlOTmAFT"},restrain:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},restrained:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},"Convenient Effect: Restrained":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cSVcyZyNe2iG1fIc"},stun:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},stunned:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},"Convenient Effect: Stunned":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.ZyZMUwA2rboh4ObS"},unconscious:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.UWw13ISmMxDzmwbd"},"Convenient Effect: Unconscious":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.UWw13ISmMxDzmwbd"},exhaustion:{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 1":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 2":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 3":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 4":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"},"Convenient Effect: Exhaustion 5":{uuid:"Compendium.dnd5e.rules.JournalEntry.w7eitkpD7QQTB6j0.JournalEntryPage.cspWveykstnu3Zcv"}},o={_1stLevelSpells:{id:"1st-level-spells",name:"tokenActionHud.dnd5e.1stLevelSpells",type:"system"},_2ndLevelSpells:{id:"2nd-level-spells",name:"tokenActionHud.dnd5e.2ndLevelSpells",type:"system"},_3rdLevelSpells:{id:"3rd-level-spells",name:"tokenActionHud.dnd5e.3rdLevelSpells",type:"system"},_4thLevelSpells:{id:"4th-level-spells",name:"tokenActionHud.dnd5e.4thLevelSpells",type:"system"},_5thLevelSpells:{id:"5th-level-spells",name:"tokenActionHud.dnd5e.5thLevelSpells",type:"system"},_6thLevelSpells:{id:"6th-level-spells",name:"tokenActionHud.dnd5e.6thLevelSpells",type:"system"},_7thLevelSpells:{id:"7th-level-spells",name:"tokenActionHud.dnd5e.7thLevelSpells",type:"system"},_8thLevelSpells:{id:"8th-level-spells",name:"tokenActionHud.dnd5e.8thLevelSpells",type:"system"},_9thLevelSpells:{id:"9th-level-spells",name:"tokenActionHud.dnd5e.9thLevelSpells",type:"system"},abilities:{id:"abilities",name:"tokenActionHud.dnd5e.abilities",type:"system"},actions:{id:"actions",name:"DND5E.ActionPl",type:"system"},activeFeatures:{id:"active-features",name:"tokenActionHud.dnd5e.activeFeatures",type:"system"},artificerInfusions:{id:"artificer-infusions",name:"tokenActionHud.dnd5e.artificerInfusions",type:"system"},atWillSpells:{id:"at-will-spells",name:"tokenActionHud.dnd5e.atWillSpells",type:"system"},backgroundFeatures:{id:"background-features",name:"tokenActionHud.dnd5e.backgroundFeatures",type:"system"},bonusActions:{id:"bonus-actions",name:"tokenActionHud.dnd5e.bonusActions",type:"system"},cantrips:{id:"cantrips",name:"tokenActionHud.dnd5e.cantrips",type:"system"},channelDivinity:{id:"channel-divinity",name:"tokenActionHud.dnd5e.channelDivinity",type:"system"},checks:{id:"checks",name:"tokenActionHud.dnd5e.checks",type:"system"},classFeatures:{id:"class-features",name:"tokenActionHud.dnd5e.classFeatures",type:"system"},combat:{id:"combat",name:"tokenActionHud.combat",type:"system"},conditions:{id:"conditions",name:"tokenActionHud.dnd5e.conditions",type:"system"},consumables:{id:"consumables",name:"ITEM.TypeConsumablePl",type:"system"},containers:{id:"containers",name:"ITEM.TypeContainerPl",type:"system"},crewActions:{id:"crew-actions",name:"tokenActionHud.dnd5e.crewActions",type:"system"},defensiveTactics:{id:"defensive-tactics",name:"tokenActionHud.dnd5e.defensiveTactics",type:"system"},eldritchInvocations:{id:"eldritch-invocations",name:"tokenActionHud.dnd5e.eldritchInvocations",type:"system"},elementalDisciplines:{id:"elemental-disciplines",name:"tokenActionHud.dnd5e.elementalDisciplines",type:"system"},equipment:{id:"equipment",name:"ITEM.TypeEquipmentPl",type:"system"},equipped:{id:"equipped",name:"DND5E.Equipped",type:"system"},exhaustion:{id:"exhaustion",name:"DND5E.Exhaustion",type:"system"},feats:{id:"feats",name:"tokenActionHud.dnd5e.feats",type:"system"},fightingStyles:{id:"fighting-styles",name:"tokenActionHud.dnd5e.fightingStyles",type:"system"},huntersPrey:{id:"hunters-prey",name:"tokenActionHud.dnd5e.huntersPrey",type:"system"},innateSpells:{id:"innate-spells",name:"tokenActionHud.dnd5e.innateSpells",type:"system"},kiAbilities:{id:"ki-abilities",name:"tokenActionHud.dnd5e.kiAbilities",type:"system"},lairActions:{id:"lair-actions",name:"tokenActionHud.dnd5e.lairActions",type:"system"},legendaryActions:{id:"legendary-actions",name:"tokenActionHud.dnd5e.legendaryActions",type:"system"},loot:{id:"loot",name:"ITEM.TypeLootPl",type:"system"},maneuvers:{id:"maneuvers",name:"tokenActionHud.dnd5e.maneuvers",type:"system"},metamagicOptions:{id:"metamagic-options",name:"tokenActionHud.dnd5e.metamagicOptions",type:"system"},monsterFeatures:{id:"monster-features",name:"tokenActionHud.dnd5e.monsterFeatures",type:"system"},multiattacks:{id:"multiattacks",name:"tokenActionHud.dnd5e.multiattacks",type:"system"},otherActions:{id:"other-actions",name:"tokenActionHud.dnd5e.otherActions",type:"system"},pactBoons:{id:"pact-boons",name:"tokenActionHud.dnd5e.pactBoons",type:"system"},pactSpells:{id:"pact-spells",name:"tokenActionHud.dnd5e.pactSpells",type:"system"},passiveEffects:{id:"passive-effects",name:"DND5E.EffectPassive",type:"system"},passiveFeatures:{id:"passive-features",name:"tokenActionHud.dnd5e.passiveFeatures",type:"system"},psionicPowers:{id:"psionic-powers",name:"tokenActionHud.dnd5e.psionicPowers",type:"system"},raceFeatures:{id:"race-features",name:"tokenActionHud.dnd5e.raceFeatures",type:"system"},reactions:{id:"reactions",name:"DND5E.ReactionPl",type:"system"},rests:{id:"rests",name:"tokenActionHud.dnd5e.rests",type:"system"},runes:{id:"runes",name:"tokenActionHud.dnd5e.runes",type:"system"},saves:{id:"saves",name:"DND5E.ClassSaves",type:"system"},skills:{id:"skills",name:"tokenActionHud.dnd5e.skills",type:"system"},superiorHuntersDefense:{id:"superior-hunters-defense",name:"tokenActionHud.dnd5e.superiorHuntersDefense",type:"system"},temporaryEffects:{id:"temporary-effects",name:"DND5E.EffectTemporary",type:"system"},token:{id:"token",name:"tokenActionHud.token",type:"system"},tools:{id:"tools",name:"ITEM.TypeToolPl",type:"system"},unequipped:{id:"unequipped",name:"DND5E.Unequipped",type:"system"},utility:{id:"utility",name:"tokenActionHud.utility",type:"system"},weapons:{id:"weapons",name:"ITEM.TypeWeaponPl",type:"system"}},r="fas fa-sun",d={.5:"fas fa-adjust",1:"fas fa-check",2:"fas fa-check-double"},c={common:"tokenActionHud.dnd5e.common",uncommon:"tokenActionHud.dnd5e.uncommon",rare:"tokenActionHud.dnd5e.rare",veryRare:"tokenActionHud.dnd5e.veryRare",legendary:"tokenActionHud.dnd5e.legendary",artifact:"tokenActionHud.dnd5e.artifact"},p="fas fa-circle-r",u={ada:"DND5E.WeaponPropertiesAda",amm:"DND5E.WeaponPropertiesAmm",fin:"DND5E.WeaponPropertiesFin",fir:"DND5E.WeaponPropertiesFir",foc:"DND5E.WeaponPropertiesFoc",hvy:"DND5E.WeaponPropertiesHvy",lgt:"DND5E.WeaponPropertiesLgt",lod:"DND5E.WeaponPropertiesLod",mgc:"DND5E.WeaponPropertiesMgc",rch:"DND5E.WeaponPropertiesRch",rel:"DND5E.WeaponPropertiesRel",ret:"DND5E.WeaponPropertiesRet",sil:"DND5E.WeaponPropertiesSil",spc:"DND5E.WeaponPropertiesSpc",thr:"DND5E.WeaponPropertiesThr",two:"DND5E.WeaponPropertiesTwo",ver:"DND5E.WeaponPropertiesVer"};let m=null;Hooks.once("tokenActionHudCoreApiReady",(async t=>{m=class Utils{static getSetting(s,i=null){let n=i??null;try{n=game.settings.get(e.ID,s)}catch{t.api.Logger.debug(`Setting '${s}' not found`)}return n}static async setSetting(s,i){try{i=await game.settings.set(e.ID,s,i),t.api.Logger.debug(`Setting '${s}' set to '${i}'`)}catch{t.api.Logger.debug(`Setting '${s}' not found`)}}}}));let y=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{y=class ActionHandler extends e.api.ActionHandler{actors=null;tokens=null;actorType=null;items=null;abbreviateSkills=null;displaySpellInfo=null;showItemsWithoutActivationCosts=null;showUnchargedItems=null;showUnequippedItems=null;showUnpreparedSpells=null;activationgroupIds=null;featuregroupIds=null;inventorygroupIds=null;spellgroupIds=null;featureActions=null;inventoryActions=null;spellActions=null;systemVersion=game.dnd5e.version;async buildSystemActions(t){if(this.actors=this.actor?[this.actor]:this.#e(),this.tokens=this.token?[this.token]:this.#t(),this.actorType=this.actor?.type,this.actor){let t=this.actor.items;t=this.#s(t),t=e.api.Utils.sortItemsByName(t),this.items=t}this.abbreviateSkills=m.getSetting("abbreviateSkills"),this.displaySpellInfo=m.getSetting("displaySpellInfo"),this.showItemsWithoutActivationCosts=m.getSetting("showItemsWithoutActivationCosts"),this.showUnchargedItems=m.getSetting("showUnchargedItems"),this.showUnequippedItems=m.getSetting("showUnequippedItems"),"npc"!==this.actorType||this.showUnequippedItems||(this.showUnequippedItems=m.getSetting("showUnequippedItemsNpcs")),this.showUnpreparedSpells=m.getSetting("showUnpreparedSpells"),this.activationgroupIds=["actions","bonus-actions","crew-actions","lair-actions","legendary-actions","reactions","other-actions"],this.featuregroupIds=["active-features","passive-features","background-features","class-features","feats","monster-features","race-features","artificer-infusions","channel-divinity","defensive-tactics","eldritch-invocations","elemental-disciplines","fighting-styles","hunters-prey","ki-abilities","maneuvers","metamagic-options","multiattacks","pact-boons","psionic-powers","runes","superior-hunters-defense"],this.spellgroupIds=["cantrips","1st-level-spells","2nd-level-spells","3rd-level-spells","4th-level-spells","5th-level-spells","6th-level-spells","7th-level-spells","8th-level-spells","9th-level-spells","at-will-spells","innate-spells","pact-spells"],"character"===this.actorType||"npc"===this.actorType?(this.inventorygroupIds=["equipped","consumables","containers","equipment","loot","tools","weapons","unequipped"],await this.#i()):"vehicle"===this.actorType?(this.inventorygroupIds=["consumables","equipment","tools","weapons"],await this.#n()):this.actor||await this.#a()}async#i(){await Promise.all([this.#l(),this.#o(),this.#r(),this.#d(),this.#c()]),this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),this.#m(),this.#y(),this.#h(),this.#g()}async#n(){await Promise.all([this.#l(),this.#o(),this.#r(),this.#d()]),this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),this.#g()}async#a(){this.#p("ability","abilities"),this.#p("check","checks"),this.#p("save","saves"),this.#u(),await this.#l(),this.#y(),this.#h(),this.#g()}#p(t,s){const n=this.actor?this.actor.system.abilities:game.dnd5e.config.abilities;if(0===n.length)return;const a=Object.entries(n).filter((e=>0!==n[e[0]].value)).map((([a,l])=>{const o=`${t}-${a}`,r=a.charAt(0).toUpperCase()+a.slice(1),d=this.systemVersion>="2.2"?game.dnd5e.config.abilities[a].label:game.dnd5e.config.abilities[a],c=this.abbreviateSkills?r:d,p=`${`${e.api.Utils.i18n(i[t])}: `??""}${d}`,u=[t,a].join(this.delimiter),m="checks"!==s?this.#f(n[a].proficient):"",y="saves"!==s?l?.mod:"saves"===s?l?.save:"";return{id:o,name:c,encodedValue:u,icon1:m,info1:this.actor?{text:e.api.Utils.getModifier(y)}:null,info2:this.actor&&"abilities"===s?{text:`(${e.api.Utils.getModifier(l?.save)})`}:null,listName:p}})),l={id:s,type:"system"};this.addActions(a,l)}async#v(e,t,s="item"){const i=new Map,n={action:"actions",bonus:"bonus-actions",crew:"crew-actions",lair:"lair-actions",legendary:"legendary-actions",reaction:"reactions",reactiondamage:"reactions",reactionmanual:"reactions",other:"other-actions"};for(const[t,s]of e){const e=s.system?.activation?.type,a=n[Object.keys(n).includes(e)?e:"other"];i.has(a)||i.set(a,new Map),i.get(a).set(t,s)}for(const e of this.activationgroupIds){if(!i.has(e))continue;const n={...t,id:`${e}+${t.id}`,type:"system-derived"};["equipped","unequipped"].includes(t.id)&&(n.defaultSelected=!1);const a={id:e,type:"system"};await this.addGroup(n,a),this.addGroupInfo(t),await this.#b(i.get(e),n,s)}}#u(){const t="utility",s={initiative:{id:"initiative",name:e.api.Utils.i18n("tokenActionHud.dnd5e.rollInitiative")},endTurn:{id:"endTurn",name:e.api.Utils.i18n("tokenActionHud.endTurn")}};game.combat?.current?.tokenId!==this.token?.id&&delete s.endTurn;const n=Object.entries(s).map((s=>{const n=s[1].id,a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter),r={};let d="";if("initiative"===s[0]&&game.combat){const e=canvas.tokens.controlled.map((e=>e.id)),t=game.combat.combatants.filter((t=>e.includes(t.tokenId)));if(1===t.length){const e=t[0].initiative;r.class="tah-spotlight",r.text=e}d=`toggle${t.length>0&&t.every((e=>e?.initiative))?" active":""}`}return{id:n,name:a,encodedValue:o,info1:r,cssClass:d,listName:l}}));this.addActions(n,{id:"combat",type:"system"})}async#l(){if(0===this.tokens?.length)return;const t="condition",s=CONFIG.statusEffects.filter((e=>""!==e.id));if(0===s.length)return;const n=await Promise.all(s.map((async s=>{const n=s.id,a=e.api.Utils.i18n(s.label)??s.name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter),r=`toggle${this.actors.every((e=>game.version.startsWith("11")?e.effects.some((e=>e.statuses.some((e=>e===n))&&!e?.disabled)):e.effects.some((e=>e.flags?.core?.statusId===n&&!e?.disabled))))?" active":""}`,d=e.api.Utils.getImage(s),c=await this.#k(n,a),p=await this.#A(c);return{id:n,name:a,encodedValue:o,img:d,cssClass:r,listName:l,tooltip:p}})));this.addActions(n,{id:"conditions",type:"system"})}async#o(){const e="effect",t=this.actor.effects;if(0===t.size)return;const s=new Map,i=new Map;for(const[e,n]of t.entries()){n.isTemporary?i.set(e,n):s.set(e,n)}await Promise.all([this.#b(s,{id:"passive-effects",type:"system"},e),this.#b(i,{id:"temporary-effects",type:"system"},e)])}#m(){if(0===this.actors.length)return;if(!this.actors.every((e=>"character"===e.type)))return;const t="exhaustion",s="exhaustion",n=e.api.Utils.i18n("DND5E.Exhaustion"),a=`${`${e.api.Utils.i18n(i[t])}: `??""}${n}`,l=[t,s].join(this.delimiter),o=e.api.Utils.getImage("modules/token-action-hud-dnd5e/icons/exhaustion.svg"),r={text:this.actor.system.attributes.exhaustion};let d="";d=`toggle${this.actor.system.attributes.exhaustion>0?" active":""}`;const c=[{cssClass:d,id:s,name:n,encodedValue:l,img:o,info1:r,listName:a}];this.addActions(c,{id:"exhaustion",type:"system"})}async#r(){const t="feature",s=new Map;for(const[e,t]of this.items){"feat"===t.type&&s.set(e,t)}if(0===s.size)return;const i=new Map,n=[{type:"background",groupId:"background-features"},{type:"class",groupId:"class-features"},{type:"monster",groupId:"monster-features"},{type:"race",groupId:"race-features"},{type:"feats",groupId:"feats"}],a=[{type:"artificerInfusion",groupId:"artificer-infusions"},{type:"channelDivinity",groupId:"channel-divinity"},{type:"defensiveTactic",groupId:"defensive-tactics"},{type:"eldritchInvocation",groupId:"eldritch-invocations"},{type:"elementalDiscipline",groupId:"elemental-disciplines"},{type:"fightingStyle",groupId:"fighting-styles"},{type:"huntersPrey",groupId:"hunters-prey"},{type:"ki",groupId:"ki-abilities"},{type:"maneuver",groupId:"maneuvers"},{type:"metamagic",groupId:"metamagic-options"},{type:"multiattack",groupId:"multiattacks"},{type:"pact",groupId:"pact-boons"},{type:"psionicPower",groupId:"psionic-powers"},{type:"rune",groupId:"runes"},{type:"superiorHuntersDefense",groupId:"superior-hunters-defense"}];for(const[e,t]of s){const s=t.system.activation?.type,l=t.system.type.value,o=t.system.type?.subtype;s&&(i.has("active-features")||i.set("active-features",new Map),i.get("active-features").set(e,t)),s&&""!==s||(i.has("passive-features")||i.set("passive-features",new Map),i.get("passive-features").set(e,t));for(const s of n){const n=s.groupId;s.type===l&&(i.has(n)||i.set(n,new Map),i.get(n).set(e,t))}for(const s of a){const n=s.groupId;o&&s.type===o&&(i.has(n)||i.set(n,new Map),i.get(n).set(e,t))}}const l={"active-features":e.api.Utils.i18n("tokenActionHud.dnd5e.activeFeatures"),"passive-features":e.api.Utils.i18n("tokenActionHud.dnd5e.passiveFeatures")};for(const e of this.featuregroupIds){if(!i.has(e))continue;const s={id:e,name:l[e]??"",type:"system"},n=i.get(e);await this.#b(n,s,t),l[e]&&await this.#v(n,s,t)}}async#d(){if(0===this.items.size)return;const t=new Map;for(const[e,s]of this.items){const i=s.system.equipped,n=s.system?.quantity>0,a=this.#I(s),l=this.#E(s),o=this.#w(s),r=s.type;n&&a&&(i&&(t.has("equipped")||t.set("equipped",new Map),t.get("equipped").set(e,s)),i||(t.has("unequipped")||t.set("unequipped",new Map),t.get("unequipped").set(e,s)),l&&"consumable"===r&&(t.has("consumables")||t.set("consumables",new Map),t.get("consumables").set(e,s)),o&&("backpack"===r&&(t.has("containers")||t.set("containers",new Map),t.get("containers").set(e,s)),"equipment"===r&&(t.has("equipment")||t.set("equipment",new Map),t.get("equipment").set(e,s)),"loot"===r&&(t.has("loot")||t.set("loot",new Map),t.get("loot").set(e,s)),"tool"===r&&(t.has("tools")||t.set("tools",new Map),t.get("tools").set(e,s)),"weapon"===r&&(t.has("weapons")||t.set("weapons",new Map),t.get("weapons").set(e,s))))}const s={equipped:e.api.Utils.i18n("DND5E.Equipped"),unequipped:e.api.Utils.i18n("DND5E.Unequipped"),consumables:e.api.Utils.i18n("ITEM.TypeConsumablePl"),containers:e.api.Utils.i18n("ITEM.TypeContainerPl"),equipment:e.api.Utils.i18n("ITEM.TypeEquipmentPl"),loot:e.api.Utils.i18n("ITEM.TypeLootPl"),tools:e.api.Utils.i18n("ITEM.TypeToolPl"),weapons:e.api.Utils.i18n("ITEM.TypeWeaponPl")};for(const e of this.inventorygroupIds){if(!t.has(e))continue;const i={id:e,name:s[e],type:"system"},n=t.get(e);await this.#b(n,i),this.activationgroupIds&&await this.#v(n,i)}}#y(){if(0===this.actors.length)return;if(!this.actors.every((e=>"character"===e.type)))return;const t="utility",s={shortRest:{name:e.api.Utils.i18n("DND5E.ShortRest")},longRest:{name:e.api.Utils.i18n("DND5E.LongRest")}},n=Object.entries(s).map((s=>{const n=s[0],a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter);return{id:n,name:a,encodedValue:o,listName:l}}));this.addActions(n,{id:"rests",type:"system"})}#h(){const t="skill",s=this.actor?this.actor.system.skills:game.dnd5e.config.skills;if(0===s.length)return;const n=Object.entries(s).map((n=>{try{const a=n[0],l=a.charAt(0).toUpperCase()+a.slice(1),o=this.abbreviateSkills?l:game.dnd5e.config.skills[a].label,r=`${`${e.api.Utils.i18n(i[t])}: `??""}${game.dnd5e.config.skills[a].label}`,d=[t,a].join(this.delimiter),c=this.#f(s[a].value),p=s[a].total;return{id:a,name:o,encodedValue:d,icon1:c,info1:this.actor?{text:p||0===p?`${p>=0?"+":""}${p}`:""}:"",listName:r}}catch(t){return e.api.Logger.error(n),null}})).filter((e=>!!e));this.addActions(n,{id:"skills",type:"system"})}async#c(){const t="spell",s=new Map;for(const[e,t]of this.items){if("spell"===t.type){const i=this.#E(t),n=this.#D(t);if(i&&n){switch(t.system.preparation.mode){case"atwill":s.has("at-will-spells")||s.set("at-will-spells",new Map),s.get("at-will-spells").set(e,t);break;case"innate":s.has("innate-spells")||s.set("innate-spells",new Map),s.get("innate-spells").set(e,t);break;case"pact":s.has("pact-spells")||s.set("pact-spells",new Map),s.get("pact-spells").set(e,t);break;default:switch(t.system.level){case 0:s.has("cantrips")||s.set("cantrips",new Map),s.get("cantrips").set(e,t);break;case 1:s.has("1st-level-spells")||s.set("1st-level-spells",new Map),s.get("1st-level-spells").set(e,t);break;case 2:s.has("2nd-level-spells")||s.set("2nd-level-spells",new Map),s.get("2nd-level-spells").set(e,t);break;case 3:s.has("3rd-level-spells")||s.set("3rd-level-spells",new Map),s.get("3rd-level-spells").set(e,t);break;case 4:s.has("4th-level-spells")||s.set("4th-level-spells",new Map),s.get("4th-level-spells").set(e,t);break;case 5:s.has("5th-level-spells")||s.set("5th-level-spells",new Map),s.get("5th-level-spells").set(e,t);break;case 6:s.has("6th-level-spells")||s.set("6th-level-spells",new Map),s.get("6th-level-spells").set(e,t);break;case 7:s.has("7th-level-spells")||s.set("7th-level-spells",new Map),s.get("7th-level-spells").set(e,t);break;case 8:s.has("8th-level-spells")||s.set("8th-level-spells",new Map),s.get("8th-level-spells").set(e,t);break;case 9:s.has("9th-level-spells")||s.set("9th-level-spells",new Map),s.get("9th-level-spells").set(e,t)}}}}}const i=Object.entries(this.actor.system.spells).reverse();let n=null;const a=[];let l=this.showUnchargedItems,o=this.showUnchargedItems;for(const[e,t]of i){const s=t.value>0,i=t.max>0,r=t.level>0;"pact"===e&&(!o&&s&&i&&r&&(o=!0),r||(o=!1),t.slotAvailable=o,n=[e,t]),e.startsWith("spell")&&"spell0"!==e?(!l&&s&&i&&(l=!0),t.slotAvailable=l,a.push([e,t])):s&&(t.slotsAvailable=!0,a.push(e,t))}if(n[1].slotAvailable){const e=a.findIndex((e=>e[0]==="spell"+n[1].level));a[e][1].slotsAvailable=!0}const r={"1st-level-spells":{spellMode:1,name:e.api.Utils.i18n("tokenActionHud.dnd5e.1stLevelSpells")},"2nd-level-spells":{spellMode:2,name:e.api.Utils.i18n("tokenActionHud.dnd5e.2ndLevelSpells")},"3rd-level-spells":{spellMode:3,name:e.api.Utils.i18n("tokenActionHud.dnd5e.3rdLevelSpells")},"4th-level-spells":{spellMode:4,name:e.api.Utils.i18n("tokenActionHud.dnd5e.4thLevelSpells")},"5th-level-spells":{spellMode:5,name:e.api.Utils.i18n("tokenActionHud.dnd5e.5thLevelSpells")},"6th-level-spells":{spellMode:6,name:e.api.Utils.i18n("tokenActionHud.dnd5e.6thLevelSpells")},"7th-level-spells":{spellMode:7,name:e.api.Utils.i18n("tokenActionHud.dnd5e.7thLevelSpells")},"8th-level-spells":{spellMode:8,name:e.api.Utils.i18n("tokenActionHud.dnd5e.8thLevelSpells")},"9th-level-spells":{spellMode:9,name:e.api.Utils.i18n("tokenActionHud.dnd5e.9thLevelSpells")},"at-will-spells":{spellMode:"atwill",name:e.api.Utils.i18n("tokenActionHud.dnd5e.atWillSpells")},cantrips:{spellMode:0,name:e.api.Utils.i18n("tokenActionHud.dnd5e.cantrips")},"innate-spells":{spellMode:"innate",name:e.api.Utils.i18n("tokenActionHud.dnd5e.innateSpells")},"pact-spells":{spellMode:"pact",name:e.api.Utils.i18n("tokenActionHud.dnd5e.pactSpells")}},d=["1","2","3","4","5","6","7","8","9","pact"];for(const e of this.spellgroupIds){const i=r[e].spellMode,l=r[e].name;if(!s.has(e))continue;const o="pact"===i?n[1]:a.find((e=>e[0]===`spell${i}`))?.[1],c=o?.value,p=o?.max,u=o?.slotAvailable;if(!u&&d.includes(i))continue;const m={};m.info1={class:"tah-spotlight",text:p>=0?`${c}/${p}`:""};const y={id:e,name:l,type:"system",info:m};this.addGroupInfo(y);const h=s.get(e);await this.#b(h,y,t),this.activationgroupIds&&await this.#v(h,y,t)}}#g(){if(0===this.actors.length)return;if(!this.actors.every((e=>"character"===e.type)))return;const t="utility",s={deathSave:{name:e.api.Utils.i18n("DND5E.DeathSave")},inspiration:{name:e.api.Utils.i18n("DND5E.Inspiration")}};(!this.actor||this.actor.system.attributes.hp.value>0)&&delete s.deathSave;const n=Object.entries(s).map((s=>{const n=s[0],a=s[1].name,l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`,o=[t,n].join(this.delimiter);let r="";if("inspiration"===s[0]){r=`toggle${this.actors.every((e=>e.system.attributes?.inspiration))?" active":""}`}return{id:n,name:a,encodedValue:o,cssClass:r,listName:l}}));this.addActions(n,{id:"utility",type:"system"})}async#b(e,t,s="item"){if(0===e.size)return;if(!("string"==typeof t?t:t?.id))return;const i=await Promise.all([...e].map((async e=>await this.#S(s,e[1]))));this.addActions(i,t)}async#S(t,s){const n=s.id??s._id;let a=s?.name??s?.label;s?.system?.recharge&&!s?.system?.recharge?.charged&&s?.system?.recharge?.value&&(a+=` (${e.api.Utils.i18n("DND5E.Recharge")})`);const l=`${`${e.api.Utils.i18n(i[t])}: `??""}${a}`;let o="";if(Object.hasOwn(s,"disabled")){o=`toggle${s.disabled?"":" active"}`}const r=[t,n].join(this.delimiter),d=e.api.Utils.getImage(s),c=this.#U(s?.system?.activation?.type);let p=null,u=null;"spell"===s.type?(p=this.#C(s),this.displaySpellInfo&&(u=this.#H(s))):u=this.#T(s);const m=u?.info1,y=u?.info2,h=u?.info3,g=await this.#P(s);return{id:n,name:a,encodedValue:r,cssClass:o,img:d,icon1:c,icon2:p,info1:m,info2:y,info3:h,listName:l,tooltip:await this.#A(g)}}#I(e){if(this.showItemsWithoutActivationCosts)return!0;const t=Object.keys(game.dnd5e.config.abilityActivationTypes).filter((e=>"none"!==e)),s=e.system.activation,i=s?.type;return!!(s&&t.includes(i)||"tool"===e.type)}#w(e){const t=e.type;if(this.showUnequippedItems&&!["consumable","spell","feat"].includes(t))return!0;return!(!e.system.equipped||"consumable"===t)}#E(e){if(this.showUnchargedItems)return!0;return!!e.system.uses}#D(e){if("character"!==this.actorType&&this.showUnequippedItems)return!0;const t=e.system.preparation.prepared;if(this.showUnpreparedSpells)return!0;const s=e.system.level,i=Object.keys(game.dnd5e.config.spellPreparationModes).filter((e=>"prepared"!==e)),n=e.system.preparation.mode;return!(0!==s&&!i.includes(n)&&!t)}#T(e){return{info1:{text:this.#M(e)},info2:{text:this.#J(e)},info3:{text:this.#$(e)}}}#H(t){const s=t.system.components,i=[],n={},a={},l={};if(s?.vocal&&i.push(e.api.Utils.i18n("DND5E.ComponentVerbal")),s?.somatic&&i.push(e.api.Utils.i18n("DND5E.ComponentSomatic")),s?.material&&i.push(e.api.Utils.i18n("DND5E.ComponentMaterial")),i.length&&(n.title=i.join(", "),n.text=i.map((e=>e.charAt(0).toUpperCase())).join("")),s?.concentration){const t=e.api.Utils.i18n("DND5E.Concentration");a.title=t,a.text=t.charAt(0).toUpperCase()}if(s?.ritual){const t=e.api.Utils.i18n("DND5E.Ritual");l.title=t,l.text=t.charAt(0).toUpperCase()}return{info1:n,info2:a,info3:l}}#e(){const e=["character","npc"],t=canvas.tokens.controlled.filter((e=>e.actor)).map((e=>e.actor));return t.every((t=>e.includes(t.type)))?t:[]}#t(){const e=["character","npc"],t=canvas.tokens.controlled;return t.filter((e=>e.actor)).map((e=>e.actor)).every((t=>e.includes(t.type)))?t:[]}#M(e){const t=e?.system?.quantity??0;return t>1?t:""}#J(e){const t=e?.system?.uses;return t&&(t.value>0||t.max>0)?`${t.value??"0"}${t.max>0?`/${t.max}`:""}`:""}#$(e){const t=e?.system?.consume?.target,s=e?.system?.consume?.type;if(t===e.id)return"";if("attribute"===s){if(!t)return"";const e=t.substr(0,t.lastIndexOf(".")),s=this.actor.system[e];return s?`${s.value??"0"}${s.max?`/${s.max}`:""}`:""}const i=this.items.get(t);if("charges"===s){const e=i?.system.uses;return e?.value?`${e.value}${e.max?`/${e.max}`:""}`:""}return i?.system?.quantity??""}#s(e){if(m.getSetting("showSlowActions"))return e;const t=["minute","hour","day"],s=new Map;for(const[i,n]of e.entries()){const e=n.system?.activation?.type;t.includes(e)||s.set(i,n)}return s}#f(e){const t=CONFIG.DND5E.proficiencyLevels[e]??"",s=d[e];if(s)return``}#U(e){const t=CONFIG.DND5E.abilityActivationTypes[e]??"",s=n[e];if(s)return``}#C(t){const s=t.system.level,i=t.system.preparation.mode,n=t.system.preparation.prepared,a=n?"fas fa-sun":"fas fa-sun tah-icon-disabled",l=n?e.api.Utils.i18n("DND5E.SpellPrepared"):e.api.Utils.i18n("DND5E.SpellUnprepared");return"prepared"===i&&0!==s?``:""}async#P(e){if("none"===this.tooltipsSetting)return"";const t=e?.name??"";if("nameOnly"===this.tooltipsSetting)return t;return{name:t,description:"string"==typeof e?.system?.description?e?.system?.description:e?.system?.description?.value??"",modifiers:e?.modifiers??null,properties:[...e.system?.chatProperties??[],...e.system?.equippableItemChatProperties??[],...e.system?.activatedEffectChatProperties??[]].filter((e=>e)),rarity:e?.rarity??null,traits:"weapon"===e?.type?this.#N(e?.system?.properties):null}}async#k(e,t){if("none"===this.tooltipsSetting)return"";if("nameOnly"===this.tooltipsSetting)return t;return{name:t,description:(l[e]&&l[e]?.uuid?await fromUuid(l[e].uuid):null)?.text?.content??""}}async#A(t){if("none"===this.tooltipsSetting)return"";if("string"==typeof t)return t;const s=e.api.Utils.i18n(t.name);if("nameOnly"===this.tooltipsSetting)return s;const i=`

${s}

`,n=t?.descriptionLocalised??await TextEditor.enrichHTML(e.api.Utils.i18n(t?.description??""),{async:!0}),a=t?.rarity?`${e.api.Utils.i18n(c[t.rarity])}`:"",l=t?.properties?`
${t.properties.map((t=>`${e.api.Utils.i18n(t)}`)).join("")}
`:"",o=t?.traits?t.traits.map((t=>`${e.api.Utils.i18n(t.label??t)}`)).join(""):"",r=t?.traits2?t.traits2.map((t=>`${e.api.Utils.i18n(t.label??t)}`)).join(""):"",d=t?.traitsAlt?t.traitsAlt.map((t=>`${e.api.Utils.i18n(t.label)}`)).join(""):"",p=t?.modifiers?`
${t.modifiers.filter((e=>e.enabled)).map((t=>`${e.api.Utils.i18n(t.label)} ${`${t.modifier>=0?"+":""}${t.modifier??""}`}`)).join("")}
`:"",u=[a,o,r,d].join(""),m=u?`
${u}
`:"";return n||m||p?`
${i}${m||p?`
${m}${p}
`:""}${n}${l}
`:s}#N(t){return t?Object.entries(t).filter((([e,t])=>t&&u[e])).map((([t,s])=>e.api.Utils.i18n(u[t]))):null}}}));let h=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{const t=o;Object.values(t).forEach((t=>{t.name=e.api.Utils.i18n(t.name),t.listName=`Group: ${e.api.Utils.i18n(t.name)}`}));const s=Object.values(t);h={layout:[{nestId:"inventory",id:"inventory",name:e.api.Utils.i18n("DND5E.Inventory"),groups:[{...t.weapons,nestId:"inventory_weapons"},{...t.equipment,nestId:"inventory_equipment"},{...t.consumables,nestId:"inventory_consumables"},{...t.tools,nestId:"inventory_tools"},{...t.containers,nestId:"inventory_containers"},{...t.loot,nestId:"inventory_loot"}]},{nestId:"features",id:"features",name:e.api.Utils.i18n("DND5E.Features"),groups:[{...t.activeFeatures,nestId:"features_active-features"},{...t.passiveFeatures,nestId:"features_passive-features"}]},{nestId:"spells",id:"spells",name:e.api.Utils.i18n("ITEM.TypeSpellPl"),groups:[{...t.atWillSpells,nestId:"spells_at-will-spells"},{...t.innateSpells,nestId:"spells_innate-spells"},{...t.pactSpells,nestId:"spells_pact-spells"},{...t.cantrips,nestId:"spells_cantrips"},{...t._1stLevelSpells,nestId:"spells_1st-level-spells"},{...t._2ndLevelSpells,nestId:"spells_2nd-level-spells"},{...t._3rdLevelSpells,nestId:"spells_3rd-level-spells"},{...t._4thLevelSpells,nestId:"spells_4th-level-spells"},{...t._5thLevelSpells,nestId:"spells_5th-level-spells"},{...t._6thLevelSpells,nestId:"spells_6th-level-spells"},{...t._7thLevelSpells,nestId:"spells_7th-level-spells"},{...t._8thLevelSpells,nestId:"spells_8th-level-spells"},{...t._9thLevelSpells,nestId:"spells_9th-level-spells"}]},{nestId:"attributes",id:"attributes",name:e.api.Utils.i18n("DND5E.Attributes"),groups:[{...t.abilities,nestId:"attributes_abilities"},{...t.skills,nestId:"attributes_skills"}]},{nestId:"effects",id:"effects",name:e.api.Utils.i18n("DND5E.Effects"),groups:[{...t.temporaryEffects,nestId:"effects_temporary-effects"},{...t.passiveEffects,nestId:"effects_passive-effects"}]},{nestId:"conditions",id:"conditions",name:e.api.Utils.i18n("tokenActionHud.dnd5e.conditions"),groups:[{...t.conditions,nestId:"conditions_conditions"}]},{nestId:"utility",id:"utility",name:e.api.Utils.i18n("tokenActionHud.utility"),groups:[{...t.combat,nestId:"utility_combat"},{...t.token,nestId:"utility_token"},{...t.rests,nestId:"utility_rests"},{...t.utility,nestId:"utility_utility"}]}],groups:s}}));let g=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{g=class MagicItemActionListExtender extends e.api.ActionListExtender{constructor(e){super(e.categoryManager),this.actionHandler=e,this.categoryManager=e.categoryManager,this.actor=null}extendActionList(){if(this.actor=this.actionHandler.actor,!this.actor)return;const t=MagicItems.actor(this.actor.id);if(!t)return;const s=t.items??[];if(0===s.length)return;const i={id:"magic-items",type:"system"};s.forEach((t=>{if(t.attuned&&!this._isItemAttuned(t))return;if(t.equipped&&!this._isItemEquipped(t))return;const s={id:`magic-items_${t.id}`,name:t.name,type:"system-derived",info1:`${t.uses}/${t.charges}`};this.actionHandler.addGroup(s,i);const n=t.ownedEntries.map((s=>{const i=s.item,n=i.id;return{id:n,name:i.name,encodedValue:["magicItem",`${t.id}>${n}`].join("|"),img:e.api.Utils.getImage(i),info1:i.consumption,info2:i.baseLevel?`${e.api.Utils.i18n("DND5E.AbbreviationLevel")} ${i.baseLevel}`:"",selected:!0}}));this.actionHandler.addActions(n,s)}))}_isItemEquipped(e){return e.item.system.equipped}_isItemAttuned(e){return e.item.system.attunment!==(CONFIG.DND5E.attunementTypes?.REQUIRED??1)}}}));let f=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{f=class RollHandler extends e.api.RollHandler{async doHandleActionEvent(e,t){const s=t.split("|");2!==s.length&&super.throwInvalidValueErr();const i=s[0],n=s[1];if(this.actor)await this.#Q(e,i,this.actor,this.token,n);else for(const t of canvas.tokens.controlled){const s=t.actor;await this.#Q(e,i,s,t,n)}}async#Q(e,t,s,i,n){switch(t){case"ability":this.#j(e,s,n);break;case"check":this.#x(e,s,n);break;case"save":this.#B(e,s,n);break;case"condition":if(!i)return;await this.#q(e,s,i,n);break;case"effect":await this.#L(e,s,n);break;case"exhaustion":await this.#_(e,s);break;case"feature":case"item":case"spell":case"weapon":this.isRenderItem()?this.doRenderItem(s,n):this.#R(e,s,n);break;case"magicItem":this.#W(s,n);break;case"skill":this.#O(e,s,n);break;case"utility":await this.#F(e,s,i,n)}}async#_(e,t){const s=this.isRightClick(e),i=t.system.attributes.exhaustion,n=s?i-1:i+1;n>=0&&t.update({"system.attributes.exhaustion":n})}#j(e,t,s){t&&t.system?.abilities&&t.rollAbility(s,{event:e})}#B(e,t,s){t&&t.system?.abilities&&t.rollAbilitySave(s,{event:e})}#x(e,t,s){t&&t.system?.abilities&&t.rollAbilityTest(s,{event:e})}#W(e,t){const s=t.split(">"),i=s[0],n=s[1];MagicItems.actor(e.id).roll(i,n),Hooks.callAll("forceUpdateTokenActionHud")}#O(e,t,s){t&&t.system?.skills&&t.rollSkill(s,{event:e})}#R(t,s,i){const n=e.api.Utils.getItem(s,i);if(!this.#Z(n))return n.use({event:t});n.rollRecharge()}#Z(e){return e.system.recharge&&!e.system.recharge.charged&&e.system.recharge.value}async#F(e,t,s,i){switch(i){case"deathSave":t.rollDeathSave({event:e});break;case"endTurn":if(!s)break;game.combat?.current?.tokenId===s.id&&await(game.combat?.nextTurn());break;case"initiative":await this.#G(t);break;case"inspiration":{const e=!t.system.attributes.inspiration;t.update({"system.attributes.inspiration":e});break}case"longRest":t.longRest();break;case"shortRest":t.shortRest()}Hooks.callAll("forceUpdateTokenActionHud")}async#G(e){e&&(await e.rollInitiative({createCombatants:!0}),Hooks.callAll("forceUpdateTokenActionHud"))}async#q(e,t,s,i){if(!s)return;const n=this.isRightClick(e),a=CONFIG.statusEffects.find((e=>e.id===i)),l=a?.flags?Object.hasOwn(a.flags,"dfreds-convenient-effects")?a.flags["dfreds-convenient-effects"].isConvenient:null:i.startsWith("Convenient Effect");if(game.dfreds&&l)n?await game.dfreds.effectInterface.toggleEffect(a.name??a.label,{overlay:!0}):await game.dfreds.effectInterface.toggleEffect(a.name??a.label);else{const e=this.#z(i);if(!e)return;const a=this.#V(t,i);a?.disabled&&await a.delete(),n?await s.toggleEffect(e,{overlay:!0}):await s.toggleEffect(e)}Hooks.callAll("forceUpdateTokenActionHud")}#z(e){return CONFIG.statusEffects.find((t=>t.id===e))}#V(e,t){return game.version.startsWith("11")?e.effects.find((e=>e.statuses.every((e=>e===t)))):e.effects.find((e=>e.flags?.core?.statusId===t))}async#L(e,t,s){const i=("find"in t.effects.entries?t.effects.entries:t.effects).find((e=>e.id===s));if(!i)return;this.isRightClick(e)?await i.delete():await i.update({disabled:!i.disabled}),Hooks.callAll("forceUpdateTokenActionHud")}}}));class RollHandlerObsidian extends f{_rollAbilityTest(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"abl",abl:t})}_rollAbilitySave(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"save",save:t})}_rollSkill(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"skl",skl:t})}_useItem(e,t){OBSIDIAN.Items.roll(super.actor,{roll:"item",id:t})}}function register(t){game.settings.register(e.ID,"abbreviateSkills",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.abbreviateSkills.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.abbreviateSkills.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showSlowActions",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showSlowActions.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showSlowActions.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"displaySpellInfo",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.displaySpellInfo.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.displaySpellInfo.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnchargedItems",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnchargedItems.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnchargedItems.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnequippedItems",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItems.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItems.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnequippedItemsNpcs",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItemsNpcs.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnequippedItemsNpcs.hint"),scope:"client",config:!0,type:Boolean,default:!0,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showUnpreparedSpells",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnpreparedSpells.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showUnpreparedSpells.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}}),game.settings.register(e.ID,"showItemsWithoutActivationCosts",{name:game.i18n.localize("tokenActionHud.dnd5e.settings.showItemsWithoutActivationCosts.name"),hint:game.i18n.localize("tokenActionHud.dnd5e.settings.showItemsWithoutActivationCosts.hint"),scope:"client",config:!0,type:Boolean,default:!1,onChange:e=>{t(e)}})}let v=null;Hooks.once("tokenActionHudCoreApiReady",(async e=>{v=class SystemManager extends e.api.SystemManager{doGetCategoryManager(){return new e.api.CategoryManager}doGetActionHandler(t){const s=new y(t);return(e.api.Utils.isModuleActive("magic-items-2")||e.api.Utils.isModuleActive("magicitems"))&&s.addFurtherActionHandler(new g(s)),s}getAvailableRollHandlers(){let t="Core D&D5e";e.api.Utils.isModuleActive("midi-qol")&&(t+=` [supports ${e.api.Utils.getModuleTitle("midi-qol")}]`);const s={core:t};return e.api.SystemManager.addHandler(s,"obsidian"),s}doGetRollHandler(e){let t;if("obsidian"===e)t=new RollHandlerObsidian;else t=new f;return t}doRegisterSettings(e){register(e)}async doRegisterDefaultFlags(){const t=h;if(game.modules.get("magicitems")?.active||game.modules.get("magic-items-2")?.active){const s=e.api.Utils.i18n("tokenActionHud.dnd5e.magicItems");t.groups.push({id:"magic-items",name:s,listName:`Group: ${s}`,type:"system"}),t.groups.sort(((e,t)=>e.id.localeCompare(t.id)))}return t}}})),Hooks.on("tokenActionHudCoreApiReady",(async()=>{const t=game.modules.get(e.ID);t.api={requiredCoreModuleVersion:"1.4",SystemManager:v},Hooks.call("tokenActionHudSystemReady",t)}));export{i as ACTION_TYPE,n as ACTIVATION_TYPE_ICON,y as ActionHandler,a as CONCENTRATION_ICON,l as CONDITION,t as CORE_MODULE,h as DEFAULTS,o as GROUP,e as MODULE,g as MagicItemActionListExtender,r as PREPARED_ICON,d as PROFICIENCY_LEVEL_ICON,c as RARITY,s as REQUIRED_CORE_MODULE_VERSION,p as RITUAL_ICON,f as RollHandler,RollHandlerObsidian,v as SystemManager,m as Utils,u as WEAPON_PROPERTY,register};