"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useBlockRegistryProvider = useBlockRegistryProvider;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
function useBlockRegistryProvider() {
    const entriesRef = React.useRef(new Map());
    const listenersRef = React.useRef(new Set());
    return React.useMemo(() => {
        const notify = () => {
            for (const listener of listenersRef.current) {
                listener();
            }
        };
        return {
            register(pathKey, path, element, dropZone) {
                entriesRef.current.set(pathKey, { path, element, dropZone });
                notify();
            },
            unregister(pathKey) {
                if (entriesRef.current.delete(pathKey)) {
                    notify();
                }
            },
            subscribe(listener) {
                listenersRef.current.add(listener);
                return () => {
                    listenersRef.current.delete(listener);
                };
            },
            getEntries() {
                return Array.from(entriesRef.current.values());
            },
        };
    }, []);
}
//# sourceMappingURL=useBlockRegistryProvider.js.map
