import { create } from 'zustand';
export const useRouteRegistry = create((set) => ({
    currentPath: window.location.pathname,
    routeMap: {},
    isCurrentRouteInitialized: false,
    setPath: (path) => set((state) => {
        var _a;
        return ({
            currentPath: path,
            isCurrentRouteInitialized: ((_a = state.routeMap[path]) === null || _a === void 0 ? void 0 : _a.isPublic) !== undefined
        });
    }),
    registerRoute: (path, config) => set((state) => {
        const nextRouteMap = Object.assign(Object.assign({}, state.routeMap), { [path]: config });
        const currentRouteConfig = nextRouteMap[state.currentPath];
        return {
            routeMap: nextRouteMap,
            isCurrentRouteInitialized: (currentRouteConfig === null || currentRouteConfig === void 0 ? void 0 : currentRouteConfig.isPublic) !== undefined
        };
    }),
}));
// Helper to access state outside of React components (e.g., in Axios/Fetch interceptors)
export const getRouteConfig = () => {
    const state = useRouteRegistry.getState();
    return state.routeMap[state.currentPath];
};
export const getCurrentRouteInitialized = () => {
    const state = useRouteRegistry.getState();
    return state.isCurrentRouteInitialized;
};
//# sourceMappingURL=routeRegistryStore.js.map