react-shepherd 3.3.1 → 3.3.6

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.
@@ -1,7 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
 
3
- /*! shepherd.js 8.0.2 */
4
-
3
+ /*! shepherd.js 8.3.1 */
5
4
  var isMergeableObject = function isMergeableObject(value) {
6
5
  return isNonNullObject(value) && !isSpecial(value);
7
6
  };
@@ -126,12 +125,12 @@ deepmerge.all = function deepmergeAll(array, options) {
126
125
 
127
126
  var deepmerge_1 = deepmerge;
128
127
  var cjs = deepmerge_1;
129
-
130
128
  /**
131
129
  * Checks if `value` is classified as an `Element`.
132
130
  * @param {*} value The param to check if it is an Element
133
131
  */
134
- function isElement(value) {
132
+
133
+ function isElement$1(value) {
135
134
  return value instanceof Element;
136
135
  }
137
136
  /**
@@ -139,7 +138,8 @@ function isElement(value) {
139
138
  * @param {*} value The param to check if it is an HTMLElement
140
139
  */
141
140
 
142
- function isHTMLElement(value) {
141
+
142
+ function isHTMLElement$1(value) {
143
143
  return value instanceof HTMLElement;
144
144
  }
145
145
  /**
@@ -147,6 +147,7 @@ function isHTMLElement(value) {
147
147
  * @param {*} value The param to check if it is a function
148
148
  */
149
149
 
150
+
150
151
  function isFunction(value) {
151
152
  return typeof value === 'function';
152
153
  }
@@ -155,6 +156,7 @@ function isFunction(value) {
155
156
  * @param {*} value The param to check if it is a string
156
157
  */
157
158
 
159
+
158
160
  function isString(value) {
159
161
  return typeof value === 'string';
160
162
  }
@@ -163,6 +165,7 @@ function isString(value) {
163
165
  * @param {*} value The param to check if it is undefined
164
166
  */
165
167
 
168
+
166
169
  function isUndefined(value) {
167
170
  return value === undefined;
168
171
  }
@@ -228,13 +231,14 @@ class Evented {
228
231
  }
229
232
 
230
233
  }
231
-
232
234
  /**
233
235
  * Binds all the methods on a JS Class to the `this` context of the class.
234
236
  * Adapted from https://github.com/sindresorhus/auto-bind
235
237
  * @param {object} self The `this` context of the class
236
238
  * @return {object} The `this` context of the class
237
239
  */
240
+
241
+
238
242
  function autoBind(self) {
239
243
  const keys = Object.getOwnPropertyNames(self.constructor.prototype);
240
244
 
@@ -249,7 +253,6 @@ function autoBind(self) {
249
253
 
250
254
  return self;
251
255
  }
252
-
253
256
  /**
254
257
  * Sets up the handler to determine if we should advance the tour
255
258
  * @param {string} selector
@@ -258,6 +261,7 @@ function autoBind(self) {
258
261
  * @private
259
262
  */
260
263
 
264
+
261
265
  function _setupAdvanceOnHandler(selector, step) {
262
266
  return event => {
263
267
  if (step.isOpen()) {
@@ -312,243 +316,285 @@ function bindAdvance(step) {
312
316
  }
313
317
  }
314
318
 
315
- function getBoundingClientRect(element) {
316
- var rect = element.getBoundingClientRect();
317
- return {
318
- width: rect.width,
319
- height: rect.height,
320
- top: rect.top,
321
- right: rect.right,
322
- bottom: rect.bottom,
323
- left: rect.left,
324
- x: rect.left,
325
- y: rect.top
326
- };
327
- }
319
+ var top = 'top';
320
+ var bottom = 'bottom';
321
+ var right = 'right';
322
+ var left = 'left';
323
+ var auto = 'auto';
324
+ var basePlacements = [top, bottom, right, left];
325
+ var start = 'start';
326
+ var end = 'end';
327
+ var clippingParents = 'clippingParents';
328
+ var viewport = 'viewport';
329
+ var popper = 'popper';
330
+ var reference = 'reference';
331
+ var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
332
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
333
+ }, []);
334
+ var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
335
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
336
+ }, []); // modifiers that need to read the DOM
337
+
338
+ var beforeRead = 'beforeRead';
339
+ var read = 'read';
340
+ var afterRead = 'afterRead'; // pure-logic modifiers
341
+
342
+ var beforeMain = 'beforeMain';
343
+ var main = 'main';
344
+ var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
345
+
346
+ var beforeWrite = 'beforeWrite';
347
+ var write = 'write';
348
+ var afterWrite = 'afterWrite';
349
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
328
350
 
329
- /*:: import type { Window } from '../types'; */
351
+ function getNodeName(element) {
352
+ return element ? (element.nodeName || '').toLowerCase() : null;
353
+ }
330
354
 
331
- /*:: declare function getWindow(node: Node | Window): Window; */
332
355
  function getWindow(node) {
356
+ if (node == null) {
357
+ return window;
358
+ }
359
+
333
360
  if (node.toString() !== '[object Window]') {
334
361
  var ownerDocument = node.ownerDocument;
335
- return ownerDocument ? ownerDocument.defaultView : window;
362
+ return ownerDocument ? ownerDocument.defaultView || window : window;
336
363
  }
337
364
 
338
365
  return node;
339
366
  }
340
367
 
341
- function getWindowScroll(node) {
342
- var win = getWindow(node);
343
- var scrollLeft = win.pageXOffset;
344
- var scrollTop = win.pageYOffset;
345
- return {
346
- scrollLeft: scrollLeft,
347
- scrollTop: scrollTop
348
- };
349
- }
350
-
351
- /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
352
- Element); */
353
-
354
- function isElement$1(node) {
368
+ function isElement(node) {
355
369
  var OwnElement = getWindow(node).Element;
356
370
  return node instanceof OwnElement || node instanceof Element;
357
371
  }
358
- /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
359
- HTMLElement); */
360
-
361
372
 
362
- function isHTMLElement$1(node) {
373
+ function isHTMLElement(node) {
363
374
  var OwnElement = getWindow(node).HTMLElement;
364
375
  return node instanceof OwnElement || node instanceof HTMLElement;
365
376
  }
366
377
 
367
- function getHTMLElementScroll(element) {
368
- return {
369
- scrollLeft: element.scrollLeft,
370
- scrollTop: element.scrollTop
371
- };
372
- }
373
-
374
- function getNodeScroll(node) {
375
- if (node === getWindow(node) || !isHTMLElement$1(node)) {
376
- return getWindowScroll(node);
377
- } else {
378
- return getHTMLElementScroll(node);
378
+ function isShadowRoot(node) {
379
+ // IE 11 has no ShadowRoot
380
+ if (typeof ShadowRoot === 'undefined') {
381
+ return false;
379
382
  }
380
- }
381
383
 
382
- function getNodeName(element) {
383
- return element ? (element.nodeName || '').toLowerCase() : null;
384
- }
384
+ var OwnElement = getWindow(node).ShadowRoot;
385
+ return node instanceof OwnElement || node instanceof ShadowRoot;
386
+ } // and applies them to the HTMLElements such as popper and arrow
385
387
 
386
- function getDocumentElement(element) {
387
- // $FlowFixMe: assume body is always available
388
- return (isElement$1(element) ? element.ownerDocument : element.document).documentElement;
389
- }
390
388
 
391
- function getWindowScrollBarX(element) {
392
- // If <html> has a CSS width greater than the viewport, then this will be
393
- // incorrect for RTL.
394
- // Popper 1 is broken in this case and never had a bug report so let's assume
395
- // it's not an issue. I don't think anyone ever specifies width on <html>
396
- // anyway.
397
- // Browsers where the left scrollbar doesn't cause an issue report `0` for
398
- // this (e.g. Edge 2019, IE11, Safari)
399
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
400
- }
389
+ function applyStyles(_ref) {
390
+ var state = _ref.state;
391
+ Object.keys(state.elements).forEach(function (name) {
392
+ var style = state.styles[name] || {};
393
+ var attributes = state.attributes[name] || {};
394
+ var element = state.elements[name]; // arrow is optional + virtual elements
401
395
 
402
- function getComputedStyle(element) {
403
- return getWindow(element).getComputedStyle(element);
404
- }
396
+ if (!isHTMLElement(element) || !getNodeName(element)) {
397
+ return;
398
+ } // Flow doesn't support to extend this property, but it's the most
399
+ // effective way to apply styles to an HTMLElement
400
+ // $FlowFixMe[cannot-write]
405
401
 
406
- function isScrollParent(element) {
407
- // Firefox wants us to check `-x` and `-y` variations as well
408
- var _getComputedStyle = getComputedStyle(element),
409
- overflow = _getComputedStyle.overflow,
410
- overflowX = _getComputedStyle.overflowX,
411
- overflowY = _getComputedStyle.overflowY;
412
402
 
413
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
403
+ Object.assign(element.style, style);
404
+ Object.keys(attributes).forEach(function (name) {
405
+ var value = attributes[name];
406
+
407
+ if (value === false) {
408
+ element.removeAttribute(name);
409
+ } else {
410
+ element.setAttribute(name, value === true ? '' : value);
411
+ }
412
+ });
413
+ });
414
414
  }
415
415
 
416
- // Composite means it takes into account transforms as well as layout.
416
+ function effect$2(_ref2) {
417
+ var state = _ref2.state;
418
+ var initialStyles = {
419
+ popper: {
420
+ position: state.options.strategy,
421
+ left: '0',
422
+ top: '0',
423
+ margin: '0'
424
+ },
425
+ arrow: {
426
+ position: 'absolute'
427
+ },
428
+ reference: {}
429
+ };
430
+ Object.assign(state.elements.popper.style, initialStyles.popper);
431
+ state.styles = initialStyles;
417
432
 
418
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
419
- if (isFixed === void 0) {
420
- isFixed = false;
433
+ if (state.elements.arrow) {
434
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
421
435
  }
422
436
 
423
- var documentElement = getDocumentElement(offsetParent);
424
- var rect = getBoundingClientRect(elementOrVirtualElement);
425
- var isOffsetParentAnElement = isHTMLElement$1(offsetParent);
426
- var scroll = {
427
- scrollLeft: 0,
428
- scrollTop: 0
429
- };
430
- var offsets = {
431
- x: 0,
432
- y: 0
437
+ return function () {
438
+ Object.keys(state.elements).forEach(function (name) {
439
+ var element = state.elements[name];
440
+ var attributes = state.attributes[name] || {};
441
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
442
+
443
+ var style = styleProperties.reduce(function (style, property) {
444
+ style[property] = '';
445
+ return style;
446
+ }, {}); // arrow is optional + virtual elements
447
+
448
+ if (!isHTMLElement(element) || !getNodeName(element)) {
449
+ return;
450
+ }
451
+
452
+ Object.assign(element.style, style);
453
+ Object.keys(attributes).forEach(function (attribute) {
454
+ element.removeAttribute(attribute);
455
+ });
456
+ });
433
457
  };
458
+ } // eslint-disable-next-line import/no-unused-modules
434
459
 
435
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
436
- if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
437
- isScrollParent(documentElement)) {
438
- scroll = getNodeScroll(offsetParent);
439
- }
440
460
 
441
- if (isHTMLElement$1(offsetParent)) {
442
- offsets = getBoundingClientRect(offsetParent);
443
- offsets.x += offsetParent.clientLeft;
444
- offsets.y += offsetParent.clientTop;
445
- } else if (documentElement) {
446
- offsets.x = getWindowScrollBarX(documentElement);
447
- }
448
- }
461
+ var applyStyles$1 = {
462
+ name: 'applyStyles',
463
+ enabled: true,
464
+ phase: 'write',
465
+ fn: applyStyles,
466
+ effect: effect$2,
467
+ requires: ['computeStyles']
468
+ };
469
+
470
+ function getBasePlacement(placement) {
471
+ return placement.split('-')[0];
472
+ }
449
473
 
474
+ function getBoundingClientRect(element) {
475
+ var rect = element.getBoundingClientRect();
450
476
  return {
451
- x: rect.left + scroll.scrollLeft - offsets.x,
452
- y: rect.top + scroll.scrollTop - offsets.y,
453
477
  width: rect.width,
454
- height: rect.height
478
+ height: rect.height,
479
+ top: rect.top,
480
+ right: rect.right,
481
+ bottom: rect.bottom,
482
+ left: rect.left,
483
+ x: rect.left,
484
+ y: rect.top
455
485
  };
456
- }
486
+ } // means it doesn't take into account transforms.
487
+
457
488
 
458
- // Returns the layout rect of an element relative to its offsetParent. Layout
459
- // means it doesn't take into account transforms.
460
489
  function getLayoutRect(element) {
490
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
491
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
492
+
493
+ var width = element.offsetWidth;
494
+ var height = element.offsetHeight;
495
+
496
+ if (Math.abs(clientRect.width - width) <= 1) {
497
+ width = clientRect.width;
498
+ }
499
+
500
+ if (Math.abs(clientRect.height - height) <= 1) {
501
+ height = clientRect.height;
502
+ }
503
+
461
504
  return {
462
505
  x: element.offsetLeft,
463
506
  y: element.offsetTop,
464
- width: element.offsetWidth,
465
- height: element.offsetHeight
507
+ width: width,
508
+ height: height
466
509
  };
467
510
  }
468
511
 
512
+ function contains(parent, child) {
513
+ var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
514
+
515
+ if (parent.contains(child)) {
516
+ return true;
517
+ } // then fallback to custom implementation with Shadow DOM support
518
+ else if (rootNode && isShadowRoot(rootNode)) {
519
+ var next = child;
520
+
521
+ do {
522
+ if (next && parent.isSameNode(next)) {
523
+ return true;
524
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
525
+
526
+
527
+ next = next.parentNode || next.host;
528
+ } while (next);
529
+ } // Give up, the result is false
530
+
531
+
532
+ return false;
533
+ }
534
+
535
+ function getComputedStyle(element) {
536
+ return getWindow(element).getComputedStyle(element);
537
+ }
538
+
539
+ function isTableElement(element) {
540
+ return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
541
+ }
542
+
543
+ function getDocumentElement(element) {
544
+ // $FlowFixMe[incompatible-return]: assume body is always available
545
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
546
+ element.document) || window.document).documentElement;
547
+ }
548
+
469
549
  function getParentNode(element) {
470
550
  if (getNodeName(element) === 'html') {
471
551
  return element;
472
552
  }
473
553
 
474
- return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
554
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
555
+ // $FlowFixMe[incompatible-return]
556
+ // $FlowFixMe[prop-missing]
475
557
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
476
- element.parentNode || // DOM Element detected
477
- // $FlowFixMe: need a better way to handle this...
478
- element.host || // ShadowRoot detected
479
- // $FlowFixMe: HTMLElement is a Node
558
+ element.parentNode || ( // DOM Element detected
559
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
560
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
480
561
  getDocumentElement(element) // fallback
481
562
 
482
563
  );
483
564
  }
484
565
 
485
- function getScrollParent(node) {
486
- if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
487
- // $FlowFixMe: assume body is always available
488
- return node.ownerDocument.body;
489
- }
490
-
491
- if (isHTMLElement$1(node) && isScrollParent(node)) {
492
- return node;
493
- }
494
-
495
- return getScrollParent(getParentNode(node));
496
- }
497
-
498
- /*
499
- given a DOM element, return the list of all scroll parents, up the list of ancesors
500
- until we get to the top window object. This list is what we attach scroll listeners
501
- to, because if any of these parent elements scroll, we'll need to re-calculate the
502
- reference element's position.
503
- */
504
-
505
- function listScrollParents(element, list) {
506
- if (list === void 0) {
507
- list = [];
508
- }
509
-
510
- var scrollParent = getScrollParent(element);
511
- var isBody = getNodeName(scrollParent) === 'body';
512
- var win = getWindow(scrollParent);
513
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
514
- var updatedList = list.concat(target);
515
- return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
516
- updatedList.concat(listScrollParents(getParentNode(target)));
517
- }
518
-
519
- function isTableElement(element) {
520
- return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
521
- }
522
-
523
566
  function getTrueOffsetParent(element) {
524
- if (!isHTMLElement$1(element) || // https://github.com/popperjs/popper-core/issues/837
567
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
525
568
  getComputedStyle(element).position === 'fixed') {
526
569
  return null;
527
570
  }
528
571
 
529
- var offsetParent = element.offsetParent;
530
-
531
- if (offsetParent) {
532
- var html = getDocumentElement(offsetParent);
533
-
534
- if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
535
- return html;
536
- }
537
- }
538
-
539
- return offsetParent;
572
+ return element.offsetParent;
540
573
  } // `.offsetParent` reports `null` for fixed elements, while absolute elements
541
574
  // return the containing block
542
575
 
543
576
 
544
577
  function getContainingBlock(element) {
578
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
579
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
580
+
581
+ if (isIE && isHTMLElement(element)) {
582
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
583
+ var elementCss = getComputedStyle(element);
584
+
585
+ if (elementCss.position === 'fixed') {
586
+ return null;
587
+ }
588
+ }
589
+
545
590
  var currentNode = getParentNode(element);
546
591
 
547
- while (isHTMLElement$1(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
592
+ while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
548
593
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
549
594
  // create a containing block.
595
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
550
596
 
551
- if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
597
+ 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') {
552
598
  return currentNode;
553
599
  } else {
554
600
  currentNode = currentNode.parentNode;
@@ -568,636 +614,285 @@ function getOffsetParent(element) {
568
614
  offsetParent = getTrueOffsetParent(offsetParent);
569
615
  }
570
616
 
571
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
617
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
572
618
  return window;
573
619
  }
574
620
 
575
621
  return offsetParent || getContainingBlock(element) || window;
576
622
  }
577
623
 
578
- var top = 'top';
579
- var bottom = 'bottom';
580
- var right = 'right';
581
- var left = 'left';
582
- var auto = 'auto';
583
- var basePlacements = [top, bottom, right, left];
584
- var start = 'start';
585
- var end = 'end';
586
- var clippingParents = 'clippingParents';
587
- var viewport = 'viewport';
588
- var popper = 'popper';
589
- var reference = 'reference';
590
- var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
591
- return acc.concat([placement + "-" + start, placement + "-" + end]);
592
- }, []);
593
- var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
594
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
595
- }, []); // modifiers that need to read the DOM
596
-
597
- var beforeRead = 'beforeRead';
598
- var read = 'read';
599
- var afterRead = 'afterRead'; // pure-logic modifiers
600
-
601
- var beforeMain = 'beforeMain';
602
- var main = 'main';
603
- var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
604
-
605
- var beforeWrite = 'beforeWrite';
606
- var write = 'write';
607
- var afterWrite = 'afterWrite';
608
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
609
-
610
- function order(modifiers) {
611
- var map = new Map();
612
- var visited = new Set();
613
- var result = [];
614
- modifiers.forEach(function (modifier) {
615
- map.set(modifier.name, modifier);
616
- }); // On visiting object, check for its dependencies and visit them recursively
617
-
618
- function sort(modifier) {
619
- visited.add(modifier.name);
620
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
621
- requires.forEach(function (dep) {
622
- if (!visited.has(dep)) {
623
- var depModifier = map.get(dep);
624
-
625
- if (depModifier) {
626
- sort(depModifier);
627
- }
628
- }
629
- });
630
- result.push(modifier);
631
- }
632
-
633
- modifiers.forEach(function (modifier) {
634
- if (!visited.has(modifier.name)) {
635
- // check for visited object
636
- sort(modifier);
637
- }
638
- });
639
- return result;
624
+ function getMainAxisFromPlacement(placement) {
625
+ return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
640
626
  }
641
627
 
642
- function orderModifiers(modifiers) {
643
- // order based on dependencies
644
- var orderedModifiers = order(modifiers); // order based on phase
628
+ var max = Math.max;
629
+ var min = Math.min;
630
+ var round = Math.round;
645
631
 
646
- return modifierPhases.reduce(function (acc, phase) {
647
- return acc.concat(orderedModifiers.filter(function (modifier) {
648
- return modifier.phase === phase;
649
- }));
650
- }, []);
632
+ function within(min$1, value, max$1) {
633
+ return max(min$1, min(value, max$1));
651
634
  }
652
635
 
653
- function debounce(fn) {
654
- var pending;
655
- return function () {
656
- if (!pending) {
657
- pending = new Promise(function (resolve) {
658
- Promise.resolve().then(function () {
659
- pending = undefined;
660
- resolve(fn());
661
- });
662
- });
663
- }
664
-
665
- return pending;
636
+ function getFreshSideObject() {
637
+ return {
638
+ top: 0,
639
+ right: 0,
640
+ bottom: 0,
641
+ left: 0
666
642
  };
667
643
  }
668
644
 
669
- function getBasePlacement(placement) {
670
- return placement.split('-')[0];
645
+ function mergePaddingObject(paddingObject) {
646
+ return Object.assign({}, getFreshSideObject(), paddingObject);
671
647
  }
672
648
 
673
- function mergeByName(modifiers) {
674
- var merged = modifiers.reduce(function (merged, current) {
675
- var existing = merged[current.name];
676
- merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
677
- options: Object.assign(Object.assign({}, existing.options), current.options),
678
- data: Object.assign(Object.assign({}, existing.data), current.data)
679
- }) : current;
680
- return merged;
681
- }, {}); // IE11 does not support Object.values
682
-
683
- return Object.keys(merged).map(function (key) {
684
- return merged[key];
685
- });
649
+ function expandToHashMap(value, keys) {
650
+ return keys.reduce(function (hashMap, key) {
651
+ hashMap[key] = value;
652
+ return hashMap;
653
+ }, {});
686
654
  }
687
655
 
688
- function getViewportRect(element) {
689
- var win = getWindow(element);
690
- var html = getDocumentElement(element);
691
- var visualViewport = win.visualViewport;
692
- var width = html.clientWidth;
693
- var height = html.clientHeight;
694
- var x = 0;
695
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
696
- // can be obscured underneath it.
697
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
698
- // if it isn't open, so if this isn't available, the popper will be detected
699
- // to overflow the bottom of the screen too early.
700
-
701
- if (visualViewport) {
702
- width = visualViewport.width;
703
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
704
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
705
- // errors due to floating point numbers, so we need to check precision.
706
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
707
- // Feature detection fails in mobile emulation mode in Chrome.
708
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
709
- // 0.001
710
- // Fallback here: "Not Safari" userAgent
656
+ var toPaddingObject = function toPaddingObject(padding, state) {
657
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
658
+ placement: state.placement
659
+ })) : padding;
660
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
661
+ };
711
662
 
712
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
713
- x = visualViewport.offsetLeft;
714
- y = visualViewport.offsetTop;
715
- }
716
- }
663
+ function arrow(_ref) {
664
+ var _state$modifiersData$;
717
665
 
718
- return {
719
- width: width,
720
- height: height,
721
- x: x + getWindowScrollBarX(element),
722
- y: y
723
- };
724
- }
666
+ var state = _ref.state,
667
+ name = _ref.name,
668
+ options = _ref.options;
669
+ var arrowElement = state.elements.arrow;
670
+ var popperOffsets = state.modifiersData.popperOffsets;
671
+ var basePlacement = getBasePlacement(state.placement);
672
+ var axis = getMainAxisFromPlacement(basePlacement);
673
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
674
+ var len = isVertical ? 'height' : 'width';
725
675
 
726
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
676
+ if (!arrowElement || !popperOffsets) {
677
+ return;
678
+ }
727
679
 
728
- function getDocumentRect(element) {
729
- var html = getDocumentElement(element);
730
- var winScroll = getWindowScroll(element);
731
- var body = element.ownerDocument.body;
732
- var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
733
- var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
734
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
735
- var y = -winScroll.scrollTop;
680
+ var paddingObject = toPaddingObject(options.padding, state);
681
+ var arrowRect = getLayoutRect(arrowElement);
682
+ var minProp = axis === 'y' ? top : left;
683
+ var maxProp = axis === 'y' ? bottom : right;
684
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
685
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
686
+ var arrowOffsetParent = getOffsetParent(arrowElement);
687
+ var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
688
+ var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
689
+ // outside of the popper bounds
736
690
 
737
- if (getComputedStyle(body || html).direction === 'rtl') {
738
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
739
- }
691
+ var min = paddingObject[minProp];
692
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
693
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
694
+ var offset = within(min, center, max); // Prevents breaking syntax highlighting...
740
695
 
741
- return {
742
- width: width,
743
- height: height,
744
- x: x,
745
- y: y
746
- };
696
+ var axisProp = axis;
697
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
747
698
  }
748
699
 
749
- function contains(parent, child) {
750
- // $FlowFixMe: hasOwnProperty doesn't seem to work in tests
751
- var isShadow = Boolean(child.getRootNode && child.getRootNode().host); // First, attempt with faster native method
700
+ function effect$1(_ref2) {
701
+ var state = _ref2.state,
702
+ options = _ref2.options;
703
+ var _options$element = options.element,
704
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
752
705
 
753
- if (parent.contains(child)) {
754
- return true;
755
- } // then fallback to custom implementation with Shadow DOM support
756
- else if (isShadow) {
757
- var next = child;
706
+ if (arrowElement == null) {
707
+ return;
708
+ } // CSS selector
758
709
 
759
- do {
760
- if (next && parent.isSameNode(next)) {
761
- return true;
762
- } // $FlowFixMe: need a better way to handle this...
763
710
 
711
+ if (typeof arrowElement === 'string') {
712
+ arrowElement = state.elements.popper.querySelector(arrowElement);
764
713
 
765
- next = next.parentNode || next.host;
766
- } while (next);
767
- } // Give up, the result is false
714
+ if (!arrowElement) {
715
+ return;
716
+ }
717
+ }
768
718
 
719
+ if (!contains(state.elements.popper, arrowElement)) {
720
+ return;
721
+ }
769
722
 
770
- return false;
771
- }
723
+ state.elements.arrow = arrowElement;
724
+ } // eslint-disable-next-line import/no-unused-modules
772
725
 
773
- function rectToClientRect(rect) {
774
- return Object.assign(Object.assign({}, rect), {}, {
775
- left: rect.x,
776
- top: rect.y,
777
- right: rect.x + rect.width,
778
- bottom: rect.y + rect.height
779
- });
780
- }
781
-
782
- function getInnerBoundingClientRect(element) {
783
- var rect = getBoundingClientRect(element);
784
- rect.top = rect.top + element.clientTop;
785
- rect.left = rect.left + element.clientLeft;
786
- rect.bottom = rect.top + element.clientHeight;
787
- rect.right = rect.left + element.clientWidth;
788
- rect.width = element.clientWidth;
789
- rect.height = element.clientHeight;
790
- rect.x = rect.left;
791
- rect.y = rect.top;
792
- return rect;
793
- }
794
-
795
- function getClientRectFromMixedType(element, clippingParent) {
796
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement$1(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
797
- } // A "clipping parent" is an overflowable container with the characteristic of
798
- // clipping (or hiding) overflowing elements with a position different from
799
- // `initial`
800
726
 
727
+ var arrow$1 = {
728
+ name: 'arrow',
729
+ enabled: true,
730
+ phase: 'main',
731
+ fn: arrow,
732
+ effect: effect$1,
733
+ requires: ['popperOffsets'],
734
+ requiresIfExists: ['preventOverflow']
735
+ };
736
+ var unsetSides = {
737
+ top: 'auto',
738
+ right: 'auto',
739
+ bottom: 'auto',
740
+ left: 'auto'
741
+ }; // Round the offsets to the nearest suitable subpixel based on the DPR.
742
+ // Zooming can change the DPR, but it seems to report a value that will
743
+ // cleanly divide the values into the appropriate subpixels.
801
744
 
802
- function getClippingParents(element) {
803
- var clippingParents = listScrollParents(getParentNode(element));
804
- var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
805
- var clipperElement = canEscapeClipping && isHTMLElement$1(element) ? getOffsetParent(element) : element;
745
+ function roundOffsetsByDPR(_ref) {
746
+ var x = _ref.x,
747
+ y = _ref.y;
748
+ var win = window;
749
+ var dpr = win.devicePixelRatio || 1;
750
+ return {
751
+ x: round(round(x * dpr) / dpr) || 0,
752
+ y: round(round(y * dpr) / dpr) || 0
753
+ };
754
+ }
806
755
 
807
- if (!isElement$1(clipperElement)) {
808
- return [];
809
- } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
756
+ function mapToStyles(_ref2) {
757
+ var _Object$assign2;
810
758
 
759
+ var popper = _ref2.popper,
760
+ popperRect = _ref2.popperRect,
761
+ placement = _ref2.placement,
762
+ offsets = _ref2.offsets,
763
+ position = _ref2.position,
764
+ gpuAcceleration = _ref2.gpuAcceleration,
765
+ adaptive = _ref2.adaptive,
766
+ roundOffsets = _ref2.roundOffsets;
811
767
 
812
- return clippingParents.filter(function (clippingParent) {
813
- return isElement$1(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
814
- });
815
- } // Gets the maximum area that the element is visible in due to any number of
816
- // clipping parents
768
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
769
+ _ref3$x = _ref3.x,
770
+ x = _ref3$x === void 0 ? 0 : _ref3$x,
771
+ _ref3$y = _ref3.y,
772
+ y = _ref3$y === void 0 ? 0 : _ref3$y;
817
773
 
774
+ var hasX = offsets.hasOwnProperty('x');
775
+ var hasY = offsets.hasOwnProperty('y');
776
+ var sideX = left;
777
+ var sideY = top;
778
+ var win = window;
818
779
 
819
- function getClippingRect(element, boundary, rootBoundary) {
820
- var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
821
- var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
822
- var firstClippingParent = clippingParents[0];
823
- var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
824
- var rect = getClientRectFromMixedType(element, clippingParent);
825
- accRect.top = Math.max(rect.top, accRect.top);
826
- accRect.right = Math.min(rect.right, accRect.right);
827
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
828
- accRect.left = Math.max(rect.left, accRect.left);
829
- return accRect;
830
- }, getClientRectFromMixedType(element, firstClippingParent));
831
- clippingRect.width = clippingRect.right - clippingRect.left;
832
- clippingRect.height = clippingRect.bottom - clippingRect.top;
833
- clippingRect.x = clippingRect.left;
834
- clippingRect.y = clippingRect.top;
835
- return clippingRect;
836
- }
780
+ if (adaptive) {
781
+ var offsetParent = getOffsetParent(popper);
782
+ var heightProp = 'clientHeight';
783
+ var widthProp = 'clientWidth';
837
784
 
838
- function getVariation(placement) {
839
- return placement.split('-')[1];
840
- }
785
+ if (offsetParent === getWindow(popper)) {
786
+ offsetParent = getDocumentElement(popper);
841
787
 
842
- function getMainAxisFromPlacement(placement) {
843
- return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
844
- }
788
+ if (getComputedStyle(offsetParent).position !== 'static') {
789
+ heightProp = 'scrollHeight';
790
+ widthProp = 'scrollWidth';
791
+ }
792
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
845
793
 
846
- function computeOffsets(_ref) {
847
- var reference = _ref.reference,
848
- element = _ref.element,
849
- placement = _ref.placement;
850
- var basePlacement = placement ? getBasePlacement(placement) : null;
851
- var variation = placement ? getVariation(placement) : null;
852
- var commonX = reference.x + reference.width / 2 - element.width / 2;
853
- var commonY = reference.y + reference.height / 2 - element.height / 2;
854
- var offsets;
855
794
 
856
- switch (basePlacement) {
857
- case top:
858
- offsets = {
859
- x: commonX,
860
- y: reference.y - element.height
861
- };
862
- break;
795
+ offsetParent = offsetParent;
863
796
 
864
- case bottom:
865
- offsets = {
866
- x: commonX,
867
- y: reference.y + reference.height
868
- };
869
- break;
797
+ if (placement === top) {
798
+ sideY = bottom; // $FlowFixMe[prop-missing]
870
799
 
871
- case right:
872
- offsets = {
873
- x: reference.x + reference.width,
874
- y: commonY
875
- };
876
- break;
800
+ y -= offsetParent[heightProp] - popperRect.height;
801
+ y *= gpuAcceleration ? 1 : -1;
802
+ }
877
803
 
878
- case left:
879
- offsets = {
880
- x: reference.x - element.width,
881
- y: commonY
882
- };
883
- break;
804
+ if (placement === left) {
805
+ sideX = right; // $FlowFixMe[prop-missing]
884
806
 
885
- default:
886
- offsets = {
887
- x: reference.x,
888
- y: reference.y
889
- };
807
+ x -= offsetParent[widthProp] - popperRect.width;
808
+ x *= gpuAcceleration ? 1 : -1;
809
+ }
890
810
  }
891
811
 
892
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
893
-
894
- if (mainAxis != null) {
895
- var len = mainAxis === 'y' ? 'height' : 'width';
812
+ var commonStyles = Object.assign({
813
+ position: position
814
+ }, adaptive && unsetSides);
896
815
 
897
- switch (variation) {
898
- case start:
899
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
900
- break;
816
+ if (gpuAcceleration) {
817
+ var _Object$assign;
901
818
 
902
- case end:
903
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
904
- break;
905
- }
819
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
906
820
  }
907
821
 
908
- return offsets;
822
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
909
823
  }
910
824
 
911
- function getFreshSideObject() {
912
- return {
913
- top: 0,
914
- right: 0,
915
- bottom: 0,
916
- left: 0
825
+ function computeStyles(_ref4) {
826
+ var state = _ref4.state,
827
+ options = _ref4.options;
828
+ var _options$gpuAccelerat = options.gpuAcceleration,
829
+ gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
830
+ _options$adaptive = options.adaptive,
831
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
832
+ _options$roundOffsets = options.roundOffsets,
833
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
834
+ var commonStyles = {
835
+ placement: getBasePlacement(state.placement),
836
+ popper: state.elements.popper,
837
+ popperRect: state.rects.popper,
838
+ gpuAcceleration: gpuAcceleration
917
839
  };
918
- }
919
840
 
920
- function mergePaddingObject(paddingObject) {
921
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
922
- }
923
-
924
- function expandToHashMap(value, keys) {
925
- return keys.reduce(function (hashMap, key) {
926
- hashMap[key] = value;
927
- return hashMap;
928
- }, {});
929
- }
841
+ if (state.modifiersData.popperOffsets != null) {
842
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
843
+ offsets: state.modifiersData.popperOffsets,
844
+ position: state.options.strategy,
845
+ adaptive: adaptive,
846
+ roundOffsets: roundOffsets
847
+ })));
848
+ }
930
849
 
931
- function detectOverflow(state, options) {
932
- if (options === void 0) {
933
- options = {};
850
+ if (state.modifiersData.arrow != null) {
851
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
852
+ offsets: state.modifiersData.arrow,
853
+ position: 'absolute',
854
+ adaptive: false,
855
+ roundOffsets: roundOffsets
856
+ })));
934
857
  }
935
858
 
936
- var _options = options,
937
- _options$placement = _options.placement,
938
- placement = _options$placement === void 0 ? state.placement : _options$placement,
939
- _options$boundary = _options.boundary,
940
- boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
941
- _options$rootBoundary = _options.rootBoundary,
942
- rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
943
- _options$elementConte = _options.elementContext,
944
- elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
945
- _options$altBoundary = _options.altBoundary,
946
- altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
947
- _options$padding = _options.padding,
948
- padding = _options$padding === void 0 ? 0 : _options$padding;
949
- var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
950
- var altContext = elementContext === popper ? reference : popper;
951
- var referenceElement = state.elements.reference;
952
- var popperRect = state.rects.popper;
953
- var element = state.elements[altBoundary ? altContext : elementContext];
954
- var clippingClientRect = getClippingRect(isElement$1(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
955
- var referenceClientRect = getBoundingClientRect(referenceElement);
956
- var popperOffsets = computeOffsets({
957
- reference: referenceClientRect,
958
- element: popperRect,
959
- strategy: 'absolute',
960
- placement: placement
859
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
860
+ 'data-popper-placement': state.placement
961
861
  });
962
- var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
963
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
964
- // 0 or negative = within the clipping rect
862
+ } // eslint-disable-next-line import/no-unused-modules
965
863
 
966
- var overflowOffsets = {
967
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
968
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
969
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
970
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
971
- };
972
- var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
973
864
 
974
- if (elementContext === popper && offsetData) {
975
- var offset = offsetData[placement];
976
- Object.keys(overflowOffsets).forEach(function (key) {
977
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
978
- var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
979
- overflowOffsets[key] += offset[axis] * multiply;
865
+ var computeStyles$1 = {
866
+ name: 'computeStyles',
867
+ enabled: true,
868
+ phase: 'beforeWrite',
869
+ fn: computeStyles,
870
+ data: {}
871
+ };
872
+ var passive = {
873
+ passive: true
874
+ };
875
+
876
+ function effect(_ref) {
877
+ var state = _ref.state,
878
+ instance = _ref.instance,
879
+ options = _ref.options;
880
+ var _options$scroll = options.scroll,
881
+ scroll = _options$scroll === void 0 ? true : _options$scroll,
882
+ _options$resize = options.resize,
883
+ resize = _options$resize === void 0 ? true : _options$resize;
884
+ var window = getWindow(state.elements.popper);
885
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
886
+
887
+ if (scroll) {
888
+ scrollParents.forEach(function (scrollParent) {
889
+ scrollParent.addEventListener('scroll', instance.update, passive);
980
890
  });
981
891
  }
982
892
 
983
- return overflowOffsets;
984
- }
985
-
986
- var DEFAULT_OPTIONS = {
987
- placement: 'bottom',
988
- modifiers: [],
989
- strategy: 'absolute'
990
- };
991
-
992
- function areValidElements() {
993
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
994
- args[_key] = arguments[_key];
995
- }
996
-
997
- return !args.some(function (element) {
998
- return !(element && typeof element.getBoundingClientRect === 'function');
999
- });
1000
- }
1001
-
1002
- function popperGenerator(generatorOptions) {
1003
- if (generatorOptions === void 0) {
1004
- generatorOptions = {};
1005
- }
1006
-
1007
- var _generatorOptions = generatorOptions,
1008
- _generatorOptions$def = _generatorOptions.defaultModifiers,
1009
- defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1010
- _generatorOptions$def2 = _generatorOptions.defaultOptions,
1011
- defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1012
- return function createPopper(reference, popper, options) {
1013
- if (options === void 0) {
1014
- options = defaultOptions;
1015
- }
1016
-
1017
- var state = {
1018
- placement: 'bottom',
1019
- orderedModifiers: [],
1020
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
1021
- modifiersData: {},
1022
- elements: {
1023
- reference: reference,
1024
- popper: popper
1025
- },
1026
- attributes: {},
1027
- styles: {}
1028
- };
1029
- var effectCleanupFns = [];
1030
- var isDestroyed = false;
1031
- var instance = {
1032
- state: state,
1033
- setOptions: function setOptions(options) {
1034
- cleanupModifierEffects();
1035
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
1036
- state.scrollParents = {
1037
- reference: isElement$1(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1038
- popper: listScrollParents(popper)
1039
- }; // Orders the modifiers based on their dependencies and `phase`
1040
- // properties
1041
-
1042
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1043
-
1044
- state.orderedModifiers = orderedModifiers.filter(function (m) {
1045
- return m.enabled;
1046
- }); // Validate the provided modifiers so that the consumer will get warned
1047
-
1048
- runModifierEffects();
1049
- return instance.update();
1050
- },
1051
- // Sync update – it will always be executed, even if not necessary. This
1052
- // is useful for low frequency updates where sync behavior simplifies the
1053
- // logic.
1054
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1055
- // prefer the async Popper#update method
1056
- forceUpdate: function forceUpdate() {
1057
- if (isDestroyed) {
1058
- return;
1059
- }
1060
-
1061
- var _state$elements = state.elements,
1062
- reference = _state$elements.reference,
1063
- popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1064
- // anymore
1065
-
1066
- if (!areValidElements(reference, popper)) {
1067
-
1068
- return;
1069
- } // Store the reference and popper rects to be read by modifiers
1070
-
1071
-
1072
- state.rects = {
1073
- reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1074
- popper: getLayoutRect(popper)
1075
- }; // Modifiers have the ability to reset the current update cycle. The
1076
- // most common use case for this is the `flip` modifier changing the
1077
- // placement, which then needs to re-run all the modifiers, because the
1078
- // logic was previously ran for the previous placement and is therefore
1079
- // stale/incorrect
1080
-
1081
- state.reset = false;
1082
- state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1083
- // is filled with the initial data specified by the modifier. This means
1084
- // it doesn't persist and is fresh on each update.
1085
- // To ensure persistent data, use `${name}#persistent`
1086
-
1087
- state.orderedModifiers.forEach(function (modifier) {
1088
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1089
- });
1090
-
1091
- for (var index = 0; index < state.orderedModifiers.length; index++) {
1092
-
1093
- if (state.reset === true) {
1094
- state.reset = false;
1095
- index = -1;
1096
- continue;
1097
- }
1098
-
1099
- var _state$orderedModifie = state.orderedModifiers[index],
1100
- fn = _state$orderedModifie.fn,
1101
- _state$orderedModifie2 = _state$orderedModifie.options,
1102
- _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1103
- name = _state$orderedModifie.name;
1104
-
1105
- if (typeof fn === 'function') {
1106
- state = fn({
1107
- state: state,
1108
- options: _options,
1109
- name: name,
1110
- instance: instance
1111
- }) || state;
1112
- }
1113
- }
1114
- },
1115
- // Async and optimistically optimized update – it will not be executed if
1116
- // not necessary (debounced to run at most once-per-tick)
1117
- update: debounce(function () {
1118
- return new Promise(function (resolve) {
1119
- instance.forceUpdate();
1120
- resolve(state);
1121
- });
1122
- }),
1123
- destroy: function destroy() {
1124
- cleanupModifierEffects();
1125
- isDestroyed = true;
1126
- }
1127
- };
1128
-
1129
- if (!areValidElements(reference, popper)) {
1130
-
1131
- return instance;
1132
- }
1133
-
1134
- instance.setOptions(options).then(function (state) {
1135
- if (!isDestroyed && options.onFirstUpdate) {
1136
- options.onFirstUpdate(state);
1137
- }
1138
- }); // Modifiers have the ability to execute arbitrary code before the first
1139
- // update cycle runs. They will be executed in the same order as the update
1140
- // cycle. This is useful when a modifier adds some persistent data that
1141
- // other modifiers need to use, but the modifier is run after the dependent
1142
- // one.
1143
-
1144
- function runModifierEffects() {
1145
- state.orderedModifiers.forEach(function (_ref3) {
1146
- var name = _ref3.name,
1147
- _ref3$options = _ref3.options,
1148
- options = _ref3$options === void 0 ? {} : _ref3$options,
1149
- effect = _ref3.effect;
1150
-
1151
- if (typeof effect === 'function') {
1152
- var cleanupFn = effect({
1153
- state: state,
1154
- name: name,
1155
- instance: instance,
1156
- options: options
1157
- });
1158
-
1159
- var noopFn = function noopFn() {};
1160
-
1161
- effectCleanupFns.push(cleanupFn || noopFn);
1162
- }
1163
- });
1164
- }
1165
-
1166
- function cleanupModifierEffects() {
1167
- effectCleanupFns.forEach(function (fn) {
1168
- return fn();
1169
- });
1170
- effectCleanupFns = [];
1171
- }
1172
-
1173
- return instance;
1174
- };
1175
- }
1176
-
1177
- var passive = {
1178
- passive: true
1179
- };
1180
-
1181
- function effect(_ref) {
1182
- var state = _ref.state,
1183
- instance = _ref.instance,
1184
- options = _ref.options;
1185
- var _options$scroll = options.scroll,
1186
- scroll = _options$scroll === void 0 ? true : _options$scroll,
1187
- _options$resize = options.resize,
1188
- resize = _options$resize === void 0 ? true : _options$resize;
1189
- var window = getWindow(state.elements.popper);
1190
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1191
-
1192
- if (scroll) {
1193
- scrollParents.forEach(function (scrollParent) {
1194
- scrollParent.addEventListener('scroll', instance.update, passive);
1195
- });
1196
- }
1197
-
1198
- if (resize) {
1199
- window.addEventListener('resize', instance.update, passive);
1200
- }
893
+ if (resize) {
894
+ window.addEventListener('resize', instance.update, passive);
895
+ }
1201
896
 
1202
897
  return function () {
1203
898
  if (scroll) {
@@ -1221,315 +916,347 @@ var eventListeners = {
1221
916
  effect: effect,
1222
917
  data: {}
1223
918
  };
919
+ var hash$1 = {
920
+ left: 'right',
921
+ right: 'left',
922
+ bottom: 'top',
923
+ top: 'bottom'
924
+ };
1224
925
 
1225
- function popperOffsets(_ref) {
1226
- var state = _ref.state,
1227
- name = _ref.name; // Offsets are the actual position the popper needs to have to be
1228
- // properly positioned near its reference element
1229
- // This is the most basic placement, and will be adjusted by
1230
- // the modifiers in the next step
1231
-
1232
- state.modifiersData[name] = computeOffsets({
1233
- reference: state.rects.reference,
1234
- element: state.rects.popper,
1235
- strategy: 'absolute',
1236
- placement: state.placement
926
+ function getOppositePlacement(placement) {
927
+ return placement.replace(/left|right|bottom|top/g, function (matched) {
928
+ return hash$1[matched];
1237
929
  });
1238
- } // eslint-disable-next-line import/no-unused-modules
1239
-
930
+ }
1240
931
 
1241
- var popperOffsets$1 = {
1242
- name: 'popperOffsets',
1243
- enabled: true,
1244
- phase: 'read',
1245
- fn: popperOffsets,
1246
- data: {}
932
+ var hash = {
933
+ start: 'end',
934
+ end: 'start'
1247
935
  };
1248
936
 
1249
- var unsetSides = {
1250
- top: 'auto',
1251
- right: 'auto',
1252
- bottom: 'auto',
1253
- left: 'auto'
1254
- }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1255
- // Zooming can change the DPR, but it seems to report a value that will
1256
- // cleanly divide the values into the appropriate subpixels.
937
+ function getOppositeVariationPlacement(placement) {
938
+ return placement.replace(/start|end/g, function (matched) {
939
+ return hash[matched];
940
+ });
941
+ }
1257
942
 
1258
- function roundOffsets(_ref) {
1259
- var x = _ref.x,
1260
- y = _ref.y;
1261
- var win = window;
1262
- var dpr = win.devicePixelRatio || 1;
943
+ function getWindowScroll(node) {
944
+ var win = getWindow(node);
945
+ var scrollLeft = win.pageXOffset;
946
+ var scrollTop = win.pageYOffset;
1263
947
  return {
1264
- x: Math.round(x * dpr) / dpr || 0,
1265
- y: Math.round(y * dpr) / dpr || 0
948
+ scrollLeft: scrollLeft,
949
+ scrollTop: scrollTop
1266
950
  };
1267
951
  }
1268
952
 
1269
- function mapToStyles(_ref2) {
1270
- var _Object$assign2;
1271
-
1272
- var popper = _ref2.popper,
1273
- popperRect = _ref2.popperRect,
1274
- placement = _ref2.placement,
1275
- offsets = _ref2.offsets,
1276
- position = _ref2.position,
1277
- gpuAcceleration = _ref2.gpuAcceleration,
1278
- adaptive = _ref2.adaptive;
953
+ function getWindowScrollBarX(element) {
954
+ // If <html> has a CSS width greater than the viewport, then this will be
955
+ // incorrect for RTL.
956
+ // Popper 1 is broken in this case and never had a bug report so let's assume
957
+ // it's not an issue. I don't think anyone ever specifies width on <html>
958
+ // anyway.
959
+ // Browsers where the left scrollbar doesn't cause an issue report `0` for
960
+ // this (e.g. Edge 2019, IE11, Safari)
961
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
962
+ }
1279
963
 
1280
- var _roundOffsets = roundOffsets(offsets),
1281
- x = _roundOffsets.x,
1282
- y = _roundOffsets.y;
964
+ function getViewportRect(element) {
965
+ var win = getWindow(element);
966
+ var html = getDocumentElement(element);
967
+ var visualViewport = win.visualViewport;
968
+ var width = html.clientWidth;
969
+ var height = html.clientHeight;
970
+ var x = 0;
971
+ var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
972
+ // can be obscured underneath it.
973
+ // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
974
+ // if it isn't open, so if this isn't available, the popper will be detected
975
+ // to overflow the bottom of the screen too early.
1283
976
 
1284
- var hasX = offsets.hasOwnProperty('x');
1285
- var hasY = offsets.hasOwnProperty('y');
1286
- var sideX = left;
1287
- var sideY = top;
1288
- var win = window;
977
+ if (visualViewport) {
978
+ width = visualViewport.width;
979
+ height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
980
+ // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
981
+ // errors due to floating point numbers, so we need to check precision.
982
+ // Safari returns a number <= 0, usually < -1 when pinch-zoomed
983
+ // Feature detection fails in mobile emulation mode in Chrome.
984
+ // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
985
+ // 0.001
986
+ // Fallback here: "Not Safari" userAgent
1289
987
 
1290
- if (adaptive) {
1291
- var offsetParent = getOffsetParent(popper);
988
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
989
+ x = visualViewport.offsetLeft;
990
+ y = visualViewport.offsetTop;
991
+ }
992
+ }
1292
993
 
1293
- if (offsetParent === getWindow(popper)) {
1294
- offsetParent = getDocumentElement(popper);
1295
- } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
994
+ return {
995
+ width: width,
996
+ height: height,
997
+ x: x + getWindowScrollBarX(element),
998
+ y: y
999
+ };
1000
+ } // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1296
1001
 
1297
- /*:: offsetParent = (offsetParent: Element); */
1298
1002
 
1003
+ function getDocumentRect(element) {
1004
+ var _element$ownerDocumen;
1299
1005
 
1300
- if (placement === top) {
1301
- sideY = bottom;
1302
- y -= offsetParent.clientHeight - popperRect.height;
1303
- y *= gpuAcceleration ? 1 : -1;
1304
- }
1006
+ var html = getDocumentElement(element);
1007
+ var winScroll = getWindowScroll(element);
1008
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1009
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1010
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1011
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1012
+ var y = -winScroll.scrollTop;
1305
1013
 
1306
- if (placement === left) {
1307
- sideX = right;
1308
- x -= offsetParent.clientWidth - popperRect.width;
1309
- x *= gpuAcceleration ? 1 : -1;
1310
- }
1014
+ if (getComputedStyle(body || html).direction === 'rtl') {
1015
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1311
1016
  }
1312
1017
 
1313
- var commonStyles = Object.assign({
1314
- position: position
1315
- }, adaptive && unsetSides);
1316
-
1317
- if (gpuAcceleration) {
1318
- var _Object$assign;
1018
+ return {
1019
+ width: width,
1020
+ height: height,
1021
+ x: x,
1022
+ y: y
1023
+ };
1024
+ }
1319
1025
 
1320
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1321
- }
1026
+ function isScrollParent(element) {
1027
+ // Firefox wants us to check `-x` and `-y` variations as well
1028
+ var _getComputedStyle = getComputedStyle(element),
1029
+ overflow = _getComputedStyle.overflow,
1030
+ overflowX = _getComputedStyle.overflowX,
1031
+ overflowY = _getComputedStyle.overflowY;
1322
1032
 
1323
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1033
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1324
1034
  }
1325
1035
 
1326
- function computeStyles(_ref3) {
1327
- var state = _ref3.state,
1328
- options = _ref3.options;
1329
- var _options$gpuAccelerat = options.gpuAcceleration,
1330
- gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1331
- _options$adaptive = options.adaptive,
1332
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
1333
-
1334
- var commonStyles = {
1335
- placement: getBasePlacement(state.placement),
1336
- popper: state.elements.popper,
1337
- popperRect: state.rects.popper,
1338
- gpuAcceleration: gpuAcceleration
1339
- };
1036
+ function getScrollParent(node) {
1037
+ if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
1038
+ // $FlowFixMe[incompatible-return]: assume body is always available
1039
+ return node.ownerDocument.body;
1040
+ }
1340
1041
 
1341
- if (state.modifiersData.popperOffsets != null) {
1342
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
1343
- offsets: state.modifiersData.popperOffsets,
1344
- position: state.options.strategy,
1345
- adaptive: adaptive
1346
- })));
1042
+ if (isHTMLElement(node) && isScrollParent(node)) {
1043
+ return node;
1347
1044
  }
1348
1045
 
1349
- if (state.modifiersData.arrow != null) {
1350
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
1351
- offsets: state.modifiersData.arrow,
1352
- position: 'absolute',
1353
- adaptive: false
1354
- })));
1046
+ return getScrollParent(getParentNode(node));
1047
+ }
1048
+ /*
1049
+ given a DOM element, return the list of all scroll parents, up the list of ancesors
1050
+ until we get to the top window object. This list is what we attach scroll listeners
1051
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
1052
+ reference element's position.
1053
+ */
1054
+
1055
+
1056
+ function listScrollParents(element, list) {
1057
+ var _element$ownerDocumen;
1058
+
1059
+ if (list === void 0) {
1060
+ list = [];
1355
1061
  }
1356
1062
 
1357
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1358
- 'data-popper-placement': state.placement
1359
- });
1360
- } // eslint-disable-next-line import/no-unused-modules
1063
+ var scrollParent = getScrollParent(element);
1064
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1065
+ var win = getWindow(scrollParent);
1066
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1067
+ var updatedList = list.concat(target);
1068
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1069
+ updatedList.concat(listScrollParents(getParentNode(target)));
1070
+ }
1361
1071
 
1072
+ function rectToClientRect(rect) {
1073
+ return Object.assign({}, rect, {
1074
+ left: rect.x,
1075
+ top: rect.y,
1076
+ right: rect.x + rect.width,
1077
+ bottom: rect.y + rect.height
1078
+ });
1079
+ }
1362
1080
 
1363
- var computeStyles$1 = {
1364
- name: 'computeStyles',
1365
- enabled: true,
1366
- phase: 'beforeWrite',
1367
- fn: computeStyles,
1368
- data: {}
1369
- };
1081
+ function getInnerBoundingClientRect(element) {
1082
+ var rect = getBoundingClientRect(element);
1083
+ rect.top = rect.top + element.clientTop;
1084
+ rect.left = rect.left + element.clientLeft;
1085
+ rect.bottom = rect.top + element.clientHeight;
1086
+ rect.right = rect.left + element.clientWidth;
1087
+ rect.width = element.clientWidth;
1088
+ rect.height = element.clientHeight;
1089
+ rect.x = rect.left;
1090
+ rect.y = rect.top;
1091
+ return rect;
1092
+ }
1370
1093
 
1371
- // and applies them to the HTMLElements such as popper and arrow
1094
+ function getClientRectFromMixedType(element, clippingParent) {
1095
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1096
+ } // A "clipping parent" is an overflowable container with the characteristic of
1097
+ // clipping (or hiding) overflowing elements with a position different from
1098
+ // `initial`
1372
1099
 
1373
- function applyStyles(_ref) {
1374
- var state = _ref.state;
1375
- Object.keys(state.elements).forEach(function (name) {
1376
- var style = state.styles[name] || {};
1377
- var attributes = state.attributes[name] || {};
1378
- var element = state.elements[name]; // arrow is optional + virtual elements
1379
1100
 
1380
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
1381
- return;
1382
- } // Flow doesn't support to extend this property, but it's the most
1383
- // effective way to apply styles to an HTMLElement
1384
- // $FlowFixMe
1101
+ function getClippingParents(element) {
1102
+ var clippingParents = listScrollParents(getParentNode(element));
1103
+ var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
1104
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1385
1105
 
1106
+ if (!isElement(clipperElement)) {
1107
+ return [];
1108
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
1386
1109
 
1387
- Object.assign(element.style, style);
1388
- Object.keys(attributes).forEach(function (name) {
1389
- var value = attributes[name];
1390
1110
 
1391
- if (value === false) {
1392
- element.removeAttribute(name);
1393
- } else {
1394
- element.setAttribute(name, value === true ? '' : value);
1395
- }
1396
- });
1111
+ return clippingParents.filter(function (clippingParent) {
1112
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
1397
1113
  });
1398
- }
1399
-
1400
- function effect$1(_ref2) {
1401
- var state = _ref2.state;
1402
- var initialStyles = {
1403
- popper: {
1404
- position: state.options.strategy,
1405
- left: '0',
1406
- top: '0',
1407
- margin: '0'
1408
- },
1409
- arrow: {
1410
- position: 'absolute'
1411
- },
1412
- reference: {}
1413
- };
1414
- Object.assign(state.elements.popper.style, initialStyles.popper);
1114
+ } // Gets the maximum area that the element is visible in due to any number of
1115
+ // clipping parents
1415
1116
 
1416
- if (state.elements.arrow) {
1417
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
1418
- }
1419
1117
 
1420
- return function () {
1421
- Object.keys(state.elements).forEach(function (name) {
1422
- var element = state.elements[name];
1423
- var attributes = state.attributes[name] || {};
1424
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
1118
+ function getClippingRect(element, boundary, rootBoundary) {
1119
+ var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
1120
+ var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
1121
+ var firstClippingParent = clippingParents[0];
1122
+ var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
1123
+ var rect = getClientRectFromMixedType(element, clippingParent);
1124
+ accRect.top = max(rect.top, accRect.top);
1125
+ accRect.right = min(rect.right, accRect.right);
1126
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1127
+ accRect.left = max(rect.left, accRect.left);
1128
+ return accRect;
1129
+ }, getClientRectFromMixedType(element, firstClippingParent));
1130
+ clippingRect.width = clippingRect.right - clippingRect.left;
1131
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1132
+ clippingRect.x = clippingRect.left;
1133
+ clippingRect.y = clippingRect.top;
1134
+ return clippingRect;
1135
+ }
1425
1136
 
1426
- var style = styleProperties.reduce(function (style, property) {
1427
- style[property] = '';
1428
- return style;
1429
- }, {}); // arrow is optional + virtual elements
1137
+ function getVariation(placement) {
1138
+ return placement.split('-')[1];
1139
+ }
1430
1140
 
1431
- if (!isHTMLElement$1(element) || !getNodeName(element)) {
1432
- return;
1433
- } // Flow doesn't support to extend this property, but it's the most
1434
- // effective way to apply styles to an HTMLElement
1435
- // $FlowFixMe
1141
+ function computeOffsets(_ref) {
1142
+ var reference = _ref.reference,
1143
+ element = _ref.element,
1144
+ placement = _ref.placement;
1145
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1146
+ var variation = placement ? getVariation(placement) : null;
1147
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1148
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1149
+ var offsets;
1436
1150
 
1151
+ switch (basePlacement) {
1152
+ case top:
1153
+ offsets = {
1154
+ x: commonX,
1155
+ y: reference.y - element.height
1156
+ };
1157
+ break;
1437
1158
 
1438
- Object.assign(element.style, style);
1439
- Object.keys(attributes).forEach(function (attribute) {
1440
- element.removeAttribute(attribute);
1441
- });
1442
- });
1443
- };
1444
- } // eslint-disable-next-line import/no-unused-modules
1159
+ case bottom:
1160
+ offsets = {
1161
+ x: commonX,
1162
+ y: reference.y + reference.height
1163
+ };
1164
+ break;
1445
1165
 
1166
+ case right:
1167
+ offsets = {
1168
+ x: reference.x + reference.width,
1169
+ y: commonY
1170
+ };
1171
+ break;
1446
1172
 
1447
- var applyStyles$1 = {
1448
- name: 'applyStyles',
1449
- enabled: true,
1450
- phase: 'write',
1451
- fn: applyStyles,
1452
- effect: effect$1,
1453
- requires: ['computeStyles']
1454
- };
1173
+ case left:
1174
+ offsets = {
1175
+ x: reference.x - element.width,
1176
+ y: commonY
1177
+ };
1178
+ break;
1455
1179
 
1456
- function distanceAndSkiddingToXY(placement, rects, offset) {
1457
- var basePlacement = getBasePlacement(placement);
1458
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1180
+ default:
1181
+ offsets = {
1182
+ x: reference.x,
1183
+ y: reference.y
1184
+ };
1185
+ }
1459
1186
 
1460
- var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
1461
- placement: placement
1462
- })) : offset,
1463
- skidding = _ref[0],
1464
- distance = _ref[1];
1187
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1465
1188
 
1466
- skidding = skidding || 0;
1467
- distance = (distance || 0) * invertDistance;
1468
- return [left, right].indexOf(basePlacement) >= 0 ? {
1469
- x: distance,
1470
- y: skidding
1471
- } : {
1472
- x: skidding,
1473
- y: distance
1474
- };
1475
- }
1189
+ if (mainAxis != null) {
1190
+ var len = mainAxis === 'y' ? 'height' : 'width';
1476
1191
 
1477
- function offset(_ref2) {
1478
- var state = _ref2.state,
1479
- options = _ref2.options,
1480
- name = _ref2.name;
1481
- var _options$offset = options.offset,
1482
- offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1483
- var data = placements.reduce(function (acc, placement) {
1484
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1485
- return acc;
1486
- }, {});
1487
- var _data$state$placement = data[state.placement],
1488
- x = _data$state$placement.x,
1489
- y = _data$state$placement.y;
1192
+ switch (variation) {
1193
+ case start:
1194
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1195
+ break;
1490
1196
 
1491
- if (state.modifiersData.popperOffsets != null) {
1492
- state.modifiersData.popperOffsets.x += x;
1493
- state.modifiersData.popperOffsets.y += y;
1197
+ case end:
1198
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1199
+ break;
1200
+ }
1494
1201
  }
1495
1202
 
1496
- state.modifiersData[name] = data;
1497
- } // eslint-disable-next-line import/no-unused-modules
1498
-
1203
+ return offsets;
1204
+ }
1499
1205
 
1500
- var offset$1 = {
1501
- name: 'offset',
1502
- enabled: true,
1503
- phase: 'main',
1504
- requires: ['popperOffsets'],
1505
- fn: offset
1506
- };
1206
+ function detectOverflow(state, options) {
1207
+ if (options === void 0) {
1208
+ options = {};
1209
+ }
1507
1210
 
1508
- var hash = {
1509
- left: 'right',
1510
- right: 'left',
1511
- bottom: 'top',
1512
- top: 'bottom'
1513
- };
1514
- function getOppositePlacement(placement) {
1515
- return placement.replace(/left|right|bottom|top/g, function (matched) {
1516
- return hash[matched];
1211
+ var _options = options,
1212
+ _options$placement = _options.placement,
1213
+ placement = _options$placement === void 0 ? state.placement : _options$placement,
1214
+ _options$boundary = _options.boundary,
1215
+ boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
1216
+ _options$rootBoundary = _options.rootBoundary,
1217
+ rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
1218
+ _options$elementConte = _options.elementContext,
1219
+ elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
1220
+ _options$altBoundary = _options.altBoundary,
1221
+ altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
1222
+ _options$padding = _options.padding,
1223
+ padding = _options$padding === void 0 ? 0 : _options$padding;
1224
+ var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
1225
+ var altContext = elementContext === popper ? reference : popper;
1226
+ var referenceElement = state.elements.reference;
1227
+ var popperRect = state.rects.popper;
1228
+ var element = state.elements[altBoundary ? altContext : elementContext];
1229
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1230
+ var referenceClientRect = getBoundingClientRect(referenceElement);
1231
+ var popperOffsets = computeOffsets({
1232
+ reference: referenceClientRect,
1233
+ element: popperRect,
1234
+ strategy: 'absolute',
1235
+ placement: placement
1517
1236
  });
1518
- }
1237
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1238
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
1239
+ // 0 or negative = within the clipping rect
1519
1240
 
1520
- var hash$1 = {
1521
- start: 'end',
1522
- end: 'start'
1523
- };
1524
- function getOppositeVariationPlacement(placement) {
1525
- return placement.replace(/start|end/g, function (matched) {
1526
- return hash$1[matched];
1527
- });
1528
- }
1241
+ var overflowOffsets = {
1242
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1243
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1244
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1245
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1246
+ };
1247
+ var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
1529
1248
 
1530
- /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
1249
+ if (elementContext === popper && offsetData) {
1250
+ var offset = offsetData[placement];
1251
+ Object.keys(overflowOffsets).forEach(function (key) {
1252
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
1253
+ var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
1254
+ overflowOffsets[key] += offset[axis] * multiply;
1255
+ });
1256
+ }
1531
1257
 
1532
- /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
1258
+ return overflowOffsets;
1259
+ }
1533
1260
 
1534
1261
  function computeAutoPlacement(state, options) {
1535
1262
  if (options === void 0) {
@@ -1547,15 +1274,14 @@ function computeAutoPlacement(state, options) {
1547
1274
  var variation = getVariation(placement);
1548
1275
  var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
1549
1276
  return getVariation(placement) === variation;
1550
- }) : basePlacements; // $FlowFixMe
1551
-
1277
+ }) : basePlacements;
1552
1278
  var allowedPlacements = placements$1.filter(function (placement) {
1553
1279
  return allowedAutoPlacements.indexOf(placement) >= 0;
1554
1280
  });
1555
1281
 
1556
1282
  if (allowedPlacements.length === 0) {
1557
1283
  allowedPlacements = placements$1;
1558
- } // $FlowFixMe: Flow seems to have problems with two array unions...
1284
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
1559
1285
 
1560
1286
 
1561
1287
  var overflows = allowedPlacements.reduce(function (acc, placement) {
@@ -1712,12 +1438,143 @@ var flip$1 = {
1712
1438
  }
1713
1439
  };
1714
1440
 
1715
- function getAltAxis(axis) {
1716
- return axis === 'x' ? 'y' : 'x';
1441
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1442
+ if (preventedOffsets === void 0) {
1443
+ preventedOffsets = {
1444
+ x: 0,
1445
+ y: 0
1446
+ };
1447
+ }
1448
+
1449
+ return {
1450
+ top: overflow.top - rect.height - preventedOffsets.y,
1451
+ right: overflow.right - rect.width + preventedOffsets.x,
1452
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1453
+ left: overflow.left - rect.width - preventedOffsets.x
1454
+ };
1455
+ }
1456
+
1457
+ function isAnySideFullyClipped(overflow) {
1458
+ return [top, right, bottom, left].some(function (side) {
1459
+ return overflow[side] >= 0;
1460
+ });
1461
+ }
1462
+
1463
+ function hide(_ref) {
1464
+ var state = _ref.state,
1465
+ name = _ref.name;
1466
+ var referenceRect = state.rects.reference;
1467
+ var popperRect = state.rects.popper;
1468
+ var preventedOffsets = state.modifiersData.preventOverflow;
1469
+ var referenceOverflow = detectOverflow(state, {
1470
+ elementContext: 'reference'
1471
+ });
1472
+ var popperAltOverflow = detectOverflow(state, {
1473
+ altBoundary: true
1474
+ });
1475
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1476
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1477
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1478
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1479
+ state.modifiersData[name] = {
1480
+ referenceClippingOffsets: referenceClippingOffsets,
1481
+ popperEscapeOffsets: popperEscapeOffsets,
1482
+ isReferenceHidden: isReferenceHidden,
1483
+ hasPopperEscaped: hasPopperEscaped
1484
+ };
1485
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1486
+ 'data-popper-reference-hidden': isReferenceHidden,
1487
+ 'data-popper-escaped': hasPopperEscaped
1488
+ });
1489
+ } // eslint-disable-next-line import/no-unused-modules
1490
+
1491
+
1492
+ var hide$1 = {
1493
+ name: 'hide',
1494
+ enabled: true,
1495
+ phase: 'main',
1496
+ requiresIfExists: ['preventOverflow'],
1497
+ fn: hide
1498
+ };
1499
+
1500
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1501
+ var basePlacement = getBasePlacement(placement);
1502
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1503
+
1504
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1505
+ placement: placement
1506
+ })) : offset,
1507
+ skidding = _ref[0],
1508
+ distance = _ref[1];
1509
+
1510
+ skidding = skidding || 0;
1511
+ distance = (distance || 0) * invertDistance;
1512
+ return [left, right].indexOf(basePlacement) >= 0 ? {
1513
+ x: distance,
1514
+ y: skidding
1515
+ } : {
1516
+ x: skidding,
1517
+ y: distance
1518
+ };
1717
1519
  }
