1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
"use strict";function getWindow(e){return null==e?window:"[object Window]"!==e.toString()?(t=e.ownerDocument)&&t.defaultView||window:e;var t}function isElement(e){return e instanceof getWindow(e).Element||e instanceof Element}function isHTMLElement(e){return e instanceof getWindow(e).HTMLElement||e instanceof HTMLElement}function isShadowRoot(e){return"undefined"!=typeof ShadowRoot&&(e instanceof getWindow(e).ShadowRoot||e instanceof ShadowRoot)}Object.defineProperty(exports,"__esModule",{value:!0});var max=Math.max,min=Math.min,round=Math.round;function getUAString(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function isLayoutViewport(){return!/^((?!chrome|android).)*safari/i.test(getUAString())}function getBoundingClientRect(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);var o=e.getBoundingClientRect(),r=1,i=1;t&&isHTMLElement(e)&&(r=0<e.offsetWidth&&round(o.width)/e.offsetWidth||1,i=0<e.offsetHeight&&round(o.height)/e.offsetHeight||1);t=(isElement(e)?getWindow(e):window).visualViewport,e=!isLayoutViewport()&&n,n=(o.left+(e&&t?t.offsetLeft:0))/r,e=(o.top+(e&&t?t.offsetTop:0))/i,t=o.width/r,r=o.height/i;return{width:t,height:r,top:e,right:n+t,bottom:e+r,left:n,x:n,y:e}}function getWindowScroll(e){e=getWindow(e);return{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function getHTMLElementScroll(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function getNodeScroll(e){return(e!==getWindow(e)&&isHTMLElement(e)?getHTMLElementScroll:getWindowScroll)(e)}function getNodeName(e){return e?(e.nodeName||"").toLowerCase():null}function getDocumentElement(e){return((isElement(e)?e.ownerDocument:e.document)||window.document).documentElement}function getWindowScrollBarX(e){return getBoundingClientRect(getDocumentElement(e)).left+getWindowScroll(e).scrollLeft}function getComputedStyle(e){return getWindow(e).getComputedStyle(e)}function isScrollParent(e){var e=getComputedStyle(e),t=e.overflow,n=e.overflowX,e=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+e+n)}function isElementScaled(e){var t=e.getBoundingClientRect(),n=round(t.width)/e.offsetWidth||1,t=round(t.height)/e.offsetHeight||1;return 1!==n||1!==t}function getCompositeRect(e,t,n){void 0===n&&(n=!1);var o=isHTMLElement(t),r=isHTMLElement(t)&&isElementScaled(t),i=getDocumentElement(t),e=getBoundingClientRect(e,r,n),r={scrollLeft:0,scrollTop:0},a={x:0,y:0};return!o&&n||("body"===getNodeName(t)&&!isScrollParent(i)||(r=getNodeScroll(t)),isHTMLElement(t)?((a=getBoundingClientRect(t,!0)).x+=t.clientLeft,a.y+=t.clientTop):i&&(a.x=getWindowScrollBarX(i))),{x:e.left+r.scrollLeft-a.x,y:e.top+r.scrollTop-a.y,width:e.width,height:e.height}}function getLayoutRect(e){var t=getBoundingClientRect(e),n=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:o}}function getParentNode(e){return"html"===getNodeName(e)?e:e.assignedSlot||e.parentNode||(isShadowRoot(e)?e.host:null)||getDocumentElement(e)}function getScrollParent(e){return 0<=["html","body","#document"].indexOf(getNodeName(e))?e.ownerDocument.body:isHTMLElement(e)&&isScrollParent(e)?e:getScrollParent(getParentNode(e))}function listScrollParents(e,t){void 0===t&&(t=[]);var n=getScrollParent(e),e=n===(null==(e=e.ownerDocument)?void 0:e.body),o=getWindow(n),o=e?[o].concat(o.visualViewport||[],isScrollParent(n)?n:[]):n,n=t.concat(o);return e?n:n.concat(listScrollParents(getParentNode(o)))}function isTableElement(e){return 0<=["table","td","th"].indexOf(getNodeName(e))}function getTrueOffsetParent(e){return isHTMLElement(e)&&"fixed"!==getComputedStyle(e).position?e.offsetParent:null}function getContainingBlock(e){var t=/firefox/i.test(getUAString()),n=/Trident/i.test(getUAString());if(n&&isHTMLElement(e)&&"fixed"===getComputedStyle(e).position)return null;var o=getParentNode(e);for(isShadowRoot(o)&&(o=o.host);isHTMLElement(o)&&["html","body"].indexOf(getNodeName(o))<0;){var r=getComputedStyle(o);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return o;o=o.parentNode}return null}function getOffsetParent(e){for(var t=getWindow(e),n=getTrueOffsetParent(e);n&&isTableElement(n)&&"static"===getComputedStyle(n).position;)n=getTrueOffsetParent(n);return(!n||"html"!==getNodeName(n)&&("body"!==getNodeName(n)||"static"!==getComputedStyle(n).position))&&(n||getContainingBlock(e))||t}var top="top",bottom="bottom",right="right",left="left",auto="auto",basePlacements=[top,bottom,right,left],start="start",end="end",clippingParents="clippingParents",viewport="viewport",popper="popper",reference="reference",beforeRead="beforeRead",read="read",afterRead="afterRead",beforeMain="beforeMain",main="main",afterMain="afterMain",beforeWrite="beforeWrite",write="write",afterWrite="afterWrite",modifierPhases=[beforeRead,read,afterRead,beforeMain,main,afterMain,beforeWrite,write,afterWrite];function order(e){var n=new Map,o=new Set,r=[];return e.forEach(function(e){n.set(e.name,e)}),e.forEach(function(e){o.has(e.name)||!function t(e){o.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){o.has(e)||(e=n.get(e))&&t(e)}),r.push(e)}(e)}),r}function orderModifiers(e){var n=order(e);return modifierPhases.reduce(function(e,t){return e.concat(n.filter(function(e){return e.phase===t}))},[])}function debounce(t){var n;return function(){return n=n||new Promise(function(e){Promise.resolve().then(function(){n=void 0,e(t())})})}}function format(e){for(var t=arguments.length,n=new Array(1<t?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return[].concat(n).reduce(function(e,t){return e.replace(/%s/,t)},e)}var INVALID_MODIFIER_ERROR='Popper: modifier "%s" provided an invalid %s property, expected %s but got %s',MISSING_DEPENDENCY_ERROR='Popper: modifier "%s" requires "%s", but "%s" modifier is not available',VALID_PROPERTIES=["name","enabled","phase","fn","effect","requires","options"];function validateModifiers(o){o.forEach(function(n){[].concat(Object.keys(n),VALID_PROPERTIES).filter(function(e,t,n){return n.indexOf(e)===t}).forEach(function(e){switch(e){case"name":"string"!=typeof n.name&&console.error(format(INVALID_MODIFIER_ERROR,String(n.name),'"name"','"string"','"'+String(n.name)+'"'));break;case"enabled":"boolean"!=typeof n.enabled&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"enabled"','"boolean"','"'+String(n.enabled)+'"'));break;case"phase":modifierPhases.indexOf(n.phase)<0&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"phase"',"either "+modifierPhases.join(", "),'"'+String(n.phase)+'"'));break;case"fn":"function"!=typeof n.fn&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"fn"','"function"','"'+String(n.fn)+'"'));break;case"effect":null!=n.effect&&"function"!=typeof n.effect&&console.error(format(INVALID_MODIFIER_ERROR,n.name,'"effect"','"function"','"'+String(n.fn)+'"'));break;case"requires":null==n.requires||Array.isArray(n.requires)||console.error(format(INVALID_MODIFIER_ERROR,n.name,'"requires"','"array"','"'+String(n.requires)+'"'));break;case"requiresIfExists":Array.isArray(n.requiresIfExists)||console.error(format(INVALID_MODIFIER_ERROR,n.name,'"requiresIfExists"','"array"','"'+String(n.requiresIfExists)+'"'));break;case"options":case"data":break;default:console.error('PopperJS: an invalid property has been provided to the "'+n.name+'" modifier, valid properties are '+VALID_PROPERTIES.map(function(e){return'"'+e+'"'}).join(", ")+'; but "'+e+'" was provided.')}n.requires&&n.requires.forEach(function(t){null==o.find(function(e){return e.name===t})&&console.error(format(MISSING_DEPENDENCY_ERROR,String(n.name),t,t))})})})}function uniqueBy(e,t){var n=new Set;return e.filter(function(e){e=t(e);if(!n.has(e))return n.add(e),!0})}function getBasePlacement(e){return e.split("-")[0]}function mergeByName(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}function getViewportRect(e,t){var n,o=getWindow(e),r=getDocumentElement(e),o=o.visualViewport,i=r.clientWidth,r=r.clientHeight,a=0,c=0;return o&&(i=o.width,r=o.height,((n=isLayoutViewport())||!n&&"fixed"===t)&&(a=o.offsetLeft,c=o.offsetTop)),{width:i,height:r,x:a+getWindowScrollBarX(e),y:c}}function getDocumentRect(e){var t=getDocumentElement(e),n=getWindowScroll(e),o=null==(o=e.ownerDocument)?void 0:o.body,r=max(t.scrollWidth,t.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=max(t.scrollHeight,t.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),e=-n.scrollLeft+getWindowScrollBarX(e),n=-n.scrollTop;return"rtl"===getComputedStyle(o||t).direction&&(e+=max(t.clientWidth,o?o.clientWidth:0)-r),{width:r,height:i,x:e,y:n}}function contains(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&isShadowRoot(n)){var o=t;do{if(o&&e.isSameNode(o))return!0}while(o=o.parentNode||o.host)}return!1}function rectToClientRect(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function getInnerBoundingClientRect(e,t){t=getBoundingClientRect(e,!1,"fixed"===t);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}function getClientRectFromMixedType(e,t,n){return t===viewport?rectToClientRect(getViewportRect(e,n)):isElement(t)?getInnerBoundingClientRect(t,n):rectToClientRect(getDocumentRect(getDocumentElement(e)))}function getClippingParents(e){var t=listScrollParents(getParentNode(e)),n=0<=["absolute","fixed"].indexOf(getComputedStyle(e).position)&&isHTMLElement(e)?getOffsetParent(e):e;return isElement(n)?t.filter(function(e){return isElement(e)&&contains(e,n)&&"body"!==getNodeName(e)}):[]}function getClippingRect(n,e,t,o){e="clippingParents"===e?getClippingParents(n):[].concat(e),e=[].concat(e,[t]),t=e[0],e=e.reduce(function(e,t){t=getClientRectFromMixedType(n,t,o);return e.top=max(t.top,e.top),e.right=min(t.right,e.right),e.bottom=min(t.bottom,e.bottom),e.left=max(t.left,e.left),e},getClientRectFromMixedType(n,t,o));return e.width=e.right-e.left,e.height=e.bottom-e.top,e.x=e.left,e.y=e.top,e}function getVariation(e){return e.split("-")[1]}function getMainAxisFromPlacement(e){return 0<=["top","bottom"].indexOf(e)?"x":"y"}function computeOffsets(e){var t,n=e.reference,o=e.element,e=e.placement,r=e?getBasePlacement(e):null,e=e?getVariation(e):null,i=n.x+n.width/2-o.width/2,a=n.y+n.height/2-o.height/2;switch(r){case top:t={x:i,y:n.y-o.height};break;case bottom:t={x:i,y:n.y+n.height};break;case right:t={x:n.x+n.width,y:a};break;case left:t={x:n.x-o.width,y:a};break;default:t={x:n.x,y:n.y}}var c=r?getMainAxisFromPlacement(r):null;if(null!=c){var s="y"===c?"height":"width";switch(e){case start:t[c]=t[c]-(n[s]/2-o[s]/2);break;case end:t[c]=t[c]+(n[s]/2-o[s]/2)}}return t}function getFreshSideObject(){return{top:0,right:0,bottom:0,left:0}}function mergePaddingObject(e){return Object.assign({},getFreshSideObject(),e)}function expandToHashMap(n,e){return e.reduce(function(e,t){return e[t]=n,e},{})}function detectOverflow(e,t){var o,t=t=void 0===t?{}:t,n=t.placement,n=void 0===n?e.placement:n,r=t.strategy,r=void 0===r?e.strategy:r,i=t.boundary,i=void 0===i?clippingParents:i,a=t.rootBoundary,a=void 0===a?viewport:a,c=t.elementContext,c=void 0===c?popper:c,s=t.altBoundary,s=void 0!==s&&s,t=t.padding,t=void 0===t?0:t,t=mergePaddingObject("number"!=typeof t?t:expandToHashMap(t,basePlacements)),l=e.rects.popper,s=e.elements[s?c===popper?reference:popper:c],s=getClippingRect(isElement(s)?s:s.contextElement||getDocumentElement(e.elements.popper),i,a,r),i=getBoundingClientRect(e.elements.reference),a=computeOffsets({reference:i,element:l,strategy:"absolute",placement:n}),r=rectToClientRect(Object.assign({},l,a)),l=c===popper?r:i,f={top:s.top-l.top+t.top,bottom:l.bottom-s.bottom+t.bottom,left:s.left-l.left+t.left,right:l.right-s.right+t.right},a=e.modifiersData.offset;return c===popper&&a&&(o=a[n],Object.keys(f).forEach(function(e){var t=0<=[right,bottom].indexOf(e)?1:-1,n=0<=[top,bottom].indexOf(e)?"y":"x";f[e]+=o[n]*t})),f}var INVALID_ELEMENT_ERROR="Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.",INFINITE_LOOP_ERROR="Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.",DEFAULT_OPTIONS={placement:"bottom",modifiers:[],strategy:"absolute"};function areValidElements(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(e){return!(e&&"function"==typeof e.getBoundingClientRect)})}function popperGenerator(e){var e=e=void 0===e?{}:e,t=e.defaultModifiers,a=void 0===t?[]:t,t=e.defaultOptions,f=void 0===t?DEFAULT_OPTIONS:t;return function(t,n,o){void 0===o&&(o=f);var c={placement:"bottom",orderedModifiers:[],options:Object.assign({},DEFAULT_OPTIONS,f),modifiersData:{},elements:{reference:t,popper:n},attributes:{},styles:{}},r=[],s=!1,l={state:c,setOptions:function(e){var e="function"==typeof e?e(c.options):e,e=(i(),c.options=Object.assign({},f,c.options,e),c.scrollParents={reference:isElement(t)?listScrollParents(t):t.contextElement?listScrollParents(t.contextElement):[],popper:listScrollParents(n)},orderModifiers(mergeByName([].concat(a,c.options.modifiers))));return c.orderedModifiers=e.filter(function(e){return e.enabled}),"production"!==process.env.NODE_ENV&&(validateModifiers(uniqueBy([].concat(e,c.options.modifiers),function(e){return e.name})),getBasePlacement(c.options.placement)!==auto||c.orderedModifiers.find(function(e){return"flip"===e.name})||console.error(['Popper: "auto" placements require the "flip" modifier be',"present and enabled to work."].join(" ")),[(e=getComputedStyle(n)).marginTop,e.marginRight,e.marginBottom,e.marginLeft].some(function(e){return parseFloat(e)})&&console.warn(['Popper: CSS "margin" styles cannot be used to apply padding',"between the popper and its reference element or boundary.","To replicate margin, use the `offset` modifier, as well as","the `padding` option in the `preventOverflow` and `flip`","modifiers."].join(" "))),c.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,e=e.effect;"function"==typeof e&&(e=e({state:c,name:t,instance:l,options:void 0===n?{}:n}),r.push(e||function(){}))}),l.update()},forceUpdate:function(){if(!s){var e=c.elements,t=e.reference,e=e.popper;if(areValidElements(t,e)){c.rects={reference:getCompositeRect(t,getOffsetParent(e),"fixed"===c.options.strategy),popper:getLayoutRect(e)},c.reset=!1,c.placement=c.options.placement,c.orderedModifiers.forEach(function(e){return c.modifiersData[e.name]=Object.assign({},e.data)});for(var n,o,r,i=0,a=0;a<c.orderedModifiers.length;a++){if("production"!==process.env.NODE_ENV&&100<(i+=1)){console.error(INFINITE_LOOP_ERROR);break}!0===c.reset?(c.reset=!1,a=-1):(n=(r=c.orderedModifiers[a]).fn,o=r.options,r=r.name,"function"==typeof n&&(c=n({state:c,options:void 0===o?{}:o,name:r,instance:l})||c))}}else"production"!==process.env.NODE_ENV&&console.error(INVALID_ELEMENT_ERROR)}},update:debounce(function(){return new Promise(function(e){l.forceUpdate(),e(c)})}),destroy:function(){i(),s=!0}};return areValidElements(t,n)?l.setOptions(o).then(function(e){!s&&o.onFirstUpdate&&o.onFirstUpdate(e)}):"production"!==process.env.NODE_ENV&&console.error(INVALID_ELEMENT_ERROR),l;function i(){r.forEach(function(e){return e()}),r=[]}}}var createPopper=popperGenerator();exports.createPopper=createPopper,exports.detectOverflow=detectOverflow,exports.popperGenerator=popperGenerator; |