import { Cell, Fun } from '@ephox/katamari';
const fromSource = (event, source) => {
    const stopper = Cell(false);
    const cutter = Cell(false);
    const stop = () => {
        stopper.set(true);
    };
    const cut = () => {
        cutter.set(true);
    };
    return {
        stop,
        cut,
        isStopped: stopper.get,
        isCut: cutter.get,
        event,
        // Used only for tiered menu at the moment. It is an element, not a component
        setSource: source.set,
        getSource: source.get
    };
};
// Events that come from outside of the alloy root (e.g. window scroll)
const fromExternal = (event) => {
    const stopper = Cell(false);
    const stop = () => {
        stopper.set(true);
    };
    return {
        stop,
        cut: Fun.noop,
        isStopped: stopper.get,
        isCut: Fun.never,
        event,
        // Nor do targets really
        setSource: Fun.die('Cannot set source of a broadcasted event'),
        getSource: Fun.die('Cannot get source of a broadcasted event')
    };
};
const fromTarget = (event, target) => {
    const source = Cell(target);
    return fromSource(event, source);
};
export { fromSource, fromExternal, fromTarget };
//# sourceMappingURL=SimulatedEvent.js.map