1718
1520
 
1719
- function within(min, value, max) {
1720
- return Math.max(min, Math.min(value, max));
1521
+ function offset(_ref2) {
1522
+ var state = _ref2.state,
1523
+ options = _ref2.options,
1524
+ name = _ref2.name;
1525
+ var _options$offset = options.offset,
1526
+ offset = _options$offset === void 0 ? [0, 0] : _options$offset;
1527
+ var data = placements.reduce(function (acc, placement) {
1528
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1529
+ return acc;
1530
+ }, {});
1531
+ var _data$state$placement = data[state.placement],
1532
+ x = _data$state$placement.x,
1533
+ y = _data$state$placement.y;
1534
+
1535
+ if (state.modifiersData.popperOffsets != null) {
1536
+ state.modifiersData.popperOffsets.x += x;
1537
+ state.modifiersData.popperOffsets.y += y;
1538
+ }
1539
+
1540
+ state.modifiersData[name] = data;
1541
+ } // eslint-disable-next-line import/no-unused-modules
1542
+
1543
+
1544
+ var offset$1 = {
1545
+ name: 'offset',
1546
+ enabled: true,
1547
+ phase: 'main',
1548
+ requires: ['popperOffsets'],
1549
+ fn: offset
1550
+ };
1551
+
1552
+ function popperOffsets(_ref) {
1553
+ var state = _ref.state,
1554
+ name = _ref.name; // Offsets are the actual position the popper needs to have to be
1555
+ // properly positioned near its reference element
1556
+ // This is the most basic placement, and will be adjusted by
1557
+ // the modifiers in the next step
1558
+
1559
+ state.modifiersData[name] = computeOffsets({
1560
+ reference: state.rects.reference,
1561
+ element: state.rects.popper,
1562
+ strategy: 'absolute',
1563
+ placement: state.placement
1564
+ });
1565
+ } // eslint-disable-next-line import/no-unused-modules
1566
+
1567
+
1568
+ var popperOffsets$1 = {
1569
+ name: 'popperOffsets',
1570
+ enabled: true,
1571
+ phase: 'read',
1572
+ fn: popperOffsets,
1573
+ data: {}
1574
+ };
1575
+
1576
+ function getAltAxis(axis) {
1577
+ return axis === 'x' ? 'y' : 'x';
1721
1578
  }
1722
1579
 
1723
1580
  function preventOverflow(_ref) {
@@ -1750,7 +1607,7 @@ function preventOverflow(_ref) {
1750
1607
  var popperOffsets = state.modifiersData.popperOffsets;
1751
1608
  var referenceRect = state.rects.reference;
1752
1609
  var popperRect = state.rects.popper;
1753
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
1610
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1754
1611
  placement: state.placement
1755
1612
  })) : tetherOffset;
