text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("rxjs")):"function"==typeof define&&define.amd?define("ngx-bootstrap/positioning",["exports","@angular/core","@angular/common","rxjs"],e):e((t["ngx-bootstrap"]=t["ngx-bootstrap"]||{},t["ngx-bootstrap"].positioning={}),t.ng.core,t.ng.common,t.rxjs)}(this,function(t,e,n,r){"use strict";var g=function(){return(g=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function v(t,e){if(1!==t.nodeType)return[];var o=t.ownerDocument.defaultView.getComputedStyle(t,null);return e?o[e]:o}function m(t){return"HTML"===t.nodeName?t:t.parentNode||t.host}function d(t){if(!t)return document.body;switch(t.nodeName){case"HTML":case"BODY":return t.ownerDocument.body;case"#document":return t.body}var e=v(t),o=e.overflow,n=e.overflowX,r=e.overflowY;return/(auto|scroll|overlay)/.test(String(o)+String(r)+String(n))?t:d(m(t))}var o="undefined"!=typeof window&&"undefined"!=typeof document,i=o&&!(!window.MSInputMethodContext||!document.documentMode),a=o&&!(!window.MSInputMethodContext||!/MSIE 10/.test(navigator.userAgent));function b(t){return 11===t?i:10===t?a:i||a}function l(t){if(!t)return document.documentElement;for(var e,o=b(10)?document.body:null,n=t.offsetParent||null;n===o&&t.nextElementSibling&&"BODY"!==t.nodeName;)n=(e=t.nextElementSibling).offsetParent;var r=n&&n.nodeName;return r&&"BODY"!==r&&"HTML"!==r?-1!==["TH","TD","TABLE"].indexOf(n.nodeName)&&"static"===v(n,"position")?l(n):n:e?e.ownerDocument.documentElement:document.documentElement}function u(t){return null!==t.parentNode?u(t.parentNode):t}function w(t,e){if(!(t&&t.nodeType&&e&&e.nodeType))return document.documentElement;var o=t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING,n=o?t:e,r=o?e:t,i=document.createRange();i.setStart(n,0),i.setEnd(r,0);var a=i.commonAncestorContainer;if(t!==a&&e!==a||n.contains(r))return function s(t){var e=t.nodeName;return"BODY"!==e&&("HTML"===e||l(t.firstElementChild)===t)}(a)?a:l(a);var f=u(t);return f.host?w(f.host,e):w(t,u(e).host)}function p(t,e){var o="x"===e?"Left":"Top",n="Left"===o?"Right":"Bottom";return parseFloat(t["border"+o+"Width"])+parseFloat(t["border"+n+"Width"])}function f(t,e,o,n){return Math.max(e["offset"+t],e["scroll"+t],o["client"+t],o["offset"+t],o["scroll"+t],b(10)?parseInt(o["offset"+t],10)+parseInt(n["margin"+("Height"===t?"Top":"Left")],10)+parseInt(n["margin"+("Height"===t?"Bottom":"Right")],10):0)}function y(t){var e=t.body,o=t.documentElement,n=b(10)&&getComputedStyle(o);return{height:f("Height",e,o,n),width:f("Width",e,o,n)}}function M(t,e){void 0===e&&(e="top");var o="top"===e?"scrollTop":"scrollLeft",n=t.nodeName;if("BODY"!==n&&"HTML"!==n)return t[o];var r=t.ownerDocument.documentElement;return(t.ownerDocument.scrollingElement||r)[o]}function x(t){return g({},t,{right:t.left+t.width,bottom:t.top+t.height})}function N(t){var e={};try{if(b(10)){e=t.getBoundingClientRect();var o=M(t,"top"),n=M(t,"left");e.top+=o,e.left+=n,e.bottom+=o,e.right+=n}else e=t.getBoundingClientRect()}catch(h){return undefined}var r={left:e.left,top:e.top,width:e.right-e.left,height:e.bottom-e.top},i="HTML"===t.nodeName?y(t.ownerDocument):{},a=i.width||t.clientWidth||r.right-r.left,f=i.height||t.clientHeight||r.bottom-r.top,s=t.offsetWidth-a,l=t.offsetHeight-f;if(s||l){var u=v(t);s-=p(u,"x"),l-=p(u,"y"),r.width-=s,r.height-=l}return x(r)}function E(t,e,o){void 0===o&&(o=!1);var n=b(10),r="HTML"===e.nodeName,i=N(t),a=N(e),f=d(t),s=v(e),l=parseFloat(s.borderTopWidth),u=parseFloat(s.borderLeftWidth);o&&r&&(a.top=Math.max(a.top,0),a.left=Math.max(a.left,0));var h=x({top:i.top-a.top-l,left:i.left-a.left-u,width:i.width,height:i.height});if(h.marginTop=0,h.marginLeft=0,!n&&r){var p=parseFloat(s.marginTop),c=parseFloat(s.marginLeft);h.top-=l-p,h.bottom-=l-p,h.left-=u-c,h.right-=u-c,h.marginTop=p,h.marginLeft=c}return(n&&!o?e.contains(f):e===f&&"BODY"!==f.nodeName)&&(h=function m(t,e,o){void 0===o&&(o=!1);var n=M(e,"top"),r=M(e,"left"),i=o?-1:1;return t.top+=n*i,t.bottom+=n*i,t.left+=r*i,t.right+=r*i,t}(h,e)),h}function O(t){if(!t||!t.parentElement||b())return document.documentElement;for(var e=t.parentElement;e&&"none"===v(e,"transform");)e=e.parentElement;return e||document.documentElement}function T(t,e,o,n,r){void 0===o&&(o=0),void 0===r&&(r=!1);var i={top:0,left:0},a=r?O(t):w(t,e);if("viewport"===n)i=function p(t,e){void 0===e&&(e=!1);var o=t.ownerDocument.documentElement,n=E(t,o),r=Math.max(o.clientWidth,window.innerWidth||0),i=Math.max(o.clientHeight,window.innerHeight||0),a=e?0:M(o),f=e?0:M(o,"left");return x({top:a-Number(n.top)+Number(n.marginTop),left:f-Number(n.left)+Number(n.marginLeft),width:r,height:i})}(a,r);else{var f=void 0;"scrollParent"===n?"BODY"===(f=d(m(e))).nodeName&&(f=t.ownerDocument.documentElement):f="window"===n?t.ownerDocument.documentElement:n;var s=E(f,a,r);if("HTML"!==f.nodeName||function c(t){var e=t.nodeName;return"BODY"!==e&&"HTML"!==e&&("fixed"===v(t,"position")||c(m(t)))}(a))i=s;else{var l=y(t.ownerDocument),u=l.height,h=l.width;i.top+=s.top-s.marginTop,i.bottom=Number(u)+Number(s.top),i.left+=s.left-s.marginLeft,i.right=Number(h)+Number(s.left)}}return i.left+=o,i.top+=o,i.right-=o,i.bottom-=o,i}function s(t,e,n,o,r,i,a){if(void 0===r&&(r=["top","bottom","right","left"]),void 0===i&&(i="viewport"),void 0===a&&(a=0),-1===t.indexOf("auto"))return t;var f=T(n,o,a,i),s={top:{width:f.width,height:e.top-f.top},right:{width:f.right-e.right,height:f.height},bottom:{width:f.width,height:f.bottom-e.bottom},left:{width:e.left-f.left,height:f.height}},l=Object.keys(s).map(function(t){return g({key:t},s[t],{area:function e(t){return t.width*t.height}(s[t])})}).sort(function(t,e){return e.area-t.area}),u=l.filter(function(t){var e=t.width,o=t.height;return e>=n.clientWidth&&o>=n.clientHeight}),h=0<(u=u.filter(function(e){return r.some(function(t){return t===e.key})})).length?u[0].key:l[0].key,p=t.split(" ")[1];return n.className=n.className.replace(/bs-tooltip-auto/g,"bs-tooltip-"+h),h+(p?"-"+p:"")}function L(t){var e=t.ownerDocument.defaultView.getComputedStyle(t),o=parseFloat(e.marginTop||0)+parseFloat(e.marginBottom||0),n=parseFloat(e.marginLeft||0)+parseFloat(e.marginRight||0);return{width:Number(t.offsetWidth)+n,height:Number(t.offsetHeight)+o}}function h(t,e,o){return void 0===o&&(o=null),E(e,o?O(t):w(t,e),o)}function D(t,e,o){var n=o.split(" ")[0],r=L(t),i={width:r.width,height:r.height},a=-1!==["right","left"].indexOf(n),f=a?"top":"left",s=a?"left":"top",l=a?"height":"width",u=a?"width":"height";return i[f]=e[f]+e[l]/2-r[l]/2,i[s]=n===s?e[s]-r[u]:e[function h(t){var e={left:"right",right:"left",bottom:"top",top:"bottom"};return t.replace(/left|right|bottom|top/g,function(t){return e[t]})}(s)],i}function S(t,e){return t&&t.modifiers&&t.modifiers[e]&&t.modifiers[e].enabled}function c(n,r,i){Object.keys(r).forEach(function(t){var e="";-1!==["width","height","top","right","bottom","left"].indexOf(t)&&function o(t){return""!==t&&!isNaN(parseFloat(t))&&isFinite(t)}(r[t])&&(e="px"),i?i.setStyle(n,t,""+String(r[t])+e):n.style[t]=String(r[t])+e})}function F(t){var e,o=t.offsets.target,n=t.instance.target.querySelector(".arrow");if(!n)return t;var r=-1!==["left","right"].indexOf(t.placement),i=r?"height":"width",a=r?"Top":"Left",f=a.toLowerCase(),s=r?"left":"top",l=r?"bottom":"right",u=L(n)[i];t.offsets.host[l]-u<o[f]&&(o[f]-=o[f]-(t.offsets.host[l]-u)),Number(t.offsets.host[f])+Number(u)>o[l]&&(o[f]+=Number(t.offsets.host[f])+Number(u)-Number(o[l])),o=x(o);var h=Number(t.offsets.host[f])+Number(t.offsets.host[i]/2-u/2),p=v(t.instance.target),c=parseFloat(p["margin"+a]),m=parseFloat(p["border"+a+"Width"]),d=h-o[f]-c-m;return d=Math.max(Math.min(o[i]-u,d),0),t.offsets.arrow=((e={})[f]=Math.round(d),e[s]="",e),t.instance.arrow=n,t}function H(h){if(h.offsets.target=x(h.offsets.target),!S(h.options,"flip"))return h.offsets.target=g({},h.offsets.target,D(h.instance.target,h.offsets.host,h.placement)),h;var p=T(h.instance.target,h.instance.host,0,"viewport",!1),c=h.placement.split(" ")[0],m=h.placement.split(" ")[1]||"",t=s("auto",h.offsets.host,h.instance.target,h.instance.host,h.options.allowedPositions),d=[c,t];return d.forEach(function(t,e){if(c!==t||d.length===e+1)return h;var o="left"===(c=h.placement.split(" ")[0])&&Math.floor(h.offsets.target.right)>Math.floor(h.offsets.host.left)||"right"===c&&Math.floor(h.offsets.target.left)<Math.floor(h.offsets.host.right)||"top"===c&&Math.floor(h.offsets.target.bottom)>Math.floor(h.offsets.host.top)||"bottom"===c&&Math.floor(h.offsets.target.top)<Math.floor(h.offsets.host.bottom),n=Math.floor(h.offsets.target.left)<Math.floor(p.left),r=Math.floor(h.offsets.target.right)>Math.floor(p.right),i=Math.floor(h.offsets.target.top)<Math.floor(p.top),a=Math.floor(h.offsets.target.bottom)>Math.floor(p.bottom),f="left"===c&&n||"right"===c&&r||"top"===c&&i||"bottom"===c&&a,s=-1!==["top","bottom"].indexOf(c),l=s&&"left"===m&&n||s&&"right"===m&&r||!s&&"left"===m&&i||!s&&"right"===m&&a;(o||f||l)&&((o||f)&&(c=d[e+1]),l&&(m=function u(t){return"right"===t?"left":"left"===t?"right":t}(m)),h.placement=c+(m?" "+m:""),h.offsets.target=g({},h.offsets.target,D(h.instance.target,h.offsets.host,h.placement)))}),h}function P(r){if(!S(r.options,"preventOverflow"))return r;var t="transform",e=r.instance.target.style,o=e.top,n=e.left,i=e.transform;e.top="",e.left="",e[t]="";var a=T(r.instance.target,r.instance.host,0,"scrollParent",!1);e.top=o,e.left=n,e[t]=i;var f,s={primary:function(t){var e,o=r.offsets.target[t];return r.offsets.target[t]<a[t]&&(o=Math.max(r.offsets.target[t],a[t])),(e={})[t]=o,e},secondary:function(t){var e,o="right"===t?"left":"top",n=r.offsets.target[o];return r.offsets.target[t]>a[t]&&(n=Math.min(r.offsets.target[o],a[t]-("right"===t?r.offsets.target.width:r.offsets.target.height))),(e={})[o]=n,e}};return["left","right","top","bottom"].forEach(function(t){f=-1!==["left","top"].indexOf(t)?"primary":"secondary",r.offsets.target=g({},r.offsets.target,s[f](t))}),r}function B(t){var e,o,n=t.placement,r=n.split(" ")[0],i=n.split(" ")[1];if(i){var a=t.offsets,f=a.host,s=a.target,l=-1!==["bottom","top"].indexOf(r),u=l?"left":"top",h=l?"width":"height",p={start:(e={},e[u]=f[u],e),end:(o={},o[u]=f[u]+f[h]-s[h],o)};t.offsets.target=g({},s,p[i])}return t}var W=function(){function t(){}return t.prototype.position=function(t,e,o){return void 0===o&&(o=!0),this.offset(t,e,!1)},t.prototype.offset=function(t,e,o){return void 0===o&&(o=!0),h(e,t)},t.prototype.positionElements=function(t,e,o,n,r){return[H,B,P,F].reduce(function(t,e){return e(t)},function f(t,e,o,n){var r=h(t,e);o.match(/^(auto)*\s*(left|right|top|bottom)*$/)||o.match(/^(left|right|top|bottom)*\s*(start|end)*$/)||(o="auto");var i=!!o.match(/auto/g),a=o.match(/auto\s(left|right|top|bottom)/)?o.split(" ")[1]||"auto":o;return{options:n,instance:{target:t,host:e,arrow:null},offsets:{target:D(t,r,a),host:r,arrow:null},positionFixed:!1,placement:a=s(a,r,t,e,n?n.allowedPositions:undefined),placementAuto:i}}(e,t,o,r))},t}(),j=new W;function I(t,e,o,n,r,i){var a=j.positionElements(t,e,o,n,r),f=function s(t){return{width:t.offsets.target.width,height:t.offsets.target.height,left:Math.floor(t.offsets.target.left),top:Math.round(t.offsets.target.top),bottom:Math.round(t.offsets.target.bottom),right:Math.floor(t.offsets.target.right)}}(a);c(e,{"will-change":"transform",top:"0px",left:"0px",transform:"translate3d("+f.left+"px, "+f.top+"px, 0px)"},i),a.instance.arrow&&c(a.instance.arrow,a.offsets.arrow,i),function l(t,e){var o=t.instance.target,n=o.className;t.placementAuto&&(-1!==(n=(n=(n=n.replace(/bs-popover-auto/g,"bs-popover-"+t.placement)).replace(/bs-tooltip-auto/g,"bs-tooltip-"+t.placement)).replace(/\sauto/g," "+t.placement)).indexOf("popover")&&-1===n.indexOf("popover-auto")&&(n+=" popover-auto"),-1!==n.indexOf("tooltip")&&-1===n.indexOf("tooltip-auto")&&(n+=" tooltip-auto")),n=n.replace(/left|right|top|bottom/g,""+t.placement.split(" ")[0]),e?e.setAttribute(o,"class",n):o.className=n}(a,i)}var C=function(){function t(e,t){var o=this;this.update$$=new r.Subject,this.positionElements=new Map,n.isPlatformBrowser(t)&&r.merge(r.fromEvent(window,"scroll"),r.fromEvent(window,"resize"),r.of(0,r.animationFrameScheduler),this.update$$).subscribe(function(){o.positionElements.forEach(function(t){I(R(t.target),R(t.element),t.attachment,t.appendToBody,o.options,e.createRenderer(null,null))})})}return t.prototype.position=function(t){this.addPositionElement(t)},t.prototype.addPositionElement=function(t){this.positionElements.set(R(t.element),t)},t.prototype.calcPosition=function(){this.update$$.next()},t.prototype.deletePositionElement=function(t){this.positionElements["delete"](R(t))},t.prototype.setOptions=function(t){this.options=t},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:e.RendererFactory2},{type:Number,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]}]},t}();function R(t){return"string"==typeof t?document.querySelector(t):t instanceof e.ElementRef?t.nativeElement:t}t.positionElements=I,t.Positioning=W,t.PositioningService=C,Object.defineProperty(t,"__esModule",{value:!0})});
  //# sourceMappingURL=ngx-bootstrap-positioning.umd.min.js.map