"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeMessageListener = makeMessageListener;
exports.listenMessage = listenMessage;
function makeMessageListener(listener, _global = false) {
    return (component) => {
        return listenMessage(component, listener, _global);
    };
}
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);
    };
}
//# sourceMappingURL=message.js.map