1756
1613
  var data = {
@@ -1758,216 +1615,398 @@ function preventOverflow(_ref) {
1758
1615
  y: 0
1759
1616
  };
1760
1617
 
1761
- if (!popperOffsets) {
1762
- return;
1618
+ if (!popperOffsets) {
1619
+ return;
1620
+ }
1621
+
1622
+ if (checkMainAxis || checkAltAxis) {
1623
+ var mainSide = mainAxis === 'y' ? top : left;
1624
+ var altSide = mainAxis === 'y' ? bottom : right;
1625
+ var len = mainAxis === 'y' ? 'height' : 'width';
1626
+ var offset = popperOffsets[mainAxis];
1627
+ var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1628
+ var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1629
+ var additive = tether ? -popperRect[len] / 2 : 0;
1630
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1631
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1632
+ // outside the reference bounds
1633
+
1634
+ var arrowElement = state.elements.arrow;
1635
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1636
+ width: 0,
1637
+ height: 0
1638
+ };
1639
+ var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1640
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1641
+ var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1642
+ // to include its full size in the calculation. If the reference is small
1643
+ // and near the edge of a boundary, the popper can overflow even if the
1644
+ // reference is not overflowing as well (e.g. virtual elements with no
1645
+ // width or height)
1646
+
1647
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1648
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1649
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1650
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1651
+ var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1652
+ var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1653
+ var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1654
+ var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1655
+
1656
+ if (checkMainAxis) {
1657
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1658
+ popperOffsets[mainAxis] = preventedOffset;
1659
+ data[mainAxis] = preventedOffset - offset;
1660
+ }
1661
+
1662
+ if (checkAltAxis) {
1663
+ var _mainSide = mainAxis === 'x' ? top : left;
1664
+
1665
+ var _altSide = mainAxis === 'x' ? bottom : right;
1666
+
1667
+ var _offset = popperOffsets[altAxis];
1668
+
1669
+ var _min = _offset + overflow[_mainSide];
1670
+
1671
+ var _max = _offset - overflow[_altSide];
1672
+
1673
+ var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
1674
+
1675
+ popperOffsets[altAxis] = _preventedOffset;
1676
+ data[altAxis] = _preventedOffset - _offset;
1677
+ }
1678
+ }
1679
+
1680
+ state.modifiersData[name] = data;
1681
+ } // eslint-disable-next-line import/no-unused-modules
1682
+
1683
+
1684
+ var preventOverflow$1 = {
1685
+ name: 'preventOverflow',
1686
+ enabled: true,
1687
+ phase: 'main',
1688
+ fn: preventOverflow,
1689
+ requiresIfExists: ['offset']
1690
+ };
1691
+
1692
+ function getHTMLElementScroll(element) {
1693
+ return {
1694
+ scrollLeft: element.scrollLeft,
1695
+ scrollTop: element.scrollTop
1696
+ };
1697
+ }
1698
+
1699
+ function getNodeScroll(node) {
1700
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1701
+ return getWindowScroll(node);
1702
+ } else {
1703
+ return getHTMLElementScroll(node);
1704
+ }
1705
+ } // Composite means it takes into account transforms as well as layout.
1706
+
1707
+
1708
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1709
+ if (isFixed === void 0) {
1710
+ isFixed = false;
1711
+ }
1712
+
1713
+ var documentElement = getDocumentElement(offsetParent);
1714
+ var rect = getBoundingClientRect(elementOrVirtualElement);
1715
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1716
+ var scroll = {
1717
+ scrollLeft: 0,
1718
+ scrollTop: 0
1719
+ };
1720
+ var offsets = {
1721
+ x: 0,
1722
+ y: 0
1723
+ };
1724
+
1725
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1726
+ if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
1727
+ isScrollParent(documentElement)) {
1728
+ scroll = getNodeScroll(offsetParent);
1729
+ }
1730
+
1731
+ if (isHTMLElement(offsetParent)) {
1732
+ offsets = getBoundingClientRect(offsetParent);
1733
+ offsets.x += offsetParent.clientLeft;
1734
+ offsets.y += offsetParent.clientTop;
1735
+ } else if (documentElement) {
1736
+ offsets.x = getWindowScrollBarX(documentElement);
1737
+ }
1763
1738
  }
