"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listenMessage = exports.makeMessageListener = void 0;
function makeMessageListener(listener, _global = false) {
    return (component) => {
        return listenMessage(component, listener, _global);
    };
}
exports.makeMessageListener = makeMessageListener;
function listenMessage(component, listener, _global = false) {
    const { $element } = component;
    const messageListener = (_event) => {
        listener(_event.data, _event);
    };
    $element.addEventListener('message', messageListener);
    return () => {
        $element.removeEventListener('message', messageListener);
    };
}
exports.listenMessage = listenMessage;
//# sourceMappingURL=message.js.map