//#region src/module/constants.ts
var e = "xdy-pf2e-workbench";
//#endregion
//#region src/module/preloadTemplates.ts
async function t() {
	let t = [`modules/${e}/templates/feature/heropoint-handler/index.hbs`];
	await foundry.applications.handlebars.loadTemplates(t);
}
//#endregion
//#region src/module/utils/systems.ts
var n = /* @__PURE__ */ function(e) {
	return e.PF2E = "pf2e", e.SF2E = "sf2e", e;
}({});
function r() {
	return String(game.system.id) === "sf2e" ? "sf2e" : "pf2e";
}
function i(e, t) {
	let n = r(), i = e?.flags?.[n];
	if (i) return t.split(".").reduce((e, t) => e?.[t], i);
}
function a(e, t) {
	let n = r();
	return game.settings.get(n, `${e}.${t}`);
}
function o(e) {
	let t = r();
	return game.settings.get(t, e);
}
async function s(e, t) {
	let n = r();
	return await game.settings.set(n, e, t);
}
function c(e) {
	return r() === "sf2e" ? `${e}-sf2e` : e;
}
function l(e, t = "xdy-pf2e-workbench") {
	return `${t}.${c(e)}`;
}
//#endregion
//#region src/module/lifecycle.ts
var u = /* @__PURE__ */ function(e) {
	return e[e.DOWN = 0] = "DOWN", e[e.INIT = 10] = "INIT", e[e.SETUP = 20] = "SETUP", e[e.READY = 30] = "READY", e[e.ACTIVE = 40] = "ACTIVE", e;
}({}), d = 0;
function f(e) {
	d = e;
}
//#endregion
//#region src/module/utils/logging.ts
var p = {
	TRACE: 0,
	DEBUG: 1,
	INFO: 2,
	WARN: 3,
	ERROR: 4
};
function m(...e) {
	v(p.DEBUG, ...e);
}
function h(...e) {
	v(p.INFO, ...e);
}
function g(...e) {
	v(p.WARN, ...e);
}
function _(...e) {
	v(p.ERROR, ...e);
}
function v(e = p.INFO, ...t) {
	let n = p.INFO;
	if (d >= u.READY && (n = Number(game.settings.get("xdy-pf2e-workbench", "logLevel")) ?? p.INFO), !(e < n)) switch (e) {
		case p.TRACE:
			console.trace(...t);
			break;
		case p.DEBUG:
			console.debug(...t);
			break;
		case p.INFO:
			console.info(...t);
			break;
		case p.WARN:
			console.warn(...t);
			break;
		case p.ERROR:
			console.error(...t);
			break;
	}
}
//#endregion
//#region src/module/utils.ts
function y(t) {
	let n = game.settings.get(e, t);
	return n ?? _(`${e} | Setting "${t}" returned ${n}`), n;
}
function b(t, n = 0) {
	let r = game.settings.get(e, t);
	if (r == null) return n;
	let i = Number.parseInt(String(r));
	return Number.isNaN(i) ? n : i;
}
function x(e, t) {
	for (let n of e.items) if (n.slug === t) return !0;
	return !1;
}
function S(e, t = !0, n = !0) {
	let r = e.author?.id === game.user?.id;
	return !game.user?.isGM && t && r ? !0 : !!(game.user?.isGM && n && r);
}
function ee(e) {
	let t = i(e, "context"), n = t?.outcome ?? "";
	if (t?.isReroll) {
		let t = e.flavor?.match("Result: <span .*? class=\"(.*?)\"");
		t && t[1] && (n = t[1]);
	}
	return n;
}
function C() {
	return game.users.activeGM === game.user;
}
function w(e) {
	let t = e.rolls?.length !== 0 && (e.item?.type ?? "") && [
		"ancestry",
		"effect",
		"feat",
		"melee",
		"weapon"
	].includes(e.item?.type ?? "") && (!e.isRoll || e.isDamageRoll), n = e.item?.type === "spell" && e.isDamageRoll;
	return t || n;
}
function te(e) {
	return canvas?.scene?.tokens.get(e.speaker.token)?.actor ?? game.actors?.get(e.speaker.actor) ?? null;
}
function ne(e) {
	return e instanceof HTMLElement ? e : e[0];
}
function re(e, t, n, r) {
	let i = game.i18n.format(n, {
		name: game?.scenes?.current?.tokens?.find((t) => t.actor?.id === e.id)?.name ?? e.name,
		items: t.map((e) => e.name).join(", ")
	});
	E(ChatMessage.create({
		flavor: i,
		speaker: ChatMessage.getSpeaker({ actor: e })
	}), r);
}
function T(e) {
	return e.charAt(0).toUpperCase() + e.slice(1);
}
function E(t, n) {
	t.catch((t) => _(`${e} | ${n}:`, t));
}
async function ie(t, n) {
	try {
		return {
			ok: !0,
			value: await t()
		};
	} catch (t) {
		return _(`${e} | ${n}:`, t), { ok: !1 };
	}
}
async function ae(e, t, n) {
	let r = await ie(e, n);
	return r.ok ? r.value : t;
}
function D(e) {
	if (!e) return null;
	let t = game.users.current, n = game.users.players.filter((e) => e.active), r = n.find((t) => t.character === e), i = n.find((t) => e.canUserModify(t, "update")), a = t?.active && e.canUserModify(t, "update") ? t : r ?? game.users.activeGM ?? i ?? null;
	return game.user.id === a?.id;
}
function oe(t, n) {
	game.socket.emit("module." + e, {
		operation: "notification",
		args: [t, n]
	});
}
function se(e) {
	let t = {};
	for (let n of Object.keys(e)) ce(t, n, e[n]);
	return t;
}
function ce(e, t, n) {
	let r = t.split("."), i = r.pop();
	i !== void 0 && (r.reduce(function(e, t, n, r) {
		return e[t] = e[t] || (isFinite(n + 1 in r ? Number(r[n + 1]) : Number(i)) ? [] : {});
	}, e)[i] = n);
}
async function le(t) {
	try {
		let n = JSON.parse(decodeURI(String(t))), r = 0;
		for (let { uuid: e, action: t, data: i } of n) {
			let n = await fromUuid(e);
			if (n?.inCompendium) {
				let e = n.compendium;
				if (t === "update") {
					let e = n.toObject(), t = e?.system?.traits?.value, a = "xdy-pf2e-housepatched";
					if (!(t?.includes("pf2e-ccc-patched") || t?.includes(a))) {
						let t = se(i), o = t.system ??= {}, s = o.traits ??= {};
						(s.value ??= []).push(a);
						let c = foundry.utils.mergeObject(e, t);
						await n.update(se(c)), r += 1;
					}
				} else t === "unlock" ? e.locked && await e.configure({ locked: !1 }) : t === "lock" ? e.locked || await e.configure({ locked: !0 }) : t === "delete" && (await n.delete(), await e.getIndex());
			}
		}
		let i = game.i18n.format(`${e}.SETTINGS.housepatcher.notification`, { count: r });
		ui.notifications.info(i);
	} catch {
		ui.notifications.error(game.i18n.format(`${e}.SETTINGS.housepatcher.error`)), game.settings.set(e, "housepatcher", "");
	}
}
function ue(e) {
	return e.isOfType("character") ? game.scenes.current?.tokens?.filter(() => !game.user.isGM)?.filter((e) => e.canUserModify(game.user, "update"))?.map((e) => e.actor)?.filter((e) => e?.traits.has("minion")) : [];
}
function O(t, n, r) {
	return t?.getFlag?.(e, n) ?? r;
}
function de() {
	return game.actors?.party?.members.filter((e) => e?.isOfType("character")).filter((e) => !e?.system.traits?.value.toString().includes("minion")).filter((e) => !e?.system.traits?.value.toString().includes("eidolon")) || [];
}
function fe(e, t) {
	return (typeof t == "string" || typeof t == "number") && t in e;
}
//#endregion
//#region src/module/feature/settingsHandler/index.ts
function k(e, t, n) {
	let r = e.querySelector(t)?.closest(".form-group");
	r && (r.style.display = n ? "" : "none");
}
function pe(e, t) {
	for (let n of t.settings) if (n) {
		let t = n.key;
		if (t !== "handleDyingRecoveryRollAllow" && t.startsWith("handleDyingRecoveryRoll")) {
			let n = !(y("handleDyingRecoveryRollAllow") === "none" || (game.user?.isGM ? y("handleDyingRecoveryRollAllow") === "players" : y("handleDyingRecoveryRollAllow") === "gm"));
			k(e, `input[name="${t}"]`, n);
		}
		if (t !== "autoRollDamageAllow" && t.startsWith("autoRollDamage")) {
			let n = !(y("autoRollDamageAllow") === "none" || (game.user?.isGM ? y("autoRollDamageAllow") === "players" : y("autoRollDamageAllow") === "gm"));
			k(e, `input[name="${t}"]`, n), k(e, `select[name="${t}"]`, n);
		}
	}
	let n = y("canvasPointerPingMode"), r = n === "sound" || n === "visualAndSound";
	k(e, "[name=\"canvasPointerPingSound\"]", r), k(e, "[name=\"canvasPointerPingVolume\"]", r);
	let i = e.querySelector("[name=\"canvasPointerPingMode\"]");
	i && !i.dataset.pingListenerAttached && (i.dataset.pingListenerAttached = "true", i.addEventListener("change", () => {
		let t = i.value, n = t === "sound" || t === "visualAndSound";
		k(e, "[name=\"canvasPointerPingSound\"]", n), k(e, "[name=\"canvasPointerPingVolume\"]", n);
	}));
}
//#endregion
//#region src/module/settings/menu.ts
var A = class t extends foundry.applications.api.HandlebarsApplicationMixin(foundry.applications.api.ApplicationV2) {
	static namespace;
	static DEFAULT_OPTIONS = {
		tag: "form",
		window: {
			contentClasses: [
				"form",
				"xdy-pf2e-workbench",
				"settings-menu",
				"standard-form"
			],
			resizable: !0
		},
		position: {
			width: 780,
			height: 680
		},
		form: {
			handler: t.formHandler,
			closeOnSubmit: !0
		}
	};
	static hidelist = {};
	constructor(e) {
		let t = new.target;
		super(foundry.utils.mergeObject({ id: `${t.namespace}-settings` }, e ?? {}));
	}
	static get PARTS() {
		return {
			content: { template: `modules/${e}/templates/menu.hbs` },
			footer: { template: "templates/generic/form-footer.hbs" }
		};
	}
	static get settings() {
		return {};
	}
	get title() {
		return game.i18n.localize(`${e}.SETTINGS.${this.namespace}.name`);
	}
	get namespace() {
		return this.constructor.namespace;
	}
	static registerSettings() {
		let t = this.settings;
		for (let n of Object.keys(t)) {
			let r = { ...t[n] };
			game.settings.register(e, n, {
				...r,
				config: !1
			});
		}
	}
	static hideForm(e, t) {
		e != null && (e.style.display = t ? "" : "none");
	}
	static registerSettingsAndCreateMenu(t, n = !0) {
		game.settings.registerMenu(e, this.namespace, {
			name: `${e}.SETTINGS.${this.namespace}.name`,
			label: `${e}.SETTINGS.${this.namespace}.label`,
			hint: `${e}.SETTINGS.${this.namespace}.hint`,
			icon: t,
			type: this,
			restricted: n
		}), this.registerSettings();
	}
	static async formHandler(t, n, r) {
		let i = foundry.utils.expandObject(r.object);
		for (let t of Object.keys(i)) {
			let n = i[t];
			(n === null || n === "null") && (n = ""), ["submit", "reset"].includes(t) || await game.settings.set(e, t, n);
		}
	}
	async _prepareContext(e) {
		let t = this.constructor.settings;
		return {
			settings: Object.entries(t).map(([e, t]) => {
				let n = y(e), r = t.type === Number && t.range;
				return {
					...t,
					key: e,
					value: n,
					isCheckbox: t.type === Boolean,
					isFilepicker: t.type === String && t.filePicker,
					isNumber: t.type === Number && !r,
					isRange: r,
					isSelect: !!t.choices,
					isText: t.type === String && !t.filePicker
				};
			}),
			buttons: [{
				type: "submit",
				icon: "fa-solid fa-save",
				label: "SETTINGS.Save"
			}]
		};
	}
	async _onRender(e, n) {
		pe(this.element, e);
		let r = this.constructor.hidelist;
		Object.entries(r).forEach(([e, n]) => {
			let r = game.settings.get("xdy-pf2e-workbench", e) !== (n.falsy ?? !1), i = this.element.querySelector(`.form-fields [name="${e}"]`);
			for (let e of n.list ?? []) {
				let n = this.element.querySelector(`.form-group:has(.form-fields [name="${e}"])`);
				t.hideForm(n, r);
			}
			i?.addEventListener("change", (e) => {
				for (let r of n.list ?? []) {
					let i = this.element.querySelector(`.form-group:has(.form-fields [name="${r}"])`), a = e.target.checked;
					switch (n.type) {
						case "select":
							a = e.target.value !== n.falsy;
							break;
						default: break;
					}
					t.hideForm(i, a);
				}
			});
		});
	}
}, j, me, he = class extends A {
	static namespace = "npcMystificationSettings";
	static get settings() {
		return {
			npcMystifier: {
				name: `${e}.SETTINGS.npcMystifier.name`,
				hint: `${e}.SETTINGS.npcMystifier.hint`,
				scope: "world",
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			npcMystifierDemystifyAllTokensBasedOnTheSameActor: {
				name: `${e}.SETTINGS.npcMystifierDemystifyAllTokensBasedOnTheSameActor.name`,
				hint: `${e}.SETTINGS.npcMystifierDemystifyAllTokensBasedOnTheSameActor.hint`,
				scope: "world",
				default: !0,
				type: Boolean
			},
			npcMystifierAddRandomProperty: {
				name: `${e}.SETTINGS.npcMystifierAddRandomProperty.name`,
				hint: `${e}.SETTINGS.npcMystifierAddRandomProperty.hint`,
				scope: "world",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.npcMystifierAddRandomProperty.none`),
					numberPostfix: game.i18n.localize(`${e}.SETTINGS.npcMystifierAddRandomProperty.numberPostfix`),
					wordPrefix: game.i18n.localize(`${e}.SETTINGS.npcMystifierAddRandomProperty.wordPrefix`)
				},
				default: "none",
				onChange: (e) => {
					j = e;
				}
			},
			npcMystifierRandomWordPrefixRollTable: {
				name: `${e}.SETTINGS.npcMystifierWordPrefix.name`,
				hint: `${e}.SETTINGS.npcMystifierWordPrefix.hint`,
				scope: "world",
				default: "",
				type: String
			},
			npcMystifierKeepRandomProperty: {
				name: `${e}.SETTINGS.npcMystifierKeepRandomProperty.name`,
				hint: `${e}.SETTINGS.npcMystifierKeepRandomProperty.hint`,
				scope: "world",
				default: !0,
				type: Boolean
			},
			npcMystifierRandomPropertySkipForUnique: {
				name: `${e}.SETTINGS.npcMystifierRandomPropertySkipForUnique.name`,
				hint: `${e}.SETTINGS.npcMystifierRandomPropertySkipForUnique.hint`,
				scope: "world",
				default: !0,
				type: Boolean
			},
			npcMystifierIncludeCreaturesOfThisRarityOrGreater: {
				name: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisRarityOrGreater.name`,
				hint: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisRarityOrGreater.hint`,
				scope: "world",
				default: "common",
				type: String,
				choices: {
					common: game.i18n.localize("PF2E.TraitCommon"),
					uncommon: game.i18n.localize("PF2E.TraitUncommon"),
					rare: game.i18n.localize("PF2E.TraitRare"),
					unique: game.i18n.localize("PF2E.TraitUnique")
				}
			},
			npcMystifierIncludeCreaturesOfThisLevelOrGreater: {
				name: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisLevelOrGreater.name`,
				hint: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisLevelOrGreater.hint`,
				scope: "world",
				default: -1,
				type: Number
			},
			npcMystifierIncludeCreaturesOfThisLevelOrGreaterUsingPartyLevel: {
				name: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisLevelOrGreaterUsingPartyLevel.name`,
				hint: `${e}.SETTINGS.npcMystifierIncludeCreaturesOfThisLevelOrGreaterUsingPartyLevel.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			npcMystifierPrefix: {
				name: `${e}.SETTINGS.npcMystifierPrefix.name`,
				hint: `${e}.SETTINGS.npcMystifierPrefix.hint`,
				scope: "world",
				type: String,
				default: ""
			},
			npcMystifierPostfix: {
				name: `${e}.SETTINGS.npcMystifierPostfix.name`,
				hint: `${e}.SETTINGS.npcMystifierPostfix.hint`,
				scope: "world",
				type: String,
				default: "Workbench Adjectives"
			},
			npcMystifierUseSize: {
				name: `${e}.SETTINGS.npcMystifierUseSize.name`,
				hint: `${e}.SETTINGS.npcMystifierUseSize.hint`,
				scope: "world",
				default: !0,
				type: Boolean
			},
			npcMystifierUseRarities: {
				name: `${e}.SETTINGS.npcMystifierUseRarities.name`,
				hint: `${e}.SETTINGS.npcMystifierUseRarities.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			npcMystifierUseRaritiesReplacement: {
				name: `${e}.SETTINGS.npcMystifierUseRaritiesReplacement.name`,
				hint: `${e}.SETTINGS.npcMystifierUseRaritiesReplacement.hint`,
				scope: "world",
				default: "",
				type: String
			},
			npcMystifierUseEliteWeak: {
				name: `${e}.SETTINGS.npcMystifierUseEliteWeak.name`,
				hint: `${e}.SETTINGS.npcMystifierUseEliteWeak.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			npcMystifierUseCreatureTypesTraits: {
				name: `${e}.SETTINGS.npcMystifierUseCreatureTypesTraits.name`,
				hint: `${e}.SETTINGS.npcMystifierUseCreatureTypesTraits.hint`,
				scope: "world",
				default: !0,
				type: Boolean
			},
			npcMystifierUseCreatureTraits: {
				name: `${e}.SETTINGS.npcMystifierUseCreatureTraits.name`,
				hint: `${e}.SETTINGS.npcMystifierUseCreatureTraits.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			npcMystifierUseOtherTraits: {
				name: `${e}.SETTINGS.npcMystifierUseOtherTraits.name`,
				hint: `${e}.SETTINGS.npcMystifierUseOtherTraits.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			npcMystifierBlacklist: {
				name: `${e}.SETTINGS.npcMystifierBlacklist.name`,
				hint: `${e}.SETTINGS.npcMystifierBlacklist.hint`,
				scope: "world",
				default: "",
				type: String
			},
			npcMystifierNoMatch: {
				name: `${e}.SETTINGS.npcMystifierNoMatch.name`,
				hint: `${e}.SETTINGS.npcMystifierNoMatch.hint`,
				scope: "world",
				default: "...",
				type: String,
				onChange: async (t) => {
					t || (await new Promise((e) => setTimeout(e, 250)), game.settings.set(e, "npcMystifierNoMatch", "..."));
				}
			},
			npcMystifierModifierKey: {
				name: `${e}.SETTINGS.npcMystifierModifierKey.name`,
				hint: `${e}.SETTINGS.npcMystifierModifierKey.hint`,
				scope: "world",
				type: String,
				choices: {
					ALWAYS: game.i18n.localize(`${e}.SETTINGS.npcMystifierModifierKey.always`),
					DISABLED: game.i18n.localize(`${e}.SETTINGS.npcMystifierModifierKey.disabled`),
					ALT: game.i18n.localize(`${e}.SETTINGS.npcMystifierModifierKey.alt`),
					CONTROL: game.i18n.localize(`${e}.SETTINGS.npcMystifierModifierKey.control`),
					META: game.i18n.localize(`${e}.SETTINGS.npcMystifierModifierKey.meta`)
				},
				default: "CONTROL",
				onChange: (e) => {
					me = e;
				}
			},
			npcMystifierDemystifyToOriginalTokenName: {
				name: `${e}.SETTINGS.npcMystifierDemystifyToOriginalTokenName.name`,
				hint: `${e}.SETTINGS.npcMystifierDemystifyToOriginalTokenName.hint`,
				scope: "world",
				type: Boolean,
				default: !1
			},
			npcMystifierExcludeActorTypes: {
				name: `${e}.SETTINGS.npcMystifierExcludeActorTypes.name`,
				hint: `${e}.SETTINGS.npcMystifierExcludeActorTypes.hint`,
				scope: "world",
				type: String,
				default: ""
			},
			npcMystifierIcon: {
				name: `${e}.SETTINGS.npcMystifierIcon.name`,
				hint: `${e}.SETTINGS.npcMystifierIcon.hint`,
				scope: "world",
				type: String,
				default: "fa-solid fa-eye-slash"
			}
		};
	}
	static registerSettings() {
		super.registerSettings(), me = y("npcMystifierModifierKey"), j = y("npcMystifierAddRandomProperty");
	}
}, ge = [
	"aberration",
	"animal",
	"astral",
	"beast",
	"celestial",
	"construct",
	"dragon",
	"dream",
	"elemental",
	"ethereal",
	"fey",
	"fiend",
	"fungus",
	"humanoid",
	"monitor",
	"ooze",
	"plant",
	"shade",
	"spirit",
	"time",
	"undead"
], _e = ["elite", "weak"], M;
async function ve(e) {
	let t = y(e).trim();
	if (t !== null && t !== "null" && t !== "") {
		let e = game?.tables?.find((e) => e.name === t);
		if (e) {
			let t = await e?.draw({ displayChat: !1 });
			if (t && t?.results[0]) return t?.results[0].description;
		} else {
			let e = l("xdy-internal-tables"), n = game.packs.get(e);
			if (n) {
				let e = (await n.getIndex()).find((e) => e.name.includes(t))?._id;
				if (e) {
					let t = await (await n?.getDocument(e)).draw({ displayChat: !1 });
					if (t && t?.results[0]) return t?.results[0].description;
				}
			}
		}
		return t;
	}
	return "";
}
function ye() {
	M = {
		RARITIES: Object.keys(CONFIG.PF2E.rarityTraits),
		SIZES: Object.keys(CONFIG.PF2E.actorSizes),
		CREATURE_IDENTIFICATION_TRAITS: ge,
		PF2E_CREATURE_TRAITS: Object.keys(CONFIG.PF2E.creatureTraits),
		ELITE_WEAK: _e
	};
}
function be(e, t, n) {
	if (y("npcMystifierBlacklist")) {
		let t = y("npcMystifierBlacklist").toLocaleLowerCase().split(",") || null;
		t && (e = e.filter((e) => !t.map((e) => e.trim()).includes(e)));
	}
	let r = [];
	y("npcMystifierUseSize") && (r = e.filter((e) => M.SIZES.includes(e)));
	let i = [];
	y("npcMystifierUseEliteWeak") && (i = e.filter((e) => M.ELITE_WEAK.includes(e)));
	let a = [];
	if (y("npcMystifierUseRarities")) {
		a = e.filter((e) => M.RARITIES.includes(e));
		let t = y("npcMystifierUseRaritiesReplacement").toLocaleLowerCase();
		t !== "" && (a = a.map((e) => e === "common" ? e : t));
	}
	let o = [];
	y("npcMystifierUseCreatureTypesTraits") && (o = e.filter((e) => M.CREATURE_IDENTIFICATION_TRAITS.includes(e)));
	let s = [];
	y("npcMystifierUseCreatureTraits") && (s = e.filter((e) => M.PF2E_CREATURE_TRAITS.includes(e)));
	let c = [];
	return y("npcMystifierUseOtherTraits") && (c = e.filter((e) => !M.ELITE_WEAK.includes(e)).filter((e) => !M.SIZES.includes(e)).filter((e) => !M.RARITIES.includes(e)).filter((e) => !M.CREATURE_IDENTIFICATION_TRAITS.includes(e)).filter((e) => !M.PF2E_CREATURE_TRAITS.includes(e))), Array.from(new Set([t].concat(r, i, a, c, o, s, [n])).values());
}
async function xe(e) {
	let t = game.scenes?.current?.tokens?.get(e);
	if (t) return Se(t);
}
async function Se(e) {
	let t = "", n = (e?.actor)?.system?.traits;
	if (M || ye(), n) {
		let r = n.value;
		if (r) {
			let i = n.rarity;
			i && (r = r.concat(i));
			let a = n?.size?.value;
			a && r.push(a);
			let o = e.actor?.system?.attributes?.adjustment;
			o && r.push(String(o));
			let s = await ve("npcMystifierPrefix") || "", c = await ve("npcMystifierPostfix") || "";
			r = be(r, s, c), t = r.map((e) => e.trim()).filter((e, t) => r.indexOf(e) === t).filter((e) => e.trim().length > 0).map((e) => e?.charAt(0).toLocaleUpperCase() + e?.slice(1)).map((e) => {
				let t = e.toLocaleLowerCase();
				if (M.ELITE_WEAK.includes(t)) switch (t) {
					case M.ELITE_WEAK[0]: return game.i18n.localize("PF2E.NPC.Adjustment.EliteLabel");
					case M.ELITE_WEAK[1]: return game.i18n.localize("PF2E.NPC.Adjustment.WeakLabel");
				}
				else if (M.SIZES.includes(t)) return game.i18n.localize(CONFIG.PF2E.actorSizes[t]);
				let n = game.i18n.translations.PF2E ?? {};
				return (e !== s && e !== c ? n[`Trait${e}`] : e) ?? e;
			}).join(" ");
		}
	} else t = y("npcMystifierNoMatch");
	return t;
}
//#endregion
//#region src/module/feature/tokenMystificationHandler/index.ts
function Ce(e) {
	return y("npcMystifierRandomPropertySkipForUnique") && (e?.actor?.system)?.traits?.rarity === "unique";
}
function we(e) {
	switch (j) {
		case "numberPostfix":
		case "wordPrefix": return e.name.split(" ").length !== (e.actor?.prototypeToken.name.split(" ") ?? [""]).length;
		default: return !1;
	}
}
async function Te() {
	let e = y("npcMystifierRandomWordPrefixRollTable").trim();
	if (e !== null && e !== "null" && e !== "") {
		let t = game?.tables?.find((t) => t.name === e);
		if (!t) {
			let t = l("xdy-internal-tables"), n = game.packs.get(t);
			if (n) {
				let t = (await n.getIndex()).find((t) => t.name.includes(e))?._id;
				if (t) {
					let r = await (await n?.getDocument(t)).draw({ displayChat: !1 });
					return r && r?.results[0] ? r?.results[0].description : e;
				}
			}
		}
		let n = await t?.draw({ displayChat: !1 });
		return n && n?.results[0] ? n?.results[0].description : e;
	}
	return _(`Rolltable for ${e} setting not defined or not found.`), "";
}
async function Ee(t, n, r = !0) {
	let i = "";
	function a() {
		if (y("npcMystifierDemystifyToOriginalTokenName")) {
			let e = O(t, "originalTokenName", "");
			if (e) return e ?? "";
		}
		return t.actor?.prototypeToken.name ?? "";
	}
	if (t && t.actor) {
		i = t.name;
		let o = y("npcMystifierKeepRandomProperty");
		if (n) if (o && !Ce(t)) switch (j) {
			case "numberPostfix":
				i = `${a()} ${i.match(/\d+$/)?.[0] ?? ""}`.trim();
				break;
			case "wordPrefix":
				i = `${(i.match(/\b([a-zA-Z0-9_-]+)\b/) ?? [""])[0]} ${a()}`.trim();
				break;
			default: i = a();
		}
		else i = a();
		else if (O(t, "originalTokenName") || await t.setFlag(e, "originalTokenName", t.name), i = r ? await Se(t) : a(), we(t) && o && !Ce(t)) switch (j) {
			case "numberPostfix":
				i = `${i} ${t.name.match(/\d+$/)?.[0] ?? ""}`.trim();
				break;
			case "wordPrefix":
				i = `${(t.name.match(/\b([a-zA-Z0-9_-]+)\b/) ?? [""])[0]} ${i}`.trim();
				break;
			default: i = a();
		}
		else if (!Ce(t)) {
			let e = 0;
			switch (j) {
				case "numberPostfix":
					e = Math.floor(Math.random() * 100) + 1, canvas?.scene?.tokens?.find((t) => t.name.endsWith(` ${e}`)) && (e = Math.floor(Math.random() * 100) + 1), i += ` ${e}`;
					break;
				case "wordPrefix":
					i = `${await Te()} ${i}`.trim();
					break;
			}
		}
	}
	return i === "" ? y("npcMystifierNoMatch") : i;
}
function De() {
	let e = foundry.helpers.interaction.KeyboardManager;
	switch (me) {
		case "ALT": return game.keyboard.isModifierActive(e.MODIFIER_KEYS.ALT);
		case "CONTROL": return game.keyboard.isModifierActive(e.MODIFIER_KEYS.CONTROL);
		case "META": return game.keyboard.downKeys.has("MetaLeft") || game.keyboard.downKeys.has("MetaRight");
		default: return !1;
	}
}
async function Oe(e) {
	let t = y("npcMystifierModifierKey");
	game.user?.isGM && e && !e?.actor?.hasPlayerOwner && t !== "DISABLED" && (t === "ALWAYS" || De()) && (!game.keyboard?.downKeys.has("V") || game.keyboard?.downKeys.has("Insert")) && Hooks.call("xdy-pf2e-workbench.tokenCreateMystification", e) && await Me(e, !1);
}
function N(e) {
	let t = e?.name, n = e?.actor?.prototypeToken.name ?? "";
	return (t?.indexOf(n) ?? -1) < 0;
}
async function ke(e, t) {
	let n = game.scenes?.current?.tokens?.get(e);
	if (n) return Me(n, t);
}
function Ae(e) {
	let t = Object.keys(CONFIG.PF2E.rarityTraits).indexOf(e);
	return t >= 0 ? t : 0;
}
function je(e) {
	let t = y("npcMystifierIncludeCreaturesOfThisRarityOrGreater"), n = Ae((e.actor?.system)?.traits?.rarity ?? "common") >= Ae(t), r = Number(y("npcMystifierIncludeCreaturesOfThisLevelOrGreater"));
	y("npcMystifierIncludeCreaturesOfThisLevelOrGreaterUsingPartyLevel") && (r = game?.actors?.party?.level ?? r);
	let i = r === -1 || e.actor.level >= r;
	return n && i;
}
async function Me(e, t) {
	if (!e?.actor || !canvas.scene || e.actor.type === "party" || de().includes(e.actor) || y("npcMystifierExcludeActorTypes").split(",").map((e) => e.trim()).includes(e.actor?.type)) return;
	let n = je(e), r = [{
		_id: e.id,
		name: await Ee(e, t, n)
	}], i = y("npcMystifierDemystifyAllTokensBasedOnTheSameActor");
	if (t && game.user?.isGM && N(e) && i) for (let i of canvas.scene.tokens) i.id !== e.id && i.actor?.id === e.actor.id && N(i) && r.push({
		_id: i.id,
		name: await Ee(i, t, n)
	});
	await canvas.scene.updateEmbeddedDocuments("Token", r, { render: !0 }), Ne(e);
}
function Ne(e) {
	for (let t of game.combats) {
		let n = t.combatants.filter((t) => t.actor?.id === e.actor?.id).map((e) => ({ _id: e.id }));
		n.length > 0 && t.updateEmbeddedDocuments("Combatant", n, {
			diff: !1,
			render: !0
		});
	}
}
function Pe(e, t) {
	let n = e?.object?.id ?? (e?.object)?.document?.id;
	if (!n || !canvas?.tokens) return;
	let r = canvas.tokens.get(n);
	if (!r) return;
	let i = N(r);
	if (!Le() || r?.actor?.hasPlayerOwner) return;
	let a = Fe(i, n), o = t.querySelector("div.col.left");
	o && o.appendChild(a);
}
function Fe(e, t) {
	let n = e ? "Unmystify" : "Mystify", r = document.createElement("div");
	r.className = `control-icon toggle ${e ? "active" : ""}`, r.setAttribute("data-action", "mystify");
	let i = document.createElement("i");
	return i.className = y("npcMystifierIcon"), i.title = n, r.appendChild(i), r.addEventListener("click", Ie(t)), r;
}
function Ie(e) {
	return async (t) => {
		let n = t.currentTarget, r = n.classList.contains("active"), i = canvas?.tokens?.get(e) ?? null;
		i && N(i) === r && await Me(i.document, N(i)), n.classList.toggle("active");
	};
}
function Le() {
	return game.user?.isGM && canvas && canvas.tokens;
}
//#endregion
//#region src/module/feature/heroPointHandler/index.ts
var Re = /* @__PURE__ */ function(e) {
	return e[e.Start = 0] = "Start", e[e.Check = 1] = "Check", e[e.Timeout = 2] = "Timeout", e;
}({}), ze = 60 * 1e3, Be = !1;
function Ve() {
	return `modules/${e}/templates/feature/heropoint-handler/index.hbs`;
}
async function He() {
	await game.user?.unsetFlag(e, "heroPointHandler.startTime"), await game.user?.unsetFlag(e, "heroPointHandler.remainingMinutes"), await game.user?.unsetFlag(e, "heroPointHandler.timeout");
}
async function Ue(e) {
	let t = O(game.user, "heroPointHandler.timeout");
	if (t && clearTimeout(t), e > 0) {
		let t = e * ze, n = setTimeout(async () => {
			await qe(2);
		}, t), r = { flags: { "xdy-pf2e-workbench": { heroPointHandler: {
			startTime: game.time.serverTime,
			remainingMinutes: e,
			timeout: n
		} } } };
		await game.user?.update(r);
	} else (!e || e <= 0) && await He();
}
async function We() {
	return qe(2);
}
function Ge(t) {
	tt(t > 0 ? game.i18n.format(`${e}.SETTINGS.heroPointHandler.willBeResetIn`, {
		remainingMinutes: t,
		time: new Date(Date.now() + t * ze).toLocaleTimeString([], {
			hour: "2-digit",
			minute: "2-digit"
		})
	}) : game.i18n.localize(`${e}.SETTINGS.heroPointHandler.timerStopped`), [game.user.id]);
}
function Ke() {
	return [{
		action: "timer",
		label: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.submitShortLabel`),
		default: !0,
		callback: async (e, t, n) => {
			let r = nt(t.form ?? t.closest("form"));
			return {
				button: "timer",
				remainingMinutes: r.remainingMinutes,
				reason: r.reason
			};
		}
	}, {
		action: "noTimer",
		label: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.stopShortLabel`),
		callback: async (e, t, n) => (nt(t.form ?? t.closest("form")), {
			button: "noTimer",
			remainingMinutes: 0,
			reason: ""
		})
	}];
}
async function qe(t) {
	if (!Be) {
		Be = !0;
		try {
			let n;
			switch (t) {
				case 0:
					n = b("heroPointHandlerDefaultTimeoutMinutes");
					break;
				case 1:
					n = Ze(!0);
					break;
				case 2:
					n = b("heroPointHandlerDefaultTimeoutMinutes");
					break;
			}
			let r = `${game.i18n.localize(`${e}.SETTINGS.heroPointHandler.title`)} (${n ? n + " " + game.i18n.localize(`${e}.SETTINGS.heroPointHandler.minutesLeft`) : game.i18n.localize(`${e}.SETTINGS.heroPointHandler.noRunningTimer`)})`, i = await Xe(n, t), a = game.i18n.localize(`${e}.SETTINGS.heroPointHandler.startTimerLabel`), o = game.i18n.localize(`${e}.SETTINGS.heroPointHandler.noTimerLabel`), s = Hooks.on("renderDialogV2", (e) => {
				if (!e.options.window.contentClasses?.includes("hero-point-handler-window")) return;
				Hooks.off("renderDialogV2", s);
				let t = e.element, n = Math.round((window.innerHeight - t.offsetHeight) / 2);
				t.style.top = `${n}px`, e.position.top = n, t.style.left = `${Math.round((window.innerWidth - 375) / 2)}px`, t.style.width = "375px";
				let i = t.querySelector(".window-title");
				i && (i.innerHTML = r);
				let c = t.querySelectorAll("footer button[data-action]");
				for (let e of c) switch (e.dataset.action) {
					case "timer":
						e.title = a, e.setAttribute("aria-label", a);
						break;
					case "noTimer":
						e.title = o, e.setAttribute("aria-label", o);
						break;
				}
			}), c = await foundry.applications.api.DialogV2.wait({
				position: {
					left: Math.round((window.innerWidth - 375) / 2),
					width: 375,
					height: "auto"
				},
				window: {
					title: r,
					resizable: !0,
					positioned: !0,
					contentClasses: ["hero-point-handler-window"],
					icon: "fa-solid fa-hourglass"
				},
				content: i,
				buttons: Ke(),
				close: () => {
					Hooks.off("renderDialogV2", s);
				}
			});
			if (!c) return;
			switch (c.button) {
				case "timer":
					await Ue(c.remainingMinutes);
					break;
				case "noTimer":
					await He();
					break;
			}
			Ge(c.remainingMinutes);
		} finally {
			Be = !1;
		}
	}
}
var Je = "partymembersThatHaveGottenHeropoints";
async function Ye(t) {
	if (t.length === 0) return await game.actors?.party?.unsetFlag(e, Je), -1;
	let n = O(game.actors?.party, Je, "");
	m("Hero point handler existing party flag value", n);
	let r = n ? new Set(n.split(",")) : /* @__PURE__ */ new Set(), i = t.filter((e) => !r.has(e.id));
	i.length === 0 && (r.clear(), i.push(...t));
	let a = i[Math.floor(Math.random() * i.length)]?.id ?? "";
	return r.add(a), await game.actors?.party?.setFlag(e, Je, [...r].join(",")), t.findIndex((e) => e.id === a);
}
async function Xe(t, n) {
	let r = de(), i = /* @__PURE__ */ new Set();
	switch (n) {
		case 0: break;
		case 2: {
			let e = -1;
			switch (y("heropointHandlerRandomization")) {
				case "none": break;
				case "random":
					e = Math.floor(Math.random() * r.length);
					break;
				case "randomPartymemberThatHasNotReceivedAHeropoint": e = await Ye(r);
			}
			r.length > 0 && e >= 0 && i.add(e);
			break;
		}
		case 1: break;
	}
	let a = b("heroPointHandlerDefaultTimeoutMinutes"), o = {
		instructions: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.instructions`),
		doWhat: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.doWhat`),
		resetTo: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.resetTo`),
		addLabel: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.add`),
		ignore: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.ignore`),
		thisMany: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.thisMany`),
		addOne: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.addOne`),
		actors: r.map((e, t) => {
			let n = e?.isOfType("character") ? e.system.resources.heroPoints.value : 0, r = e?.isOfType("character") ? e.system.resources.heroPoints.max : 3, a = game.users?.find((t) => !t.isGM && e?.ownership[t.id] === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)?.name ?? "", o = a ? ` (${a})` : "";
			return {
				id: e.id,
				name: `${e.name}${o} [${n}/${r}]`,
				radioId: `characters-${t}`,
				checked: i.has(t)
			};
		}),
		timerValue: game.i18n.format(`${e}.SETTINGS.heroPointHandler.timerValue`, { maxMinutes: a }),
		timerMinutes: t || a,
		maxMinutes: a,
		reasonLabel: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.reasonLabel`),
		reasonPlaceholder: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.reasonPlaceholder`),
		showAfter: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.showAfter`),
		submitShortLabel: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.submitShortLabel`),
		stopShortLabel: game.i18n.localize(`${e}.SETTINGS.heroPointHandler.stopShortLabel`)
	};
	return foundry.applications.handlebars.renderTemplate(Ve(), o);
}
function Ze(e) {
	let t = O(game.user, "heroPointHandler.startTime"), n = O(game.user, "heroPointHandler.remainingMinutes"), r = b("heroPointHandlerDefaultTimeoutMinutes"), i = Math.clamp(n ?? (e ? r : 0), 0, r), a = game.time.serverTime - (t ?? game.time.serverTime);
	return i - Math.floor(a / ze);
}
async function Qe(e) {
	for (let t of de()) t.isOfType("character") && await t.update({ "system.resources.heroPoints.value": Math.min(e, t.system.resources.heroPoints.max) });
}
async function $e(e, t = "ALL") {
	let n;
	switch (t) {
		case "ALL":
			n = de();
			break;
		case "NONE":
			n = [];
			break;
		default:
			n = game.actors?.has(t) ? [game.actors.get(t, { strict: !0 })] : [];
			break;
	}
	for (let t of n) {
		if (!t.isOfType("character")) continue;
		let n = t.system, r = Math.min(n.resources.heroPoints.value + e, t.system.resources.heroPoints.max);
		await t.update({ "system.resources.heroPoints.value": r });
	}
}
function et(t, n = "") {
	for (let r of t) $e(1, r).then(() => {
		let t = game?.actors?.find((e) => e.id === r)?.name;
		if (t) {
			let r = game.i18n.format(`${e}.SETTINGS.heroPointHandler.addedFor`, { name: t });
			n && (r += ` (${n})`), tt(r), y("heropointHandlerNotification") && oe("info", r);
		}
	});
}
function tt(e, t = void 0) {
	y("heropointHandlerNotificationChat") ? E(ChatMessage.create({
		flavor: e,
		whisper: t
	}), "heropointhandler#sendMessage") : ui.notifications.info(e);
}
function nt(t) {
	if (!t) return {
		remainingMinutes: 0,
		reason: ""
	};
	let n = t.querySelector("input[name=\"sessionStart\"]:checked"), r = n ? n.value : "IGNORE", i = t.querySelector("input[name=\"heropoints\"]"), a = i ? Number.parseInt(i.value) : 1, o = t.querySelector("input[name=\"reason\"]"), s = o ? o.value : "", c = t.querySelectorAll("input[name=\"characters\"]:checked"), l = Array.from(c).map((e) => e.value), u = t.querySelector("input[name=\"timerText\"]"), d = b("heroPointHandlerDefaultTimeoutMinutes"), f = Math.clamp(u && Number.parseInt(u.value) || 0, 0, d);
	return r === "RESET" ? Qe(a).then(() => {
		tt(game.i18n.format(`${e}.SETTINGS.heroPointHandler.resetToForAll`, { heroPoints: a })), et(l, s);
	}) : r === "ADD" ? $e(a).then(() => {
		tt(game.i18n.format(`${e}.SETTINGS.heroPointHandler.addedToForAll`, { heroPoints: a })), et(l, s);
	}) : r === "IGNORE" && et(l, s), {
		remainingMinutes: f,
		reason: s
	};
}
//#endregion
//#region src/module/feature/initiativeHandler/index.ts
async function rt(e) {
	let t = game?.combat;
	if (t && e && e !== t?.combatant?.id) {
		let n = t?.combatants.map((e) => ({ initiative: e.initiative || 0 })).sort((e, t) => e.initiative - t.initiative).find((e) => e.initiative > t?.combatant?.initiative)?.initiative, r = t?.combatant?.initiative, i = !n || n < r ? r + 2 : (n + r) / 2 || 0;
		await t?.setInitiative(e, i);
	}
}
function it(e) {
	let t = game.combat?.getCombatantByToken(e.isToken ? e.token?.id : canvas?.scene?.tokens?.find((t) => t.actor?.id === e.id)?.id);
	D(e) && t && t.id !== game.combat?.combatant?.id && E(rt(t.id), "moveSelectedAheadOfCurrent");
}
//#endregion
//#region src/module/feature/canvas-pointer/constants.ts
var at = "canvasPointerSync", ot = "canvasPointerStop", st = "canvasPointerPing", ct = "xdy-pf2e-workbench-pointer-remote", lt = "module.xdy-pf2e-workbench";
//#endregion
//#region src/module/feature/canvas-pointer/network.ts
function ut(e, t) {
	if (!canvas?.ready) return {
		screenX: 0,
		screenY: 0
	};
	let { x: n, y: r } = canvas.stage.worldTransform.apply({
		x: e,
		y: t
	});
	return {
		screenX: n,
		screenY: r
	};
}
function dt(e, t) {
	if (!canvas?.ready) return;
	let n = canvas.mousePosition, r = {
		operation: at,
		userId: game.user?.id,
		wx: Math.round(n.x),
		wy: Math.round(n.y),
		iconClass: e,
		color: t
	};
	game.socket.emit(lt, r);
}
function ft(e, t) {
	if (!canvas?.ready) return;
	let n = canvas.mousePosition;
	game.socket.emit(lt, {
		operation: st,
		userId: game.user?.id,
		wx: Math.round(n.x),
		wy: Math.round(n.y),
		soundSrc: e,
		volume: t
	});
}
function pt(e) {
	game.socket.emit(lt, {
		operation: ot,
		userId: e
	});
}
function mt(e, t) {
	let n = e.get(t);
	return n || (n = document.createElement("i"), n.classList.add(ct), n.setAttribute("aria-hidden", "true"), document.body.appendChild(n), e.set(t, n)), n;
}
function ht(e, t, n) {
	e.className = `${ct} ${t}`, e.style.color = n;
}
function gt(e, t) {
	let n = e.get(t);
	n && (n.remove(), e.delete(t));
}
//#endregion
//#region src/module/feature/canvas-pointer/index.ts
var _t = !1, vt = !1, P = null, yt = "", bt = "", xt = null, St = /* @__PURE__ */ new Map();
function Ct() {
	_t || (_t = !0, game.socket.on(lt, (e) => {
		e.operation === "canvasPointerSync" ? kt(e) : e.operation === "canvasPointerPing" ? Ft(e) : At(e);
	}), Hooks.on("userConnected", jt));
}
function wt(e) {
	return vt || !canvas?.ready ? !1 : (vt = !0, yt = e, bt = game.user?.color?.css ?? "#ffffff", Ot(), Et(), document.body.classList.add("xdy-pf2e-workbench-pointer-active"), document.addEventListener("mousemove", Nt, { passive: !0 }), document.addEventListener("visibilitychange", Mt), document.addEventListener("mousedown", Pt), !0);
}
function Tt() {
	return vt ? (vt = !1, Dt(), document.body.classList.remove("xdy-pf2e-workbench-pointer-active"), document.removeEventListener("mousemove", Nt), document.removeEventListener("visibilitychange", Mt), document.removeEventListener("mousedown", Pt), P && (P.style.display = "none"), !0) : !1;
}
function Et() {
	dt(yt, bt);
	let e = y("canvasPointerBroadcastInterval") ?? 10;
	xt = setInterval(() => dt(yt, bt), e);
}
function Dt() {
	xt !== null && (clearInterval(xt), xt = null), pt(game.user?.id ?? "");
}
function Ot() {
	P || (P = document.createElement("i"), P.id = "xdy-pf2e-workbench-pointer-overlay", P.setAttribute("aria-hidden", "true"), document.body.appendChild(P)), P.className = yt, P.style.display = "block", P.style.color = bt;
}
function kt(e) {
	if (!canvas?.ready || e.userId === game.user?.id) return;
	let { screenX: t, screenY: n } = ut(e.wx, e.wy), r = mt(St, e.userId);
	ht(r, e.iconClass, e.color), r.style.left = `${Math.round(t)}px`, r.style.top = `${Math.round(n)}px`;
}
function At({ userId: e }) {
	gt(St, e);
}
function jt(e, t) {
	t || gt(St, e.id);
}
function Mt() {
	document.visibilityState === "hidden" && Tt();
}
function Nt(e) {
	P && (P.style.left = `${e.clientX}px`, P.style.top = `${e.clientY}px`);
}
function Pt(e) {
	if (!canvas?.ready) return;
	let t = y("canvasPointerPingMode");
	if (t === "sound" || t === "visualAndSound") {
		let e = y("canvasPointerPingSound"), t = y("canvasPointerPingVolume");
		e && (game.audio.play(e, { volume: t }), ft(e, t));
	}
	(t === "visual" || t === "visualAndSound") && canvas.ping(canvas.mousePosition);
}
function Ft(e) {
	canvas?.ready && e.userId !== game.user?.id && e.soundSrc && game.audio.play(e.soundSrc, { volume: e.volume });
}
//#endregion
//#region src/module/keybinds.ts
function It() {
	h(`${e} | registerKeybindings`);
	let t = game.keybindings;
	t.register(e, "addUserTargets", {
		name: `${e}.SETTINGS.addUserTargets.name`,
		hint: `${e}.SETTINGS.addUserTargets.hint`,
		restricted: !0,
		editable: [],
		onDown: () => {
			let t = game.users.filter((e) => !e.isGM).map((e) => ({
				label: e.name,
				key: e.id
			})), n = "<div style=\"display: flex; line-height: 2rem;\">\n        <label style=\"flex-grow: 1;\" for=\"dialogUserId\">User</label>\n        <select style=\"height: 2rem;\" id=\"dialogUserId\">";
			for (let { key: e, label: r } of t) n += `<option value="${e}">${r}</option>`;
			return n += "</div></select>", foundry.applications.api.DialogV2.wait({
				window: { title: game.i18n.localize(`${e}.SETTINGS.addUserTargets.title`) },
				content: n,
				buttons: [{
					icon: "<i class=\"fa-solid fa-users\"></i>",
					label: game.i18n.localize(`${e}.SETTINGS.addUserTargets.addFor`),
					action: "addFor",
					callback: async (e, t, n) => {
						let r = Array.from(canvas.tokens?.controlled ?? []).concat(canvas.tokens?.placeables.filter((e) => e.mouseInteractionManager.state === 1) ?? []), i = game.users?.find((e) => e.id === (n.element.querySelector("#dialogUserId")?.value ?? ""));
						if (game.user?.isGM && r && i) for (let e of r) e.setTarget(!0, {
							user: i,
							releaseOthers: !1
						}), i.targets.add(e);
					}
				}, {
					icon: "<i class=\"fa-solid fa-users-slash\"></i>",
					label: game.i18n.localize(`${e}.SETTINGS.addUserTargets.clearFor`),
					action: "clearFor",
					callback: async (e, t, n) => {
						let r = game.users?.find((e) => e.id === (n.element.querySelector("#dialogUserId")?.value ?? ""));
						if (game.user?.isGM && r) {
							let e = r.targets;
							for (let t of e) t.setTarget(!1, {
								user: r,
								releaseOthers: !1
							});
						}
					}
				}],
				default: "addFor",
				rejectClose: !1
			}), !0;
		}
	}), t.register(e, "heroPointHandler", {
		name: game.i18n.localize(`${e}.SETTINGS.heroPointHandlerKey.name`),
		hint: game.i18n.localize(`${e}.SETTINGS.heroPointHandlerKey.hint`),
		restricted: !0,
		onDown: () => (game.user?.isGM && y("heroPointHandler") && E(qe(Ze(!1) > 0 ? Re.Check : Re.Start), "heroPointHandler"), !0)
	}), t.register(e, "moveBeforeCurrentCombatantKey", {
		name: game.i18n.localize(`${e}.SETTINGS.moveBeforeCurrentCombatantKey.name`),
		hint: game.i18n.localize(`${e}.SETTINGS.moveBeforeCurrentCombatantKey.hint`),
		restricted: !0,
		onDown: () => {
			if (game.user?.isGM) {
				let e = game?.combat?.getCombatantsByToken(canvas?.tokens?.controlled[0].id)[0];
				e && E(rt(e.id), "moveSelectedAheadOfCurrent");
			}
			return !0;
		}
	}), t.register(e, "npcMystifierMystifyKey", {
		name: game.i18n.localize(`${e}.SETTINGS.npcMystifierMystifyKey.name`),
		hint: game.i18n.localize(`${e}.SETTINGS.npcMystifierMystifyKey.hint`),
		restricted: !0,
		editable: [{
			key: "KeyM",
			modifiers: ["Shift"]
		}],
		onDown: () => {
			if (y("npcMystifier")) {
				if (Le()) for (let e of canvas?.tokens?.controlled ?? []) E(Me(e?.document, N(e)), "doMystification");
				else ui.notifications?.warn(game.i18n.localize(`${e}.SETTINGS.notifications.cantMystify`));
				return !0;
			}
			return !1;
		},
		reservedModifiers: [],
		precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL
	}), t.register(e, "canvasPointer", {
		name: game.i18n.localize(`${e}.SETTINGS.canvasPointerKey.name`),
		hint: game.i18n.localize(`${e}.SETTINGS.canvasPointerKey.hint`),
		restricted: !1,
		editable: [{
			key: "KeyX",
			modifiers: []
		}],
		onDown: () => y("canvasPointer") ? wt(y("canvasPointerIcon") || "fa-regular fa-hand-point-down") : !1,
		onUp: () => Tt(),
		reservedModifiers: [],
		precedence: CONST.KEYBINDING_PRECEDENCE.NORMAL
	});
	for (let n = 1; n <= 5; n++) for (let r = 1; r <= 10; r++) t.register(e, `callHotbarPage${n}Macro${r}`, {
		name: `Call hotbar macro on page ${n} position ${r}`,
		hint: `Call hotbar macro on page ${n} position ${r}`,
		restricted: !1,
		onDown: () => ((game.user?.getHotbarMacros(n)?.[r - 1]).macro.execute(), !0)
	});
}
var F = {
	hitPoints: [
		{
			level: -1,
			high: {
				minimum: 9,
				maximum: 10,
				die: 2
			},
			moderate: {
				minimum: 7,
				maximum: 8,
				die: 2
			},
			low: {
				minimum: 5,
				maximum: 6,
				die: 2
			}
		},
		{
			level: 0,
			high: {
				minimum: 17,
				maximum: 20,
				die: 4
			},
			moderate: {
				minimum: 14,
				maximum: 16,
				die: 3
			},
			low: {
				minimum: 11,
				maximum: 13,
				die: 3
			}
		},
		{
			level: 1,
			high: {
				minimum: 24,
				maximum: 26,
				die: 3
			},
			moderate: {
				minimum: 19,
				maximum: 21,
				die: 3
			},
			low: {
				minimum: 14,
				maximum: 16,
				die: 3
			}
		},
		{
			level: 2,
			high: {
				minimum: 36,
				maximum: 40,
				die: 5
			},
			moderate: {
				minimum: 28,
				maximum: 32,
				die: 5
			},
			low: {
				minimum: 21,
				maximum: 25,
				die: 5
			}
		},
		{
			level: 3,
			high: {
				minimum: 53,
				maximum: 59,
				die: 7
			},
			moderate: {
				minimum: 42,
				maximum: 48,
				die: 7
			},
			low: {
				minimum: 31,
				maximum: 37,
				die: 7
			}
		},
		{
			level: 4,
			high: {
				minimum: 72,
				maximum: 78,
				die: 7
			},
			moderate: {
				minimum: 57,
				maximum: 63,
				die: 7
			},
			low: {
				minimum: 42,
				maximum: 48,
				die: 7
			}
		},
		{
			level: 5,
			high: {
				minimum: 91,
				maximum: 97,
				die: 7
			},
			moderate: {
				minimum: 72,
				maximum: 78,
				die: 7
			},
			low: {
				minimum: 53,
				maximum: 59,
				die: 7
			}
		},
		{
			level: 6,
			high: {
				minimum: 115,
				maximum: 123,
				die: 9
			},
			moderate: {
				minimum: 91,
				maximum: 99,
				die: 9
			},
			low: {
				minimum: 67,
				maximum: 75,
				die: 9
			}
		},
		{
			level: 7,
			high: {
				minimum: 140,
				maximum: 148,
				die: 9
			},
			moderate: {
				minimum: 111,
				maximum: 119,
				die: 9
			},
			low: {
				minimum: 82,
				maximum: 90,
				die: 9
			}
		},
		{
			level: 8,
			high: {
				minimum: 165,
				maximum: 173,
				die: 9
			},
			moderate: {
				minimum: 131,
				maximum: 139,
				die: 9
			},
			low: {
				minimum: 97,
				maximum: 105,
				die: 9
			}
		},
		{
			level: 9,
			high: {
				minimum: 190,
				maximum: 198,
				die: 9
			},
			moderate: {
				minimum: 151,
				maximum: 159,
				die: 9
			},
			low: {
				minimum: 112,
				maximum: 120,
				die: 9
			}
		},
		{
			level: 10,
			high: {
				minimum: 215,
				maximum: 223,
				die: 9
			},
			moderate: {
				minimum: 171,
				maximum: 179,
				die: 9
			},
			low: {
				minimum: 127,
				maximum: 135,
				die: 9
			}
		},
		{
			level: 11,
			high: {
				minimum: 240,
				maximum: 248,
				die: 9
			},
			moderate: {
				minimum: 191,
				maximum: 199,
				die: 9
			},
			low: {
				minimum: 142,
				maximum: 150,
				die: 9
			}
		},
		{
			level: 12,
			high: {
				minimum: 265,
				maximum: 273,
				die: 9
			},
			moderate: {
				minimum: 211,
				maximum: 219,
				die: 9
			},
			low: {
				minimum: 157,
				maximum: 165,
				die: 9
			}
		},
		{
			level: 13,
			high: {
				minimum: 290,
				maximum: 298,
				die: 9
			},
			moderate: {
				minimum: 231,
				maximum: 239,
				die: 9
			},
			low: {
				minimum: 172,
				maximum: 180,
				die: 9
			}
		},
		{
			level: 14,
			high: {
				minimum: 315,
				maximum: 323,
				die: 9
			},
			moderate: {
				minimum: 251,
				maximum: 259,
				die: 9
			},
			low: {
				minimum: 187,
				maximum: 195,
				die: 9
			}
		},
		{
			level: 15,
			high: {
				minimum: 340,
				maximum: 348,
				die: 9
			},
			moderate: {
				minimum: 271,
				maximum: 279,
				die: 9
			},
			low: {
				minimum: 202,
				maximum: 210,
				die: 9
			}
		},
		{
			level: 16,
			high: {
				minimum: 365,
				maximum: 373,
				die: 9
			},
			moderate: {
				minimum: 291,
				maximum: 299,
				die: 9
			},
			low: {
				minimum: 217,
				maximum: 225,
				die: 9
			}
		},
		{
			level: 17,
			high: {
				minimum: 390,
				maximum: 398,
				die: 9
			},
			moderate: {
				minimum: 311,
				maximum: 319,
				die: 9
			},
			low: {
				minimum: 232,
				maximum: 240,
				die: 9
			}
		},
		{
			level: 18,
			high: {
				minimum: 415,
				maximum: 423,
				die: 9
			},
			moderate: {
				minimum: 331,
				maximum: 339,
				die: 9
			},
			low: {
				minimum: 247,
				maximum: 255,
				die: 9
			}
		},
		{
			level: 19,
			high: {
				minimum: 440,
				maximum: 448,
				die: 9
			},
			moderate: {
				minimum: 351,
				maximum: 359,
				die: 9
			},
			low: {
				minimum: 262,
				maximum: 270,
				die: 9
			}
		},
		{
			level: 20,
			high: {
				minimum: 465,
				maximum: 473,
				die: 9
			},
			moderate: {
				minimum: 371,
				maximum: 379,
				die: 9
			},
			low: {
				minimum: 277,
				maximum: 285,
				die: 9
			}
		},
		{
			level: 21,
			high: {
				minimum: 495,
				maximum: 505,
				die: 11
			},
			moderate: {
				minimum: 395,
				maximum: 405,
				die: 11
			},
			low: {
				minimum: 295,
				maximum: 305,
				die: 11
			}
		},
		{
			level: 22,
			high: {
				minimum: 532,
				maximum: 544,
				die: 13
			},
			moderate: {
				minimum: 424,
				maximum: 436,
				die: 13
			},
			low: {
				minimum: 317,
				maximum: 329,
				die: 13
			}
		},
		{
			level: 23,
			high: {
				minimum: 569,
				maximum: 581,
				die: 13
			},
			moderate: {
				minimum: 454,
				maximum: 466,
				die: 13
			},
			low: {
				minimum: 339,
				maximum: 351,
				die: 13
			}
		},
		{
			level: 24,
			high: {
				minimum: 617,
				maximum: 633,
				die: 17
			},
			moderate: {
				minimum: 492,
				maximum: 508,
				die: 17
			},
			low: {
				minimum: 367,
				maximum: 383,
				die: 17
			}
		}
	],
	abilityScore: [
		{
			level: -1,
			extreme: 3,
			high: 3,
			moderate: 2,
			low: 0,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 0,
			extreme: 3,
			high: 3,
			moderate: 2,
			low: 0,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 1,
			extreme: 5,
			high: 4,
			moderate: 3,
			low: 1,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 2,
			extreme: 5,
			high: 4,
			moderate: 3,
			low: 1,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 3,
			extreme: 5,
			high: 4,
			moderate: 3,
			low: 1,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 4,
			extreme: 6,
			high: 5,
			moderate: 3,
			low: 2,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 5,
			extreme: 6,
			high: 5,
			moderate: 4,
			low: 2,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 6,
			extreme: 7,
			high: 5,
			moderate: 4,
			low: 2,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 7,
			extreme: 7,
			high: 6,
			moderate: 4,
			low: 2,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 8,
			extreme: 7,
			high: 6,
			moderate: 4,
			low: 3,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 9,
			extreme: 7,
			high: 6,
			moderate: 4,
			low: 3,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 10,
			extreme: 8,
			high: 7,
			moderate: 5,
			low: 3,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 11,
			extreme: 8,
			high: 7,
			moderate: 5,
			low: 3,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 12,
			extreme: 8,
			high: 7,
			moderate: 5,
			low: 4,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 13,
			extreme: 9,
			high: 8,
			moderate: 5,
			low: 4,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 14,
			extreme: 9,
			high: 8,
			moderate: 5,
			low: 4,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 15,
			extreme: 9,
			high: 8,
			moderate: 6,
			low: 4,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 16,
			extreme: 10,
			high: 9,
			moderate: 6,
			low: 5,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 17,
			extreme: 10,
			high: 9,
			moderate: 6,
			low: 5,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 18,
			extreme: 10,
			high: 9,
			moderate: 6,
			low: 5,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 19,
			extreme: 11,
			high: 10,
			moderate: 6,
			low: 5,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 20,
			extreme: 11,
			high: 10,
			moderate: 7,
			low: 6,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 21,
			extreme: 11,
			high: 10,
			moderate: 7,
			low: 6,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 22,
			extreme: 11,
			high: 10,
			moderate: 8,
			low: 6,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 23,
			extreme: 11,
			high: 10,
			moderate: 8,
			low: 6,
			terrible: -4,
			abysmal: -5
		},
		{
			level: 24,
			extreme: 13,
			high: 12,
			moderate: 9,
			low: 7,
			terrible: -4,
			abysmal: -5
		}
	],
	savingThrow: [
		{
			level: -1,
			extreme: 9,
			high: 8,
			moderate: 5,
			low: 2,
			terrible: 0
		},
		{
			level: 0,
			extreme: 10,
			high: 9,
			moderate: 6,
			low: 3,
			terrible: 1
		},
		{
			level: 1,
			extreme: 11,
			high: 10,
			moderate: 7,
			low: 4,
			terrible: 2
		},
		{
			level: 2,
			extreme: 12,
			high: 11,
			moderate: 8,
			low: 5,
			terrible: 3
		},
		{
			level: 3,
			extreme: 14,
			high: 12,
			moderate: 9,
			low: 6,
			terrible: 4
		},
		{
			level: 4,
			extreme: 15,
			high: 14,
			moderate: 11,
			low: 8,
			terrible: 6
		},
		{
			level: 5,
			extreme: 17,
			high: 15,
			moderate: 12,
			low: 9,
			terrible: 7
		},
		{
			level: 6,
			extreme: 18,
			high: 17,
			moderate: 14,
			low: 11,
			terrible: 8
		},
		{
			level: 7,
			extreme: 20,
			high: 18,
			moderate: 15,
			low: 12,
			terrible: 10
		},
		{
			level: 8,
			extreme: 21,
			high: 19,
			moderate: 16,
			low: 13,
			terrible: 11
		},
		{
			level: 9,
			extreme: 23,
			high: 21,
			moderate: 18,
			low: 15,
			terrible: 12
		},
		{
			level: 10,
			extreme: 24,
			high: 22,
			moderate: 19,
			low: 16,
			terrible: 14
		},
		{
			level: 11,
			extreme: 26,
			high: 24,
			moderate: 21,
			low: 18,
			terrible: 15
		},
		{
			level: 12,
			extreme: 27,
			high: 25,
			moderate: 22,
			low: 19,
			terrible: 16
		},
		{
			level: 13,
			extreme: 29,
			high: 26,
			moderate: 23,
			low: 20,
			terrible: 18
		},
		{
			level: 14,
			extreme: 30,
			high: 28,
			moderate: 25,
			low: 22,
			terrible: 19
		},
		{
			level: 15,
			extreme: 32,
			high: 29,
			moderate: 26,
			low: 23,
			terrible: 20
		},
		{
			level: 16,
			extreme: 33,
			high: 30,
			moderate: 28,
			low: 25,
			terrible: 22
		},
		{
			level: 17,
			extreme: 35,
			high: 32,
			moderate: 29,
			low: 26,
			terrible: 23
		},
		{
			level: 18,
			extreme: 36,
			high: 33,
			moderate: 30,
			low: 27,
			terrible: 24
		},
		{
			level: 19,
			extreme: 38,
			high: 35,
			moderate: 32,
			low: 29,
			terrible: 26
		},
		{
			level: 20,
			extreme: 39,
			high: 36,
			moderate: 33,
			low: 30,
			terrible: 27
		},
		{
			level: 21,
			extreme: 41,
			high: 38,
			moderate: 35,
			low: 32,
			terrible: 28
		},
		{
			level: 22,
			extreme: 43,
			high: 39,
			moderate: 36,
			low: 33,
			terrible: 30
		},
		{
			level: 23,
			extreme: 44,
			high: 40,
			moderate: 37,
			low: 34,
			terrible: 31
		},
		{
			level: 24,
			extreme: 46,
			high: 42,
			moderate: 38,
			low: 36,
			terrible: 32
		}
	],
	armorClass: [
		{
			level: -1,
			extreme: 18,
			high: 15,
			moderate: 14,
			low: 12
		},
		{
			level: 0,
			extreme: 19,
			high: 16,
			moderate: 15,
			low: 13
		},
		{
			level: 1,
			extreme: 19,
			high: 16,
			moderate: 15,
			low: 13
		},
		{
			level: 2,
			extreme: 21,
			high: 18,
			moderate: 17,
			low: 15
		},
		{
			level: 3,
			extreme: 22,
			high: 19,
			moderate: 18,
			low: 16
		},
		{
			level: 4,
			extreme: 24,
			high: 21,
			moderate: 20,
			low: 18
		},
		{
			level: 5,
			extreme: 25,
			high: 22,
			moderate: 21,
			low: 19
		},
		{
			level: 6,
			extreme: 27,
			high: 24,
			moderate: 23,
			low: 21
		},
		{
			level: 7,
			extreme: 28,
			high: 25,
			moderate: 24,
			low: 22
		},
		{
			level: 8,
			extreme: 30,
			high: 27,
			moderate: 26,
			low: 24
		},
		{
			level: 9,
			extreme: 31,
			high: 28,
			moderate: 27,
			low: 25
		},
		{
			level: 10,
			extreme: 33,
			high: 30,
			moderate: 29,
			low: 27
		},
		{
			level: 11,
			extreme: 34,
			high: 31,
			moderate: 30,
			low: 28
		},
		{
			level: 12,
			extreme: 36,
			high: 33,
			moderate: 32,
			low: 30
		},
		{
			level: 13,
			extreme: 37,
			high: 34,
			moderate: 33,
			low: 31
		},
		{
			level: 14,
			extreme: 39,
			high: 36,
			moderate: 35,
			low: 33
		},
		{
			level: 15,
			extreme: 40,
			high: 37,
			moderate: 36,
			low: 34
		},
		{
			level: 16,
			extreme: 42,
			high: 39,
			moderate: 38,
			low: 36
		},
		{
			level: 17,
			extreme: 43,
			high: 40,
			moderate: 39,
			low: 37
		},
		{
			level: 18,
			extreme: 45,
			high: 42,
			moderate: 41,
			low: 39
		},
		{
			level: 19,
			extreme: 46,
			high: 43,
			moderate: 42,
			low: 40
		},
		{
			level: 20,
			extreme: 48,
			high: 45,
			moderate: 44,
			low: 42
		},
		{
			level: 21,
			extreme: 49,
			high: 46,
			moderate: 45,
			low: 43
		},
		{
			level: 22,
			extreme: 51,
			high: 48,
			moderate: 47,
			low: 45
		},
		{
			level: 23,
			extreme: 52,
			high: 49,
			moderate: 48,
			low: 46
		},
		{
			level: 24,
			extreme: 54,
			high: 51,
			moderate: 50,
			low: 48
		}
	],
	perception: [
		{
			level: -1,
			extreme: 9,
			high: 8,
			moderate: 5,
			low: 2,
			terrible: 0
		},
		{
			level: 0,
			extreme: 10,
			high: 9,
			moderate: 6,
			low: 3,
			terrible: 1
		},
		{
			level: 1,
			extreme: 11,
			high: 10,
			moderate: 7,
			low: 4,
			terrible: 2
		},
		{
			level: 2,
			extreme: 12,
			high: 11,
			moderate: 8,
			low: 5,
			terrible: 3
		},
		{
			level: 3,
			extreme: 14,
			high: 12,
			moderate: 9,
			low: 6,
			terrible: 4
		},
		{
			level: 4,
			extreme: 15,
			high: 14,
			moderate: 11,
			low: 8,
			terrible: 6
		},
		{
			level: 5,
			extreme: 17,
			high: 15,
			moderate: 12,
			low: 9,
			terrible: 7
		},
		{
			level: 6,
			extreme: 18,
			high: 17,
			moderate: 14,
			low: 11,
			terrible: 8
		},
		{
			level: 7,
			extreme: 20,
			high: 18,
			moderate: 15,
			low: 12,
			terrible: 10
		},
		{
			level: 8,
			extreme: 21,
			high: 19,
			moderate: 16,
			low: 13,
			terrible: 11
		},
		{
			level: 9,
			extreme: 23,
			high: 21,
			moderate: 18,
			low: 15,
			terrible: 12
		},
		{
			level: 10,
			extreme: 24,
			high: 22,
			moderate: 19,
			low: 16,
			terrible: 14
		},
		{
			level: 11,
			extreme: 26,
			high: 24,
			moderate: 21,
			low: 18,
			terrible: 15
		},
		{
			level: 12,
			extreme: 27,
			high: 25,
			moderate: 22,
			low: 19,
			terrible: 16
		},
		{
			level: 13,
			extreme: 29,
			high: 26,
			moderate: 23,
			low: 20,
			terrible: 18
		},
		{
			level: 14,
			extreme: 30,
			high: 28,
			moderate: 25,
			low: 22,
			terrible: 19
		},
		{
			level: 15,
			extreme: 32,
			high: 29,
			moderate: 26,
			low: 23,
			terrible: 20
		},
		{
			level: 16,
			extreme: 33,
			high: 30,
			moderate: 28,
			low: 25,
			terrible: 22
		},
		{
			level: 17,
			extreme: 35,
			high: 32,
			moderate: 29,
			low: 26,
			terrible: 23
		},
		{
			level: 18,
			extreme: 36,
			high: 33,
			moderate: 30,
			low: 27,
			terrible: 24
		},
		{
			level: 19,
			extreme: 38,
			high: 35,
			moderate: 32,
			low: 29,
			terrible: 26
		},
		{
			level: 20,
			extreme: 39,
			high: 36,
			moderate: 33,
			low: 30,
			terrible: 27
		},
		{
			level: 21,
			extreme: 41,
			high: 38,
			moderate: 35,
			low: 32,
			terrible: 28
		},
		{
			level: 22,
			extreme: 43,
			high: 39,
			moderate: 36,
			low: 33,
			terrible: 30
		},
		{
			level: 23,
			extreme: 44,
			high: 40,
			moderate: 37,
			low: 34,
			terrible: 31
		},
		{
			level: 24,
			extreme: 46,
			high: 42,
			moderate: 38,
			low: 36,
			terrible: 32
		}
	],
	skill: [
		{
			level: -1,
			extreme: 8,
			high: 5,
			moderate: 4,
			low: 2,
			terrible: 1
		},
		{
			level: 0,
			extreme: 9,
			high: 6,
			moderate: 5,
			low: 3,
			terrible: 2
		},
		{
			level: 1,
			extreme: 10,
			high: 7,
			moderate: 6,
			low: 4,
			terrible: 3
		},
		{
			level: 2,
			extreme: 11,
			high: 8,
			moderate: 7,
			low: 5,
			terrible: 4
		},
		{
			level: 3,
			extreme: 13,
			high: 10,
			moderate: 9,
			low: 7,
			terrible: 5
		},
		{
			level: 4,
			extreme: 15,
			high: 12,
			moderate: 10,
			low: 8,
			terrible: 7
		},
		{
			level: 5,
			extreme: 16,
			high: 13,
			moderate: 12,
			low: 10,
			terrible: 8
		},
		{
			level: 6,
			extreme: 18,
			high: 15,
			moderate: 13,
			low: 11,
			terrible: 9
		},
		{
			level: 7,
			extreme: 20,
			high: 17,
			moderate: 15,
			low: 13,
			terrible: 11
		},
		{
			level: 8,
			extreme: 21,
			high: 18,
			moderate: 16,
			low: 14,
			terrible: 12
		},
		{
			level: 9,
			extreme: 23,
			high: 20,
			moderate: 18,
			low: 16,
			terrible: 13
		},
		{
			level: 10,
			extreme: 25,
			high: 22,
			moderate: 19,
			low: 17,
			terrible: 15
		},
		{
			level: 11,
			extreme: 26,
			high: 23,
			moderate: 21,
			low: 19,
			terrible: 16
		},
		{
			level: 12,
			extreme: 28,
			high: 25,
			moderate: 22,
			low: 20,
			terrible: 17
		},
		{
			level: 13,
			extreme: 30,
			high: 27,
			moderate: 24,
			low: 22,
			terrible: 19
		},
		{
			level: 14,
			extreme: 31,
			high: 28,
			moderate: 25,
			low: 23,
			terrible: 20
		},
		{
			level: 15,
			extreme: 33,
			high: 30,
			moderate: 27,
			low: 25,
			terrible: 21
		},
		{
			level: 16,
			extreme: 35,
			high: 32,
			moderate: 28,
			low: 26,
			terrible: 23
		},
		{
			level: 17,
			extreme: 36,
			high: 33,
			moderate: 30,
			low: 28,
			terrible: 24
		},
		{
			level: 18,
			extreme: 38,
			high: 35,
			moderate: 31,
			low: 29,
			terrible: 25
		},
		{
			level: 19,
			extreme: 40,
			high: 37,
			moderate: 33,
			low: 31,
			terrible: 27
		},
		{
			level: 20,
			extreme: 41,
			high: 38,
			moderate: 34,
			low: 32,
			terrible: 28
		},
		{
			level: 21,
			extreme: 43,
			high: 40,
			moderate: 36,
			low: 34,
			terrible: 29
		},
		{
			level: 22,
			extreme: 45,
			high: 42,
			moderate: 37,
			low: 35,
			terrible: 31
		},
		{
			level: 23,
			extreme: 46,
			high: 43,
			moderate: 38,
			low: 36,
			terrible: 32
		},
		{
			level: 24,
			extreme: 48,
			high: 45,
			moderate: 40,
			low: 38,
			terrible: 33
		}
	],
	strikeAttack: [
		{
			level: -1,
			extreme: 10,
			high: 8,
			moderate: 6,
			low: 4
		},
		{
			level: 0,
			extreme: 10,
			high: 8,
			moderate: 6,
			low: 4
		},
		{
			level: 1,
			extreme: 11,
			high: 9,
			moderate: 7,
			low: 5
		},
		{
			level: 2,
			extreme: 13,
			high: 11,
			moderate: 9,
			low: 7
		},
		{
			level: 3,
			extreme: 14,
			high: 12,
			moderate: 10,
			low: 8
		},
		{
			level: 4,
			extreme: 16,
			high: 14,
			moderate: 12,
			low: 9
		},
		{
			level: 5,
			extreme: 17,
			high: 15,
			moderate: 13,
			low: 11
		},
		{
			level: 6,
			extreme: 19,
			high: 17,
			moderate: 15,
			low: 12
		},
		{
			level: 7,
			extreme: 20,
			high: 18,
			moderate: 16,
			low: 13
		},
		{
			level: 8,
			extreme: 22,
			high: 20,
			moderate: 18,
			low: 15
		},
		{
			level: 9,
			extreme: 23,
			high: 21,
			moderate: 19,
			low: 16
		},
		{
			level: 10,
			extreme: 25,
			high: 23,
			moderate: 21,
			low: 17
		},
		{
			level: 11,
			extreme: 27,
			high: 24,
			moderate: 22,
			low: 19
		},
		{
			level: 12,
			extreme: 28,
			high: 26,
			moderate: 24,
			low: 20
		},
		{
			level: 13,
			extreme: 29,
			high: 27,
			moderate: 25,
			low: 21
		},
		{
			level: 14,
			extreme: 31,
			high: 29,
			moderate: 27,
			low: 23
		},
		{
			level: 15,
			extreme: 32,
			high: 30,
			moderate: 28,
			low: 24
		},
		{
			level: 16,
			extreme: 34,
			high: 32,
			moderate: 30,
			low: 25
		},
		{
			level: 17,
			extreme: 35,
			high: 33,
			moderate: 31,
			low: 27
		},
		{
			level: 18,
			extreme: 37,
			high: 35,
			moderate: 33,
			low: 28
		},
		{
			level: 19,
			extreme: 38,
			high: 36,
			moderate: 34,
			low: 29
		},
		{
			level: 20,
			extreme: 40,
			high: 38,
			moderate: 36,
			low: 31
		},
		{
			level: 21,
			extreme: 41,
			high: 39,
			moderate: 37,
			low: 32
		},
		{
			level: 22,
			extreme: 43,
			high: 41,
			moderate: 39,
			low: 33
		},
		{
			level: 23,
			extreme: 44,
			high: 42,
			moderate: 40,
			low: 35
		},
		{
			level: 24,
			extreme: 46,
			high: 44,
			moderate: 42,
			low: 36
		}
	],
	strikeDamage: [
		{
			level: -1,
			extreme: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+1",
				average: 4.5,
				bonus: 1
			},
			high: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4+1",
				average: 3.5,
				bonus: 1
			},
			moderate: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4",
				average: 2.5,
				bonus: 0
			},
			low: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4",
				average: 2.5,
				bonus: 0
			}
		},
		{
			level: 0,
			extreme: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+3",
				average: 6.5,
				bonus: 3
			},
			high: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+2",
				average: 5.5,
				bonus: 2
			},
			moderate: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4+2",
				average: 4.5,
				bonus: 2
			},
			low: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4+1",
				average: 3.5,
				bonus: 1
			}
		},
		{
			level: 1,
			extreme: {
				diceCount: 1,
				diceSize: 8,
				original: "1d8+4",
				average: 8.5,
				bonus: 4
			},
			high: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+3",
				average: 6.5,
				bonus: 3
			},
			moderate: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+2",
				average: 5.5,
				bonus: 2
			},
			low: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4+2",
				average: 4.5,
				bonus: 2
			}
		},
		{
			level: 2,
			extreme: {
				diceCount: 1,
				diceSize: 12,
				original: "1d12+4",
				average: 10.5,
				bonus: 4
			},
			high: {
				diceCount: 1,
				diceSize: 10,
				original: "1d10+4",
				average: 9.5,
				bonus: 4
			},
			moderate: {
				diceCount: 1,
				diceSize: 8,
				original: "1d8+4",
				average: 8.5,
				bonus: 4
			},
			low: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+3",
				average: 6.5,
				bonus: 3
			}
		},
		{
			level: 3,
			extreme: {
				diceCount: 1,
				diceSize: 12,
				original: "1d12+8",
				average: 14.5,
				bonus: 8
			},
			high: {
				diceCount: 1,
				diceSize: 10,
				original: "1d10+6",
				average: 11.5,
				bonus: 6
			},
			moderate: {
				diceCount: 1,
				diceSize: 8,
				original: "1d8+6",
				average: 10.5,
				bonus: 6
			},
			low: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6+5",
				average: 8.5,
				bonus: 5
			}
		},
		{
			level: 4,
			extreme: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+7",
				average: 18,
				bonus: 7
			},
			high: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+5",
				average: 14,
				bonus: 5
			},
			moderate: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+5",
				average: 12,
				bonus: 5
			},
			low: {
				diceCount: 2,
				diceSize: 4,
				original: "2d4+4",
				average: 9,
				bonus: 4
			}
		},
		{
			level: 5,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+7",
				average: 20,
				bonus: 7
			},
			high: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+7",
				average: 16,
				bonus: 7
			},
			moderate: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+6",
				average: 13,
				bonus: 6
			},
			low: {
				diceCount: 2,
				diceSize: 4,
				original: "2d4+6",
				average: 11,
				bonus: 6
			}
		},
		{
			level: 6,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+10",
				average: 23,
				bonus: 10
			},
			high: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+9",
				average: 18,
				bonus: 9
			},
			moderate: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+8",
				average: 15,
				bonus: 8
			},
			low: {
				diceCount: 2,
				diceSize: 4,
				original: "2d4+7",
				average: 12,
				bonus: 7
			}
		},
		{
			level: 7,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+12",
				average: 25,
				bonus: 12
			},
			high: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+9",
				average: 20,
				bonus: 9
			},
			moderate: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+8",
				average: 17,
				bonus: 8
			},
			low: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+6",
				average: 13,
				bonus: 6
			}
		},
		{
			level: 8,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+15",
				average: 28,
				bonus: 15
			},
			high: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+11",
				average: 22,
				bonus: 11
			},
			moderate: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+9",
				average: 18,
				bonus: 9
			},
			low: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+8",
				average: 15,
				bonus: 8
			}
		},
		{
			level: 9,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+17",
				average: 30,
				bonus: 17
			},
			high: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+13",
				average: 24,
				bonus: 13
			},
			moderate: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+11",
				average: 20,
				bonus: 11
			},
			low: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+9",
				average: 16,
				bonus: 9
			}
		},
		{
			level: 10,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+20",
				average: 33,
				bonus: 20
			},
			high: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+13",
				average: 26,
				bonus: 13
			},
			moderate: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+11",
				average: 22,
				bonus: 11
			},
			low: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6+10",
				average: 17,
				bonus: 10
			}
		},
		{
			level: 11,
			extreme: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+22",
				average: 35,
				bonus: 22
			},
			high: {
				diceCount: 2,
				diceSize: 12,
				original: "2d12+15",
				average: 28,
				bonus: 15
			},
			moderate: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10+12",
				average: 23,
				bonus: 12
			},
			low: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8+10",
				average: 19,
				bonus: 10
			}
		},
		{
			level: 12,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+19",
				average: 38.5,
				bonus: 19
			},
			high: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+14",
				average: 30.5,
				bonus: 14
			},
			moderate: {
				diceCount: 3,
				diceSize: 8,
				original: "3d8+12",
				average: 25.5,
				bonus: 12
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+10",
				average: 20.5,
				bonus: 10
			}
		},
		{
			level: 13,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+21",
				average: 40.5,
				bonus: 21
			},
			high: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+16",
				average: 32.5,
				bonus: 16
			},
			moderate: {
				diceCount: 3,
				diceSize: 8,
				original: "3d8+14",
				average: 27.5,
				bonus: 14
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+11",
				average: 21.5,
				bonus: 11
			}
		},
		{
			level: 14,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+24",
				average: 43.5,
				bonus: 24
			},
			high: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+18",
				average: 34.5,
				bonus: 18
			},
			moderate: {
				diceCount: 3,
				diceSize: 8,
				original: "3d8+15",
				average: 28.5,
				bonus: 15
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+13",
				average: 23.5,
				bonus: 13
			}
		},
		{
			level: 15,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+26",
				average: 45.5,
				bonus: 26
			},
			high: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+17",
				average: 36.5,
				bonus: 17
			},
			moderate: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+14",
				average: 30.5,
				bonus: 14
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+14",
				average: 24.5,
				bonus: 14
			}
		},
		{
			level: 16,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+29",
				average: 48.5,
				bonus: 29
			},
			high: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+18",
				average: 37.5,
				bonus: 18
			},
			moderate: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+15",
				average: 31.5,
				bonus: 15
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+15",
				average: 25.5,
				bonus: 15
			}
		},
		{
			level: 17,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+31",
				average: 50.5,
				bonus: 31
			},
			high: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+19",
				average: 38.5,
				bonus: 19
			},
			moderate: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+16",
				average: 32.5,
				bonus: 16
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+16",
				average: 26.5,
				bonus: 16
			}
		},
		{
			level: 18,
			extreme: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+34",
				average: 53.5,
				bonus: 34
			},
			high: {
				diceCount: 3,
				diceSize: 12,
				original: "3d12+20",
				average: 39.5,
				bonus: 20
			},
			moderate: {
				diceCount: 3,
				diceSize: 10,
				original: "3d10+17",
				average: 33.5,
				bonus: 17
			},
			low: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6+17",
				average: 27.5,
				bonus: 17
			}
		},
		{
			level: 19,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+29",
				average: 55,
				bonus: 29
			},
			high: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+20",
				average: 42,
				bonus: 20
			},
			moderate: {
				diceCount: 4,
				diceSize: 8,
				original: "4d8+17",
				average: 35,
				bonus: 17
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+14",
				average: 28,
				bonus: 14
			}
		},
		{
			level: 20,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+32",
				average: 58,
				bonus: 32
			},
			high: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+22",
				average: 44,
				bonus: 22
			},
			moderate: {
				diceCount: 4,
				diceSize: 8,
				original: "4d8+19",
				average: 37,
				bonus: 19
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+15",
				average: 29,
				bonus: 15
			}
		},
		{
			level: 21,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+34",
				average: 60,
				bonus: 34
			},
			high: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+24",
				average: 46,
				bonus: 24
			},
			moderate: {
				diceCount: 4,
				diceSize: 8,
				original: "4d8+20",
				average: 38,
				bonus: 20
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+17",
				average: 31,
				bonus: 17
			}
		},
		{
			level: 22,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+37",
				average: 63,
				bonus: 37
			},
			high: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+26",
				average: 48,
				bonus: 26
			},
			moderate: {
				diceCount: 4,
				diceSize: 8,
				original: "4d8+22",
				average: 40,
				bonus: 22
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+18",
				average: 32,
				bonus: 18
			}
		},
		{
			level: 23,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+39",
				average: 65,
				bonus: 39
			},
			high: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+24",
				average: 50,
				bonus: 24
			},
			moderate: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+20",
				average: 42,
				bonus: 20
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+19",
				average: 33,
				bonus: 19
			}
		},
		{
			level: 24,
			extreme: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+42",
				average: 68,
				bonus: 42
			},
			high: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12+26",
				average: 52,
				bonus: 26
			},
			moderate: {
				diceCount: 4,
				diceSize: 10,
				original: "4d10+22",
				average: 44,
				bonus: 22
			},
			low: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6+21",
				average: 35,
				bonus: 21
			}
		}
	],
	areaDamage: [
		{
			limited: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6",
				average: 3.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 1,
				diceSize: 4,
				original: "1d4",
				average: 2.5,
				bonus: 0
			},
			level: -1
		},
		{
			limited: {
				diceCount: 1,
				diceSize: 10,
				original: "1d10",
				average: 5.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 1,
				diceSize: 6,
				original: "1d6",
				average: 3.5,
				bonus: 0
			},
			level: 0
		},
		{
			limited: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6",
				average: 7,
				bonus: 0
			},
			unlimited: {
				diceCount: 2,
				diceSize: 4,
				original: "2d4",
				average: 5,
				bonus: 0
			},
			level: 1
		},
		{
			limited: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6",
				average: 10.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 2,
				diceSize: 6,
				original: "2d6",
				average: 7,
				bonus: 0
			},
			level: 2
		},
		{
			limited: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6",
				average: 14,
				bonus: 0
			},
			unlimited: {
				diceCount: 2,
				diceSize: 8,
				original: "2d8",
				average: 9,
				bonus: 0
			},
			level: 3
		},
		{
			limited: {
				diceCount: 5,
				diceSize: 6,
				original: "5d6",
				average: 17.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 3,
				diceSize: 6,
				original: "3d6",
				average: 10.5,
				bonus: 0
			},
			level: 4
		},
		{
			limited: {
				diceCount: 6,
				diceSize: 6,
				original: "6d6",
				average: 21,
				bonus: 0
			},
			unlimited: {
				diceCount: 2,
				diceSize: 10,
				original: "2d10",
				average: 11,
				bonus: 0
			},
			level: 5
		},
		{
			limited: {
				diceCount: 7,
				diceSize: 6,
				original: "7d6",
				average: 24.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6",
				average: 14,
				bonus: 0
			},
			level: 6
		},
		{
			limited: {
				diceCount: 8,
				diceSize: 6,
				original: "8d6",
				average: 28,
				bonus: 0
			},
			unlimited: {
				diceCount: 4,
				diceSize: 6,
				original: "4d6",
				average: 14,
				bonus: 0
			},
			level: 7
		},
		{
			limited: {
				diceCount: 9,
				diceSize: 6,
				original: "9d6",
				average: 31.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 5,
				diceSize: 6,
				original: "5d6",
				average: 17.5,
				bonus: 0
			},
			level: 8
		},
		{
			limited: {
				diceCount: 10,
				diceSize: 6,
				original: "10d6",
				average: 35,
				bonus: 0
			},
			unlimited: {
				diceCount: 5,
				diceSize: 6,
				original: "5d6",
				average: 17.5,
				bonus: 0
			},
			level: 9
		},
		{
			limited: {
				diceCount: 11,
				diceSize: 6,
				original: "11d6",
				average: 38.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 6,
				diceSize: 6,
				original: "6d6",
				average: 21,
				bonus: 0
			},
			level: 10
		},
		{
			limited: {
				diceCount: 12,
				diceSize: 6,
				original: "12d6",
				average: 42,
				bonus: 0
			},
			unlimited: {
				diceCount: 6,
				diceSize: 6,
				original: "6d6",
				average: 21,
				bonus: 0
			},
			level: 11
		},
		{
			limited: {
				diceCount: 13,
				diceSize: 6,
				original: "13d6",
				average: 45.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 5,
				diceSize: 8,
				original: "5d8",
				average: 22.5,
				bonus: 0
			},
			level: 12
		},
		{
			limited: {
				diceCount: 14,
				diceSize: 6,
				original: "14d6",
				average: 49,
				bonus: 0
			},
			unlimited: {
				diceCount: 7,
				diceSize: 6,
				original: "7d6",
				average: 24.5,
				bonus: 0
			},
			level: 13
		},
		{
			limited: {
				diceCount: 15,
				diceSize: 6,
				original: "15d6",
				average: 52.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 4,
				diceSize: 12,
				original: "4d12",
				average: 26,
				bonus: 0
			},
			level: 14
		},
		{
			limited: {
				diceCount: 16,
				diceSize: 6,
				original: "16d6",
				average: 56,
				bonus: 0
			},
			unlimited: {
				diceCount: 8,
				diceSize: 6,
				original: "8d6",
				average: 28,
				bonus: 0
			},
			level: 15
		},
		{
			limited: {
				diceCount: 17,
				diceSize: 6,
				original: "17d6",
				average: 59.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 8,
				diceSize: 6,
				original: "8d6",
				average: 28,
				bonus: 0
			},
			level: 16
		},
		{
			limited: {
				diceCount: 18,
				diceSize: 6,
				original: "18d6",
				average: 63,
				bonus: 0
			},
			unlimited: {
				diceCount: 8,
				diceSize: 6,
				original: "8d6",
				average: 28,
				bonus: 0
			},
			level: 17
		},
		{
			limited: {
				diceCount: 19,
				diceSize: 6,
				original: "19d6",
				average: 66.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 9,
				diceSize: 6,
				original: "9d6",
				average: 31.5,
				bonus: 0
			},
			level: 18
		},
		{
			limited: {
				diceCount: 20,
				diceSize: 6,
				original: "20d6",
				average: 70,
				bonus: 0
			},
			unlimited: {
				diceCount: 9,
				diceSize: 6,
				original: "9d6",
				average: 31.5,
				bonus: 0
			},
			level: 19
		},
		{
			limited: {
				diceCount: 21,
				diceSize: 6,
				original: "21d6",
				average: 73.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 6,
				diceSize: 10,
				original: "6d10",
				average: 33,
				bonus: 0
			},
			level: 20
		},
		{
			limited: {
				diceCount: 22,
				diceSize: 6,
				original: "22d6",
				average: 77,
				bonus: 0
			},
			unlimited: {
				diceCount: 10,
				diceSize: 6,
				original: "10d6",
				average: 35,
				bonus: 0
			},
			level: 21
		},
		{
			limited: {
				diceCount: 23,
				diceSize: 6,
				original: "23d6",
				average: 80.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 8,
				diceSize: 8,
				original: "8d8",
				average: 36,
				bonus: 0
			},
			level: 22
		},
		{
			limited: {
				diceCount: 24,
				diceSize: 6,
				original: "24d6",
				average: 84,
				bonus: 0
			},
			unlimited: {
				diceCount: 11,
				diceSize: 6,
				original: "11d6",
				average: 38.5,
				bonus: 0
			},
			level: 23
		},
		{
			limited: {
				diceCount: 25,
				diceSize: 6,
				original: "25d6",
				average: 87.5,
				bonus: 0
			},
			unlimited: {
				diceCount: 11,
				diceSize: 6,
				original: "11d6",
				average: 38.5,
				bonus: 0
			},
			level: 24
		}
	],
	difficultyClass: [
		{
			level: -1,
			extreme: 19,
			high: 16,
			moderate: 13
		},
		{
			level: 0,
			extreme: 19,
			high: 16,
			moderate: 13
		},
		{
			level: 1,
			extreme: 20,
			high: 17,
			moderate: 14
		},
		{
			level: 2,
			extreme: 22,
			high: 18,
			moderate: 15
		},
		{
			level: 3,
			extreme: 23,
			high: 20,
			moderate: 17
		},
		{
			level: 4,
			extreme: 25,
			high: 21,
			moderate: 18
		},
		{
			level: 5,
			extreme: 26,
			high: 22,
			moderate: 19
		},
		{
			level: 6,
			extreme: 27,
			high: 24,
			moderate: 21
		},
		{
			level: 7,
			extreme: 29,
			high: 25,
			moderate: 22
		},
		{
			level: 8,
			extreme: 30,
			high: 26,
			moderate: 23
		},
		{
			level: 9,
			extreme: 32,
			high: 28,
			moderate: 25
		},
		{
			level: 10,
			extreme: 33,
			high: 29,
			moderate: 26
		},
		{
			level: 11,
			extreme: 34,
			high: 30,
			moderate: 27
		},
		{
			level: 12,
			extreme: 36,
			high: 32,
			moderate: 29
		},
		{
			level: 13,
			extreme: 37,
			high: 33,
			moderate: 30
		},
		{
			level: 14,
			extreme: 39,
			high: 34,
			moderate: 31
		},
		{
			level: 15,
			extreme: 40,
			high: 36,
			moderate: 33
		},
		{
			level: 16,
			extreme: 41,
			high: 37,
			moderate: 34
		},
		{
			level: 17,
			extreme: 43,
			high: 38,
			moderate: 35
		},
		{
			level: 18,
			extreme: 44,
			high: 40,
			moderate: 37
		},
		{
			level: 19,
			extreme: 46,
			high: 41,
			moderate: 38
		},
		{
			level: 20,
			extreme: 47,
			high: 42,
			moderate: 39
		},
		{
			level: 21,
			extreme: 48,
			high: 44,
			moderate: 41
		},
		{
			level: 22,
			extreme: 50,
			high: 45,
			moderate: 42
		},
		{
			level: 23,
			extreme: 51,
			high: 46,
			moderate: 43
		},
		{
			level: 24,
			extreme: 52,
			high: 48,
			moderate: 45
		}
	],
	spell: [
		{
			level: -1,
			extreme: 11,
			high: 8,
			moderate: 5
		},
		{
			level: 0,
			extreme: 11,
			high: 8,
			moderate: 5
		},
		{
			level: 1,
			extreme: 12,
			high: 9,
			moderate: 6
		},
		{
			level: 2,
			extreme: 14,
			high: 10,
			moderate: 7
		},
		{
			level: 3,
			extreme: 15,
			high: 12,
			moderate: 9
		},
		{
			level: 4,
			extreme: 17,
			high: 13,
			moderate: 10
		},
		{
			level: 5,
			extreme: 18,
			high: 14,
			moderate: 11
		},
		{
			level: 6,
			extreme: 19,
			high: 16,
			moderate: 13
		},
		{
			level: 7,
			extreme: 21,
			high: 17,
			moderate: 14
		},
		{
			level: 8,
			extreme: 22,
			high: 18,
			moderate: 15
		},
		{
			level: 9,
			extreme: 24,
			high: 20,
			moderate: 17
		},
		{
			level: 10,
			extreme: 25,
			high: 21,
			moderate: 18
		},
		{
			level: 11,
			extreme: 26,
			high: 22,
			moderate: 19
		},
		{
			level: 12,
			extreme: 28,
			high: 24,
			moderate: 21
		},
		{
			level: 13,
			extreme: 29,
			high: 25,
			moderate: 22
		},
		{
			level: 14,
			extreme: 31,
			high: 26,
			moderate: 23
		},
		{
			level: 15,
			extreme: 32,
			high: 28,
			moderate: 25
		},
		{
			level: 16,
			extreme: 33,
			high: 29,
			moderate: 26
		},
		{
			level: 17,
			extreme: 35,
			high: 30,
			moderate: 27
		},
		{
			level: 18,
			extreme: 36,
			high: 32,
			moderate: 29
		},
		{
			level: 19,
			extreme: 38,
			high: 33,
			moderate: 30
		},
		{
			level: 20,
			extreme: 39,
			high: 34,
			moderate: 31
		},
		{
			level: 21,
			extreme: 40,
			high: 36,
			moderate: 33
		},
		{
			level: 22,
			extreme: 42,
			high: 37,
			moderate: 34
		},
		{
			level: 23,
			extreme: 43,
			high: 38,
			moderate: 35
		},
		{
			level: 24,
			extreme: 44,
			high: 40,
			moderate: 37
		}
	],
	resistance: [
		{
			level: -1,
			maximum: 1,
			minimum: 1
		},
		{
			level: 0,
			maximum: 3,
			minimum: 1
		},
		{
			level: 1,
			maximum: 3,
			minimum: 2
		},
		{
			level: 2,
			maximum: 5,
			minimum: 2
		},
		{
			level: 3,
			maximum: 6,
			minimum: 3
		},
		{
			level: 4,
			maximum: 7,
			minimum: 4
		},
		{
			level: 5,
			maximum: 8,
			minimum: 4
		},
		{
			level: 6,
			maximum: 9,
			minimum: 5
		},
		{
			level: 7,
			maximum: 10,
			minimum: 5
		},
		{
			level: 8,
			maximum: 11,
			minimum: 6
		},
		{
			level: 9,
			maximum: 12,
			minimum: 6
		},
		{
			level: 10,
			maximum: 13,
			minimum: 7
		},
		{
			level: 11,
			maximum: 14,
			minimum: 7
		},
		{
			level: 12,
			maximum: 15,
			minimum: 8
		},
		{
			level: 13,
			maximum: 16,
			minimum: 8
		},
		{
			level: 14,
			maximum: 17,
			minimum: 9
		},
		{
			level: 15,
			maximum: 18,
			minimum: 9
		},
		{
			level: 16,
			maximum: 19,
			minimum: 9
		},
		{
			level: 17,
			maximum: 19,
			minimum: 10
		},
		{
			level: 18,
			maximum: 20,
			minimum: 10
		},
		{
			level: 19,
			maximum: 21,
			minimum: 11
		},
		{
			level: 20,
			maximum: 22,
			minimum: 11
		},
		{
			level: 21,
			maximum: 23,
			minimum: 12
		},
		{
			level: 22,
			maximum: 24,
			minimum: 12
		},
		{
			level: 23,
			maximum: 25,
			minimum: 13
		},
		{
			level: 24,
			maximum: 26,
			minimum: 13
		}
	],
	weakness: [
		{
			level: -1,
			maximum: 1,
			minimum: 1
		},
		{
			level: 0,
			maximum: 3,
			minimum: 1
		},
		{
			level: 1,
			maximum: 3,
			minimum: 2
		},
		{
			level: 2,
			maximum: 5,
			minimum: 2
		},
		{
			level: 3,
			maximum: 6,
			minimum: 3
		},
		{
			level: 4,
			maximum: 7,
			minimum: 4
		},
		{
			level: 5,
			maximum: 8,
			minimum: 4
		},
		{
			level: 6,
			maximum: 9,
			minimum: 5
		},
		{
			level: 7,
			maximum: 10,
			minimum: 5
		},
		{
			level: 8,
			maximum: 11,
			minimum: 6
		},
		{
			level: 9,
			maximum: 12,
			minimum: 6
		},
		{
			level: 10,
			maximum: 13,
			minimum: 7
		},
		{
			level: 11,
			maximum: 14,
			minimum: 7
		},
		{
			level: 12,
			maximum: 15,
			minimum: 8
		},
		{
			level: 13,
			maximum: 16,
			minimum: 8
		},
		{
			level: 14,
			maximum: 17,
			minimum: 9
		},
		{
			level: 15,
			maximum: 18,
			minimum: 9
		},
		{
			level: 16,
			maximum: 19,
			minimum: 9
		},
		{
			level: 17,
			maximum: 19,
			minimum: 10
		},
		{
			level: 18,
			maximum: 20,
			minimum: 10
		},
		{
			level: 19,
			maximum: 21,
			minimum: 11
		},
		{
			level: 20,
			maximum: 22,
			minimum: 11
		},
		{
			level: 21,
			maximum: 23,
			minimum: 12
		},
		{
			level: 22,
			maximum: 24,
			minimum: 12
		},
		{
			level: 23,
			maximum: 25,
			minimum: 13
		},
		{
			level: 24,
			maximum: 26,
			minimum: 13
		}
	],
	hazarddefense: [
		{
			level: -1,
			eac: 18,
			hac: 15,
			lac: 12,
			esave: 9,
			hsave: 8,
			lsave: 2,
			hardness: "2-4",
			hpmin: 11
		},
		{
			level: 0,
			eac: 19,
			hac: 16,
			lac: 13,
			esave: 10,
			hsave: 9,
			lsave: 3,
			hardness: "3-5",
			hitPoints: "15-17"
		},
		{
			level: 1,
			eac: 19,
			hac: 16,
			lac: 13,
			esave: 11,
			hsave: 10,
			lsave: 4,
			hardness: "5-7",
			hitPoints: "23-25"
		},
		{
			level: 2,
			eac: 21,
			hac: 18,
			lac: 15,
			esave: 12,
			hsave: 11,
			lsave: 5,
			hardness: "7-9",
			hitPoints: "30-34"
		},
		{
			level: 3,
			eac: 22,
			hac: 19,
			lac: 16,
			esave: 14,
			hsave: 12,
			lsave: 6,
			hardness: "10-12",
			hitPoints: "42-46"
		},
		{
			level: 4,
			eac: 24,
			hac: 21,
			lac: 18,
			esave: 15,
			hsave: 14,
			lsave: 8,
			hardness: "11-13",
			hitPoints: "46-50"
		},
		{
			level: 5,
			eac: 25,
			hac: 22,
			lac: 19,
			esave: 17,
			hsave: 15,
			lsave: 9,
			hardness: "12-14",
			hitPoints: "50-54"
		},
		{
			level: 6,
			eac: 27,
			hac: 24,
			lac: 21,
			esave: 18,
			hsave: 17,
			lsave: 11,
			hardness: "13-15",
			hitPoints: "54-58"
		},
		{
			level: 7,
			eac: 28,
			hac: 25,
			lac: 22,
			esave: 20,
			hsave: 18,
			lsave: 12,
			hardness: "14-16",
			hitPoints: "58-62"
		},
		{
			level: 8,
			eac: 30,
			hac: 27,
			lac: 24,
			esave: 21,
			hsave: 19,
			lsave: 13,
			hardness: "15-17",
			hitPoints: "62-66"
		},
		{
			level: 9,
			eac: 31,
			hac: 28,
			lac: 25,
			esave: 23,
			hsave: 21,
			lsave: 15,
			hardness: "16-18",
			hitPoints: "66-70"
		},
		{
			level: 10,
			eac: 33,
			hac: 30,
			lac: 27,
			esave: 24,
			hsave: 22,
			lsave: 16,
			hardness: "17-19",
			hitPoints: "70-74"
		},
		{
			level: 11,
			eac: 34,
			hac: 31,
			lac: 28,
			esave: 26,
			hsave: 24,
			lsave: 18,
			hardness: "19-21",
			hitPoints: "78-82"
		},
		{
			level: 12,
			eac: 36,
			hac: 33,
			lac: 30,
			esave: 27,
			hsave: 25,
			lsave: 19,
			hardness: "20-22",
			hitPoints: "82-86"
		},
		{
			level: 13,
			eac: 37,
			hac: 34,
			lac: 31,
			esave: 29,
			hsave: 26,
			lsave: 20,
			hardness: "21-23",
			hitPoints: "86-90"
		},
		{
			level: 14,
			eac: 39,
			hac: 36,
			lac: 33,
			esave: 30,
			hsave: 28,
			lsave: 22,
			hardness: "22-24",
			hitPoints: "90-94"
		},
		{
			level: 15,
			eac: 40,
			hac: 37,
			lac: 34,
			esave: 32,
			hsave: 29,
			lsave: 23,
			hardness: "23-25",
			hitPoints: "94-98"
		},
		{
			level: 16,
			eac: 42,
			hac: 39,
			lac: 36,
			esave: 33,
			hsave: 30,
			lsave: 25,
			hardness: "25-27",
			hitPoints: "101-107"
		},
		{
			level: 17,
			eac: 43,
			hac: 40,
			lac: 37,
			esave: 35,
			hsave: 32,
			lsave: 26,
			hardness: "27-29",
			hitPoints: "109-115"
		},
		{
			level: 18,
			eac: 45,
			hac: 42,
			lac: 39,
			esave: 36,
			hsave: 33,
			lsave: 27,
			hardness: "29-31",
			hitPoints: "117-123"
		},
		{
			level: 19,
			eac: 46,
			hac: 43,
			lac: 40,
			esave: 38,
			hsave: 35,
			lsave: 29,
			hardness: "31-33",
			hitPoints: "125-131"
		},
		{
			level: 20,
			eac: 48,
			hac: 45,
			lac: 42,
			esave: 39,
			hsave: 36,
			lsave: 30,
			hardness: "33-35",
			hitPoints: "133-139"
		},
		{
			level: 21,
			eac: 49,
			hac: 46,
			lac: 43,
			esave: 41,
			hsave: 38,
			lsave: 32,
			hardness: "36-38",
			hitPoints: "144-152"
		},
		{
			level: 22,
			eac: 51,
			hac: 48,
			lac: 45,
			esave: 43,
			hsave: 39,
			lsave: 33,
			hardness: "39-41",
			hitPoints: "156-164"
		},
		{
			level: 23,
			eac: 52,
			hac: 49,
			lac: 46,
			esave: 44,
			hsave: 40,
			lsave: 34,
			hardness: "44-46",
			hitPoints: "168-176"
		},
		{
			level: 24,
			eac: 54,
			hac: 51,
			lac: 48,
			esave: 46,
			hsave: 42,
			lsave: 36,
			hardness: "46-50",
			hitPoints: "180-188"
		}
	],
	hazardoffense: [
		{
			level: -1,
			satk: 10,
			catk: 8,
			simpledmg: "2d4+1",
			complexdmg: "1d4+1",
			edc: 19,
			hdc: 16
		},
		{
			level: 0,
			satk: 11,
			catk: 8,
			simpledmg: "2d6+3",
			complexdmg: "1d6+2",
			edc: 19,
			hdc: 16
		},
		{
			level: 1,
			satk: 13,
			catk: 9,
			simpledmg: "2d6+5",
			complexdmg: "1d6+3",
			edc: 20,
			hdc: 17
		},
		{
			level: 2,
			satk: 14,
			catk: 11,
			simpledmg: "2d10+7",
			complexdmg: "1d10+4",
			edc: 22,
			hdc: 18
		},
		{
			level: 3,
			satk: 16,
			catk: 12,
			simpledmg: "2d10+13",
			complexdmg: "1d10+6",
			edc: 23,
			hdc: 20
		},
		{
			level: 4,
			satk: 17,
			catk: 14,
			simpledmg: "4d8+10",
			complexdmg: "2d8+5",
			edc: 25,
			hdc: 21
		},
		{
			level: 5,
			satk: 19,
			catk: 15,
			simpledmg: "4d8+14",
			complexdmg: "2d8+7",
			edc: 26,
			hdc: 22
		},
		{
			level: 6,
			satk: 20,
			catk: 17,
			simpledmg: "4d8+18",
			complexdmg: "2d8+9",
			edc: 27,
			hdc: 24
		},
		{
			level: 7,
			satk: 22,
			catk: 18,
			simpledmg: "4d10+18",
			complexdmg: "2d10+9",
			edc: 29,
			hdc: 25
		},
		{
			level: 8,
			satk: 23,
			catk: 20,
			simpledmg: "4d10+22",
			complexdmg: "2d10+11",
			edc: 30,
			hdc: 26
		},
		{
			level: 9,
			satk: 25,
			catk: 21,
			simpledmg: "4d10+26",
			complexdmg: "2d10+13",
			edc: 32,
			hdc: 28
		},
		{
			level: 10,
			satk: 26,
			catk: 23,
			simpledmg: "4d12+26",
			complexdmg: "2d12+13",
			edc: 33,
			hdc: 29
		},
		{
			level: 11,
			satk: 28,
			catk: 24,
			simpledmg: "4d12+30",
			complexdmg: "2d12+15",
			edc: 34,
			hdc: 30
		},
		{
			level: 12,
			satk: 29,
			catk: 26,
			simpledmg: "6d10+27",
			complexdmg: "3d10+14",
			edc: 36,
			hdc: 32
		},
		{
			level: 13,
			satk: 31,
			catk: 27,
			simpledmg: "6d10+31",
			complexdmg: "3d10+16",
			edc: 37,
			hdc: 33
		},
		{
			level: 14,
			satk: 32,
			catk: 29,
			simpledmg: "6d10+35",
			complexdmg: "3d10+18",
			edc: 39,
			hdc: 34
		},
		{
			level: 15,
			satk: 34,
			catk: 30,
			simpledmg: "6d12+33",
			complexdmg: "3d12+17",
			edc: 40,
			hdc: 36
		},
		{
			level: 16,
			satk: 35,
			catk: 32,
			simpledmg: "6d12+35",
			complexdmg: "3d12+18",
			edc: 41,
			hdc: 37
		},
		{
			level: 17,
			satk: 37,
			catk: 33,
			simpledmg: "6d12+37",
			complexdmg: "3d12+19",
			edc: 43,
			hdc: 38
		},
		{
			level: 18,
			satk: 38,
			catk: 35,
			simpledmg: "6d12+41",
			complexdmg: "3d12+20",
			edc: 44,
			hdc: 40
		},
		{
			level: 19,
			satk: 40,
			catk: 36,
			simpledmg: "8d10+40",
			complexdmg: "4d10+20",
			edc: 46,
			hdc: 41
		},
		{
			level: 20,
			satk: 41,
			catk: 38,
			simpledmg: "8d10+44",
			complexdmg: "4d10+22",
			edc: 47,
			hdc: 42
		},
		{
			level: 21,
			satk: 43,
			catk: 39,
			simpledmg: "8d10+48",
			complexdmg: "4d10+24",
			edc: 48,
			hdc: 44
		},
		{
			level: 22,
			satk: 44,
			catk: 41,
			simpledmg: "8d10+52",
			complexdmg: "4d10+26",
			edc: 50,
			hdc: 45
		},
		{
			level: 23,
			satk: 46,
			catk: 42,
			simpledmg: "8d12+48",
			complexdmg: "4d12+24",
			edc: 51,
			hdc: 46
		},
		{
			level: 24,
			satk: 47,
			catk: 44,
			simpledmg: "8d12+52",
			complexdmg: "4d12+26",
			edc: 52,
			hdc: 48
		}
	],
	level: [
		-1,
		0,
		1,
		2,
		3,
		4,
		5,
		6,
		7,
		8,
		9,
		10,
		11,
		12,
		13,
		14,
		15,
		16,
		17,
		18,
		19,
		20,
		21,
		22,
		23,
		24
	]
};
//#endregion
//#region src/module/feature/npc-roller/NpcRoller.ts
async function Lt() {
	await foundry.applications.handlebars.loadTemplates([
		`modules/${e}/templates/feature/npc-roller/index.hbs`,
		`modules/${e}/templates/feature/npc-roller/table.hbs`,
		`modules/${e}/templates/feature/npc-roller/cell.hbs`
	]), Handlebars.registerPartial("rollAppTable", `{{> "modules/${e}/templates/feature/npc-roller/table.hbs"}}`), Handlebars.registerPartial("rollAppCell", `{{> "modules/${e}/templates/feature/npc-roller/cell.hbs"}}`);
}
function Rt(t, n) {
	let r = document.createElement("button");
	r.innerHTML = `<i class="fa fa-dice"></i> ${game.i18n.localize(`${e}.npcRoller.button-label`)}`, r.addEventListener("click", () => {
		new zt().render({ force: !0 });
	});
	let i = n.querySelector(".directory-footer.action-buttons");
	i ? i.appendChild(r) : g("enableNpcRollerButton: Footer element not found.");
}
var zt = class extends foundry.applications.api.HandlebarsApplicationMixin(foundry.applications.api.ApplicationV2) {
	static DEFAULT_OPTIONS = {
		id: "xdy-pf2e-workbench-npc-roller",
		window: { resizable: !0 },
		position: {
			width: 800,
			height: "auto"
		}
	};
	static TABS = { primary: {
		tabs: [
			{ id: "roll-app-strike" },
			{ id: "roll-app-damage" },
			{ id: "roll-app-ac" },
			{ id: "roll-app-save" },
			{ id: "roll-app-hp" },
			{ id: "roll-app-spell" },
			{ id: "roll-app-dc" },
			{ id: "roll-app-areaDamage" },
			{ id: "roll-app-perception" },
			{ id: "roll-app-skill" },
			{ id: "roll-app-abilityScore" }
		],
		initial: "roll-app-strike"
	} };
	constructor(e) {
		super(e);
	}
	static get PARTS() {
		return { index: { template: `modules/${e}/templates/feature/npc-roller/index.hbs` } };
	}
	get title() {
		return game.i18n.localize(`${e}.npcRoller.title`);
	}
	static onControlToken() {
		let e = Object.values(ui.windows).find((e) => e.id === "xdy-pf2e-workbench-npc-roller");
		e && e.render({ force: !0 });
	}
	async _prepareContext(e) {
		let t = await super._prepareContext(e);
		return foundry.utils.mergeObject(t, { data: {
			levels: foundry.utils.deepClone(F),
			selected: canvas.tokens?.controlled.map((e) => e.actor?.system.details.level.value)
		} });
	}
	async _preparePartContext(e, t, n) {
		return t = await super._preparePartContext(e, t, n), e === "index" && (t.tabs = this._prepareTabs("primary")), t;
	}
	_onRender(e, t) {
		let n = Array.from(this.element.querySelectorAll("[role='tab'][data-tab]")), r = Array.from(this.element.querySelectorAll(".tab[data-tab]:not([role='tab'])"));
		n.forEach((e) => {
			e.addEventListener("click", () => {
				let t = e.dataset.tab, i = e.dataset.group ?? "primary";
				this.tabGroups[i] = t, n.filter((e) => e.dataset.group === i).forEach((e) => e.classList.toggle("active", e.dataset.tab === t)), r.filter((e) => e.dataset.group === i).forEach((e) => e.classList.toggle("active", e.dataset.tab === t));
			});
		}), this.element.querySelectorAll("button.rollable").forEach((e) => e.addEventListener("click", (e) => this.#e(e)));
	}
	async #e(e) {
		let t = e.currentTarget, n = t.dataset.rollname, r = canvas.tokens?.controlled[0], i = t.dataset.formula, a = foundry.helpers.interaction.KeyboardManager, o = game.keyboard.isModifierActive(a.MODIFIER_KEYS.CONTROL);
		if (i) {
			let e, t = i.toString();
			if (n.toLowerCase().includes("damage")) {
				if (e = CONFIG.Dice.rolls.find((e) => e.name === "DamageRoll"), !e) throw Error("DamageRoll doesn't exist‽");
			} else e = Roll;
			await new e(t).toMessage({
				speaker: ChatMessage.getSpeaker({ token: r?.document }),
				flavor: n,
				whisper: ChatMessage.getWhisperRecipients("GM").map((e) => e.id)
			}, {
				rollMode: o ? CONST.DICE_ROLL_MODES.PRIVATE : game.settings.get("core", "messageMode"),
				create: !0
			});
		}
	}
};
//#endregion
//#region src/module/feature/cr-scaler/Utilities.ts
function Bt(e) {
	return game.folders?.getName(e);
}
function Vt(e, t) {
	let n;
	return t ? (n = game.folders?.getName(t), n.getSubfolders().find((t) => t.name === e)) : Bt(e);
}
function Ht(e, t) {
	return game.actors?.find((n) => n.name === e && n.folder?.name === t);
}
//#endregion
//#region src/module/feature/cr-scaler/NPCScalerUtil.ts
function Ut(e) {
	let [t, n] = e.split("+"), r = 0;
	n !== void 0 && (r = parseInt(n));
	let [i, a] = t.split("d"), o = {
		diceCount: parseInt(i),
		diceSize: parseInt(a),
		original: e,
		average: 0,
		bonus: r
	};
	return o.average = (o.diceSize + 1) / 2 * o.diceCount + o.bonus, o;
}
function Wt({ diceCount: e, diceSize: t, bonus: n }) {
	let r = `${e}d${t}`;
	return n > 0 && (r = `${r}+${n}`), r;
}
function I(e, t, n, r) {
	let i = F[e], a = i[n + 1], o = i[r + 1], s = {
		key: "undefined",
		delta: 2 ** 53 - 1
	};
	for (let e of Object.entries(a)) {
		let n = e[0];
		if (n === "level") continue;
		let r = Number(e[1]), i = Math.abs(r - t);
		i < s.delta && (s = {
			key: n,
			delta: i
		});
	}
	let c = {
		value: o[s.key],
		delta: t - a[s.key],
		total: 0
	};
	return c.total = c.value + c.delta, c;
}
function Gt(e, t, n) {
	let r = F.hitPoints, i = r[t + 1], a = r[n + 1], o = {
		key: "undefined",
		percentile: 0,
		delta: 2 ** 53 - 1
	};
	for (let t of Object.entries(i)) {
		let n = t[0];
		if (n === "level") continue;
		let { minimum: r, maximum: i } = t[1], a = i - r, s = (e - r) / a, c = Math.abs(e - r), l = Math.abs(e - i), u = Math.min(c, l);
		if (e > r && e < i) {
			o = {
				key: n,
				percentile: s,
				delta: u
			};
			break;
		} else u < o.delta && (o = {
			key: n,
			percentile: s,
			delta: u
		});
	}
	let s = a[o.key];
	return Math.round(s.minimum + (s.maximum - s.minimum) * o.percentile);
}
function Kt(e, t, n, r) {
	let i = F[e], a = i[n + 1], o = i[r + 1], s = Math.abs(a.maximum - a.minimum), c = (t - a.minimum) / s, l = Math.abs(o.maximum - o.minimum);
	return Math.round(o.minimum + l * c);
}
function qt(e, t, n) {
	let r = n.diceCount, i = n.diceSize;
	return Ut(Wt({
		diceCount: r,
		diceSize: i,
		bonus: n.bonus + e.bonus - t.bonus
	}));
}
function Jt(e, t, n) {
	let r = F.strikeDamage, i = r[t + 1], a = r[n + 1], o = Ut(e), s = {
		key: "undefined",
		delta: 2 ** 53 - 1
	};
	for (let e of Object.entries(i)) {
		let t = e[0];
		if (t === "level") continue;
		let n = e[1], r = Math.abs(n.average - o.average);
		r < s.delta && (s = {
			key: t,
			delta: r
		});
	}
	return s.delta < o.average * .5 ? qt(o, i[s.key], a[s.key]).original : e;
}
function Yt(e, t, n) {
	let r = F.areaDamage, i = r[t + 1], a = r[n + 1], o = Ut(e), s = {
		key: "undefined",
		delta: 2 ** 53 - 1
	};
	for (let e of Object.entries(i)) {
		let t = e[0];
		if (t === "level") continue;
		let n = e[1], r = Math.abs(n.average - o.average);
		r < s.delta && (s = {
			key: t,
			delta: r
		});
	}
	return s.delta < o.average * .5 ? qt(o, i[s.key], a[s.key]).original : e;
}
//#endregion
//#region src/module/feature/cr-scaler/NPCScaler.ts
async function Xt(e, t) {
	let n = game.actors.get(e);
	n && await Qt(n, t);
}
function Zt(e) {
	let t = e.match(/^(.*?)(?:\s+\d+)?$/);
	return t ? t[1] : e;
}
async function Qt(e, t) {
	let n = Bt("cr-scaler"), r = `Level ${t}`, i = Vt(r, n?.name) ?? await Folder.create({
		name: r,
		type: "Actor",
		parent: n ? n.id : ""
	}), a = e.system, o = a.details.level.value, s = {
		folder: i.id,
		"system.details.level.value": t
	};
	for (let [e, n] of Object.entries(a.abilities)) {
		let r = I("abilityScore", parseInt(n.mod), o, t).total, i = 10 + r * 2;
		s[`system.abilities.${e}`] = {
			value: i,
			min: 3,
			mod: r
		};
	}
	let c = [], l = a.attributes.resistances;
	for (let e = 0; e < l.length; e++) {
		let n = l[e];
		c.push({
			label: Zt(n.label),
			type: n.type,
			exceptions: n.exceptions ?? "",
			value: Kt("resistance", n.value, o, t),
			doubleVs: n.doubleVs ?? ""
		});
	}
	s["system.attributes.resistances"] = c;
	let u = [], d = a.attributes.weaknesses;
	for (let e = 0; e < d.length; e++) {
		let n = d[e];
		u.push({
			label: Zt(n.label),
			type: n.type,
			exceptions: n.exceptions ?? [],
			value: Kt("weakness", n.value, o, t)
		});
	}
	s["system.attributes.weaknesses"] = u, s["system.attributes.ac.value"] = I("armorClass", a.attributes.ac?.value ?? 0, o, t).total, s["system.perception.mod"] = I("perception", a.perception.mod ?? 0, o, t).total, s["system.saves.fortitude.value"] = I("savingThrow", a.saves.fortitude.value ?? 0, o, t).total, s["system.saves.reflex.value"] = I("savingThrow", a.saves.reflex.value ?? 0, o, t).total, s["system.saves.will.value"] = I("savingThrow", a.saves.will.value ?? 0, o, t).total;
	let f = Gt(a.attributes.hp?.value ?? 0, o, t);
	s["system.attributes.hp.max"] = f, s["system.attributes.hp.value"] = f;
	for (let [e, n] of Object.entries(a.skills).filter(([, e]) => e.base > 0)) {
		let r = n, i = I("skill", parseInt(r.mod), o, t).total, a = I("skill", parseInt(r.value), o, t).total, c = I("skill", parseInt(r.base), o, t).total;
		s[`system.skills.${e}`] = {
			...n,
			mod: i,
			value: a,
			base: c
		};
	}
	let p = [], h = e.items;
	for (let e of h.keys()) {
		let n = h.get(e);
		if (n.type === "spellcastingEntry") {
			let e = I("spell", parseInt(n.system.spelldc.value), o, t).total, r = I("difficultyClass", parseInt(n.system.spelldc.dc), o, t).total;
			p.push({
				_id: n.id,
				"system.spelldc.value": e,
				"system.spelldc.dc": r
			});
		} else if (n.type === "melee") {
			let e = I("spell", parseInt(n.system.bonus.value), o, t).total, r = {
				_id: n.id,
				"system.bonus.value": e,
				"system.bonus.total": e
			}, i = n.system.damageRolls;
			if (Array.isArray(i)) for (let e = 0; e < i.length; e++) r[`system.damageRolls.${e}.damage`] = Jt(i[e].damage, o, t), r[`system.damageRolls.${e}.damageType`] = i[e].damageType;
			else for (let e in i) r[`system.damageRolls.${e}.damage`] = Jt(i[e].damage, o, t), r[`system.damageRolls.${e}.damageType`] = i[e].damageType;
			p.push(r);
		}
	}
	m(p);
	let g = Ht(e.name, i.name);
	g === void 0 ? g = await Actor.create(e.clone(s)._source) : await g.update(s), await g.updateEmbeddedDocuments("Item", p), p = [];
	let _ = [/(data-pf2-dc=")(\d+)(")/g, /(@Check\[.*?type:.*?|dc:)(\d+)(.*?])/g];
	for (let e = 0; e < _.length; e++) {
		let n = _[e];
		for (let r of h.filter((e) => e.system.description.value.includes("DC") || e.system.description.value.includes("dc:")).filter((e) => ![
			"consumable",
			"armor",
			"backpack",
			"book",
			"equipment",
			"treasure",
			"weapon"
		].includes(e.type)).filter((e) => !e.system.description.value.includes("type:flat"))) {
			let i = r.system.description.value, a = i, s = n.exec(i), c = 0;
			for (; s !== null;) {
				let r = s[0], l;
				l = e === 0 ? s[1] : s[2];
				let u = s.index + c, d = I("difficultyClass", parseInt(l), o, t).total, f = `${s[1]}${d}${s[3]}`;
				a = a.substring(0, u) + f + a.substring(u + r.length), c += a.length - i.length - c, s = n.exec(i);
			}
			p.push({
				_id: r.id,
				"system.description.value": a
			});
		}
	}
	await g.updateEmbeddedDocuments("Item", p), p = [];
	for (let e of g.items.filter((e) => !e.isOfType("spell")).values()) {
		let n = /\d+d\d+(\+\d*)?/g, r = e.system.description.value, i = r, a = n.exec(r), s = 0;
		for (; a !== null;) {
			let [e] = a, c = a.index + s, l = Yt(e, o, t);
			i = i.substring(0, c) + l + i.substring(c + e.length), s += i.length - r.length - s, a = n.exec(r);
		}
		p.push({
			_id: e.id,
			"system.description.value": i
		});
	}
	await g.updateEmbeddedDocuments("Item", p);
}
//#endregion
//#region node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/lazyDataLastImpl--3B10z3s.js
function $t(e, t, n) {
	let r = (n) => e(n, ...t);
	return n === void 0 ? r : Object.assign(r, {
		lazy: n,
		lazyArgs: t
	});
}
//#endregion
//#region node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/purry.js
function en(e, t, n) {
	let r = e.length - t.length;
	if (r === 0) return e(...t);
	if (r === 1) return $t(e, t, n);
	throw Error("Wrong number of arguments");
}
//#endregion
//#region node_modules/.pnpm/remeda@2.39.0/node_modules/remeda/dist/pick.js
function tn(...e) {
	return en(nn, e);
}
function nn(e, t) {
	let n = {};
	for (let r of t) r in e && (n[r] = e[r]);
	return n;
}
//#endregion
//#region src/module/feature/macros/follow-the-expert.ts
var rn = class {
	img;
	name;
	slug;
	traits;
	variants;
	effect;
	constructor() {
		this.img = `systems/${game.system.id}/icons/spells/favorable-review.webp`, this.name = `${e}.macros.basicActionMacros.actions.FollowTheExpertToggle`, this.slug = "follow-the-expert", this.traits = ["exploration"], this.variants = new Collection(), this.effect = "Compendium.pf2e.other-effects.VCSpuc3Tf3XWMkd3";
	}
	async use(e) {
		let t = await fromUuid(this.effect);
		if (!t) throw Error(`Effect ${this.effect} not found!`);
		let n = t.toObject();
		(n.flags.core ??= {}).sourceId = this.effect;
		let r = canvas.tokens.controlled.flatMap((e) => e.actor ?? []);
		if (r.length === 0 && game.user.character && r.push(game.user.character), r.length === 0) return ui.notifications.error("PF2E.ErrorMessage.NoTokenSelected", { localize: !0 });
		let i = game.user.targets.first();
		i?.actor && this.fixupRules(n, i.actor);
		for (let e of r) {
			let t = e.itemTypes.effect.find((e) => e.flags.core?.sourceId === this.effect);
			t ? await t.delete() : await e.createEmbeddedDocuments("Item", [n]);
		}
		return !0;
	}
	async toMessage(e) {}
	fixupRules(e, t) {
		let n = t.skills;
		if (!n) return;
		let r = i(t, "followTheExpert"), a = r?.minimum ?? 2, o = Object.values(n).filter((e) => e.lore && (e.rank ?? 0) >= a).map((e) => ({
			label: e.label,
			value: e.slug
		})), s = e.system.rules.find((e) => e.key === "ChoiceSet" && e.flag === "followTheExpertSkill"), c = e.system.rules.find((e) => e.key === "ChoiceSet" && e.flag === "followTheExpertProficiency");
		if (!s || !c) throw Error("Effect: FTE did not have expected rules");
		a <= 1 && c.choices.push({
			label: "PF2E.ProficiencyLevel1",
			sort: 0,
			value: 1
		}), s.choices = s.choices.filter((e) => (n[e.value]?.rank ?? 0) >= a).concat(o);
		let l = s.choices.map((e) => e.value);
		for (let e of c.choices) {
			let t = l.filter((t) => n[t].rank === e.value);
			t.length > 0 ? e.predicate = [{ or: t.map((e) => ({ eq: ["{item|flags.pf2e.rulesSelections.followTheExpertSkill}", e] })) }] : e.predicate = ["disabled"];
		}
		if (r?.bonus) {
			let t = Object.keys(CONFIG.PF2E.proficiencyRanks);
			e.system.rules.push({
				key: "AdjustModifier",
				mode: "upgrade",
				slug: "follow-the-expert-circumstance",
				selector: "{item|flags.pf2e.rulesSelections.followTheExpertSkill}",
				value: {
					brackets: t.map((e, t) => ({
						start: t,
						end: t,
						value: r.bonus?.[e]
					})).filter((e) => e.value !== void 0),
					field: "item|flags.pf2e.rulesSelections.followTheExpertProficiency"
				}
			});
		}
	}
}, an;
Hooks.once("setup", () => {
	an = new rn();
});
//#endregion
//#region src/module/feature/macros/basicActionMacros.ts
function on(e) {
	return foundry.utils.hasProperty(e, "preview");
}
async function sn() {
	await foundry.applications.handlebars.loadTemplates([`modules/${e}/templates/macros/bam/index.hbs`, `modules/${e}/templates/macros/bam/actionButton.hbs`]), Handlebars.registerPartial("actionButton", `{{> "modules/${e}/templates/macros/bam/actionButton.hbs"}}`);
}
function cn(e, t, n) {
	for (let r of t) {
		let t = e.get(r);
		for (let e of n) {
			let n = t?.[e.skill];
			if (!n) continue;
			let i = n.check?.mod ?? n.mod;
			i > (e.best ?? -1) && (e.best = i, e.whoIsBest = r);
		}
	}
}
function ln(e) {
	let t = /* @__PURE__ */ new Map();
	for (let n of e) {
		let e = un(n);
		e && t.set(n.id, e);
	}
	return t;
}
function un(e) {
	return {
		perception: e.perception,
		...e.skills
	};
}
function dn(e, t, n, r, i) {
	let a = i[e.skill], o = a?.rank ?? +!!a?.proficient, s = e.bonus ?? a?.mod;
	return {
		best: y("basicActionMacroShowBestBonus") && r.includes(n.id) && (s ?? -100) >= (e.best ?? 0),
		idx: t,
		action: e,
		rank: o,
		bonus: s
	};
}
function fn(e, t) {
	let n = y("bamShowUnusable"), r = x(e, "clever-improviser"), i = (t) => t === "perception" ? e.perception : e.skills?.[t], a = (e) => e === "" ? !0 : i(e)?.proficient ?? !1, o = t.filter((t) => {
		if (t.module && !game.modules.get(t.module)?.active || t.feat && !x(e, t.feat)) return !1;
		let i = a(t.skill) || t.altSkillAndFeat?.some((t) => a(t.skill) && x(e, t.feat));
		return t.actionType !== "skill_trained" || n || i || r || e.type === "familiar";
	});
	return o.forEach((t) => {
		let n = t.action;
		if (t.skill === "" && n && on(n)) {
			let r = n.preview({ actor: e }).reduce((e, t) => (e?.modifier ?? -100) > (t.modifier ?? 0) ? e : t);
			t.bonus = r.modifier, t.skill = r.slug, t.name += ` (${r.label})`;
		}
		let r = t.action && typeof t.action == "object" && "traits" in t.action ? t.action.traits : [];
		t.showMAP = r.includes("attack"), t.showDowntime = r.includes("downtime"), t.showExploration = r.includes("exploration"), t.showMAP && (t.MAP = [-5, -10], t.skill === "athletics" && o.push({
			...t,
			name: `${t.name} (${game.i18n.localize("PF2E.TraitAgile")})`,
			MAP: [-4, -8]
		}));
	}), o.sort((e, t) => e.name.localeCompare(t.name, game.i18n.lang));
}
var L = class {
	traits = [];
	#e;
	#t;
	constructor(e, t) {
		if (this.#e = e, t.startsWith("xdy-pf2e-workbench.")) {
			let e = t.replace("xdy-pf2e-workbench.", "");
			this.#t = l(e);
		} else this.#t = t;
	}
	get slug() {
		return this.#e.slugify();
	}
	async use(t) {
		let n = game.packs.get(this.#t);
		if (n) {
			let r = await n.getDocuments({ name: this.#e });
			r.length > 0 ? await r[0].execute(tn(t, ["event"])) : ui.notifications.error(game.i18n.format(`${e}.macros.basicActionMacros.macroNotFound`, { macroName: this.#e }));
		} else ui.notifications.error(game.i18n.format(`${e}.macros.basicActionMacros.compendiumNotFound`, { compendiumName: this.#t }));
	}
	async toMessage() {}
};
async function pn() {
	let t = [
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AdministerFirstAidStabilize`),
			skill: "medicine",
			action: game.pf2e.actions.get("administer-first-aid")?.variants.get("stabilize"),
			icon: `systems/${game.system.id}/icons/features/feats/treat-wounds.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AdministerFirstAidStopBleeding`),
			skill: "medicine",
			action: game.pf2e.actions.get("administer-first-aid")?.variants.get("stop-bleeding"),
			icon: `systems/${game.system.id}/icons/conditions/persistent-damage.webp`
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AidToggle`),
			skill: "",
			action: new L("macroEffectAid", "xdy-pf2e-workbench.xdy-internal-utility-macros"),
			icon: `systems/${game.system.id}/icons/spells/efficient-apport.webp`
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AidASE`),
			skill: "",
			action: new L("Aid", "pf2e-action-support-engine-macros.action-support-engine-macros"),
			module: "pf2e-action-support-engine",
			icon: `systems/${game.system.id}/icons/spells/efficient-apport.webp`
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AidPF2eMacros`),
			skill: "",
			action: (e) => game.activemacros.aid(e.actors?.[0]),
			module: "pf2e-macros",
			icon: `systems/${game.system.id}/icons/spells/efficient-apport.webp`
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.AvoidNotice`),
			skill: "stealth",
			action: game.pf2e.actions.get("avoid-notice"),
			icon: `systems/${game.system.id}/icons/features/classes/surprice-attack.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Balance`),
			skill: "acrobatics",
			action: game.pf2e.actions.get("balance"),
			icon: "icons/skills/movement/feet-winged-boots-brown.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Climb`),
			skill: "athletics",
			action: game.pf2e.actions.get("climb"),
			icon: "icons/sundries/misc/ladder.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Coerce`),
			skill: "intimidation",
			action: game.pf2e.actions.get("coerce"),
			icon: "icons/skills/social/intimidation-impressing.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.CommandAnAnimal`),
			skill: "nature",
			action: game.pf2e.actions.get("command-an-animal"),
			icon: "icons/environment/creatures/horse-white.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.ConcealAnObject`),
			skill: "stealth",
			action: game.pf2e.actions.get("conceal-an-object"),
			icon: `systems/${game.system.id}/icons/equipment/adventuring-gear/wax-key-blank.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Craft`),
			skill: "crafting",
			action: game.pf2e.actions.craft,
			icon: "icons/skills/trades/smithing-anvil-silver-red.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.CreateForgery`),
			skill: "society",
			action: game.pf2e.actions.get("create-forgery"),
			icon: `systems/${game.system.id}/icons/spells/transcribe-moment.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.CreateADiversionDistractingWords`),
			skill: "deception",
			action: game.pf2e.actions.get("create-a-diversion")?.variants.get("distracting-words"),
			icon: "icons/skills/social/wave-halt-stop.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.CreateADiversionGesture`),
			skill: "deception",
			action: game.pf2e.actions.get("create-a-diversion")?.variants.get("gesture"),
			icon: "icons/skills/social/wave-halt-stop.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.CreateADiversionTrick`),
			skill: "deception",
			action: game.pf2e.actions.get("create-a-diversion")?.variants.get("trick"),
			icon: `systems/${game.system.id}/icons/spells/charming-words.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.DecipherWritingArcana`),
			skill: "arcana",
			action: game.pf2e.actions.get("decipher-writing"),
			options: { statistic: "arcana" },
			icon: "icons/skills/trades/academics-book-study-runes.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.DecipherWritingOccultism`),
			skill: "occultism",
			action: game.pf2e.actions.get("decipher-writing"),
			options: { statistic: "occultism" },
			icon: "icons/skills/trades/academics-book-study-purple.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.DecipherWritingReligion`),
			skill: "religion",
			action: game.pf2e.actions.get("decipher-writing"),
			options: { statistic: "religion" },
			icon: `systems/${game.system.id}/icons/equipment/other/spellbooks/thresholds-of-truth.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.DecipherWritingSociety`),
			skill: "society",
			action: game.pf2e.actions.get("decipher-writing"),
			options: { statistic: "society" },
			icon: "icons/skills/trades/academics-study-reading-book.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Demoralize`),
			skill: "intimidation",
			action: new L("XDY DO_NOT_IMPORT Demoralize", "xdy-pf2e-workbench.asymonous-benefactor-macros-internal"),
			icon: "icons/skills/social/intimidation-impressing.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Disarm`),
			skill: "athletics",
			action: game.pf2e.actions.get("disarm"),
			icon: "icons/skills/melee/sword-damaged-broken-glow-red.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.DisableDevice`),
			skill: "thievery",
			action: game.pf2e.actions.get("disable-device"),
			icon: `systems/${game.system.id}/icons/equipment/adventuring-gear/thieves-tools.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Escape`),
			skill: "",
			action: game.pf2e.actions.get("escape"),
			icon: "icons/skills/movement/feet-winged-boots-glowing-yellow.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Feint`),
			skill: "deception",
			action: game.pf2e.actions.get("feint"),
			icon: "icons/skills/melee/maneuver-sword-katana-yellow.webp"
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.FollowTheExpertToggle`),
			skill: "",
			action: an,
			icon: `systems/${game.system.id}/icons/spells/favorable-review.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.ForceOpen`),
			skill: "athletics",
			action: game.pf2e.actions.get("force-open"),
			icon: "icons/equipment/feet/boots-armored-steel.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.GatherInformation`),
			skill: "diplomacy",
			action: game.pf2e.actions.get("gather-information"),
			icon: "icons/skills/social/diplomacy-handshake.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Grapple`),
			skill: "athletics",
			action: game.pf2e.actions.get("grapple"),
			icon: "icons/skills/melee/unarmed-punch-fist.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Hide`),
			skill: "stealth",
			action: game.pf2e.actions.get("hide"),
			icon: `systems/${game.system.id}/icons/features/classes/wild.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Impersonate`),
			skill: "deception",
			action: game.pf2e.actions.get("impersonate"),
			icon: "icons/equipment/head/mask-carved-scream-tan.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.JumpHigh`),
			skill: "athletics",
			action: game.pf2e.actions.get("high-jump"),
			icon: "icons/skills/movement/arrows-up-trio-red.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.JumpLong`),
			skill: "athletics",
			action: game.pf2e.actions.get("long-jump"),
			icon: "icons/skills/movement/figure-running-gray.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Lie`),
			skill: "deception",
			action: game.pf2e.actions.get("lie"),
			icon: "icons/magic/control/mouth-smile-deception-purple.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.MakeAnImpression`),
			skill: "diplomacy",
			action: game.pf2e.actions.get("make-an-impression"),
			icon: "icons/environment/people/commoner.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.MakeAnImpression`) + " - " + game.i18n.localize("PF2E.Skill.Performance"),
			skill: "performance",
			action: game.pf2e.actions.get("make-an-impression"),
			options: { statistic: "performance" },
			icon: "icons/environment/people/commoner.webp",
			feat: "impressive-performance"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.ManeuverInFlight`),
			skill: "acrobatics",
			action: game.pf2e.actions.get("maneuver-in-flight"),
			icon: "icons/commodities/biological/wing-bird-white.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.PalmAnObject`),
			skill: "thievery",
			action: game.pf2e.actions.get("palm-an-object"),
			icon: "icons/sundries/gaming/playing-cards.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Perform`),
			skill: "performance",
			action: game.pf2e.actions.get("perform")?.variants.get("singing"),
			icon: "icons/skills/trades/music-singing-voice-blue.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.PickALock`),
			skill: "thievery",
			action: game.pf2e.actions.get("pick-a-lock"),
			icon: "icons/skills/social/theft-pickpocket-bribery-brown.webp"
		},
		{
			actionType: "other",
			name: game.i18n.localize("PF2E.Actions.PointOut.Title"),
			skill: "",
			action: game.pf2e.actions.get("point-out"),
			icon: `systems/${game.system.id}/icons/conditions/observed.webp`
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.RaiseAShieldToggle`),
			skill: "",
			action: game.pf2e.actions.raiseAShield,
			icon: `systems/${game.system.id}/icons/actions/raise-a-shield.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.RecallKnowledge`),
			skill: "",
			action: new L("XDY DO_NOT_IMPORT Recall_Knowledge", "xdy-pf2e-workbench.asymonous-benefactor-macros-internal"),
			icon: "icons/skills/trades/academics-study-reading-book.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Repair`),
			skill: "crafting",
			action: game.pf2e.actions.repair,
			icon: "icons/tools/smithing/anvil.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Reposition`),
			skill: "athletics",
			action: game.pf2e.actions.get("reposition"),
			icon: "icons/sundries/gaming/chess-pawn-white-pink.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Request`),
			skill: "diplomacy",
			action: game.pf2e.actions.get("request"),
			icon: "icons/skills/social/thumbsup-approval-like.webp"
		},
		{
			actionType: "basic",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Seek`),
			skill: "perception",
			action: game.pf2e.actions.get("seek"),
			icon: "icons/tools/scribal/magnifying-glass.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.SenseDirection`),
			skill: "survival",
			action: game.pf2e.actions.get("sense-direction"),
			icon: "icons/tools/navigation/compass-brass-blue-red.webp"
		},
		{
			actionType: "basic",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.SenseMotive`),
			skill: "perception",
			action: game.pf2e.actions.get("sense-motive"),
			icon: "icons/environment/people/commoner.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Shove`),
			skill: "athletics",
			action: game.pf2e.actions.get("shove"),
			icon: `systems/${game.system.id}/icons/spells/hydraulic-push.webp`
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Sneak`),
			skill: "stealth",
			action: game.pf2e.actions.get("sneak"),
			icon: `systems/${game.system.id}/icons/conditions/unnoticed.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Squeeze`),
			skill: "acrobatics",
			action: game.pf2e.actions.get("squeeze"),
			icon: "icons/commodities/tech/claw-mechanical.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Steal`),
			skill: "thievery",
			action: game.pf2e.actions.get("steal"),
			icon: "icons/containers/bags/coinpouch-gold-red.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.SubsistSociety`),
			skill: "society",
			action: game.pf2e.actions.get("subsist"),
			options: { statistic: "society" },
			icon: "icons/environment/settlement/building-rubble.webp"
		},
		{
			actionType: "basic",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.SubsistSurvival`),
			skill: "survival",
			action: game.pf2e.actions.get("subsist"),
			options: { statistic: "survival" },
			icon: "icons/environment/wilderness/camp-improvised.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Swim`),
			skill: "athletics",
			action: game.pf2e.actions.get("swim"),
			icon: "icons/creatures/fish/fish-shark-swimming.webp"
		},
		{
			actionType: "other",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.TakeCoverToggle`),
			skill: "",
			action: game.pf2e.actions.get("take-cover"),
			icon: `systems/${game.system.id}/icons/equipment/shields/tower-shield.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Track`),
			skill: "survival",
			action: game.pf2e.actions.get("track"),
			icon: `systems/${game.system.id}/icons/conditions/observed.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.TreatDisease`),
			skill: "medicine",
			action: game.pf2e.actions.get("treat-disease"),
			icon: "icons/magic/nature/root-vine-caduceus-healing.webp"
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.TreatPoison`),
			skill: "medicine",
			action: game.pf2e.actions.get("treat-poison"),
			icon: `systems/${game.system.id}/icons/effects/treat-poison.webp`
		},
		{
			actionType: "skill_trained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.TreatWounds`),
			skill: "medicine",
			altSkillAndFeat: [{
				skill: "nature",
				feat: "natural-medicine"
			}, {
				skill: "crafting",
				feat: "chirurgeon"
			}],
			action: new L("XDY DO_NOT_IMPORT Treat Wounds and Battle Medicine", "xdy-pf2e-workbench.asymonous-benefactor-macros-internal"),
			icon: "icons/skills/wounds/injury-stapled-flesh-tan.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.Trip`),
			skill: "athletics",
			action: game.pf2e.actions.get("trip"),
			icon: "icons/skills/wounds/bone-broken-marrow-yellow.webp"
		},
		{
			actionType: "skill_untrained",
			name: game.i18n.localize(`${e}.macros.basicActionMacros.actions.TumbleThrough`),
			skill: "acrobatics",
			action: game.pf2e.actions.get("tumble-through"),
			icon: "icons/skills/movement/feet-winged-sandals-tan.webp"
		},
		{
			actionType: "basic",
			name: game.i18n.localize("PF2E.Actions.DropProne.Title"),
			skill: "",
			action: game.pf2e.actions.get("drop-prone"),
			icon: `systems/${game.system.id}/icons/conditions/prone.webp`
		}
	];
	if (foundry.applications.instances.get("xdy-pf2e-workbench-BAM-app")?.rendered) {
		foundry.applications.instances.get("xdy-pf2e-workbench-BAM-app")?.close();
		return;
	}
	let n = canvas.tokens.controlled.flatMap((e) => e.actor ?? []);
	game.user.character && n.push(game.user.character);
	let r = [
		"character",
		"npc",
		"familiar"
	], i = n.filter((e) => r.includes(e.type))[0];
	if (!i) {
		ui.notifications.warn(game.i18n.localize(`${e}.macros.basicActionMacros.noActorSelected`));
		return;
	}
	let a = fn(i, t), o = game.scenes.current?.tokens.map((e) => e.actor).filter((e) => e !== null).filter((e) => r.includes(e.type)) || [], s = game.actors.party?.members || [], c = s.map((e) => e.id), l = ln(o);
	c.includes(i.id) && cn(ln(s), c, a);
	let u = 26 + (1 + ~~((a.length - 1) / 14)) * 260, d = y("bamTabview"), f = l.get(i.id) ?? {}, p = a.map((e, t) => dn(e, t, i, c, f)), m = {
		encounter: p.filter((e) => !(e.action.showDowntime || e.action.showExploration)),
		downtime: p.filter((e) => e.action.showDowntime),
		exploration: p.filter((e) => e.action.showExploration),
		tabView: d
	}, { ApplicationV2: h, HandlebarsApplicationMixin: g } = foundry.applications.api;
	class _ extends g(h) {
		static DEFAULT_OPTIONS = {
			tag: "form",
			id: "xdy-pf2e-workbench-BAM-app",
			position: { width: u },
			window: {
				title: game.i18n.format(`${e}.macros.basicActionMacros.title`, { name: i.name }),
				contentClasses: [
					"pf2e-bg",
					"bam-dialog",
					"standard-form"
				],
				resizable: !0
			},
			form: {
				handler: _.handler,
				closeOnSubmit: !1,
				submitOnChange: !1
			},
			actions: Object.fromEntries(new Map(a.map((e, t) => [t, _.use])))
		};
		static PARTS = {
			index: { template: "modules/xdy-pf2e-workbench/templates/macros/bam/index.hbs" },
			footer: { template: "templates/generic/form-footer.hbs" }
		};
		static TABS = { primary: {
			tabs: [
				{
					id: "encounter",
					label: "Encounter"
				},
				{
					id: "exploration",
					label: "Exploration"
				},
				{
					id: "downtime",
					label: "Downtime"
				}
			],
			initial: "encounter"
		} };
		static async handler(e, t, n) {
			let r = e.submitter;
			r && r.dataset.action === "cancel" && foundry.applications.instances.get("xdy-pf2e-workbench-BAM-app")?.close();
		}
		static async use(e, t) {
			let n = Number(t.dataset.action);
			if (isNaN(n)) return;
			let r = a[n], o = r.action;
			if (typeof o == "object") {
				let n = -(Number.parseInt(t.dataset.map ?? "0") / 5);
				await o.use({
					event: e,
					actors: [i],
					multipleAttackPenalty: n,
					...r.options
				});
			} else o && await o({
				event: e,
				actors: [i],
				skill: r.skill
			});
		}
		async _prepareContext(e) {
			let t = await super._prepareContext(e);
			return foundry.utils.mergeObject(t, m), t;
		}
		async _preparePartContext(e, t, n) {
			switch (t = await super._preparePartContext(e, t, n), e) {
				case "footer":
					t.buttons = [{
						type: "cancel",
						action: "cancel",
						icon: "fa-solid fa-xmark",
						label: "Cancel"
					}];
					break;
				case "index":
					t.tabs = this._prepareTabs("primary");
					break;
				default: break;
			}
			return t;
		}
	}
	new _().render({ force: !0 });
}
//#endregion
//#region src/module/feature/macros/buildNpcSpellbookJournal.ts
async function mn() {
	let t = ui.activeWindow, n;
	if (t?.constructor.name === "NPCSheetPF2e") n = t.token?.actor || t.actor;
	else {
		let e = canvas.tokens.controlled.map((e) => e.actor).filter((e) => e?.isOfType("npc"));
		e?.length === 1 && (n = e[0]);
	}
	let r = n?.spellcasting?.contents?.filter((e) => e.spells), i = r?.length;
	if (!n || i === 0) {
		ui.notifications.warn(game.i18n.localize(`${e}.macros.buildNpcSpellbookJournal.noSpellcastingEntry`));
		return;
	}
	let a = [];
	for (let e = 0; e < i; e++) {
		a[e] = {
			entry: r[e].name,
			spells: []
		};
		for (let t = 0; t < r[e]?.spells?.contents?.length; t++) a[e].spells.push("@UUID[" + r[e].spells.contents[t].sourceId + "]");
	}
	let o = "<table class=\"pf2-table\">\n<tr>\n   <th>Entry</th>\n   <th>Spells</th>\n</tr>";
	for (let e = 0; e < a.length; e++) o += `
  <tr>
  <td>${a[e].entry}</td>
  <td><div style="display: flex; gap:3px; flex-wrap: wrap; align-items: center;justify-content: center;">${a[e].spells}</div></td>
  </tr>
  `;
	let s = {
		name: game.i18n.format("xdy-pf2e-workbench.macros.buildNpcSpellbookJournal.generatedSpellbookFor", { name: n.name }),
		pages: [{
			name: "Spell book",
			text: { content: o }
		}]
	};
	s.content += "</table>";
	let c = game.journal.getName(s.name);
	c && await c.delete(), await JournalEntry.create(s);
}
//#endregion
//#region src/module/utils/settings.ts
function R(t, n) {
	let r = game.settings.get(e, t);
	return r === "all" ? !0 : n === "player" ? r === "players" : n === "gm" && r === "gm";
}
//#endregion
//#region src/module/feature/damageHandler/index.ts
async function hn(e, t = {}) {
	let n = {
		autoRollDamageAllow: y("autoRollDamageAllow"),
		autoRollDamageForStrike: y("autoRollDamageForStrike"),
		autoRollDamageForSpellAttack: y("autoRollDamageForSpellAttack"),
		autoRollDamageForSpellWhenNotAnAttack: y("autoRollDamageForSpellWhenNotAnAttack")
	}, r = n.autoRollDamageAllow && (n.autoRollDamageForStrike || n.autoRollDamageForSpellAttack || n.autoRollDamageForSpellWhenNotAnAttack !== "no"), a = t.forceSaveSpellRoll ? C() : S(e, R("autoRollDamageAllow", "player"), R("autoRollDamageAllow", "gm"));
	if (r && a) {
		let r = i(e, "origin.uuid");
		if (r) {
			let a = te(e), o = i(e, "context.type"), s = r ? await fromUuid(r) : null, c = s?.traits?.has("attack") ?? !1, l = s?.system?.defense?.save ?? !1, u = Number.isInteger(parseInt(s?.system?.time?.value ?? "")) ?? !1, d = o === "attack-roll" && n.autoRollDamageForStrike, f = s !== null && !c && i(e, "casting") !== null && u && s?.system?.damage, p = l && f && (n.autoRollDamageForSpellWhenNotAnAttack === "saveSpell" || n.autoRollDamageForSpellWhenNotAnAttack === "anySpell");
			if (Xn(e, p, t)) return;
			let m = !l && f && (n.autoRollDamageForSpellWhenNotAnAttack === "nonSaveSpell" || n.autoRollDamageForSpellWhenNotAnAttack === "anySpell"), h = c && n.autoRollDamageForSpellAttack && u, g = t.forcedDegreeOfSuccess ?? ee(e), _ = ["criticalFailure", "failure"].includes(g), v = ["criticalSuccess", "success"].includes(g), y = i(e, "context.options")?.includes("item:defense:basic"), b = t.forceSaveSpellRoll && p, x = (await bn(5, r))?.flags, S = game.modules.get("pf2e-target-helper")?.active && game.settings.get("pf2e-target-helper", "multipleTargetRollDamage") !== "no", C = (x["pf2e-target-helper"]?.targets ?? 0) > 1 && S;
			a && (m || b || p && (_ || y && g === "success") || h && v) && !C && !(c && l) ? await Sn(x, 10, r, s, e, g) : a && d && v && await Tn(a, e, g);
		}
	}
}
var z = /* @__PURE__ */ new Map();
async function gn(e) {
	let t = !0;
	if (!game.modules.get("pf2-flat-check")?.active) return t;
	let n = e.actor?.itemTypes.condition.filter((e) => ["blinded", "dazzled"].includes(e.slug)) ?? [], r = e.target?.actor?.itemTypes.condition.filter((e) => [
		"concealed",
		"hidden",
		"invisible",
		"undetected"
	].includes(e.slug)) ?? [];
	if (n?.length === 0 && r?.length === 0) return t;
	let { token: a, actor: o } = e, { item: s } = e, c = i(e, "origin.uuid")?.match(/Item.(\w+)/);
	if (!s && c && c[1] === "xxPF2ExUNARMEDxx" && (s = {
		type: "weapon",
		data: {}
	}), !a || !s || !o || w(e)) return t;
	let l = `${e.id}`;
	if (z.has(l)) return z.get(l);
	await new Promise((e) => setTimeout(e, 150));
	let u = game.messages.contents, d = u.findIndex((t) => t.id === e.id);
	if (d > -1) {
		let e = Math.min(5, u.length - d);
		t = !u.slice(d, d + e).some((e) => e.content.includes("dice-result flat-check-failure")), z.set(l, t);
	}
	return t;
}
function _n(e) {
	if (!e || !game.ready || !e.token || !e.actor || !e.isDamageRoll) return;
	let t = Array.isArray(e.rolls) ? e.rolls : null;
	if (!t) return;
	let n;
	if (t.length !== 0 && (t[0]?.instances?.some((e) => e.persistent && e.options.evaluatePersistent) ? n = "Damage" : t.some((e) => e.kinds.has("healing")) && (e.flavor?.includes(game.i18n.localize("PF2E.Encounter.Broadcast.FastHealing.fast-healing.ReceivedMessage")) || e.flavor?.includes(game.i18n.localize("PF2E.Encounter.Broadcast.FastHealing.regeneration.ReceivedMessage"))) && (n = "Healing"), n && y(`applyPersistent${n}`))) {
		let r = e.item?.getRollOptions("item") ?? [], i = /* @__PURE__ */ new Set([...r, ...e.actor.getSelfRollOptions()]), a = n === "Damage" ? t[0] : -t.reduce((e, t) => e + (t.total ?? 1), 0), o = e.actor.applyDamage({
			damage: a,
			token: e.token,
			item: e.item,
			rollOptions: i,
			skipIWR: n === "Healing"
		});
		n === "Damage" && y("applyPersistentDamageRecoveryRoll") && E(o.then(() => {
			e.item?.isOfType("condition") && e.item.rollRecovery();
		}), "damageHandler: persistent recovery roll");
	}
}
function vn(t, n) {
	let r = t.filter((e) => e?.system?.traits.value.includes("attack")).filter((e) => e.id === n.item?.id), i = n.actor?.system?.actions?.filter((e) => e?.type === "strike").filter((e) => e?.item?.id === n.item?.id), a = r.concat(i);
	if (a.length === 1) return a[0];
	if (a.length > 1 && i && i?.length > 1) {
		let r = `<h4 class="action">(.*?)${game.i18n.localize(`${e}.SETTINGS.autoRollDamageForStrike.strike`)}: (.*?)<`, i = n.flavor?.match(r);
		return i && i[2] ? t.find((e) => e.label === i[2]) : null;
	} else return null;
}
var B = /* @__PURE__ */ new Map();
function yn() {
	z.size > 100 && z.clear(), B.size > 100 && B.clear();
}
async function bn(e, t) {
	if (B.has(t)) return B.get(t);
	let n = game.messages?.contents.length ?? 0;
	for (let r = 1; r <= Math.min(e + 1, n); r++) {
		let e = game.messages?.contents[n - r];
		if (e && i(e, "origin.uuid") === t) return B.set(t, e), e;
	}
}
async function xn(e, t) {
	let n = (await bn(e, t))?.content.match(/data-cast-level="(\d+)"/);
	return n && n[1] ? parseInt(n[1]) : 0;
}
async function Sn(e, t, n, r, a, o) {
	let s = await Cn(r.name, e, t, n, r.system.level.value);
	if (await gn(a)) {
		let e = wn(s), t = Rn(a), c = Yn() && t?.type === "spell";
		if (c && Dn.set(n, {
			targetHelperData: t,
			createdAt: Date.now()
		}), (i(a, "origin.variant.overlays")?.length ?? 0) > 0) {
			let t = i(a, "origin.variant.overlays");
			await r.loadVariant({
				castRank: s,
				overlayIds: t?.[0] ? [t[0]] : []
			}).rollDamage({
				outcome: o,
				target: e
			});
		} else await r?.rollDamage({
			outcome: o,
			target: e
		});
		c && await a.setFlag("pf2e-toolbelt", "targetHelper", null);
	}
}
async function Cn(t, n, r, i, a) {
	let o = n.pf2e.origin?.castRank ? Number(n.pf2e.origin?.castRank) : 0;
	return o === 0 && (o = await xn(r, i)), o === 0 && (y("autoRollDamageNotifyOnSpellCardNotFound") && ui.notifications.info(game.i18n.format(`${e}.spellCardNotFound`, { spell: t })), o = a ?? 0), o;
}
function wn(e) {
	let t = document.createElement("div");
	return t.dataset.castRank = e.toString(), t.closest = () => ({ dataset: { castRank: e } }), t;
}
async function Tn(e, t, n) {
	let r = e?.getRollOptions(["all", "damage-roll"]), a = (r?.find((e) => e.match(/(.*)-attack/)))?.replace("-attack", "-damage");
	a && r?.push(a);
	let o = i(t, "context") ?? null, s = o && "mapIncreases" in o && [
		0,
		1,
		2
	].includes(o.mapIncreases) ? o.mapIncreases : null, c = o && "altUsage" in o ? o.altUsage : null, l = t.target?.token?.object ?? null, u = e?.system?.actions;
	if (!u || u.length === 0 || !await gn(t)) return;
	let d = vn(u, t);
	if (d && d.type === "strike") return d[n === "success" ? "damage" : "critical"]?.({
		event,
		altUsage: c,
		mapIncreases: s,
		checkContext: o,
		target: l,
		options: r
	});
	await En(e, t, n, o);
}
async function En(e, t, n, r) {
	let i = t.rolls?.find((e) => e.options?.action === "elemental-blast");
	if (i && e.isOfType("character")) {
		let [t, a, o, s] = (i?.options.identifier)?.split(".") ?? [];
		if (fe(CONFIG.PF2E.elementTraits, t) && fe(CONFIG.PF2E.damageTypes, a)) {
			let i = {
				element: t,
				damageType: a,
				melee: o === "melee",
				actionCost: Number(s) || 1,
				checkContext: r,
				outcome: n,
				event
			};
			await new game.pf2e.ElementalBlast(e).damage(i);
		}
	}
}
//#endregion
//#region src/module/feature/damageHandler/toolbeltIntegration.ts
var Dn = /* @__PURE__ */ new Map(), On = /* @__PURE__ */ new Map(), kn = /* @__PURE__ */ new Map();
function An() {
	kn.clear(), On.clear(), Dn.clear();
}
function jn(t, n) {
	globalThis.libWrapper?.register(e, t, n, "WRAPPER");
}
var Mn = !1;
function Nn() {
	Mn || globalThis.libWrapper && (jn("ChatMessage.prototype.update", function(e, t, ...n) {
		return Fn(this.id, Pn(t)), e(t, ...n);
	}), jn("ChatMessage.prototype.setFlag", function(e, t, n, r, ...i) {
		return t === "pf2e-toolbelt" && n === "targetHelper" && (r && typeof r == "object" ? Fn(this.id, r) : On.delete(this.id)), e(t, n, r, ...i);
	}), jn("ChatMessage.prototype._preCreate", function(e, t, ...n) {
		let r = i(this, "origin.uuid");
		if (this.isDamageRoll && r) {
			let e = Dn.get(r);
			e && (this.updateSource({ flags: { "pf2e-toolbelt": { targetHelper: e.targetHelperData } } }), Dn.delete(r));
		}
		return e(t, ...n);
	}), Mn = !0);
}
function Pn(e) {
	let t = e["flags.pf2e-toolbelt.targetHelper"];
	if (t !== void 0) return t;
	let n = e.flags;
	if (!n || typeof n != "object") return;
	let r = n["pf2e-toolbelt"];
	if (!(!r || typeof r != "object")) return r.targetHelper;
}
function Fn(e, t) {
	!t || typeof t != "object" || On.set(e, {
		data: foundry.utils.deepClone(t),
		updatedAt: Date.now()
	});
}
function In(e) {
	if (!game.modules.get("pf2e-toolbelt")?.active) return null;
	let t = e.getFlag("pf2e-toolbelt", "targetHelper");
	return t && typeof t == "object" ? t : null;
}
function Ln(e) {
	return On.get(e)?.data ?? null;
}
function Rn(e) {
	let t = Ln(e.id), n = In(e);
	return !t && !n ? null : {
		...t,
		...n
	};
}
function zn(e) {
	if (!e?.saveVariants) return [];
	let t = [];
	for (let n of Object.values(e.saveVariants)) n?.saves && t.push(...Object.entries(n.saves));
	return t;
}
function Bn(e) {
	return Qn.includes(e);
}
function Vn(e) {
	let t = e?.id;
	return typeof t == "string" && t.length > 0 ? t : null;
}
function Hn(e) {
	let t = e.match(/Token\.([^.]+)/);
	if (t?.[1]) return t[1];
	let n = e.split(".").at(-1);
	return n && n !== "Token" ? n : null;
}
function Un(e) {
	return !e?.targets || !Array.isArray(e.targets) ? /* @__PURE__ */ new Set() : new Set(e.targets.map(Hn).filter((e) => e !== null));
}
function Wn(e) {
	return new Set(zn(e).map(([e]) => e));
}
function Gn(e) {
	return zn(e).map(([, e]) => e?.success).filter(Bn);
}
function Kn(e) {
	return e?.saveVariants ? Object.values(e.saveVariants).some((e) => !!e && !!e.basic) : !1;
}
function qn(e, t) {
	let n = kn.get(e);
	if (n) {
		for (let e of t) n.expectedTargetIds.add(e);
		return n.updatedAt = Date.now(), n;
	}
	let r = {
		expectedTargetIds: t,
		savedTargetIds: /* @__PURE__ */ new Set(),
		saveOutcomes: /* @__PURE__ */ new Set(),
		hasBasicSave: !1,
		completed: !1,
		updatedAt: Date.now()
	};
	return kn.set(e, r), r;
}
function Jn(e) {
	return e.saveOutcomes.has("criticalFailure") || e.saveOutcomes.has("failure") ? !0 : e.hasBasicSave && e.saveOutcomes.has("success");
}
function Yn() {
	return y("experimentalToolbeltSaveIntegration");
}
function Xn(e, t, n) {
	return !n.ignoreToolbeltTargetHelperWait && Yn() && t && Rn(e)?.type === "spell";
}
async function Zn(e) {
	if (!Yn()) return;
	let t = e.message, n = game.messages.get(t.id) ?? t, r = Rn(n);
	if (r?.type !== "spell") return;
	let i = Un(r);
	if (i.size === 0) return;
	let a = qn(n.id, i);
	if (a.completed) return;
	a.hasBasicSave ||= Kn(r);
	for (let e of Wn(r)) a.savedTargetIds.add(e);
	for (let e of Gn(r)) a.saveOutcomes.add(e);
	let o = Vn(e.target);
	o && a.savedTargetIds.add(o);
	let s = Bn(e.data?.success) ? e.data?.success : null;
	s && a.saveOutcomes.add(s), a.updatedAt = Date.now();
	let c = n.flags?.["pf2e-toolbelt"];
	c && typeof c == "object" && Object.keys(c).length === 0 || a.expectedTargetIds.size > 0 && [...a.expectedTargetIds].every((e) => a.savedTargetIds.has(e)) && (a.completed = !0, Jn(a) && (await new Promise((e) => setTimeout(e, 100)), await hn(n, {
		ignoreToolbeltTargetHelperWait: !0,
		forceSaveSpellRoll: !0,
		forcedDegreeOfSuccess: "failure"
	})));
}
var Qn = [
	"criticalFailure",
	"failure",
	"success",
	"criticalSuccess"
];
//#endregion
//#region src/module/hooks/combatStartHook.ts
function $n() {
	An();
}
//#endregion
//#region src/module/feature/damageHandler/dyingHandling.ts
function er(t, n, r, i) {
	E(ChatMessage.create({
		flavor: game.i18n.format(`${e}.SETTINGS.${r}`, { name: n }),
		speaker: ChatMessage.getSpeaker({ actor: t }),
		whisper: a("metagame", "secretDamage") && !t?.hasPlayerOwner ? ChatMessage.getWhisperRecipients("GM").map((e) => e.id) : []
	}), i);
}
function tr(e, t, n, r, i) {
	let a = y("enableAutomaticMove"), o = game.combat && (a === "reaching0HPCharactersOnly" && e.type === "character" || a === "reaching0HP" && ["character", "npc"].includes(e.type)), s = y("autoRemoveDyingAtGreaterThanZeroHP"), c = y("autoRemoveUnconsciousAtGreaterThanZeroHP"), l = n <= 0 && r > 0;
	i && !i.startsWith("no") ? E((async () => {
		let a = await hr(e, foundry.utils.deepClone(t), n, r, i);
		m("Workbench increaseDyingOnZeroHP complete"), a || l ? (s && !s.startsWith("no") && (await new Promise((e) => setTimeout(e, 250)), await ir(e, !0, s), m("Workbench autoRemoveDyingAtGreaterThanZeroHP complete")), c && await ar(e, !0)) : o && n > 0 && r <= 0 && it(e);
	})(), "dyingHandlingPreUpdateActorHook") : l ? E((async () => {
		s && !s.startsWith("no") && await ir(e, !0, s), c && await ar(e, !0);
	})(), "dyingHandlingPreUpdateActorHook (hp restored)") : o && n > 0 && r <= 0 && it(e);
}
async function nr(e) {
	C() && e.slug === "dying" && e.parent && E(V(0, 0, e.parent, !1), "itemHandlingItemHook handleDying");
	let t = y("giveWoundedWhenDyingRemoved"), n = y("giveUnconsciousIfDyingRemovedAt0HP");
	t && (await gr(e), m("Workbench giveWoundedWhenDyingRemoved complete")), n && (await _r(e), m("Workbench giveUnconsciousIfDyingRemovedAt0HP complete"));
}
function rr(t, n) {
	let r = t.flavor, a = t.token;
	if (n && S(t, R("handleDyingRecoveryRollAllow", "player"), R("handleDyingRecoveryRollAllow", "gm")) && (r.includes(game.i18n.localize("PF2E.Recovery.critFailure")) || r.includes(game.i18n.localize("PF2E.Recovery.critSuccess")) || r.includes(game.i18n.localize("PF2E.Recovery.failure")) || r.includes(game.i18n.localize("PF2E.Recovery.success"))) && t.id === game.messages.contents.pop()?.id && a && a.actor && a.isOwner) {
		let n = i(t, "context.outcome") ?? "", r = te(t);
		if (!r) return;
		let o = a.actor?.getCondition("dying")?.value ?? 0, s = 0, c = "";
		switch (n) {
			case "criticalFailure":
				s += 2, c = game.i18n.localize("PF2E.CritFailure");
				break;
			case "criticalSuccess":
				s -= 2, c = game.i18n.localize("PF2E.CritSuccess");
				break;
			case "failure":
				s += 1, c = game.i18n.localize("PF2E.Failure");
				break;
			case "success":
				c = game.i18n.localize("PF2E.Success"), --s;
				break;
		}
		if (o > 0 || s !== 0) {
			E(V(s, o, r), "handleDyingRecoveryRoll handleDying");
			let n = t.rolls.reduce((e, t) => e + t.total, 0);
			E(ChatMessage.create({
				flavor: game.i18n.format(`${e}.SETTINGS.handleDyingRecoveryRoll.handled`, {
					outcome: c,
					defeated: a.combatant?.defeated ? game.i18n.format(`${e}.SETTINGS.handleDyingRecoveryRoll.defeated`, { name: a.actor?.name ?? "???" }) : "",
					roll: n
				}),
				speaker: t.speaker
			}), "handleDyingRecoveryRoll ChatMessage"), E(t.delete({ render: !1 }), "handleDyingRecoveryRoll delete");
		}
	}
}
async function V(t, n, r, i = r.combatant?.defeated) {
	let a = r.system.attributes.dying?.max, o = n + t >= (a ?? 4) && !i, s = n + t > 0 && !i;
	if (o) await r.increaseCondition("dying", {
		max: a ?? 4,
		value: a ?? 4
	}), await r.combatant?.toggleDefeated(), await r.unsetFlag(e, "dyingLastApplied"), m("dyingLastApplied cleared because dead");
	else if (s) {
		await r.increaseCondition("dying", {
			max: a ?? 4,
			value: Math.min(t, a ?? 4)
		});
		let i = r.getCondition("dying");
		if (i) {
			m(`dyingCounter was ${n} is ${i.value}`);
			let t = Date.now();
			await r.setFlag(e, "dyingLastApplied", t), m(`dyingLastApplied set to ${t}, dyingCounter was ${n} is ${i.value}`);
		}
	} else r.getCondition("dying") ? (await r.decreaseCondition("dying", { forceRemove: !0 }), await r.unsetFlag(e, "dyingLastApplied"), m("dyingLastApplied cleared because not dying")) : (await r.unsetFlag(e, "dyingLastApplied"), m("handleDying (clear flag, dying already removed)"));
}
async function ir(e, t, n) {
	let r = e.getCondition("dying");
	if (D(e) && r && !r.isLocked && t) {
		let t = r?.value || 0;
		r && t > 0 && !r.isLocked && H(e.type, n) && await V(0, 0, e);
	}
	return !0;
}
function H(e, t) {
	return !t.endsWith("ForCharacters") || ["character", "familiar"].includes(e);
}
async function ar(e, t) {
	let n = e.getCondition("unconscious");
	D(e) && t && n && !n.isLocked && await e.decreaseCondition("unconscious", { forceRemove: !0 });
}
function or(e) {
	let t = game.messages.contents.slice(-Math.min(10, game.messages.size));
	return y("autoGainDyingIgnoresTargeting") ? t : t.filter((t) => t.target?.actor.id === e.id);
}
function sr(e, t) {
	return e.filter((e) => i(e, "context.type") === t);
}
function cr(e) {
	return e.filter((e) => i(e, "strike.damaging"));
}
function lr(e) {
	return e.filter((e) => e.target?.actor && e.actor?.isEnemyOf(e.target?.actor));
}
function ur(e, t) {
	return e.findLast((e) => e.rolls?.[0]?.total >= t);
}
function dr(e, t) {
	let n = e.attributes.hp;
	if (n && n.value && game.messages.contents.length > 0 && H(e.type, t)) {
		let t = sr(or(e), "damage-roll"), r = ur(fr(lr(cr(t))), n.value);
		return (r === t?.reverse()[0] ? r : null) != null;
	}
	return !1;
}
function fr(e) {
	return e.filter((e) => i(e, "context.outcome") === "criticalSuccess");
}
function pr(t, n, r, i, a = !0, o = !1) {
	let s = t.itemTypes.feat.find((e) => e.slug === "orc-ferocity"), c = t.itemTypes.effect.find((e) => e.slug === "orc-ferocity-used"), l = t.itemTypes.feat.find((e) => e.slug === "incredible-ferocity"), u = t.itemTypes.feat.find((e) => e.slug === "undying-ferocity"), d = t.itemTypes.feat.find((e) => e.slug === "rampaging-ferocity");
	if (s && (!c || c.isExpired)) {
		foundry.utils.setProperty(n, "system.attributes.hp.value", 1), u && foundry.utils.setProperty(n, "system.attributes.hp.temp", Math.max(t.level, t.hitPoints?.temp ?? 0)), a = !0;
		let s = {
			type: "effect",
			name: game.i18n.localize(`${e}.effects.orcFerocityUsed`),
			img: `systems/${game.system.id}/icons/default-icons/alternatives/ancestries/orc.svg`,
			system: {
				slug: "orc-ferocity-used",
				tokenIcon: { show: !1 },
				duration: {
					value: l ? 1 : 24,
					unit: "hours",
					sustained: !1,
					expiry: "turn-start"
				}
			}
		};
		r.push(s), d && er(t, i, "autoGainDyingAtZeroHP.orcFerocityMessage", "handleOrcFerocity ChatMessage"), o = !0;
	}
	return {
		shouldIncreaseWounded: a,
		hpNowAboveZero: o
	};
}
function mr(t, n, r) {
	let i = t.itemTypes.feat.find((e) => e.slug === "deliberate-death"), a = t.itemTypes.effect.find((e) => e.slug === "deliberate-death-used");
	if (i && (!a || a.isExpired)) {
		let i = {
			type: "effect",
			name: game.i18n.localize(`${e}.effects.deliberateDeathUsed`),
			img: "icons/skills/melee/strike-dagger-skull-white.webp",
			system: {
				slug: "deliberate-death-used",
				tokenIcon: { show: !1 },
				duration: {
					value: 24,
					unit: "hours",
					sustained: !1,
					expiry: "turn-start"
				}
			}
		};
		n.push(i), er(t, r, "autoGainDyingAtZeroHP.deliberateDeathMessage", "handleDeliberateDeath ChatMessage");
	}
}
async function hr(e, t, n, r, i) {
	if (!D(e) || n <= 0 || r > 0) return r > 0;
	let a = `${e.token?.name ?? e.name}`, o = !1, s = 0, c = !1, l = [], u = y("nonLethalIsNotLethal");
	return {shouldIncreaseWounded: o, hpNowAboveZero: c} = pr(e, t, l, a, o, c), mr(e, l, a), !c && H(e.type, i) && (s = i?.startsWith("addWoundedLevel") ? (e.getCondition("wounded")?.value ?? 0) + 1 : 1), dr(e, i) && (s += 1), c && await e.update(t), o && await e.increaseCondition("wounded"), H(e.type, u) && !c && yr(e, u) && (e.hasCondition("unconscious") || await e.toggleCondition("unconscious"), s = 0), E(V(s, 0, e), "handleDyingOnZeroHP handleDying"), l.length > 0 && await e.createEmbeddedDocuments("Item", l), c;
}
async function gr(t) {
	let n = t.parent;
	if (C() && t.slug === "dying" && n) {
		let r = n.items, i = !1, a = !1, o = !1, s = !1;
		r && (i = r.find((e) => e.slug === "bounce-back"), a = n.itemTypes.effect.find((e) => e.slug === "bounce-back-used") ?? !1, o = r.find((e) => e.slug === "numb-to-death"), s = n.itemTypes.effect.find((e) => e.slug === "numb-to-death-used") ?? !1);
		let c = `${n.token?.name ?? n.name}`;
		if (o && (!s || s.isExpired)) {
			let t = {
				type: "effect",
				name: game.i18n.localize(`${e}.effects.numbToDeathUsed`),
				img: "icons/magic/death/hand-dirt-undead-zombie.webp",
				system: {
					slug: "numb-to-death-used",
					tokenIcon: { show: !1 },
					duration: {
						value: 24,
						unit: "hours",
						sustained: !1,
						expiry: "turn-start"
					}
				}
			};
			er(n, c, "giveWoundedWhenDyingRemoved.numbToDeathMessage", "giveWoundedWhenDyingRemoved ChatMessage"), await n.createEmbeddedDocuments("Item", [t]);
		} else if (i && (!a || a.isExpired)) {
			let t = {
				type: "effect",
				name: game.i18n.localize(`${e}.effects.bounceBackUsed`),
				img: "icons/magic/life/ankh-gold-blue.webp",
				system: {
					slug: "bounce-back-used",
					tokenIcon: { show: !1 },
					duration: {
						value: 24,
						unit: "hours",
						sustained: !1,
						expiry: "turn-start"
					}
				}
			};
			await n.createEmbeddedDocuments("Item", [t]);
		} else await t.parent?.increaseCondition("wounded");
	}
}
async function _r(e) {
	let t = e.parent;
	C() && e.slug === "dying" && y("giveUnconsciousIfDyingRemovedAt0HP") && t.system.attributes?.hp?.value === 0 && !t.hasCondition("unconscious") && (t.hasCondition("unconscious") || await e.parent?.toggleCondition("unconscious"));
}
function vr(e) {
	let t = y("autoGainDyingIfTakingDamageWhenAlreadyDying");
	if (t && !t.startsWith("no")) {
		let n = e.actor;
		if (n && D(n) && e.content?.includes("damage-taken")) {
			let e = Date.now(), r = O(n, "dyingLastApplied") || e;
			if (m(`dyingLastApplied is ${r}, now is ${e}`), !r?.between(e - 4e3, e)) {
				let i = n?.getCondition("dying")?.value ?? 0, a = 0;
				if (!t.startsWith("no") && i > 0) {
					let o = dr(n, t);
					H(n.type, t) && (a += 1, o && (a += 1)), m(`Before handleDying dyingLastApplied is ${r}, now is ${e}, dyingCounter was ${i} will increase by ${a}`), E(V(a, i, n), "dyingHandlingCreateChatMessageHook handleDying");
				}
			}
		}
	}
}
function yr(e, t) {
	let n = e.attributes.hp;
	if (n && n.value && game.messages.contents.length > 0 && H(e.type, t)) {
		let t = or(e).findLast((e) => i(e, "context.type") === "damage-roll"), r = t?.rolls?.[0]?.total ?? 0, a = t ? (i(t, "context.options") ?? []).includes("nonlethal") : !1;
		return (r >= n.value && a) ?? !1;
	}
	return !1;
}
//#endregion
//#region src/module/feature/reminders/checkAttackValidity.ts
function br(e) {
	return e?.traits.has("eidolon") && y("reminderCannotAttackIgnoreDeadEidolon");
}
function xr(e, t) {
	if (!Cr(e)) return !0;
	let n = Sr(e), r = wr(n, i(e, "context.options")?.filter((e) => e.startsWith("action:")));
	return r ? (Tr(n, r, i(e, "context.title"), t), !1) : !0;
}
function Sr(e) {
	return canvas?.scene?.tokens.get(e.speaker.token);
}
function Cr(e) {
	let t = (i(e, "context") ?? {})?.traits, n = i(e, "context.type");
	return e.actor && D(e.actor) && e.flags && e.author && [
		"spell-attack-roll",
		"attack-roll",
		"skill-check"
	].includes(n) && t?.some((e) => e === "attack");
}
function wr(t, n) {
	let r = t?.actor;
	if (!r) return "";
	let i = {
		dead: `${e}.SETTINGS.reminderCannotAttack.dead`,
		hasNoHp: `${e}.SETTINGS.reminderCannotAttack.hasNoHp`,
		defeated: `${e}.SETTINGS.reminderCannotAttack.defeated`,
		unconscious: `${e}.SETTINGS.reminderCannotAttack.unconscious`,
		dying: `${e}.SETTINGS.reminderCannotAttack.dying`,
		petrified: `${e}.SETTINGS.reminderCannotAttack.petrified`,
		restrained: `${e}.SETTINGS.reminderCannotAttack.restrained`
	};
	return r?.isDead && !br(r) ? i.dead : (r?.hitPoints?.value ?? 0) <= 0 && !br(r) && r?.type !== "hazard" ? i.hasNoHp : r?.hasCondition("dying") && !br(r) ? i.dying : game.combats.active?.combatant?.token === t && game.combats.active.combatant.defeated ? i.defeated : r?.hasCondition("unconscious") ? i.unconscious : r?.hasCondition("petrified") ? i.petrified : r?.hasCondition("restrained") && !["action:escape", "action:force-open"].some((e) => n.includes(e)) ? i.restrained : "";
}
function Tr(e, t, n, r) {
	let i = r ? "reminderCannotAttack.error" : "reminderCannotAttack.info", a = e.actor?.name || "(unknown)";
	ui.notifications[r ? "error" : "info"](Er(n, a, t, i));
}
function Er(t, n, r, i) {
	return game.i18n.format(`${e}.SETTINGS.${i}`, {
		title: t,
		actorName: n,
		reason: game.i18n.localize(r)
	});
}
//#endregion
//#region src/module/feature/reminders/index.ts
function Dr(e, t = 0) {
	let n = e.actor;
	if (n && D(n) && Or(n, t)) {
		let r = `${e.token?.name} has ${Math.max(Ar(n) - Math.max(n.getCondition("stunned")?.value ?? 0, n.getCondition("slowed")?.value ?? 0, t), 0)} actions remaining.`;
		E(ChatMessage.create({
			flavor: r,
			whisper: n?.hasPlayerOwner ? [] : ChatMessage.getWhisperRecipients("GM").map((e) => e.id)
		}, {}), "actionsReminder ChatMessage"), ui.notifications.info(r);
	}
}
function Or(e, t) {
	let n = R("actionsReminderAllow", "player") && e?.hasPlayerOwner, r = R("actionsReminderAllow", "gm") && !e?.hasPlayerOwner;
	return (n || r) && kr(e, t);
}
function kr(e, t) {
	return e.hasCondition("stunned", "slowed", "quickened") || t > 0;
}
function Ar(e) {
	return e.traits?.has("minion") ? 2 : 3 + +!!e.hasCondition("quickened");
}
async function jr(t, n) {
	if (!t?.actor || n !== game.user.id && !D(t?.actor)) return 0;
	let r = 0, i = [t?.actor, ...ue(t?.actor)];
	for (let n of i) {
		let i = n.getCondition("stunned")?.value ?? 0;
		if (i) {
			r = Math.min(i, Ar(n));
			for (let e = 0; e < r; e++) await n?.decreaseCondition("stunned");
			let a = t?.combat;
			if (!a) continue;
			await n?.setFlag(e, "stunReduction", {
				combat: a.id,
				round: a.round,
				reducedBy: r
			});
		}
	}
	return r;
}
function Mr(t, n) {
	let r = i(t, "context");
	if (t.actor && D(t.actor) && t.flags && t.author && r && r.type && ["spell-attack-roll", "attack-roll"].includes(r.type)) {
		let i = t.author.targets;
		if (!i || i.size === 0) {
			let t = r?.title;
			if (n === "reminder") {
				let n = game.i18n.format(`${e}.SETTINGS.reminderTargeting.info`, { title: t });
				ui.notifications.info(n);
			} else if (n === "mustTarget") {
				let n = game.i18n.format(`${e}.SETTINGS.reminderTargeting.error`, { title: t });
				return ui.notifications.error(n), !1;
			}
		}
	}
	return !0;
}
//#endregion
//#region src/module/feature/reminders/reminderBreathWeapon.ts
async function Nr(e) {
	let t = e.content, n = canvas?.scene?.tokens.get(e.speaker.token);
	if (C() && t && game.combats && game.combats.active && n?.actor) {
		let r;
		if (t.includes("fa-solid fa-dice-d20") && t.includes("data-roll") && t.includes("data-tooltip")) {
			let e = t.match(/<i class="fa-solid fa-dice-d20"><\/i>(\d).* rounds/);
			e && e.length > 1 && (r = Number(e[1]));
		} else if (!i(e, "origin.rollOptions")?.includes("polymorph")) {
			let e = t.match(/<a\b[^>]*class="inline-roll gmroll"[^>]*>/)?.[0]?.match(/data-formula="(1d\d+)"/);
			if (e?.[1]) {
				let t = e[1];
				Roll.validate(t) && (r = (await new Roll(t).roll()).total);
			} else {
				let e = t.match(/1d([46])( rounds| recharge|<\/a> rounds)/i);
				if (e?.[1]) {
					let t = `1d${e[1]}`;
					Roll.validate(t) && (r = (await new Roll(t).roll()).total);
				}
			}
		}
		if (r) {
			let e = await Pr(n.actor, t, r);
			await n.actor?.createEmbeddedDocuments("Item", [e]);
		}
	}
}
async function Pr(t, n, r) {
	let i = n.match(/>(.*?) <span class="action-glyph"/);
	return {
		type: "effect",
		name: i ? game.i18n.localize(`${e}.SETTINGS.reminderBreathWeapon.used`) + i[1] : game.i18n.localize(`${e}.SETTINGS.reminderBreathWeapon.used`) + game.i18n.localize(`${e}.SETTINGS.reminderBreathWeapon.defaultName`),
		img: `systems/${game.system.id}/icons/spells/dragon-breath.webp`,
		system: {
			tokenIcon: { show: !0 },
			duration: {
				value: r,
				unit: "rounds",
				sustained: !1,
				expiry: "turn-start"
			},
			description: { value: `<h2>${game.i18n.localize(`${e}.SETTINGS.reminderBreathWeapon.name`)}</h2>` },
			source: { value: game.i18n.localize(`${e}.SETTINGS.reminderBreathWeapon.defaultName`) },
			rules: [],
			slug: `xdy-breath-weapon-reminder-${foundry.utils.randomID()}`,
			unidentified: y("reminderBreathWeaponHidden") && !game.actors?.party?.members.map((e) => e?.id).includes(t.id),
			traits: { value: [] },
			level: { value: t.level ?? 0 },
			badge: null,
			context: null
		}
	};
}
//#endregion
//#region src/module/hooks/createChatMessageHook.ts
function Fr(e) {
	return i(e, "context.type") === "damage-taken";
}
function Ir(e) {
	yn(), y("reminderCannotAttack") === "reminder" && xr(e, !1);
	let t = y("reminderTargeting");
	["no", "reminder"].includes(t) && Mr(e, t), w(e) || Fr(e) || (O(e, "noAutoDamageRoll") || E(hn(e), "autoRollDamage"), y("reminderBreathWeapon") && E(Nr(e), "reminderBreathWeapon")), vr(e);
}
//#endregion
//#region src/module/feature/qolHandler/index.ts
function Lr(t) {
	if (!(t instanceof HTMLElement)) return;
	let n = t.querySelectorAll(".card-content:not(span.flavor-text *)");
	if (n.length > 0) {
		let r = game.i18n.localize(`${e}.effectItem`);
		if (y("autoCollapseItemChatCardContent") === "collapsedDefault") {
			n.forEach((e) => e.style.display = "none");
			let e = n[0].parentElement?.children;
			if (e?.[0] && e[0].insertAdjacentHTML("beforeend", Vr), y("autoCollapseItemChatCardMoveEffectLinks")) {
				let e = [], n = Array.from(t.getElementsByTagName("p"));
				for (let t of n) {
					let n = t.querySelector("a.content-link");
					n && n?.getAttribute("data-tooltip")?.includes(r) && e.push(t);
				}
				let i = t.closest(".chat-message");
				i && e.length > 0 && (e[0].classList.add("item-block-line"), i.append(...e));
			}
		}
		let i = t.querySelector(".card-header");
		i instanceof HTMLElement && i.addEventListener("click", (e) => {
			e.preventDefault(), i.closest(".chat-message")?.querySelectorAll(".card-content")?.forEach((e) => {
				e instanceof HTMLElement && (e.style.display = e.style.display === "none" ? "block" : "none");
			}), Rr(i);
		});
	}
}
function Rr(e) {
	let t = e.querySelectorAll(".fa-eye"), n = e.querySelectorAll(".fa-eye-slash");
	for (let e of Array.from(t)) e.classList.toggle("fa-eye-slash"), e.classList.toggle("fa-eye");
	for (let e of Array.from(n)) e.classList.toggle("fa-eye-slash"), e.classList.toggle("fa-eye");
}
function zr(e) {
	let t, n = e.querySelectorAll(".roll-note");
	for (t of Array.from(n)) t.style.display = t.style.display === "none" ? "block" : "none";
	Rr(e);
}
function Br(e) {
	let t = e.querySelectorAll(".action");
	if (t.length > 0) {
		let n = e.querySelectorAll(".roll-note");
		if (n.length > 0) {
			if (y("autoCollapseItemActionChatCardContent") === "collapsedDefault") {
				for (let e of Array.from(n)) e.style.display = "none";
				let e = t[0].parentElement?.children;
				e?.[1] && e[1].insertAdjacentHTML("beforeend", Vr);
			}
			e.addEventListener("click", (t) => {
				t.target?.matches("h4.action, .fa-eye, .fa-eye-slash, strong") && (t.preventDefault(), zr(e));
			});
		}
	}
}
var Vr = " <i style=\"font-size: small; max-width: min-content\" class=\"fa-solid fa-eye-slash\">";
function Hr(e) {
	let t = e.querySelectorAll(".roll-note");
	if (t.length > 0) {
		if (y("autoCollapseItemAttackChatCardContent") === "collapsedDefault") {
			for (let e of t) e.style.display = "none";
			t[0].parentNode?.parentNode?.children[0].insertAdjacentHTML("beforeend", Vr);
		}
		e.addEventListener("click", (t) => {
			t.target.matches("h4.action, .fa-eye, .fa-eye-slash, strong") && (t.preventDefault(), zr(e));
		});
	}
}
var U = /* @__PURE__ */ new Set(), Ur = 10;
Hooks.on("createChatMessage", (e) => {
	if (w(e) && (U.add(e.id), U.size > Ur)) {
		let e = Array.from(U)[0];
		U.delete(e);
	}
}), Hooks.on("deleteChatMessage", (e) => {
	U.delete(e.id);
});
function Wr(e, t, n) {
	let r = t.querySelectorAll(".dice-tooltip");
	if (r.length !== 0) {
		if (n === "expandedAll") {
			r.forEach((e) => e.style.display = "block");
			return;
		}
		if (n.startsWith("expandedNew")) if (n.endsWith("est")) {
			let t = Array.from(U).pop();
			e.id === t && r.forEach((e) => e.style.display = "block");
		} else U.has(e.id) && r.forEach((e) => e.style.display = "block");
	}
}
var Gr = {
	common: "Common",
	uncommon: "Uncommon",
	rare: "Rare",
	unique: "Unique"
}, Kr = [
	"common",
	"uncommon",
	"rare",
	"unique"
];
function qr(e, t) {
	let n = t ? "Pl" : "Abs";
	return `mystifyThreshold${Gr[e]}${n}`;
}
var Jr = /* @__PURE__ */ new Set([
	"armor",
	"shield",
	"consumable",
	"backpack",
	"book",
	"equipment",
	"treasure",
	"weapon"
]);
async function Yr(e, t = y("npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel"), n = {}) {
	if (!e?.items) return;
	let r = t ? game.actors?.party?.level ?? 0 : 0, i = {};
	for (let e of Kr) i[e] = n[e] ?? Number.parseInt(y(qr(e, t)));
	let a = [];
	for (let t of e.items) {
		if (!Jr.has(t.type)) continue;
		let e = t;
		if (!e.isIdentified || e.isTemporary || !(e.isMagical || e.isAlchemical)) continue;
		let n = i[e.rarity];
		if (n === void 0 || n === 999) continue;
		let o = r + n;
		e.level < o || a.push({
			_id: t.id,
			"system.identification.status": "unidentified",
			"system.identification.unidentified": e.getMystifiedData("unidentified")
		});
	}
	a.length > 0 && await e.updateEmbeddedDocuments("Item", a);
}
//#endregion
//#region src/module/hooks/createTokenHook.ts
async function Xr(e, ...t) {
	game.user?.isGM && y("npcMystifier") && E(Oe(e), "tokenCreateMystification"), game.user?.isGM && a("automation", "lootableNPCs") && y("npcMystifyAllPhysicalMagicalItems") === "onScene" && e.actor && e.actor.isOfType("npc") && e.actor.items && e.actor.items.size > 0 && await Yr(e.actor);
}
//#endregion
//#region src/module/hooks/deleteCombatHook.ts
async function Zr(e, t) {
	An(), y("sheatheHeldItemsAfterEncounter") && await Qr(e);
}
async function Qr(t) {
	let n = y("sheatheHeldItemsAfterEncounterTypes").split(",").map((e) => e.trim()).filter((e) => e);
	for (let r of t.combatants) {
		let t = r.actor;
		if (!t) continue;
		let i = t.items?.filter((e) => e.isHeld);
		if (!i || i.length === 0) continue;
		let a = i.filter((e) => n.includes(e.type));
		if (a.length > 0) {
			for (let e of a) await t.changeCarryType(e, {
				carryType: "worn",
				handsHeld: 0,
				inSlot: !1
			});
			re(t, a, `${e}.SETTINGS.sheatheHeldItemsAfterEncounter.message`, "sheatheHeldItems ChatMessage");
		}
	}
}
//#endregion
//#region src/module/hooks/deleteItemHook.ts
async function $r(e, t) {
	await nr(e);
}
//#endregion
//#region src/module/feature/conditionHandler/index.ts
async function ei(e, t) {
	if (!e || !e.actor || t !== game.user.id && !D(e.actor)) return;
	let n = [e.actor, ...ue(e.actor)];
	for (let e of n) {
		let t = O(e, "condition.frightened.min", 0), n = e.getCondition("frightened"), r = n?.value ?? 0, i = ["dwarven-doughtiness", "calm-and-centered"];
		if (n && r > 0 && !n.isLocked) {
			let n = i.some((t) => x(e, t)) ? 2 : 1;
			for (let i = 0; i < n && r - i > t; i++) await e.decreaseCondition("frightened");
		}
	}
}
//#endregion
//#region src/module/hooks/pf2eEndTurnHook.ts
function ti(e, t, n) {
	y("decreaseFrightenedConditionEachTurn") && E(ei(e, n), "reduceFrightened");
}
//#endregion
//#region src/module/hooks/pf2eRerollHook.ts
function ni(e, t, n, r) {
	let i = r.keep ?? "new";
	if (n?.slug !== "hero-points" || i !== "new") return;
	let a = t.dice.find((e) => e instanceof foundry.dice.terms.Die && e.number === 1 && e.faces === 20), o = a?.results.find((e) => e.active && e.result <= 10);
	if (a && o && y("heroPointRules") === "keeleysHeroPointRule") t.terms.push(foundry.dice.terms.OperatorTerm.fromData({
		class: "OperatorTerm",
		operator: "+",
		evaluated: !0
	}), foundry.dice.terms.NumericTerm.fromData({
		class: "NumericTerm",
		number: 10,
		evaluated: !0
	})), t._total += 10, t.reroll(), t.options.keeleyAdd10 = !0;
	else if (a && o && y("heroPointRules") === "heroicRerolls") {
		let e = o.result;
		o.result = 10, t._total = t._total - e + 10, t.options.heroicReroll = !0;
	} else y("heroPointRules") === "useHighestHeroPointRoll" && (r.keep = "higher");
}
//#endregion
//#region src/module/hooks/pf2eToolbeltRollSaveHook.ts
function ri(e) {
	E(Zn(e), "pf2eToolbeltRollSaveHook");
}
//#endregion
//#region src/module/hooks/pf2eStartTurnHook.ts
async function ii(e, t, n) {
	let r = y("actionsReminderAllow");
	if (y("autoReduceStunned")) {
		let t = await jr(e, n);
		r !== "none" && Dr(e, t);
	} else r !== "none" && Dr(e, 0);
}
//#endregion
//#region src/module/hooks/pf2eSystemReadyHook.ts
async function ai() {
	let e = y("housepatcher");
	game.user.isGM && e && await le(e);
}
//#endregion
//#region src/module/feature/qolHandler/buildPublicSpellMessage.ts
var oi = "PF2E.RecallKnowledge.Label", si = "PF2E.Trait", ci = {
	arcane: "arcana",
	divine: "religion",
	occult: "occultism",
	primal: "nature"
};
function li(t, n, r, i, a, o, s, c, l) {
	if (!t) return game.i18n.localize(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.secondPartNoRk`);
	let u = di(n, r, i, a);
	return c && (u += fi(t, l)), u += pi(t, i), u += mi(o, t, s), u;
}
function di(t, n, r, i) {
	let a = vi(r);
	return game.i18n.localize(game.i18n.format(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.firstPart`, {
		tokenName: t,
		type: n,
		traditionString: a,
		spellUUID: i
	}));
}
function fi(t, n) {
	let r = n.split(",").map((e) => e.trim()).filter((e) => e), i = Object.values(t.system.traits.value).map((e) => String(e)).filter((e) => !r.includes(e)).map((e) => vi(e)).sort().join(", ");
	return game.i18n.localize(game.i18n.format(`${e}.SETTINGS.castPrivateSpellWithPublicMessageShowTraits.traitPart`, { traits: i }));
}
function pi(t, n) {
	let r = t.system.level.value, i = gi(r) + _i(t.system.traits?.rarity ?? "common"), a = ci[n] ?? "";
	return game.i18n.format(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.secondPartRK`, {
		skill: a,
		dcRK: i,
		rk: `&#123;${game.i18n.localize(oi)}\t&#125;`
	});
}
function mi(t, n, r) {
	let i = document.createElement("div");
	i.innerHTML = t;
	let a = i.querySelectorAll("button[data-action=\"spell-save\"]");
	if (a.length !== 1) return "";
	let o = a[0], s = o.getAttribute("data-save") ?? "";
	return game.modules.find((e) => e.id === "pf2e-target-helper")?.active ? game.i18n.format(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.noButtonSavePart`, {
		dataSave: s,
		basic: r ? game.i18n.localize(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.basic`) : ""
	}) : hi(s, o.getAttribute("data-dc") ?? "", n, r);
}
function hi(t, n, r, i) {
	let a = Object.values(r.system.traits.value).map((e) => game.pf2e.system.sluggify(String(e))).sort().join(",");
	return game.i18n.format(`${e}.SETTINGS.castPrivateSpellWithPublicMessage.savePart`, {
		dataSave: t,
		dataDC: n,
		traits: a,
		basic: i ? "|basic:true" : ""
	});
}
function gi(e) {
	return {
		1: 15,
		2: 18,
		3: 20,
		4: 23,
		5: 26,
		6: 28,
		7: 31,
		8: 34,
		9: 36,
		10: 39
	}[e] ?? 0;
}
function _i(e) {
	return {
		uncommon: 2,
		rare: 5,
		unique: 10,
		common: 0
	}[e] ?? 0;
}
function vi(e) {
	return e && game.i18n.localize(`${si}${e.charAt(0).toUpperCase() + e.slice(1)}`);
}
//#endregion
//#region src/module/feature/qolHandler/handlePrivateSpellcasting.ts
var yi = `${e}.SETTINGS.castPrivateSpellWithPublicMessage`;
async function bi(e, t) {
	let n = xi(), r = i(t, "origin.uuid"), a = fromUuidSync(r), o = Si(a);
	if (n.autoRevealIfKnown && o && o.length > 0) {
		n.autoRevealMembers && Ti(t, o, e), n.autoRevealOverrideGMRoll && t.applyRollMode("publicroll");
		return;
	}
	if (Oi(e, t), n.publicMessage && !ki()) {
		let { content: i, flags: o } = await Ei(t, a, r, e, n), s = game.users.activeGM?.id, c = n.showToGM ? [] : game.users.filter((e) => e.active && e.id !== s).map((e) => e.id);
		await ChatMessage.create({
			author: game.userId,
			content: i,
			flags: o,
			whisper: c
		});
	}
}
function xi() {
	return {
		autoRevealIfKnown: y("castPrivateSpellAutoRevealIfKnown"),
		autoRevealMembers: y("castPrivateSpellAutoRevealPartyMembersThatKnowSpell"),
		autoRevealOverrideGMRoll: y("castPrivateSpellAutoRevealOverrideGMRollMode"),
		publicMessage: y("castPrivateSpellWithPublicMessage"),
		showToGM: y("castPrivateSpellWithPublicMessageShowToGM"),
		showTraits: y("castPrivateSpellWithPublicMessageShowTraits"),
		traitsBlocklist: y("castPrivateSpellWithPublicMessageTraitsBlocklist") ?? ""
	};
}
function Si(e) {
	if (e) return game.actors?.party?.members?.filter((t) => t?.items?.some((t) => Ci(t, e))).map((e) => e?.name);
}
function Ci(e, t) {
	if (e.slug !== t.slug || !e.isOfType("spell")) return !1;
	let n = e;
	return n.spellcasting ? wi(n) : !1;
}
function wi(e) {
	let t = e.spellcasting;
	if (!t?.isPrepared) return !0;
	let n = t?.system?.slots;
	return n ? Object.values(n).some((t) => t.prepared.some((t) => t.id === e.id)) : !1;
}
function Ti(e, t, n) {
	let r = document.createElement("div");
	r.innerHTML = e.content;
	let i = r.querySelector("hr.item-block-divider");
	if (i) {
		let e = game.i18n.format(`${yi}.knownBy`, { spellHavers: t?.join(",") ?? "" }), n = document.createElement("div");
		n.innerHTML = e, i.insertAdjacentElement("afterend", n);
	}
	let a = r.innerHTML;
	a !== e.content && (n.content = a, e.updateSource({ content: a }));
}
async function Ei(e, t, n, r, a) {
	let o = game.i18n.localize(`${yi}.they`), s = game.pf2e.settings.tokens.nameVisibility ? o : e.alias ?? e.token?.name ?? e.actor?.name ?? o, c = i(e, "origin.type") ?? "spell", l = i(e, "casting.tradition") ?? "", u = i(e, "context.options")?.includes("item:defense:basic");
	return {
		content: li(t, s, c, l, n, r.content ?? "", u, a.showTraits, a.traitsBlocklist),
		flags: Di(e)
	};
}
function Di(e) {
	return { "xdy-pf2e-workbench": { privateSpell: {
		originUuid: i(e, "origin.uuid"),
		originCastRank: i(e, "origin.castRank"),
		originMessageUuid: e.uuid
	} } };
}
function Oi(e, t) {
	e.style = CONST.CHAT_MESSAGE_STYLES.OTHER, e.whisper = ChatMessage.getWhisperRecipients("GM").map((e) => e.id), game.user.isGM || e.whisper.push(game.user.id), t.updateSource(e);
}
function ki() {
	let e = foundry.helpers.interaction.KeyboardManager;
	return game.keyboard.isModifierActive(e.MODIFIER_KEYS.SHIFT);
}
//#endregion
//#region src/module/hooks/preCreateChatMessageHook.ts
var Ai = [
	"ControlLeft",
	"ControlRight",
	"MetaLeft",
	"MetaRight",
	"Meta",
	"OsLeft",
	"OsRight"
], ji = (e, t, n, r) => {
	let a = !0, o = y("reminderTargeting") === "mustTarget", s = y("reminderCannotAttack");
	if (y("castPrivateSpell") && i(e, "casting.id")) {
		let n = Ai.some((e) => game?.keyboard.downKeys.has(e)), r = Mi(game.actors?.party?.members?.some((t) => t?.id === e?.actor?.id) ?? !1, e);
		(n && !r || !n && r) && E(bi(t, e), "handlePrivateSpellcasting");
	}
	let c = y("applyPersistentDamage"), l = y("applyPersistentHealing");
	return (c || l) && _n(e), o && (a = Mr(e, y("reminderTargeting"))), a && s === "cancelAttack" && (a = xr(e, !0)), a;
};
function Mi(e, t) {
	let n = t.actor?.type === "npc", r = t.actor?.alliance === "party", i = y("castPrivateSpellAlwaysFor") === "npcs", a = y("castPrivateSpellAlwaysFor") === "nonAllies", o = y("castPrivateSpellAlwaysFor") === "nonPartymembers";
	return n && i || !r && a || !e && o;
}
//#endregion
//#region src/module/feature/spells/flags.ts
var W = "learnSpellFailures";
function G(e) {
	return e.replace(/\./g, "!");
}
async function Ni(e) {
	return e.getFlag("xdy-pf2e-workbench", W) ?? {};
}
async function Pi(t, n, r) {
	let i = await Ni(t);
	i[G(n)] = {
		level: r,
		timestamp: game.time.worldTime
	};
	try {
		await t.setFlag(e, W, i);
	} catch (e) {
		_("setLearnFailure: setFlag failed", e);
	}
}
async function Fi(t, n) {
	let r = await Ni(t);
	delete r[G(n)];
	try {
		Object.keys(r).length === 0 ? await t.unsetFlag(e, W) : await t.setFlag(e, W, r);
	} catch (e) {
		_("clearLearnFailure: flag write failed", e);
	}
}
function Ii(e, t) {
	return (e.getFlag("xdy-pf2e-workbench", W) ?? {})[G(t)];
}
function Li(e, t) {
	return Ii(e, t)?.level;
}
//#endregion
//#region src/module/feature/spells/helpers.ts
var K = `${e}.spellLearn`, Ri = "cantrip", zi = {
	criticalSuccess: "learnResultCriticalSuccess",
	success: "learnResultSuccess",
	failure: "learnResultFailure",
	criticalFailure: "learnResultCriticalFailure",
	skipped: "learnSpellSkipped",
	alreadyKnown: "learnSpellBatchLearnAlreadyKnown"
};
function Bi(e) {
	let t = e.spellcasting;
	return t ? [...t] : [];
}
function Vi(e) {
	return e.system.details.level.value;
}
function Hi(e, t) {
	let n = Ii(e, t);
	return !(!n || Vi(e) > n.level || x(e, "magical-shorthand") && game.time.worldTime - n.timestamp >= 604800);
}
//#endregion
//#region src/module/utils/locks.ts
var Ui = /* @__PURE__ */ new Set();
function Wi(e) {
	return Ui.has(e);
}
async function Gi(e, t) {
	Ui.add(e);
	try {
		return await t();
	} finally {
		Ui.delete(e);
	}
}
//#endregion
//#region src/module/feature/spells/spellChatUtils.ts
function q(e, t, n) {
	let r = game.i18n.format(`${K}.${t}`, n);
	E(ChatMessage.create({
		content: r,
		speaker: ChatMessage.getSpeaker({ actor: e })
	}), "postLearnChatMessage");
}
async function Ki(e, t, n) {
	let r = n ? {
		...t,
		system: {
			...t.system ?? {},
			location: { value: n }
		}
	} : t;
	return Gi(e.id, async () => {
		let t = await e.createEmbeddedDocuments("Item", [r]);
		return Array.isArray(t) && t.length > 0 ? t[0]?.uuid ?? null : null;
	});
}
//#endregion
//#region src/module/feature/spells/economyHandler.ts
var J = {
	cp: 1,
	sp: 10,
	credits: 10,
	gp: 100,
	pp: 1e3
};
function qi(e) {
	return (e.cp ?? 0) + (e.sp ?? 0) * J.sp + (e.gp ?? 0) * J.gp + (e.pp ?? 0) * J.pp + (e.credits ?? 0) * J.credits;
}
function Ji() {
	return r() === n.SF2E ? J.credits : J.gp;
}
function Y(e) {
	if (r() === n.SF2E) {
		let t = Math.ceil(e / J.credits);
		return `${t} ${t === 1 ? "credit" : "credits"}`;
	}
	return `${e / J.gp} gp`;
}
function Yi(e, t) {
	let n = e.inventory ?? null;
	return n ? qi(n.currency) >= t : !1;
}
async function Xi(e, t) {
	let i = e.inventory ?? null;
	if (!i) return g("economyHandler: no inventory for actor; cannot deduct cost"), {
		ok: !1,
		debt: t
	};
	let a = qi(i.currency), o = r() === n.SF2E ? { sp: Math.ceil(t / J.sp) } : { gp: Math.ceil(t / J.gp) };
	if (!await ae(() => i.removeCurrency(o, { byValue: !0 }), !1, "economyHandler: removeCurrency")) return {
		ok: !1,
		debt: t
	};
	let s = a - qi(i.currency);
	if (s >= t) return {
		ok: !0,
		debt: 0
	};
	let c = t - s;
	return g(`economyHandler: insufficient funds to deduct ${Y(t)}; ${Y(c)} remaining`), {
		ok: !1,
		debt: c
	};
}
function Zi(e) {
	return e.costCopper <= 0 || y("allowDebtItems") || Yi(e.actor, e.costCopper) ? !1 : (q(e.actor, "insufficientFundsForLearn", {
		actor: e.actor.name,
		cost: Y(e.costCopper),
		spellName: e.spellName,
		collectionName: e.collectionName
	}), !0);
}
function Qi(e, t) {
	let n = Y(e), r = t?.spellName, i = t?.collectionName;
	return i ? r ? game.i18n.format(`${K}.debtItemDescription`, {
		amount: n,
		spells: r,
		collectionName: i
	}) : game.i18n.format(`${K}.debtItemDescriptionNoSpells`, {
		amount: n,
		collectionName: i
	}) : r ? game.i18n.format(`${K}.debtItemDescriptionForSpell`, {
		amount: n,
		spellName: r
	}) : game.i18n.format(`${K}.debtItemDescriptionNoSpellbook`, { amount: n });
}
async function $i(e, t, n) {
	let r = Y(t), i = {
		name: game.i18n.format(`${K}.debtItemName`, { amount: r }),
		type: "equipment",
		img: "icons/sundries/misc/piggybank.webp",
		system: {
			description: { value: Qi(t, n) },
			price: { value: {
				cp: 0,
				sp: 0,
				gp: 0,
				pp: 0
			} },
			quantity: 1,
			slug: `xdy-spell-debt-item-${foundry.utils.randomID(8)}`
		}
	};
	return ae(async () => {
		let t = (await e.createEmbeddedDocuments("Item", [i]))?.[0] ?? null;
		return t && q(e, "debtItemCreated", {
			actor: e.name,
			amount: r,
			spellName: n?.spellName
		}), t;
	}, null, "economyHandler: createDebtItem");
}
async function ea(e) {
	if (Zi(e)) return !1;
	let t = await Xi(e.actor, e.costCopper);
	return t.ok ? !0 : !!await $i(e.actor, t.debt, {
		spellName: e.spellName,
		collectionName: e.collectionName
	});
}
//#endregion
//#region src/module/feature/spells/spellData.ts
function ta(e) {
	return e.system;
}
function X(e) {
	let t = e, n = t.sourceId ?? t._stats?.compendiumSource;
	if (n) return `sourceId:${n}`;
	let r = ta(e)?.slug;
	return r ? `slug:${r}` : null;
}
var na = {
	[Ri]: 15,
	1: 15,
	2: 18,
	3: 20,
	4: 23,
	5: 26,
	6: 28,
	7: 31,
	8: 34,
	9: 36,
	10: 41
}, ra = {
	common: 0,
	uncommon: 2,
	rare: 5,
	unique: 10
}, ia = {
	[Ri]: 1,
	1: 1,
	2: 3,
	3: 8,
	4: 18,
	5: 35,
	6: 70,
	7: 150,
	8: 325,
	9: 750,
	10: 3500
};
function aa(e) {
	return na[e] ?? 15;
}
function oa(e) {
	return ra[e?.toLowerCase()] ?? 0;
}
function sa(e, t, n = 0) {
	return aa(e) + oa(t.find((e) => ra[e.toLowerCase()] !== void 0) ?? "common") + n;
}
function ca() {
	return y("learnSpellDcAdjustment") ?? 0;
}
function la(e) {
	return (ia[e] ?? 1) * 2 * Ji();
}
function ua(e, t) {
	if (t && x(t, "magical-shorthand")) return 1 / 6;
	if (e === "cantrip") return 1;
	let n = Number(e);
	return Number.isFinite(n) && n > 0 ? n : 1;
}
function da(e) {
	let t = ta(e), n = t?.level?.value;
	if (n === void 0) return null;
	let r = t?.traits?.value ?? [];
	return {
		traits: r,
		traditions: t?.traits?.traditions ?? [],
		rankKey: r.includes("cantrip") || n <= 0 ? Ri : String(n),
		spellName: e.name ?? ""
	};
}
function fa(e) {
	return "toObject" in e ? e.toObject() : e;
}
//#endregion
//#region src/module/feature/spells/spellActorQueries.ts
function* pa(e) {
	for (let t of Bi(e)) {
		let e = t.spells?.contents ? [...t.spells.contents] : [];
		for (let t of e) {
			let e = X(t);
			e && (yield [t, e]);
		}
	}
}
function ma(e, t) {
	if (!t) return null;
	for (let [n, r] of pa(e)) if (r === t) return n;
	return null;
}
function ha(e, t) {
	return ma(e, t) !== null;
}
function ga(e) {
	return Bi(e).some((e) => e.isSpontaneous);
}
function _a(e) {
	return (e.tradition ?? e.system?.tradition?.value) || null;
}
function va(e, t) {
	if (t.length === 0) return !0;
	for (let n of Bi(e)) {
		let e = _a(n);
		if (e && t.includes(e)) return !0;
	}
	return !1;
}
function ya(e) {
	let t = _a(e) ?? "";
	return e.isFocusPool ? {
		name: e.name,
		tradition: t,
		type: "focus"
	} : e.isSpontaneous ? {
		name: e.name,
		tradition: t,
		type: "spontaneous"
	} : e.isPrepared ? {
		name: e.name,
		tradition: t,
		type: "prepared"
	} : {
		name: e.name,
		tradition: t,
		type: "spellcasting"
	};
}
function ba(e) {
	let t = [];
	for (let n of Bi(e)) {
		let e = _a(n);
		e && t.push({
			item: n,
			tradition: e
		});
	}
	return t;
}
function xa(e, t) {
	return t.length === 0 || t.includes(e);
}
function Sa(e, t, n) {
	let r = ba(e);
	if (r.length === 0) return null;
	if (n) {
		let e = r.find((e) => e.item.id === n);
		if (e && xa(e.tradition, t)) return e.item;
		if (e) return null;
	}
	return r.find((e) => xa(e.tradition, t))?.item ?? null;
}
async function Ca(e, t, n) {
	let r = ba(e);
	if (r.length === 0) return null;
	if (n) {
		let e = r.find((e) => e.item.id === n);
		if (e && xa(e.tradition, t)) return e.item;
		if (e) return null;
	}
	let i = r.filter((e) => xa(e.tradition, t));
	if (i.length === 0) return null;
	if (i.length === 1) return i[0].item;
	let a = i.map((e) => ({
		value: e.item.id,
		label: e.item.name
	})), o = await foundry.applications.api.DialogV2.wait({
		window: { title: game.i18n.localize(`${K}.pickEntryTitle`) },
		content: `<p>${game.i18n.localize(`${K}.pickEntryMessage`)}</p>`,
		buttons: a.map((e) => ({
			action: e.value,
			label: e.label
		}))
	});
	return o ? i.find((e) => e.item.id === o)?.item ?? null : null;
}
var wa = {
	arcane: "arcana",
	divine: "religion",
	occult: "occultism",
	primal: "nature"
};
function Ta(e, t) {
	let n = wa[_a(t) ?? ""];
	return n ? e.skills?.[n] ?? null : null;
}
//#endregion
//#region src/module/feature/spells/dialogHelper.ts
function Ea(e, t) {
	return t ? game.i18n.format(`${K}.${e}`, t) : game.i18n.localize(`${K}.${e}`);
}
function Da(e) {
	return e < 1 ? game.i18n.format(`${K}.learnSpellTime10Minutes`, { minutes: Math.round(e * 60) }) : game.i18n.format(`${K}.learnSpellTimeHours`, { hours: e });
}
async function Oa(e, t, n, r) {
	let i = r?.yes ? game.i18n.localize(`${K}.${r.yes}`) : game.i18n.localize(`${K}.yes`), a = r?.no ? game.i18n.localize(`${K}.${r.no}`) : game.i18n.localize(`${K}.no`);
	return await foundry.applications.api.DialogV2.confirm({
		window: { title: Ea(e, n) },
		content: `<p>${Ea(t, n)}</p>`,
		yes: { label: i },
		no: { label: a }
	});
}
async function ka(e, t, n) {
	let r = G(t);
	if (!Hi(e, r)) return {
		allowed: !0,
		didOverride: !1
	};
	let i = await Oa("overrideLearnFailureTitle", "overrideLearnFailureMessage", {
		spellName: n,
		level: Li(e, r) ?? Vi(e)
	}, {
		yes: "overrideLearnFailureYes",
		no: "overrideLearnFailureNo"
	});
	return {
		allowed: i,
		didOverride: i
	};
}
async function Aa(e, t, n, r) {
	let i = r ? `<br>${game.i18n.format(`${K}.learnSpellDialogEntry`, {
		entryName: r.name,
		tradition: r.tradition,
		type: r.type
	})}` : "", a = await foundry.applications.api.DialogV2.wait({
		window: { title: game.i18n.localize(`${K}.learnSpellDialogTitle`) },
		content: `<p>${game.i18n.format(`${K}.learnSpellDialogMessage`, {
			spellName: e,
			cost: Y(t),
			time: Da(n)
		})}${i}</p>`,
		buttons: [
			{
				action: "yes",
				label: game.i18n.localize(`${K}.learnSpellYes`),
				icon: "fa-solid fa-graduation-cap"
			},
			{
				action: "no",
				label: game.i18n.localize(`${K}.learnSpellNo`),
				icon: "fa-solid fa-check"
			},
			{
				action: "cancel",
				label: game.i18n.localize(`${K}.learnSpellCancel`),
				icon: "fa-solid fa-times"
			}
		]
	});
	return !a || a === "cancel" ? null : a;
}
//#endregion
//#region src/module/feature/spells/learn/spellRoll.ts
function ja(e, t, n, r, i) {
	let a = Ta(e, t);
	if (!a?.roll) return ui.notifications.warn(game.i18n.localize(`${K}.learnNoSkill`)), Promise.resolve(null);
	let o = i?.skipDialog ?? !1;
	return new Promise((e) => {
		a.roll({
			dc: { value: n },
			skipDialog: o,
			extraRollOptions: ["concentrate", "exploration"],
			createMessage: !0,
			callback: async (t, n) => {
				try {
					await r?.(n);
				} catch (e) {
					_("performSpellRoll: outcome callback threw", e), ui.notifications.error(game.i18n.localize(`${K}.learnSpellFailed`));
				}
				e(n ?? null);
			}
		});
	});
}
//#endregion
//#region src/module/feature/spells/learn/batchLearn.ts
function Ma(e) {
	return e === "criticalSuccess" || e === "success";
}
function Na(e) {
	return e === "failure" || e === "criticalFailure";
}
function Pa(e) {
	return e === "alreadyKnown";
}
function Fa(e) {
	return e === "skipped";
}
function Ia(e, t) {
	return t === "skipped" ? 0 : t === "criticalSuccess" || t === "criticalFailure" ? Math.floor(e / 2) : t === "failure" ? 0 : e;
}
function Z(e, t, n, r, i) {
	return {
		uuid: e.uuid,
		name: e.name,
		rankKey: e.rankKey,
		outcome: t,
		costCopper: n,
		hours: r,
		wasAlreadyKnown: i
	};
}
async function La(e, t) {
	let n = [], r = 0, i = 0, a = 0, o = 0, s = 0, c = 0;
	for (let l of e) try {
		let { result: e, stopBatch: u } = await Ra(l, t);
		if (n.push(e), u || (r += e.costCopper, i += e.hours), Pa(e.outcome) ? c++ : Fa(e.outcome) ? s++ : Ma(e.outcome) ? a++ : Na(e.outcome) && o++, u) break;
	} catch (e) {
		_(`batchLearnSpells: unhandled error processing spell ${l.name} (${l.uuid})`, e), ui.notifications.warn(game.i18n.format(`${K}.batchLearnSingleError`, { spellName: l.name }) || `Failed to process ${l.name}`), n.push(Z(l, null, 0, 0, !1));
	}
	return {
		spells: n,
		totalCostCopper: r,
		totalHours: i,
		successCount: a,
		failureCount: o,
		skippedCount: s,
		alreadyKnownCount: c
	};
}
async function Ra(e, t) {
	let n = await fromUuid(e.uuid);
	if (!n) return { result: Z(e, null, 0, 0, !1) };
	let r = X(n);
	if (r && ma(t.actor, r) !== null) return { result: Z(e, "alreadyKnown", 0, 0, !0) };
	let i = await za(n, t.actor, t.entryId);
	return i ? Va(e, t, i, n, await ja(t.actor, i.entry, i.finalDc, void 0, { skipDialog: !0 })) : { result: Z(e, null, 0, 0, !1) };
}
async function za(e, t, n, r = !1) {
	let i = da(e);
	if (!i) return ui.notifications.warn(game.i18n.localize(`${K}.learnSpellInvalidRank`)), null;
	let a = X(e), o = Sa(t, i.traditions, n);
	return o ? r && a && Hi(t, G(a)) ? null : {
		ident: a,
		resolved: i,
		entry: o,
		finalDc: sa(i.rankKey, i.traits, ca()),
		costCopper: la(i.rankKey),
		hours: ua(i.rankKey, t)
	} : (ui.notifications.warn(game.i18n.localize(`${K}.learnNoCompatibleEntry`)), null);
}
async function Ba(e, t, n, r) {
	let i = Ia(e.costCopper, t);
	return !await ea({
		actor: e.actor,
		costCopper: i,
		spellName: e.spellName
	}) && i > 0 ? !1 : (Ma(t) ? (e.ident && await Fi(e.actor, G(e.ident)), await r()) : Na(t) && e.ident && await Pi(e.actor, G(e.ident), Vi(e.actor)), !n && t && q(e.actor, zi[t] ?? "", {
		actor: e.actor.name,
		spellName: e.spellName,
		cost: Y(i),
		hours: e.hours
	}), !0);
}
async function Va(e, t, n, r, i) {
	let a = await Ba({
		actor: t.actor,
		ident: n.ident,
		costCopper: n.costCopper,
		hours: n.hours,
		spellName: n.resolved.spellName,
		entryId: n.entry.id
	}, i, t.suppressIndividualMessages ?? !1, async () => {
		await Ki(t.actor, fa(r), n.entry.id);
	}), o = Ia(n.costCopper, i);
	return a ? { result: Z(e, i ?? null, o, n.hours, !1) } : {
		result: Z(e, i ?? null, 0, n.hours, !1),
		stopBatch: !0
	};
}
//#endregion
//#region src/module/feature/spells/learn/learnSpellHandler.ts
var Ha = class {
	#e;
	constructor(e) {
		this.#e = e;
	}
	async initiateFromSpellData(e, t, n) {
		let r = da(e);
		r && await this.#t(e, t, n, !1, async () => {
			let n = X(e);
			if (n) {
				let { allowed: e } = await ka(t, n, r.spellName);
				return e;
			}
			return !0;
		});
	}
	async addSpellDirectly(e, t, n, r) {
		let i = X(e), { allowed: a, didOverride: o } = i ? await ka(t, i, r) : {
			allowed: !0,
			didOverride: !1
		};
		a && (await this.#e.addSpell(e, t, n, "", r), q(t, "learnSpellSkipped", {
			actor: t.name,
			spellName: r
		}), o && i && (await Fi(t, G(i)), q(t, "learnFailureOverridden", {
			actor: t.name,
			spellName: r
		})));
	}
	async batchLearnSpells(e, t, n, r) {
		return La(e, {
			actor: t,
			entryId: n,
			suppressIndividualMessages: r
		});
	}
	async #t(e, t, n, r, i) {
		let a = await za(e, t, n, r);
		if (!a || i && !await i(a)) return;
		let o = this.#e;
		await ja(t, a.entry, a.finalDc, async (n) => {
			await Ba({
				actor: t,
				ident: a.ident,
				costCopper: a.costCopper,
				hours: a.hours,
				spellName: a.resolved.spellName,
				entryId: a.entry.id
			}, n, !1, async () => {
				let n = fa(e);
				await o.addSpell(n, t, a.entry.id, a.resolved.rankKey, a.resolved.spellName);
			});
		});
	}
}, Ua = class {
	async addSpell(e, t, n, r, i) {
		return Ki(t, e, n);
	}
}, Wa = new Ha(new Ua());
function Ga(e) {
	if (e.type !== "spell") return !1;
	let t = e.actor;
	return !t || t.type !== "character" ? !1 : y("enableGeneralLearnSpell");
}
function Ka(e, t) {
	if (!Ga(e)) return;
	let n = e.actor;
	if (!n || Wi(n.id)) return;
	let r = t, i = r.name ?? "", a = X(r);
	return a && ha(n, a) ? ga(n) ? void 0 : (ui.notifications.info(game.i18n.format(`${K}.alreadyKnown`, { name: i })), !1) : (E(qa(r, n, i), "preCreateItemHook: spellAddIntercept"), !1);
}
async function qa(e, t, n) {
	let r = da(e);
	if (r && !va(t, r.traditions)) {
		ui.notifications.warn(game.i18n.format(`${K}.traditionMismatch`, {
			spellName: r.spellName,
			traditions: r.traditions.join(", ") || game.i18n.localize(`${K}.noTradition`)
		}));
		return;
	}
	await Gi(t.id, () => Ya(e, t));
}
function Ja(e) {
	return e.system?.location?.value;
}
async function Ya(e, t) {
	let n = da(e), r = n?.rankKey ?? "cantrip", i = e.name ?? "", a = n?.traditions ?? [], o = Ja(e), s = o ? Sa(t, a, o) : await Ca(t, a);
	if (!s) {
		let e = o ? game.i18n.format(`${K}.traditionMismatch`, {
			spellName: i,
			traditions: a.join(", ") || game.i18n.localize(`${K}.noTradition`)
		}) : game.i18n.localize(`${K}.learnNoCompatibleEntry`);
		ui.notifications.warn(e);
		return;
	}
	let c = ya(s), l = await Aa(i, la(r), ua(r, t), c);
	if (l) {
		if (l === "no") {
			await Xa(e, t, i, s.id);
			return;
		}
		await Za(e, t, s.id);
	}
}
async function Xa(e, t, n, r) {
	await Wa.addSpellDirectly(e, t, r, n);
}
async function Za(e, t, n) {
	await Wa.initiateFromSpellData(e, t, n);
}
//#endregion
//#region src/module/feature/spells/learn/scrollCreateIntercept.ts
function Qa(e) {
	let t = e.system.spell;
	return t && typeof t == "object" && t.name ? t : null;
}
function $a(e) {
	let t = e.system;
	return e.type === "consumable" && t.category === "scroll" && !!t.spell;
}
function eo(e) {
	return e.system?.identification?.status === "unidentified";
}
async function to(e) {
	if (!y("learnSpellDestroyScroll") || !e.actor) return;
	let t = e.system.quantity ?? 1;
	await (t > 1 ? e.update({ "system.quantity": t - 1 }) : e.delete());
}
async function no(e, t) {
	if (Wi(t.id)) return;
	if (eo(e)) {
		ui.notifications.warn(game.i18n.localize(`${K}.scrollMystified`));
		return;
	}
	let n = Qa(e);
	if (!n) return;
	let r = da(n);
	if (!r || !await Oa("learnFromScrollTitle", "learnFromScrollMessage", { spellName: r.spellName })) return;
	let i = await Ca(t, r.traditions);
	if (!i) {
		ui.notifications.warn(game.i18n.format(`${K}.traditionMismatch`, {
			spellName: r.spellName,
			traditions: r.traditions.join(", ")
		}));
		return;
	}
	let a = fa(n);
	await new Ha(new Ua()).initiateFromSpellData(a, t, i.id), await to(e);
}
function ro(e, t) {
	if (!y("enableGeneralLearnSpell") || !$a(e)) return;
	let n = e.actor;
	if (!n || n.type !== "character") return;
	let r = Qa(e);
	if (r) {
		let e = X(r);
		if (e && ha(n, e) && ga(n)) return;
	}
	let i = e.name, a = Hooks.on("createItem", (e) => {
		e.actor?.id !== n?.id || e.name !== i || !$a(e) || (Hooks.off("createItem", a), E(no(e, n), "createItem: scrollLearn"));
	});
}
//#endregion
//#region src/module/hooks/preCreateItemHook.ts
function io(e, t, n, r) {
	if (e.type === "condition" && e.slug === "unconscious" && e.actor?.isOfType("character") && y("dropHeldItemsOnBecomingUnconscious") && ao(e.actor), y("enableGeneralLearnSpell") && (ro(e, t), Ka(e, t) === !1)) return !1;
}
function ao(t) {
	let n = t.inventory.filter((e) => e.isHeld);
	if (n && n.length > 0) {
		for (let e of n) e.traits.has("free-hand") || e.type === "shield" || e.traits.has("attached-to-shield") ? t.changeCarryType(e, {
			carryType: "worn",
			handsHeld: 0,
			inSlot: !1
		}) : t.changeCarryType(e, {
			carryType: "dropped",
			handsHeld: 0,
			inSlot: !1
		});
		re(t, n, `${e}.SETTINGS.dropHeldItemsOnBecomingUnconscious.message`, "dropHeldItemsOnBecomingUnconscious ChatMessage");
	}
}
//#endregion
//#region src/module/hooks/preUpdateActorHook.ts
async function oo(e, t) {
	let n = foundry.utils.getProperty(t, "system.attributes.hp.value");
	if (typeof n == "number") {
		let r = e.system.attributes.hp?.value || 0;
		game.user?.isGM && e?.type === "npc" && e?.items?.size > 0 && r > 0 && n <= 0 && a("automation", "lootableNPCs") && y("npcMystifyAllPhysicalMagicalItems") === "onZeroHp" && await Yr(e), tr(e, t, r, n, y("autoGainDyingAtZeroHP"));
	}
}
//#endregion
//#region src/module/hooks/preUpdateTokenHook.ts
function so(e, t, n, ...r) {
	y("tokenAnimation") && (t.x !== null || t.y !== null) && foundry.utils.setProperty(n, "animation", { movementSpeed: y("tokenAnimationSpeed") });
}
//#endregion
//#region src/module/hooks/readyHook.ts
function co() {
	let t = game.settings.get(e, "legacyVariantRuleAncestryParagon"), n = game.settings.get(e, "legacyVariantRuleDualClass");
	if (n || t) {
		let r = o("campaignFeatSections");
		t && (r.find((e) => e.id === "xdy_ancestryparagon") || r.push({
			id: "xdy_ancestryparagon",
			label: game.i18n.localize(`${e}.SETTINGS.legacyVariantRuleAncestryParagon.title`),
			supported: ["ancestry"],
			slots: [
				1,
				3,
				7,
				11,
				15,
				19
			]
		})), n && (r.find((e) => e.id === "xdy_dualclass") || r.push({
			id: "xdy_dualclass",
			label: game.i18n.localize(`${e}.SETTINGS.legacyVariantRuleDualClass.title`),
			supported: ["class"],
			slots: [
				1,
				2,
				4,
				6,
				8,
				10,
				12,
				14,
				16,
				18,
				20
			]
		})), s("campaignFeatSections", r);
	}
	let r = o("campaignFeatSections");
	r && !n && r.find((e) => e.id === "xdy_dualclass") && (r.splice(r.findIndex((e) => e.id === "xdy_dualclass"), 1), s("campaignFeatSections", r)), r && !t && r.find((e) => e.id === "xdy_ancestryparagon") && (r.splice(r.findIndex((e) => e.id === "xdy_ancestryparagon"), 1), s("campaignFeatSections", r));
}
//#endregion
//#region src/module/feature/characterOglContent/index.ts
var lo = /* @__PURE__ */ new Set(["lore", "spellcastingEntry"]), uo = "OGL", fo = null;
function po(e) {
	return !lo.has(e.type) && e.system.publication?.license === uo;
}
function mo(e) {
	return e.items.filter(po).map((e) => ({
		name: e.name,
		uuid: e.uuid,
		type: e.type
	}));
}
function ho(t) {
	let n = Map.groupBy(t, (e) => e.type), r = [...n.keys()].sort().map((e) => {
		let t = (n.get(e) ?? []).sort((e, t) => e.name.localeCompare(t.name)).map((e) => `<li>@UUID[${e.uuid}]{${e.name}}</li>`).join("\n");
		return `<h4>${game.i18n.localize(`TYPES.Item.${e}`)}</h4>\n<ul class="xdy-pf2e-workbench-ogl-list">\n${t}\n</ul>`;
	}).join("\n");
	return `
        <div class="xdy-pf2e-workbench-ogl-dialog">
            <p>${game.i18n.format(`${e}.SETTINGS.showCharacterOglTag.oglItemsFound`, { count: t.length })}</p>
            ${r}
        </div>
    `;
}
var go = {
	render: (e, t) => {
		fo = t;
	},
	close: () => {
		fo = null;
	}
};
async function _o(t) {
	let n = mo(t), r = `${game.i18n.localize(`${e}.SETTINGS.showCharacterOglTag.title`)}: ${t.name}`;
	fo &&= (await fo.close(), null);
	let i = await TextEditor.enrichHTML(ho(n));
	await foundry.applications.api.DialogV2.wait({
		window: {
			title: r,
			resizable: !0
		},
		content: i,
		buttons: [{
			action: "close",
			label: game.i18n.localize("Close"),
			default: !0
		}],
		...go
	});
}
function vo(e) {
	return e.items.some(po);
}
function yo(t, n) {
	if (!vo(n)) return !1;
	let r = t.querySelector(".abcd ul.tags.traits");
	if (!r || r.querySelector(".xdy-pf2e-workbench-ogl-char-tag")) return !1;
	let i = game.i18n.localize(`${e}.SETTINGS.showCharacterOglTag.clickToView`), a = document.createElement("li");
	return a.classList.add("tag", "xdy-pf2e-workbench-ogl-char-tag"), a.textContent = "OGL CONTENT", a.title = i, a.addEventListener("click", () => {
		E(_o(n), "showCharacterOglDialog");
	}), r.append(a), !0;
}
//#endregion
//#region src/module/feature/actorSheet/index.ts
function bo(e, t, n) {
	let r = e.getAttribute(t);
	return r ? n.items?.get(r) ?? null : null;
}
function xo(e, t) {
	let n = e.getAttribute(t);
	return n ? fromUuidSync(n) : null;
}
function So({ html: e, actor: t, setting: n, listSelector: r, itemSelector: i, fetchItem: a, headingSelector: o = "h4" }) {
	if (t.type === "character" && y(n)) {
		let t = e?.querySelectorAll(r) ?? [];
		for (let e of t) {
			let t = e.querySelectorAll(i);
			for (let e of t) {
				let t = a(e);
				if (t) {
					let n = t.system?.traits?.rarity;
					n && e.querySelectorAll(o).forEach((e) => e.classList.add(`xdy-pf2e-workbench-rarity-${n}`));
				}
			}
		}
	}
}
function Co(e, t) {
	t.type !== "character" || !y("playerFeatsPrerequisiteHint") || e.querySelectorAll(".feats-pane").forEach((e) => {
		let n = e.querySelectorAll(".slot");
		for (let e of n) {
			let n = bo(e, "data-item-id", t);
			n && n.system.prerequisites.value.length > 0 && e.querySelectorAll("h4").forEach((e) => e.innerHTML += "*");
		}
	});
}
var wo = "workbench-spell-to-chat";
function To(e) {
	return e?.closest(`[data-action="${wo}"]`)?.parentElement?.parentElement ?? null;
}
function Eo(t, n) {
	if (t.actor?.type !== "character" || !y("playerSpellsChangeSendToChat")) return;
	let r = t.actor;
	n.querySelectorAll("li.spell").forEach((t) => {
		t.querySelectorAll("div.item-name [data-action=\"item-to-chat\"]").forEach((t) => {
			t.getAttribute("data-action") !== wo && (t.setAttribute("data-action", wo), t.onclick = (t) => {
				let n = t.target, i = To(n);
				if (!D(r) || !i) return;
				let a = bo(i, "data-item-id", r);
				if (!a || a.type !== "spell") return;
				let o = `${game.i18n.localize(`${e}.SETTINGS.playerSpellsChangeSendToChat.text`)}<em>@UUID[${a.sourceId}]</em></p>`;
				E(ChatMessage.create({
					style: CONST.CHAT_MESSAGE_STYLES.OOC,
					speaker: ChatMessage.getSpeaker(),
					flavor: o
				}), "playerSpellsChange ChatMessage");
			});
		});
	});
}
//#endregion
//#region src/module/hooks/renderActorSheetHook.ts
function Do(e, t) {
	let n = ne(t);
	if (!n || !e.actor) return;
	let r = e.actor;
	So({
		html: n,
		actor: r,
		setting: "playerSpellsRarityColour",
		listSelector: ".spell-list",
		itemSelector: ".spell",
		fetchItem: (e) => bo(e, "data-item-id", r)
	}), So({
		html: n,
		actor: r,
		setting: "playerFeatsRarityColour",
		listSelector: ".feats-pane",
		itemSelector: ".slot",
		fetchItem: (e) => bo(e, "data-item-id", r)
	}), So({
		html: n,
		actor: r,
		setting: "playerCraftingRarityColour",
		listSelector: ".crafting-pane",
		itemSelector: ".formula-item",
		fetchItem: (e) => xo(e, "data-item-uuid")
	}), So({
		html: n,
		actor: r,
		setting: "playerAbcdRarityColour",
		listSelector: ".abcd",
		itemSelector: ".detail",
		fetchItem: (e) => bo(e.querySelector(".detail-item-control") ?? e, "data-item-id", r),
		headingSelector: "h3"
	}), Co(n, r), Eo(e, n), y("showCharacterOglTag") && yo(n, r);
}
//#endregion
//#region src/module/feature/qolHandler/hidePrivateSpellName.ts
async function Oo(t, n) {
	let r = i(t, "origin.uuid");
	if (!r) return;
	let a = game.messages.contents.findLast((e) => i(e, "casting") && i(e, "origin.uuid") === r);
	if (!a?.item || a.whisper.length === 0) return;
	let o = n.querySelector(".flavor-text");
	if (!o?.innerHTML) return;
	let s = game.i18n.localize(`${e}.SETTINGS.castPrivateSpell.aSpell`) + "<p data-visibility=\"gm\">($&)</p>";
	o.innerHTML = o.innerHTML.replace(a.item.name, s);
}
//#endregion
//#region src/module/hooks/renderChatMessageHook.ts
function ko(e) {
	return e === "collapsedDefault" || e === "nonCollapsedDefault";
}
function Ao(e, t) {
	if (jo(e), w(e)) {
		let n = y("autoExpandDamageRolls");
		[
			"expandedAll",
			"expandedNew",
			"expandedNewest"
		].includes(n) && Wr(e, t, n), y("castPrivateSpell") && i(e, "origin.type") === "spell" && Oo(e, t);
	} else {
		let n = y("autoCollapseItemChatCardContent"), r = y("autoCollapseItemAttackChatCardContent"), i = y("autoCollapseItemActionChatCardContent");
		ko(n) && Lr(t);
		let a = e.item?.type ?? "";
		ko(r) && [
			"weapon",
			"melee",
			"spell"
		].includes(a) && Hr(t), ko(i) && (a === "action" || !e.item) && Br(t);
	}
	y("heroPointRules") !== "no" && No(e, t);
}
function jo(e) {
	rr(e, y("handleDyingRecoveryRoll"));
}
function Mo(t, n, r) {
	let i = t.querySelector(".flavor-text > .tags.modifiers"), a = t.querySelector(".reroll-second .dice-total");
	if (!i || !a) return !1;
	let o = document.createElement("span");
	return o.classList.add("tag", "tag_transparent", n), o.innerText = game.i18n.localize(`${e}.SETTINGS.heroPointRules.${r}`), o.dataset.slug = n, i.querySelector(".tag")?.dataset.visibility === "gm" && (o.dataset.visibility = "gm"), i.append(o), a.classList.add(n), !0;
}
function No(e, t) {
	let n = e.rolls.at(-1);
	if (n) {
		if (n.options.keeleyAdd10 && Mo(t, "keeley-add-10", "bonusTagKeeleys")) {
			let e = t.querySelector(".reroll-discard .dice-formula");
			if (e) {
				let t = document.createElement("span");
				t.className = "keeley-add-10", t.innerText = " + 10", e.append(t);
			}
		}
		n.options.useHighestRoll && Mo(t, "use-highest-roll", "bonusTagUseHighestRoll"), n.options.heroicReroll && Mo(t, "heroic-reroll", "bonusTagHeroicRerolls");
	}
}
//#endregion
//#region src/module/hooks/renderGamePauseHook.ts
function Po(e) {
	try {
		return e === decodeURIComponent(e) ? encodeURIComponent(e) : e;
	} catch {
		return encodeURIComponent(e);
	}
}
function Fo() {
	if (!document?.querySelector("#pause")?.classList.contains("paused")) return;
	let e = document.documentElement.style, t = y("customPauseImage");
	if (t !== "") {
		let n;
		if (/^https?:/i.test(t)) {
			let e = new URL(t), r = e.pathname.split("/");
			r.forEach((e, t) => {
				r[t] = Po(e);
			}), e.pathname = r.join("/"), n = `url("${e}")`;
		} else n = `url("../../../${Po(t)}")`;
		e.setProperty("--xdy-pf2e-workbench-pause", n);
	}
	if (d >= u.READY) {
		let e = document.querySelector("#pause > figcaption"), t = document.querySelector("#pause > img"), n = y("customPauseText");
		n && e && (e.textContent = n), y("pauseImageNoSpin") ? t?.classList.remove("fa-spin") : t?.classList.add("fa-spin");
	}
}
//#endregion
//#region src/module/hooks/renderItemSheetHook.ts
function Io(e, t) {
	let n = ne(t);
	if (!n || !y("showItemLicenseTags")) return;
	let r = e.item?.system?.publication?.license;
	if (r !== "ORC" && r !== "OGL") return;
	let i = n.querySelector(".details");
	if (!i || i.querySelector(".xdy-pf2e-workbench-license-tag")) return;
	let a = document.createElement("span");
	a.classList.add("tag", "xdy-pf2e-workbench-license-tag"), a.textContent = `LICENSE:${r}`, i.append(a);
}
//#endregion
//#region src/module/hooks/renderTokenHUDHook.ts
function Lo(e, t, n) {
	t && game.user?.isGM && y("npcMystifier") && Pe(e, t);
}
//#endregion
//#region src/module/hooks/updateCombatHook.ts
function Ro(e, t) {
	t.round !== void 0 && An();
}
//#endregion
//#region src/module/feature/cr-scaler/NPCScalerSetup.ts
function zo(e) {
	return e.dataset.entryId !== void 0 && (game.actors.get(e.dataset.entryId)?.isOfType("npc") ?? !1);
}
function Bo(e) {
	let t = game.actors.get(e.dataset.entryId, { strict: !0 }), n = t.level;
	t.isOfType("npc") && new foundry.applications.api.DialogV2({
		window: { title: "Scale NPC" },
		content: `
            <p>Scale a creature to a range of levels, creating the creature at each level in the range. The min level must be less than or
            equal to the max level. To only scale to a single level, set both equal to the desired level.</p>
            <div class="form-group"><label>Min Level</label><input id="startLevel" type="number" value="${n}" min="-1" max="24"></div>
            <div class="form-group"><label>Max Level</label><input id="endLevel" type="number" value="${n}" min="-1" max="24"></div>`,
		buttons: [{
			action: "scale",
			default: !0,
			icon: "<i class=\"fa-solid fa-level-up-alt\"></i>",
			label: "Scale",
			callback: async (e, n, r) => {
				ui.notifications.info("Scaling NPC... please wait.");
				let i = n.form?.elements, a = parseInt(i.startLevel.value), o = parseInt(i.endLevel.value);
				for (let e = a; e <= o; e++) await Qt(t, e);
				ui.notifications.info(`Scaled ${t.name} to levels ${a} - ${o}.`);
			}
		}]
	}).render({ force: !0 });
}
function Vo(e, t) {
	game.user.isGM && t.push({
		name: "Scale to Level",
		icon: "<i class=\"fa-solid fa-level-up-alt\"></i>",
		condition: zo,
		callback: Bo
	});
}
//#endregion
//#region src/module/settings/item-mystification.ts
function Ho() {
	return {
		999: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.notMystified`),
		4: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.plus4`),
		3: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.plus3`),
		2: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.plus2`),
		1: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.plus1`),
		0: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.plus0`),
		"-1": game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.minus1`),
		"-2": game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.minus2`),
		"-3": game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.minus3`),
		"-4": game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.minus4`)
	};
}
function Uo() {
	let t = { 999: game.i18n.localize(`${e}.SETTINGS.mystifyThreshold.notMystified`) };
	for (let e = 0; e <= 20; e++) t[String(e)] = String(e);
	return t;
}
var Wo = [
	"999",
	"4",
	"3",
	"2",
	"1",
	"0",
	"-1",
	"-2",
	"-3",
	"-4"
];
function Go(e) {
	let t = new Map(Wo.map((e, t) => [e, t])), n = [...e.options];
	n.sort((e, n) => (t.get(e.value) ?? 9999) - (t.get(n.value) ?? 9999));
	for (let t of n) e.appendChild(t);
}
var Ko = [
	"common",
	"uncommon",
	"rare",
	"unique"
], qo = class t extends A {
	static namespace = "itemMystificationSettings";
	static hidelist = { npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel: {
		type: "input",
		falsy: !1,
		list: Ko.flatMap((e) => [`mystifyThreshold${T(e)}Pl`])
	} };
	static get settings() {
		return {
			npcMystifyAllPhysicalMagicalItems: {
				name: `${e}.SETTINGS.npcMystifyAllPhysicalMagicalItems.name`,
				hint: `${e}.SETTINGS.npcMystifyAllPhysicalMagicalItems.hint`,
				scope: "world",
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.npcMystifyAllPhysicalMagicalItems.no`),
					onScene: game.i18n.localize(`${e}.SETTINGS.npcMystifyAllPhysicalMagicalItems.onScene`),
					onZeroHp: game.i18n.localize(`${e}.SETTINGS.npcMystifyAllPhysicalMagicalItems.onZeroHp`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel: {
				name: `${e}.SETTINGS.npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel.name`,
				hint: `${e}.SETTINGS.npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel.hint`,
				scope: "world",
				default: !1,
				type: Boolean
			},
			...t.thresholdSettings("Pl", Ho),
			...t.thresholdSettings("Abs", Uo)
		};
	}
	static thresholdSettings(t, n) {
		let r = n(), i = {};
		for (let n of Ko) {
			let a = T(n);
			i[`mystifyThreshold${a}${t}`] = {
				name: `${e}.SETTINGS.mystifyThreshold.name${t}${a}`,
				hint: `${e}.SETTINGS.mystifyThreshold.hint${t}`,
				scope: "world",
				default: "999",
				type: String,
				choices: r
			};
		}
		return i;
	}
	async _onRender(e, t) {
		await super._onRender(e, t);
		let n = "npcMystifyAllPhysicalMagicalItemsOfThisLevelOrGreaterUsingPartyLevel", r = (e) => {
			for (let t of Ko) {
				let n = T(t), r = this.element.querySelector(`.form-group:has(.form-fields [name="mystifyThreshold${n}Abs"])`);
				A.hideForm(r, !e);
			}
		};
		r(y(n));
		let i = this.element.querySelector(`.form-fields [name="${n}"]`);
		i?.addEventListener("change", () => r(i.checked));
		for (let e of Ko) {
			let t = T(e), n = this.element.querySelector(`.form-fields [name="mystifyThreshold${t}Pl"]`);
			n && Go(n);
		}
	}
}, Jo = class extends A {
	static namespace = "remindersSettings";
	static get settings() {
		return {
			reminderCannotAttack: {
				name: `${e}.SETTINGS.reminderCannotAttack.name`,
				hint: `${e}.SETTINGS.reminderCannotAttack.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.reminderCannotAttack.no`),
					reminder: game.i18n.localize(`${e}.SETTINGS.reminderCannotAttack.reminder`),
					cancelAttack: game.i18n.localize(`${e}.SETTINGS.reminderCannotAttack.cancelAttack`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			reminderCannotAttackIgnoreDeadEidolon: {
				name: `${e}.SETTINGS.reminderCannotAttackIgnoreDeadEidolon.name`,
				hint: `${e}.SETTINGS.reminderCannotAttackIgnoreDeadEidolon.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			reminderTargeting: {
				name: `${e}.SETTINGS.reminderTargeting.name`,
				hint: `${e}.SETTINGS.reminderTargeting.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.reminderTargeting.no`),
					reminder: game.i18n.localize(`${e}.SETTINGS.reminderTargeting.reminder`),
					mustTarget: game.i18n.localize(`${e}.SETTINGS.reminderTargeting.mustTarget`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			actionsReminderAllow: {
				name: `${e}.SETTINGS.actionsReminderAllow.name`,
				hint: `${e}.SETTINGS.actionsReminderAllow.hint`,
				scope: "world",
				config: !0,
				default: "none",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.actionsReminderAllow.none`),
					all: game.i18n.localize(`${e}.SETTINGS.actionsReminderAllow.all`),
					gm: game.i18n.localize(`${e}.SETTINGS.actionsReminderAllow.gm`),
					players: game.i18n.localize(`${e}.SETTINGS.actionsReminderAllow.players`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			reminderBreathWeapon: {
				name: `${e}.SETTINGS.reminderBreathWeapon.name`,
				hint: `${e}.SETTINGS.reminderBreathWeapon.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			reminderBreathWeaponHidden: {
				name: `${e}.SETTINGS.reminderBreathWeaponHidden.name`,
				hint: `${e}.SETTINGS.reminderBreathWeaponHidden.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			heroPointHandler: {
				name: `${e}.SETTINGS.heroPointHandler.name`,
				hint: `${e}.SETTINGS.heroPointHandler.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			heropointHandlerNotificationChat: {
				name: `${e}.SETTINGS.heropointHandlerNotificationChat.name`,
				hint: `${e}.SETTINGS.heropointHandlerNotificationChat.hint`,
				scope: "world",
				config: !0,
				default: !0,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			heroPointHandlerStartTimerOnReady: {
				name: `${e}.SETTINGS.heroPointHandlerStartTimerOnReady.name`,
				hint: `${e}.SETTINGS.heroPointHandlerStartTimerOnReady.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			heroPointHandlerDefaultTimeoutMinutes: {
				name: `${e}.SETTINGS.heroPointHandlerDefaultTimeoutMinutes.name`,
				hint: `${e}.SETTINGS.heroPointHandlerDefaultTimeoutMinutes.hint`,
				scope: "world",
				config: !0,
				default: 60,
				type: Number,
				onChange: () => $(),
				requiresReload: !0
			},
			heropointHandlerNotification: {
				name: `${e}.SETTINGS.heropointHandlerNotification.name`,
				hint: `${e}.SETTINGS.heropointHandlerNotification.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			heropointHandlerRandomization: {
				name: `${e}.SETTINGS.heropointHandlerRandomization.name`,
				hint: `${e}.SETTINGS.heropointHandlerRandomization.hint`,
				scope: "world",
				config: !0,
				default: "random",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.heropointHandlerRandomization.none`),
					random: game.i18n.localize(`${e}.SETTINGS.heropointHandlerRandomization.random`),
					randomPartymemberThatHasNotReceivedAHeropoint: game.i18n.localize(`${e}.SETTINGS.heropointHandlerRandomization.randomPartymemberThatHasNotReceivedAHeropoint`)
				},
				onChange: () => $(),
				requiresReload: !0
			}
		};
	}
}, Yo = class extends A {
	static namespace = "automationWorldSettings";
	static hidelist = { autoGainDyingAtZeroHP: {
		type: "select",
		falsy: "no",
		list: [
			"nonLethalIsNotLethal",
			"autoGainDyingAtZeroHPIfCriticallyHitOneMore",
			"autoGainDyingIfTakingDamageWhenAlreadyDying",
			"autoGainDyingIgnoresTargeting"
		]
	} };
	static get settings() {
		return {
			enableAutomaticMove: {
				name: `${e}.SETTINGS.enableAutomaticMove.name`,
				hint: `${e}.SETTINGS.enableAutomaticMove.hint`,
				scope: "world",
				config: !0,
				default: "noAutomation",
				type: String,
				choices: {
					noAutomation: game.i18n.localize(`${e}.SETTINGS.enableAutomaticMove.noAutomation`),
					reaching0HP: game.i18n.localize(`${e}.SETTINGS.enableAutomaticMove.reaching0HP`),
					reaching0HPCharactersOnly: game.i18n.localize(`${e}.SETTINGS.enableAutomaticMove.reaching0HPCharactersOnly`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			autoRollDamageAllow: {
				name: `${e}.SETTINGS.autoRollDamageAllow.name`,
				hint: `${e}.SETTINGS.autoRollDamageAllow.hint`,
				scope: "world",
				config: !0,
				default: "none",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.autoRollDamageAllow.none`),
					all: game.i18n.localize(`${e}.SETTINGS.autoRollDamageAllow.all`),
					gm: game.i18n.localize(`${e}.SETTINGS.autoRollDamageAllow.gm`),
					players: game.i18n.localize(`${e}.SETTINGS.autoRollDamageAllow.players`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			experimentalToolbeltSaveIntegration: {
				name: `${e}.SETTINGS.experimentalToolbeltSaveIntegration.name`,
				hint: `${e}.SETTINGS.experimentalToolbeltSaveIntegration.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			applyPersistentDamage: {
				name: `${e}.SETTINGS.applyPersistentDamage.name`,
				hint: `${e}.SETTINGS.applyPersistentDamage.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			applyPersistentDamageRecoveryRoll: {
				name: `${e}.SETTINGS.applyPersistentDamageRecoveryRoll.name`,
				hint: `${e}.SETTINGS.applyPersistentDamageRecoveryRoll.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			applyPersistentHealing: {
				name: `${e}.SETTINGS.applyPersistentHealing.name`,
				hint: `${e}.SETTINGS.applyPersistentHealing.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			handleDyingRecoveryRollAllow: {
				name: `${e}.SETTINGS.handleDyingRecoveryRollAllow.name`,
				hint: `${e}.SETTINGS.handleDyingRecoveryRollAllow.hint`,
				scope: "world",
				config: !0,
				default: "none",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.handleDyingRecoveryRollAllow.none`),
					all: game.i18n.localize(`${e}.SETTINGS.handleDyingRecoveryRollAllow.all`),
					gm: game.i18n.localize(`${e}.SETTINGS.handleDyingRecoveryRollAllow.gm`),
					players: game.i18n.localize(`${e}.SETTINGS.handleDyingRecoveryRollAllow.players`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			autoReduceStunned: {
				name: `${e}.SETTINGS.autoReduceStunned.name`,
				hint: `${e}.SETTINGS.autoReduceStunned.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			giveUnconsciousIfDyingRemovedAt0HP: {
				name: `${e}.SETTINGS.giveUnconsciousIfDyingRemovedAt0HP.name`,
				hint: `${e}.SETTINGS.giveUnconsciousIfDyingRemovedAt0HP.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			autoRemoveUnconsciousAtGreaterThanZeroHP: {
				name: `${e}.SETTINGS.autoRemoveUnconsciousAtGreaterThanZeroHP.name`,
				hint: `${e}.SETTINGS.autoRemoveUnconsciousAtGreaterThanZeroHP.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			giveWoundedWhenDyingRemoved: {
				name: `${e}.SETTINGS.giveWoundedWhenDyingRemoved.name`,
				hint: `${e}.SETTINGS.giveWoundedWhenDyingRemoved.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			autoGainDyingAtZeroHP: {
				name: `${e}.SETTINGS.autoGainDyingAtZeroHP.name`,
				hint: `${e}.SETTINGS.autoGainDyingAtZeroHP.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHP.no`),
					addOne: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHP.addOne`),
					addWoundedLevel: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHP.addWoundedLevel`),
					addOneForCharacters: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHP.addOneForCharacters`),
					addWoundedLevelForCharacters: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHP.addWoundedLevelForCharacters`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			nonLethalIsNotLethal: {
				name: `${e}.SETTINGS.nonLethalIsNotLethal.name`,
				hint: `${e}.SETTINGS.nonLethalIsNotLethal.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.nonLethalIsNotLethal.no`),
					unconscious: game.i18n.localize(`${e}.SETTINGS.nonLethalIsNotLethal.unconscious`),
					unconsciousForCharacters: game.i18n.localize(`${e}.SETTINGS.nonLethalIsNotLethal.unconsciousForCharacters`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			autoGainDyingAtZeroHPIfCriticallyHitOneMore: {
				name: `${e}.SETTINGS.autoGainDyingAtZeroHPIfCriticallyHitOneMore.name`,
				hint: `${e}.SETTINGS.autoGainDyingAtZeroHPIfCriticallyHitOneMore.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHPIfCriticallyHitOneMore.no`),
					add: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHPIfCriticallyHitOneMore.add`),
					addForCharacters: game.i18n.localize(`${e}.SETTINGS.autoGainDyingAtZeroHPIfCriticallyHitOneMore.addForCharacters`)
				}
			},
			autoGainDyingIfTakingDamageWhenAlreadyDying: {
				name: `${e}.SETTINGS.autoGainDyingIfTakingDamageWhenAlreadyDying.name`,
				hint: `${e}.SETTINGS.autoGainDyingIfTakingDamageWhenAlreadyDying.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.autoGainDyingIfTakingDamageWhenAlreadyDying.no`),
					add: game.i18n.localize(`${e}.SETTINGS.autoGainDyingIfTakingDamageWhenAlreadyDying.add`),
					addForCharacters: game.i18n.localize(`${e}.SETTINGS.autoGainDyingIfTakingDamageWhenAlreadyDying.addForCharacters`)
				}
			},
			autoGainDyingIgnoresTargeting: {
				name: `${e}.SETTINGS.autoGainDyingIgnoresTargeting.name`,
				hint: `${e}.SETTINGS.autoGainDyingIgnoresTargeting.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			autoRemoveDyingAtGreaterThanZeroHP: {
				name: `${e}.SETTINGS.autoRemoveDyingAtGreaterThanZeroHP.name`,
				hint: `${e}.SETTINGS.autoRemoveDyingAtGreaterThanZeroHP.hint`,
				scope: "world",
				config: !0,
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.autoRemoveDyingAtGreaterThanZeroHP.no`),
					remove: game.i18n.localize(`${e}.SETTINGS.autoRemoveDyingAtGreaterThanZeroHP.removeDying`),
					removeForCharacters: game.i18n.localize(`${e}.SETTINGS.autoRemoveDyingAtGreaterThanZeroHP.removeDyingForCharacters`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			dropHeldItemsOnBecomingUnconscious: {
				name: `${e}.SETTINGS.dropHeldItemsOnBecomingUnconscious.name`,
				hint: `${e}.SETTINGS.dropHeldItemsOnBecomingUnconscious.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			sheatheHeldItemsAfterEncounter: {
				name: `${e}.SETTINGS.sheatheHeldItemsAfterEncounter.name`,
				hint: `${e}.SETTINGS.sheatheHeldItemsAfterEncounter.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			sheatheHeldItemsAfterEncounterTypes: {
				name: `${e}.SETTINGS.sheatheHeldItemsAfterEncounterTypes.name`,
				hint: `${e}.SETTINGS.sheatheHeldItemsAfterEncounterTypes.hint`,
				scope: "world",
				config: !0,
				default: "weapon",
				type: String,
				onChange: () => $(),
				requiresReload: !0
			}
		};
	}
}, Xo = class extends A {
	static namespace = "automationClientSettings";
	static DEFAULT_OPTIONS = foundry.utils.mergeObject(super.DEFAULT_OPTIONS, { height: "fit-content" });
	static get settings() {
		return {
			autoRollDamageForStrike: {
				name: `${e}.SETTINGS.autoRollDamageForStrike.name`,
				hint: `${e}.SETTINGS.autoRollDamageForStrike.hint`,
				scope: "client",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			autoRollDamageForSpellAttack: {
				name: `${e}.SETTINGS.autoRollDamageForSpellAttack.name`,
				hint: `${e}.SETTINGS.autoRollDamageForSpellAttack.hint`,
				scope: "client",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			autoRollDamageForSpellWhenNotAnAttack: {
				name: `${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.name`,
				hint: `${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.hint`,
				scope: "client",
				config: !0,
				default: !1,
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.no`),
					anySpell: game.i18n.localize(`${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.anySpell`),
					saveSpell: game.i18n.localize(`${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.saveSpell`),
					nonSaveSpell: game.i18n.localize(`${e}.SETTINGS.autoRollDamageForSpellWhenNotAnAttack.nonSaveSpell`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			autoRollDamageNotifyOnSpellCardNotFound: {
				name: `${e}.SETTINGS.autoRollDamageNotifyOnSpellCardNotFound.name`,
				hint: `${e}.SETTINGS.autoRollDamageNotifyOnSpellCardNotFound.hint`,
				scope: "client",
				config: !0,
				default: !0,
				type: Boolean
			},
			handleDyingRecoveryRoll: {
				name: `${e}.SETTINGS.handleDyingRecoveryRoll.name`,
				hint: `${e}.SETTINGS.handleDyingRecoveryRoll.hint`,
				scope: "client",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			decreaseFrightenedConditionEachTurn: {
				name: `${e}.SETTINGS.decreaseFrightenedConditionEachTurn.name`,
				hint: `${e}.SETTINGS.decreaseFrightenedConditionEachTurn.hint`,
				scope: "client",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			}
		};
	}
}, Zo = class extends A {
	static namespace = "qolWorldSettings";
	static hidelist = {
		castPrivateSpell: { list: [
			"castPrivateSpellAutoRevealIfKnown",
			"castPrivateSpellAutoRevealPartyMembersThatKnowSpell",
			"castPrivateSpellAlwaysFor",
			"castPrivateSpellAutoRevealOverrideGMRollMode"
		] },
		castPrivateSpellWithPublicMessage: { list: ["castPrivateSpellWithPublicMessageShowToGM", "castPrivateSpellWithPublicMessageShowTraits"] },
		castPrivateSpellWithPublicMessageShowTraits: { list: ["castPrivateSpellWithPublicMessageTraitsBlocklist"] },
		sheatheHeldItemsAfterEncounter: { list: ["sheatheHeldItemsAfterEncounterTypes"] }
	};
	static get settings() {
		return {
			npcScaler: {
				name: `${e}.SETTINGS.npcScaler.name`,
				hint: `${e}.SETTINGS.npcScaler.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			npcRoller: {
				name: `${e}.SETTINGS.npcRoller.name`,
				hint: `${e}.SETTINGS.npcRoller.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpell: {
				name: `${e}.SETTINGS.castPrivateSpell.name`,
				hint: `${e}.SETTINGS.castPrivateSpell.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellAutoRevealIfKnown: {
				name: `${e}.SETTINGS.castPrivateSpellAutoRevealIfKnown.name`,
				hint: `${e}.SETTINGS.castPrivateSpellAutoRevealIfKnown.hint`,
				scope: "world",
				config: !0,
				default: !0,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellAutoRevealOverrideGMRollMode: {
				name: `${e}.SETTINGS.castPrivateSpellAutoRevealOverrideGMRollMode.name`,
				hint: `${e}.SETTINGS.castPrivateSpellAutoRevealOverrideGMRollMode.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellAutoRevealPartyMembersThatKnowSpell: {
				name: `${e}.SETTINGS.castPrivateSpellAutoRevealPartyMembersThatKnowSpell.name`,
				hint: `${e}.SETTINGS.castPrivateSpellAutoRevealPartyMembersThatKnowSpell.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellAlwaysFor: {
				name: `${e}.SETTINGS.castPrivateSpellAlwaysFor.name`,
				hint: `${e}.SETTINGS.castPrivateSpellAlwaysFor.hint`,
				scope: "world",
				config: !0,
				default: "none",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.castPrivateSpellAlwaysFor.none`),
					nonAllies: game.i18n.localize(`${e}.SETTINGS.castPrivateSpellAlwaysFor.nonAllies`),
					nonPartymembers: game.i18n.localize(`${e}.SETTINGS.castPrivateSpellAlwaysFor.nonPartymembers`),
					npcs: game.i18n.localize(`${e}.SETTINGS.castPrivateSpellAlwaysFor.npcs`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellWithPublicMessage: {
				name: `${e}.SETTINGS.castPrivateSpellWithPublicMessage.name`,
				hint: `${e}.SETTINGS.castPrivateSpellWithPublicMessage.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellWithPublicMessageShowToGM: {
				name: `${e}.SETTINGS.castPrivateSpellWithPublicMessageShowToGM.name`,
				hint: `${e}.SETTINGS.castPrivateSpellWithPublicMessageShowToGM.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellWithPublicMessageShowTraits: {
				name: `${e}.SETTINGS.castPrivateSpellWithPublicMessageShowTraits.name`,
				hint: `${e}.SETTINGS.castPrivateSpellWithPublicMessageShowTraits.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			castPrivateSpellWithPublicMessageTraitsBlocklist: {
				name: `${e}.SETTINGS.castPrivateSpellWithPublicMessageTraitsBlocklist.name`,
				hint: `${e}.SETTINGS.castPrivateSpellWithPublicMessageTraitsBlocklist.hint`,
				scope: "world",
				config: !0,
				default: "",
				type: String,
				onChange: () => $(),
				requiresReload: !0
			},
			playerFeatsPrerequisiteHint: {
				name: `${e}.SETTINGS.playerFeatsPrerequisiteHint.name`,
				hint: `${e}.SETTINGS.playerFeatsPrerequisiteHint.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			playerFeatsRarityColour: {
				name: `${e}.SETTINGS.playerFeatsRarityColour.name`,
				hint: `${e}.SETTINGS.playerFeatsRarityColour.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			playerAbcdRarityColour: {
				name: `${e}.SETTINGS.playerAbcdRarityColour.name`,
				hint: `${e}.SETTINGS.playerAbcdRarityColour.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			playerCraftingRarityColour: {
				name: `${e}.SETTINGS.playerCraftingRarityColour.name`,
				hint: `${e}.SETTINGS.playerCraftingRarityColour.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			playerSpellsRarityColour: {
				name: `${e}.SETTINGS.playerSpellsRarityColour.name`,
				hint: `${e}.SETTINGS.playerSpellsRarityColour.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			playerSpellsChangeSendToChat: {
				name: `${e}.SETTINGS.playerSpellsChangeSendToChat.name`,
				hint: `${e}.SETTINGS.playerSpellsChangeSendToChat.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			showItemLicenseTags: {
				name: `${e}.SETTINGS.showItemLicenseTags.name`,
				hint: `${e}.SETTINGS.showItemLicenseTags.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			showCharacterOglTag: {
				name: `${e}.SETTINGS.showCharacterOglTag.name`,
				hint: `${e}.SETTINGS.showCharacterOglTag.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			enableGeneralLearnSpell: {
				name: `${e}.SETTINGS.enableGeneralLearnSpell.name`,
				hint: `${e}.SETTINGS.enableGeneralLearnSpell.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			learnSpellDcAdjustment: {
				name: `${e}.SETTINGS.learnSpellDcAdjustment.name`,
				hint: `${e}.SETTINGS.learnSpellDcAdjustment.hint`,
				scope: "world",
				config: !0,
				default: 0,
				type: Number
			},
			learnSpellDestroyScroll: {
				name: `${e}.SETTINGS.learnSpellDestroyScroll.name`,
				hint: `${e}.SETTINGS.learnSpellDestroyScroll.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			},
			allowDebtItems: {
				name: `${e}.SETTINGS.allowDebtItems.name`,
				hint: `${e}.SETTINGS.allowDebtItems.hint`,
				scope: "world",
				config: !0,
				default: !0,
				type: Boolean
			}
		};
	}
}, Qo = class extends A {
	static namespace = "houseRulesSettings";
	static DEFAULT_OPTIONS = foundry.utils.mergeObject(super.DEFAULT_OPTIONS, { height: "fit-content" });
	static get settings() {
		return {
			heroPointRules: {
				name: `${e}.SETTINGS.heroPointRules.name`,
				hint: `${e}.SETTINGS.heroPointRules.hint`,
				scope: "world",
				default: "no",
				type: String,
				choices: {
					no: game.i18n.localize(`${e}.SETTINGS.heroPointRules.no`),
					keeleysHeroPointRule: game.i18n.localize(`${e}.SETTINGS.heroPointRules.keeleysHeroPointRule`),
					useHighestHeroPointRoll: game.i18n.localize(`${e}.SETTINGS.heroPointRules.useHighestHeroPointRoll`),
					heroicRerolls: game.i18n.localize(`${e}.SETTINGS.heroPointRules.heroicRerolls`)
				},
				onChange: () => $(),
				requiresReload: !0
			},
			legacyVariantRuleAncestryParagon: {
				name: `${e}.SETTINGS.legacyVariantRuleAncestryParagon.name`,
				hint: `${e}.SETTINGS.legacyVariantRuleAncestryParagon.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => {
					game.settings.set("pf2e", "campaignFeatSections", game.settings.get("pf2e", "campaignFeatSections").filter((e) => e.id !== "xdy_ancestryparagon")), $();
				}
			},
			legacyVariantRuleDualClass: {
				name: `${e}.SETTINGS.legacyVariantRuleDualClass.name`,
				hint: `${e}.SETTINGS.legacyVariantRuleDualClass.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => {
					game.settings.set("pf2e", "campaignFeatSections", game.settings.get("pf2e", "campaignFeatSections").filter((e) => e.id !== "xdy_dualclass")), $();
				}
			},
			housepatcher: {
				name: `${e}.SETTINGS.housepatcher.name`,
				hint: `${e}.SETTINGS.housepatcher.hint`,
				scope: "world",
				config: !0,
				default: "",
				type: String
			}
		};
	}
}, $o = class extends A {
	static namespace = "canvasFeaturesSettings";
	static get settings() {
		return {
			canvasPointer: {
				name: `${e}.SETTINGS.canvasPointer.name`,
				hint: `${e}.SETTINGS.canvasPointer.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean
			},
			canvasPointerIcon: {
				name: `${e}.SETTINGS.canvasPointerIcon.name`,
				hint: `${e}.SETTINGS.canvasPointerIcon.hint`,
				scope: "world",
				config: !0,
				default: "fa-regular fa-hand-point-down",
				type: String
			},
			canvasPointerBroadcastInterval: {
				name: `${e}.SETTINGS.canvasPointerBroadcastInterval.name`,
				hint: `${e}.SETTINGS.canvasPointerBroadcastInterval.hint`,
				scope: "world",
				config: !0,
				default: 10,
				type: Number,
				range: {
					min: 1,
					max: 1e3,
					step: 1
				}
			},
			canvasPointerPingMode: {
				name: `${e}.SETTINGS.canvasPointerPingMode.name`,
				hint: `${e}.SETTINGS.canvasPointerPingMode.hint`,
				scope: "world",
				config: !0,
				default: "none",
				type: String,
				choices: {
					none: game.i18n.localize(`${e}.SETTINGS.canvasPointerPingMode.none`),
					visual: game.i18n.localize(`${e}.SETTINGS.canvasPointerPingMode.visual`),
					sound: game.i18n.localize(`${e}.SETTINGS.canvasPointerPingMode.sound`),
					visualAndSound: game.i18n.localize(`${e}.SETTINGS.canvasPointerPingMode.visualAndSound`)
				}
			},
			canvasPointerPingSound: {
				name: `${e}.SETTINGS.canvasPointerPingSound.name`,
				hint: `${e}.SETTINGS.canvasPointerPingSound.hint`,
				scope: "world",
				config: !0,
				default: "",
				type: String,
				filePicker: "audio"
			},
			canvasPointerPingVolume: {
				name: `${e}.SETTINGS.canvasPointerPingVolume.name`,
				hint: `${e}.SETTINGS.canvasPointerPingVolume.hint`,
				scope: "client",
				config: !0,
				default: .2,
				type: Number,
				range: {
					min: 0,
					max: 1,
					step: .1
				}
			},
			tokenAnimation: {
				name: `${e}.SETTINGS.tokenAnimation.name`,
				hint: `${e}.SETTINGS.tokenAnimation.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $(),
				requiresReload: !0
			},
			tokenAnimationSpeed: {
				name: `${e}.SETTINGS.tokenAnimationSpeed.name`,
				hint: `${e}.SETTINGS.tokenAnimationSpeed.hint`,
				scope: "world",
				config: !0,
				default: 6,
				type: Number,
				onChange: () => $(),
				requiresReload: !0
			},
			customPauseImage: {
				name: `${e}.SETTINGS.customPauseImage.name`,
				hint: `${e}.SETTINGS.customPauseImage.hint`,
				scope: "world",
				config: !0,
				default: "",
				type: String,
				filePicker: "imagevideo",
				onChange: () => $()
			},
			customPauseText: {
				name: `${e}.SETTINGS.customPauseText.name`,
				hint: `${e}.SETTINGS.customPauseText.hint`,
				scope: "world",
				config: !0,
				default: "",
				type: String,
				onChange: () => $()
			},
			pauseImageNoSpin: {
				name: `${e}.SETTINGS.pauseImageNoSpin.name`,
				hint: `${e}.SETTINGS.pauseImageNoSpin.hint`,
				scope: "world",
				config: !0,
				default: !1,
				type: Boolean,
				onChange: () => $()
			}
		};
	}
};
//#endregion
//#region src/module/settings/index.ts
function es(t) {
	return {
		noCollapse: game.i18n.localize(`${e}.SETTINGS.${t}.noCollapse`),
		collapsedDefault: game.i18n.localize(`${e}.SETTINGS.${t}.collapsedDefault`),
		nonCollapsedDefault: game.i18n.localize(`${e}.SETTINGS.${t}.nonCollapsedDefault`)
	};
}
function ts() {
	h(`${e} | registerSettings`), he.registerSettingsAndCreateMenu("fa-solid fa-eye-slash"), qo.registerSettingsAndCreateMenu("fa-solid fa-mask"), Jo.registerSettingsAndCreateMenu("fa-solid fa-bell"), Zo.registerSettingsAndCreateMenu("fa-solid fa-smile"), Yo.registerSettingsAndCreateMenu("fa-solid fa-robot"), Xo.registerSettingsAndCreateMenu("fa-solid fa-magic", !1), Qo.registerSettingsAndCreateMenu("fa-solid fa-house"), $o.registerSettingsAndCreateMenu("fa-solid fa-compass");
	for (let t of [
		"autoCollapseItemChatCardContent",
		"autoCollapseItemActionChatCardContent",
		"autoCollapseItemAttackChatCardContent"
	]) game.settings.register(e, t, {
		name: `${e}.SETTINGS.${t}.name`,
		hint: `${e}.SETTINGS.${t}.hint`,
		scope: "client",
		config: !0,
		default: "noCollapse",
		type: String,
		choices: es(t),
		onChange: () => $()
	});
	game.settings.register(e, "autoCollapseItemChatCardMoveEffectLinks", {
		name: `${e}.SETTINGS.autoCollapseItemChatCardMoveEffectLinks.name`,
		hint: `${e}.SETTINGS.autoCollapseItemChatCardMoveEffectLinks.hint`,
		scope: "client",
		config: !0,
		default: !1,
		type: Boolean,
		onChange: () => $()
	}), game.settings.register(e, "autoExpandDamageRolls", {
		name: `${e}.SETTINGS.autoExpandDamageRolls.name`,
		hint: `${e}.SETTINGS.autoExpandDamageRolls.hint`,
		scope: "client",
		config: !0,
		default: "collapsedDefault",
		type: String,
		choices: {
			collapsedAll: game.i18n.localize(`${e}.SETTINGS.autoExpandDamageRolls.collapsedAll`),
			expandedAll: game.i18n.localize(`${e}.SETTINGS.autoExpandDamageRolls.expandedAll`),
			expandedNew: game.i18n.localize(`${e}.SETTINGS.autoExpandDamageRolls.expandedNew`),
			expandedNewest: game.i18n.localize(`${e}.SETTINGS.autoExpandDamageRolls.expandedNewest`)
		},
		onChange: () => $()
	}), game.settings.register(e, "basicActionMacroShowBestBonus", {
		name: `${e}.macros.basicActionMacros.settings.showBestBonus.name`,
		hint: `${e}.macros.basicActionMacros.settings.showBestBonus.hint`,
		scope: "world",
		config: !0,
		default: !0,
		type: Boolean
	}), game.settings.register(e, "bamShowUnusable", {
		name: `${e}.macros.basicActionMacros.bamShowUnusable.name`,
		hint: `${e}.macros.basicActionMacros.bamShowUnusable.hint`,
		scope: "client",
		config: !0,
		default: !1,
		type: Boolean,
		onChange: () => $()
	}), game.settings.register(e, "bamTabview", {
		name: `${e}.macros.basicActionMacros.bamTabview.name`,
		hint: `${e}.macros.basicActionMacros.bamTabview.hint`,
		scope: "client",
		config: !0,
		default: !0,
		type: Boolean,
		onChange: () => $()
	}), game.settings.register(e, "rkBreakdown", {
		name: `${e}.macros.recallKnowledge.breakdown.name`,
		hint: `${e}.macros.recallKnowledge.breakdown.hint`,
		scope: "world",
		config: !0,
		default: "all",
		type: String,
		choices: {
			all: game.i18n.localize(`${e}.macros.recallKnowledge.breakdown.all`),
			extra: game.i18n.localize(`${e}.macros.recallKnowledge.breakdown.extra`),
			none: game.i18n.localize(`${e}.macros.recallKnowledge.breakdown.none`)
		}
	}), game.settings.register(e, "logLevel", {
		name: `${e}.SETTINGS.logLevel.name`,
		hint: `${e}.SETTINGS.logLevel.hint`,
		scope: "client",
		config: !0,
		default: 2,
		type: Number,
		choices: {
			0: game.i18n.localize(`${e}.SETTINGS.logLevel.trace`),
			1: game.i18n.localize(`${e}.SETTINGS.logLevel.debug`),
			2: game.i18n.localize(`${e}.SETTINGS.logLevel.info`),
			3: game.i18n.localize(`${e}.SETTINGS.logLevel.warn`),
			4: game.i18n.localize(`${e}.SETTINGS.logLevel.error`),
			5: game.i18n.localize(`${e}.SETTINGS.logLevel.off`)
		},
		onChange: () => $()
	}), game.settings.register(e, "workbenchVersion", {
		name: `${e}.SETTINGS.workbenchVersion.name`,
		hint: `${e}.SETTINGS.workbenchVersion.hint`,
		scope: "world",
		config: !0,
		default: "3.34.0",
		type: String,
		onChange: () => $()
	});
}
//#endregion
//#region src/module/feature/api/getAllFromAllowedPacks.ts
async function ns({ type: e = "equipment", fields: t = [], filter: n = null, strictSourcing: r = !0, fetch: i = !1 } = {}) {
	let a = "getAllFromAllowedPacks", o = game.pf2e.compendiumBrowser, s = Object.keys(o.settings);
	s.push("all");
	let c = {
		actor: "bestiary",
		npc: "bestiary",
		ability: "action"
	}, l = e;
	if (!s.includes(e) && !s.includes(e = c[e] ?? "")) return ui.notifications.error(`${a}: invalid type ${l}`), null;
	if (!Array.isArray(t) || t.length && t.some(() => !1)) return ui.notifications.error(`${a}: fields must be an array of only strings`), null;
	if (n && typeof n != "function") return ui.notifications.error(`${a}: provided filter must be a function`), null;
	Object.keys(o.packLoader.sourcesSettings.sources).length || await o.packLoader.updateSources(o.loadedPacksAll());
	let u = (e === "all" ? Object.values(o.settings).flatMap((e) => Object.entries(e).filter((e) => e[1] !== void 0)) : Object.entries(o.settings[e] ?? {}).filter((e) => e[1] !== void 0)).filter(([, e]) => e.load).map(([e]) => e), d = o.packLoader.sourcesSettings.sources, f = Object.values(d).filter((e) => e !== void 0 && e.load).map((e) => e.name.slugify({ strict: !0 }));
	t.push("system.details.publication", "system.publication", "system.source", "system.details.source");
	let p = [], m = (e) => {
		let t = (e?.system?.details?.publication?.title ?? e?.system?.publication?.title ?? e?.system?.details?.source?.value ?? e?.system?.source?.value ?? "").slugify({ strict: !0 });
		return t ? f.includes(t) : !r;
	};
	for (let e of u) {
		let r = game.packs.get(e), a = (await r?.getIndex({ fields: t }))?.filter(m), o;
		try {
			o = n ? a?.filter(n) : a;
		} catch (e) {
			let t = e instanceof Error ? e.message : String(e);
			return ui.notifications.error(`Error in provided filter: ${t}`), null;
		}
		if (i) {
			let e = await r?.getDocuments({ _id__in: o?.map((e) => e._id) });
			p.push(...e ?? []);
		} else p.push(...o ?? []);
	}
	return p;
}
//#endregion
//#region src/module/feature/macros/refocus.ts
async function rs(t, n) {
	let r = t.system.resources.focus, i = r.value, a = Math.min(i + n, r.max);
	await t.update({ "system.resources.focus.value": a }), await ChatMessage.create({
		style: CONST.CHAT_MESSAGE_STYLES.EMOTE,
		speaker: ChatMessage.getSpeaker(t),
		flavor: `<strong><img src="systems/${game.system.id}/icons/actions/Passive.webp" width="10" height="10" style="border: 0; margin-right: 3px;" alt="Passive">Refocus</strong>`,
		content: game.i18n.format(`${e}.macros.refocus.regains`, { focus: a - i })
	});
}
async function is(t = canvas.tokens.controlled.map((e) => e.actor) ?? []) {
	if (t.length === 1) {
		let e = canvas.tokens.controlled[0].actor, t = 1;
		e && ((e.feats?.map((e) => e.feats).flat())?.find((e) => [
			"bloodline-focus",
			"bonded-focus",
			"conflux-focus",
			"devoted-focus",
			"domain-focus",
			"hex-focus",
			"inspirational-focus",
			"link-focus",
			"meditative-focus",
			"primal-focus",
			"wardens-focus"
		].includes(e.feat?.system?.slug)) && (t = e.system.resources.focus.max), rs(e, t));
	} else ui.notifications.warn(game.i18n.localize(`${e}.macros.refocus.selectOneActor`));
}
//#endregion
//#region src/module/feature/macros/hypercognition.ts
async function as(e) {
	if (game.user.targets.size !== 1) {
		ui.notifications.error("Please select exactly one target");
		return;
	}
	let t = e?.actor;
	if (!t) {
		ui.notifications.error("No actor found");
		return;
	}
	let n = t.itemTypes.spell.find((e) => ["hypercognition"].includes(e.slug)), r = t.itemTypes.feat.find((e) => ["true-hypercognition"].includes(e.slug)), i = t.itemTypes.feat.find((e) => ["incredible-recollection"].includes(e.slug));
	if (!n && !r && !i) {
		ui.notifications.error("Selected actor has neither Hypercognition, Incredible Recollection nor True Hypercognition!");
		return;
	}
	let a = {
		criticalSuccess: {
			count: 0,
			rolls: []
		},
		success: {
			count: 0,
			rolls: []
		},
		failure: {
			count: 0,
			rolls: []
		},
		criticalFailure: {
			count: 0,
			rolls: []
		}
	}, o = game.macros.find((e) => e.name === "Recall_Knowledge");
	if (!o) {
		ui.notifications.error("Could not find the Recall_Knowledge macro");
		return;
	}
	let s = [
		"arcana",
		"crafting",
		"medicine",
		"nature",
		"occultism",
		"religion",
		"society"
	].map((e) => {
		let n = t.skills?.[e];
		return {
			name: n?.label,
			rank: n?.rank,
			modifier: n?.totalModifier,
			wasUsed: !1,
			actualModifier: 0
		};
	}), c = Object.values(t.skills).filter((e) => e.lore).map((e) => ({
		name: e.label,
		rank: e.rank,
		modifier: e.totalModifier,
		wasUsed: !1,
		actualModifier: null
	})), l = n ? 6 : 5;
	for (let e = 0; e < l; e++) {
		await o.execute(), await new Promise((e) => setTimeout(e, 100));
		let e = game.messages?.contents;
		if (!e?.length) continue;
		let t = e[e.length - 1];
		if (!t?.content) continue;
		let n = document.createElement("div");
		n.innerHTML = t.content;
		let r = n.querySelectorAll("table");
		if (r.length === 0) continue;
		let i = n.innerHTML.match(/Roll: <span[^>]*>(\d+)<\/span>/), l = i ? parseInt(i[1]) : null, u = r[0].querySelectorAll("tr"), d;
		u.forEach((e) => {
			let t = e.querySelectorAll("td, th");
			if (t.length >= 3) {
				let n = t[0].textContent?.trim(), r = t[2]?.querySelector("span")?.textContent, i = r ? parseInt(r) : null, a = i !== null && l !== null ? i - l : null, o = s.find((e) => e.name === n);
				o && (o.wasUsed = !0, a !== null && (o.actualModifier = a));
				let c = e.textContent?.match(/(CrSuc|Suc|Fail|CrFail)/);
				if (c) {
					let e = c[1];
					(!d || e === "CrSuc" || e === "Suc" && d !== "CrSuc" || e === "Fail" && d === "CrFail") && (d = e);
				}
			}
		});
		let f = r[r.length - 2];
		if (f && f.querySelectorAll("tr").forEach((e) => {
			let t = e.querySelectorAll("td, th");
			if (t.length >= 3) {
				let e = t[0].textContent?.trim(), n = (t[2]?.textContent?.trim())?.match(/[+-]\d+/), r = c.find((t) => t.name === e);
				r && n && (r.wasUsed = !0, r.actualModifier = parseInt(n[0]));
			}
		}), d && l !== null) switch (d) {
			case "CrSuc":
				a.criticalSuccess.count++, a.criticalSuccess.rolls.push(l);
				break;
			case "Suc":
				a.success.count++, a.success.rolls.push(l);
				break;
			case "Fail":
				a.failure.count++, a.failure.rolls.push(l);
				break;
			case "CrFail":
				a.criticalFailure.count++, a.criticalFailure.rolls.push(l);
				break;
		}
		try {
			await t.delete();
		} catch (e) {
			g("Could not delete message:", e);
		}
	}
	let u = [
		"UNTRAINED",
		"TRAINED",
		"EXPERT",
		"MASTER",
		"LEGENDARY"
	], d = [
		"#443730",
		"#171f69",
		"#3c005e",
		"#5e4000",
		"#5e0000"
	], f = [
		"red",
		"orange",
		"royalblue",
		"green"
	], p = (e, t, n) => t.count === 0 ? `${e}: 0` : `<span style="color:${f[n]}">${e}: ${t.count} (Rolls: ${t.rolls.join(", ")})</span>`, m = `${e.name} ponders the true nature of <strong>${game.user.targets?.first()?.name}</strong> (${l} Recall Knowledge rolls)<br>
<div data-visibility="gm" style="display: block">
        ${p("Critical Successes", a.criticalSuccess, 3)}<br>
        ${p("Successes", a.success, 2)}<br>
        ${p("Failures", a.failure, 1)}<br>
        ${p("Critical Failures", a.criticalFailure, 0)}<br><br>`, h = s.filter((e) => e.wasUsed);
	if (h.length > 0) {
		m += "<strong>Used Skills:</strong><br>", m += "<table style=\"border-collapse: collapse; width: 100%;\"><tr><th>Skill</th><th>Proficiency</th><th>Modifier</th></tr>";
		for (let e of h) {
			let t = e.actualModifier === null ? e.modifier : e.actualModifier;
			m += `<tr><td>${e.name}</td><td class="tags"><div class="tag" style="background-color: ${d[e.rank]}; white-space:nowrap">${u[e.rank]}</div></td><td>${t === null ? "" : (t >= 0 ? "+" : "") + t}</td></tr>`;
		}
		m += "</table><br>";
	}
	let _ = c.filter((e) => e.wasUsed);
	if (_.length > 0) {
		m += "<strong>Used Lore Skills:</strong><br>", m += "<table style=\"border-collapse: collapse; width: 100%;\"><tr><th>Lore</th><th>Proficiency</th><th>Modifier</th></tr>";
		for (let e of _) {
			let t = e.actualModifier === null ? e.modifier : e.actualModifier;
			m += `<tr><td>${e.name}</td><td class="tags"><div class="tag" style="background-color: ${d[e.rank]}; white-space:nowrap">${u[e.rank]}</div></td><td>${t === null ? "" : (t >= 0 ? "+" : "") + t}</td></tr>`;
		}
		m += "</table></div>";
	}
	await ChatMessage.create({ content: m });
}
//#endregion
//#region src/module/feature/macros/npcScaler.ts
async function os() {
	let t = canvas.tokens.controlled.flatMap((e) => e.actor ?? []);
	t.length === 0 && game.user.character && t.push(game.user.character);
	let n = t[0];
	if (!n || !["npc"].includes(n.type)) {
		ui.notifications.warn(game.i18n.localize(`${e}.macros.basicActionMacros.noActorSelected`));
		return;
	}
	await foundry.applications.api.DialogV2.wait({
		window: { title: "Scale NPC" },
		content: "<p>Scale a creature to a range of levels, creating the creature at each level in the range. The min level must be less than or equal to the max level. To only scale to a single level, set both equal to the desired level.</p><div class=\"form-group\"><label>Min Level</label><input id=\"startLevel\" name=\"startLevel\" type=\"number\" value=\"24\" min=\"-1\" max=\"24\"></div><div class=\"form-group\"><label>Max Level</label><input id=\"endLevel\" name=\"endLevel\" type=\"number\" value=\"24\" min=\"-1\" max=\"24\"></div>",
		buttons: [{
			icon: "<i class=\"fa-solid fa-level-up-alt\"></i>",
			label: "Scale",
			action: "scale",
			default: !0,
			callback: async (e, t, r) => {
				ui.notifications?.info("Scaling NPC... please wait.");
				let i = parseInt((t?.form?.elements.namedItem("startLevel")).value), a = parseInt((t?.form?.elements.namedItem("endLevel")).value);
				for (let e = i; e <= a; e++) await Qt(n, e);
				ui.notifications?.info(`Scaled ${n.name} to levels ${i} - ${a}.`);
			}
		}]
	});
}
//#endregion
//#region src/module/utils/handlebarsHelpers.ts
function ss() {
	Handlebars.registerHelper("xdy_includes", function(e, t, n) {
		return e.includes(t) ? n.fn(this) : n.inverse(this);
	}), Handlebars.registerHelper("xdy_ifeq", function(e, t, n) {
		return e === t ? n.fn(this) : n.inverse();
	}), Handlebars.registerHelper("xdy_ifne", function(e, t, n) {
		return e === t ? n.inverse() : n.fn(this);
	}), Handlebars.registerHelper("xdy_isNaN", function(e, t) {
		return isNaN(e) && typeof e != "string" ? t.fn(this) : t.inverse(this);
	}), Handlebars.registerHelper("xdy_undefined", function() {}), Handlebars.registerHelper("xdy_hasKey", function(e, t) {
		for (let n of e) if (Object.hasOwn(n, t)) return !0;
		return !1;
	});
}
//#endregion
//#region src/module/xdy-pf2e-workbench.ts
var cs = "npc", ls = "character", us = /* @__PURE__ */ new Set();
function Q(e, t, n, r = !1) {
	us.has(e) ? t || (Hooks.off(e, n), us.delete(e)) : t && (r ? Hooks.once(e, n) : Hooks.on(e, n), us.add(e));
}
function $(t = !1) {
	d > u.SETUP && game.user.isGM && game.socket.emit("module." + e, { operation: "updateHooks" }), t && us.clear();
	let n = y("autoRollDamageAllow"), r = y("experimentalToolbeltSaveIntegration"), i = y("autoRollDamageForStrike"), o = y("autoRollDamageForSpellAttack"), s = y("autoRollDamageForSpellWhenNotAnAttack"), c = y("castPrivateSpell"), l = y("reminderTargeting"), f = y("reminderCannotAttack"), p = y("applyPersistentDamage"), m = y("applyPersistentHealing"), h = y("reminderBreathWeapon"), g = y("autoGainDyingIfTakingDamageWhenAlreadyDying"), _ = y("autoCollapseItemChatCardContent"), v = y("autoCollapseItemActionChatCardContent"), b = y("autoCollapseItemAttackChatCardContent"), x = y("autoExpandDamageRolls"), S = y("heroPointRules"), ee = y("npcScaler"), C = y("npcRoller"), w = y("dropHeldItemsOnBecomingUnconscious"), te = y("housepatcher"), ne = y("decreaseFrightenedConditionEachTurn"), re = y("actionsReminderAllow"), T = y("autoReduceStunned"), E = y("npcMystifier"), ie = y("enableAutomaticMove"), ae = y("autoGainDyingAtZeroHP"), D = y("nonLethalIsNotLethal"), oe = y("autoRemoveDyingAtGreaterThanZeroHP"), se = y("autoRemoveUnconsciousAtGreaterThanZeroHP"), ce = y("npcMystifyAllPhysicalMagicalItems"), le = y("tokenAnimation"), ue = y("playerFeatsRarityColour"), O = y("playerFeatsPrerequisiteHint"), de = y("playerSpellsRarityColour"), fe = y("playerAbcdRarityColour"), k = y("playerSpellsChangeSendToChat"), pe = y("sheatheHeldItemsAfterEncounter"), A = y("showItemLicenseTags"), j = y("showCharacterOglTag"), me = y("enableGeneralLearnSpell"), he = y("handleDyingRecoveryRoll"), ge = y("giveWoundedWhenDyingRemoved"), _e = y("giveUnconsciousIfDyingRemovedAt0HP");
	Q("getActorContextOptions", ee, Vo), Q("renderJournalDirectory", C, Rt), Q("controlToken", C, zt.onControlToken), Q("preCreateChatMessage", c || l !== "no" || f === "cancelAttack" || p || m, ji), Q("createChatMessage", n && (i || o || s !== "no") || h || f === "reminder" || !g.startsWith("no"), Ir);
	let M = r && n && ["saveSpell", "anySpell"].includes(s) && !!game.modules.get("pf2e-toolbelt")?.active;
	Q("pf2e-toolbelt.rollSave", M, ri), Q("combatStart", M, $n), Q("updateCombat", M, Ro), Q("deleteCombat", pe || M, Zr), Q("renderTokenHUD", E, Lo), Q("renderChatMessageHTML", c || ["collapsedDefault", "nonCollapsedDefault"].includes(_) || ["collapsedDefault", "nonCollapsedDefault"].includes(v) || ["collapsedDefault", "nonCollapsedDefault"].includes(b) || [
		"expandedAll",
		"expandedNew",
		"expandedNewest"
	].includes(x) || he || S !== "no", Ao), Q("preCreateItem", me || w, io), Q("deleteItem", ge || _e, $r), Q("pf2e.systemReady", te !== "", ai, !0), Q("pf2e.endTurn", ne, ti), Q("pf2e.startTurn", re !== "none" || T, ii), Q("pf2e.reroll", S === "keeleysHeroPointRule" || S === "useHighestHeroPointRoll" || S === "heroicRerolls", ni), Q("renderTokenHUD", E, Lo), Q("preUpdateActor", ie.startsWith("reaching0HP") || !ae.startsWith("no") || !D.startsWith("no") || !oe.startsWith("no") || se || a("automation", "lootableNPCs") && ce === "onZeroHp", oo), Q("preUpdateToken", le, so), Q("createToken", E || a("automation", "lootableNPCs") && ce === "onScene", Xr), Q("renderActorSheet", ue || O || de || fe || c || k || j, Do), Q("renderItemSheet", A, Io);
	let ve = y("customPauseImage"), ye = y("customPauseText"), be = y("pauseImageNoSpin");
	Q("renderGamePause", ve !== "" || ye !== "" || be, Fo), Q("ready", y("legacyVariantRuleAncestryParagon") || y("legacyVariantRuleDualClass"), co, !0);
}
Hooks.once("init", async (n) => {
	h(`${e} | Initializing xdy-pf2e-workbench`), f(u.INIT), ts(), It(), await t(), E(Lt(), "registerNpcRollerHandlebarsTemplates"), E(sn(), "registerBasicActionMacrosHandlebarsTemplates"), ss(), Ct(), $();
}), Hooks.once("setup", async () => {
	h(`${e} | Setting up`), f(u.SETUP);
}), Hooks.once("ready", () => {
	h(`${e} | Ready`), f(u.READY);
	let t = {
		resetHeroPoints: Qe,
		addHeroPoints: $e,
		scaleNPCToLevelFromActor: Xt,
		moveSelectedAheadOfCurrent: rt,
		doMystificationFromToken: ke,
		generateNameFromTraitsFromTokenId: xe,
		noOrSuccessfulFlatcheck: gn,
		basicActionMacros: pn,
		refocus: is,
		followTheExpert: an,
		hypercognition: as,
		buildNpcSpellbookJournal: mn,
		callHeroPointHandler: We,
		mystifyNpcItemsByRarity: Yr,
		getAllFromAllowedPacks: ns,
		npcScaler: os,
		autoRollDamage: hn
	};
	game.PF2eWorkbench = t, console.debug(`${e} | game.PF2eWorkbench registered`, !!game.PF2eWorkbench);
	let n = y("autoRollDamageForSpellWhenNotAnAttack");
	game.modules.get("pf2e-toolbelt")?.active && (n === "anySpell" || n === "saveSpell") && Nn(), game.modules.get("pf2e-sheet-skill-actions")?.active && ui.notifications.error(game.i18n.localize(`${e}.modules.pf2e-sheet-skill-actions`)), game.modules.get("pf2e-toolbox")?.active && ui.notifications.error(game.i18n.localize(`${e}.modules.pf2e-toolbox`));
	let r = y("tokenAnimation"), i = game.modules.get("multilevel-tokens");
	if (r && i?.active && ui.notifications.error(game.i18n.localize(`${e}.modules.multilevel-tokens`)), $(), C() && y("heroPointHandler")) {
		let e = Ze(!1);
		(e > 0 || y("heroPointHandlerStartTimerOnReady")) && (e = Ze(!0), Ue(e).then(() => {
			Ge(e);
		}));
	}
	game.socket.on("module." + e, (e) => {
		switch (e?.operation) {
			case "updateHooks":
				game.user.isGM || $();
				break;
			case "notification":
				if (!game.user.isGM) {
					let t = e.args[0], n = e.args[1];
					ui.notifications.notify(n, t);
				}
				break;
			default: break;
		}
	}), f(u.ACTIVE), Hooks.callAll(`${e}.moduleReady`);
});
//#endregion
export { ls as CHARACTER_TYPE, cs as NPC_TYPE, u as Phase, $ as updateHooks };

//# sourceMappingURL=xdy-pf2e-workbench.js.map