import { nu as NuSpotInfo } from '../view/SpotInfo';
import * as Direction from './Direction';
import { boundsRestriction } from './LayoutBounds';
/*
  Layout for menus and inline context dialogs;
  Either above or below. Never left or right.
  Aligned to the left or right of the anchor as appropriate.
 */
const labelPrefix = 'layout';
// display element to the right, left edge against the anchor
const eastX = (anchor) => anchor.x;
// element centre aligned horizontally with the anchor
const middleX = (anchor, element) => anchor.x + (anchor.width / 2) - (element.width / 2);
// display element to the left, right edge against the right of the anchor
const westX = (anchor, element) => anchor.x + anchor.width - element.width;
// display element above, bottom edge against the top of the anchor
const northY = (anchor, element) => anchor.y - element.height;
// display element below, top edge against the bottom of the anchor
const southY = (anchor) => anchor.y + anchor.height;
// display element below, top edge against the bottom of the anchor
const centreY = (anchor, element) => anchor.y + (anchor.height / 2) - (element.height / 2);
const eastEdgeX = (anchor) => anchor.x + anchor.width;
const westEdgeX = (anchor, element) => anchor.x - element.width;
const southeast = (anchor, element, bubbles) => NuSpotInfo(eastX(anchor), southY(anchor), bubbles.southeast(), Direction.southeast(), "southeast" /* Placement.Southeast */, boundsRestriction(anchor, { left: 1 /* AnchorBoxBounds.LeftEdge */, top: 3 /* AnchorBoxBounds.BottomEdge */ }), labelPrefix);
const southwest = (anchor, element, bubbles) => NuSpotInfo(westX(anchor, element), southY(anchor), bubbles.southwest(), Direction.southwest(), "southwest" /* Placement.Southwest */, boundsRestriction(anchor, { right: 0 /* AnchorBoxBounds.RightEdge */, top: 3 /* AnchorBoxBounds.BottomEdge */ }), labelPrefix);
const northeast = (anchor, element, bubbles) => NuSpotInfo(eastX(anchor), northY(anchor, element), bubbles.northeast(), Direction.northeast(), "northeast" /* Placement.Northeast */, boundsRestriction(anchor, { left: 1 /* AnchorBoxBounds.LeftEdge */, bottom: 2 /* AnchorBoxBounds.TopEdge */ }), labelPrefix);
const northwest = (anchor, element, bubbles) => NuSpotInfo(westX(anchor, element), northY(anchor, element), bubbles.northwest(), Direction.northwest(), "northwest" /* Placement.Northwest */, boundsRestriction(anchor, { right: 0 /* AnchorBoxBounds.RightEdge */, bottom: 2 /* AnchorBoxBounds.TopEdge */ }), labelPrefix);
const north = (anchor, element, bubbles) => NuSpotInfo(middleX(anchor, element), northY(anchor, element), bubbles.north(), Direction.north(), "north" /* Placement.North */, boundsRestriction(anchor, { bottom: 2 /* AnchorBoxBounds.TopEdge */ }), labelPrefix);
const south = (anchor, element, bubbles) => NuSpotInfo(middleX(anchor, element), southY(anchor), bubbles.south(), Direction.south(), "south" /* Placement.South */, boundsRestriction(anchor, { top: 3 /* AnchorBoxBounds.BottomEdge */ }), labelPrefix);
const east = (anchor, element, bubbles) => NuSpotInfo(eastEdgeX(anchor), centreY(anchor, element), bubbles.east(), Direction.east(), "east" /* Placement.East */, boundsRestriction(anchor, { left: 0 /* AnchorBoxBounds.RightEdge */ }), labelPrefix);
const west = (anchor, element, bubbles) => NuSpotInfo(westEdgeX(anchor, element), centreY(anchor, element), bubbles.west(), Direction.west(), "west" /* Placement.West */, boundsRestriction(anchor, { right: 1 /* AnchorBoxBounds.LeftEdge */ }), labelPrefix);
const all = () => [southeast, southwest, northeast, northwest, south, north, east, west];
const allRtl = () => [southwest, southeast, northwest, northeast, south, north, east, west];
const aboveOrBelow = () => [northeast, northwest, southeast, southwest, north, south];
const aboveOrBelowRtl = () => [northwest, northeast, southwest, southeast, north, south];
const belowOrAbove = () => [southeast, southwest, northeast, northwest, south, north];
const belowOrAboveRtl = () => [southwest, southeast, northwest, northeast, south, north];
export { southeast, northeast, southwest, northwest, south, north, east, west, all, allRtl, belowOrAbove, belowOrAboveRtl, aboveOrBelow, aboveOrBelowRtl };
//# sourceMappingURL=Layout.js.map