1764
1739
 
1765
- if (checkMainAxis) {
1766
- var mainSide = mainAxis === 'y' ? top : left;
1767
- var altSide = mainAxis === 'y' ? bottom : right;
1768
- var len = mainAxis === 'y' ? 'height' : 'width';
1769
- var offset = popperOffsets[mainAxis];
1770
- var min = popperOffsets[mainAxis] + overflow[mainSide];
1771
- var max = popperOffsets[mainAxis] - overflow[altSide];
1772
- var additive = tether ? -popperRect[len] / 2 : 0;
1773
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
1774
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
1775
- // outside the reference bounds
1740
+ return {
1741
+ x: rect.left + scroll.scrollLeft - offsets.x,
1742
+ y: rect.top + scroll.scrollTop - offsets.y,
1743
+ width: rect.width,
1744
+ height: rect.height
1745
+ };
1746
+ }
1776
1747
 
1777
- var arrowElement = state.elements.arrow;
1778
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1779
- width: 0,
1780
- height: 0
1781
- };
1782
- var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
1783
- var arrowPaddingMin = arrowPaddingObject[mainSide];
1784
- var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
1785
- // to include its full size in the calculation. If the reference is small
1786
- // and near the edge of a boundary, the popper can overflow even if the
1787
- // reference is not overflowing as well (e.g. virtual elements with no
1788
- // width or height)
1748
+ function order(modifiers) {
1749
+ var map = new Map();
1750
+ var visited = new Set();
1751
+ var result = [];
1752
+ modifiers.forEach(function (modifier) {
1753
+ map.set(modifier.name, modifier);
1754
+ }); // On visiting object, check for its dependencies and visit them recursively
1789
1755
 
1790
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1791
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1792
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1793
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1794
- var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1795
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1796
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1797
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1798
- var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
1799
- popperOffsets[mainAxis] = preventedOffset;
1800
- data[mainAxis] = preventedOffset - offset;
1756
+ function sort(modifier) {
1757
+ visited.add(modifier.name);
1758
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1759
+ requires.forEach(function (dep) {
1760
+ if (!visited.has(dep)) {
1761
+ var depModifier = map.get(dep);
1762
+
1763
+ if (depModifier) {
1764
+ sort(depModifier);
1765
+ }
1766
+ }
1767
+ });
1768
+ result.push(modifier);
1801
1769
  }
1802
1770
 
1803
- if (checkAltAxis) {
1804
- var _mainSide = mainAxis === 'x' ? top : left;
1771
+ modifiers.forEach(function (modifier) {
1772
+ if (!visited.has(modifier.name)) {
1773
+ // check for visited object
1774
+ sort(modifier);
1775
+ }
1776
+ });
1777
+ return result;
1778
+ }
1779
+
1780
+ function orderModifiers(modifiers) {
1781
+ // order based on dependencies
1782
+ var orderedModifiers = order(modifiers); // order based on phase
1783
+
1784
+ return modifierPhases.reduce(function (acc, phase) {
1785
+ return acc.concat(orderedModifiers.filter(function (modifier) {
1786
+ return modifier.phase === phase;
1787
+ }));
1788
+ }, []);
1789
+ }
1805
1790
 
1806
- var _altSide = mainAxis === 'x' ? bottom : right;
1791
+ function debounce(fn) {
1792
+ var pending;
1793
+ return function () {
1794
+ if (!pending) {
1795
+ pending = new Promise(function (resolve) {
1796
+ Promise.resolve().then(function () {
1797
+ pending = undefined;
1798
+ resolve(fn());
1799
+ });
1800
+ });
1801
+ }
1807
1802
 
1808
- var _offset = popperOffsets[altAxis];
1803
+ return pending;
1804
+ };
1805
+ }
1809
1806
 
1810
- var _min = _offset + overflow[_mainSide];
1807
+ function mergeByName(modifiers) {
1808
+ var merged = modifiers.reduce(function (merged, current) {
1809
+ var existing = merged[current.name];
1810
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1811
+ options: Object.assign({}, existing.options, current.options),
1812
+ data: Object.assign({}, existing.data, current.data)
1813
+ }) : current;
1814
+ return merged;
1815
+ }, {}); // IE11 does not support Object.values
1811
1816
 
