import { world } from '@minecraft/server';
import FSFormNavigationController from './FSFormNavController';
class FSFormManager {
    constructor() {
        this.formNavControllers = {}; 
    }
    static sharedInstance() {
        if (FSFormManager.instance === null) {
            FSFormManager.instance = new FSFormManager();
            world.afterEvents.playerLeave.subscribe((eventData) => {
                if (eventData.playerId && FSFormManager.instance?.formNavControllers[eventData.playerId]) {
                    delete FSFormManager.instance.formNavControllers[eventData.playerId];
                }
            });
            world.afterEvents.playerJoin.subscribe((eventData) => {
                if (eventData.playerId && FSFormManager.instance?.formNavControllers[eventData.playerId]) {
                    delete FSFormManager.instance.formNavControllers[eventData.playerId];
                }
            });
        }
        return FSFormManager.instance;
    }
    navigationControllerForPlayer(player, clearStack = false, persistWithNamespace = '') {
        const playerKey = player.id;
        if (!this.formNavControllers[playerKey] || clearStack) {
            this.formNavControllers[playerKey] = new FSFormNavigationController(player);
        }
        else {
        }
        return this.formNavControllers[playerKey];
    }
    clearStackForPlayer(player) {
        if (player && FSFormManager.instance?.formNavControllers[player.id]) {
            delete FSFormManager.instance.formNavControllers[player.id];
        }
    }
}
FSFormManager.instance = null;
export default FSFormManager;

//# sourceMappingURL=../../../../../../_SBUNK_BPDebug/fs_sbunk/fs/libs/forms/FSFormManager.js.map
