import { create } from 'zustand';
import { createTeleporter } from 'react-teleporter';
export const useTeleporterStore = create((set, get) => ({
    teleporterMap: new Map(),
    getTeleporter: (targetId = '', location) => {
        const mapCopy = new Map(get().teleporterMap); // clone to maintain reactivity
        let locationMap = mapCopy.get(targetId);
        if (!locationMap) {
            locationMap = new Map();
            mapCopy.set(targetId, locationMap);
        }
        if (!locationMap.has(location)) {
            locationMap.set(location, {
                teleporter: createTeleporter()
            });
        }
        const teleporter = locationMap.get(location).teleporter;
        // Update store
        set({ teleporterMap: mapCopy });
        return teleporter;
    },
    getAllTeleporters: () => {
        const result = [];
        const map = get().teleporterMap;
        for (const [targetId, locationMap] of map.entries()) {
            for (const [location, entry] of locationMap.entries()) {
                result.push([targetId, location, entry.teleporter]);
            }
        }
        return result;
    }
}));
//# sourceMappingURL=teleporterStore.js.map