import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var getPosition=function(a,b){return{x:Math.round(a),y:Math.round(b)}};export var getPointPossition=function(a,b,c){if(b){if(!c)return b;var d=a.getBoundingClientRect(),e=getPosition(b.x-d.left,b.y-d.top);return e}};export var getRenderPosition=function(a,b,c,d,e){if(d&&e){if(!c)return getPosition(((null===b||void 0===b?void 0:b.x)||0)+window.scrollX,((null===b||void 0===b?void 0:b.y)||0)+window.scrollY);var f=a.getBoundingClientRect();return!b||0>b.x||0>b.y||b.x+d>a.clientWidth||b.y+e>a.clientHeight?void 0:getPosition(((null===b||void 0===b?void 0:b.x)||0)+window.scrollX+f.left,((null===b||void 0===b?void 0:b.y)||0)+window.scrollY+f.top)}};export var getPositionsByDirection=function(a){var b=a.contentSize,c=a.anchorSize,d=a.position,e=d.x,f=d.y,g=a.arrowOffset,h=void 0===g?0:g,i=a.offset,j=void 0===i?0:i,k=b.width,l=b.height,m=c.width,n=c.height,o={x:e+m/2,y:f+n/2},p=e+m+j,q=e-k-j,r={right:o.x-h,center:o.x-k/2,left:o.x-k+h},s=f+n+j,t=f-l-j,u={up:o.y-l+h,center:o.y-l/2,down:o.y-h},v=e,w=e-k+m,x=f,y=f-l+n;return{upLeft:getPosition(r.left,t),upCenter:getPosition(r.center,t),upRight:getPosition(r.right,t),downLeft:getPosition(r.left,s),downCenter:getPosition(r.center,s),downRight:getPosition(r.right,s),rightUp:getPosition(p,u.up),rightCenter:getPosition(p,u.center),rightDown:getPosition(p,u.down),leftUp:getPosition(q,u.up),leftCenter:getPosition(q,u.center),leftDown:getPosition(q,u.down),downStartLeft:getPosition(v,s),downStartRight:getPosition(w,s),upStartLeft:getPosition(v,t),upStartRight:getPosition(w,t),leftStartUp:getPosition(q,x),leftStartDown:getPosition(q,y),rightStartUp:getPosition(p,x),rightStartDown:getPosition(p,y)}};export var getComputedPositionAndDirection=function(a){var b=a.position,c=a.contentSize,d=a.viewportSize,e=a.anchorSize,f=void 0===e?{width:0,height:0}:e,g=a.arrowOffset,h=a.direction,i=a.possibleDirections,j=a.bannedDirections,k=a.spareDirection,l=a.offset,m=void 0===l?0:l;if(!b)return{position:b,direction:h};var n=getPositionsByDirection({contentSize:c,anchorSize:f,position:b,arrowOffset:g,offset:m}),o=[h].concat(_toConsumableArray(i)).filter(function(a){return!j.includes(a)}).find(function(a){var b=n[a],e=c.width,f=c.height,g=b.y+f<=d.height,h=0<=b.y,i=0<=b.x,j=b.x+e<=d.width;return h&&g&&i&&j})||k;return{direction:o,position:n[o]}};
//# sourceMappingURL=helpers.js.map