1812
- var _max = _offset - overflow[_altSide];
1817
+ return Object.keys(merged).map(function (key) {
1818
+ return merged[key];
1819
+ });
1820
+ }
1813
1821
 
1814
- var _preventedOffset = within(_min, _offset, _max);
1822
+ var DEFAULT_OPTIONS = {
1823
+ placement: 'bottom',
1824
+ modifiers: [],
1825
+ strategy: 'absolute'
1826
+ };
1815
1827
 
1816
- popperOffsets[altAxis] = _preventedOffset;
1817
- data[altAxis] = _preventedOffset - _offset;
1828
+ function areValidElements() {
1829
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1830
+ args[_key] = arguments[_key];
1818
1831
  }
1819
1832
 
1820
- state.modifiersData[name] = data;
1821
- } // eslint-disable-next-line import/no-unused-modules
1833
+ return !args.some(function (element) {
1834
+ return !(element && typeof element.getBoundingClientRect === 'function');
1835
+ });
1836
+ }
1822
1837
 
1838
+ function popperGenerator(generatorOptions) {
1839
+ if (generatorOptions === void 0) {
1840
+ generatorOptions = {};
1841
+ }
1823
1842
 
1824
- var preventOverflow$1 = {
1825
- name: 'preventOverflow',
1826
- enabled: true,
1827
- phase: 'main',
1828
- fn: preventOverflow,
1829
- requiresIfExists: ['offset']
1830
- };
1843
+ var _generatorOptions = generatorOptions,
1844
+ _generatorOptions$def = _generatorOptions.defaultModifiers,
1845
+ defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
1846
+ _generatorOptions$def2 = _generatorOptions.defaultOptions,
1847
+ defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1848
+ return function createPopper(reference, popper, options) {
1849
+ if (options === void 0) {
1850
+ options = defaultOptions;
1851
+ }
1831
1852
 
1832
- function arrow(_ref) {
1833
- var _state$modifiersData$;
1853
+ var state = {
1854
+ placement: 'bottom',
1855
+ orderedModifiers: [],
1856
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1857
+ modifiersData: {},
1858
+ elements: {
1859
+ reference: reference,
1860
+ popper: popper
1861
+ },
1862
+ attributes: {},
1863
+ styles: {}
1864
+ };
1865
+ var effectCleanupFns = [];
1866
+ var isDestroyed = false;
1867
+ var instance = {
1868
+ state: state,
1869
+ setOptions: function setOptions(options) {
1870
+ cleanupModifierEffects();
1871
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1872
+ state.scrollParents = {
1873
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1874
+ popper: listScrollParents(popper)
1875
+ }; // Orders the modifiers based on their dependencies and `phase`
1876
+ // properties
1834
1877
 
1835
- var state = _ref.state,
1836
- name = _ref.name;
1837
- var arrowElement = state.elements.arrow;
1838
- var popperOffsets = state.modifiersData.popperOffsets;
1839
- var basePlacement = getBasePlacement(state.placement);
1840
- var axis = getMainAxisFromPlacement(basePlacement);
1841
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
1842
- var len = isVertical ? 'height' : 'width';
1878
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
1843
1879
 
1844
- if (!arrowElement || !popperOffsets) {
1845
- return;
1846
- }
1880
+ state.orderedModifiers = orderedModifiers.filter(function (m) {
1881
+ return m.enabled;
1882
+ }); // Validate the provided modifiers so that the consumer will get warned
1847
1883
 
1848
- var paddingObject = state.modifiersData[name + "#persistent"].padding;
1849
- var arrowRect = getLayoutRect(arrowElement);
1850
- var minProp = axis === 'y' ? top : left;
1851
- var maxProp = axis === 'y' ? bottom : right;
1852
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
1853
- var startDiff = popperOffsets[axis] - state.rects.reference[axis];
1854
- var arrowOffsetParent = getOffsetParent(arrowElement);
1855
- var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1856
- var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
1857
- // outside of the popper bounds
1884
+ runModifierEffects();
1885
+ return instance.update();
1886
+ },
1887
+ // Sync update it will always be executed, even if not necessary. This
1888
+ // is useful for low frequency updates where sync behavior simplifies the
1889
+ // logic.
1890
+ // For high frequency updates (e.g. `resize` and `scroll` events), always
1891
+ // prefer the async Popper#update method
1892
+ forceUpdate: function forceUpdate() {
1893
+ if (isDestroyed) {
1894
+ return;
1895
+ }
1858
1896
 
1859
- var min = paddingObject[minProp];
1860
- var max = clientSize - arrowRect[len] - paddingObject[maxProp];
1861
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1862
- var offset = within(min, center, max); // Prevents breaking syntax highlighting...
1897
+ var _state$elements = state.elements,
1898
+ reference = _state$elements.reference,
1899
+ popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
1900
+ // anymore
1863
1901
 
1864
- var axisProp = axis;
1865
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
1866
- }
1902
+ if (!areValidElements(reference, popper)) {
1903
+ return;
1904
+ } // Store the reference and popper rects to be read by modifiers
1867
1905
 
1868
- function effect$2(_ref2) {
1869
- var state = _ref2.state,
1870
- options = _ref2.options,
1871
- name = _ref2.name;
1872
- var _options$element = options.element,
1873
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
1874
- _options$padding = options.padding,
1875
- padding = _options$padding === void 0 ? 0 : _options$padding;
1876
1906
 
1877
- if (arrowElement == null) {
1878
- return;
1879
- } // CSS selector
1907
+ state.rects = {
1908
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
1909
+ popper: getLayoutRect(popper)
1910
+ }; // Modifiers have the ability to reset the current update cycle. The
1911
+ // most common use case for this is the `flip` modifier changing the
1912
+ // placement, which then needs to re-run all the modifiers, because the
1913
+ // logic was previously ran for the previous placement and is therefore
1914
+ // stale/incorrect
1915
+
1916
+ state.reset = false;
1917
+ state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
1918
+ // is filled with the initial data specified by the modifier. This means
1919
+ // it doesn't persist and is fresh on each update.
1920
+ // To ensure persistent data, use `${name}#persistent`
1921
+
1922
+ state.orderedModifiers.forEach(function (modifier) {
1923
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1924
+ });
1925
+
1926
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
1927
+ if (state.reset === true) {
1928
+ state.reset = false;
1929
+ index = -1;
1930
+ continue;
1931
+ }
1880
1932
 
1933
+ var _state$orderedModifie = state.orderedModifiers[index],
1934
+ fn = _state$orderedModifie.fn,
1935
+ _state$orderedModifie2 = _state$orderedModifie.options,
1936
+ _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1937
+ name = _state$orderedModifie.name;
1881
1938
 
1882
- if (typeof arrowElement === 'string') {
1883
- arrowElement = state.elements.popper.querySelector(arrowElement);
1939
+ if (typeof fn === 'function') {
1940
+ state = fn({
1941
+ state: state,
1942
+ options: _options,
1943
+ name: name,
1944
+ instance: instance
1945
+ }) || state;
1946
+ }
1947
+ }
1948
+ },
1949
+ // Async and optimistically optimized update – it will not be executed if
1950
+ // not necessary (debounced to run at most once-per-tick)
1951
+ update: debounce(function () {
1952
+ return new Promise(function (resolve) {
1953
+ instance.forceUpdate();
1954
+ resolve(state);
1955
+ });
1956
+ }),
1957
+ destroy: function destroy() {
1958
+ cleanupModifierEffects();
1959
+ isDestroyed = true;
1960
+ }
1961
+ };
1884
1962
 
1885
- if (!arrowElement) {
1886
- return;
1963
+ if (!areValidElements(reference, popper)) {
1964
+ return instance;
1887
1965
  }
1888
- }
1889
1966
 
1890
- if (!contains(state.elements.popper, arrowElement)) {
1967
+ instance.setOptions(options).then(function (state) {
1968
+ if (!isDestroyed && options.onFirstUpdate) {
1969
+ options.onFirstUpdate(state);
1970
+ }
1971
+ }); // Modifiers have the ability to execute arbitrary code before the first
1972
+ // update cycle runs. They will be executed in the same order as the update
1973
+ // cycle. This is useful when a modifier adds some persistent data that
1974
+ // other modifiers need to use, but the modifier is run after the dependent
1975
+ // one.
1891
1976
 
1892
- return;
1893
- }
1977
+ function runModifierEffects() {
1978
+ state.orderedModifiers.forEach(function (_ref3) {
1979
+ var name = _ref3.name,
1980
+ _ref3$options = _ref3.options,
1981
+ options = _ref3$options === void 0 ? {} : _ref3$options,
1982
+ effect = _ref3.effect;
1894
1983
 
1895
- state.elements.arrow = arrowElement;
1896
- state.modifiersData[name + "#persistent"] = {
1897
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
1898
- };
1899
- } // eslint-disable-next-line import/no-unused-modules
1984
+ if (typeof effect === 'function') {
1985
+ var cleanupFn = effect({
1986
+ state: state,
1987
+ name: name,
1988
+ instance: instance,
1989
+ options: options
1990
+ });
1900
1991
 
1992
+ var noopFn = function noopFn() {};
1901
1993
 
1902
- var arrow$1 = {
1903
- name: 'arrow',
1904
- enabled: true,
1905
- phase: 'main',
1906
- fn: arrow,
1907
- effect: effect$2,
1908
- requires: ['popperOffsets'],
1909
- requiresIfExists: ['preventOverflow']
1910
- };
1994
+ effectCleanupFns.push(cleanupFn || noopFn);
1995
+ }
1996
+ });
1997
+ }
1911
1998
 
1912
- function getSideOffsets(overflow, rect, preventedOffsets) {
1913
- if (preventedOffsets === void 0) {
1914
- preventedOffsets = {
1915
- x: 0,
1916
- y: 0
1917
- };
1918
- }
1999
+ function cleanupModifierEffects() {
2000
+ effectCleanupFns.forEach(function (fn) {
2001
+ return fn();
2002
+ });
2003
+ effectCleanupFns = [];
2004
+ }
1919
2005
 
1920
- return {
1921
- top: overflow.top - rect.height - preventedOffsets.y,
1922
- right: overflow.right - rect.width + preventedOffsets.x,
1923
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
1924
- left: overflow.left - rect.width - preventedOffsets.x
2006
+ return instance;
1925
2007
  };
1926
2008
  }
1927
2009
 
1928
- function isAnySideFullyClipped(overflow) {
1929
- return [top, right, bottom, left].some(function (side) {
1930
- return overflow[side] >= 0;
1931
- });
1932
- }
1933
-
1934
- function hide(_ref) {
1935
- var state = _ref.state,
1936
- name = _ref.name;
1937
- var referenceRect = state.rects.reference;
1938
- var popperRect = state.rects.popper;
1939
- var preventedOffsets = state.modifiersData.preventOverflow;
1940
- var referenceOverflow = detectOverflow(state, {
1941
- elementContext: 'reference'
1942
- });
1943
- var popperAltOverflow = detectOverflow(state, {
1944
- altBoundary: true
1945
- });
1946
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1947
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1948
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1949
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1950
- state.modifiersData[name] = {
1951
- referenceClippingOffsets: referenceClippingOffsets,
1952
- popperEscapeOffsets: popperEscapeOffsets,
1953
- isReferenceHidden: isReferenceHidden,
1954
- hasPopperEscaped: hasPopperEscaped
1955
- };
1956
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1957
- 'data-popper-reference-hidden': isReferenceHidden,
1958
- 'data-popper-escaped': hasPopperEscaped
1959
- });
1960
- } // eslint-disable-next-line import/no-unused-modules
1961
-
1962
-
1963
- var hide$1 = {
1964
- name: 'hide',
1965
- enabled: true,
1966
- phase: 'main',
1967
- requiresIfExists: ['preventOverflow'],
1968
- fn: hide
1969
- };
1970
-
1971
2010
  var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
