popper-3f97eb01.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. 'use strict';
  7. const dom = require('./dom-9ac0341c.js');
  8. var top = 'top';
  9. var bottom = 'bottom';
  10. var right = 'right';
  11. var left = 'left';
  12. var auto = 'auto';
  13. var basePlacements = [top, bottom, right, left];
  14. var start = 'start';
  15. var end = 'end';
  16. var clippingParents = 'clippingParents';
  17. var viewport = 'viewport';
  18. var popper = 'popper';
  19. var reference = 'reference';
  20. var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
  21. return acc.concat([placement + "-" + start, placement + "-" + end]);
  22. }, []);
  23. var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
  24. return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
  25. }, []); // modifiers that need to read the DOM
  26. var beforeRead = 'beforeRead';
  27. var read = 'read';
  28. var afterRead = 'afterRead'; // pure-logic modifiers
  29. var beforeMain = 'beforeMain';
  30. var main = 'main';
  31. var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
  32. var beforeWrite = 'beforeWrite';
  33. var write = 'write';
  34. var afterWrite = 'afterWrite';
  35. var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
  36. function getNodeName(element) {
  37. return element ? (element.nodeName || '').toLowerCase() : null;
  38. }
  39. function getWindow(node) {
  40. if (node == null) {
  41. return window;
  42. }
  43. if (node.toString() !== '[object Window]') {
  44. var ownerDocument = node.ownerDocument;
  45. return ownerDocument ? ownerDocument.defaultView || window : window;
  46. }
  47. return node;
  48. }
  49. function isElement(node) {
  50. var OwnElement = getWindow(node).Element;
  51. return node instanceof OwnElement || node instanceof Element;
  52. }
  53. function isHTMLElement(node) {
  54. var OwnElement = getWindow(node).HTMLElement;
  55. return node instanceof OwnElement || node instanceof HTMLElement;
  56. }
  57. function isShadowRoot(node) {
  58. // IE 11 has no ShadowRoot
  59. if (typeof ShadowRoot === 'undefined') {
  60. return false;
  61. }
  62. var OwnElement = getWindow(node).ShadowRoot;
  63. return node instanceof OwnElement || node instanceof ShadowRoot;
  64. }
  65. // and applies them to the HTMLElements such as popper and arrow
  66. function applyStyles(_ref) {
  67. var state = _ref.state;
  68. Object.keys(state.elements).forEach(function (name) {
  69. var style = state.styles[name] || {};
  70. var attributes = state.attributes[name] || {};
  71. var element = state.elements[name]; // arrow is optional + virtual elements
  72. if (!isHTMLElement(element) || !getNodeName(element)) {
  73. return;
  74. } // Flow doesn't support to extend this property, but it's the most
  75. // effective way to apply styles to an HTMLElement
  76. // $FlowFixMe[cannot-write]
  77. Object.assign(element.style, style);
  78. Object.keys(attributes).forEach(function (name) {
  79. var value = attributes[name];
  80. if (value === false) {
  81. element.removeAttribute(name);
  82. } else {
  83. element.setAttribute(name, value === true ? '' : value);
  84. }
  85. });
  86. });
  87. }
  88. function effect$2(_ref2) {
  89. var state = _ref2.state;
  90. var initialStyles = {
  91. popper: {
  92. position: state.options.strategy,
  93. left: '0',
  94. top: '0',
  95. margin: '0'
  96. },
  97. arrow: {
  98. position: 'absolute'
  99. },
  100. reference: {}
  101. };
  102. Object.assign(state.elements.popper.style, initialStyles.popper);
  103. state.styles = initialStyles;
  104. if (state.elements.arrow) {
  105. Object.assign(state.elements.arrow.style, initialStyles.arrow);
  106. }
  107. return function () {
  108. Object.keys(state.elements).forEach(function (name) {
  109. var element = state.elements[name];
  110. var attributes = state.attributes[name] || {};
  111. var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
  112. var style = styleProperties.reduce(function (style, property) {
  113. style[property] = '';
  114. return style;
  115. }, {}); // arrow is optional + virtual elements
  116. if (!isHTMLElement(element) || !getNodeName(element)) {
  117. return;
  118. }
  119. Object.assign(element.style, style);
  120. Object.keys(attributes).forEach(function (attribute) {
  121. element.removeAttribute(attribute);
  122. });
  123. });
  124. };
  125. } // eslint-disable-next-line import/no-unused-modules
  126. const applyStyles$1 = {
  127. name: 'applyStyles',
  128. enabled: true,
  129. phase: 'write',
  130. fn: applyStyles,
  131. effect: effect$2,
  132. requires: ['computeStyles']
  133. };
  134. function getBasePlacement(placement) {
  135. return placement.split('-')[0];
  136. }
  137. var max = Math.max;
  138. var min = Math.min;
  139. var round = Math.round;
  140. function getBoundingClientRect(element, includeScale) {
  141. if (includeScale === void 0) {
  142. includeScale = false;
  143. }
  144. var rect = element.getBoundingClientRect();
  145. var scaleX = 1;
  146. var scaleY = 1;
  147. if (isHTMLElement(element) && includeScale) {
  148. var offsetHeight = element.offsetHeight;
  149. var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
  150. // Fallback to 1 in case both values are `0`
  151. if (offsetWidth > 0) {
  152. scaleX = round(rect.width) / offsetWidth || 1;
  153. }
  154. if (offsetHeight > 0) {
  155. scaleY = round(rect.height) / offsetHeight || 1;
  156. }
  157. }
  158. return {
  159. width: rect.width / scaleX,
  160. height: rect.height / scaleY,
  161. top: rect.top / scaleY,
  162. right: rect.right / scaleX,
  163. bottom: rect.bottom / scaleY,
  164. left: rect.left / scaleX,
  165. x: rect.left / scaleX,
  166. y: rect.top / scaleY
  167. };
  168. }
  169. // means it doesn't take into account transforms.
  170. function getLayoutRect(element) {
  171. var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
  172. // Fixes https://github.com/popperjs/popper-core/issues/1223
  173. var width = element.offsetWidth;
  174. var height = element.offsetHeight;
  175. if (Math.abs(clientRect.width - width) <= 1) {
  176. width = clientRect.width;
  177. }
  178. if (Math.abs(clientRect.height - height) <= 1) {
  179. height = clientRect.height;
  180. }
  181. return {
  182. x: element.offsetLeft,
  183. y: element.offsetTop,
  184. width: width,
  185. height: height
  186. };
  187. }
  188. function contains(parent, child) {
  189. var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
  190. if (parent.contains(child)) {
  191. return true;
  192. } // then fallback to custom implementation with Shadow DOM support
  193. else if (rootNode && isShadowRoot(rootNode)) {
  194. var next = child;
  195. do {
  196. if (next && parent.isSameNode(next)) {
  197. return true;
  198. } // $FlowFixMe[prop-missing]: need a better way to handle this...
  199. next = next.parentNode || next.host;
  200. } while (next);
  201. } // Give up, the result is false
  202. return false;
  203. }
  204. function getComputedStyle(element) {
  205. return getWindow(element).getComputedStyle(element);
  206. }
  207. function isTableElement(element) {
  208. return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
  209. }
  210. function getDocumentElement(element) {
  211. // $FlowFixMe[incompatible-return]: assume body is always available
  212. return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
  213. element.document) || window.document).documentElement;
  214. }
  215. function getParentNode(element) {
  216. if (getNodeName(element) === 'html') {
  217. return element;
  218. }
  219. return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
  220. // $FlowFixMe[incompatible-return]
  221. // $FlowFixMe[prop-missing]
  222. element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
  223. element.parentNode || ( // DOM Element detected
  224. isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
  225. // $FlowFixMe[incompatible-call]: HTMLElement is a Node
  226. getDocumentElement(element) // fallback
  227. );
  228. }
  229. function getTrueOffsetParent(element) {
  230. if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
  231. getComputedStyle(element).position === 'fixed') {
  232. return null;
  233. }
  234. return element.offsetParent;
  235. } // `.offsetParent` reports `null` for fixed elements, while absolute elements
  236. // return the containing block
  237. function getContainingBlock(element) {
  238. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
  239. var isIE = navigator.userAgent.indexOf('Trident') !== -1;
  240. if (isIE && isHTMLElement(element)) {
  241. // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
  242. var elementCss = getComputedStyle(element);
  243. if (elementCss.position === 'fixed') {
  244. return null;
  245. }
  246. }
  247. var currentNode = getParentNode(element);
  248. if (isShadowRoot(currentNode)) {
  249. currentNode = currentNode.host;
  250. }
  251. while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
  252. var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
  253. // create a containing block.
  254. // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
  255. if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
  256. return currentNode;
  257. } else {
  258. currentNode = currentNode.parentNode;
  259. }
  260. }
  261. return null;
  262. } // Gets the closest ancestor positioned element. Handles some edge cases,
  263. // such as table ancestors and cross browser bugs.
  264. function getOffsetParent(element) {
  265. var window = getWindow(element);
  266. var offsetParent = getTrueOffsetParent(element);
  267. while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
  268. offsetParent = getTrueOffsetParent(offsetParent);
  269. }
  270. if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
  271. return window;
  272. }
  273. return offsetParent || getContainingBlock(element) || window;
  274. }
  275. function getMainAxisFromPlacement(placement) {
  276. return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
  277. }
  278. function within(min$1, value, max$1) {
  279. return max(min$1, min(value, max$1));
  280. }
  281. function withinMaxClamp(min, value, max) {
  282. var v = within(min, value, max);
  283. return v > max ? max : v;
  284. }
  285. function getFreshSideObject() {
  286. return {
  287. top: 0,
  288. right: 0,
  289. bottom: 0,
  290. left: 0
  291. };
  292. }
  293. function mergePaddingObject(paddingObject) {
  294. return Object.assign({}, getFreshSideObject(), paddingObject);
  295. }
  296. function expandToHashMap(value, keys) {
  297. return keys.reduce(function (hashMap, key) {
  298. hashMap[key] = value;
  299. return hashMap;
  300. }, {});
  301. }
  302. var toPaddingObject = function toPaddingObject(padding, state) {
  303. padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
  304. placement: state.placement
  305. })) : padding;
  306. return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  307. };
  308. function arrow(_ref) {
  309. var _state$modifiersData$;
  310. var state = _ref.state,
  311. name = _ref.name,
  312. options = _ref.options;
  313. var arrowElement = state.elements.arrow;
  314. var popperOffsets = state.modifiersData.popperOffsets;
  315. var basePlacement = getBasePlacement(state.placement);
  316. var axis = getMainAxisFromPlacement(basePlacement);
  317. var isVertical = [left, right].indexOf(basePlacement) >= 0;
  318. var len = isVertical ? 'height' : 'width';
  319. if (!arrowElement || !popperOffsets) {
  320. return;
  321. }
  322. var paddingObject = toPaddingObject(options.padding, state);
  323. var arrowRect = getLayoutRect(arrowElement);
  324. var minProp = axis === 'y' ? top : left;
  325. var maxProp = axis === 'y' ? bottom : right;
  326. var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
  327. var startDiff = popperOffsets[axis] - state.rects.reference[axis];
  328. var arrowOffsetParent = getOffsetParent(arrowElement);
  329. var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
  330. var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
  331. // outside of the popper bounds
  332. var min = paddingObject[minProp];
  333. var max = clientSize - arrowRect[len] - paddingObject[maxProp];
  334. var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
  335. var offset = within(min, center, max); // Prevents breaking syntax highlighting...
  336. var axisProp = axis;
  337. state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
  338. }
  339. function effect$1(_ref2) {
  340. var state = _ref2.state,
  341. options = _ref2.options;
  342. var _options$element = options.element,
  343. arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
  344. if (arrowElement == null) {
  345. return;
  346. } // CSS selector
  347. if (typeof arrowElement === 'string') {
  348. arrowElement = state.elements.popper.querySelector(arrowElement);
  349. if (!arrowElement) {
  350. return;
  351. }
  352. }
  353. if (!contains(state.elements.popper, arrowElement)) {
  354. return;
  355. }
  356. state.elements.arrow = arrowElement;
  357. } // eslint-disable-next-line import/no-unused-modules
  358. const arrow$1 = {
  359. name: 'arrow',
  360. enabled: true,
  361. phase: 'main',
  362. fn: arrow,
  363. effect: effect$1,
  364. requires: ['popperOffsets'],
  365. requiresIfExists: ['preventOverflow']
  366. };
  367. function getVariation(placement) {
  368. return placement.split('-')[1];
  369. }
  370. var unsetSides = {
  371. top: 'auto',
  372. right: 'auto',
  373. bottom: 'auto',
  374. left: 'auto'
  375. }; // Round the offsets to the nearest suitable subpixel based on the DPR.
  376. // Zooming can change the DPR, but it seems to report a value that will
  377. // cleanly divide the values into the appropriate subpixels.
  378. function roundOffsetsByDPR(_ref) {
  379. var x = _ref.x,
  380. y = _ref.y;
  381. var win = window;
  382. var dpr = win.devicePixelRatio || 1;
  383. return {
  384. x: round(x * dpr) / dpr || 0,
  385. y: round(y * dpr) / dpr || 0
  386. };
  387. }
  388. function mapToStyles(_ref2) {
  389. var _Object$assign2;
  390. var popper = _ref2.popper,
  391. popperRect = _ref2.popperRect,
  392. placement = _ref2.placement,
  393. variation = _ref2.variation,
  394. offsets = _ref2.offsets,
  395. position = _ref2.position,
  396. gpuAcceleration = _ref2.gpuAcceleration,
  397. adaptive = _ref2.adaptive,
  398. roundOffsets = _ref2.roundOffsets,
  399. isFixed = _ref2.isFixed;
  400. var _offsets$x = offsets.x,
  401. x = _offsets$x === void 0 ? 0 : _offsets$x,
  402. _offsets$y = offsets.y,
  403. y = _offsets$y === void 0 ? 0 : _offsets$y;
  404. var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
  405. x: x,
  406. y: y
  407. }) : {
  408. x: x,
  409. y: y
  410. };
  411. x = _ref3.x;
  412. y = _ref3.y;
  413. var hasX = offsets.hasOwnProperty('x');
  414. var hasY = offsets.hasOwnProperty('y');
  415. var sideX = left;
  416. var sideY = top;
  417. var win = window;
  418. if (adaptive) {
  419. var offsetParent = getOffsetParent(popper);
  420. var heightProp = 'clientHeight';
  421. var widthProp = 'clientWidth';
  422. if (offsetParent === getWindow(popper)) {
  423. offsetParent = getDocumentElement(popper);
  424. if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
  425. heightProp = 'scrollHeight';
  426. widthProp = 'scrollWidth';
  427. }
  428. } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
  429. offsetParent = offsetParent;
  430. if (placement === top || (placement === left || placement === right) && variation === end) {
  431. sideY = bottom;
  432. var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
  433. offsetParent[heightProp];
  434. y -= offsetY - popperRect.height;
  435. y *= gpuAcceleration ? 1 : -1;
  436. }
  437. if (placement === left || (placement === top || placement === bottom) && variation === end) {
  438. sideX = right;
  439. var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
  440. offsetParent[widthProp];
  441. x -= offsetX - popperRect.width;
  442. x *= gpuAcceleration ? 1 : -1;
  443. }
  444. }
  445. var commonStyles = Object.assign({
  446. position: position
  447. }, adaptive && unsetSides);
  448. var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
  449. x: x,
  450. y: y
  451. }) : {
  452. x: x,
  453. y: y
  454. };
  455. x = _ref4.x;
  456. y = _ref4.y;
  457. if (gpuAcceleration) {
  458. var _Object$assign;
  459. return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
  460. }
  461. return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
  462. }
  463. function computeStyles(_ref5) {
  464. var state = _ref5.state,
  465. options = _ref5.options;
  466. var _options$gpuAccelerat = options.gpuAcceleration,
  467. gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
  468. _options$adaptive = options.adaptive,
  469. adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
  470. _options$roundOffsets = options.roundOffsets,
  471. roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
  472. var commonStyles = {
  473. placement: getBasePlacement(state.placement),
  474. variation: getVariation(state.placement),
  475. popper: state.elements.popper,
  476. popperRect: state.rects.popper,
  477. gpuAcceleration: gpuAcceleration,
  478. isFixed: state.options.strategy === 'fixed'
  479. };
  480. if (state.modifiersData.popperOffsets != null) {
  481. state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
  482. offsets: state.modifiersData.popperOffsets,
  483. position: state.options.strategy,
  484. adaptive: adaptive,
  485. roundOffsets: roundOffsets
  486. })));
  487. }
  488. if (state.modifiersData.arrow != null) {
  489. state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
  490. offsets: state.modifiersData.arrow,
  491. position: 'absolute',
  492. adaptive: false,
  493. roundOffsets: roundOffsets
  494. })));
  495. }
  496. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  497. 'data-popper-placement': state.placement
  498. });
  499. } // eslint-disable-next-line import/no-unused-modules
  500. const computeStyles$1 = {
  501. name: 'computeStyles',
  502. enabled: true,
  503. phase: 'beforeWrite',
  504. fn: computeStyles,
  505. data: {}
  506. };
  507. var passive = {
  508. passive: true
  509. };
  510. function effect(_ref) {
  511. var state = _ref.state,
  512. instance = _ref.instance,
  513. options = _ref.options;
  514. var _options$scroll = options.scroll,
  515. scroll = _options$scroll === void 0 ? true : _options$scroll,
  516. _options$resize = options.resize,
  517. resize = _options$resize === void 0 ? true : _options$resize;
  518. var window = getWindow(state.elements.popper);
  519. var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
  520. if (scroll) {
  521. scrollParents.forEach(function (scrollParent) {
  522. scrollParent.addEventListener('scroll', instance.update, passive);
  523. });
  524. }
  525. if (resize) {
  526. window.addEventListener('resize', instance.update, passive);
  527. }
  528. return function () {
  529. if (scroll) {
  530. scrollParents.forEach(function (scrollParent) {
  531. scrollParent.removeEventListener('scroll', instance.update, passive);
  532. });
  533. }
  534. if (resize) {
  535. window.removeEventListener('resize', instance.update, passive);
  536. }
  537. };
  538. } // eslint-disable-next-line import/no-unused-modules
  539. const eventListeners = {
  540. name: 'eventListeners',
  541. enabled: true,
  542. phase: 'write',
  543. fn: function fn() {},
  544. effect: effect,
  545. data: {}
  546. };
  547. var hash$1 = {
  548. left: 'right',
  549. right: 'left',
  550. bottom: 'top',
  551. top: 'bottom'
  552. };
  553. function getOppositePlacement(placement) {
  554. return placement.replace(/left|right|bottom|top/g, function (matched) {
  555. return hash$1[matched];
  556. });
  557. }
  558. var hash = {
  559. start: 'end',
  560. end: 'start'
  561. };
  562. function getOppositeVariationPlacement(placement) {
  563. return placement.replace(/start|end/g, function (matched) {
  564. return hash[matched];
  565. });
  566. }
  567. function getWindowScroll(node) {
  568. var win = getWindow(node);
  569. var scrollLeft = win.pageXOffset;
  570. var scrollTop = win.pageYOffset;
  571. return {
  572. scrollLeft: scrollLeft,
  573. scrollTop: scrollTop
  574. };
  575. }
  576. function getWindowScrollBarX(element) {
  577. // If <html> has a CSS width greater than the viewport, then this will be
  578. // incorrect for RTL.
  579. // Popper 1 is broken in this case and never had a bug report so let's assume
  580. // it's not an issue. I don't think anyone ever specifies width on <html>
  581. // anyway.
  582. // Browsers where the left scrollbar doesn't cause an issue report `0` for
  583. // this (e.g. Edge 2019, IE11, Safari)
  584. return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
  585. }
  586. function getViewportRect(element) {
  587. var win = getWindow(element);
  588. var html = getDocumentElement(element);
  589. var visualViewport = win.visualViewport;
  590. var width = html.clientWidth;
  591. var height = html.clientHeight;
  592. var x = 0;
  593. var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
  594. // can be obscured underneath it.
  595. // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
  596. // if it isn't open, so if this isn't available, the popper will be detected
  597. // to overflow the bottom of the screen too early.
  598. if (visualViewport) {
  599. width = visualViewport.width;
  600. height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
  601. // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
  602. // errors due to floating point numbers, so we need to check precision.
  603. // Safari returns a number <= 0, usually < -1 when pinch-zoomed
  604. // Feature detection fails in mobile emulation mode in Chrome.
  605. // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
  606. // 0.001
  607. // Fallback here: "Not Safari" userAgent
  608. if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
  609. x = visualViewport.offsetLeft;
  610. y = visualViewport.offsetTop;
  611. }
  612. }
  613. return {
  614. width: width,
  615. height: height,
  616. x: x + getWindowScrollBarX(element),
  617. y: y
  618. };
  619. }
  620. // of the `<html>` and `<body>` rect bounds if horizontally scrollable
  621. function getDocumentRect(element) {
  622. var _element$ownerDocumen;
  623. var html = getDocumentElement(element);
  624. var winScroll = getWindowScroll(element);
  625. var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
  626. var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
  627. var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
  628. var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
  629. var y = -winScroll.scrollTop;
  630. if (getComputedStyle(body || html).direction === 'rtl') {
  631. x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
  632. }
  633. return {
  634. width: width,
  635. height: height,
  636. x: x,
  637. y: y
  638. };
  639. }
  640. function isScrollParent(element) {
  641. // Firefox wants us to check `-x` and `-y` variations as well
  642. var _getComputedStyle = getComputedStyle(element),
  643. overflow = _getComputedStyle.overflow,
  644. overflowX = _getComputedStyle.overflowX,
  645. overflowY = _getComputedStyle.overflowY;
  646. return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
  647. }
  648. function getScrollParent(node) {
  649. if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
  650. // $FlowFixMe[incompatible-return]: assume body is always available
  651. return node.ownerDocument.body;
  652. }
  653. if (isHTMLElement(node) && isScrollParent(node)) {
  654. return node;
  655. }
  656. return getScrollParent(getParentNode(node));
  657. }
  658. /*
  659. given a DOM element, return the list of all scroll parents, up the list of ancesors
  660. until we get to the top window object. This list is what we attach scroll listeners
  661. to, because if any of these parent elements scroll, we'll need to re-calculate the
  662. reference element's position.
  663. */
  664. function listScrollParents(element, list) {
  665. var _element$ownerDocumen;
  666. if (list === void 0) {
  667. list = [];
  668. }
  669. var scrollParent = getScrollParent(element);
  670. var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
  671. var win = getWindow(scrollParent);
  672. var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
  673. var updatedList = list.concat(target);
  674. return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
  675. updatedList.concat(listScrollParents(getParentNode(target)));
  676. }
  677. function rectToClientRect(rect) {
  678. return Object.assign({}, rect, {
  679. left: rect.x,
  680. top: rect.y,
  681. right: rect.x + rect.width,
  682. bottom: rect.y + rect.height
  683. });
  684. }
  685. function getInnerBoundingClientRect(element) {
  686. var rect = getBoundingClientRect(element);
  687. rect.top = rect.top + element.clientTop;
  688. rect.left = rect.left + element.clientLeft;
  689. rect.bottom = rect.top + element.clientHeight;
  690. rect.right = rect.left + element.clientWidth;
  691. rect.width = element.clientWidth;
  692. rect.height = element.clientHeight;
  693. rect.x = rect.left;
  694. rect.y = rect.top;
  695. return rect;
  696. }
  697. function getClientRectFromMixedType(element, clippingParent) {
  698. return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
  699. } // A "clipping parent" is an overflowable container with the characteristic of
  700. // clipping (or hiding) overflowing elements with a position different from
  701. // `initial`
  702. function getClippingParents(element) {
  703. var clippingParents = listScrollParents(getParentNode(element));
  704. var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
  705. var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
  706. if (!isElement(clipperElement)) {
  707. return [];
  708. } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
  709. return clippingParents.filter(function (clippingParent) {
  710. return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
  711. });
  712. } // Gets the maximum area that the element is visible in due to any number of
  713. // clipping parents
  714. function getClippingRect(element, boundary, rootBoundary) {
  715. var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
  716. var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
  717. var firstClippingParent = clippingParents[0];
  718. var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
  719. var rect = getClientRectFromMixedType(element, clippingParent);
  720. accRect.top = max(rect.top, accRect.top);
  721. accRect.right = min(rect.right, accRect.right);
  722. accRect.bottom = min(rect.bottom, accRect.bottom);
  723. accRect.left = max(rect.left, accRect.left);
  724. return accRect;
  725. }, getClientRectFromMixedType(element, firstClippingParent));
  726. clippingRect.width = clippingRect.right - clippingRect.left;
  727. clippingRect.height = clippingRect.bottom - clippingRect.top;
  728. clippingRect.x = clippingRect.left;
  729. clippingRect.y = clippingRect.top;
  730. return clippingRect;
  731. }
  732. function computeOffsets(_ref) {
  733. var reference = _ref.reference,
  734. element = _ref.element,
  735. placement = _ref.placement;
  736. var basePlacement = placement ? getBasePlacement(placement) : null;
  737. var variation = placement ? getVariation(placement) : null;
  738. var commonX = reference.x + reference.width / 2 - element.width / 2;
  739. var commonY = reference.y + reference.height / 2 - element.height / 2;
  740. var offsets;
  741. switch (basePlacement) {
  742. case top:
  743. offsets = {
  744. x: commonX,
  745. y: reference.y - element.height
  746. };
  747. break;
  748. case bottom:
  749. offsets = {
  750. x: commonX,
  751. y: reference.y + reference.height
  752. };
  753. break;
  754. case right:
  755. offsets = {
  756. x: reference.x + reference.width,
  757. y: commonY
  758. };
  759. break;
  760. case left:
  761. offsets = {
  762. x: reference.x - element.width,
  763. y: commonY
  764. };
  765. break;
  766. default:
  767. offsets = {
  768. x: reference.x,
  769. y: reference.y
  770. };
  771. }
  772. var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
  773. if (mainAxis != null) {
  774. var len = mainAxis === 'y' ? 'height' : 'width';
  775. switch (variation) {
  776. case start:
  777. offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
  778. break;
  779. case end:
  780. offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
  781. break;
  782. }
  783. }
  784. return offsets;
  785. }
  786. function detectOverflow(state, options) {
  787. if (options === void 0) {
  788. options = {};
  789. }
  790. var _options = options,
  791. _options$placement = _options.placement,
  792. placement = _options$placement === void 0 ? state.placement : _options$placement,
  793. _options$boundary = _options.boundary,
  794. boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
  795. _options$rootBoundary = _options.rootBoundary,
  796. rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
  797. _options$elementConte = _options.elementContext,
  798. elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
  799. _options$altBoundary = _options.altBoundary,
  800. altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
  801. _options$padding = _options.padding,
  802. padding = _options$padding === void 0 ? 0 : _options$padding;
  803. var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
  804. var altContext = elementContext === popper ? reference : popper;
  805. var popperRect = state.rects.popper;
  806. var element = state.elements[altBoundary ? altContext : elementContext];
  807. var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
  808. var referenceClientRect = getBoundingClientRect(state.elements.reference);
  809. var popperOffsets = computeOffsets({
  810. reference: referenceClientRect,
  811. element: popperRect,
  812. strategy: 'absolute',
  813. placement: placement
  814. });
  815. var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
  816. var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
  817. // 0 or negative = within the clipping rect
  818. var overflowOffsets = {
  819. top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
  820. bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
  821. left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
  822. right: elementClientRect.right - clippingClientRect.right + paddingObject.right
  823. };
  824. var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
  825. if (elementContext === popper && offsetData) {
  826. var offset = offsetData[placement];
  827. Object.keys(overflowOffsets).forEach(function (key) {
  828. var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
  829. var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
  830. overflowOffsets[key] += offset[axis] * multiply;
  831. });
  832. }
  833. return overflowOffsets;
  834. }
  835. function computeAutoPlacement(state, options) {
  836. if (options === void 0) {
  837. options = {};
  838. }
  839. var _options = options,
  840. placement = _options.placement,
  841. boundary = _options.boundary,
  842. rootBoundary = _options.rootBoundary,
  843. padding = _options.padding,
  844. flipVariations = _options.flipVariations,
  845. _options$allowedAutoP = _options.allowedAutoPlacements,
  846. allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
  847. var variation = getVariation(placement);
  848. var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
  849. return getVariation(placement) === variation;
  850. }) : basePlacements;
  851. var allowedPlacements = placements$1.filter(function (placement) {
  852. return allowedAutoPlacements.indexOf(placement) >= 0;
  853. });
  854. if (allowedPlacements.length === 0) {
  855. allowedPlacements = placements$1;
  856. } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
  857. var overflows = allowedPlacements.reduce(function (acc, placement) {
  858. acc[placement] = detectOverflow(state, {
  859. placement: placement,
  860. boundary: boundary,
  861. rootBoundary: rootBoundary,
  862. padding: padding
  863. })[getBasePlacement(placement)];
  864. return acc;
  865. }, {});
  866. return Object.keys(overflows).sort(function (a, b) {
  867. return overflows[a] - overflows[b];
  868. });
  869. }
  870. function getExpandedFallbackPlacements(placement) {
  871. if (getBasePlacement(placement) === auto) {
  872. return [];
  873. }
  874. var oppositePlacement = getOppositePlacement(placement);
  875. return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
  876. }
  877. function flip(_ref) {
  878. var state = _ref.state,
  879. options = _ref.options,
  880. name = _ref.name;
  881. if (state.modifiersData[name]._skip) {
  882. return;
  883. }
  884. var _options$mainAxis = options.mainAxis,
  885. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  886. _options$altAxis = options.altAxis,
  887. checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
  888. specifiedFallbackPlacements = options.fallbackPlacements,
  889. padding = options.padding,
  890. boundary = options.boundary,
  891. rootBoundary = options.rootBoundary,
  892. altBoundary = options.altBoundary,
  893. _options$flipVariatio = options.flipVariations,
  894. flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
  895. allowedAutoPlacements = options.allowedAutoPlacements;
  896. var preferredPlacement = state.options.placement;
  897. var basePlacement = getBasePlacement(preferredPlacement);
  898. var isBasePlacement = basePlacement === preferredPlacement;
  899. var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
  900. var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
  901. return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
  902. placement: placement,
  903. boundary: boundary,
  904. rootBoundary: rootBoundary,
  905. padding: padding,
  906. flipVariations: flipVariations,
  907. allowedAutoPlacements: allowedAutoPlacements
  908. }) : placement);
  909. }, []);
  910. var referenceRect = state.rects.reference;
  911. var popperRect = state.rects.popper;
  912. var checksMap = new Map();
  913. var makeFallbackChecks = true;
  914. var firstFittingPlacement = placements[0];
  915. for (var i = 0; i < placements.length; i++) {
  916. var placement = placements[i];
  917. var _basePlacement = getBasePlacement(placement);
  918. var isStartVariation = getVariation(placement) === start;
  919. var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
  920. var len = isVertical ? 'width' : 'height';
  921. var overflow = detectOverflow(state, {
  922. placement: placement,
  923. boundary: boundary,
  924. rootBoundary: rootBoundary,
  925. altBoundary: altBoundary,
  926. padding: padding
  927. });
  928. var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
  929. if (referenceRect[len] > popperRect[len]) {
  930. mainVariationSide = getOppositePlacement(mainVariationSide);
  931. }
  932. var altVariationSide = getOppositePlacement(mainVariationSide);
  933. var checks = [];
  934. if (checkMainAxis) {
  935. checks.push(overflow[_basePlacement] <= 0);
  936. }
  937. if (checkAltAxis) {
  938. checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
  939. }
  940. if (checks.every(function (check) {
  941. return check;
  942. })) {
  943. firstFittingPlacement = placement;
  944. makeFallbackChecks = false;
  945. break;
  946. }
  947. checksMap.set(placement, checks);
  948. }
  949. if (makeFallbackChecks) {
  950. // `2` may be desired in some cases – research later
  951. var numberOfChecks = flipVariations ? 3 : 1;
  952. var _loop = function _loop(_i) {
  953. var fittingPlacement = placements.find(function (placement) {
  954. var checks = checksMap.get(placement);
  955. if (checks) {
  956. return checks.slice(0, _i).every(function (check) {
  957. return check;
  958. });
  959. }
  960. });
  961. if (fittingPlacement) {
  962. firstFittingPlacement = fittingPlacement;
  963. return "break";
  964. }
  965. };
  966. for (var _i = numberOfChecks; _i > 0; _i--) {
  967. var _ret = _loop(_i);
  968. if (_ret === "break") break;
  969. }
  970. }
  971. if (state.placement !== firstFittingPlacement) {
  972. state.modifiersData[name]._skip = true;
  973. state.placement = firstFittingPlacement;
  974. state.reset = true;
  975. }
  976. } // eslint-disable-next-line import/no-unused-modules
  977. const flip$1 = {
  978. name: 'flip',
  979. enabled: true,
  980. phase: 'main',
  981. fn: flip,
  982. requiresIfExists: ['offset'],
  983. data: {
  984. _skip: false
  985. }
  986. };
  987. function getSideOffsets(overflow, rect, preventedOffsets) {
  988. if (preventedOffsets === void 0) {
  989. preventedOffsets = {
  990. x: 0,
  991. y: 0
  992. };
  993. }
  994. return {
  995. top: overflow.top - rect.height - preventedOffsets.y,
  996. right: overflow.right - rect.width + preventedOffsets.x,
  997. bottom: overflow.bottom - rect.height + preventedOffsets.y,
  998. left: overflow.left - rect.width - preventedOffsets.x
  999. };
  1000. }
  1001. function isAnySideFullyClipped(overflow) {
  1002. return [top, right, bottom, left].some(function (side) {
  1003. return overflow[side] >= 0;
  1004. });
  1005. }
  1006. function hide(_ref) {
  1007. var state = _ref.state,
  1008. name = _ref.name;
  1009. var referenceRect = state.rects.reference;
  1010. var popperRect = state.rects.popper;
  1011. var preventedOffsets = state.modifiersData.preventOverflow;
  1012. var referenceOverflow = detectOverflow(state, {
  1013. elementContext: 'reference'
  1014. });
  1015. var popperAltOverflow = detectOverflow(state, {
  1016. altBoundary: true
  1017. });
  1018. var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
  1019. var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
  1020. var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
  1021. var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
  1022. state.modifiersData[name] = {
  1023. referenceClippingOffsets: referenceClippingOffsets,
  1024. popperEscapeOffsets: popperEscapeOffsets,
  1025. isReferenceHidden: isReferenceHidden,
  1026. hasPopperEscaped: hasPopperEscaped
  1027. };
  1028. state.attributes.popper = Object.assign({}, state.attributes.popper, {
  1029. 'data-popper-reference-hidden': isReferenceHidden,
  1030. 'data-popper-escaped': hasPopperEscaped
  1031. });
  1032. } // eslint-disable-next-line import/no-unused-modules
  1033. const hide$1 = {
  1034. name: 'hide',
  1035. enabled: true,
  1036. phase: 'main',
  1037. requiresIfExists: ['preventOverflow'],
  1038. fn: hide
  1039. };
  1040. function distanceAndSkiddingToXY(placement, rects, offset) {
  1041. var basePlacement = getBasePlacement(placement);
  1042. var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
  1043. var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
  1044. placement: placement
  1045. })) : offset,
  1046. skidding = _ref[0],
  1047. distance = _ref[1];
  1048. skidding = skidding || 0;
  1049. distance = (distance || 0) * invertDistance;
  1050. return [left, right].indexOf(basePlacement) >= 0 ? {
  1051. x: distance,
  1052. y: skidding
  1053. } : {
  1054. x: skidding,
  1055. y: distance
  1056. };
  1057. }
  1058. function offset(_ref2) {
  1059. var state = _ref2.state,
  1060. options = _ref2.options,
  1061. name = _ref2.name;
  1062. var _options$offset = options.offset,
  1063. offset = _options$offset === void 0 ? [0, 0] : _options$offset;
  1064. var data = placements.reduce(function (acc, placement) {
  1065. acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
  1066. return acc;
  1067. }, {});
  1068. var _data$state$placement = data[state.placement],
  1069. x = _data$state$placement.x,
  1070. y = _data$state$placement.y;
  1071. if (state.modifiersData.popperOffsets != null) {
  1072. state.modifiersData.popperOffsets.x += x;
  1073. state.modifiersData.popperOffsets.y += y;
  1074. }
  1075. state.modifiersData[name] = data;
  1076. } // eslint-disable-next-line import/no-unused-modules
  1077. const offset$1 = {
  1078. name: 'offset',
  1079. enabled: true,
  1080. phase: 'main',
  1081. requires: ['popperOffsets'],
  1082. fn: offset
  1083. };
  1084. function popperOffsets(_ref) {
  1085. var state = _ref.state,
  1086. name = _ref.name;
  1087. // Offsets are the actual position the popper needs to have to be
  1088. // properly positioned near its reference element
  1089. // This is the most basic placement, and will be adjusted by
  1090. // the modifiers in the next step
  1091. state.modifiersData[name] = computeOffsets({
  1092. reference: state.rects.reference,
  1093. element: state.rects.popper,
  1094. strategy: 'absolute',
  1095. placement: state.placement
  1096. });
  1097. } // eslint-disable-next-line import/no-unused-modules
  1098. const popperOffsets$1 = {
  1099. name: 'popperOffsets',
  1100. enabled: true,
  1101. phase: 'read',
  1102. fn: popperOffsets,
  1103. data: {}
  1104. };
  1105. function getAltAxis(axis) {
  1106. return axis === 'x' ? 'y' : 'x';
  1107. }
  1108. function preventOverflow(_ref) {
  1109. var state = _ref.state,
  1110. options = _ref.options,
  1111. name = _ref.name;
  1112. var _options$mainAxis = options.mainAxis,
  1113. checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
  1114. _options$altAxis = options.altAxis,
  1115. checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
  1116. boundary = options.boundary,
  1117. rootBoundary = options.rootBoundary,
  1118. altBoundary = options.altBoundary,
  1119. padding = options.padding,
  1120. _options$tether = options.tether,
  1121. tether = _options$tether === void 0 ? true : _options$tether,
  1122. _options$tetherOffset = options.tetherOffset,
  1123. tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
  1124. var overflow = detectOverflow(state, {
  1125. boundary: boundary,
  1126. rootBoundary: rootBoundary,
  1127. padding: padding,
  1128. altBoundary: altBoundary
  1129. });
  1130. var basePlacement = getBasePlacement(state.placement);
  1131. var variation = getVariation(state.placement);
  1132. var isBasePlacement = !variation;
  1133. var mainAxis = getMainAxisFromPlacement(basePlacement);
  1134. var altAxis = getAltAxis(mainAxis);
  1135. var popperOffsets = state.modifiersData.popperOffsets;
  1136. var referenceRect = state.rects.reference;
  1137. var popperRect = state.rects.popper;
  1138. var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
  1139. placement: state.placement
  1140. })) : tetherOffset;
  1141. var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
  1142. mainAxis: tetherOffsetValue,
  1143. altAxis: tetherOffsetValue
  1144. } : Object.assign({
  1145. mainAxis: 0,
  1146. altAxis: 0
  1147. }, tetherOffsetValue);
  1148. var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
  1149. var data = {
  1150. x: 0,
  1151. y: 0
  1152. };
  1153. if (!popperOffsets) {
  1154. return;
  1155. }
  1156. if (checkMainAxis) {
  1157. var _offsetModifierState$;
  1158. var mainSide = mainAxis === 'y' ? top : left;
  1159. var altSide = mainAxis === 'y' ? bottom : right;
  1160. var len = mainAxis === 'y' ? 'height' : 'width';
  1161. var offset = popperOffsets[mainAxis];
  1162. var min$1 = offset + overflow[mainSide];
  1163. var max$1 = offset - overflow[altSide];
  1164. var additive = tether ? -popperRect[len] / 2 : 0;
  1165. var minLen = variation === start ? referenceRect[len] : popperRect[len];
  1166. var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
  1167. // outside the reference bounds
  1168. var arrowElement = state.elements.arrow;
  1169. var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
  1170. width: 0,
  1171. height: 0
  1172. };
  1173. var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
  1174. var arrowPaddingMin = arrowPaddingObject[mainSide];
  1175. var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
  1176. // to include its full size in the calculation. If the reference is small
  1177. // and near the edge of a boundary, the popper can overflow even if the
  1178. // reference is not overflowing as well (e.g. virtual elements with no
  1179. // width or height)
  1180. var arrowLen = within(0, referenceRect[len], arrowRect[len]);
  1181. var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
  1182. var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
  1183. var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
  1184. var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
  1185. var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
  1186. var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
  1187. var tetherMax = offset + maxOffset - offsetModifierValue;
  1188. var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
  1189. popperOffsets[mainAxis] = preventedOffset;
  1190. data[mainAxis] = preventedOffset - offset;
  1191. }
  1192. if (checkAltAxis) {
  1193. var _offsetModifierState$2;
  1194. var _mainSide = mainAxis === 'x' ? top : left;
  1195. var _altSide = mainAxis === 'x' ? bottom : right;
  1196. var _offset = popperOffsets[altAxis];
  1197. var _len = altAxis === 'y' ? 'height' : 'width';
  1198. var _min = _offset + overflow[_mainSide];
  1199. var _max = _offset - overflow[_altSide];
  1200. var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
  1201. var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
  1202. var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
  1203. var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
  1204. var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
  1205. popperOffsets[altAxis] = _preventedOffset;
  1206. data[altAxis] = _preventedOffset - _offset;
  1207. }
  1208. state.modifiersData[name] = data;
  1209. } // eslint-disable-next-line import/no-unused-modules
  1210. const preventOverflow$1 = {
  1211. name: 'preventOverflow',
  1212. enabled: true,
  1213. phase: 'main',
  1214. fn: preventOverflow,
  1215. requiresIfExists: ['offset']
  1216. };
  1217. function getHTMLElementScroll(element) {
  1218. return {
  1219. scrollLeft: element.scrollLeft,
  1220. scrollTop: element.scrollTop
  1221. };
  1222. }
  1223. function getNodeScroll(node) {
  1224. if (node === getWindow(node) || !isHTMLElement(node)) {
  1225. return getWindowScroll(node);
  1226. } else {
  1227. return getHTMLElementScroll(node);
  1228. }
  1229. }
  1230. function isElementScaled(element) {
  1231. var rect = element.getBoundingClientRect();
  1232. var scaleX = round(rect.width) / element.offsetWidth || 1;
  1233. var scaleY = round(rect.height) / element.offsetHeight || 1;
  1234. return scaleX !== 1 || scaleY !== 1;
  1235. } // Returns the composite rect of an element relative to its offsetParent.
  1236. // Composite means it takes into account transforms as well as layout.
  1237. function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
  1238. if (isFixed === void 0) {
  1239. isFixed = false;
  1240. }
  1241. var isOffsetParentAnElement = isHTMLElement(offsetParent);
  1242. var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
  1243. var documentElement = getDocumentElement(offsetParent);
  1244. var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
  1245. var scroll = {
  1246. scrollLeft: 0,
  1247. scrollTop: 0
  1248. };
  1249. var offsets = {
  1250. x: 0,
  1251. y: 0
  1252. };
  1253. if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
  1254. if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
  1255. isScrollParent(documentElement)) {
  1256. scroll = getNodeScroll(offsetParent);
  1257. }
  1258. if (isHTMLElement(offsetParent)) {
  1259. offsets = getBoundingClientRect(offsetParent, true);
  1260. offsets.x += offsetParent.clientLeft;
  1261. offsets.y += offsetParent.clientTop;
  1262. } else if (documentElement) {
  1263. offsets.x = getWindowScrollBarX(documentElement);
  1264. }
  1265. }
  1266. return {
  1267. x: rect.left + scroll.scrollLeft - offsets.x,
  1268. y: rect.top + scroll.scrollTop - offsets.y,
  1269. width: rect.width,
  1270. height: rect.height
  1271. };
  1272. }
  1273. function order(modifiers) {
  1274. var map = new Map();
  1275. var visited = new Set();
  1276. var result = [];
  1277. modifiers.forEach(function (modifier) {
  1278. map.set(modifier.name, modifier);
  1279. }); // On visiting object, check for its dependencies and visit them recursively
  1280. function sort(modifier) {
  1281. visited.add(modifier.name);
  1282. var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
  1283. requires.forEach(function (dep) {
  1284. if (!visited.has(dep)) {
  1285. var depModifier = map.get(dep);
  1286. if (depModifier) {
  1287. sort(depModifier);
  1288. }
  1289. }
  1290. });
  1291. result.push(modifier);
  1292. }
  1293. modifiers.forEach(function (modifier) {
  1294. if (!visited.has(modifier.name)) {
  1295. // check for visited object
  1296. sort(modifier);
  1297. }
  1298. });
  1299. return result;
  1300. }
  1301. function orderModifiers(modifiers) {
  1302. // order based on dependencies
  1303. var orderedModifiers = order(modifiers); // order based on phase
  1304. return modifierPhases.reduce(function (acc, phase) {
  1305. return acc.concat(orderedModifiers.filter(function (modifier) {
  1306. return modifier.phase === phase;
  1307. }));
  1308. }, []);
  1309. }
  1310. function debounce(fn) {
  1311. var pending;
  1312. return function () {
  1313. if (!pending) {
  1314. pending = new Promise(function (resolve) {
  1315. Promise.resolve().then(function () {
  1316. pending = undefined;
  1317. resolve(fn());
  1318. });
  1319. });
  1320. }
  1321. return pending;
  1322. };
  1323. }
  1324. function mergeByName(modifiers) {
  1325. var merged = modifiers.reduce(function (merged, current) {
  1326. var existing = merged[current.name];
  1327. merged[current.name] = existing ? Object.assign({}, existing, current, {
  1328. options: Object.assign({}, existing.options, current.options),
  1329. data: Object.assign({}, existing.data, current.data)
  1330. }) : current;
  1331. return merged;
  1332. }, {}); // IE11 does not support Object.values
  1333. return Object.keys(merged).map(function (key) {
  1334. return merged[key];
  1335. });
  1336. }
  1337. var DEFAULT_OPTIONS = {
  1338. placement: 'bottom',
  1339. modifiers: [],
  1340. strategy: 'absolute'
  1341. };
  1342. function areValidElements() {
  1343. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1344. args[_key] = arguments[_key];
  1345. }
  1346. return !args.some(function (element) {
  1347. return !(element && typeof element.getBoundingClientRect === 'function');
  1348. });
  1349. }
  1350. function popperGenerator(generatorOptions) {
  1351. if (generatorOptions === void 0) {
  1352. generatorOptions = {};
  1353. }
  1354. var _generatorOptions = generatorOptions,
  1355. _generatorOptions$def = _generatorOptions.defaultModifiers,
  1356. defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
  1357. _generatorOptions$def2 = _generatorOptions.defaultOptions,
  1358. defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
  1359. return function createPopper(reference, popper, options) {
  1360. if (options === void 0) {
  1361. options = defaultOptions;
  1362. }
  1363. var state = {
  1364. placement: 'bottom',
  1365. orderedModifiers: [],
  1366. options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
  1367. modifiersData: {},
  1368. elements: {
  1369. reference: reference,
  1370. popper: popper
  1371. },
  1372. attributes: {},
  1373. styles: {}
  1374. };
  1375. var effectCleanupFns = [];
  1376. var isDestroyed = false;
  1377. var instance = {
  1378. state: state,
  1379. setOptions: function setOptions(setOptionsAction) {
  1380. var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
  1381. cleanupModifierEffects();
  1382. state.options = Object.assign({}, defaultOptions, state.options, options);
  1383. state.scrollParents = {
  1384. reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
  1385. popper: listScrollParents(popper)
  1386. }; // Orders the modifiers based on their dependencies and `phase`
  1387. // properties
  1388. var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
  1389. state.orderedModifiers = orderedModifiers.filter(function (m) {
  1390. return m.enabled;
  1391. }); // Validate the provided modifiers so that the consumer will get warned
  1392. runModifierEffects();
  1393. return instance.update();
  1394. },
  1395. // Sync update – it will always be executed, even if not necessary. This
  1396. // is useful for low frequency updates where sync behavior simplifies the
  1397. // logic.
  1398. // For high frequency updates (e.g. `resize` and `scroll` events), always
  1399. // prefer the async Popper#update method
  1400. forceUpdate: function forceUpdate() {
  1401. if (isDestroyed) {
  1402. return;
  1403. }
  1404. var _state$elements = state.elements,
  1405. reference = _state$elements.reference,
  1406. popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
  1407. // anymore
  1408. if (!areValidElements(reference, popper)) {
  1409. return;
  1410. } // Store the reference and popper rects to be read by modifiers
  1411. state.rects = {
  1412. reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
  1413. popper: getLayoutRect(popper)
  1414. }; // Modifiers have the ability to reset the current update cycle. The
  1415. // most common use case for this is the `flip` modifier changing the
  1416. // placement, which then needs to re-run all the modifiers, because the
  1417. // logic was previously ran for the previous placement and is therefore
  1418. // stale/incorrect
  1419. state.reset = false;
  1420. state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
  1421. // is filled with the initial data specified by the modifier. This means
  1422. // it doesn't persist and is fresh on each update.
  1423. // To ensure persistent data, use `${name}#persistent`
  1424. state.orderedModifiers.forEach(function (modifier) {
  1425. return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
  1426. });
  1427. for (var index = 0; index < state.orderedModifiers.length; index++) {
  1428. if (state.reset === true) {
  1429. state.reset = false;
  1430. index = -1;
  1431. continue;
  1432. }
  1433. var _state$orderedModifie = state.orderedModifiers[index],
  1434. fn = _state$orderedModifie.fn,
  1435. _state$orderedModifie2 = _state$orderedModifie.options,
  1436. _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
  1437. name = _state$orderedModifie.name;
  1438. if (typeof fn === 'function') {
  1439. state = fn({
  1440. state: state,
  1441. options: _options,
  1442. name: name,
  1443. instance: instance
  1444. }) || state;
  1445. }
  1446. }
  1447. },
  1448. // Async and optimistically optimized update – it will not be executed if
  1449. // not necessary (debounced to run at most once-per-tick)
  1450. update: debounce(function () {
  1451. return new Promise(function (resolve) {
  1452. instance.forceUpdate();
  1453. resolve(state);
  1454. });
  1455. }),
  1456. destroy: function destroy() {
  1457. cleanupModifierEffects();
  1458. isDestroyed = true;
  1459. }
  1460. };
  1461. if (!areValidElements(reference, popper)) {
  1462. return instance;
  1463. }
  1464. instance.setOptions(options).then(function (state) {
  1465. if (!isDestroyed && options.onFirstUpdate) {
  1466. options.onFirstUpdate(state);
  1467. }
  1468. }); // Modifiers have the ability to execute arbitrary code before the first
  1469. // update cycle runs. They will be executed in the same order as the update
  1470. // cycle. This is useful when a modifier adds some persistent data that
  1471. // other modifiers need to use, but the modifier is run after the dependent
  1472. // one.
  1473. function runModifierEffects() {
  1474. state.orderedModifiers.forEach(function (_ref3) {
  1475. var name = _ref3.name,
  1476. _ref3$options = _ref3.options,
  1477. options = _ref3$options === void 0 ? {} : _ref3$options,
  1478. effect = _ref3.effect;
  1479. if (typeof effect === 'function') {
  1480. var cleanupFn = effect({
  1481. state: state,
  1482. name: name,
  1483. instance: instance,
  1484. options: options
  1485. });
  1486. var noopFn = function noopFn() {};
  1487. effectCleanupFns.push(cleanupFn || noopFn);
  1488. }
  1489. });
  1490. }
  1491. function cleanupModifierEffects() {
  1492. effectCleanupFns.forEach(function (fn) {
  1493. return fn();
  1494. });
  1495. effectCleanupFns = [];
  1496. }
  1497. return instance;
  1498. };
  1499. }
  1500. var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
  1501. var createPopper$1 = /*#__PURE__*/popperGenerator({
  1502. defaultModifiers: defaultModifiers
  1503. }); // eslint-disable-next-line import/no-unused-modules
  1504. const popperComputedPlacements = [
  1505. "top",
  1506. "bottom",
  1507. "right",
  1508. "left",
  1509. "top-start",
  1510. "top-end",
  1511. "bottom-start",
  1512. "bottom-end",
  1513. "right-start",
  1514. "right-end",
  1515. "left-start",
  1516. "left-end"
  1517. ];
  1518. const defaultMenuPlacement = "bottom-leading";
  1519. const popperMenuComputedPlacements = [
  1520. "top-start",
  1521. "top",
  1522. "top-end",
  1523. "bottom-start",
  1524. "bottom",
  1525. "bottom-end"
  1526. ];
  1527. const CSS = {
  1528. animation: "calcite-popper-anim",
  1529. animationActive: "calcite-popper-anim--active"
  1530. };
  1531. function filterComputedPlacements(placements, el) {
  1532. const filteredPlacements = placements.filter((placement) => popperComputedPlacements.includes(placement));
  1533. if (filteredPlacements.length !== placements.length) {
  1534. console.warn(`${el.tagName}: Invalid value found in: flipPlacements. Try any of these: ${popperComputedPlacements
  1535. .map((placement) => `"${placement}"`)
  1536. .join(", ")
  1537. .trim()}`, { el });
  1538. }
  1539. return filteredPlacements;
  1540. }
  1541. function getPlacement(el, placement) {
  1542. const placements = ["left", "right"];
  1543. const variations = ["start", "end"];
  1544. if (dom.getElementDir(el) === "rtl") {
  1545. placements.reverse();
  1546. variations.reverse();
  1547. }
  1548. return placement
  1549. .replace(/-leading/gi, `-${variations[0]}`)
  1550. .replace(/-trailing/gi, `-${variations[1]}`)
  1551. .replace(/leading/gi, placements[0])
  1552. .replace(/trailing/gi, placements[1]);
  1553. }
  1554. function createPopper({ referenceEl, el, placement, overlayPositioning = "absolute", modifiers }) {
  1555. if (!referenceEl) {
  1556. return null;
  1557. }
  1558. return createPopper$1(referenceEl, el, {
  1559. strategy: overlayPositioning,
  1560. placement: getPlacement(el, placement),
  1561. modifiers
  1562. });
  1563. }
  1564. async function updatePopper({ el, modifiers, placement: PopperPlacement, popper }) {
  1565. const placement = getPlacement(el, PopperPlacement);
  1566. await popper.setOptions({
  1567. modifiers,
  1568. placement
  1569. });
  1570. }
  1571. function hypotenuse(sideA, sideB) {
  1572. return Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2));
  1573. }
  1574. const visiblePointerSize = 4;
  1575. const defaultOffsetDistance = Math.ceil(hypotenuse(visiblePointerSize, visiblePointerSize));
  1576. exports.CSS = CSS;
  1577. exports.createPopper = createPopper;
  1578. exports.defaultMenuPlacement = defaultMenuPlacement;
  1579. exports.defaultOffsetDistance = defaultOffsetDistance;
  1580. exports.filterComputedPlacements = filterComputedPlacements;
  1581. exports.popperMenuComputedPlacements = popperMenuComputedPlacements;
  1582. exports.updatePopper = updatePopper;