"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    canvasEventBus: ()=>canvasEventBus
});
class EventBus {
    listeners = new Map();
    emit(eventName, payload) {
        const listeners = this.listeners.get(eventName);
        if (listeners) {
            const enrichedPayload = {
                ...payload,
                timestamp: Date.now()
            };
            listeners.forEach((callback)=>callback(enrichedPayload));
        }
    }
    on(eventName, callback) {
        if (!this.listeners.has(eventName)) this.listeners.set(eventName, new Set());
        this.listeners.get(eventName).add(callback);
        return ()=>this.off(eventName, callback);
    }
    off(eventName, callback) {
        this.listeners.get(eventName)?.delete(callback);
        if (this.listeners.get(eventName)?.size === 0) this.listeners.delete(eventName);
    }
    once(eventName, callback) {
        const wrappedCallback = (payload)=>{
            callback(payload);
            this.off(eventName, wrappedCallback);
        };
        return this.on(eventName, wrappedCallback);
    }
    clear() {
        this.listeners.clear();
    }
}
const canvasEventBus = new EventBus();
exports.canvasEventBus = __webpack_exports__.canvasEventBus;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "canvasEventBus"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