1972
2011
  var createPopper = /*#__PURE__*/popperGenerator({
1973
2012
  defaultModifiers: defaultModifiers
@@ -2067,13 +2106,13 @@ function makeCenteredPopper(step) {
2067
2106
  });
2068
2107
  return popperOptions;
2069
2108
  }
2070
-
2071
2109
  /**
2072
2110
  * Ensure class prefix ends in `-`
2073
2111
  * @param {string} prefix The prefix to prepend to the class names generated by nano-css
2074
2112
  * @return {string} The prefix ending in `-`
2075
2113
  */
2076
2114
 
2115
+
2077
2116
  function normalizePrefix(prefix) {
2078
2117
  if (!isString(prefix) || prefix === '') {
2079
2118
  return '';
@@ -2089,6 +2128,7 @@ function normalizePrefix(prefix) {
2089
2128
  * `on` is a string position value
2090
2129
  */
2091
2130
 
2131
+
2092
2132
  function parseAttachTo(step) {
2093
2133
  const options = step.options.attachTo || {};
2094
2134
  const returnOpts = Object.assign({}, options);
@@ -2114,6 +2154,7 @@ function parseAttachTo(step) {
2114
2154
  * @param {Step} step The step instance
2115
2155
  */
2116
2156
 
2157
+
2117
2158
  function setupTooltip(step) {
2118
2159
  if (step.tooltip) {
2119
2160
  step.tooltip.destroy();
@@ -2138,6 +2179,7 @@ function setupTooltip(step) {
2138
2179
  * @return {string}
2139
2180
  */
2140
2181
 
2182
+
2141
2183
  function uuid() {
2142
2184
  let d = Date.now();
2143
2185
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
@@ -2154,12 +2196,14 @@ function uuid() {
2154
2196
  * @private
2155
2197
  */
2156
2198
 
2199
+
2157
2200
  function getPopperOptions(attachToOptions, step) {
2158
2201
  let popperOptions = {
2159
2202
  modifiers: [{
2160
2203
  name: 'preventOverflow',
2161
2204
  options: {
2162
- altAxis: true
2205
+ altAxis: true,
2206
+ tether: false
2163
2207
  }
2164
2208
  }, {
2165
2209
  name: 'focusAfterRender',
@@ -2239,6 +2283,10 @@ function safe_not_equal(a, b) {
2239
2283
  return a != a ? b == b : a !== b || a && typeof a === 'object' || typeof a === 'function';
2240
2284
  }
2241
2285
 
2286
+ function is_empty(obj) {
2287
+ return Object.keys(obj).length === 0;
2288
+ }
2289
+
2242
2290
  function append(target, node) {
2243
2291
  target.appendChild(node);
2244
2292
  }
@@ -2320,7 +2368,7 @@ function set_current_component(component) {
2320
2368
  }
2321
2369
 
2322
2370
  function get_current_component() {
2323
- if (!current_component) throw new Error(`Function called outside component initialization`);
2371
+ if (!current_component) throw new Error('Function called outside component initialization');
2324
2372
  return current_component;
2325
2373
  }
2326
2374
 
@@ -2366,6 +2414,7 @@ function flush() {
2366
2414
  update(component.$$);
2367
2415
  }
2368
2416
 
2417
+ set_current_component(null);
2369
2418
  dirty_components.length = 0;
2370
2419
 
2371
2420
  while (binding_callbacks.length) binding_callbacks.pop()(); // then, once components are updated, call
@@ -2492,28 +2541,32 @@ function create_component(block) {
2492
2541
  block && block.c();
2493
2542
  }
2494
2543
 
2495
- function mount_component(component, target, anchor) {
2544
+ function mount_component(component, target, anchor, customElement) {
2496
2545
  const {
2497
2546
  fragment,
2498
2547
  on_mount,
2499
2548
  on_destroy,
2500
2549
  after_update
2501
2550
  } = component.$$;
2502
- fragment && fragment.m(target, anchor); // onMount happens before the initial afterUpdate
2551
+ fragment && fragment.m(target, anchor);
2503
2552
 
2504
- add_render_callback(() => {
2505
- const new_on_destroy = on_mount.map(run).filter(is_function);
2553
+ if (!customElement) {
2554
+ // onMount happens before the initial afterUpdate
2555
+ add_render_callback(() => {
2556
+ const new_on_destroy = on_mount.map(run).filter(is_function);
2506
2557
 
2507
- if (on_destroy) {
2508
- on_destroy.push(...new_on_destroy);
2509
- } else {
2510
- // Edge case - component was destroyed immediately,
2511
- // most likely as a result of a binding initialising
2512
- run_all(new_on_destroy);
2513
- }
2558
+ if (on_destroy) {
2559
+ on_destroy.push(...new_on_destroy);
2560
+ } else {
2561
+ // Edge case - component was destroyed immediately,
2562
+ // most likely as a result of a binding initialising
2563
+ run_all(new_on_destroy);
2564
+ }
2565
+
2566
+ component.$$.on_mount = [];
2567
+ });
2568
+ }
2514
2569
 
2515
- component.$$.on_mount = [];
2516
- });
2517
2570
  after_update.forEach(add_render_callback);
2518
2571
  }
2519
2572
 
@@ -2543,7 +2596,6 @@ function make_dirty(component, i) {
2543
2596
  function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
2544
2597
  const parent_component = current_component;
2545
2598
  set_current_component(component);
2546
- const prop_values = options.props || {};
2547
2599
  const $$ = component.$$ = {
2548
2600
  fragment: null,
2549
2601
  ctx: null,
@@ -2555,19 +2607,21 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2555
2607
  // lifecycle
2556
2608
  on_mount: [],
2557
2609
  on_destroy: [],
2610
+ on_disconnect: [],
2558
2611
  before_update: [],
2559
2612
  after_update: [],
2560
- context: new Map(parent_component ? parent_component.$$.context : []),
2613
+ context: new Map(parent_component ? parent_component.$$.context : options.context || []),
2561
2614
  // everything else
2562
2615
  callbacks: blank_object(),
2563
- dirty
2616
+ dirty,
2617
+ skip_bound: false
2564
2618
  };
2565
2619
  let ready = false;
2566
- $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => {
2620
+ $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
2567
2621
  const value = rest.length ? rest[0] : ret;
2568
2622
 
2569
2623
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
2570
- if ($$.bound[i]) $$.bound[i](value);
2624
+ if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
2571
2625
  if (ready) make_dirty(component, i);
2572
2626
  }
2573
2627
 
@@ -2591,12 +2645,16 @@ function init(component, options, instance, create_fragment, not_equal, props, d
2591
2645
  }
2592
2646
 
2593
2647
  if (options.intro) transition_in(component.$$.fragment);
2594
- mount_component(component, options.target, options.anchor);
2648
+ mount_component(component, options.target, options.anchor, options.customElement);
2595
2649
  flush();
2596
2650
  }
2597
2651
 
2598
2652
  set_current_component(parent_component);
2599
2653
  }
2654
+ /**
2655
+ * Base class for Svelte components. Used when dev=false.
2656
+ */
2657
+
2600
2658
 
2601
2659
  class SvelteComponent {
2602
2660
  $destroy() {
@@ -2613,14 +2671,19 @@ class SvelteComponent {
2613
2671
  };
2614
2672
  }
2615
2673
 
2616
- $set() {// overridden by instance, if it has props
2674
+ $set($$props) {
2675
+ if (this.$$set && !is_empty($$props)) {
2676
+ this.$$.skip_bound = true;
2677
+ this.$$set($$props);
2678
+ this.$$.skip_bound = false;
2679
+ }
2617
2680
  }
2618
2681
 
2619
2682
  }
2683
+ /* src/js/components/shepherd-button.svelte generated by Svelte v3.37.0 */
2620
2684
 
2621
- /* src/js/components/shepherd-button.svelte generated by Svelte v3.23.2 */
2622
2685
 
2623
- function create_fragment(ctx) {
2686
+ function create_fragment$8(ctx) {
2624
2687
  let button;
2625
2688
  let button_aria_label_value;
2626
2689
  let button_class_value;
@@ -2712,7 +2775,7 @@ function create_fragment(ctx) {
2712
2775
  };
2713
2776
  }
2714
2777
 
2715
- function instance($$self, $$props, $$invalidate) {
2778
+ function instance$8($$self, $$props, $$invalidate) {
2716
2779
  let {
2717
2780
  config
2718
2781
  } = $$props,
@@ -2729,7 +2792,7 @@ function instance($$self, $$props, $$invalidate) {
2729
2792
  return disabled;
2730
2793
  }
2731
2794
 
2732
- $$self.$set = $$props => {
2795
+ $$self.$$set = $$props => {
2733
2796
  if ("config" in $$props) $$invalidate(6, config = $$props.config);
2734
2797
  if ("step" in $$props) $$invalidate(7, step = $$props.step);
2735
2798
  };
@@ -2738,7 +2801,7 @@ function instance($$self, $$props, $$invalidate) {
2738
2801
  if ($$self.$$.dirty &
2739
2802
  /*config, step*/
2740
2803
  192) {
2741
- {
2804
+ {
2742
2805
  $$invalidate(0, action = config.action ? config.action.bind(step.tour) : null);
2743
2806
  $$invalidate(1, classes = config.classes);
2744
2807
  $$invalidate(2, disabled = config.disabled ? getDisabled(config.disabled) : false);
@@ -2755,15 +2818,15 @@ function instance($$self, $$props, $$invalidate) {
2755
2818
  class Shepherd_button extends SvelteComponent {
2756
2819
  constructor(options) {
2757
2820
  super();
2758
- init(this, options, instance, create_fragment, safe_not_equal, {
2821
+ init(this, options, instance$8, create_fragment$8, safe_not_equal, {
2759
2822
  config: 6,
2760
2823
  step: 7
2761
2824
  });
2762
2825
  }
2763
2826
 
2764
2827
  }
2828
+ /* src/js/components/shepherd-footer.svelte generated by Svelte v3.37.0 */
2765
2829
 
2766
- /* src/js/components/shepherd-footer.svelte generated by Svelte v3.23.2 */
2767
2830
 
2768
2831
  function get_each_context(ctx, list, i) {
2769
2832
  const child_ctx = ctx.slice();
@@ -2772,7 +2835,7 @@ function get_each_context(ctx, list, i) {
2772
2835
  } // (24:4) {#if buttons}
2773
2836
 
2774
2837
 
2775
- function create_if_block(ctx) {
2838
+ function create_if_block$3(ctx) {
2776
2839
  let each_1_anchor;
2777
2840
  let current;
2778
2841
  let each_value =
@@ -2924,12 +2987,12 @@ function create_each_block(ctx) {
2924
2987
  };
2925
2988
  }
2926
2989
 
2927
- function create_fragment$1(ctx) {
2990
+ function create_fragment$7(ctx) {
2928
2991
  let footer;
2929
2992
  let current;
2930
2993
  let if_block =
2931
2994
  /*buttons*/
2932
- ctx[1] && create_if_block(ctx);
2995
+ ctx[1] && create_if_block$3(ctx);
2933
2996
  return {
2934
2997
  c() {
2935
2998
  footer = element("footer");
@@ -2956,7 +3019,7 @@ function create_fragment$1(ctx) {
2956
3019
  transition_in(if_block, 1);
2957
3020
  }
2958
3021
  } else {
2959
- if_block = create_if_block(ctx);
3022
+ if_block = create_if_block$3(ctx);
2960
3023
  if_block.c();
2961
3024
  transition_in(if_block, 1);
2962
3025
  if_block.m(footer, null);
@@ -2989,22 +3052,21 @@ function create_fragment$1(ctx) {
2989
3052
  };
2990
3053
  }
2991
3054
 
2992
- function instance$1($$self, $$props, $$invalidate) {
3055
+ function instance$7($$self, $$props, $$invalidate) {
3056
+ let buttons;
2993
3057
  let {
2994
3058
  step
2995
3059
  } = $$props;
2996
3060
 
2997
- $$self.$set = $$props => {
3061
+ $$self.$$set = $$props => {
2998
3062
  if ("step" in $$props) $$invalidate(0, step = $$props.step);
2999
3063
  };
3000
3064
 
3001
- let buttons;
3002
-
3003
3065
  $$self.$$.update = () => {
3004
3066
  if ($$self.$$.dirty &
3005
3067
  /*step*/
3006
3068
  1) {
3007
- $$invalidate(1, buttons = step.options.buttons);
3069
+ $$invalidate(1, buttons = step.options.buttons);
3008
3070
  }
3009
3071
  };
3010
3072
 
@@ -3014,16 +3076,16 @@ function instance$1($$self, $$props, $$invalidate) {
3014
3076
  class Shepherd_footer extends SvelteComponent {
3015
3077
  constructor(options) {
3016
3078
  super();
3017
- init(this, options, instance$1, create_fragment$1, safe_not_equal, {
3079
+ init(this, options, instance$7, create_fragment$7, safe_not_equal, {
3018
3080
  step: 0
3019
3081
  });
3020
3082
  }
3021
3083
 
3022
3084
  }
3085
+ /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.37.0 */
3023
3086
 
3024
- /* src/js/components/shepherd-cancel-icon.svelte generated by Svelte v3.23.2 */
3025
3087
 
3026
- function create_fragment$2(ctx) {
3088
+ function create_fragment$6(ctx) {
3027
3089
  let button;
3028
3090
  let span;
3029
3091
  let button_aria_label_value;
@@ -3080,7 +3142,7 @@ function create_fragment$2(ctx) {
3080
3142
  };
3081
3143
  }
3082
3144
 
3083
- function instance$2($$self, $$props, $$invalidate) {
3145
+ function instance$6($$self, $$props, $$invalidate) {
3084
3146
  let {
3085
3147
  cancelIcon
3086
3148
  } = $$props,
@@ -3096,7 +3158,7 @@ function instance$2($$self, $$props, $$invalidate) {
3096
3158
  step.cancel();
3097
3159
  };
3098
3160
 
3099
- $$self.$set = $$props => {
3161
+ $$self.$$set = $$props => {
3100
3162
  if ("cancelIcon" in $$props) $$invalidate(0, cancelIcon = $$props.cancelIcon);
3101
3163
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
3102
3164
  };
@@ -3107,17 +3169,17 @@ function instance$2($$self, $$props, $$invalidate) {
3107
3169
  class Shepherd_cancel_icon extends SvelteComponent {
3108
3170
  constructor(options) {
3109
3171
  super();
3110
- init(this, options, instance$2, create_fragment$2, safe_not_equal, {
3172
+ init(this, options, instance$6, create_fragment$6, safe_not_equal, {
3111
3173
  cancelIcon: 0,
3112
3174
  step: 2
3113
3175
  });
3114
3176
  }
3115
3177
 
3116
3178
  }
3179
+ /* src/js/components/shepherd-title.svelte generated by Svelte v3.37.0 */
3117
3180
 
3118
- /* src/js/components/shepherd-title.svelte generated by Svelte v3.23.2 */
3119
3181
 
3120
- function create_fragment$3(ctx) {
3182
+ function create_fragment$5(ctx) {
3121
3183
  let h3;
3122
3184
  return {
3123
3185
  c() {
@@ -3158,7 +3220,7 @@ function create_fragment$3(ctx) {
3158
3220
  };
3159
3221
  }
3160
3222
 
3161
- function instance$3($$self, $$props, $$invalidate) {
3223
+ function instance$5($$self, $$props, $$invalidate) {
3162
3224
  let {
3163
3225
  labelId
3164
3226
  } = $$props,
@@ -3183,7 +3245,7 @@ function instance$3($$self, $$props, $$invalidate) {
3183
3245
  });
3184
3246
  }
3185
3247
 
3186
- $$self.$set = $$props => {
3248
+ $$self.$$set = $$props => {
3187
3249
  if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3188
3250
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
3189
3251
  if ("title" in $$props) $$invalidate(2, title = $$props.title);
@@ -3195,7 +3257,7 @@ function instance$3($$self, $$props, $$invalidate) {
3195
3257
  class Shepherd_title extends SvelteComponent {
3196
3258
  constructor(options) {
3197
3259
  super();
3198
- init(this, options, instance$3, create_fragment$3, safe_not_equal, {
3260
+ init(this, options, instance$5, create_fragment$5, safe_not_equal, {
3199
3261
  labelId: 1,
3200
3262
  element: 0,
3201
3263
  title: 2
@@ -3203,10 +3265,10 @@ class Shepherd_title extends SvelteComponent {
3203
3265
  }
3204
3266
 
3205
3267
  }
3268
+ /* src/js/components/shepherd-header.svelte generated by Svelte v3.37.0 */
3206
3269
 
3207
- /* src/js/components/shepherd-header.svelte generated by Svelte v3.23.2 */
3208
3270
 
3209
- function create_if_block_1(ctx) {
3271
+ function create_if_block_1$1(ctx) {
3210
3272
  let shepherdtitle;
3211
3273
  let current;
3212
3274
  shepherdtitle = new Shepherd_title({
@@ -3263,7 +3325,7 @@ function create_if_block_1(ctx) {
3263
3325
  } // (39:4) {#if cancelIcon && cancelIcon.enabled}
3264
3326
 
3265
3327
 
3266
- function create_if_block$1(ctx) {
3328
+ function create_if_block$2(ctx) {
3267
3329
  let shepherdcancelicon;
3268
3330
  let current;
3269
3331
  shepherdcancelicon = new Shepherd_cancel_icon({
@@ -3325,12 +3387,12 @@ function create_fragment$4(ctx) {
3325
3387
  let current;
3326
3388
  let if_block0 =
3327
3389
  /*title*/
3328
- ctx[2] && create_if_block_1(ctx);
3390
+ ctx[2] && create_if_block_1$1(ctx);
3329
3391
  let if_block1 =
3330
3392
  /*cancelIcon*/
3331
3393
  ctx[3] &&
3332
3394
  /*cancelIcon*/
3333
- ctx[3].enabled && create_if_block$1(ctx);
3395
+ ctx[3].enabled && create_if_block$2(ctx);
3334
3396
  return {
3335
3397
  c() {
3336
3398
  header = element("header");
@@ -3361,7 +3423,7 @@ function create_fragment$4(ctx) {
3361
3423
  transition_in(if_block0, 1);
3362
3424
  }
3363
3425
  } else {
3364
- if_block0 = create_if_block_1(ctx);
3426
+ if_block0 = create_if_block_1$1(ctx);
3365
3427
  if_block0.c();
3366
3428
  transition_in(if_block0, 1);
3367
3429
  if_block0.m(header, t);
@@ -3388,7 +3450,7 @@ function create_fragment$4(ctx) {
3388
3450
  transition_in(if_block1, 1);
3389
3451
  }
3390
3452
  } else {
3391
- if_block1 = create_if_block$1(ctx);
3453
+ if_block1 = create_if_block$2(ctx);
3392
3454
  if_block1.c();
3393
3455
  transition_in(if_block1, 1);
3394
3456
  if_block1.m(header, null);
@@ -3433,7 +3495,7 @@ function instance$4($$self, $$props, $$invalidate) {
3433
3495
  } = $$props;
3434
3496
  let title, cancelIcon;
3435
3497
 
3436
- $$self.$set = $$props => {
3498
+ $$self.$$set = $$props => {
3437
3499
  if ("labelId" in $$props) $$invalidate(0, labelId = $$props.labelId);
3438
3500
  if ("step" in $$props) $$invalidate(1, step = $$props.step);
3439
3501
  };
@@ -3442,7 +3504,7 @@ function instance$4($$self, $$props, $$invalidate) {
3442
3504
  if ($$self.$$.dirty &
3443
3505
  /*step*/
3444
3506
  2) {
3445
- {
3507
+ {
3446
3508
  $$invalidate(2, title = step.options.title);
3447
3509
  $$invalidate(3, cancelIcon = step.options.cancelIcon);
3448
3510
  }
@@ -3462,10 +3524,10 @@ class Shepherd_header extends SvelteComponent {
3462
3524
  }
3463
3525
 
3464
3526
  }
3527
+ /* src/js/components/shepherd-text.svelte generated by Svelte v3.37.0 */
3465
3528
 
3466
- /* src/js/components/shepherd-text.svelte generated by Svelte v3.23.2 */
3467
3529
 
3468
- function create_fragment$5(ctx) {
3530
+ function create_fragment$3(ctx) {
3469
3531
  let div;
3470
3532
  return {
3471
3533
  c() {
@@ -3506,7 +3568,7 @@ function create_fragment$5(ctx) {
3506
3568
  };
3507
3569
  }
3508
3570
 
3509
- function instance$5($$self, $$props, $$invalidate) {
3571
+ function instance$3($$self, $$props, $$invalidate) {
3510
3572
  let {
3511
3573
  descriptionId
3512
3574
  } = $$props,
@@ -3525,7 +3587,7 @@ function instance$5($$self, $$props, $$invalidate) {
3525
3587
  text = text.call(step);
3526
3588
  }
3527
3589
 
3528
- if (isHTMLElement(text)) {
3590
+ if (isHTMLElement$1(text)) {
3529
3591
  element.appendChild(text);
3530
3592
  } else {
3531
3593
  $$invalidate(0, element.innerHTML = text, element);
@@ -3539,7 +3601,7 @@ function instance$5($$self, $$props, $$invalidate) {
3539
3601
  });
3540
3602
  }
3541
3603
 
3542
- $$self.$set = $$props => {
3604
+ $$self.$$set = $$props => {
3543
3605
  if ("descriptionId" in $$props) $$invalidate(1, descriptionId = $$props.descriptionId);
3544
3606
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
3545
3607
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
@@ -3551,7 +3613,7 @@ function instance$5($$self, $$props, $$invalidate) {
3551
3613
  class Shepherd_text extends SvelteComponent {
3552
3614
  constructor(options) {
3553
3615
  super();
3554
- init(this, options, instance$5, create_fragment$5, safe_not_equal, {
3616
+ init(this, options, instance$3, create_fragment$3, safe_not_equal, {
3555
3617
  descriptionId: 1,
3556
3618
  element: 0,
3557
3619
  step: 2
@@ -3559,8 +3621,8 @@ class Shepherd_text extends SvelteComponent {
3559
3621
  }
3560
3622
 
3561
3623
  }
3624
+ /* src/js/components/shepherd-content.svelte generated by Svelte v3.37.0 */
3562
3625
 
3563
- /* src/js/components/shepherd-content.svelte generated by Svelte v3.23.2 */
3564
3626
 
3565
3627
  function create_if_block_2(ctx) {
3566
3628
  let shepherdheader;
@@ -3619,7 +3681,7 @@ function create_if_block_2(ctx) {
3619
3681
  } // (28:2) {#if !isUndefined(step.options.text)}
3620
3682
 
3621
3683
 
3622
- function create_if_block_1$1(ctx) {
3684
+ function create_if_block_1(ctx) {
3623
3685
  let shepherdtext;
3624
3686
  let current;
3625
3687
  shepherdtext = new Shepherd_text({
@@ -3676,7 +3738,7 @@ function create_if_block_1$1(ctx) {
3676
3738
  } // (35:2) {#if Array.isArray(step.options.buttons) && step.options.buttons.length}
3677
3739
 
3678
3740
 
3679
- function create_if_block$2(ctx) {
3741
+ function create_if_block$1(ctx) {
3680
3742
  let shepherdfooter;
3681
3743
  let current;
3682
3744
  shepherdfooter = new Shepherd_footer({
@@ -3724,7 +3786,7 @@ function create_if_block$2(ctx) {
3724
3786
  };
3725
3787
  }
3726
3788
 
3727
- function create_fragment$6(ctx) {
3789
+ function create_fragment$2(ctx) {
3728
3790
  let div;
3729
3791
  let show_if_2 = !isUndefined(
3730
3792
  /*step*/
@@ -3745,8 +3807,8 @@ function create_fragment$6(ctx) {
3745
3807
  ctx[2].options.buttons.length;
3746
3808
  let current;
3747
3809
  let if_block0 = show_if_2 && create_if_block_2(ctx);
3748
- let if_block1 = show_if_1 && create_if_block_1$1(ctx);
3749
- let if_block2 = show_if && create_if_block$2(ctx);
3810
+ let if_block1 = show_if_1 && create_if_block_1(ctx);
3811
+ let if_block2 = show_if && create_if_block$1(ctx);
3750
3812
  return {
3751
3813
  c() {
3752
3814
  div = element("div");
@@ -3818,7 +3880,7 @@ function create_fragment$6(ctx) {
3818
3880
  transition_in(if_block1, 1);
3819
3881
  }
3820
3882
  } else {
3821
- if_block1 = create_if_block_1$1(ctx);
3883
+ if_block1 = create_if_block_1(ctx);
3822
3884
  if_block1.c();
3823
3885
  transition_in(if_block1, 1);
3824
3886
  if_block1.m(div, t1);
@@ -3849,7 +3911,7 @@ function create_fragment$6(ctx) {
3849
3911
  transition_in(if_block2, 1);
3850
3912
  }
3851
3913
  } else {
3852
- if_block2 = create_if_block$2(ctx);
3914
+ if_block2 = create_if_block$1(ctx);
3853
3915
  if_block2.c();
3854
3916
  transition_in(if_block2, 1);
3855
3917
  if_block2.m(div, null);
@@ -3888,7 +3950,7 @@ function create_fragment$6(ctx) {
3888
3950
  };
3889
3951
  }
3890
3952
 
3891
- function instance$6($$self, $$props, $$invalidate) {
3953
+ function instance$2($$self, $$props, $$invalidate) {
3892
3954
  let {
3893
3955
  descriptionId
3894
3956
  } = $$props,
@@ -3899,7 +3961,7 @@ function instance$6($$self, $$props, $$invalidate) {
3899
3961
  step
3900
3962
  } = $$props;
3901
3963
 
3902
- $$self.$set = $$props => {
3964
+ $$self.$$set = $$props => {
3903
3965
  if ("descriptionId" in $$props) $$invalidate(0, descriptionId = $$props.descriptionId);
3904
3966
  if ("labelId" in $$props) $$invalidate(1, labelId = $$props.labelId);
3905
3967
  if ("step" in $$props) $$invalidate(2, step = $$props.step);
@@ -3911,7 +3973,7 @@ function instance$6($$self, $$props, $$invalidate) {
3911
3973
  class Shepherd_content extends SvelteComponent {
3912
3974
  constructor(options) {
3913
3975
  super();
3914
- init(this, options, instance$6, create_fragment$6, safe_not_equal, {
3976
+ init(this, options, instance$2, create_fragment$2, safe_not_equal, {
3915
3977
  descriptionId: 0,
3916
3978
  labelId: 1,
3917
3979
  step: 2
@@ -3919,10 +3981,10 @@ class Shepherd_content extends SvelteComponent {
3919
3981
  }
3920
3982
 
3921
3983
  }
3984
+ /* src/js/components/shepherd-element.svelte generated by Svelte v3.37.0 */
3922
3985
 
3923
- /* src/js/components/shepherd-element.svelte generated by Svelte v3.23.2 */
3924
3986
 
3925
- function create_if_block$3(ctx) {
3987
+ function create_if_block(ctx) {
3926
3988
  let div;
3927
3989
  return {
3928
3990
  c() {
@@ -3942,10 +4004,12 @@ function create_if_block$3(ctx) {
3942
4004
  };
3943
4005
  }
3944
4006
 
3945
- function create_fragment$7(ctx) {
4007
+ function create_fragment$1(ctx) {
3946
4008
  let div;
3947
4009
  let t;
3948
4010
  let shepherdcontent;
4011
+ let div_aria_describedby_value;
4012
+ let div_aria_labelledby_value;
3949
4013
  let current;
3950
4014
  let mounted;
3951
4015
  let dispose;
@@ -3957,7 +4021,7 @@ function create_fragment$7(ctx) {
3957
4021
  /*step*/
3958
4022
  ctx[4].options.attachTo.element &&
3959
4023
  /*step*/
3960
- ctx[4].options.attachTo.on && create_if_block$3();
4024
+ ctx[4].options.attachTo.on && create_if_block();
3961
4025
  shepherdcontent = new Shepherd_content({
3962
4026
  props: {
3963
4027
  descriptionId:
@@ -3972,13 +4036,13 @@ function create_fragment$7(ctx) {
3972
4036
  }
3973
4037
  });
3974
4038
  let div_levels = [{
3975
- "aria-describedby": !isUndefined(
4039
+ "aria-describedby": div_aria_describedby_value = !isUndefined(
3976
4040
  /*step*/
3977
4041
  ctx[4].options.text) ?
3978
4042
  /*descriptionId*/
3979
4043
  ctx[2] : null
3980
4044
  }, {
3981
- "aria-labelledby":
4045
+ "aria-labelledby": div_aria_labelledby_value =
3982
4046
  /*step*/
3983
4047
  ctx[4].options.title ?
3984
4048
  /*labelId*/
@@ -4040,8 +4104,8 @@ function create_fragment$7(ctx) {
4040
4104
  ctx[4].options.attachTo.element &&
4041
4105
  /*step*/
4042
4106
  ctx[4].options.attachTo.on) {
4043
- if (if_block) ; else {
4044
- if_block = create_if_block$3();
4107
+ if (if_block) ;else {
4108
+ if_block = create_if_block();
4045
4109
  if_block.c();
4046
4110
  if_block.m(div, t);
4047
4111
  }
@@ -4067,22 +4131,22 @@ function create_fragment$7(ctx) {
4067
4131
  /*step*/
4068
4132
  ctx[4];
4069
4133
  shepherdcontent.$set(shepherdcontent_changes);
4070
- set_attributes(div, div_data = get_spread_update(div_levels, [dirty &
4071
- /*isUndefined, step, descriptionId*/
4072
- 20 && {
4073
- "aria-describedby": !isUndefined(
4074
- /*step*/
4075
- ctx[4].options.text) ?
4076
- /*descriptionId*/
4077
- ctx[2] : null
4078
- }, dirty &
4134
+ set_attributes(div, div_data = get_spread_update(div_levels, [(!current || dirty &
4135
+ /*step, descriptionId*/
4136
+ 20 && div_aria_describedby_value !== (div_aria_describedby_value = !isUndefined(
4137
+ /*step*/
4138
+ ctx[4].options.text) ?
4139
+ /*descriptionId*/
4140
+ ctx[2] : null)) && {
4141
+ "aria-describedby": div_aria_describedby_value
4142
+ }, (!current || dirty &
4079
4143
  /*step, labelId*/
4080
- 24 && {
4081
- "aria-labelledby":
4082
- /*step*/
4083
- ctx[4].options.title ?
4084
- /*labelId*/
4085
- ctx[3] : null
4144
+ 24 && div_aria_labelledby_value !== (div_aria_labelledby_value =
4145
+ /*step*/
4146
+ ctx[4].options.title ?
4147
+ /*labelId*/
4148
+ ctx[3] : null)) && {
4149
+ "aria-labelledby": div_aria_labelledby_value
4086
4150
  }, dirty &
4087
4151
  /*dataStepId*/
4088
4152
  2 &&
@@ -4135,7 +4199,7 @@ function getClassesArray(classes) {
4135
4199
  return classes.split(" ").filter(className => !!className.length);
4136
4200
  }
4137
4201
 
4138
- function instance$7($$self, $$props, $$invalidate) {
4202
+ function instance$1($$self, $$props, $$invalidate) {
4139
4203
  let {
4140
4204
  classPrefix
4141
4205
  } = $$props,
@@ -4230,7 +4294,7 @@ function instance$7($$self, $$props, $$invalidate) {
4230
4294
 
4231
4295
 
4232
4296
  if (e.shiftKey) {
4233
- if (document.activeElement === firstFocusableElement) {
4297
+ if (document.activeElement === firstFocusableElement || document.activeElement.classList.contains("shepherd-element")) {
4234
4298
  e.preventDefault();
4235
4299
  lastFocusableElement.focus();
4236
4300
  }
@@ -4273,7 +4337,7 @@ function instance$7($$self, $$props, $$invalidate) {
4273
4337
  });
4274
4338
  }
4275
4339
 
4276
- $$self.$set = $$props => {
4340
+ $$self.$$set = $$props => {
4277
4341
  if ("classPrefix" in $$props) $$invalidate(11, classPrefix = $$props.classPrefix);
4278
4342
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
4279
4343
  if ("descriptionId" in $$props) $$invalidate(2, descriptionId = $$props.descriptionId);
@@ -4289,7 +4353,7 @@ function instance$7($$self, $$props, $$invalidate) {
4289
4353
  if ($$self.$$.dirty &
4290
4354
  /*step*/
4291
4355
  16) {
4292
- {
4356
+ {
4293
4357
  $$invalidate(5, hasCancelIcon = step.options && step.options.cancelIcon && step.options.cancelIcon.enabled);
4294
4358
  $$invalidate(6, hasTitle = step.options && step.options.title);
4295
4359
  }
@@ -4302,7 +4366,7 @@ function instance$7($$self, $$props, $$invalidate) {
4302
4366
  class Shepherd_element extends SvelteComponent {
4303
4367
  constructor(options) {
4304
4368
  super();
4305
- init(this, options, instance$7, create_fragment$7, safe_not_equal, {
4369
+ init(this, options, instance$1, create_fragment$1, safe_not_equal, {
4306
4370
  classPrefix: 11,
4307
4371
  element: 0,
4308
4372
  descriptionId: 2,
@@ -4323,13 +4387,14 @@ class Shepherd_element extends SvelteComponent {
4323
4387
  }
4324
4388
 
4325
4389
  function createCommonjsModule(fn, module) {
4326
- return module = { exports: {} }, fn(module, module.exports), module.exports;
4390
+ return module = {
4391
+ exports: {}
4392
+ }, fn(module, module.exports), module.exports;
4327
4393
  }
4328
4394
 
4329
4395
  var smoothscroll = createCommonjsModule(function (module, exports) {
4330
4396
  /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
4331
4397
  (function () {
4332
-
4333
4398
  function polyfill() {
4334
4399
  // aliases
4335
4400
  var w = window;
@@ -4668,8 +4733,7 @@ var smoothscroll = createCommonjsModule(function (module, exports) {
4668
4733
  }
4669
4734
  })();
4670
4735
  });
4671
- var smoothscroll_1 = smoothscroll.polyfill;
4672
-
4736
+ smoothscroll.polyfill;
4673
4737
  smoothscroll.polyfill();
4674
4738
  /**
4675
4739
  * A class representing steps to be added to a tour.
@@ -4807,14 +4871,12 @@ class Step extends Evented {
4807
4871
  this.tooltip = null;
4808
4872
  }
4809
4873
 
4810
- if (isHTMLElement(this.el) && this.el.parentNode) {
4874
+ if (isHTMLElement$1(this.el) && this.el.parentNode) {
4811
4875
  this.el.parentNode.removeChild(this.el);
4812
4876
  this.el = null;
4813
4877
  }
4814
4878
 
4815
- if (this.target) {
4816
- this._updateStepTargetOnHide();
4817
- }
4879
+ this._updateStepTargetOnHide();
4818
4880
 
4819
4881
  this.trigger('destroy');
4820
4882
  }
@@ -4840,9 +4902,7 @@ class Step extends Evented {
4840
4902
  this.el.hidden = true;
4841
4903
  }
4842
4904
 
4843
- if (this.target) {
4844
- this._updateStepTargetOnHide();
4845
- }
4905
+ this._updateStepTargetOnHide();
4846
4906
 
4847
4907
  this.trigger('hide');
4848
4908
  }
@@ -4928,7 +4988,7 @@ class Step extends Evented {
4928
4988
  const descriptionId = `${this.id}-description`;
4929
4989
  const labelId = `${this.id}-label`;
4930
4990
  this.shepherdElementComponent = new Shepherd_element({
4931
- target: document.body,
4991
+ target: this.tour.options.stepsContainer || document.body,
4932
4992
  props: {
4933
4993
  classPrefix: this.classPrefix,
4934
4994
  descriptionId,
@@ -4956,7 +5016,7 @@ class Step extends Evented {
4956
5016
 
4957
5017
  if (isFunction(this.options.scrollToHandler)) {
4958
5018
  this.options.scrollToHandler(element);
4959
- } else if (isElement(element) && typeof element.scrollIntoView === 'function') {
5019
+ } else if (isElement$1(element) && typeof element.scrollIntoView === 'function') {
4960
5020
  element.scrollIntoView(scrollToOptions);
4961
5021
  }
4962
5022
  }
@@ -5089,19 +5149,22 @@ class Step extends Evented {
5089
5149
 
5090
5150
 
5091
5151
  _updateStepTargetOnHide() {
5152
+ const target = this.target || document.body;
5153
+
5092
5154
  if (this.options.highlightClass) {
5093
- this.target.classList.remove(this.options.highlightClass);
5155
+ target.classList.remove(this.options.highlightClass);
5094
5156
  }
5095
5157
 
5096
- this.target.classList.remove(`${this.classPrefix}shepherd-enabled`, `${this.classPrefix}shepherd-target`);
5158
+ target.classList.remove('shepherd-target-click-disabled', `${this.classPrefix}shepherd-enabled`, `${this.classPrefix}shepherd-target`);
5097
5159
  }
5098
5160
 
5099
5161
  }
5100
-
5101
5162
  /**
5102
5163
  * Cleanup the steps and set pointerEvents back to 'auto'
5103
5164
  * @param tour The tour object
5104
5165
  */
5166
+
5167
+
5105
5168
  function cleanupSteps(tour) {
5106
5169
  if (tour) {
5107
5170
  const {
@@ -5116,7 +5179,6 @@ function cleanupSteps(tour) {
5116
5179
  });
5117
5180
  }
5118
5181
  }
5119
-
5120
5182
  /**
5121
5183
  * Generates the svg path data for a rounded rectangle overlay
5122
5184
  * @param {Object} dimension - Dimensions of rectangle.
@@ -5127,6 +5189,8 @@ function cleanupSteps(tour) {
5127
5189
  * @param {number} [r=0] - Corner Radius. Keep this smaller than half of width or height.
5128
5190
  * @returns {string} - Rounded rectangle overlay path data.
5129
5191
  */
5192
+
5193
+
5130
5194
  function makeOverlayPath({
5131
5195
  width,
5132
5196
  height,
@@ -5154,10 +5218,10 @@ V${y + r}\
5154
5218
  a${r},${r},0,0,0-${r}-${r}\
5155
5219
  Z`;
5156
5220
  }
5221
+ /* src/js/components/shepherd-modal.svelte generated by Svelte v3.37.0 */
5157
5222
 
5158
- /* src/js/components/shepherd-modal.svelte generated by Svelte v3.23.2 */
5159
5223
 
5160
- function create_fragment$8(ctx) {
5224
+ function create_fragment(ctx) {
5161
5225
  let svg;
5162
5226
  let path;
5163
5227
  let svg_class_value;
@@ -5239,14 +5303,14 @@ function _getScrollParent(element) {
5239
5303
  return _getScrollParent(element.parentElement);
5240
5304
  }
5241
5305
  /**
5242
- * Get the visible height of the target element relative to its scrollParent.
5243
- * If there is no scroll parent, the height of the element is returned.
5244
- *
5245
- * @param {HTMLElement} element The target element
5246
- * @param {HTMLElement} [scrollParent] The scrollable parent element
5247
- * @returns {{y: number, height: number}}
5248
- * @private
5249
- */
5306
+ * Get the visible height of the target element relative to its scrollParent.
5307
+ * If there is no scroll parent, the height of the element is returned.
5308
+ *
5309
+ * @param {HTMLElement} element The target element
5310
+ * @param {HTMLElement} [scrollParent] The scrollable parent element
5311
+ * @returns {{y: number, height: number}}
5312
+ * @private
5313
+ */
5250
5314
 
5251
5315
 
5252
5316
  function _getVisibleHeight(element, scrollParent) {
@@ -5270,14 +5334,14 @@ function _getVisibleHeight(element, scrollParent) {
5270
5334
  };
5271
5335
  }
5272
5336
 
5273
- function instance$8($$self, $$props, $$invalidate) {
5337
+ function instance($$self, $$props, $$invalidate) {
5274
5338
  let {
5275
5339
  element
5276
5340
  } = $$props,
5277
5341
  {
5278
5342
  openingProperties
5279
5343
  } = $$props;
5280
- const guid = uuid();
5344
+ uuid();
5281
5345
  let modalIsVisible = false;
5282
5346
  let rafId = undefined;
5283
5347
  let pathDefinition;
@@ -5301,8 +5365,8 @@ function instance$8($$self, $$props, $$invalidate) {
5301
5365
  _cleanupStepEventListeners();
5302
5366
  }
5303
5367
 
5304
- function positionModalOpening(targetElement, scrollParent, modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0) {
5305
- if (targetElement.getBoundingClientRect) {
5368
+ function positionModal(modalOverlayOpeningPadding = 0, modalOverlayOpeningRadius = 0, scrollParent, targetElement) {
5369
+ if (targetElement) {
5306
5370
  const {
5307
5371
  y,
5308
5372
  height
@@ -5321,6 +5385,8 @@ function instance$8($$self, $$props, $$invalidate) {
5321
5385
  y: y - modalOverlayOpeningPadding,
5322
5386
  r: modalOverlayOpeningRadius
5323
5387
  });
5388
+ } else {
5389
+ closeModalOpening();
5324
5390
  }
5325
5391
  }
5326
5392
 
@@ -5389,22 +5455,18 @@ function instance$8($$self, $$props, $$invalidate) {
5389
5455
  modalOverlayOpeningRadius
5390
5456
  } = step.options;
5391
5457
 
5392
- if (step.target) {
5393
- const scrollParent = _getScrollParent(step.target); // Setup recursive function to call requestAnimationFrame to update the modal opening position
5458
+ const scrollParent = _getScrollParent(step.target); // Setup recursive function to call requestAnimationFrame to update the modal opening position
5394
5459
 
5395
5460
 
5396
- const rafLoop = () => {
5397
- rafId = undefined;
5398
- positionModalOpening(step.target, scrollParent, modalOverlayOpeningPadding, modalOverlayOpeningRadius);
5399
- rafId = requestAnimationFrame(rafLoop);
5400
- };
5461
+ const rafLoop = () => {
5462
+ rafId = undefined;
5463
+ positionModal(modalOverlayOpeningPadding, modalOverlayOpeningRadius, scrollParent, step.target);
5464
+ rafId = requestAnimationFrame(rafLoop);
5465
+ };
5401
5466
 
5402
- rafLoop();
5467
+ rafLoop();
5403
5468
 
5404
- _addStepEventListeners();
5405
- } else {
5406
- closeModalOpening();
5407
- }
5469
+ _addStepEventListeners();
5408
5470
  }
5409
5471
 
5410
5472
  function svg_binding($$value) {
@@ -5414,7 +5476,7 @@ function instance$8($$self, $$props, $$invalidate) {
5414
5476
  });
5415
5477
  }
5416
5478
 
5417
- $$self.$set = $$props => {
5479
+ $$self.$$set = $$props => {
5418
5480
  if ("element" in $$props) $$invalidate(0, element = $$props.element);
5419
5481
  if ("openingProperties" in $$props) $$invalidate(4, openingProperties = $$props.openingProperties);
5420
5482
  };
@@ -5423,23 +5485,23 @@ function instance$8($$self, $$props, $$invalidate) {
5423
5485
  if ($$self.$$.dirty &
5424
5486
  /*openingProperties*/
5425
5487
  16) {
5426
- $$invalidate(2, pathDefinition = makeOverlayPath(openingProperties));
5488
+ $$invalidate(2, pathDefinition = makeOverlayPath(openingProperties));
5427
5489
  }
5428
5490
  };
5429
5491
 
5430
- return [element, modalIsVisible, pathDefinition, _preventModalOverlayTouch, openingProperties, getElement, closeModalOpening, hide, positionModalOpening, setupForStep, show, svg_binding];
5492
+ return [element, modalIsVisible, pathDefinition, _preventModalOverlayTouch, openingProperties, getElement, closeModalOpening, hide, positionModal, setupForStep, show, svg_binding];
5431
5493
  }
5432
5494
 
5433
5495
  class Shepherd_modal extends SvelteComponent {
5434
5496
  constructor(options) {
5435
5497
  super();
5436
- init(this, options, instance$8, create_fragment$8, safe_not_equal, {
5498
+ init(this, options, instance, create_fragment, safe_not_equal, {
5437
5499
  element: 0,
5438
5500
  openingProperties: 4,
5439
5501
  getElement: 5,
5440
5502
  closeModalOpening: 6,
5441
5503
  hide: 7,
5442
- positionModalOpening: 8,
5504
+ positionModal: 8,
5443
5505
  setupForStep: 9,
5444
5506
  show: 10
5445
5507
  });
@@ -5457,7 +5519,7 @@ class Shepherd_modal extends SvelteComponent {
5457
5519
  return this.$$.ctx[7];
5458
5520
  }
5459
5521
 
5460
- get positionModalOpening() {
5522
+ get positionModal() {
5461
5523
  return this.$$.ctx[8];
5462
5524
  }
5463
5525
 
@@ -5488,6 +5550,8 @@ class Tour extends Evented {
5488
5550
  * set to false.
5489
5551
  * @param {boolean} options.keyboardNavigation Navigating the tour via left and right arrow keys will be enabled
5490
5552
  * unless this is explicitly set to false.
5553
+ * @param {HTMLElement} options.stepsContainer An optional container element for the steps.
5554
+ * If not set, the steps will be appended to `document.body`.
5491
5555
  * @param {HTMLElement} options.modalContainer An optional container element for the modal.
5492
5556
  * If not set, the modal will be appended to `document.body`.
5493
5557
  * @param {object[] | Step[]} options.steps An array of step options objects or Step instances to initialize the tour with
@@ -5768,7 +5832,7 @@ class Tour extends Evented {
5768
5832
  } // Focus the element that was focused before the tour started
5769
5833
 
5770
5834
 
5771
- if (isHTMLElement(this.focusedElBeforeOpen)) {
5835
+ if (isHTMLElement$1(this.focusedElBeforeOpen)) {
5772
5836
  this.focusedElBeforeOpen.focus();
5773
5837
  }
5774
5838
  }
@@ -5859,7 +5923,6 @@ var addSteps = function (steps, tour) {
5859
5923
  if (!steps.length) {
5860
5924
  return [];
5861
5925
  }
5862
- console.log('🍻');
5863
5926
  var parsedStepsforAction = steps.map(function (step) {
5864
5927
  var buttons = step.buttons;
5865
5928
  if (buttons) {
@@ -5868,7 +5931,7 @@ var addSteps = function (steps, tour) {
5868
5931
  return {
5869
5932
  // TypeScript doesn't have great support for dynamic method calls with
5870
5933
  // bracket notation, so we use the `any` escape hatch
5871
- action: action || tour[type],
5934
+ action: tour[type] || action,
5872
5935
  classes: classes,
5873
5936
  disabled: disabled,
5874
5937
  label: label,