import { after, before } from '@ephox/bedrock-client';
import { Fun, Optional } from '@ephox/katamari';
import { Compare, PredicateExists } from '@ephox/sugar';
import * as Behaviour from 'ephox/alloy/api/behaviour/Behaviour';
import { Positioning } from 'ephox/alloy/api/behaviour/Positioning';
import * as GuiFactory from 'ephox/alloy/api/component/GuiFactory';
import { Container } from 'ephox/alloy/api/ui/Container';
const fixedSink = () => GuiFactory.build(Container.sketch({
    dom: {
        styles: {
            border: '1px solid green'
        }
    },
    uid: 'fixed-sink',
    containerBehaviours: Behaviour.derive([
        Positioning.config({
            useFixed: Fun.always
        })
    ])
}));
const relativeSink = () => GuiFactory.build(Container.sketch({
    dom: {
        tag: 'div',
        styles: {
            border: '1px solid blue'
        }
    },
    uid: 'relative-sink',
    containerBehaviours: Behaviour.derive([
        Positioning.config({
            useFixed: Fun.always
        })
    ])
}));
const popup = () => GuiFactory.build(Container.sketch({
    dom: {
        innerHtml: 'Demo day',
        styles: {
            width: '200px',
            height: '150px',
            border: 'inherit'
        }
    },
    uid: 'popup'
}));
const isInside = (sinkComponent, popupComponent) => {
    const isSink = (el) => Compare.eq(el, sinkComponent.element);
    return PredicateExists.closest(popupComponent.element, isSink);
};
const bddSetup = () => {
    let fixed;
    let relative;
    let pop;
    before(() => {
        fixed = Optional.some(fixedSink());
        relative = Optional.some(relativeSink());
        pop = Optional.some(popup());
    });
    after(() => {
        fixed = relative = pop = Optional.none();
    });
    return {
        fixed: () => fixed.getOrDie('Fixed sink not initialized'),
        relative: () => relative.getOrDie('Relative sink not initialized'),
        popup: () => pop.getOrDie('Popup not initialized')
    };
};
export { fixedSink, isInside, relativeSink, popup, bddSetup };
//# sourceMappingURL=Sinks.js.map