gd-bs 5.7.1 → 5.7.4

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