import { ModalFormData } from '@minecraft/server-ui';
/**
 * Handles the settings UI
 */
export class SettingsUI {
    settingsManager;
    constructor(settingsManager) {
        this.settingsManager = settingsManager;
    }
    /**
     * Show the main settings menu
     */
    async showSettingsMenu(player) {
        const currentSettings = this.settingsManager.getSettings(player);
        const form = new ModalFormData()
            .title("§l§6Settings")
            .toggle("§bGhost Mode\n§7Makes you invisible with visible boots", { defaultValue: currentSettings.ghostMode })
            .toggle("§bDisable Checkpoint Item\n§7Removes checkpoint teleport from hotbar", { defaultValue: currentSettings.disableCheckpointItem });
        try {
            const response = await form.show(player);
            if (response.canceled) {
                return;
            }
            // Get form values (they come in order they were added)
            const ghostMode = response.formValues?.[0] ?? currentSettings.ghostMode;
            const disableCheckpoint = response.formValues?.[1] ?? currentSettings.disableCheckpointItem;
            // Update settings
            const newSettings = {
                ghostMode: ghostMode,
                disableCheckpointItem: disableCheckpoint
            };
            this.settingsManager.saveSettings(player, newSettings);
            // Apply ghost mode immediately if changed
            if (ghostMode !== currentSettings.ghostMode) {
                this.settingsManager.applyGhostMode(player, ghostMode);
            }
            player.sendMessage("§aSettings saved!");
            player.playSound("random.orb");
        }
        catch (error) {
            player.sendMessage("§cError showing settings menu!");
        }
    }
}
