"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeToggleListener = makeToggleListener;
function makeToggleListener(listener) {
    return (component) => {
        const { $element } = component;
        const toggleListener = (_event) => {
            const { newState, oldState } = _event;
            if (newState !== oldState) {
                const open = newState === 'open' ? true : false;
                listener(open, _event);
            }
        };
        $element.addEventListener('toggle', toggleListener);
        return () => {
            $element.removeEventListener('toggle', toggleListener);
        };
    };
}
//# sourceMappingURL=toggle.js.map