import { ItemStack, system, world } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";
import config from "../config";
import { Button, Buttons, giveItem } from "../others/my_API";
class TutorialBookButtons {
}
TutorialBookButtons.pillar_regeneration = new Button('nps_tbe:tutorial_book.pillar_regeneration', 'ui/icon_end_crystal');
TutorialBookButtons.travel_stone = new Button('nps_tbe:tutorial_book.travel_stone', 'ui/icon_travel_stone');
TutorialBookButtons.altar = new Button('nps_tbe:tutorial_book.altar', undefined);
TutorialBookButtons.void_totem = new Button('nps_tbe:tutorial_book.void_totem', 'items/void_totem');
TutorialBookButtons.aether_wand = new Button('nps_tbe:tutorial_book.aether_wand', 'items/aether_wand');
TutorialBookButtons.chorusflare = new Button('nps_tbe:tutorial_book.chorusflare', 'items/chorusflare_sprout');
//
TutorialBookButtons.new_ore = new Button('nps_tbe:tutorial_book.new_ore', 'items/ores/enderite_ingot');
TutorialBookButtons.new_armor = new Button('nps_tbe:tutorial_book.new_armor', 'items/enderite/enderite_chestplate');
TutorialBookButtons.upgrade_templates = new Button('nps_tbe:tutorial_book.upgrade_templates', 'items/celestium_upgrade_smithing_template');
TutorialBookButtons.monster_drops = new Button('nps_tbe:tutorial_book.monster_drops', 'items/thornshade_claws');
//
TutorialBookButtons.dungeons = new Button('nps_tbe:tutorial_book.dungeons', 'ui/icon_bookshelf');
//
TutorialBookButtons.skiropteron = new Button('nps_tbe:tutorial_book.skiropteron', 'items/skiropteron_feather');
TutorialBookButtons.stellarmanta = new Button('nps_tbe:tutorial_book.stellarmanta', 'ui/icon_stellarmanta');
TutorialBookButtons.spoofykin = new Button('nps_tbe:tutorial_book.spoofykin', 'items/stellar_iron/stellar_iron_pickaxe');
//
TutorialBookButtons.introduction = new Button('nps_tbe:tutorial_book.introduction', 'ui/icon_introduction');
TutorialBookButtons.gameplay = new Button('nps_tbe:tutorial_book.gameplay', 'ui/icon_gameplay');
TutorialBookButtons.commands = new Button('nps_tbe:tutorial_book.commands', 'ui/icon_gear');
TutorialBookButtons.faq = new Button('nps_tbe:tutorial_book.faq', 'ui/icon_question_mark');
TutorialBookButtons.community = new Button('nps_tbe:tutorial_book.community', 'ui/icon_community');
export class SettingsToolButtons {
}
SettingsToolButtons.damage_indicators = new Button('nps_tbe:form_button.damage_indicators', undefined);
SettingsToolButtons.monster_regen = new Button('nps_tbe:form_button.monster_regen', undefined);
SettingsToolButtons.life_indicators = new Button('nps_tbe:form_button.life_indicators', undefined);
SettingsToolButtons.entity_name_indicators = new Button('nps_tbe:form_button.entity_name_indicators', undefined);
;
export class Setting {
    constructor(id, defaultValue, button) {
        this.id = id;
        this.defaultValue = defaultValue;
        if (button !== undefined) {
            this.button = button;
        }
        else {
            this.button = undefined;
        }
    }
    getDescription() {
        return `nps_mot:${this.id}Description`;
    }
}
export var parameterNames;
(function (parameterNames) {
    parameterNames["damageIndicators"] = "damageIndicators";
    parameterNames["lifeIndicators"] = "lifeIndicators";
    parameterNames["entityNameIndicators"] = "entityNameIndicators";
    parameterNames["monsterRegen"] = "monsterRegen";
})(parameterNames || (parameterNames = {}));
;
export class Settings {
    static getSettingsScoreboard() {
        let scoreboard = world.scoreboard.getObjective(this.objectiveId);
        if (!scoreboard) {
            scoreboard = world.scoreboard.addObjective(this.objectiveId, this.objectiveId);
            for (const setting of this.settings) {
                scoreboard.setScore(setting.id, setting.defaultValue);
            }
        }
        for (const setting of this.settings) {
            if (scoreboard.hasParticipant(setting.id) == false) {
                scoreboard.addScore(setting.id, setting.defaultValue);
            }
        }
        return scoreboard;
    }
    static getSetting(settingId) {
        return this.settings.find(setting => setting.id === settingId);
    }
    static getValue(settingId) {
        const scoreboard = this.getSettingsScoreboard();
        const score = scoreboard.getScore(settingId);
        return score !== undefined ? score : undefined;
    }
    static setValue(settingId, value) {
        const scoreboard = this.getSettingsScoreboard();
        scoreboard.setScore(settingId, value);
    }
}
Settings.objectiveId = config.settingsObjectiveId;
Settings.settings = [
    new Setting(parameterNames.damageIndicators, 1, SettingsToolButtons.damage_indicators),
    new Setting(parameterNames.lifeIndicators, 1, SettingsToolButtons.life_indicators),
    new Setting(parameterNames.entityNameIndicators, 1, SettingsToolButtons.entity_name_indicators),
    new Setting(parameterNames.monsterRegen, 1, SettingsToolButtons.monster_regen),
];
class SettingsTool {
    static initialize(event) { event.itemComponentRegistry.registerCustomComponent(this.componentName, new this()); }
    onUse(event) {
        const player = event.source;
        const isAdmin = player.hasTag(config.adminTag);
        if (isAdmin) {
            SettingsTool.openAdminSettingsToolForm(player);
        }
        else {
            SettingsTool.openSettingsToolForm(player);
        }
    }
    static openSettingsToolForm(player) {
        const form = new ActionFormData();
        form.title({ translate: 'item.nps_tbe:settings_tool' });
        form.body({ translate: 'nps_tbe:settings_tool.you_are_not_admin' });
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player);
    }
    static openAdminSettingsToolForm(player) {
        const form = new ActionFormData();
        form.title({ translate: 'item.nps_tbe:settings_tool' });
        form.body({ translate: 'nps_tbe:form_body.choose_gamerule' });
        const settingsKeysWithDescriptions = [
            { key: parameterNames.damageIndicators },
            { key: parameterNames.lifeIndicators },
            { key: parameterNames.entityNameIndicators },
            { key: parameterNames.monsterRegen },
        ];
        settingsKeysWithDescriptions.forEach(({ key }, index) => {
            const setting = Settings.getSetting(key);
            const currentValue = Settings.getValue(key);
            const buttonLabel = currentValue ? 'nps_tbe:form_button.toggle_on' : 'nps_tbe:form_button.toggle_off';
            const text = {
                translate: "nps_tbe:gap_form_text",
                with: {
                    rawtext: [
                        { translate: setting.button.rawtext },
                        { text: '\n' },
                        { translate: buttonLabel }
                    ]
                }
            };
            form.button(text, setting.button.iconPath);
        });
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player).then(response => {
            if (response.canceled || response.selection === undefined) {
                return;
            }
            const selectedSetting = settingsKeysWithDescriptions[response.selection]?.key;
            if (selectedSetting) {
                this.openSettingsToggleForm(player, selectedSetting);
            }
        });
    }
    static openSettingsToggleForm(player, settingName) {
        const setting = Settings.getSetting(settingName);
        const currentValue = Settings.getValue(settingName);
        const description = `nps_tbe:${setting.id}.description`;
        const form = new ModalFormData();
        form.title({ translate: `item.nps_tbe:settings_tool` });
        form.toggle({ translate: description }, currentValue === 1);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            const toggleResponse = response.formValues[0];
            if (toggleResponse !== currentValue) {
                const messageKey = toggleResponse ? 'enable_message' : 'disable_message';
                const message = `nps_tbe:${setting.id}.${messageKey}`;
                world.sendMessage([config.addonPrefix, { translate: message }]);
                Settings.setValue(settingName, toggleResponse);
            }
        });
    }
}
SettingsTool.componentName = "nps_tbe:settings_tool";
export class TutorialBook {
    static initialize(event) { event.itemComponentRegistry.registerCustomComponent(this.componentName, new this()); }
    onUse(event) {
        const player = event.source;
        TutorialBook.openMainMenu(player);
    }
    static openMainMenu(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.main_title" });
        form.body({ translate: "nps_tbe:tutorial_book.welcome_message" });
        form.button(TutorialBookButtons.introduction.rawtext, TutorialBookButtons.introduction.iconPath);
        form.button(TutorialBookButtons.gameplay.rawtext, TutorialBookButtons.gameplay.iconPath);
        form.button(TutorialBookButtons.commands.rawtext, TutorialBookButtons.commands.iconPath);
        form.button(TutorialBookButtons.faq.rawtext, TutorialBookButtons.faq.iconPath);
        form.button(TutorialBookButtons.community.rawtext, TutorialBookButtons.community.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openIntroduction(player);
                    break;
                case 1:
                    this.openSpoilerAlert(player);
                    break;
                case 2:
                    this.openCommands(player);
                    break;
                case 3:
                    this.openFAQ(player);
                    break;
                case 4:
                    this.openCommunity(player);
                    break;
            }
        });
    }
    static openIntroduction(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.introduction_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_1' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_2' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_3' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_4' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_5' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_6' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_7' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_8' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_9' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_10' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_11' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_12' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_13' },
                    { translate: 'nps_tbe:tutorial_book.introduction_body.line_14' },
                ] }
        };
        form.body(bodyText);
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player);
    }
    static openSpoilerAlert(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.spoiler_alert_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.spoiler_alert_body.line_1' },
                    { translate: 'nps_tbe:tutorial_book.spoiler_alert_body.line_2' },
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.access_anyway.rawtext, Buttons.access_anyway.iconPath);
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openGameplay(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.gameplay_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.gameplay_body.line_1' }
                ] }
        };
        form.body(bodyText);
        form.button(TutorialBookButtons.pillar_regeneration.rawtext, TutorialBookButtons.pillar_regeneration.iconPath);
        form.button(TutorialBookButtons.travel_stone.rawtext, TutorialBookButtons.travel_stone.iconPath);
        form.button(TutorialBookButtons.void_totem.rawtext, TutorialBookButtons.void_totem.iconPath);
        form.button(TutorialBookButtons.aether_wand.rawtext, TutorialBookButtons.aether_wand.iconPath);
        form.button(TutorialBookButtons.chorusflare.rawtext, TutorialBookButtons.chorusflare.iconPath);
        form.button(TutorialBookButtons.new_ore.rawtext, TutorialBookButtons.new_ore.iconPath);
        form.button(TutorialBookButtons.new_armor.rawtext, TutorialBookButtons.new_armor.iconPath);
        form.button(TutorialBookButtons.upgrade_templates.rawtext, TutorialBookButtons.upgrade_templates.iconPath);
        form.button(TutorialBookButtons.monster_drops.rawtext, TutorialBookButtons.monster_drops.iconPath);
        form.button(TutorialBookButtons.dungeons.rawtext, TutorialBookButtons.dungeons.iconPath);
        form.button(TutorialBookButtons.skiropteron.rawtext, TutorialBookButtons.skiropteron.iconPath);
        form.button(TutorialBookButtons.stellarmanta.rawtext, TutorialBookButtons.stellarmanta.iconPath);
        form.button(TutorialBookButtons.spoofykin.rawtext, TutorialBookButtons.spoofykin.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openPillarRegenerationForm(player);
                    break;
                case 1:
                    this.openTravelStoneForm(player);
                    break;
                case 2:
                    this.openVoidTotemForm(player);
                    break;
                case 3:
                    this.openAetherWandForm(player);
                    break;
                case 4:
                    this.openChorusFlareForm(player);
                    break;
                case 5:
                    this.openNewOresForm(player);
                    break;
                case 6:
                    this.openNewArmorsForm(player);
                    break;
                case 7:
                    this.openUpgradeTemplatesForm(player);
                    break;
                case 8:
                    this.openMonsterDropsForm(player);
                    break;
                case 9:
                    this.openDungeonsForm(player);
                    break;
                case 10:
                    this.openSkiropteronForm(player);
                    break;
                case 11:
                    this.openStellarmantaForm(player);
                    break;
                case 12:
                    this.openSpoofykinForm(player);
                    break;
            }
        });
    }
    static openChorusFlareForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.chorusflare.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.chorusflare.line_1' },
                    { translate: 'nps_tbe:tutorial_book.chorusflare.line_2' },
                    { translate: 'nps_tbe:tutorial_book.chorusflare.line_3' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openStellarmantaForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.skiropteron.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.stellarmanta.line_1' },
                    { translate: 'nps_tbe:tutorial_book.stellarmanta.line_2' },
                    { translate: 'nps_tbe:tutorial_book.stellarmanta.line_3' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openSkiropteronForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.skiropteron.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_1' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_2' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_3' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_4' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_5' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_6' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_7' },
                    { translate: 'nps_tbe:tutorial_book.skiropteron.line_8' },
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openAltarForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.altar.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.altar.line_1' },
                    { translate: 'nps_tbe:tutorial_book.altar.line_2' },
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openVoidTotemForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.void_totem.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.void_totem.line_1' },
                    { translate: 'nps_tbe:tutorial_book.void_totem.line_2' },
                    { translate: 'nps_tbe:tutorial_book.void_totem.line_3' },
                    { translate: 'nps_tbe:tutorial_book.void_totem.line_4' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openTravelStoneForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.travel_stone.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_1' },
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_2' },
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_3' },
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_4' },
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_5' },
                    { translate: 'nps_tbe:tutorial_book.travel_stone.line_6' },
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openSpoofykinForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.spoofykin.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_1' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_2' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_3' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_4' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_5' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_6' },
                    { translate: 'nps_tbe:tutorial_book.spoofykin.line_7' },
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openAetherWandForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.aether_wand.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.aether_wand.line_1' },
                    { translate: 'nps_tbe:tutorial_book.aether_wand.line_2' },
                    { translate: 'nps_tbe:tutorial_book.aether_wand.line_3' },
                    { translate: 'nps_tbe:tutorial_book.aether_wand.line_4' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openNewOresForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.new_ore.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.new_ore.line_1' },
                    { translate: 'nps_tbe:tutorial_book.new_ore.line_2' },
                    { translate: 'nps_tbe:tutorial_book.new_ore.line_3' },
                    { translate: 'nps_tbe:tutorial_book.new_ore.line_4' },
                    { translate: 'nps_tbe:tutorial_book.new_ore.line_5' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openNewArmorsForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.new_armor.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.new_armor.line_1' },
                    { translate: 'nps_tbe:tutorial_book.new_armor.line_2' },
                    { translate: 'nps_tbe:tutorial_book.new_armor.line_3' },
                    { translate: 'nps_tbe:tutorial_book.new_armor.line_4' },
                    { translate: 'nps_tbe:tutorial_book.new_armor.line_5' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openUpgradeTemplatesForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.upgrade_templates.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.upgrade_templates.line_1' },
                    { translate: 'nps_tbe:tutorial_book.upgrade_templates.line_2' },
                    { translate: 'nps_tbe:tutorial_book.upgrade_templates.line_3' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openMonsterDropsForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.monster_drops.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.monster_drops.line_1' },
                    { translate: 'nps_tbe:tutorial_book.monster_drops.line_2' },
                    { translate: 'nps_tbe:tutorial_book.monster_drops.line_3' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openDungeonsForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.dungeons.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.dungeons.line_1' },
                    { translate: 'nps_tbe:tutorial_book.dungeons.line_2' },
                    { translate: 'nps_tbe:tutorial_book.dungeons.line_3' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openPillarRegenerationForm(player) {
        const form = new ActionFormData();
        form.title(TutorialBookButtons.pillar_regeneration.rawtext);
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.pillar_regeneration_body.line_1' },
                    { translate: 'nps_tbe:tutorial_book.pillar_regeneration_body.line_2' }
                ] }
        };
        form.body(bodyText);
        form.button(Buttons.back.rawtext, Buttons.back.iconPath);
        form.show(player).then(response => {
            if (response.canceled)
                return;
            switch (response.selection) {
                case 0:
                    this.openGameplay(player);
                    break;
            }
        });
    }
    static openCommands(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.commands_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.commands_body.line_1' },
                    { translate: 'nps_tbe:tutorial_book.commands_body.line_2' },
                    { translate: 'nps_tbe:tutorial_book.commands_body.line_3' },
                ] }
        };
        form.body(bodyText);
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player);
    }
    static openFAQ(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.faq_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.faq_body.line_1' },
                    { translate: 'nps_tbe:tutorial_book.faq_body.line_2' },
                    { translate: 'nps_tbe:tutorial_book.faq_body.line_3' },
                    { translate: 'nps_tbe:tutorial_book.faq_body.line_4' },
                    { text: `${config.discordLink}` },
                    { text: '\n§§' }
                ] }
        };
        form.body(bodyText);
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player);
    }
    static openCommunity(player) {
        const form = new ActionFormData();
        form.title({ translate: "nps_tbe:tutorial_book.community_title" });
        const bodyText = {
            translate: "nps_tbe:gap_form_text",
            with: { rawtext: [
                    { translate: 'nps_tbe:tutorial_book.community_body' },
                    { text: `${config.discordLink}` },
                    { text: '\n§§' }
                ] }
        };
        form.body(bodyText);
        //form.button(Buttons.close.rawtext, Buttons.close.iconPath);
        form.show(player);
    }
}
TutorialBook.componentName = "nps_tbe:tutorial_book";
world.beforeEvents.worldInitialize.subscribe(event => {
    SettingsTool.initialize(event);
    TutorialBook.initialize(event);
});
export class NPS_TBE {
    static getTutorialBook() {
        const item = new ItemStack(`nps_tbe:tutorial_book`);
        item.keepOnDeath = true;
        item.setLore(['', config.addonFullName, config.credits]);
        return item;
    }
    static getSettingsTool() {
        const item = new ItemStack(`nps_tbe:settings_tool`);
        item.keepOnDeath = true;
        item.setLore(['', config.addonFullName, config.credits]);
        return item;
    }
    static getGFXTool() {
        const item = new ItemStack(`nps_tbe:gfx_config`);
        item.keepOnDeath = true;
        item.setLore(['', config.addonFullName, config.credits]);
        return item;
    }
}
system.runInterval(() => {
    world.getAllPlayers().forEach(player => {
        if (player.hasTag(config.tutorialPassedTag) == false) {
            giveEssentials(player);
            player.addTag(config.tutorialPassedTag);
        }
    });
}, 100);
function giveEssentials(player) {
    ;
    giveItem(player, NPS_TBE.getTutorialBook());
    giveItem(player, NPS_TBE.getSettingsTool());
    giveItem(player, NPS_TBE.getGFXTool());
    player.sendMessage([config.addonPrefix, { translate: `nps_tbe:giveTutorialPack` }]);
}
