"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDndMonitorProvider = void 0;
var react_1 = require("react");
var useDndMonitorProvider = function () {
    var listeners = (0, react_1.useState)(function () { return new Set(); })[0];
    var registerListener = (0, react_1.useCallback)(function (listener) {
        listeners.add(listener);
        return function () { return listeners.delete(listener); };
    }, [listeners]);
    var dispatch = (0, react_1.useCallback)(function (_a) {
        var type = _a.type, event = _a.event;
        listeners.forEach(function (listener) { var _a; return (_a = listener[type]) === null || _a === void 0 ? void 0 : _a.call(listener, event); });
    }, [listeners]);
    return [dispatch, registerListener];
};
exports.useDndMonitorProvider = useDndMonitorProvider;
