PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.1
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / assets / js / libraries / shepherd.js

shepherd.js in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.1, at assets/js/libraries/shepherd.js

9,407 lines 291.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! shepherd.js 5.0.1 */
2
3 (function (global, factory) {
4 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
5 typeof define === 'function' && define.amd ? define(factory) :
6 (global = global || self, global.Shepherd = factory());
7 }(this, function () { 'use strict';
8
9 function _extends() {
10 _extends = Object.assign || function (target) {
11 for (var i = 1; i < arguments.length; i++) {
12 var source = arguments[i];
13
14 for (var key in source) {
15 if (Object.prototype.hasOwnProperty.call(source, key)) {
16 target[key] = source[key];
17 }
18 }
19 }
20
21 return target;
22 };
23
24 return _extends.apply(this, arguments);
25 }
26
27 function _inheritsLoose(subClass, superClass) {
28 subClass.prototype = Object.create(superClass.prototype);
29 subClass.prototype.constructor = subClass;
30 subClass.__proto__ = superClass;
31 }
32
33 function _assertThisInitialized(self) {
34 if (self === void 0) {
35 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
36 }
37
38 return self;
39 }
40
41 var validTypes = { object: true, symbol: true };
42
43 var isImplemented = function () {
44 var symbol;
45 if (typeof Symbol !== 'function') return false;
46 symbol = Symbol('test symbol');
47 try { String(symbol); } catch (e) { return false; }
48
49 // Return 'true' also for polyfills
50 if (!validTypes[typeof Symbol.iterator]) return false;
51 if (!validTypes[typeof Symbol.toPrimitive]) return false;
52 if (!validTypes[typeof Symbol.toStringTag]) return false;
53
54 return true;
55 };
56
57 var global$1 = (function () {
58 if (this) return this;
59
60 // Unexpected strict mode (may happen if e.g. bundled into ESM module) be nice
61
62 // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
63 // In all ES5 engines global object inherits from Object.prototype
64 // (if you approached one that doesn't please report)
65 Object.defineProperty(Object.prototype, "__global__", {
66 get: function () { return this; },
67 configurable: true
68 });
69 try { return __global__; }
70 finally { delete Object.prototype.__global__; }
71 })();
72
73 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
74
75 function unwrapExports (x) {
76 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
77 }
78
79 function createCommonjsModule(fn, module) {
80 return module = { exports: {} }, fn(module, module.exports), module.exports;
81 }
82
83 // ES3 safe
84 var _undefined = void 0;
85
86 var is = function (value) { return value !== _undefined && value !== null; };
87
88 // prettier-ignore
89 var possibleTypes = { "object": true, "function": true, "undefined": true /* document.all */ };
90
91 var is$1 = function (value) {
92 if (!is(value)) return false;
93 return hasOwnProperty.call(possibleTypes, typeof value);
94 };
95
96 var is$2 = function (value) {
97 if (!is$1(value)) return false;
98 try {
99 if (!value.constructor) return false;
100 return value.constructor.prototype === value;
101 } catch (error) {
102 return false;
103 }
104 };
105
106 var is$3 = function (value) {
107 if (typeof value !== "function") return false;
108
109 if (!hasOwnProperty.call(value, "length")) return false;
110
111 try {
112 if (typeof value.length !== "number") return false;
113 if (typeof value.call !== "function") return false;
114 if (typeof value.apply !== "function") return false;
115 } catch (error) {
116 return false;
117 }
118
119 return !is$2(value);
120 };
121
122 var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
123
124 var is$4 = function (value) {
125 if (!is$3(value)) return false;
126 if (classRe.test(functionToString.call(value))) return false;
127 return true;
128 };
129
130 var isImplemented$1 = function () {
131 var assign = Object.assign, obj;
132 if (typeof assign !== "function") return false;
133 obj = { foo: "raz" };
134 assign(obj, { bar: "dwa" }, { trzy: "trzy" });
135 return (obj.foo + obj.bar + obj.trzy) === "razdwatrzy";
136 };
137
138 var isImplemented$2 = function () {
139 try {
140 Object.keys("primitive");
141 return true;
142 } catch (e) {
143 return false;
144 }
145 };
146
147 // eslint-disable-next-line no-empty-function
148 var noop = function () {};
149
150 var _undefined$1 = noop(); // Support ES3 engines
151
152 var isValue = function (val) {
153 return (val !== _undefined$1) && (val !== null);
154 };
155
156 var keys = Object.keys;
157
158 var shim = function (object) { return keys(isValue(object) ? Object(object) : object); };
159
160 var keys$1 = isImplemented$2() ? Object.keys : shim;
161
162 var validValue = function (value) {
163 if (!isValue(value)) throw new TypeError("Cannot use null or undefined");
164 return value;
165 };
166
167 var max = Math.max;
168
169 var shim$1 = function (dest, src /*, …srcn*/) {
170 var error, i, length = max(arguments.length, 2), assign;
171 dest = Object(validValue(dest));
172 assign = function (key) {
173 try {
174 dest[key] = src[key];
175 } catch (e) {
176 if (!error) error = e;
177 }
178 };
179 for (i = 1; i < length; ++i) {
180 src = arguments[i];
181 keys$1(src).forEach(assign);
182 }
183 if (error !== undefined) throw error;
184 return dest;
185 };
186
187 var assign = isImplemented$1()
188 ? Object.assign
189 : shim$1;
190
191 var forEach = Array.prototype.forEach, create = Object.create;
192
193 var process = function (src, obj) {
194 var key;
195 for (key in src) obj[key] = src[key];
196 };
197
198 // eslint-disable-next-line no-unused-vars
199 var normalizeOptions = function (opts1 /*, …options*/) {
200 var result = create(null);
201 forEach.call(arguments, function (options) {
202 if (!isValue(options)) return;
203 process(Object(options), result);
204 });
205 return result;
206 };
207
208 var str = "razdwatrzy";
209
210 var isImplemented$3 = function () {
211 if (typeof str.contains !== "function") return false;
212 return (str.contains("dwa") === true) && (str.contains("foo") === false);
213 };
214
215 var indexOf = String.prototype.indexOf;
216
217 var shim$2 = function (searchString/*, position*/) {
218 return indexOf.call(this, searchString, arguments[1]) > -1;
219 };
220
221 var contains = isImplemented$3()
222 ? String.prototype.contains
223 : shim$2;
224
225 var d_1 = createCommonjsModule(function (module) {
226
227
228
229 var d = (module.exports = function (dscr, value/*, options*/) {
230 var c, e, w, options, desc;
231 if (arguments.length < 2 || typeof dscr !== "string") {
232 options = value;
233 value = dscr;
234 dscr = null;
235 } else {
236 options = arguments[2];
237 }
238 if (is(dscr)) {
239 c = contains.call(dscr, "c");
240 e = contains.call(dscr, "e");
241 w = contains.call(dscr, "w");
242 } else {
243 c = w = true;
244 e = false;
245 }
246
247 desc = { value: value, configurable: c, enumerable: e, writable: w };
248 return !options ? desc : assign(normalizeOptions(options), desc);
249 });
250
251 d.gs = function (dscr, get, set/*, options*/) {
252 var c, e, options, desc;
253 if (typeof dscr !== "string") {
254 options = set;
255 set = get;
256 get = dscr;
257 dscr = null;
258 } else {
259 options = arguments[3];
260 }
261 if (!is(get)) {
262 get = undefined;
263 } else if (!is$4(get)) {
264 options = get;
265 get = set = undefined;
266 } else if (!is(set)) {
267 set = undefined;
268 } else if (!is$4(set)) {
269 options = set;
270 set = undefined;
271 }
272 if (is(dscr)) {
273 c = contains.call(dscr, "c");
274 e = contains.call(dscr, "e");
275 } else {
276 c = true;
277 e = false;
278 }
279
280 desc = { get: get, set: set, configurable: c, enumerable: e };
281 return !options ? desc : assign(normalizeOptions(options), desc);
282 };
283 });
284
285 var isSymbol = function (x) {
286 if (!x) return false;
287 if (typeof x === 'symbol') return true;
288 if (!x.constructor) return false;
289 if (x.constructor.name !== 'Symbol') return false;
290 return (x[x.constructor.toStringTag] === 'Symbol');
291 };
292
293 var validateSymbol = function (value) {
294 if (!isSymbol(value)) throw new TypeError(value + " is not a symbol");
295 return value;
296 };
297
298 var create$1 = Object.create, defineProperties = Object.defineProperties
299 , defineProperty = Object.defineProperty, objPrototype = Object.prototype
300 , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create$1(null)
301 , isNativeSafe;
302
303 if (typeof Symbol === 'function') {
304 NativeSymbol = Symbol;
305 try {
306 String(NativeSymbol());
307 isNativeSafe = true;
308 } catch (ignore) {}
309 }
310
311 var generateName = (function () {
312 var created = create$1(null);
313 return function (desc) {
314 var postfix = 0, name, ie11BugWorkaround;
315 while (created[desc + (postfix || '')]) ++postfix;
316 desc += (postfix || '');
317 created[desc] = true;
318 name = '@@' + desc;
319 defineProperty(objPrototype, name, d_1.gs(null, function (value) {
320 // For IE11 issue see:
321 // https://connect.microsoft.com/IE/feedbackdetail/view/1928508/
322 // ie11-broken-getters-on-dom-objects
323 // https://github.com/medikoo/es6-symbol/issues/12
324 if (ie11BugWorkaround) return;
325 ie11BugWorkaround = true;
326 defineProperty(this, name, d_1(value));
327 ie11BugWorkaround = false;
328 }));
329 return name;
330 };
331 }());
332
333 // Internal constructor (not one exposed) for creating Symbol instances.
334 // This one is used to ensure that `someSymbol instanceof Symbol` always return false
335 HiddenSymbol = function Symbol(description) {
336 if (this instanceof HiddenSymbol) throw new TypeError('Symbol is not a constructor');
337 return SymbolPolyfill(description);
338 };
339
340 // Exposed `Symbol` constructor
341 // (returns instances of HiddenSymbol)
342 var polyfill = SymbolPolyfill = function Symbol(description) {
343 var symbol;
344 if (this instanceof Symbol) throw new TypeError('Symbol is not a constructor');
345 if (isNativeSafe) return NativeSymbol(description);
346 symbol = create$1(HiddenSymbol.prototype);
347 description = (description === undefined ? '' : String(description));
348 return defineProperties(symbol, {
349 __description__: d_1('', description),
350 __name__: d_1('', generateName(description))
351 });
352 };
353 defineProperties(SymbolPolyfill, {
354 for: d_1(function (key) {
355 if (globalSymbols[key]) return globalSymbols[key];
356 return (globalSymbols[key] = SymbolPolyfill(String(key)));
357 }),
358 keyFor: d_1(function (s) {
359 var key;
360 validateSymbol(s);
361 for (key in globalSymbols) if (globalSymbols[key] === s) return key;
362 }),
363
364 // To ensure proper interoperability with other native functions (e.g. Array.from)
365 // fallback to eventual native implementation of given symbol
366 hasInstance: d_1('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')),
367 isConcatSpreadable: d_1('', (NativeSymbol && NativeSymbol.isConcatSpreadable) ||
368 SymbolPolyfill('isConcatSpreadable')),
369 iterator: d_1('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')),
370 match: d_1('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')),
371 replace: d_1('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')),
372 search: d_1('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')),
373 species: d_1('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')),
374 split: d_1('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')),
375 toPrimitive: d_1('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')),
376 toStringTag: d_1('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')),
377 unscopables: d_1('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables'))
378 });
379
380 // Internal tweaks for real symbol producer
381 defineProperties(HiddenSymbol.prototype, {
382 constructor: d_1(SymbolPolyfill),
383 toString: d_1('', function () { return this.__name__; })
384 });
385
386 // Proper implementation of methods exposed on Symbol.prototype
387 // They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype
388 defineProperties(SymbolPolyfill.prototype, {
389 toString: d_1(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }),
390 valueOf: d_1(function () { return validateSymbol(this); })
391 });
392 defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d_1('', function () {
393 var symbol = validateSymbol(this);
394 if (typeof symbol === 'symbol') return symbol;
395 return symbol.toString();
396 }));
397 defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d_1('c', 'Symbol'));
398
399 // Proper implementaton of toPrimitive and toStringTag for returned symbol instances
400 defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag,
401 d_1('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));
402
403 // Note: It's important to define `toPrimitive` as last one, as some implementations
404 // implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols)
405 // And that may invoke error in definition flow:
406 // See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149
407 defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive,
408 d_1('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]));
409
410 if (!isImplemented()) {
411 Object.defineProperty(global$1, 'Symbol',
412 { value: polyfill, configurable: true, enumerable: false,
413 writable: true });
414 }
415
416 /*!
417 * isobject <https://github.com/jonschlinkert/isobject>
418 *
419 * Copyright (c) 2014-2017, Jon Schlinkert.
420 * Released under the MIT License.
421 */
422
423 var isobject = function isObject(val) {
424 return val != null && typeof val === 'object' && Array.isArray(val) === false;
425 };
426
427 /*!
428 * get-value <https://github.com/jonschlinkert/get-value>
429 *
430 * Copyright (c) 2014-2018, Jon Schlinkert.
431 * Released under the MIT License.
432 */
433
434
435
436 var getValue = function(target, path, options) {
437 if (!isobject(options)) {
438 options = { default: options };
439 }
440
441 if (!isValidObject(target)) {
442 return typeof options.default !== 'undefined' ? options.default : target;
443 }
444
445 if (typeof path === 'number') {
446 path = String(path);
447 }
448
449 const isArray = Array.isArray(path);
450 const isString = typeof path === 'string';
451 const splitChar = options.separator || '.';
452 const joinChar = options.joinChar || (typeof splitChar === 'string' ? splitChar : '.');
453
454 if (!isString && !isArray) {
455 return target;
456 }
457
458 if (isString && path in target) {
459 return isValid(path, target, options) ? target[path] : options.default;
460 }
461
462 let segs = isArray ? path : split(path, splitChar, options);
463 let len = segs.length;
464 let idx = 0;
465
466 do {
467 let prop = segs[idx];
468 if (typeof prop === 'number') {
469 prop = String(prop);
470 }
471
472 while (prop && prop.slice(-1) === '\\') {
473 prop = join([prop.slice(0, -1), segs[++idx] || ''], joinChar, options);
474 }
475
476 if (prop in target) {
477 if (!isValid(prop, target, options)) {
478 return options.default;
479 }
480
481 target = target[prop];
482 } else {
483 let hasProp = false;
484 let n = idx + 1;
485
486 while (n < len) {
487 prop = join([prop, segs[n++]], joinChar, options);
488
489 if ((hasProp = prop in target)) {
490 if (!isValid(prop, target, options)) {
491 return options.default;
492 }
493
494 target = target[prop];
495 idx = n - 1;
496 break;
497 }
498 }
499
500 if (!hasProp) {
501 return options.default;
502 }
503 }
504 } while (++idx < len && isValidObject(target));
505
506 if (idx === len) {
507 return target;
508 }
509
510 return options.default;
511 };
512
513 function join(segs, joinChar, options) {
514 if (typeof options.join === 'function') {
515 return options.join(segs);
516 }
517 return segs[0] + joinChar + segs[1];
518 }
519
520 function split(path, splitChar, options) {
521 if (typeof options.split === 'function') {
522 return options.split(path);
523 }
524 return path.split(splitChar);
525 }
526
527 function isValid(key, target, options) {
528 if (typeof options.isValid === 'function') {
529 return options.isValid(key, target);
530 }
531 return true;
532 }
533
534 function isValidObject(val) {
535 return isobject(val) || Array.isArray(val) || typeof val === 'function';
536 }
537
538 var VNode = function VNode() {};
539
540 var options = {};
541
542 var stack = [];
543
544 var EMPTY_CHILDREN = [];
545
546 function h(nodeName, attributes) {
547 var children = EMPTY_CHILDREN,
548 lastSimple,
549 child,
550 simple,
551 i;
552 for (i = arguments.length; i-- > 2;) {
553 stack.push(arguments[i]);
554 }
555 if (attributes && attributes.children != null) {
556 if (!stack.length) stack.push(attributes.children);
557 delete attributes.children;
558 }
559 while (stack.length) {
560 if ((child = stack.pop()) && child.pop !== undefined) {
561 for (i = child.length; i--;) {
562 stack.push(child[i]);
563 }
564 } else {
565 if (typeof child === 'boolean') child = null;
566
567 if (simple = typeof nodeName !== 'function') {
568 if (child == null) child = '';else if (typeof child === 'number') child = String(child);else if (typeof child !== 'string') simple = false;
569 }
570
571 if (simple && lastSimple) {
572 children[children.length - 1] += child;
573 } else if (children === EMPTY_CHILDREN) {
574 children = [child];
575 } else {
576 children.push(child);
577 }
578
579 lastSimple = simple;
580 }
581 }
582
583 var p = new VNode();
584 p.nodeName = nodeName;
585 p.children = children;
586 p.attributes = attributes == null ? undefined : attributes;
587 p.key = attributes == null ? undefined : attributes.key;
588
589 return p;
590 }
591
592 function extend(obj, props) {
593 for (var i in props) {
594 obj[i] = props[i];
595 }return obj;
596 }
597
598 function applyRef(ref, value) {
599 if (ref) {
600 if (typeof ref == 'function') ref(value);else ref.current = value;
601 }
602 }
603
604 var defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;
605
606 function cloneElement(vnode, props) {
607 return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);
608 }
609
610 var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
611
612 var items = [];
613
614 function enqueueRender(component) {
615 if (!component._dirty && (component._dirty = true) && items.push(component) == 1) {
616 ( defer)(rerender);
617 }
618 }
619
620 function rerender() {
621 var p;
622 while (p = items.pop()) {
623 if (p._dirty) renderComponent(p);
624 }
625 }
626
627 function isSameNodeType(node, vnode, hydrating) {
628 if (typeof vnode === 'string' || typeof vnode === 'number') {
629 return node.splitText !== undefined;
630 }
631 if (typeof vnode.nodeName === 'string') {
632 return !node._componentConstructor && isNamedNode(node, vnode.nodeName);
633 }
634 return hydrating || node._componentConstructor === vnode.nodeName;
635 }
636
637 function isNamedNode(node, nodeName) {
638 return node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();
639 }
640
641 function getNodeProps(vnode) {
642 var props = extend({}, vnode.attributes);
643 props.children = vnode.children;
644
645 var defaultProps = vnode.nodeName.defaultProps;
646 if (defaultProps !== undefined) {
647 for (var i in defaultProps) {
648 if (props[i] === undefined) {
649 props[i] = defaultProps[i];
650 }
651 }
652 }
653
654 return props;
655 }
656
657 function createNode(nodeName, isSvg) {
658 var node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);
659 node.normalizedNodeName = nodeName;
660 return node;
661 }
662
663 function removeNode(node) {
664 var parentNode = node.parentNode;
665 if (parentNode) parentNode.removeChild(node);
666 }
667
668 function setAccessor(node, name, old, value, isSvg) {
669 if (name === 'className') name = 'class';
670
671 if (name === 'key') ; else if (name === 'ref') {
672 applyRef(old, null);
673 applyRef(value, node);
674 } else if (name === 'class' && !isSvg) {
675 node.className = value || '';
676 } else if (name === 'style') {
677 if (!value || typeof value === 'string' || typeof old === 'string') {
678 node.style.cssText = value || '';
679 }
680 if (value && typeof value === 'object') {
681 if (typeof old !== 'string') {
682 for (var i in old) {
683 if (!(i in value)) node.style[i] = '';
684 }
685 }
686 for (var i in value) {
687 node.style[i] = typeof value[i] === 'number' && IS_NON_DIMENSIONAL.test(i) === false ? value[i] + 'px' : value[i];
688 }
689 }
690 } else if (name === 'dangerouslySetInnerHTML') {
691 if (value) node.innerHTML = value.__html || '';
692 } else if (name[0] == 'o' && name[1] == 'n') {
693 var useCapture = name !== (name = name.replace(/Capture$/, ''));
694 name = name.toLowerCase().substring(2);
695 if (value) {
696 if (!old) node.addEventListener(name, eventProxy, useCapture);
697 } else {
698 node.removeEventListener(name, eventProxy, useCapture);
699 }
700 (node._listeners || (node._listeners = {}))[name] = value;
701 } else if (name !== 'list' && name !== 'type' && !isSvg && name in node) {
702 try {
703 node[name] = value == null ? '' : value;
704 } catch (e) {}
705 if ((value == null || value === false) && name != 'spellcheck') node.removeAttribute(name);
706 } else {
707 var ns = isSvg && name !== (name = name.replace(/^xlink:?/, ''));
708
709 if (value == null || value === false) {
710 if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);
711 } else if (typeof value !== 'function') {
712 if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);else node.setAttribute(name, value);
713 }
714 }
715 }
716
717 function eventProxy(e) {
718 return this._listeners[e.type]( e);
719 }
720
721 var mounts = [];
722
723 var diffLevel = 0;
724
725 var isSvgMode = false;
726
727 var hydrating = false;
728
729 function flushMounts() {
730 var c;
731 while (c = mounts.shift()) {
732 if (c.componentDidMount) c.componentDidMount();
733 }
734 }
735
736 function diff(dom, vnode, context, mountAll, parent, componentRoot) {
737 if (!diffLevel++) {
738 isSvgMode = parent != null && parent.ownerSVGElement !== undefined;
739
740 hydrating = dom != null && !('__preactattr_' in dom);
741 }
742
743 var ret = idiff(dom, vnode, context, mountAll, componentRoot);
744
745 if (parent && ret.parentNode !== parent) parent.appendChild(ret);
746
747 if (! --diffLevel) {
748 hydrating = false;
749
750 if (!componentRoot) flushMounts();
751 }
752
753 return ret;
754 }
755
756 function idiff(dom, vnode, context, mountAll, componentRoot) {
757 var out = dom,
758 prevSvgMode = isSvgMode;
759
760 if (vnode == null || typeof vnode === 'boolean') vnode = '';
761
762 if (typeof vnode === 'string' || typeof vnode === 'number') {
763 if (dom && dom.splitText !== undefined && dom.parentNode && (!dom._component || componentRoot)) {
764 if (dom.nodeValue != vnode) {
765 dom.nodeValue = vnode;
766 }
767 } else {
768 out = document.createTextNode(vnode);
769 if (dom) {
770 if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
771 recollectNodeTree(dom, true);
772 }
773 }
774
775 out['__preactattr_'] = true;
776
777 return out;
778 }
779
780 var vnodeName = vnode.nodeName;
781 if (typeof vnodeName === 'function') {
782 return buildComponentFromVNode(dom, vnode, context, mountAll);
783 }
784
785 isSvgMode = vnodeName === 'svg' ? true : vnodeName === 'foreignObject' ? false : isSvgMode;
786
787 vnodeName = String(vnodeName);
788 if (!dom || !isNamedNode(dom, vnodeName)) {
789 out = createNode(vnodeName, isSvgMode);
790
791 if (dom) {
792 while (dom.firstChild) {
793 out.appendChild(dom.firstChild);
794 }
795 if (dom.parentNode) dom.parentNode.replaceChild(out, dom);
796
797 recollectNodeTree(dom, true);
798 }
799 }
800
801 var fc = out.firstChild,
802 props = out['__preactattr_'],
803 vchildren = vnode.children;
804
805 if (props == null) {
806 props = out['__preactattr_'] = {};
807 for (var a = out.attributes, i = a.length; i--;) {
808 props[a[i].name] = a[i].value;
809 }
810 }
811
812 if (!hydrating && vchildren && vchildren.length === 1 && typeof vchildren[0] === 'string' && fc != null && fc.splitText !== undefined && fc.nextSibling == null) {
813 if (fc.nodeValue != vchildren[0]) {
814 fc.nodeValue = vchildren[0];
815 }
816 } else if (vchildren && vchildren.length || fc != null) {
817 innerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML != null);
818 }
819
820 diffAttributes(out, vnode.attributes, props);
821
822 isSvgMode = prevSvgMode;
823
824 return out;
825 }
826
827 function innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {
828 var originalChildren = dom.childNodes,
829 children = [],
830 keyed = {},
831 keyedLen = 0,
832 min = 0,
833 len = originalChildren.length,
834 childrenLen = 0,
835 vlen = vchildren ? vchildren.length : 0,
836 j,
837 c,
838 f,
839 vchild,
840 child;
841
842 if (len !== 0) {
843 for (var i = 0; i < len; i++) {
844 var _child = originalChildren[i],
845 props = _child['__preactattr_'],
846 key = vlen && props ? _child._component ? _child._component.__key : props.key : null;
847 if (key != null) {
848 keyedLen++;
849 keyed[key] = _child;
850 } else if (props || (_child.splitText !== undefined ? isHydrating ? _child.nodeValue.trim() : true : isHydrating)) {
851 children[childrenLen++] = _child;
852 }
853 }
854 }
855
856 if (vlen !== 0) {
857 for (var i = 0; i < vlen; i++) {
858 vchild = vchildren[i];
859 child = null;
860
861 var key = vchild.key;
862 if (key != null) {
863 if (keyedLen && keyed[key] !== undefined) {
864 child = keyed[key];
865 keyed[key] = undefined;
866 keyedLen--;
867 }
868 } else if (min < childrenLen) {
869 for (j = min; j < childrenLen; j++) {
870 if (children[j] !== undefined && isSameNodeType(c = children[j], vchild, isHydrating)) {
871 child = c;
872 children[j] = undefined;
873 if (j === childrenLen - 1) childrenLen--;
874 if (j === min) min++;
875 break;
876 }
877 }
878 }
879
880 child = idiff(child, vchild, context, mountAll);
881
882 f = originalChildren[i];
883 if (child && child !== dom && child !== f) {
884 if (f == null) {
885 dom.appendChild(child);
886 } else if (child === f.nextSibling) {
887 removeNode(f);
888 } else {
889 dom.insertBefore(child, f);
890 }
891 }
892 }
893 }
894
895 if (keyedLen) {
896 for (var i in keyed) {
897 if (keyed[i] !== undefined) recollectNodeTree(keyed[i], false);
898 }
899 }
900
901 while (min <= childrenLen) {
902 if ((child = children[childrenLen--]) !== undefined) recollectNodeTree(child, false);
903 }
904 }
905
906 function recollectNodeTree(node, unmountOnly) {
907 var component = node._component;
908 if (component) {
909 unmountComponent(component);
910 } else {
911 if (node['__preactattr_'] != null) applyRef(node['__preactattr_'].ref, null);
912
913 if (unmountOnly === false || node['__preactattr_'] == null) {
914 removeNode(node);
915 }
916
917 removeChildren(node);
918 }
919 }
920
921 function removeChildren(node) {
922 node = node.lastChild;
923 while (node) {
924 var next = node.previousSibling;
925 recollectNodeTree(node, true);
926 node = next;
927 }
928 }
929
930 function diffAttributes(dom, attrs, old) {
931 var name;
932
933 for (name in old) {
934 if (!(attrs && attrs[name] != null) && old[name] != null) {
935 setAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);
936 }
937 }
938
939 for (name in attrs) {
940 if (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {
941 setAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);
942 }
943 }
944 }
945
946 var recyclerComponents = [];
947
948 function createComponent(Ctor, props, context) {
949 var inst,
950 i = recyclerComponents.length;
951
952 if (Ctor.prototype && Ctor.prototype.render) {
953 inst = new Ctor(props, context);
954 Component.call(inst, props, context);
955 } else {
956 inst = new Component(props, context);
957 inst.constructor = Ctor;
958 inst.render = doRender;
959 }
960
961 while (i--) {
962 if (recyclerComponents[i].constructor === Ctor) {
963 inst.nextBase = recyclerComponents[i].nextBase;
964 recyclerComponents.splice(i, 1);
965 return inst;
966 }
967 }
968
969 return inst;
970 }
971
972 function doRender(props, state, context) {
973 return this.constructor(props, context);
974 }
975
976 function setComponentProps(component, props, renderMode, context, mountAll) {
977 if (component._disable) return;
978 component._disable = true;
979
980 component.__ref = props.ref;
981 component.__key = props.key;
982 delete props.ref;
983 delete props.key;
984
985 if (typeof component.constructor.getDerivedStateFromProps === 'undefined') {
986 if (!component.base || mountAll) {
987 if (component.componentWillMount) component.componentWillMount();
988 } else if (component.componentWillReceiveProps) {
989 component.componentWillReceiveProps(props, context);
990 }
991 }
992
993 if (context && context !== component.context) {
994 if (!component.prevContext) component.prevContext = component.context;
995 component.context = context;
996 }
997
998 if (!component.prevProps) component.prevProps = component.props;
999 component.props = props;
1000
1001 component._disable = false;
1002
1003 if (renderMode !== 0) {
1004 if (renderMode === 1 || options.syncComponentUpdates !== false || !component.base) {
1005 renderComponent(component, 1, mountAll);
1006 } else {
1007 enqueueRender(component);
1008 }
1009 }
1010
1011 applyRef(component.__ref, component);
1012 }
1013
1014 function renderComponent(component, renderMode, mountAll, isChild) {
1015 if (component._disable) return;
1016
1017 var props = component.props,
1018 state = component.state,
1019 context = component.context,
1020 previousProps = component.prevProps || props,
1021 previousState = component.prevState || state,
1022 previousContext = component.prevContext || context,
1023 isUpdate = component.base,
1024 nextBase = component.nextBase,
1025 initialBase = isUpdate || nextBase,
1026 initialChildComponent = component._component,
1027 skip = false,
1028 snapshot = previousContext,
1029 rendered,
1030 inst,
1031 cbase;
1032
1033 if (component.constructor.getDerivedStateFromProps) {
1034 state = extend(extend({}, state), component.constructor.getDerivedStateFromProps(props, state));
1035 component.state = state;
1036 }
1037
1038 if (isUpdate) {
1039 component.props = previousProps;
1040 component.state = previousState;
1041 component.context = previousContext;
1042 if (renderMode !== 2 && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === false) {
1043 skip = true;
1044 } else if (component.componentWillUpdate) {
1045 component.componentWillUpdate(props, state, context);
1046 }
1047 component.props = props;
1048 component.state = state;
1049 component.context = context;
1050 }
1051
1052 component.prevProps = component.prevState = component.prevContext = component.nextBase = null;
1053 component._dirty = false;
1054
1055 if (!skip) {
1056 rendered = component.render(props, state, context);
1057
1058 if (component.getChildContext) {
1059 context = extend(extend({}, context), component.getChildContext());
1060 }
1061
1062 if (isUpdate && component.getSnapshotBeforeUpdate) {
1063 snapshot = component.getSnapshotBeforeUpdate(previousProps, previousState);
1064 }
1065
1066 var childComponent = rendered && rendered.nodeName,
1067 toUnmount,
1068 base;
1069
1070 if (typeof childComponent === 'function') {
1071
1072 var childProps = getNodeProps(rendered);
1073 inst = initialChildComponent;
1074
1075 if (inst && inst.constructor === childComponent && childProps.key == inst.__key) {
1076 setComponentProps(inst, childProps, 1, context, false);
1077 } else {
1078 toUnmount = inst;
1079
1080 component._component = inst = createComponent(childComponent, childProps, context);
1081 inst.nextBase = inst.nextBase || nextBase;
1082 inst._parentComponent = component;
1083 setComponentProps(inst, childProps, 0, context, false);
1084 renderComponent(inst, 1, mountAll, true);
1085 }
1086
1087 base = inst.base;
1088 } else {
1089 cbase = initialBase;
1090
1091 toUnmount = initialChildComponent;
1092 if (toUnmount) {
1093 cbase = component._component = null;
1094 }
1095
1096 if (initialBase || renderMode === 1) {
1097 if (cbase) cbase._component = null;
1098 base = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, true);
1099 }
1100 }
1101
1102 if (initialBase && base !== initialBase && inst !== initialChildComponent) {
1103 var baseParent = initialBase.parentNode;
1104 if (baseParent && base !== baseParent) {
1105 baseParent.replaceChild(base, initialBase);
1106
1107 if (!toUnmount) {
1108 initialBase._component = null;
1109 recollectNodeTree(initialBase, false);
1110 }
1111 }
1112 }
1113
1114 if (toUnmount) {
1115 unmountComponent(toUnmount);
1116 }
1117
1118 component.base = base;
1119 if (base && !isChild) {
1120 var componentRef = component,
1121 t = component;
1122 while (t = t._parentComponent) {
1123 (componentRef = t).base = base;
1124 }
1125 base._component = componentRef;
1126 base._componentConstructor = componentRef.constructor;
1127 }
1128 }
1129
1130 if (!isUpdate || mountAll) {
1131 mounts.push(component);
1132 } else if (!skip) {
1133
1134 if (component.componentDidUpdate) {
1135 component.componentDidUpdate(previousProps, previousState, snapshot);
1136 }
1137 }
1138
1139 while (component._renderCallbacks.length) {
1140 component._renderCallbacks.pop().call(component);
1141 }if (!diffLevel && !isChild) flushMounts();
1142 }
1143
1144 function buildComponentFromVNode(dom, vnode, context, mountAll) {
1145 var c = dom && dom._component,
1146 originalComponent = c,
1147 oldDom = dom,
1148 isDirectOwner = c && dom._componentConstructor === vnode.nodeName,
1149 isOwner = isDirectOwner,
1150 props = getNodeProps(vnode);
1151 while (c && !isOwner && (c = c._parentComponent)) {
1152 isOwner = c.constructor === vnode.nodeName;
1153 }
1154
1155 if (c && isOwner && (!mountAll || c._component)) {
1156 setComponentProps(c, props, 3, context, mountAll);
1157 dom = c.base;
1158 } else {
1159 if (originalComponent && !isDirectOwner) {
1160 unmountComponent(originalComponent);
1161 dom = oldDom = null;
1162 }
1163
1164 c = createComponent(vnode.nodeName, props, context);
1165 if (dom && !c.nextBase) {
1166 c.nextBase = dom;
1167
1168 oldDom = null;
1169 }
1170 setComponentProps(c, props, 1, context, mountAll);
1171 dom = c.base;
1172
1173 if (oldDom && dom !== oldDom) {
1174 oldDom._component = null;
1175 recollectNodeTree(oldDom, false);
1176 }
1177 }
1178
1179 return dom;
1180 }
1181
1182 function unmountComponent(component) {
1183
1184 var base = component.base;
1185
1186 component._disable = true;
1187
1188 if (component.componentWillUnmount) component.componentWillUnmount();
1189
1190 component.base = null;
1191
1192 var inner = component._component;
1193 if (inner) {
1194 unmountComponent(inner);
1195 } else if (base) {
1196 if (base['__preactattr_'] != null) applyRef(base['__preactattr_'].ref, null);
1197
1198 component.nextBase = base;
1199
1200 removeNode(base);
1201 recyclerComponents.push(component);
1202
1203 removeChildren(base);
1204 }
1205
1206 applyRef(component.__ref, null);
1207 }
1208
1209 function Component(props, context) {
1210 this._dirty = true;
1211
1212 this.context = context;
1213
1214 this.props = props;
1215
1216 this.state = this.state || {};
1217
1218 this._renderCallbacks = [];
1219 }
1220
1221 extend(Component.prototype, {
1222 setState: function setState(state, callback) {
1223 if (!this.prevState) this.prevState = this.state;
1224 this.state = extend(extend({}, this.state), typeof state === 'function' ? state(this.state, this.props) : state);
1225 if (callback) this._renderCallbacks.push(callback);
1226 enqueueRender(this);
1227 },
1228 forceUpdate: function forceUpdate(callback) {
1229 if (callback) this._renderCallbacks.push(callback);
1230 renderComponent(this, 2);
1231 },
1232 render: function render() {}
1233 });
1234
1235 function render(vnode, parent, merge) {
1236 return diff(merge, vnode, {}, false, parent, false);
1237 }
1238
1239 function createRef() {
1240 return {};
1241 }
1242
1243 var preact = {
1244 h: h,
1245 createElement: h,
1246 cloneElement: cloneElement,
1247 createRef: createRef,
1248 Component: Component,
1249 render: render,
1250 rerender: rerender,
1251 options: options
1252 };
1253
1254 /**
1255 * Checks if `value` is classified as an `HTMLElement`.
1256 * @param {*} value The param to check if it is an HTMLElement
1257 */
1258 function isElement(value) {
1259 return value instanceof HTMLElement;
1260 }
1261 /**
1262 * Checks if `value` is classified as a `Function` object.
1263 * @param {*} value The param to check if it is a function
1264 */
1265
1266 function isFunction(value) {
1267 return typeof value === 'function';
1268 }
1269 /**
1270 * Checks if `value` is classified as a `String` object.
1271 * @param {*} value The param to check if it is a string
1272 */
1273
1274 function isString(value) {
1275 return typeof value === 'string';
1276 }
1277 /**
1278 * Checks if `value` is undefined.
1279 * @param {*} value The param to check if it is undefined
1280 */
1281
1282 function isUndefined(value) {
1283 return value === undefined;
1284 }
1285
1286 var Evented =
1287 /*#__PURE__*/
1288 function () {
1289 function Evented() {}
1290
1291 var _proto = Evented.prototype;
1292
1293 _proto.on = function on(event, handler, ctx) {
1294 var once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];
1295
1296 if (isUndefined(this.bindings)) {
1297 this.bindings = {};
1298 }
1299
1300 if (isUndefined(this.bindings[event])) {
1301 this.bindings[event] = [];
1302 }
1303
1304 this.bindings[event].push({
1305 handler: handler,
1306 ctx: ctx,
1307 once: once
1308 });
1309 };
1310
1311 _proto.once = function once(event, handler, ctx) {
1312 this.on(event, handler, ctx, true);
1313 };
1314
1315 _proto.off = function off(event, handler) {
1316 var _this = this;
1317
1318 if (isUndefined(this.bindings) || isUndefined(this.bindings[event])) {
1319 return false;
1320 }
1321
1322 if (isUndefined(handler)) {
1323 delete this.bindings[event];
1324 } else {
1325 this.bindings[event].forEach(function (binding, index) {
1326 if (binding.handler === handler) {
1327 _this.bindings[event].splice(index, 1);
1328 }
1329 });
1330 }
1331 };
1332
1333 _proto.trigger = function trigger(event) {
1334 var _this2 = this;
1335
1336 if (!isUndefined(this.bindings) && this.bindings[event]) {
1337 var args = Array.prototype.slice.call(arguments, 1);
1338 this.bindings[event].forEach(function (binding, index) {
1339 var ctx = binding.ctx,
1340 handler = binding.handler,
1341 once = binding.once;
1342 var context = ctx || _this2;
1343 handler.apply(context, args);
1344
1345 if (once) {
1346 _this2.bindings[event].splice(index, 1);
1347 }
1348 });
1349 }
1350 };
1351
1352 return Evented;
1353 }();
1354
1355 /**
1356 * Binds all the methods on a JS Class to the `this` context of the class.
1357 * Adapted from https://github.com/sindresorhus/auto-bind
1358 * @param {object} self The `this` context of the class
1359 * @return {object} The `this` context of the class
1360 */
1361 function autoBind(self) {
1362 var keys = Object.getOwnPropertyNames(self.constructor.prototype);
1363
1364 for (var i = 0; i < keys.length; i++) {
1365 var key = keys[i];
1366 var val = self[key];
1367
1368 if (key !== 'constructor' && typeof val === 'function') {
1369 self[key] = val.bind(self);
1370 }
1371 }
1372
1373 return self;
1374 }
1375
1376 /**
1377 * Sets up the handler to determine if we should advance the tour
1378 * @param {string} selector
1379 * @param {Step} step The step instance
1380 * @return {Function}
1381 * @private
1382 */
1383
1384 function _setupAdvanceOnHandler(selector, step) {
1385 return function (event) {
1386 if (step.isOpen()) {
1387 var targetIsEl = step.el && event.currentTarget === step.el;
1388 var targetIsSelector = !isUndefined(selector) && event.currentTarget.matches(selector);
1389
1390 if (targetIsSelector || targetIsEl) {
1391 step.tour.next();
1392 }
1393 }
1394 };
1395 }
1396 /**
1397 * Bind the event handler for advanceOn
1398 * @param {Step} step The step instance
1399 */
1400
1401
1402 function bindAdvance(step) {
1403 // An empty selector matches the step element
1404 var _ref = step.options.advanceOn || {},
1405 event = _ref.event,
1406 selector = _ref.selector;
1407
1408 if (event) {
1409 var handler = _setupAdvanceOnHandler(selector, step); // TODO: this should also bind/unbind on show/hide
1410
1411
1412 var el;
1413
1414 try {
1415 el = document.querySelector(selector);
1416 } catch (e) {// TODO
1417 }
1418
1419 if (!isUndefined(selector) && !el) {
1420 return console.error("No element was found for the selector supplied to advanceOn: " + selector);
1421 } else if (el) {
1422 el.addEventListener(event, handler);
1423 step.on('destroy', function () {
1424 return el.removeEventListener(event, handler);
1425 });
1426 } else {
1427 document.body.addEventListener(event, handler, true);
1428 step.on('destroy', function () {
1429 return document.body.removeEventListener(event, handler, true);
1430 });
1431 }
1432 } else {
1433 return console.error('advanceOn was defined, but no event name was passed.');
1434 }
1435 }
1436
1437 var addHasTitleClass = function addHasTitleClass(step) {
1438 return {
1439 addHasTitleClass: _createClassModifier(step.classPrefix + "shepherd-has-title")
1440 };
1441 };
1442 /**
1443 * Create a popper modifier for adding the passed className to the popper
1444 * @param {string} className The class to add to the popper
1445 * @return {{fn(*): *, enabled: boolean}|*}
1446 * @private
1447 */
1448
1449
1450 function _createClassModifier(className) {
1451 return {
1452 enabled: true,
1453 fn: function fn(data) {
1454 data.instance.popper.classList.add(className);
1455 return data;
1456 }
1457 };
1458 }
1459
1460 function _getCenteredStylePopperModifier(styles) {
1461 return {
1462 computeStyle: {
1463 enabled: true,
1464 fn: function fn(data) {
1465 data.styles = _extends({}, data.styles, {
1466 left: '50%',
1467 top: '50%',
1468 transform: 'translate(-50%, -50%)'
1469 });
1470 return data;
1471 }
1472 },
1473 addShepherdClass: _createClassModifier(styles.shepherd.trim())
1474 };
1475 }
1476 /**
1477 * Used to compose settings for tippyOptions.popperOptions (https://atomiks.github.io/tippyjs/#popper-options-option)
1478 * @private
1479 */
1480
1481
1482 function _getDefaultPopperOptions(styles) {
1483 return {
1484 positionFixed: true,
1485 modifiers: {
1486 addShepherdClass: _createClassModifier(styles.shepherd.trim())
1487 }
1488 };
1489 }
1490 /**
1491 * Generates the hash of options that will be passed to `Tippy` instances
1492 * target an element in the DOM.
1493 *
1494 * @param {Object} attachToOptions The local `attachTo` options
1495 * @param {Step} step The step instance
1496 * @return {Object} The final tippy options object
1497 */
1498
1499
1500 function makeAttachedTippyOptions(attachToOptions, step) {
1501 var _makeCommonTippyOptio = _makeCommonTippyOptions(step),
1502 popperOptions = _makeCommonTippyOptio.popperOptions,
1503 tippyOptions = _makeCommonTippyOptio.tippyOptions;
1504
1505 tippyOptions.flipOnUpdate = true;
1506 tippyOptions.placement = attachToOptions.on || 'right';
1507 var stepPopperOptions = getValue(step, 'options.tippyOptions.popperOptions');
1508
1509 if (stepPopperOptions) {
1510 popperOptions = _extends({}, popperOptions, {}, stepPopperOptions, {
1511 modifiers: _extends({}, popperOptions.modifiers, {}, stepPopperOptions.modifiers)
1512 });
1513 }
1514
1515 tippyOptions.popperOptions = popperOptions;
1516 return tippyOptions;
1517 }
1518 /**
1519 * Generates the hash of options for a tooltip that doesn't have a
1520 * target element in the DOM -- and thus is positioned in the center
1521 * of the view
1522 *
1523 * @param {Step} step The step instance
1524 * @return {Object} The final tippy options object
1525 */
1526
1527 function makeCenteredTippy(step) {
1528 var centeredStylePopperModifier = _getCenteredStylePopperModifier(step.styles);
1529
1530 var _makeCommonTippyOptio2 = _makeCommonTippyOptions(step),
1531 popperOptions = _makeCommonTippyOptio2.popperOptions,
1532 tippyOptions = _makeCommonTippyOptio2.tippyOptions;
1533
1534 tippyOptions.placement = 'top';
1535 tippyOptions.arrow = false;
1536 tippyOptions.popperOptions = tippyOptions.popperOptions || {};
1537 popperOptions = _extends({}, popperOptions, {}, tippyOptions.popperOptions, {
1538 modifiers: _extends({}, popperOptions.modifiers, {}, centeredStylePopperModifier, {}, tippyOptions.popperOptions.modifiers)
1539 });
1540 tippyOptions.popperOptions = popperOptions;
1541 return tippyOptions;
1542 }
1543
1544 function _makeCommonTippyOptions(step) {
1545 var popperOptions = _getDefaultPopperOptions(step.styles);
1546
1547 var tippyOptions = _extends({
1548 content: step.el
1549 }, step.options.tippyOptions);
1550
1551 var shepherdElementZIndex = getValue(step, 'tour.options.styleVariables.shepherdElementZIndex');
1552
1553 if (shepherdElementZIndex) {
1554 tippyOptions.zIndex = shepherdElementZIndex;
1555 }
1556
1557 if (step.options.title) {
1558 popperOptions.modifiers = _extends({}, popperOptions.modifiers, {}, addHasTitleClass(step));
1559 }
1560
1561 return {
1562 popperOptions: popperOptions,
1563 tippyOptions: tippyOptions
1564 };
1565 }
1566
1567 /**!
1568 * tippy.js v5.0.0-beta.1
1569 * (c) 2017-2019 atomiks
1570 * MIT License
1571 */
1572 function _extends$1() {
1573 _extends$1 = Object.assign || function (target) {
1574 for (var i = 1; i < arguments.length; i++) {
1575 var source = arguments[i];
1576
1577 for (var key in source) {
1578 if (Object.prototype.hasOwnProperty.call(source, key)) {
1579 target[key] = source[key];
1580 }
1581 }
1582 }
1583
1584 return target;
1585 };
1586
1587 return _extends$1.apply(this, arguments);
1588 }
1589
1590 var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
1591 var ua = isBrowser ? navigator.userAgent : '';
1592 var isIE = /MSIE |Trident\//.test(ua);
1593 var isUCBrowser = /UCBrowser\//.test(ua);
1594 var isIOS = isBrowser && /iPhone|iPad|iPod/.test(navigator.platform);
1595
1596 var defaultProps = {
1597 allowHTML: true,
1598 animateFill: false,
1599 animation: 'fade',
1600 appendTo: function appendTo() {
1601 return document.body;
1602 },
1603 aria: 'describedby',
1604 arrow: true,
1605 boundary: 'scrollParent',
1606 content: '',
1607 delay: 0,
1608 distance: 10,
1609 duration: [325, 275],
1610 flip: true,
1611 flipBehavior: 'flip',
1612 flipOnUpdate: false,
1613 followCursor: false,
1614 hideOnClick: true,
1615 ignoreAttributes: false,
1616 inertia: false,
1617 interactive: false,
1618 interactiveBorder: 2,
1619 interactiveDebounce: 0,
1620 lazy: true,
1621 maxWidth: 750, // TODO: Dunno.
1622 multiple: false,
1623 offset: 0,
1624 onCreate: function onCreate() {},
1625 onHidden: function onHidden() {},
1626 onHide: function onHide() {},
1627 onMount: function onMount() {},
1628 onShow: function onShow() {},
1629 onShown: function onShown() {},
1630 onTrigger: function onTrigger() {},
1631 onUntrigger: function onUntrigger() {},
1632 placement: 'top',
1633 popperOptions: {},
1634 role: 'tooltip',
1635 showOnCreate: false,
1636 sticky: false,
1637 theme: '',
1638 touch: true,
1639 trigger: 'mouseenter focus',
1640 triggerTarget: null,
1641 updateDuration: 0,
1642 zIndex: 999901
1643 /**
1644 * If the setProps() method encounters one of these, the popperInstance must be
1645 * recreated
1646 */
1647
1648 };
1649 var POPPER_INSTANCE_DEPENDENCIES = ['arrow', 'boundary', 'distance', 'flip', 'flipBehavior', 'flipOnUpdate', 'offset', 'placement', 'popperOptions'];
1650
1651 var PASSIVE = {
1652 passive: true
1653 };
1654 var PREVENT_OVERFLOW_PADDING = 5;
1655 var ROUND_ARROW_INNER_HTML = '<svg viewBox="0 0 18 7" xmlns="http://www.w3.org/2000/svg"><path d="M0 7s2.021-.015 5.253-4.218C6.584 1.051 7.797.007 9 0c1.203-.007 2.416 1.035 3.761 2.782C16.012 7.005 18 7 18 7H0z"/></svg>';
1656 var IOS_CLASS = "tippy-iOS";
1657 var POPPER_CLASS = "tippy-popper";
1658 var TOOLTIP_CLASS = "tippy-tooltip";
1659 var CONTENT_CLASS = "tippy-content";
1660 var BACKDROP_CLASS = "tippy-backdrop";
1661 var ARROW_CLASS = "tippy-arrow";
1662 var SVG_ARROW_CLASS = "tippy-svg-arrow";
1663 var POPPER_SELECTOR = "." + POPPER_CLASS;
1664 var TOOLTIP_SELECTOR = "." + TOOLTIP_CLASS;
1665 var CONTENT_SELECTOR = "." + CONTENT_CLASS;
1666 var BACKDROP_SELECTOR = "." + BACKDROP_CLASS;
1667 var ARROW_SELECTOR = "." + ARROW_CLASS;
1668 var SVG_ARROW_SELECTOR = "." + SVG_ARROW_CLASS; // TODO: Work out best way to make these updateable
1669
1670 var currentInput = {
1671 isTouch: false
1672 };
1673 var lastMouseMoveTime = 0;
1674 /**
1675 * When a `touchstart` event is fired, it's assumed the user is using touch
1676 * input. We'll bind a `mousemove` event listener to listen for mouse input in
1677 * the future. This way, the `isTouch` property is fully dynamic and will handle
1678 * hybrid devices that use a mix of touch + mouse input.
1679 */
1680
1681 function onDocumentTouchStart() {
1682 if (currentInput.isTouch) {
1683 return;
1684 }
1685
1686 currentInput.isTouch = true;
1687
1688 if (isIOS) {
1689 document.body.classList.add(IOS_CLASS);
1690 }
1691
1692 if (window.performance) {
1693 document.addEventListener('mousemove', onDocumentMouseMove);
1694 }
1695 }
1696 /**
1697 * When two `mousemove` event are fired consecutively within 20ms, it's assumed
1698 * the user is using mouse input again. `mousemove` can fire on touch devices as
1699 * well, but very rarely that quickly.
1700 */
1701
1702 function onDocumentMouseMove() {
1703 var now = performance.now();
1704
1705 if (now - lastMouseMoveTime < 20) {
1706 currentInput.isTouch = false;
1707 document.removeEventListener('mousemove', onDocumentMouseMove);
1708
1709 if (!isIOS) {
1710 document.body.classList.remove(IOS_CLASS);
1711 }
1712 }
1713
1714 lastMouseMoveTime = now;
1715 }
1716 /**
1717 * When an element is in focus and has a tippy, leaving the tab/window and
1718 * returning causes it to show again. For mouse users this is unexpected, but
1719 * for keyboard use it makes sense.
1720 * TODO: find a better technique to solve this problem
1721 */
1722
1723 function onWindowBlur() {
1724 var _document = document,
1725 activeElement = _document.activeElement;
1726 var instance = activeElement._tippy;
1727
1728 if (activeElement && activeElement.blur && instance && !instance.state.isVisible) {
1729 activeElement.blur();
1730 }
1731 }
1732 /**
1733 * Adds the needed global event listeners
1734 */
1735
1736 function bindGlobalEventListeners() {
1737 document.addEventListener('touchstart', onDocumentTouchStart, _extends$1({}, PASSIVE, {
1738 capture: true
1739 }));
1740 window.addEventListener('blur', onWindowBlur);
1741 }
1742
1743 var keys$2 = Object.keys(defaultProps);
1744 /**
1745 * Returns an object of optional props from data-tippy-* attributes
1746 */
1747
1748 function getDataAttributeProps(reference) {
1749 var props = keys$2.reduce(function (acc, key) {
1750 var valueAsString = (reference.getAttribute("data-tippy-" + key) || '').trim();
1751
1752 if (!valueAsString) {
1753 return acc;
1754 }
1755
1756 if (key === 'content') {
1757 acc[key] = valueAsString;
1758 } else {
1759 try {
1760 acc[key] = JSON.parse(valueAsString);
1761 } catch (e) {
1762 acc[key] = valueAsString;
1763 }
1764 }
1765
1766 return acc;
1767 }, {});
1768 return props;
1769 }
1770
1771 /**
1772 * Determines if the value is a reference element
1773 */
1774
1775 function isReferenceElement(value) {
1776 return !!(value && value._tippy && !value.classList.contains(POPPER_CLASS));
1777 }
1778 /**
1779 * Safe .hasOwnProperty check, for prototype-less objects
1780 */
1781
1782 function hasOwnProperty$1(obj, key) {
1783 return {}.hasOwnProperty.call(obj, key);
1784 }
1785 /**
1786 * Returns an array of elements based on the value
1787 */
1788
1789 function getArrayOfElements(value) {
1790 if (isRealElement(value)) {
1791 return [value];
1792 }
1793
1794 if (value instanceof NodeList) {
1795 return arrayFrom(value);
1796 }
1797
1798 if (Array.isArray(value)) {
1799 return value;
1800 }
1801
1802 return arrayFrom(document.querySelectorAll(value));
1803 }
1804 /**
1805 * Returns a value at a given index depending on if it's an array or number
1806 */
1807
1808 function getValueAtIndexOrReturn(value, index, defaultValue) {
1809 if (Array.isArray(value)) {
1810 var v = value[index];
1811 return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
1812 }
1813
1814 return value;
1815 }
1816 /**
1817 * Prevents errors from being thrown while accessing nested modifier objects
1818 * in `popperOptions`
1819 */
1820
1821 function getModifier(obj, key) {
1822 return obj && obj.modifiers && obj.modifiers[key];
1823 }
1824 /**
1825 * Determines if the value is a real element
1826 */
1827
1828 function isRealElement(value) {
1829 return value instanceof Element;
1830 }
1831 /**
1832 * Firefox extensions don't allow setting .innerHTML directly, this will trick
1833 * it
1834 */
1835
1836 function innerHTML() {
1837 return 'innerHTML';
1838 }
1839 /**
1840 * Evaluates a function if one, or returns the value
1841 */
1842
1843 function invokeWithArgsOrReturn(value, args) {
1844 return typeof value === 'function' ? value.apply(null, args) : value;
1845 }
1846 /**
1847 * Sets a popperInstance `flip` modifier's enabled state
1848 */
1849
1850 function setFlipModifierEnabled(modifiers, value) {
1851 modifiers.filter(function (m) {
1852 return m.name === 'flip';
1853 })[0].enabled = value;
1854 }
1855 /**
1856 * Returns a new `div` element
1857 */
1858
1859 function div() {
1860 return document.createElement('div');
1861 }
1862 /**
1863 * Applies a transition duration to a list of elements
1864 */
1865
1866 function setTransitionDuration(els, value) {
1867 els.forEach(function (el) {
1868 if (el) {
1869 el.style.transitionDuration = value + "ms";
1870 }
1871 });
1872 }
1873 /**
1874 * Sets the visibility state to elements so they can begin to transition
1875 */
1876
1877 function setVisibilityState(els, state) {
1878 els.forEach(function (el) {
1879 if (el) {
1880 el.setAttribute('data-state', state);
1881 }
1882 });
1883 }
1884 /**
1885 * Evaluates the props object by merging data attributes and disabling
1886 * conflicting props where necessary
1887 */
1888
1889 function evaluateProps(reference, props) {
1890 var out = _extends$1({}, props, {
1891 content: invokeWithArgsOrReturn(props.content, [reference])
1892 }, props.ignoreAttributes ? {} : getDataAttributeProps(reference));
1893
1894 if (out.animateFill) {
1895 out.arrow = false;
1896 }
1897
1898 if (out.arrow || isUCBrowser) {
1899 out.animateFill = false;
1900 }
1901
1902 return out;
1903 }
1904 /**
1905 * Debounce utility. To avoid bloating bundle size, we're only passing 1
1906 * argument here, a more generic function would pass all arguments. Only
1907 * `onMouseMove` uses this which takes the event object for now.
1908 */
1909
1910 function debounce(fn, ms) {
1911 // Avoid wrapping in `setTimeout` if ms is 0 anyway
1912 if (ms === 0) {
1913 return fn;
1914 }
1915
1916 var timeout;
1917 return function (arg) {
1918 clearTimeout(timeout);
1919 timeout = setTimeout(function () {
1920 fn(arg);
1921 }, ms);
1922 };
1923 }
1924 /**
1925 * Preserves the original function invocation when another function replaces it
1926 */
1927
1928 function preserveInvocation(originalFn, currentFn, args) {
1929 if (originalFn && originalFn !== currentFn) {
1930 originalFn.apply(null, args);
1931 }
1932 }
1933 /**
1934 * Ponyfill for Array.from - converts iterable values to an array
1935 */
1936
1937 function arrayFrom(value) {
1938 return [].slice.call(value);
1939 }
1940 /**
1941 * Works like Element.prototype.closest, but uses a callback instead
1942 */
1943
1944 function closestCallback(element, callback) {
1945 while (element) {
1946 if (callback(element)) {
1947 return element;
1948 }
1949
1950 element = element.parentElement;
1951 }
1952
1953 return null;
1954 }
1955 /**
1956 * Determines if an array or string includes a string
1957 */
1958
1959 function includes(a, b) {
1960 return a.indexOf(b) > -1;
1961 }
1962
1963 /**
1964 * Sets the innerHTML of an element
1965 */
1966
1967 function setInnerHTML(element, html) {
1968 element[innerHTML()] = isRealElement(html) ? html[innerHTML()] : html;
1969 }
1970 /**
1971 * Sets the content of a tooltip
1972 */
1973
1974 function setContent(contentEl, props) {
1975 if (isRealElement(props.content)) {
1976 setInnerHTML(contentEl, '');
1977 contentEl.appendChild(props.content);
1978 } else if (typeof props.content !== 'function') {
1979 var key = props.allowHTML ? 'innerHTML' : 'textContent';
1980 contentEl[key] = props.content;
1981 }
1982 }
1983 /**
1984 * Returns the child elements of a popper element
1985 */
1986
1987 function getChildren(popper) {
1988 return {
1989 tooltip: popper.querySelector(TOOLTIP_SELECTOR),
1990 backdrop: popper.querySelector(BACKDROP_SELECTOR),
1991 content: popper.querySelector(CONTENT_SELECTOR),
1992 arrow: popper.querySelector(ARROW_SELECTOR) || popper.querySelector(SVG_ARROW_SELECTOR)
1993 };
1994 }
1995 /**
1996 * Adds `data-inertia` attribute
1997 */
1998
1999 function addInertia(tooltip) {
2000 tooltip.setAttribute('data-inertia', '');
2001 }
2002 /**
2003 * Removes `data-inertia` attribute
2004 */
2005
2006 function removeInertia(tooltip) {
2007 tooltip.removeAttribute('data-inertia');
2008 }
2009 /**
2010 * Creates an arrow element and returns it
2011 */
2012
2013 function createArrowElement(arrow) {
2014 var arrowElement = div();
2015
2016 if (arrow === true) {
2017 arrowElement.className = ARROW_CLASS;
2018 } else {
2019 arrowElement.className = SVG_ARROW_CLASS;
2020
2021 if (isRealElement(arrow)) {
2022 arrowElement.appendChild(arrow);
2023 } else {
2024 setInnerHTML(arrowElement, arrow === 'round' ? ROUND_ARROW_INNER_HTML : arrow);
2025 }
2026 }
2027
2028 return arrowElement;
2029 }
2030 /**
2031 * Creates a backdrop element and returns it
2032 */
2033
2034 function createBackdropElement(isVisible) {
2035 var backdrop = div();
2036 backdrop.className = BACKDROP_CLASS;
2037 backdrop.setAttribute('data-state', isVisible ? 'visible' : 'hidden');
2038 return backdrop;
2039 }
2040 /**
2041 * Adds interactive-related attributes
2042 */
2043
2044 function addInteractive(tooltip) {
2045 tooltip.setAttribute('data-interactive', '');
2046 }
2047 /**
2048 * Removes interactive-related attributes
2049 */
2050
2051 function removeInteractive(tooltip) {
2052 tooltip.removeAttribute('data-interactive');
2053 }
2054 /**
2055 * Add/remove transitionend listener from tooltip
2056 */
2057
2058 function updateTransitionEndListener(tooltip, action, listener) {
2059 var eventName = isUCBrowser && document.body.style.webkitTransition !== undefined ? 'webkitTransitionEnd' : 'transitionend';
2060 tooltip[action + 'EventListener'](eventName, listener);
2061 }
2062 /**
2063 * Returns the popper's placement, ignoring shifting (top-start, etc)
2064 */
2065
2066 function getBasePlacement(placement) {
2067 return placement.split('-')[0];
2068 }
2069 /**
2070 * Triggers reflow
2071 */
2072
2073 function reflow(popper) {
2074 void popper.offsetHeight;
2075 }
2076 /**
2077 * Adds/removes theme from tooltip's classList
2078 */
2079
2080 function updateTheme(tooltip, action, theme) {
2081 theme.split(' ').forEach(function (name) {
2082 if (name) {
2083 tooltip.classList[action](name + "-theme");
2084 }
2085 });
2086 }
2087 /**
2088 * Constructs the popper element and returns it
2089 */
2090
2091 function createPopperElement(id, props) {
2092 var popper = div();
2093 popper.className = POPPER_CLASS;
2094 popper.style.position = 'absolute';
2095 popper.style.top = '0';
2096 popper.style.left = '0';
2097 var tooltip = div();
2098 tooltip.className = TOOLTIP_CLASS;
2099 tooltip.id = "tippy-" + id;
2100 tooltip.setAttribute('data-state', 'hidden');
2101 tooltip.setAttribute('tabindex', '-1');
2102 updateTheme(tooltip, 'add', props.theme);
2103 var content = div();
2104 content.className = CONTENT_CLASS;
2105 content.setAttribute('data-state', 'hidden');
2106
2107 if (props.interactive) {
2108 addInteractive(tooltip);
2109 }
2110
2111 if (props.arrow) {
2112 tooltip.setAttribute('data-arrow', '');
2113 tooltip.appendChild(createArrowElement(props.arrow));
2114 }
2115
2116 if (props.animateFill) {
2117 tooltip.appendChild(createBackdropElement(false));
2118 tooltip.setAttribute('data-animatefill', '');
2119 }
2120
2121 if (props.inertia) {
2122 addInertia(tooltip);
2123 }
2124
2125 setContent(content, props);
2126 tooltip.appendChild(content);
2127 popper.appendChild(tooltip);
2128 updatePopperElement(popper, props, props, false);
2129 return popper;
2130 }
2131 /**
2132 * Updates the popper element based on the new props
2133 */
2134
2135 function updatePopperElement(popper, prevProps, nextProps, isVisible) {
2136 var _getChildren = getChildren(popper),
2137 tooltip = _getChildren.tooltip,
2138 content = _getChildren.content,
2139 backdrop = _getChildren.backdrop,
2140 arrow = _getChildren.arrow;
2141
2142 popper.style.zIndex = '' + nextProps.zIndex;
2143 tooltip.setAttribute('data-animation', nextProps.animation);
2144 tooltip.style.maxWidth = nextProps.maxWidth + (typeof nextProps.maxWidth === 'number' ? 'px' : '');
2145
2146 if (nextProps.role) {
2147 tooltip.setAttribute('role', nextProps.role);
2148 } else {
2149 tooltip.removeAttribute('role');
2150 }
2151
2152 if (prevProps.content !== nextProps.content) {
2153 setContent(content, nextProps);
2154 } // animateFill
2155
2156
2157 if (!prevProps.animateFill && nextProps.animateFill) {
2158 tooltip.appendChild(createBackdropElement(isVisible));
2159 tooltip.setAttribute('data-animatefill', '');
2160 } else if (prevProps.animateFill && !nextProps.animateFill) {
2161 tooltip.removeChild(backdrop);
2162 tooltip.removeAttribute('data-animatefill');
2163 } // arrow
2164
2165
2166 if (!prevProps.arrow && nextProps.arrow) {
2167 // false to true
2168 tooltip.appendChild(createArrowElement(nextProps.arrow));
2169 tooltip.setAttribute('data-arrow', '');
2170 } else if (prevProps.arrow && !nextProps.arrow) {
2171 // true to false
2172 tooltip.removeChild(arrow);
2173 tooltip.removeAttribute('data-arrow');
2174 } else if (prevProps.arrow !== nextProps.arrow) {
2175 // true to 'round' or vice-versa
2176 tooltip.removeChild(arrow);
2177 tooltip.appendChild(createArrowElement(nextProps.arrow));
2178 } // interactive
2179
2180
2181 if (!prevProps.interactive && nextProps.interactive) {
2182 addInteractive(tooltip);
2183 } else if (prevProps.interactive && !nextProps.interactive) {
2184 removeInteractive(tooltip);
2185 } // inertia
2186
2187
2188 if (!prevProps.inertia && nextProps.inertia) {
2189 addInertia(tooltip);
2190 } else if (prevProps.inertia && !nextProps.inertia) {
2191 removeInertia(tooltip);
2192 } // theme
2193
2194
2195 if (prevProps.theme !== nextProps.theme) {
2196 updateTheme(tooltip, 'remove', prevProps.theme);
2197 updateTheme(tooltip, 'add', nextProps.theme);
2198 }
2199 }
2200 /**
2201 * Determines if the mouse cursor is outside of the popper's interactive border
2202 * region
2203 */
2204
2205 function isCursorOutsideInteractiveBorder(popperPlacement, popperRect, event, props) {
2206 if (!popperPlacement) {
2207 return true;
2208 }
2209
2210 var x = event.clientX,
2211 y = event.clientY;
2212 var interactiveBorder = props.interactiveBorder,
2213 distance = props.distance;
2214 var exceedsTop = popperRect.top - y > (popperPlacement === 'top' ? interactiveBorder + distance : interactiveBorder);
2215 var exceedsBottom = y - popperRect.bottom > (popperPlacement === 'bottom' ? interactiveBorder + distance : interactiveBorder);
2216 var exceedsLeft = popperRect.left - x > (popperPlacement === 'left' ? interactiveBorder + distance : interactiveBorder);
2217 var exceedsRight = x - popperRect.right > (popperPlacement === 'right' ? interactiveBorder + distance : interactiveBorder);
2218 return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
2219 }
2220
2221 /**!
2222 * @fileOverview Kickass library to create and place poppers near their reference elements.
2223 * @version 1.15.0
2224 * @license
2225 * Copyright (c) 2016 Federico Zivolo and contributors
2226 *
2227 * Permission is hereby granted, free of charge, to any person obtaining a copy
2228 * of this software and associated documentation files (the "Software"), to deal
2229 * in the Software without restriction, including without limitation the rights
2230 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2231 * copies of the Software, and to permit persons to whom the Software is
2232 * furnished to do so, subject to the following conditions:
2233 *
2234 * The above copyright notice and this permission notice shall be included in all
2235 * copies or substantial portions of the Software.
2236 *
2237 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2238 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2239 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2240 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2241 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2242 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2243 * SOFTWARE.
2244 */
2245 var isBrowser$1 = typeof window !== 'undefined' && typeof document !== 'undefined';
2246
2247 var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
2248 var timeoutDuration = 0;
2249 for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
2250 if (isBrowser$1 && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
2251 timeoutDuration = 1;
2252 break;
2253 }
2254 }
2255
2256 function microtaskDebounce(fn) {
2257 var called = false;
2258 return function () {
2259 if (called) {
2260 return;
2261 }
2262 called = true;
2263 window.Promise.resolve().then(function () {
2264 called = false;
2265 fn();
2266 });
2267 };
2268 }
2269
2270 function taskDebounce(fn) {
2271 var scheduled = false;
2272 return function () {
2273 if (!scheduled) {
2274 scheduled = true;
2275 setTimeout(function () {
2276 scheduled = false;
2277 fn();
2278 }, timeoutDuration);
2279 }
2280 };
2281 }
2282
2283 var supportsMicroTasks = isBrowser$1 && window.Promise;
2284
2285 /**
2286 * Create a debounced version of a method, that's asynchronously deferred
2287 * but called in the minimum time possible.
2288 *
2289 * @method
2290 * @memberof Popper.Utils
2291 * @argument {Function} fn
2292 * @returns {Function}
2293 */
2294 var debounce$1 = supportsMicroTasks ? microtaskDebounce : taskDebounce;
2295
2296 /**
2297 * Check if the given variable is a function
2298 * @method
2299 * @memberof Popper.Utils
2300 * @argument {Any} functionToCheck - variable to check
2301 * @returns {Boolean} answer to: is a function?
2302 */
2303 function isFunction$1(functionToCheck) {
2304 var getType = {};
2305 return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
2306 }
2307
2308 /**
2309 * Get CSS computed property of the given element
2310 * @method
2311 * @memberof Popper.Utils
2312 * @argument {Eement} element
2313 * @argument {String} property
2314 */
2315 function getStyleComputedProperty(element, property) {
2316 if (element.nodeType !== 1) {
2317 return [];
2318 }
2319 // NOTE: 1 DOM access here
2320 var window = element.ownerDocument.defaultView;
2321 var css = window.getComputedStyle(element, null);
2322 return property ? css[property] : css;
2323 }
2324
2325 /**
2326 * Returns the parentNode or the host of the element
2327 * @method
2328 * @memberof Popper.Utils
2329 * @argument {Element} element
2330 * @returns {Element} parent
2331 */
2332 function getParentNode(element) {
2333 if (element.nodeName === 'HTML') {
2334 return element;
2335 }
2336 return element.parentNode || element.host;
2337 }
2338
2339 /**
2340 * Returns the scrolling parent of the given element
2341 * @method
2342 * @memberof Popper.Utils
2343 * @argument {Element} element
2344 * @returns {Element} scroll parent
2345 */
2346 function getScrollParent(element) {
2347 // Return body, `getScroll` will take care to get the correct `scrollTop` from it
2348 if (!element) {
2349 return document.body;
2350 }
2351
2352 switch (element.nodeName) {
2353 case 'HTML':
2354 case 'BODY':
2355 return element.ownerDocument.body;
2356 case '#document':
2357 return element.body;
2358 }
2359
2360 // Firefox want us to check `-x` and `-y` variations as well
2361
2362 var _getStyleComputedProp = getStyleComputedProperty(element),
2363 overflow = _getStyleComputedProp.overflow,
2364 overflowX = _getStyleComputedProp.overflowX,
2365 overflowY = _getStyleComputedProp.overflowY;
2366
2367 if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
2368 return element;
2369 }
2370
2371 return getScrollParent(getParentNode(element));
2372 }
2373
2374 var isIE11 = isBrowser$1 && !!(window.MSInputMethodContext && document.documentMode);
2375 var isIE10 = isBrowser$1 && /MSIE 10/.test(navigator.userAgent);
2376
2377 /**
2378 * Determines if the browser is Internet Explorer
2379 * @method
2380 * @memberof Popper.Utils
2381 * @param {Number} version to check
2382 * @returns {Boolean} isIE
2383 */
2384 function isIE$1(version) {
2385 if (version === 11) {
2386 return isIE11;
2387 }
2388 if (version === 10) {
2389 return isIE10;
2390 }
2391 return isIE11 || isIE10;
2392 }
2393
2394 /**
2395 * Returns the offset parent of the given element
2396 * @method
2397 * @memberof Popper.Utils
2398 * @argument {Element} element
2399 * @returns {Element} offset parent
2400 */
2401 function getOffsetParent(element) {
2402 if (!element) {
2403 return document.documentElement;
2404 }
2405
2406 var noOffsetParent = isIE$1(10) ? document.body : null;
2407
2408 // NOTE: 1 DOM access here
2409 var offsetParent = element.offsetParent || null;
2410 // Skip hidden elements which don't have an offsetParent
2411 while (offsetParent === noOffsetParent && element.nextElementSibling) {
2412 offsetParent = (element = element.nextElementSibling).offsetParent;
2413 }
2414
2415 var nodeName = offsetParent && offsetParent.nodeName;
2416
2417 if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
2418 return element ? element.ownerDocument.documentElement : document.documentElement;
2419 }
2420
2421 // .offsetParent will return the closest TH, TD or TABLE in case
2422 // no offsetParent is present, I hate this job...
2423 if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
2424 return getOffsetParent(offsetParent);
2425 }
2426
2427 return offsetParent;
2428 }
2429
2430 function isOffsetContainer(element) {
2431 var nodeName = element.nodeName;
2432
2433 if (nodeName === 'BODY') {
2434 return false;
2435 }
2436 return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
2437 }
2438
2439 /**
2440 * Finds the root node (document, shadowDOM root) of the given element
2441 * @method
2442 * @memberof Popper.Utils
2443 * @argument {Element} node
2444 * @returns {Element} root node
2445 */
2446 function getRoot(node) {
2447 if (node.parentNode !== null) {
2448 return getRoot(node.parentNode);
2449 }
2450
2451 return node;
2452 }
2453
2454 /**
2455 * Finds the offset parent common to the two provided nodes
2456 * @method
2457 * @memberof Popper.Utils
2458 * @argument {Element} element1
2459 * @argument {Element} element2
2460 * @returns {Element} common offset parent
2461 */
2462 function findCommonOffsetParent(element1, element2) {
2463 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
2464 if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
2465 return document.documentElement;
2466 }
2467
2468 // Here we make sure to give as "start" the element that comes first in the DOM
2469 var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
2470 var start = order ? element1 : element2;
2471 var end = order ? element2 : element1;
2472
2473 // Get common ancestor container
2474 var range = document.createRange();
2475 range.setStart(start, 0);
2476 range.setEnd(end, 0);
2477 var commonAncestorContainer = range.commonAncestorContainer;
2478
2479 // Both nodes are inside #document
2480
2481 if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
2482 if (isOffsetContainer(commonAncestorContainer)) {
2483 return commonAncestorContainer;
2484 }
2485
2486 return getOffsetParent(commonAncestorContainer);
2487 }
2488
2489 // one of the nodes is inside shadowDOM, find which one
2490 var element1root = getRoot(element1);
2491 if (element1root.host) {
2492 return findCommonOffsetParent(element1root.host, element2);
2493 } else {
2494 return findCommonOffsetParent(element1, getRoot(element2).host);
2495 }
2496 }
2497
2498 /**
2499 * Gets the scroll value of the given element in the given side (top and left)
2500 * @method
2501 * @memberof Popper.Utils
2502 * @argument {Element} element
2503 * @argument {String} side `top` or `left`
2504 * @returns {number} amount of scrolled pixels
2505 */
2506 function getScroll(element) {
2507 var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
2508
2509 var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
2510 var nodeName = element.nodeName;
2511
2512 if (nodeName === 'BODY' || nodeName === 'HTML') {
2513 var html = element.ownerDocument.documentElement;
2514 var scrollingElement = element.ownerDocument.scrollingElement || html;
2515 return scrollingElement[upperSide];
2516 }
2517
2518 return element[upperSide];
2519 }
2520
2521 /*
2522 * Sum or subtract the element scroll values (left and top) from a given rect object
2523 * @method
2524 * @memberof Popper.Utils
2525 * @param {Object} rect - Rect object you want to change
2526 * @param {HTMLElement} element - The element from the function reads the scroll values
2527 * @param {Boolean} subtract - set to true if you want to subtract the scroll values
2528 * @return {Object} rect - The modifier rect object
2529 */
2530 function includeScroll(rect, element) {
2531 var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2532
2533 var scrollTop = getScroll(element, 'top');
2534 var scrollLeft = getScroll(element, 'left');
2535 var modifier = subtract ? -1 : 1;
2536 rect.top += scrollTop * modifier;
2537 rect.bottom += scrollTop * modifier;
2538 rect.left += scrollLeft * modifier;
2539 rect.right += scrollLeft * modifier;
2540 return rect;
2541 }
2542
2543 /*
2544 * Helper to detect borders of a given element
2545 * @method
2546 * @memberof Popper.Utils
2547 * @param {CSSStyleDeclaration} styles
2548 * Result of `getStyleComputedProperty` on the given element
2549 * @param {String} axis - `x` or `y`
2550 * @return {number} borders - The borders size of the given axis
2551 */
2552
2553 function getBordersSize(styles, axis) {
2554 var sideA = axis === 'x' ? 'Left' : 'Top';
2555 var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
2556
2557 return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
2558 }
2559
2560 function getSize(axis, body, html, computedStyle) {
2561 return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE$1(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
2562 }
2563
2564 function getWindowSizes(document) {
2565 var body = document.body;
2566 var html = document.documentElement;
2567 var computedStyle = isIE$1(10) && getComputedStyle(html);
2568
2569 return {
2570 height: getSize('Height', body, html, computedStyle),
2571 width: getSize('Width', body, html, computedStyle)
2572 };
2573 }
2574
2575 var classCallCheck = function (instance, Constructor) {
2576 if (!(instance instanceof Constructor)) {
2577 throw new TypeError("Cannot call a class as a function");
2578 }
2579 };
2580
2581 var createClass = function () {
2582 function defineProperties(target, props) {
2583 for (var i = 0; i < props.length; i++) {
2584 var descriptor = props[i];
2585 descriptor.enumerable = descriptor.enumerable || false;
2586 descriptor.configurable = true;
2587 if ("value" in descriptor) descriptor.writable = true;
2588 Object.defineProperty(target, descriptor.key, descriptor);
2589 }
2590 }
2591
2592 return function (Constructor, protoProps, staticProps) {
2593 if (protoProps) defineProperties(Constructor.prototype, protoProps);
2594 if (staticProps) defineProperties(Constructor, staticProps);
2595 return Constructor;
2596 };
2597 }();
2598
2599
2600
2601
2602
2603 var defineProperty$1 = function (obj, key, value) {
2604 if (key in obj) {
2605 Object.defineProperty(obj, key, {
2606 value: value,
2607 enumerable: true,
2608 configurable: true,
2609 writable: true
2610 });
2611 } else {
2612 obj[key] = value;
2613 }
2614
2615 return obj;
2616 };
2617
2618 var _extends$2 = Object.assign || function (target) {
2619 for (var i = 1; i < arguments.length; i++) {
2620 var source = arguments[i];
2621
2622 for (var key in source) {
2623 if (Object.prototype.hasOwnProperty.call(source, key)) {
2624 target[key] = source[key];
2625 }
2626 }
2627 }
2628
2629 return target;
2630 };
2631
2632 /**
2633 * Given element offsets, generate an output similar to getBoundingClientRect
2634 * @method
2635 * @memberof Popper.Utils
2636 * @argument {Object} offsets
2637 * @returns {Object} ClientRect like output
2638 */
2639 function getClientRect(offsets) {
2640 return _extends$2({}, offsets, {
2641 right: offsets.left + offsets.width,
2642 bottom: offsets.top + offsets.height
2643 });
2644 }
2645
2646 /**
2647 * Get bounding client rect of given element
2648 * @method
2649 * @memberof Popper.Utils
2650 * @param {HTMLElement} element
2651 * @return {Object} client rect
2652 */
2653 function getBoundingClientRect(element) {
2654 var rect = {};
2655
2656 // IE10 10 FIX: Please, don't ask, the element isn't
2657 // considered in DOM in some circumstances...
2658 // This isn't reproducible in IE10 compatibility mode of IE11
2659 try {
2660 if (isIE$1(10)) {
2661 rect = element.getBoundingClientRect();
2662 var scrollTop = getScroll(element, 'top');
2663 var scrollLeft = getScroll(element, 'left');
2664 rect.top += scrollTop;
2665 rect.left += scrollLeft;
2666 rect.bottom += scrollTop;
2667 rect.right += scrollLeft;
2668 } else {
2669 rect = element.getBoundingClientRect();
2670 }
2671 } catch (e) {}
2672
2673 var result = {
2674 left: rect.left,
2675 top: rect.top,
2676 width: rect.right - rect.left,
2677 height: rect.bottom - rect.top
2678 };
2679
2680 // subtract scrollbar size from sizes
2681 var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
2682 var width = sizes.width || element.clientWidth || result.right - result.left;
2683 var height = sizes.height || element.clientHeight || result.bottom - result.top;
2684
2685 var horizScrollbar = element.offsetWidth - width;
2686 var vertScrollbar = element.offsetHeight - height;
2687
2688 // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
2689 // we make this check conditional for performance reasons
2690 if (horizScrollbar || vertScrollbar) {
2691 var styles = getStyleComputedProperty(element);
2692 horizScrollbar -= getBordersSize(styles, 'x');
2693 vertScrollbar -= getBordersSize(styles, 'y');
2694
2695 result.width -= horizScrollbar;
2696 result.height -= vertScrollbar;
2697 }
2698
2699 return getClientRect(result);
2700 }
2701
2702 function getOffsetRectRelativeToArbitraryNode(children, parent) {
2703 var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2704
2705 var isIE10 = isIE$1(10);
2706 var isHTML = parent.nodeName === 'HTML';
2707 var childrenRect = getBoundingClientRect(children);
2708 var parentRect = getBoundingClientRect(parent);
2709 var scrollParent = getScrollParent(children);
2710
2711 var styles = getStyleComputedProperty(parent);
2712 var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
2713 var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
2714
2715 // In cases where the parent is fixed, we must ignore negative scroll in offset calc
2716 if (fixedPosition && isHTML) {
2717 parentRect.top = Math.max(parentRect.top, 0);
2718 parentRect.left = Math.max(parentRect.left, 0);
2719 }
2720 var offsets = getClientRect({
2721 top: childrenRect.top - parentRect.top - borderTopWidth,
2722 left: childrenRect.left - parentRect.left - borderLeftWidth,
2723 width: childrenRect.width,
2724 height: childrenRect.height
2725 });
2726 offsets.marginTop = 0;
2727 offsets.marginLeft = 0;
2728
2729 // Subtract margins of documentElement in case it's being used as parent
2730 // we do this only on HTML because it's the only element that behaves
2731 // differently when margins are applied to it. The margins are included in
2732 // the box of the documentElement, in the other cases not.
2733 if (!isIE10 && isHTML) {
2734 var marginTop = parseFloat(styles.marginTop, 10);
2735 var marginLeft = parseFloat(styles.marginLeft, 10);
2736
2737 offsets.top -= borderTopWidth - marginTop;
2738 offsets.bottom -= borderTopWidth - marginTop;
2739 offsets.left -= borderLeftWidth - marginLeft;
2740 offsets.right -= borderLeftWidth - marginLeft;
2741
2742 // Attach marginTop and marginLeft because in some circumstances we may need them
2743 offsets.marginTop = marginTop;
2744 offsets.marginLeft = marginLeft;
2745 }
2746
2747 if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
2748 offsets = includeScroll(offsets, parent);
2749 }
2750
2751 return offsets;
2752 }
2753
2754 function getViewportOffsetRectRelativeToArtbitraryNode(element) {
2755 var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2756
2757 var html = element.ownerDocument.documentElement;
2758 var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
2759 var width = Math.max(html.clientWidth, window.innerWidth || 0);
2760 var height = Math.max(html.clientHeight, window.innerHeight || 0);
2761
2762 var scrollTop = !excludeScroll ? getScroll(html) : 0;
2763 var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
2764
2765 var offset = {
2766 top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
2767 left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
2768 width: width,
2769 height: height
2770 };
2771
2772 return getClientRect(offset);
2773 }
2774
2775 /**
2776 * Check if the given element is fixed or is inside a fixed parent
2777 * @method
2778 * @memberof Popper.Utils
2779 * @argument {Element} element
2780 * @argument {Element} customContainer
2781 * @returns {Boolean} answer to "isFixed?"
2782 */
2783 function isFixed(element) {
2784 var nodeName = element.nodeName;
2785 if (nodeName === 'BODY' || nodeName === 'HTML') {
2786 return false;
2787 }
2788 if (getStyleComputedProperty(element, 'position') === 'fixed') {
2789 return true;
2790 }
2791 var parentNode = getParentNode(element);
2792 if (!parentNode) {
2793 return false;
2794 }
2795 return isFixed(parentNode);
2796 }
2797
2798 /**
2799 * Finds the first parent of an element that has a transformed property defined
2800 * @method
2801 * @memberof Popper.Utils
2802 * @argument {Element} element
2803 * @returns {Element} first transformed parent or documentElement
2804 */
2805
2806 function getFixedPositionOffsetParent(element) {
2807 // This check is needed to avoid errors in case one of the elements isn't defined for any reason
2808 if (!element || !element.parentElement || isIE$1()) {
2809 return document.documentElement;
2810 }
2811 var el = element.parentElement;
2812 while (el && getStyleComputedProperty(el, 'transform') === 'none') {
2813 el = el.parentElement;
2814 }
2815 return el || document.documentElement;
2816 }
2817
2818 /**
2819 * Computed the boundaries limits and return them
2820 * @method
2821 * @memberof Popper.Utils
2822 * @param {HTMLElement} popper
2823 * @param {HTMLElement} reference
2824 * @param {number} padding
2825 * @param {HTMLElement} boundariesElement - Element used to define the boundaries
2826 * @param {Boolean} fixedPosition - Is in fixed position mode
2827 * @returns {Object} Coordinates of the boundaries
2828 */
2829 function getBoundaries(popper, reference, padding, boundariesElement) {
2830 var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
2831
2832 // NOTE: 1 DOM access here
2833
2834 var boundaries = { top: 0, left: 0 };
2835 var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
2836
2837 // Handle viewport case
2838 if (boundariesElement === 'viewport') {
2839 boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
2840 } else {
2841 // Handle other cases based on DOM element used as boundaries
2842 var boundariesNode = void 0;
2843 if (boundariesElement === 'scrollParent') {
2844 boundariesNode = getScrollParent(getParentNode(reference));
2845 if (boundariesNode.nodeName === 'BODY') {
2846 boundariesNode = popper.ownerDocument.documentElement;
2847 }
2848 } else if (boundariesElement === 'window') {
2849 boundariesNode = popper.ownerDocument.documentElement;
2850 } else {
2851 boundariesNode = boundariesElement;
2852 }
2853
2854 var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
2855
2856 // In case of HTML, we need a different computation
2857 if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
2858 var _getWindowSizes = getWindowSizes(popper.ownerDocument),
2859 height = _getWindowSizes.height,
2860 width = _getWindowSizes.width;
2861
2862 boundaries.top += offsets.top - offsets.marginTop;
2863 boundaries.bottom = height + offsets.top;
2864 boundaries.left += offsets.left - offsets.marginLeft;
2865 boundaries.right = width + offsets.left;
2866 } else {
2867 // for all the other DOM elements, this one is good
2868 boundaries = offsets;
2869 }
2870 }
2871
2872 // Add paddings
2873 padding = padding || 0;
2874 var isPaddingNumber = typeof padding === 'number';
2875 boundaries.left += isPaddingNumber ? padding : padding.left || 0;
2876 boundaries.top += isPaddingNumber ? padding : padding.top || 0;
2877 boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
2878 boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
2879
2880 return boundaries;
2881 }
2882
2883 function getArea(_ref) {
2884 var width = _ref.width,
2885 height = _ref.height;
2886
2887 return width * height;
2888 }
2889
2890 /**
2891 * Utility used to transform the `auto` placement to the placement with more
2892 * available space.
2893 * @method
2894 * @memberof Popper.Utils
2895 * @argument {Object} data - The data object generated by update method
2896 * @argument {Object} options - Modifiers configuration and options
2897 * @returns {Object} The data object, properly modified
2898 */
2899 function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
2900 var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
2901
2902 if (placement.indexOf('auto') === -1) {
2903 return placement;
2904 }
2905
2906 var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
2907
2908 var rects = {
2909 top: {
2910 width: boundaries.width,
2911 height: refRect.top - boundaries.top
2912 },
2913 right: {
2914 width: boundaries.right - refRect.right,
2915 height: boundaries.height
2916 },
2917 bottom: {
2918 width: boundaries.width,
2919 height: boundaries.bottom - refRect.bottom
2920 },
2921 left: {
2922 width: refRect.left - boundaries.left,
2923 height: boundaries.height
2924 }
2925 };
2926
2927 var sortedAreas = Object.keys(rects).map(function (key) {
2928 return _extends$2({
2929 key: key
2930 }, rects[key], {
2931 area: getArea(rects[key])
2932 });
2933 }).sort(function (a, b) {
2934 return b.area - a.area;
2935 });
2936
2937 var filteredAreas = sortedAreas.filter(function (_ref2) {
2938 var width = _ref2.width,
2939 height = _ref2.height;
2940 return width >= popper.clientWidth && height >= popper.clientHeight;
2941 });
2942
2943 var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
2944
2945 var variation = placement.split('-')[1];
2946
2947 return computedPlacement + (variation ? '-' + variation : '');
2948 }
2949
2950 /**
2951 * Get offsets to the reference element
2952 * @method
2953 * @memberof Popper.Utils
2954 * @param {Object} state
2955 * @param {Element} popper - the popper element
2956 * @param {Element} reference - the reference element (the popper will be relative to this)
2957 * @param {Element} fixedPosition - is in fixed position mode
2958 * @returns {Object} An object containing the offsets which will be applied to the popper
2959 */
2960 function getReferenceOffsets(state, popper, reference) {
2961 var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2962
2963 var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
2964 return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
2965 }
2966
2967 /**
2968 * Get the outer sizes of the given element (offset size + margins)
2969 * @method
2970 * @memberof Popper.Utils
2971 * @argument {Element} element
2972 * @returns {Object} object containing width and height properties
2973 */
2974 function getOuterSizes(element) {
2975 var window = element.ownerDocument.defaultView;
2976 var styles = window.getComputedStyle(element);
2977 var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
2978 var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
2979 var result = {
2980 width: element.offsetWidth + y,
2981 height: element.offsetHeight + x
2982 };
2983 return result;
2984 }
2985
2986 /**
2987 * Get the opposite placement of the given one
2988 * @method
2989 * @memberof Popper.Utils
2990 * @argument {String} placement
2991 * @returns {String} flipped placement
2992 */
2993 function getOppositePlacement(placement) {
2994 var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
2995 return placement.replace(/left|right|bottom|top/g, function (matched) {
2996 return hash[matched];
2997 });
2998 }
2999
3000 /**
3001 * Get offsets to the popper
3002 * @method
3003 * @memberof Popper.Utils
3004 * @param {Object} position - CSS position the Popper will get applied
3005 * @param {HTMLElement} popper - the popper element
3006 * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
3007 * @param {String} placement - one of the valid placement options
3008 * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
3009 */
3010 function getPopperOffsets(popper, referenceOffsets, placement) {
3011 placement = placement.split('-')[0];
3012
3013 // Get popper node sizes
3014 var popperRect = getOuterSizes(popper);
3015
3016 // Add position, width and height to our offsets object
3017 var popperOffsets = {
3018 width: popperRect.width,
3019 height: popperRect.height
3020 };
3021
3022 // depending by the popper placement we have to compute its offsets slightly differently
3023 var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
3024 var mainSide = isHoriz ? 'top' : 'left';
3025 var secondarySide = isHoriz ? 'left' : 'top';
3026 var measurement = isHoriz ? 'height' : 'width';
3027 var secondaryMeasurement = !isHoriz ? 'height' : 'width';
3028
3029 popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
3030 if (placement === secondarySide) {
3031 popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
3032 } else {
3033 popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
3034 }
3035
3036 return popperOffsets;
3037 }
3038
3039 /**
3040 * Mimics the `find` method of Array
3041 * @method
3042 * @memberof Popper.Utils
3043 * @argument {Array} arr
3044 * @argument prop
3045 * @argument value
3046 * @returns index or -1
3047 */
3048 function find(arr, check) {
3049 // use native find if supported
3050 if (Array.prototype.find) {
3051 return arr.find(check);
3052 }
3053
3054 // use `filter` to obtain the same behavior of `find`
3055 return arr.filter(check)[0];
3056 }
3057
3058 /**
3059 * Return the index of the matching object
3060 * @method
3061 * @memberof Popper.Utils
3062 * @argument {Array} arr
3063 * @argument prop
3064 * @argument value
3065 * @returns index or -1
3066 */
3067 function findIndex(arr, prop, value) {
3068 // use native findIndex if supported
3069 if (Array.prototype.findIndex) {
3070 return arr.findIndex(function (cur) {
3071 return cur[prop] === value;
3072 });
3073 }
3074
3075 // use `find` + `indexOf` if `findIndex` isn't supported
3076 var match = find(arr, function (obj) {
3077 return obj[prop] === value;
3078 });
3079 return arr.indexOf(match);
3080 }
3081
3082 /**
3083 * Loop trough the list of modifiers and run them in order,
3084 * each of them will then edit the data object.
3085 * @method
3086 * @memberof Popper.Utils
3087 * @param {dataObject} data
3088 * @param {Array} modifiers
3089 * @param {String} ends - Optional modifier name used as stopper
3090 * @returns {dataObject}
3091 */
3092 function runModifiers(modifiers, data, ends) {
3093 var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
3094
3095 modifiersToRun.forEach(function (modifier) {
3096 if (modifier['function']) {
3097 // eslint-disable-line dot-notation
3098 console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
3099 }
3100 var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
3101 if (modifier.enabled && isFunction$1(fn)) {
3102 // Add properties to offsets to make them a complete clientRect object
3103 // we do this before each modifier to make sure the previous one doesn't
3104 // mess with these values
3105 data.offsets.popper = getClientRect(data.offsets.popper);
3106 data.offsets.reference = getClientRect(data.offsets.reference);
3107
3108 data = fn(data, modifier);
3109 }
3110 });
3111
3112 return data;
3113 }
3114
3115 /**
3116 * Updates the position of the popper, computing the new offsets and applying
3117 * the new style.<br />
3118 * Prefer `scheduleUpdate` over `update` because of performance reasons.
3119 * @method
3120 * @memberof Popper
3121 */
3122 function update() {
3123 // if popper is destroyed, don't perform any further update
3124 if (this.state.isDestroyed) {
3125 return;
3126 }
3127
3128 var data = {
3129 instance: this,
3130 styles: {},
3131 arrowStyles: {},
3132 attributes: {},
3133 flipped: false,
3134 offsets: {}
3135 };
3136
3137 // compute reference element offsets
3138 data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
3139
3140 // compute auto placement, store placement inside the data object,
3141 // modifiers will be able to edit `placement` if needed
3142 // and refer to originalPlacement to know the original value
3143 data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
3144
3145 // store the computed placement inside `originalPlacement`
3146 data.originalPlacement = data.placement;
3147
3148 data.positionFixed = this.options.positionFixed;
3149
3150 // compute the popper offsets
3151 data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
3152
3153 data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
3154
3155 // run the modifiers
3156 data = runModifiers(this.modifiers, data);
3157
3158 // the first `update` will call `onCreate` callback
3159 // the other ones will call `onUpdate` callback
3160 if (!this.state.isCreated) {
3161 this.state.isCreated = true;
3162 this.options.onCreate(data);
3163 } else {
3164 this.options.onUpdate(data);
3165 }
3166 }
3167
3168 /**
3169 * Helper used to know if the given modifier is enabled.
3170 * @method
3171 * @memberof Popper.Utils
3172 * @returns {Boolean}
3173 */
3174 function isModifierEnabled(modifiers, modifierName) {
3175 return modifiers.some(function (_ref) {
3176 var name = _ref.name,
3177 enabled = _ref.enabled;
3178 return enabled && name === modifierName;
3179 });
3180 }
3181
3182 /**
3183 * Get the prefixed supported property name
3184 * @method
3185 * @memberof Popper.Utils
3186 * @argument {String} property (camelCase)
3187 * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
3188 */
3189 function getSupportedPropertyName(property) {
3190 var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
3191 var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
3192
3193 for (var i = 0; i < prefixes.length; i++) {
3194 var prefix = prefixes[i];
3195 var toCheck = prefix ? '' + prefix + upperProp : property;
3196 if (typeof document.body.style[toCheck] !== 'undefined') {
3197 return toCheck;
3198 }
3199 }
3200 return null;
3201 }
3202
3203 /**
3204 * Destroys the popper.
3205 * @method
3206 * @memberof Popper
3207 */
3208 function destroy() {
3209 this.state.isDestroyed = true;
3210
3211 // touch DOM only if `applyStyle` modifier is enabled
3212 if (isModifierEnabled(this.modifiers, 'applyStyle')) {
3213 this.popper.removeAttribute('x-placement');
3214 this.popper.style.position = '';
3215 this.popper.style.top = '';
3216 this.popper.style.left = '';
3217 this.popper.style.right = '';
3218 this.popper.style.bottom = '';
3219 this.popper.style.willChange = '';
3220 this.popper.style[getSupportedPropertyName('transform')] = '';
3221 }
3222
3223 this.disableEventListeners();
3224
3225 // remove the popper if user explicity asked for the deletion on destroy
3226 // do not use `remove` because IE11 doesn't support it
3227 if (this.options.removeOnDestroy) {
3228 this.popper.parentNode.removeChild(this.popper);
3229 }
3230 return this;
3231 }
3232
3233 /**
3234 * Get the window associated with the element
3235 * @argument {Element} element
3236 * @returns {Window}
3237 */
3238 function getWindow(element) {
3239 var ownerDocument = element.ownerDocument;
3240 return ownerDocument ? ownerDocument.defaultView : window;
3241 }
3242
3243 function attachToScrollParents(scrollParent, event, callback, scrollParents) {
3244 var isBody = scrollParent.nodeName === 'BODY';
3245 var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
3246 target.addEventListener(event, callback, { passive: true });
3247
3248 if (!isBody) {
3249 attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
3250 }
3251 scrollParents.push(target);
3252 }
3253
3254 /**
3255 * Setup needed event listeners used to update the popper position
3256 * @method
3257 * @memberof Popper.Utils
3258 * @private
3259 */
3260 function setupEventListeners(reference, options, state, updateBound) {
3261 // Resize event listener on window
3262 state.updateBound = updateBound;
3263 getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
3264
3265 // Scroll event listener on scroll parents
3266 var scrollElement = getScrollParent(reference);
3267 attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
3268 state.scrollElement = scrollElement;
3269 state.eventsEnabled = true;
3270
3271 return state;
3272 }
3273
3274 /**
3275 * It will add resize/scroll events and start recalculating
3276 * position of the popper element when they are triggered.
3277 * @method
3278 * @memberof Popper
3279 */
3280 function enableEventListeners() {
3281 if (!this.state.eventsEnabled) {
3282 this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
3283 }
3284 }
3285
3286 /**
3287 * Remove event listeners used to update the popper position
3288 * @method
3289 * @memberof Popper.Utils
3290 * @private
3291 */
3292 function removeEventListeners(reference, state) {
3293 // Remove resize event listener on window
3294 getWindow(reference).removeEventListener('resize', state.updateBound);
3295
3296 // Remove scroll event listener on scroll parents
3297 state.scrollParents.forEach(function (target) {
3298 target.removeEventListener('scroll', state.updateBound);
3299 });
3300
3301 // Reset state
3302 state.updateBound = null;
3303 state.scrollParents = [];
3304 state.scrollElement = null;
3305 state.eventsEnabled = false;
3306 return state;
3307 }
3308
3309 /**
3310 * It will remove resize/scroll events and won't recalculate popper position
3311 * when they are triggered. It also won't trigger `onUpdate` callback anymore,
3312 * unless you call `update` method manually.
3313 * @method
3314 * @memberof Popper
3315 */
3316 function disableEventListeners() {
3317 if (this.state.eventsEnabled) {
3318 cancelAnimationFrame(this.scheduleUpdate);
3319 this.state = removeEventListeners(this.reference, this.state);
3320 }
3321 }
3322
3323 /**
3324 * Tells if a given input is a number
3325 * @method
3326 * @memberof Popper.Utils
3327 * @param {*} input to check
3328 * @return {Boolean}
3329 */
3330 function isNumeric(n) {
3331 return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
3332 }
3333
3334 /**
3335 * Set the style to the given popper
3336 * @method
3337 * @memberof Popper.Utils
3338 * @argument {Element} element - Element to apply the style to
3339 * @argument {Object} styles
3340 * Object with a list of properties and values which will be applied to the element
3341 */
3342 function setStyles(element, styles) {
3343 Object.keys(styles).forEach(function (prop) {
3344 var unit = '';
3345 // add unit if the value is numeric and is one of the following
3346 if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
3347 unit = 'px';
3348 }
3349 element.style[prop] = styles[prop] + unit;
3350 });
3351 }
3352
3353 /**
3354 * Set the attributes to the given popper
3355 * @method
3356 * @memberof Popper.Utils
3357 * @argument {Element} element - Element to apply the attributes to
3358 * @argument {Object} styles
3359 * Object with a list of properties and values which will be applied to the element
3360 */
3361 function setAttributes(element, attributes) {
3362 Object.keys(attributes).forEach(function (prop) {
3363 var value = attributes[prop];
3364 if (value !== false) {
3365 element.setAttribute(prop, attributes[prop]);
3366 } else {
3367 element.removeAttribute(prop);
3368 }
3369 });
3370 }
3371
3372 /**
3373 * @function
3374 * @memberof Modifiers
3375 * @argument {Object} data - The data object generated by `update` method
3376 * @argument {Object} data.styles - List of style properties - values to apply to popper element
3377 * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
3378 * @argument {Object} options - Modifiers configuration and options
3379 * @returns {Object} The same data object
3380 */
3381 function applyStyle(data) {
3382 // any property present in `data.styles` will be applied to the popper,
3383 // in this way we can make the 3rd party modifiers add custom styles to it
3384 // Be aware, modifiers could override the properties defined in the previous
3385 // lines of this modifier!
3386 setStyles(data.instance.popper, data.styles);
3387
3388 // any property present in `data.attributes` will be applied to the popper,
3389 // they will be set as HTML attributes of the element
3390 setAttributes(data.instance.popper, data.attributes);
3391
3392 // if arrowElement is defined and arrowStyles has some properties
3393 if (data.arrowElement && Object.keys(data.arrowStyles).length) {
3394 setStyles(data.arrowElement, data.arrowStyles);
3395 }
3396
3397 return data;
3398 }
3399
3400 /**
3401 * Set the x-placement attribute before everything else because it could be used
3402 * to add margins to the popper margins needs to be calculated to get the
3403 * correct popper offsets.
3404 * @method
3405 * @memberof Popper.modifiers
3406 * @param {HTMLElement} reference - The reference element used to position the popper
3407 * @param {HTMLElement} popper - The HTML element used as popper
3408 * @param {Object} options - Popper.js options
3409 */
3410 function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
3411 // compute reference element offsets
3412 var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
3413
3414 // compute auto placement, store placement inside the data object,
3415 // modifiers will be able to edit `placement` if needed
3416 // and refer to originalPlacement to know the original value
3417 var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
3418
3419 popper.setAttribute('x-placement', placement);
3420
3421 // Apply `position` to popper before anything else because
3422 // without the position applied we can't guarantee correct computations
3423 setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
3424
3425 return options;
3426 }
3427
3428 /**
3429 * @function
3430 * @memberof Popper.Utils
3431 * @argument {Object} data - The data object generated by `update` method
3432 * @argument {Boolean} shouldRound - If the offsets should be rounded at all
3433 * @returns {Object} The popper's position offsets rounded
3434 *
3435 * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
3436 * good as it can be within reason.
3437 * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
3438 *
3439 * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
3440 * as well on High DPI screens).
3441 *
3442 * Firefox prefers no rounding for positioning and does not have blurriness on
3443 * high DPI screens.
3444 *
3445 * Only horizontal placement and left/right values need to be considered.
3446 */
3447 function getRoundedOffsets(data, shouldRound) {
3448 var _data$offsets = data.offsets,
3449 popper = _data$offsets.popper,
3450 reference = _data$offsets.reference;
3451 var round = Math.round,
3452 floor = Math.floor;
3453
3454 var noRound = function noRound(v) {
3455 return v;
3456 };
3457
3458 var referenceWidth = round(reference.width);
3459 var popperWidth = round(popper.width);
3460
3461 var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
3462 var isVariation = data.placement.indexOf('-') !== -1;
3463 var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
3464 var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
3465
3466 var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
3467 var verticalToInteger = !shouldRound ? noRound : round;
3468
3469 return {
3470 left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
3471 top: verticalToInteger(popper.top),
3472 bottom: verticalToInteger(popper.bottom),
3473 right: horizontalToInteger(popper.right)
3474 };
3475 }
3476
3477 var isFirefox = isBrowser$1 && /Firefox/i.test(navigator.userAgent);
3478
3479 /**
3480 * @function
3481 * @memberof Modifiers
3482 * @argument {Object} data - The data object generated by `update` method
3483 * @argument {Object} options - Modifiers configuration and options
3484 * @returns {Object} The data object, properly modified
3485 */
3486 function computeStyle(data, options) {
3487 var x = options.x,
3488 y = options.y;
3489 var popper = data.offsets.popper;
3490
3491 // Remove this legacy support in Popper.js v2
3492
3493 var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
3494 return modifier.name === 'applyStyle';
3495 }).gpuAcceleration;
3496 if (legacyGpuAccelerationOption !== undefined) {
3497 console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
3498 }
3499 var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
3500
3501 var offsetParent = getOffsetParent(data.instance.popper);
3502 var offsetParentRect = getBoundingClientRect(offsetParent);
3503
3504 // Styles
3505 var styles = {
3506 position: popper.position
3507 };
3508
3509 var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
3510
3511 var sideA = x === 'bottom' ? 'top' : 'bottom';
3512 var sideB = y === 'right' ? 'left' : 'right';
3513
3514 // if gpuAcceleration is set to `true` and transform is supported,
3515 // we use `translate3d` to apply the position to the popper we
3516 // automatically use the supported prefixed version if needed
3517 var prefixedProperty = getSupportedPropertyName('transform');
3518
3519 // now, let's make a step back and look at this code closely (wtf?)
3520 // If the content of the popper grows once it's been positioned, it
3521 // may happen that the popper gets misplaced because of the new content
3522 // overflowing its reference element
3523 // To avoid this problem, we provide two options (x and y), which allow
3524 // the consumer to define the offset origin.
3525 // If we position a popper on top of a reference element, we can set
3526 // `x` to `top` to make the popper grow towards its top instead of
3527 // its bottom.
3528 var left = void 0,
3529 top = void 0;
3530 if (sideA === 'bottom') {
3531 // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
3532 // and not the bottom of the html element
3533 if (offsetParent.nodeName === 'HTML') {
3534 top = -offsetParent.clientHeight + offsets.bottom;
3535 } else {
3536 top = -offsetParentRect.height + offsets.bottom;
3537 }
3538 } else {
3539 top = offsets.top;
3540 }
3541 if (sideB === 'right') {
3542 if (offsetParent.nodeName === 'HTML') {
3543 left = -offsetParent.clientWidth + offsets.right;
3544 } else {
3545 left = -offsetParentRect.width + offsets.right;
3546 }
3547 } else {
3548 left = offsets.left;
3549 }
3550 if (gpuAcceleration && prefixedProperty) {
3551 styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
3552 styles[sideA] = 0;
3553 styles[sideB] = 0;
3554 styles.willChange = 'transform';
3555 } else {
3556 // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
3557 var invertTop = sideA === 'bottom' ? -1 : 1;
3558 var invertLeft = sideB === 'right' ? -1 : 1;
3559 styles[sideA] = top * invertTop;
3560 styles[sideB] = left * invertLeft;
3561 styles.willChange = sideA + ', ' + sideB;
3562 }
3563
3564 // Attributes
3565 var attributes = {
3566 'x-placement': data.placement
3567 };
3568
3569 // Update `data` attributes, styles and arrowStyles
3570 data.attributes = _extends$2({}, attributes, data.attributes);
3571 data.styles = _extends$2({}, styles, data.styles);
3572 data.arrowStyles = _extends$2({}, data.offsets.arrow, data.arrowStyles);
3573
3574 return data;
3575 }
3576
3577 /**
3578 * Helper used to know if the given modifier depends from another one.<br />
3579 * It checks if the needed modifier is listed and enabled.
3580 * @method
3581 * @memberof Popper.Utils
3582 * @param {Array} modifiers - list of modifiers
3583 * @param {String} requestingName - name of requesting modifier
3584 * @param {String} requestedName - name of requested modifier
3585 * @returns {Boolean}
3586 */
3587 function isModifierRequired(modifiers, requestingName, requestedName) {
3588 var requesting = find(modifiers, function (_ref) {
3589 var name = _ref.name;
3590 return name === requestingName;
3591 });
3592
3593 var isRequired = !!requesting && modifiers.some(function (modifier) {
3594 return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
3595 });
3596
3597 if (!isRequired) {
3598 var _requesting = '`' + requestingName + '`';
3599 var requested = '`' + requestedName + '`';
3600 console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
3601 }
3602 return isRequired;
3603 }
3604
3605 /**
3606 * @function
3607 * @memberof Modifiers
3608 * @argument {Object} data - The data object generated by update method
3609 * @argument {Object} options - Modifiers configuration and options
3610 * @returns {Object} The data object, properly modified
3611 */
3612 function arrow(data, options) {
3613 var _data$offsets$arrow;
3614
3615 // arrow depends on keepTogether in order to work
3616 if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
3617 return data;
3618 }
3619
3620 var arrowElement = options.element;
3621
3622 // if arrowElement is a string, suppose it's a CSS selector
3623 if (typeof arrowElement === 'string') {
3624 arrowElement = data.instance.popper.querySelector(arrowElement);
3625
3626 // if arrowElement is not found, don't run the modifier
3627 if (!arrowElement) {
3628 return data;
3629 }
3630 } else {
3631 // if the arrowElement isn't a query selector we must check that the
3632 // provided DOM node is child of its popper node
3633 if (!data.instance.popper.contains(arrowElement)) {
3634 console.warn('WARNING: `arrow.element` must be child of its popper element!');
3635 return data;
3636 }
3637 }
3638
3639 var placement = data.placement.split('-')[0];
3640 var _data$offsets = data.offsets,
3641 popper = _data$offsets.popper,
3642 reference = _data$offsets.reference;
3643
3644 var isVertical = ['left', 'right'].indexOf(placement) !== -1;
3645
3646 var len = isVertical ? 'height' : 'width';
3647 var sideCapitalized = isVertical ? 'Top' : 'Left';
3648 var side = sideCapitalized.toLowerCase();
3649 var altSide = isVertical ? 'left' : 'top';
3650 var opSide = isVertical ? 'bottom' : 'right';
3651 var arrowElementSize = getOuterSizes(arrowElement)[len];
3652
3653 //
3654 // extends keepTogether behavior making sure the popper and its
3655 // reference have enough pixels in conjunction
3656 //
3657
3658 // top/left side
3659 if (reference[opSide] - arrowElementSize < popper[side]) {
3660 data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
3661 }
3662 // bottom/right side
3663 if (reference[side] + arrowElementSize > popper[opSide]) {
3664 data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
3665 }
3666 data.offsets.popper = getClientRect(data.offsets.popper);
3667
3668 // compute center of the popper
3669 var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
3670
3671 // Compute the sideValue using the updated popper offsets
3672 // take popper margin in account because we don't have this info available
3673 var css = getStyleComputedProperty(data.instance.popper);
3674 var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
3675 var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
3676 var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
3677
3678 // prevent arrowElement from being placed not contiguously to its popper
3679 sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
3680
3681 data.arrowElement = arrowElement;
3682 data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty$1(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty$1(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
3683
3684 return data;
3685 }
3686
3687 /**
3688 * Get the opposite placement variation of the given one
3689 * @method
3690 * @memberof Popper.Utils
3691 * @argument {String} placement variation
3692 * @returns {String} flipped placement variation
3693 */
3694 function getOppositeVariation(variation) {
3695 if (variation === 'end') {
3696 return 'start';
3697 } else if (variation === 'start') {
3698 return 'end';
3699 }
3700 return variation;
3701 }
3702
3703 /**
3704 * List of accepted placements to use as values of the `placement` option.<br />
3705 * Valid placements are:
3706 * - `auto`
3707 * - `top`
3708 * - `right`
3709 * - `bottom`
3710 * - `left`
3711 *
3712 * Each placement can have a variation from this list:
3713 * - `-start`
3714 * - `-end`
3715 *
3716 * Variations are interpreted easily if you think of them as the left to right
3717 * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
3718 * is right.<br />
3719 * Vertically (`left` and `right`), `start` is top and `end` is bottom.
3720 *
3721 * Some valid examples are:
3722 * - `top-end` (on top of reference, right aligned)
3723 * - `right-start` (on right of reference, top aligned)
3724 * - `bottom` (on bottom, centered)
3725 * - `auto-end` (on the side with more space available, alignment depends by placement)
3726 *
3727 * @static
3728 * @type {Array}
3729 * @enum {String}
3730 * @readonly
3731 * @method placements
3732 * @memberof Popper
3733 */
3734 var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
3735
3736 // Get rid of `auto` `auto-start` and `auto-end`
3737 var validPlacements = placements.slice(3);
3738
3739 /**
3740 * Given an initial placement, returns all the subsequent placements
3741 * clockwise (or counter-clockwise).
3742 *
3743 * @method
3744 * @memberof Popper.Utils
3745 * @argument {String} placement - A valid placement (it accepts variations)
3746 * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
3747 * @returns {Array} placements including their variations
3748 */
3749 function clockwise(placement) {
3750 var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3751
3752 var index = validPlacements.indexOf(placement);
3753 var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
3754 return counter ? arr.reverse() : arr;
3755 }
3756
3757 var BEHAVIORS = {
3758 FLIP: 'flip',
3759 CLOCKWISE: 'clockwise',
3760 COUNTERCLOCKWISE: 'counterclockwise'
3761 };
3762
3763 /**
3764 * @function
3765 * @memberof Modifiers
3766 * @argument {Object} data - The data object generated by update method
3767 * @argument {Object} options - Modifiers configuration and options
3768 * @returns {Object} The data object, properly modified
3769 */
3770 function flip(data, options) {
3771 // if `inner` modifier is enabled, we can't use the `flip` modifier
3772 if (isModifierEnabled(data.instance.modifiers, 'inner')) {
3773 return data;
3774 }
3775
3776 if (data.flipped && data.placement === data.originalPlacement) {
3777 // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
3778 return data;
3779 }
3780
3781 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
3782
3783 var placement = data.placement.split('-')[0];
3784 var placementOpposite = getOppositePlacement(placement);
3785 var variation = data.placement.split('-')[1] || '';
3786
3787 var flipOrder = [];
3788
3789 switch (options.behavior) {
3790 case BEHAVIORS.FLIP:
3791 flipOrder = [placement, placementOpposite];
3792 break;
3793 case BEHAVIORS.CLOCKWISE:
3794 flipOrder = clockwise(placement);
3795 break;
3796 case BEHAVIORS.COUNTERCLOCKWISE:
3797 flipOrder = clockwise(placement, true);
3798 break;
3799 default:
3800 flipOrder = options.behavior;
3801 }
3802
3803 flipOrder.forEach(function (step, index) {
3804 if (placement !== step || flipOrder.length === index + 1) {
3805 return data;
3806 }
3807
3808 placement = data.placement.split('-')[0];
3809 placementOpposite = getOppositePlacement(placement);
3810
3811 var popperOffsets = data.offsets.popper;
3812 var refOffsets = data.offsets.reference;
3813
3814 // using floor because the reference offsets may contain decimals we are not going to consider here
3815 var floor = Math.floor;
3816 var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
3817
3818 var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
3819 var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
3820 var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
3821 var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
3822
3823 var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
3824
3825 // flip the variation if required
3826 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
3827
3828 // flips variation if reference element overflows boundaries
3829 var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
3830
3831 // flips variation if popper content overflows boundaries
3832 var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
3833
3834 var flippedVariation = flippedVariationByRef || flippedVariationByContent;
3835
3836 if (overlapsRef || overflowsBoundaries || flippedVariation) {
3837 // this boolean to detect any flip loop
3838 data.flipped = true;
3839
3840 if (overlapsRef || overflowsBoundaries) {
3841 placement = flipOrder[index + 1];
3842 }
3843
3844 if (flippedVariation) {
3845 variation = getOppositeVariation(variation);
3846 }
3847
3848 data.placement = placement + (variation ? '-' + variation : '');
3849
3850 // this object contains `position`, we want to preserve it along with
3851 // any additional property we may add in the future
3852 data.offsets.popper = _extends$2({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
3853
3854 data = runModifiers(data.instance.modifiers, data, 'flip');
3855 }
3856 });
3857 return data;
3858 }
3859
3860 /**
3861 * @function
3862 * @memberof Modifiers
3863 * @argument {Object} data - The data object generated by update method
3864 * @argument {Object} options - Modifiers configuration and options
3865 * @returns {Object} The data object, properly modified
3866 */
3867 function keepTogether(data) {
3868 var _data$offsets = data.offsets,
3869 popper = _data$offsets.popper,
3870 reference = _data$offsets.reference;
3871
3872 var placement = data.placement.split('-')[0];
3873 var floor = Math.floor;
3874 var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
3875 var side = isVertical ? 'right' : 'bottom';
3876 var opSide = isVertical ? 'left' : 'top';
3877 var measurement = isVertical ? 'width' : 'height';
3878
3879 if (popper[side] < floor(reference[opSide])) {
3880 data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
3881 }
3882 if (popper[opSide] > floor(reference[side])) {
3883 data.offsets.popper[opSide] = floor(reference[side]);
3884 }
3885
3886 return data;
3887 }
3888
3889 /**
3890 * Converts a string containing value + unit into a px value number
3891 * @function
3892 * @memberof {modifiers~offset}
3893 * @private
3894 * @argument {String} str - Value + unit string
3895 * @argument {String} measurement - `height` or `width`
3896 * @argument {Object} popperOffsets
3897 * @argument {Object} referenceOffsets
3898 * @returns {Number|String}
3899 * Value in pixels, or original string if no values were extracted
3900 */
3901 function toValue(str, measurement, popperOffsets, referenceOffsets) {
3902 // separate value from unit
3903 var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
3904 var value = +split[1];
3905 var unit = split[2];
3906
3907 // If it's not a number it's an operator, I guess
3908 if (!value) {
3909 return str;
3910 }
3911
3912 if (unit.indexOf('%') === 0) {
3913 var element = void 0;
3914 switch (unit) {
3915 case '%p':
3916 element = popperOffsets;
3917 break;
3918 case '%':
3919 case '%r':
3920 default:
3921 element = referenceOffsets;
3922 }
3923
3924 var rect = getClientRect(element);
3925 return rect[measurement] / 100 * value;
3926 } else if (unit === 'vh' || unit === 'vw') {
3927 // if is a vh or vw, we calculate the size based on the viewport
3928 var size = void 0;
3929 if (unit === 'vh') {
3930 size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
3931 } else {
3932 size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
3933 }
3934 return size / 100 * value;
3935 } else {
3936 // if is an explicit pixel unit, we get rid of the unit and keep the value
3937 // if is an implicit unit, it's px, and we return just the value
3938 return value;
3939 }
3940 }
3941
3942 /**
3943 * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
3944 * @function
3945 * @memberof {modifiers~offset}
3946 * @private
3947 * @argument {String} offset
3948 * @argument {Object} popperOffsets
3949 * @argument {Object} referenceOffsets
3950 * @argument {String} basePlacement
3951 * @returns {Array} a two cells array with x and y offsets in numbers
3952 */
3953 function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
3954 var offsets = [0, 0];
3955
3956 // Use height if placement is left or right and index is 0 otherwise use width
3957 // in this way the first offset will use an axis and the second one
3958 // will use the other one
3959 var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
3960
3961 // Split the offset string to obtain a list of values and operands
3962 // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
3963 var fragments = offset.split(/(\+|\-)/).map(function (frag) {
3964 return frag.trim();
3965 });
3966
3967 // Detect if the offset string contains a pair of values or a single one
3968 // they could be separated by comma or space
3969 var divider = fragments.indexOf(find(fragments, function (frag) {
3970 return frag.search(/,|\s/) !== -1;
3971 }));
3972
3973 if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
3974 console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
3975 }
3976
3977 // If divider is found, we divide the list of values and operands to divide
3978 // them by ofset X and Y.
3979 var splitRegex = /\s*,\s*|\s+/;
3980 var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
3981
3982 // Convert the values with units to absolute pixels to allow our computations
3983 ops = ops.map(function (op, index) {
3984 // Most of the units rely on the orientation of the popper
3985 var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
3986 var mergeWithPrevious = false;
3987 return op
3988 // This aggregates any `+` or `-` sign that aren't considered operators
3989 // e.g.: 10 + +5 => [10, +, +5]
3990 .reduce(function (a, b) {
3991 if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
3992 a[a.length - 1] = b;
3993 mergeWithPrevious = true;
3994 return a;
3995 } else if (mergeWithPrevious) {
3996 a[a.length - 1] += b;
3997 mergeWithPrevious = false;
3998 return a;
3999 } else {
4000 return a.concat(b);
4001 }
4002 }, [])
4003 // Here we convert the string values into number values (in px)
4004 .map(function (str) {
4005 return toValue(str, measurement, popperOffsets, referenceOffsets);
4006 });
4007 });
4008
4009 // Loop trough the offsets arrays and execute the operations
4010 ops.forEach(function (op, index) {
4011 op.forEach(function (frag, index2) {
4012 if (isNumeric(frag)) {
4013 offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
4014 }
4015 });
4016 });
4017 return offsets;
4018 }
4019
4020 /**
4021 * @function
4022 * @memberof Modifiers
4023 * @argument {Object} data - The data object generated by update method
4024 * @argument {Object} options - Modifiers configuration and options
4025 * @argument {Number|String} options.offset=0
4026 * The offset value as described in the modifier description
4027 * @returns {Object} The data object, properly modified
4028 */
4029 function offset(data, _ref) {
4030 var offset = _ref.offset;
4031 var placement = data.placement,
4032 _data$offsets = data.offsets,
4033 popper = _data$offsets.popper,
4034 reference = _data$offsets.reference;
4035
4036 var basePlacement = placement.split('-')[0];
4037
4038 var offsets = void 0;
4039 if (isNumeric(+offset)) {
4040 offsets = [+offset, 0];
4041 } else {
4042 offsets = parseOffset(offset, popper, reference, basePlacement);
4043 }
4044
4045 if (basePlacement === 'left') {
4046 popper.top += offsets[0];
4047 popper.left -= offsets[1];
4048 } else if (basePlacement === 'right') {
4049 popper.top += offsets[0];
4050 popper.left += offsets[1];
4051 } else if (basePlacement === 'top') {
4052 popper.left += offsets[0];
4053 popper.top -= offsets[1];
4054 } else if (basePlacement === 'bottom') {
4055 popper.left += offsets[0];
4056 popper.top += offsets[1];
4057 }
4058
4059 data.popper = popper;
4060 return data;
4061 }
4062
4063 /**
4064 * @function
4065 * @memberof Modifiers
4066 * @argument {Object} data - The data object generated by `update` method
4067 * @argument {Object} options - Modifiers configuration and options
4068 * @returns {Object} The data object, properly modified
4069 */
4070 function preventOverflow(data, options) {
4071 var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
4072
4073 // If offsetParent is the reference element, we really want to
4074 // go one step up and use the next offsetParent as reference to
4075 // avoid to make this modifier completely useless and look like broken
4076 if (data.instance.reference === boundariesElement) {
4077 boundariesElement = getOffsetParent(boundariesElement);
4078 }
4079
4080 // NOTE: DOM access here
4081 // resets the popper's position so that the document size can be calculated excluding
4082 // the size of the popper element itself
4083 var transformProp = getSupportedPropertyName('transform');
4084 var popperStyles = data.instance.popper.style; // assignment to help minification
4085 var top = popperStyles.top,
4086 left = popperStyles.left,
4087 transform = popperStyles[transformProp];
4088
4089 popperStyles.top = '';
4090 popperStyles.left = '';
4091 popperStyles[transformProp] = '';
4092
4093 var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
4094
4095 // NOTE: DOM access here
4096 // restores the original style properties after the offsets have been computed
4097 popperStyles.top = top;
4098 popperStyles.left = left;
4099 popperStyles[transformProp] = transform;
4100
4101 options.boundaries = boundaries;
4102
4103 var order = options.priority;
4104 var popper = data.offsets.popper;
4105
4106 var check = {
4107 primary: function primary(placement) {
4108 var value = popper[placement];
4109 if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
4110 value = Math.max(popper[placement], boundaries[placement]);
4111 }
4112 return defineProperty$1({}, placement, value);
4113 },
4114 secondary: function secondary(placement) {
4115 var mainSide = placement === 'right' ? 'left' : 'top';
4116 var value = popper[mainSide];
4117 if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
4118 value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
4119 }
4120 return defineProperty$1({}, mainSide, value);
4121 }
4122 };
4123
4124 order.forEach(function (placement) {
4125 var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
4126 popper = _extends$2({}, popper, check[side](placement));
4127 });
4128
4129 data.offsets.popper = popper;
4130
4131 return data;
4132 }
4133
4134 /**
4135 * @function
4136 * @memberof Modifiers
4137 * @argument {Object} data - The data object generated by `update` method
4138 * @argument {Object} options - Modifiers configuration and options
4139 * @returns {Object} The data object, properly modified
4140 */
4141 function shift(data) {
4142 var placement = data.placement;
4143 var basePlacement = placement.split('-')[0];
4144 var shiftvariation = placement.split('-')[1];
4145
4146 // if shift shiftvariation is specified, run the modifier
4147 if (shiftvariation) {
4148 var _data$offsets = data.offsets,
4149 reference = _data$offsets.reference,
4150 popper = _data$offsets.popper;
4151
4152 var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
4153 var side = isVertical ? 'left' : 'top';
4154 var measurement = isVertical ? 'width' : 'height';
4155
4156 var shiftOffsets = {
4157 start: defineProperty$1({}, side, reference[side]),
4158 end: defineProperty$1({}, side, reference[side] + reference[measurement] - popper[measurement])
4159 };
4160
4161 data.offsets.popper = _extends$2({}, popper, shiftOffsets[shiftvariation]);
4162 }
4163
4164 return data;
4165 }
4166
4167 /**
4168 * @function
4169 * @memberof Modifiers
4170 * @argument {Object} data - The data object generated by update method
4171 * @argument {Object} options - Modifiers configuration and options
4172 * @returns {Object} The data object, properly modified
4173 */
4174 function hide(data) {
4175 if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
4176 return data;
4177 }
4178
4179 var refRect = data.offsets.reference;
4180 var bound = find(data.instance.modifiers, function (modifier) {
4181 return modifier.name === 'preventOverflow';
4182 }).boundaries;
4183
4184 if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
4185 // Avoid unnecessary DOM access if visibility hasn't changed
4186 if (data.hide === true) {
4187 return data;
4188 }
4189
4190 data.hide = true;
4191 data.attributes['x-out-of-boundaries'] = '';
4192 } else {
4193 // Avoid unnecessary DOM access if visibility hasn't changed
4194 if (data.hide === false) {
4195 return data;
4196 }
4197
4198 data.hide = false;
4199 data.attributes['x-out-of-boundaries'] = false;
4200 }
4201
4202 return data;
4203 }
4204
4205 /**
4206 * @function
4207 * @memberof Modifiers
4208 * @argument {Object} data - The data object generated by `update` method
4209 * @argument {Object} options - Modifiers configuration and options
4210 * @returns {Object} The data object, properly modified
4211 */
4212 function inner(data) {
4213 var placement = data.placement;
4214 var basePlacement = placement.split('-')[0];
4215 var _data$offsets = data.offsets,
4216 popper = _data$offsets.popper,
4217 reference = _data$offsets.reference;
4218
4219 var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
4220
4221 var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
4222
4223 popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
4224
4225 data.placement = getOppositePlacement(placement);
4226 data.offsets.popper = getClientRect(popper);
4227
4228 return data;
4229 }
4230
4231 /**
4232 * Modifier function, each modifier can have a function of this type assigned
4233 * to its `fn` property.<br />
4234 * These functions will be called on each update, this means that you must
4235 * make sure they are performant enough to avoid performance bottlenecks.
4236 *
4237 * @function ModifierFn
4238 * @argument {dataObject} data - The data object generated by `update` method
4239 * @argument {Object} options - Modifiers configuration and options
4240 * @returns {dataObject} The data object, properly modified
4241 */
4242
4243 /**
4244 * Modifiers are plugins used to alter the behavior of your poppers.<br />
4245 * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
4246 * needed by the library.
4247 *
4248 * Usually you don't want to override the `order`, `fn` and `onLoad` props.
4249 * All the other properties are configurations that could be tweaked.
4250 * @namespace modifiers
4251 */
4252 var modifiers = {
4253 /**
4254 * Modifier used to shift the popper on the start or end of its reference
4255 * element.<br />
4256 * It will read the variation of the `placement` property.<br />
4257 * It can be one either `-end` or `-start`.
4258 * @memberof modifiers
4259 * @inner
4260 */
4261 shift: {
4262 /** @prop {number} order=100 - Index used to define the order of execution */
4263 order: 100,
4264 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4265 enabled: true,
4266 /** @prop {ModifierFn} */
4267 fn: shift
4268 },
4269
4270 /**
4271 * The `offset` modifier can shift your popper on both its axis.
4272 *
4273 * It accepts the following units:
4274 * - `px` or unit-less, interpreted as pixels
4275 * - `%` or `%r`, percentage relative to the length of the reference element
4276 * - `%p`, percentage relative to the length of the popper element
4277 * - `vw`, CSS viewport width unit
4278 * - `vh`, CSS viewport height unit
4279 *
4280 * For length is intended the main axis relative to the placement of the popper.<br />
4281 * This means that if the placement is `top` or `bottom`, the length will be the
4282 * `width`. In case of `left` or `right`, it will be the `height`.
4283 *
4284 * You can provide a single value (as `Number` or `String`), or a pair of values
4285 * as `String` divided by a comma or one (or more) white spaces.<br />
4286 * The latter is a deprecated method because it leads to confusion and will be
4287 * removed in v2.<br />
4288 * Additionally, it accepts additions and subtractions between different units.
4289 * Note that multiplications and divisions aren't supported.
4290 *
4291 * Valid examples are:
4292 * ```
4293 * 10
4294 * '10%'
4295 * '10, 10'
4296 * '10%, 10'
4297 * '10 + 10%'
4298 * '10 - 5vh + 3%'
4299 * '-10px + 5vh, 5px - 6%'
4300 * ```
4301 * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
4302 * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
4303 * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
4304 *
4305 * @memberof modifiers
4306 * @inner
4307 */
4308 offset: {
4309 /** @prop {number} order=200 - Index used to define the order of execution */
4310 order: 200,
4311 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4312 enabled: true,
4313 /** @prop {ModifierFn} */
4314 fn: offset,
4315 /** @prop {Number|String} offset=0
4316 * The offset value as described in the modifier description
4317 */
4318 offset: 0
4319 },
4320
4321 /**
4322 * Modifier used to prevent the popper from being positioned outside the boundary.
4323 *
4324 * A scenario exists where the reference itself is not within the boundaries.<br />
4325 * We can say it has "escaped the boundaries" — or just "escaped".<br />
4326 * In this case we need to decide whether the popper should either:
4327 *
4328 * - detach from the reference and remain "trapped" in the boundaries, or
4329 * - if it should ignore the boundary and "escape with its reference"
4330 *
4331 * When `escapeWithReference` is set to`true` and reference is completely
4332 * outside its boundaries, the popper will overflow (or completely leave)
4333 * the boundaries in order to remain attached to the edge of the reference.
4334 *
4335 * @memberof modifiers
4336 * @inner
4337 */
4338 preventOverflow: {
4339 /** @prop {number} order=300 - Index used to define the order of execution */
4340 order: 300,
4341 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4342 enabled: true,
4343 /** @prop {ModifierFn} */
4344 fn: preventOverflow,
4345 /**
4346 * @prop {Array} [priority=['left','right','top','bottom']]
4347 * Popper will try to prevent overflow following these priorities by default,
4348 * then, it could overflow on the left and on top of the `boundariesElement`
4349 */
4350 priority: ['left', 'right', 'top', 'bottom'],
4351 /**
4352 * @prop {number} padding=5
4353 * Amount of pixel used to define a minimum distance between the boundaries
4354 * and the popper. This makes sure the popper always has a little padding
4355 * between the edges of its container
4356 */
4357 padding: 5,
4358 /**
4359 * @prop {String|HTMLElement} boundariesElement='scrollParent'
4360 * Boundaries used by the modifier. Can be `scrollParent`, `window`,
4361 * `viewport` or any DOM element.
4362 */
4363 boundariesElement: 'scrollParent'
4364 },
4365
4366 /**
4367 * Modifier used to make sure the reference and its popper stay near each other
4368 * without leaving any gap between the two. Especially useful when the arrow is
4369 * enabled and you want to ensure that it points to its reference element.
4370 * It cares only about the first axis. You can still have poppers with margin
4371 * between the popper and its reference element.
4372 * @memberof modifiers
4373 * @inner
4374 */
4375 keepTogether: {
4376 /** @prop {number} order=400 - Index used to define the order of execution */
4377 order: 400,
4378 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4379 enabled: true,
4380 /** @prop {ModifierFn} */
4381 fn: keepTogether
4382 },
4383
4384 /**
4385 * This modifier is used to move the `arrowElement` of the popper to make
4386 * sure it is positioned between the reference element and its popper element.
4387 * It will read the outer size of the `arrowElement` node to detect how many
4388 * pixels of conjunction are needed.
4389 *
4390 * It has no effect if no `arrowElement` is provided.
4391 * @memberof modifiers
4392 * @inner
4393 */
4394 arrow: {
4395 /** @prop {number} order=500 - Index used to define the order of execution */
4396 order: 500,
4397 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4398 enabled: true,
4399 /** @prop {ModifierFn} */
4400 fn: arrow,
4401 /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
4402 element: '[x-arrow]'
4403 },
4404
4405 /**
4406 * Modifier used to flip the popper's placement when it starts to overlap its
4407 * reference element.
4408 *
4409 * Requires the `preventOverflow` modifier before it in order to work.
4410 *
4411 * **NOTE:** this modifier will interrupt the current update cycle and will
4412 * restart it if it detects the need to flip the placement.
4413 * @memberof modifiers
4414 * @inner
4415 */
4416 flip: {
4417 /** @prop {number} order=600 - Index used to define the order of execution */
4418 order: 600,
4419 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4420 enabled: true,
4421 /** @prop {ModifierFn} */
4422 fn: flip,
4423 /**
4424 * @prop {String|Array} behavior='flip'
4425 * The behavior used to change the popper's placement. It can be one of
4426 * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
4427 * placements (with optional variations)
4428 */
4429 behavior: 'flip',
4430 /**
4431 * @prop {number} padding=5
4432 * The popper will flip if it hits the edges of the `boundariesElement`
4433 */
4434 padding: 5,
4435 /**
4436 * @prop {String|HTMLElement} boundariesElement='viewport'
4437 * The element which will define the boundaries of the popper position.
4438 * The popper will never be placed outside of the defined boundaries
4439 * (except if `keepTogether` is enabled)
4440 */
4441 boundariesElement: 'viewport',
4442 /**
4443 * @prop {Boolean} flipVariations=false
4444 * The popper will switch placement variation between `-start` and `-end` when
4445 * the reference element overlaps its boundaries.
4446 *
4447 * The original placement should have a set variation.
4448 */
4449 flipVariations: false,
4450 /**
4451 * @prop {Boolean} flipVariationsByContent=false
4452 * The popper will switch placement variation between `-start` and `-end` when
4453 * the popper element overlaps its reference boundaries.
4454 *
4455 * The original placement should have a set variation.
4456 */
4457 flipVariationsByContent: false
4458 },
4459
4460 /**
4461 * Modifier used to make the popper flow toward the inner of the reference element.
4462 * By default, when this modifier is disabled, the popper will be placed outside
4463 * the reference element.
4464 * @memberof modifiers
4465 * @inner
4466 */
4467 inner: {
4468 /** @prop {number} order=700 - Index used to define the order of execution */
4469 order: 700,
4470 /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
4471 enabled: false,
4472 /** @prop {ModifierFn} */
4473 fn: inner
4474 },
4475
4476 /**
4477 * Modifier used to hide the popper when its reference element is outside of the
4478 * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
4479 * be used to hide with a CSS selector the popper when its reference is
4480 * out of boundaries.
4481 *
4482 * Requires the `preventOverflow` modifier before it in order to work.
4483 * @memberof modifiers
4484 * @inner
4485 */
4486 hide: {
4487 /** @prop {number} order=800 - Index used to define the order of execution */
4488 order: 800,
4489 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4490 enabled: true,
4491 /** @prop {ModifierFn} */
4492 fn: hide
4493 },
4494
4495 /**
4496 * Computes the style that will be applied to the popper element to gets
4497 * properly positioned.
4498 *
4499 * Note that this modifier will not touch the DOM, it just prepares the styles
4500 * so that `applyStyle` modifier can apply it. This separation is useful
4501 * in case you need to replace `applyStyle` with a custom implementation.
4502 *
4503 * This modifier has `850` as `order` value to maintain backward compatibility
4504 * with previous versions of Popper.js. Expect the modifiers ordering method
4505 * to change in future major versions of the library.
4506 *
4507 * @memberof modifiers
4508 * @inner
4509 */
4510 computeStyle: {
4511 /** @prop {number} order=850 - Index used to define the order of execution */
4512 order: 850,
4513 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4514 enabled: true,
4515 /** @prop {ModifierFn} */
4516 fn: computeStyle,
4517 /**
4518 * @prop {Boolean} gpuAcceleration=true
4519 * If true, it uses the CSS 3D transformation to position the popper.
4520 * Otherwise, it will use the `top` and `left` properties
4521 */
4522 gpuAcceleration: true,
4523 /**
4524 * @prop {string} [x='bottom']
4525 * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
4526 * Change this if your popper should grow in a direction different from `bottom`
4527 */
4528 x: 'bottom',
4529 /**
4530 * @prop {string} [x='left']
4531 * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
4532 * Change this if your popper should grow in a direction different from `right`
4533 */
4534 y: 'right'
4535 },
4536
4537 /**
4538 * Applies the computed styles to the popper element.
4539 *
4540 * All the DOM manipulations are limited to this modifier. This is useful in case
4541 * you want to integrate Popper.js inside a framework or view library and you
4542 * want to delegate all the DOM manipulations to it.
4543 *
4544 * Note that if you disable this modifier, you must make sure the popper element
4545 * has its position set to `absolute` before Popper.js can do its work!
4546 *
4547 * Just disable this modifier and define your own to achieve the desired effect.
4548 *
4549 * @memberof modifiers
4550 * @inner
4551 */
4552 applyStyle: {
4553 /** @prop {number} order=900 - Index used to define the order of execution */
4554 order: 900,
4555 /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
4556 enabled: true,
4557 /** @prop {ModifierFn} */
4558 fn: applyStyle,
4559 /** @prop {Function} */
4560 onLoad: applyStyleOnLoad,
4561 /**
4562 * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
4563 * @prop {Boolean} gpuAcceleration=true
4564 * If true, it uses the CSS 3D transformation to position the popper.
4565 * Otherwise, it will use the `top` and `left` properties
4566 */
4567 gpuAcceleration: undefined
4568 }
4569 };
4570
4571 /**
4572 * The `dataObject` is an object containing all the information used by Popper.js.
4573 * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
4574 * @name dataObject
4575 * @property {Object} data.instance The Popper.js instance
4576 * @property {String} data.placement Placement applied to popper
4577 * @property {String} data.originalPlacement Placement originally defined on init
4578 * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
4579 * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
4580 * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
4581 * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
4582 * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
4583 * @property {Object} data.boundaries Offsets of the popper boundaries
4584 * @property {Object} data.offsets The measurements of popper, reference and arrow elements
4585 * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
4586 * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
4587 * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
4588 */
4589
4590 /**
4591 * Default options provided to Popper.js constructor.<br />
4592 * These can be overridden using the `options` argument of Popper.js.<br />
4593 * To override an option, simply pass an object with the same
4594 * structure of the `options` object, as the 3rd argument. For example:
4595 * ```
4596 * new Popper(ref, pop, {
4597 * modifiers: {
4598 * preventOverflow: { enabled: false }
4599 * }
4600 * })
4601 * ```
4602 * @type {Object}
4603 * @static
4604 * @memberof Popper
4605 */
4606 var Defaults = {
4607 /**
4608 * Popper's placement.
4609 * @prop {Popper.placements} placement='bottom'
4610 */
4611 placement: 'bottom',
4612
4613 /**
4614 * Set this to true if you want popper to position it self in 'fixed' mode
4615 * @prop {Boolean} positionFixed=false
4616 */
4617 positionFixed: false,
4618
4619 /**
4620 * Whether events (resize, scroll) are initially enabled.
4621 * @prop {Boolean} eventsEnabled=true
4622 */
4623 eventsEnabled: true,
4624
4625 /**
4626 * Set to true if you want to automatically remove the popper when
4627 * you call the `destroy` method.
4628 * @prop {Boolean} removeOnDestroy=false
4629 */
4630 removeOnDestroy: false,
4631
4632 /**
4633 * Callback called when the popper is created.<br />
4634 * By default, it is set to no-op.<br />
4635 * Access Popper.js instance with `data.instance`.
4636 * @prop {onCreate}
4637 */
4638 onCreate: function onCreate() {},
4639
4640 /**
4641 * Callback called when the popper is updated. This callback is not called
4642 * on the initialization/creation of the popper, but only on subsequent
4643 * updates.<br />
4644 * By default, it is set to no-op.<br />
4645 * Access Popper.js instance with `data.instance`.
4646 * @prop {onUpdate}
4647 */
4648 onUpdate: function onUpdate() {},
4649
4650 /**
4651 * List of modifiers used to modify the offsets before they are applied to the popper.
4652 * They provide most of the functionalities of Popper.js.
4653 * @prop {modifiers}
4654 */
4655 modifiers: modifiers
4656 };
4657
4658 /**
4659 * @callback onCreate
4660 * @param {dataObject} data
4661 */
4662
4663 /**
4664 * @callback onUpdate
4665 * @param {dataObject} data
4666 */
4667
4668 // Utils
4669 // Methods
4670 var Popper = function () {
4671 /**
4672 * Creates a new Popper.js instance.
4673 * @class Popper
4674 * @param {Element|referenceObject} reference - The reference element used to position the popper
4675 * @param {Element} popper - The HTML / XML element used as the popper
4676 * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
4677 * @return {Object} instance - The generated Popper.js instance
4678 */
4679 function Popper(reference, popper) {
4680 var _this = this;
4681
4682 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4683 classCallCheck(this, Popper);
4684
4685 this.scheduleUpdate = function () {
4686 return requestAnimationFrame(_this.update);
4687 };
4688
4689 // make update() debounced, so that it only runs at most once-per-tick
4690 this.update = debounce$1(this.update.bind(this));
4691
4692 // with {} we create a new object with the options inside it
4693 this.options = _extends$2({}, Popper.Defaults, options);
4694
4695 // init state
4696 this.state = {
4697 isDestroyed: false,
4698 isCreated: false,
4699 scrollParents: []
4700 };
4701
4702 // get reference and popper elements (allow jQuery wrappers)
4703 this.reference = reference && reference.jquery ? reference[0] : reference;
4704 this.popper = popper && popper.jquery ? popper[0] : popper;
4705
4706 // Deep merge modifiers options
4707 this.options.modifiers = {};
4708 Object.keys(_extends$2({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
4709 _this.options.modifiers[name] = _extends$2({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
4710 });
4711
4712 // Refactoring modifiers' list (Object => Array)
4713 this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
4714 return _extends$2({
4715 name: name
4716 }, _this.options.modifiers[name]);
4717 })
4718 // sort the modifiers by order
4719 .sort(function (a, b) {
4720 return a.order - b.order;
4721 });
4722
4723 // modifiers have the ability to execute arbitrary code when Popper.js get inited
4724 // such code is executed in the same order of its modifier
4725 // they could add new properties to their options configuration
4726 // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
4727 this.modifiers.forEach(function (modifierOptions) {
4728 if (modifierOptions.enabled && isFunction$1(modifierOptions.onLoad)) {
4729 modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
4730 }
4731 });
4732
4733 // fire the first update to position the popper in the right place
4734 this.update();
4735
4736 var eventsEnabled = this.options.eventsEnabled;
4737 if (eventsEnabled) {
4738 // setup event listeners, they will take care of update the position in specific situations
4739 this.enableEventListeners();
4740 }
4741
4742 this.state.eventsEnabled = eventsEnabled;
4743 }
4744
4745 // We can't use class properties because they don't get listed in the
4746 // class prototype and break stuff like Sinon stubs
4747
4748
4749 createClass(Popper, [{
4750 key: 'update',
4751 value: function update$$1() {
4752 return update.call(this);
4753 }
4754 }, {
4755 key: 'destroy',
4756 value: function destroy$$1() {
4757 return destroy.call(this);
4758 }
4759 }, {
4760 key: 'enableEventListeners',
4761 value: function enableEventListeners$$1() {
4762 return enableEventListeners.call(this);
4763 }
4764 }, {
4765 key: 'disableEventListeners',
4766 value: function disableEventListeners$$1() {
4767 return disableEventListeners.call(this);
4768 }
4769
4770 /**
4771 * Schedules an update. It will run on the next UI update available.
4772 * @method scheduleUpdate
4773 * @memberof Popper
4774 */
4775
4776
4777 /**
4778 * Collection of utilities useful when writing custom modifiers.
4779 * Starting from version 1.7, this method is available only if you
4780 * include `popper-utils.js` before `popper.js`.
4781 *
4782 * **DEPRECATION**: This way to access PopperUtils is deprecated
4783 * and will be removed in v2! Use the PopperUtils module directly instead.
4784 * Due to the high instability of the methods contained in Utils, we can't
4785 * guarantee them to follow semver. Use them at your own risk!
4786 * @static
4787 * @private
4788 * @type {Object}
4789 * @deprecated since version 1.8
4790 * @member Utils
4791 * @memberof Popper
4792 */
4793
4794 }]);
4795 return Popper;
4796 }();
4797
4798 /**
4799 * The `referenceObject` is an object that provides an interface compatible with Popper.js
4800 * and lets you use it as replacement of a real DOM node.<br />
4801 * You can use this method to position a popper relatively to a set of coordinates
4802 * in case you don't have a DOM node to use as reference.
4803 *
4804 * ```
4805 * new Popper(referenceObject, popperNode);
4806 * ```
4807 *
4808 * NB: This feature isn't supported in Internet Explorer 10.
4809 * @name referenceObject
4810 * @property {Function} data.getBoundingClientRect
4811 * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
4812 * @property {number} data.clientWidth
4813 * An ES6 getter that will return the width of the virtual reference element.
4814 * @property {number} data.clientHeight
4815 * An ES6 getter that will return the height of the virtual reference element.
4816 */
4817
4818
4819 Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
4820 Popper.placements = placements;
4821 Popper.Defaults = Defaults;
4822
4823 /**!
4824 * tippy.js v5.0.0-beta.1
4825 * (c) 2017-2019 atomiks
4826 * MIT License
4827 */
4828
4829 var version = "5.0.0-beta.1";
4830
4831 var idCounter = 1; // Workaround for IE11's lack of new MouseEvent constructor
4832
4833 var mouseMoveListeners = [];
4834 /**
4835 * Creates and returns a Tippy object. We're using a closure pattern instead of
4836 * a class so that the exposed object API is clean without private members
4837 * prefixed with `_`.
4838 */
4839
4840 function createTippy(reference, collectionProps) {
4841 var props = evaluateProps(reference, collectionProps); // If the reference shouldn't have multiple tippys, return null early
4842
4843 if (!props.multiple && reference._tippy) {
4844 return null;
4845 }
4846 /* ======================= 🔒 Private members 🔒 ======================= */
4847
4848
4849 var lastTriggerEventType;
4850 var showTimeout;
4851 var hideTimeout;
4852 var scheduleHideAnimationFrame;
4853 var isBeingDestroyed = false;
4854 var hasMountCallbackRun = false;
4855 var didHideDueToDocumentMouseDown = false;
4856 var currentMountCallback;
4857 var currentTransitionEndListener;
4858 var listeners = [];
4859 var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);
4860 /* ======================= 🔑 Public members 🔑 ======================= */
4861
4862 var id = idCounter++;
4863 var popper = createPopperElement(id, props);
4864 var popperChildren = getChildren(popper);
4865 var popperInstance = null; // These two elements are static
4866
4867 var tooltip = popperChildren.tooltip,
4868 content = popperChildren.content;
4869 var state = {
4870 // The current real placement (`data-placement` attribute)
4871 currentPlacement: props.placement,
4872 // Does the instance have a pending timeout for show()?
4873 isScheduledToShow: false,
4874 // Is the instance currently enabled?
4875 isEnabled: true,
4876 // Is the tippy currently showing and not transitioning out?
4877 isVisible: false,
4878 // Has the instance been destroyed?
4879 isDestroyed: false,
4880 // Is the tippy currently mounted to the DOM?
4881 isMounted: false,
4882 // Has the tippy finished transitioning in?
4883 isShown: false
4884 };
4885 var instance = {
4886 // properties
4887 id: id,
4888 reference: reference,
4889 popper: popper,
4890 popperChildren: popperChildren,
4891 popperInstance: popperInstance,
4892 props: props,
4893 state: state,
4894 // methods
4895 clearDelayTimeouts: clearDelayTimeouts,
4896 setProps: setProps,
4897 setContent: setContent,
4898 show: show,
4899 hide: hide,
4900 enable: enable,
4901 disable: disable,
4902 destroy: destroy
4903 };
4904 /* ==================== Initial instance mutations =================== */
4905
4906
4907 reference._tippy = instance;
4908 popper._tippy = instance;
4909 addTriggersToEventListenersTarget();
4910
4911 if (!props.lazy) {
4912 createPopperInstance();
4913 }
4914
4915 if (props.showOnCreate) {
4916 scheduleShow();
4917 } // Prevent a tippy with a delay from hiding if the cursor left then returned
4918 // before it started hiding
4919
4920
4921 popper.addEventListener('mouseenter', function () {
4922 if (instance.props.interactive && instance.state.isVisible && lastTriggerEventType === 'mouseenter') {
4923 instance.clearDelayTimeouts();
4924 }
4925 });
4926 popper.addEventListener('mouseleave', function () {
4927 if (instance.props.interactive && lastTriggerEventType === 'mouseenter') {
4928 document.addEventListener('mousemove', debouncedOnMouseMove);
4929 }
4930 });
4931 props.onCreate(instance);
4932 return instance;
4933 /* ======================= 🔒 Private methods 🔒 ======================= */
4934
4935 function getNormalizedTouchSettings() {
4936 var touch = instance.props.touch;
4937 return Array.isArray(touch) ? touch : [touch, 0];
4938 }
4939
4940 function getIsCustomTouchBehavior() {
4941 return getNormalizedTouchSettings()[0] === 'hold';
4942 }
4943
4944 function getTransitionableElements() {
4945 return [tooltip, content, instance.popperChildren.backdrop];
4946 }
4947
4948 function getEventListenersTarget() {
4949 return instance.props.triggerTarget || reference;
4950 }
4951
4952 function cleanupInteractiveMouseListeners() {
4953 document.body.removeEventListener('mouseleave', scheduleHide);
4954 document.removeEventListener('mousemove', debouncedOnMouseMove);
4955 mouseMoveListeners = mouseMoveListeners.filter(function (listener) {
4956 return listener !== debouncedOnMouseMove;
4957 });
4958 }
4959
4960 function onDocumentMouseDown(event) {
4961 // Clicked on interactive popper
4962 if (instance.props.interactive && popper.contains(event.target)) {
4963 return;
4964 } // Clicked on the event listeners target
4965
4966
4967 if (getEventListenersTarget().contains(event.target)) {
4968 if (currentInput.isTouch) {
4969 return;
4970 }
4971
4972 if (instance.state.isVisible && includes(instance.props.trigger, 'click')) {
4973 return;
4974 }
4975 }
4976
4977 if (instance.props.hideOnClick === true) {
4978 instance.clearDelayTimeouts();
4979 instance.hide(); // `mousedown` event is fired right before `focus`. This lets a tippy with
4980 // `focus` trigger know that it should not show
4981
4982 didHideDueToDocumentMouseDown = true;
4983 setTimeout(function () {
4984 didHideDueToDocumentMouseDown = false;
4985 }); // The listener gets added in `scheduleShow()`, but this may be hiding it
4986 // before it shows, and hide()'s early bail-out behavior can prevent it
4987 // from being cleaned up
4988
4989 if (!instance.state.isMounted) {
4990 removeDocumentMouseDownListener();
4991 }
4992 }
4993 }
4994
4995 function addDocumentMouseDownListener() {
4996 document.addEventListener('mousedown', onDocumentMouseDown, true);
4997 }
4998
4999 function removeDocumentMouseDownListener() {
5000 document.removeEventListener('mousedown', onDocumentMouseDown, true);
5001 }
5002
5003 function makeSticky() {
5004 setTransitionDuration([popper], isIE ? 0 : instance.props.updateDuration);
5005 var prevRefRect = reference.getBoundingClientRect();
5006
5007 function updatePosition() {
5008 var currentRefRect = reference.getBoundingClientRect(); // Only schedule an update if the reference rect has changed
5009
5010 if (prevRefRect.top !== currentRefRect.top || prevRefRect.right !== currentRefRect.right || prevRefRect.bottom !== currentRefRect.bottom || prevRefRect.left !== currentRefRect.left) {
5011 instance.popperInstance.scheduleUpdate();
5012 }
5013
5014 prevRefRect = currentRefRect;
5015
5016 if (instance.state.isMounted) {
5017 requestAnimationFrame(updatePosition);
5018 }
5019 }
5020
5021 updatePosition();
5022 }
5023
5024 function onTransitionedOut(duration, callback) {
5025 onTransitionEnd(duration, function () {
5026 if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {
5027 callback();
5028 }
5029 });
5030 }
5031
5032 function onTransitionedIn(duration, callback) {
5033 onTransitionEnd(duration, callback);
5034 }
5035
5036 function onTransitionEnd(duration, callback) {
5037 /**
5038 * Listener added as the `transitionend` handler
5039 */
5040 function listener(event) {
5041 if (event.target === tooltip) {
5042 updateTransitionEndListener(tooltip, 'remove', listener);
5043 callback();
5044 }
5045 } // Make callback synchronous if duration is 0
5046 // `transitionend` won't fire otherwise
5047
5048
5049 if (duration === 0) {
5050 return callback();
5051 }
5052
5053 updateTransitionEndListener(tooltip, 'remove', currentTransitionEndListener);
5054 updateTransitionEndListener(tooltip, 'add', listener);
5055 currentTransitionEndListener = listener;
5056 }
5057
5058 function on(eventType, handler, options) {
5059 if (options === void 0) {
5060 options = false;
5061 }
5062
5063 getEventListenersTarget().addEventListener(eventType, handler, options);
5064 listeners.push({
5065 eventType: eventType,
5066 handler: handler,
5067 options: options
5068 });
5069 }
5070
5071 function addTriggersToEventListenersTarget() {
5072 if (getIsCustomTouchBehavior()) {
5073 on('touchstart', onTrigger, PASSIVE);
5074 on('touchend', onMouseLeave, PASSIVE);
5075 } // `click` for keyboard. Mouse uses `mousedown` (onDocumentMouseDown)
5076
5077
5078 if (!includes(instance.props.trigger, 'click')) {
5079 on('click', function () {
5080 if (!currentInput.isTouch && instance.props.hideOnClick === true) {
5081 instance.hide();
5082 }
5083 });
5084 }
5085
5086 instance.props.trigger.trim().split(' ').forEach(function (eventType) {
5087 if (eventType === 'manual') {
5088 return;
5089 }
5090
5091 on(eventType, onTrigger);
5092
5093 switch (eventType) {
5094 case 'mouseenter':
5095 on('mouseleave', onMouseLeave);
5096 break;
5097
5098 case 'focus':
5099 on(isIE ? 'focusout' : 'blur', onBlur);
5100 break;
5101 }
5102 });
5103 }
5104
5105 function removeTriggersFromEventListenersTarget() {
5106 listeners.forEach(function (_ref) {
5107 var eventType = _ref.eventType,
5108 handler = _ref.handler,
5109 options = _ref.options;
5110 getEventListenersTarget().removeEventListener(eventType, handler, options);
5111 });
5112 listeners = [];
5113 }
5114
5115 function onTrigger(event) {
5116 if (didHideDueToDocumentMouseDown || !instance.state.isEnabled || isEventListenerStopped(event)) {
5117 return;
5118 }
5119
5120 if (!instance.state.isVisible) {
5121 lastTriggerEventType = event.type;
5122
5123 if (event instanceof MouseEvent) {
5124 // If scrolling, `mouseenter` events can be fired if the cursor lands
5125 // over a new target, but `mousemove` events don't get fired. This
5126 // causes interactive tooltips to get stuck open until the cursor is
5127 // moved
5128 mouseMoveListeners.forEach(function (listener) {
5129 return listener(event);
5130 });
5131 }
5132 } // Toggle show/hide when clicking click-triggered tooltips
5133
5134
5135 if (event.type === 'click' && instance.props.hideOnClick !== false && instance.state.isVisible) {
5136 scheduleHide(event);
5137 } else {
5138 var _getNormalizedTouchSe = getNormalizedTouchSettings(),
5139 value = _getNormalizedTouchSe[0],
5140 duration = _getNormalizedTouchSe[1];
5141
5142 if (currentInput.isTouch && value === 'hold' && duration) {
5143 // We can hijack the show timeout here, it will be cleared by
5144 // `scheduleHide()` when necessary
5145 showTimeout = setTimeout(function () {
5146 scheduleShow(event);
5147 }, duration);
5148 } else {
5149 scheduleShow(event);
5150 }
5151 }
5152 }
5153
5154 function onMouseMove(event) {
5155 var isCursorOverReferenceOrPopper = closestCallback(event.target, function (el) {
5156 return el === reference || el === popper;
5157 });
5158
5159 if (isCursorOverReferenceOrPopper) {
5160 return;
5161 }
5162
5163 if (isCursorOutsideInteractiveBorder(getBasePlacement(instance.state.currentPlacement), popper.getBoundingClientRect(), event, instance.props)) {
5164 cleanupInteractiveMouseListeners();
5165 scheduleHide(event);
5166 }
5167 }
5168
5169 function onMouseLeave(event) {
5170 if (isEventListenerStopped(event)) {
5171 return;
5172 }
5173
5174 if (instance.props.interactive) {
5175 document.body.addEventListener('mouseleave', scheduleHide);
5176 document.addEventListener('mousemove', debouncedOnMouseMove);
5177 mouseMoveListeners.push(debouncedOnMouseMove);
5178 return;
5179 }
5180
5181 scheduleHide(event);
5182 }
5183
5184 function onBlur(event) {
5185 if (event.target !== getEventListenersTarget()) {
5186 return;
5187 } // If focus was moved to within the popper
5188
5189
5190 if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {
5191 return;
5192 }
5193
5194 scheduleHide(event);
5195 }
5196
5197 function isEventListenerStopped(event) {
5198 var supportsTouch = 'ontouchstart' in window;
5199 var isTouchEvent = includes(event.type, 'touch');
5200 var isCustomTouch = getIsCustomTouchBehavior();
5201 return supportsTouch && currentInput.isTouch && isCustomTouch && !isTouchEvent || currentInput.isTouch && !isCustomTouch && isTouchEvent;
5202 }
5203
5204 function createPopperInstance() {
5205 var popperOptions = instance.props.popperOptions;
5206 var arrow = instance.popperChildren.arrow;
5207 var preventOverflowModifier = getModifier(popperOptions, 'preventOverflow');
5208
5209 function applyMutations(data) {
5210 instance.state.currentPlacement = data.placement;
5211
5212 if (instance.props.flip && !instance.props.flipOnUpdate) {
5213 if (data.flipped) {
5214 instance.popperInstance.options.placement = data.placement;
5215 }
5216
5217 setFlipModifierEnabled(instance.popperInstance.modifiers, false);
5218 }
5219
5220 tooltip.setAttribute('data-placement', data.placement);
5221
5222 if (data.attributes['x-out-of-boundaries'] !== false) {
5223 tooltip.setAttribute('data-out-of-boundaries', '');
5224 } else {
5225 tooltip.removeAttribute('data-out-of-boundaries');
5226 }
5227
5228 var basePlacement = getBasePlacement(data.placement);
5229 var isVerticalPlacement = includes(['top', 'bottom'], basePlacement);
5230 var isSecondaryPlacement = includes(['bottom', 'right'], basePlacement); // Apply `distance` prop
5231
5232 var tooltipStyles = tooltip.style;
5233 tooltipStyles.top = '0';
5234 tooltipStyles.left = '0';
5235 tooltipStyles[isVerticalPlacement ? 'top' : 'left'] = (isSecondaryPlacement ? 1 : -1) * instance.props.distance + "px";
5236 }
5237
5238 var config = _extends$1({
5239 eventsEnabled: false,
5240 placement: instance.props.placement
5241 }, popperOptions, {
5242 modifiers: _extends$1({}, popperOptions && popperOptions.modifiers, {
5243 preventOverflow: _extends$1({
5244 boundariesElement: instance.props.boundary,
5245 padding: PREVENT_OVERFLOW_PADDING
5246 }, preventOverflowModifier),
5247 // Adds the `distance` calculation to preventOverflow padding
5248 tippySetPreventOverflowPadding: {
5249 enabled: true,
5250 order: 299,
5251 fn: function fn(data) {
5252 var basePlacement = getBasePlacement(data.placement);
5253 var padding = preventOverflowModifier && preventOverflowModifier.padding !== undefined ? preventOverflowModifier.padding : PREVENT_OVERFLOW_PADDING;
5254 var isPaddingNumber = typeof padding === 'number';
5255 var paddingObject = {
5256 top: 0,
5257 bottom: 0,
5258 left: 0,
5259 right: 0
5260 };
5261 var computedPadding = Object.keys(paddingObject).reduce(function (obj, key) {
5262 obj[key] = isPaddingNumber ? padding : padding[key];
5263
5264 if (basePlacement === key) {
5265 obj[key] = isPaddingNumber ? padding + instance.props.distance : (padding[basePlacement] || 0) + instance.props.distance;
5266 }
5267
5268 return obj;
5269 }, paddingObject);
5270 instance.popperInstance.modifiers.filter(function (m) {
5271 return m.name === 'preventOverflow';
5272 })[0].padding = computedPadding;
5273 return data;
5274 }
5275 },
5276 arrow: _extends$1({
5277 element: arrow,
5278 enabled: !!arrow
5279 }, getModifier(popperOptions, 'arrow')),
5280 flip: _extends$1({
5281 enabled: instance.props.flip,
5282 padding: instance.props.distance + PREVENT_OVERFLOW_PADDING,
5283 behavior: instance.props.flipBehavior
5284 }, getModifier(popperOptions, 'flip')),
5285 offset: _extends$1({
5286 offset: instance.props.offset
5287 }, getModifier(popperOptions, 'offset'))
5288 }),
5289 onCreate: function onCreate(data) {
5290 applyMutations(data);
5291 preserveInvocation(popperOptions && popperOptions.onCreate, config.onCreate, [data]);
5292 runMountCallback();
5293 },
5294 onUpdate: function onUpdate(data) {
5295 applyMutations(data);
5296 preserveInvocation(popperOptions && popperOptions.onUpdate, config.onUpdate, [data]);
5297 runMountCallback();
5298 }
5299 });
5300
5301 instance.popperInstance = new Popper(reference, popper, config);
5302 }
5303
5304 function runMountCallback() {
5305 if (!hasMountCallbackRun && currentMountCallback) {
5306 hasMountCallbackRun = true;
5307 reflow(popper);
5308 currentMountCallback();
5309 }
5310 }
5311
5312 function mount() {
5313 // The mounting callback (`currentMountCallback`) is only run due to a
5314 // popperInstance update/create
5315 hasMountCallbackRun = false;
5316 var appendTo = instance.props.appendTo;
5317 var parentNode = appendTo === 'parent' ? reference.parentNode : invokeWithArgsOrReturn(appendTo, [reference]); // The popper element needs to exist on the DOM before its position can be
5318 // updated as Popper.js needs to read its dimensions
5319
5320 if (!parentNode.contains(popper)) {
5321 parentNode.appendChild(popper);
5322 }
5323
5324 if (instance.popperInstance) {
5325 setFlipModifierEnabled(instance.popperInstance.modifiers, instance.props.flip);
5326 instance.popperInstance.enableEventListeners(); // Mounting callback invoked in `onUpdate`
5327
5328 instance.popperInstance.scheduleUpdate();
5329 } else {
5330 // Mounting callback invoked in `onCreate`
5331 createPopperInstance();
5332 instance.popperInstance.enableEventListeners();
5333 }
5334 }
5335
5336 function scheduleShow(event) {
5337 instance.clearDelayTimeouts();
5338 instance.state.isScheduledToShow = true;
5339
5340 if (!instance.popperInstance) {
5341 createPopperInstance();
5342 }
5343
5344 if (event) {
5345 instance.props.onTrigger(instance, event);
5346 }
5347
5348 addDocumentMouseDownListener();
5349 var delay = getValueAtIndexOrReturn(instance.props.delay, 0, defaultProps.delay);
5350
5351 if (delay) {
5352 showTimeout = setTimeout(function () {
5353 instance.show();
5354 }, delay);
5355 } else {
5356 instance.show();
5357 }
5358 }
5359
5360 function scheduleHide(event) {
5361 instance.clearDelayTimeouts();
5362 instance.props.onUntrigger(instance, event);
5363
5364 if (!instance.state.isVisible) {
5365 removeDocumentMouseDownListener();
5366 return;
5367 }
5368
5369 instance.state.isScheduledToShow = false;
5370 var delay = getValueAtIndexOrReturn(instance.props.delay, 1, defaultProps.delay);
5371
5372 if (delay) {
5373 hideTimeout = setTimeout(function () {
5374 if (instance.state.isVisible) {
5375 instance.hide();
5376 }
5377 }, delay);
5378 } else {
5379 // Fixes a `transitionend` problem when it fires 1 frame too
5380 // late sometimes, we don't want hide() to be called.
5381 scheduleHideAnimationFrame = requestAnimationFrame(function () {
5382 instance.hide();
5383 });
5384 }
5385 }
5386 /* ======================= 🔑 Public methods 🔑 ======================= */
5387
5388
5389 function enable() {
5390 instance.state.isEnabled = true;
5391 }
5392
5393 function disable() {
5394 // Disabling the instance should also hide it
5395 // https://github.com/atomiks/tippy.js-react/issues/106
5396 instance.hide();
5397 instance.state.isEnabled = false;
5398 }
5399
5400 function clearDelayTimeouts() {
5401 clearTimeout(showTimeout);
5402 clearTimeout(hideTimeout);
5403 cancelAnimationFrame(scheduleHideAnimationFrame);
5404 } // Cloning as we're deleting non-updateable props in DEV mode
5405
5406
5407 function setProps(_ref2) {
5408 var partialProps = _extends$1({}, _ref2);
5409
5410 if (instance.state.isDestroyed) {
5411 return;
5412 }
5413
5414 removeTriggersFromEventListenersTarget();
5415 var prevProps = instance.props;
5416 var nextProps = evaluateProps(reference, _extends$1({}, instance.props, {}, partialProps, {
5417 ignoreAttributes: true
5418 }));
5419 nextProps.ignoreAttributes = hasOwnProperty$1(partialProps, 'ignoreAttributes') ? partialProps.ignoreAttributes || false : prevProps.ignoreAttributes;
5420 instance.props = nextProps;
5421 addTriggersToEventListenersTarget();
5422 cleanupInteractiveMouseListeners();
5423 debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);
5424 updatePopperElement(popper, prevProps, nextProps, instance.state.isVisible);
5425 instance.popperChildren = getChildren(popper);
5426
5427 if (instance.popperInstance) {
5428 if (POPPER_INSTANCE_DEPENDENCIES.some(function (prop) {
5429 return hasOwnProperty$1(partialProps, prop) && partialProps[prop] !== prevProps[prop];
5430 })) {
5431 instance.popperInstance.destroy();
5432 createPopperInstance();
5433
5434 if (instance.state.isVisible) {
5435 instance.popperInstance.enableEventListeners();
5436 }
5437 } else {
5438 instance.popperInstance.update();
5439 }
5440 }
5441 }
5442
5443 function setContent(content) {
5444 instance.setProps({
5445 content: content
5446 });
5447 }
5448
5449 function show(duration, shouldPreventPopperTransition) {
5450 if (duration === void 0) {
5451 duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
5452 }
5453
5454 if (shouldPreventPopperTransition === void 0) {
5455 shouldPreventPopperTransition = true;
5456 }
5457
5458
5459 var isAlreadyVisible = instance.state.isVisible;
5460 var isDestroyed = instance.state.isDestroyed;
5461 var isDisabled = !instance.state.isEnabled;
5462 var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
5463
5464 if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
5465 return;
5466 } // Normalize `disabled` behavior across browsers.
5467 // Firefox allows events on disabled elements, but Chrome doesn't.
5468 // Using a wrapper element (i.e. <span>) is recommended.
5469
5470
5471 if (getEventListenersTarget().hasAttribute('disabled')) {
5472 return;
5473 }
5474
5475 if (instance.props.onShow(instance) === false) {
5476 return;
5477 }
5478
5479 addDocumentMouseDownListener();
5480 popper.style.visibility = 'visible';
5481 instance.state.isVisible = true; // Prevent a transition of the popper from its previous position and of the
5482 // elements at a different placement.
5483
5484 var transitionableElements = getTransitionableElements();
5485 setTransitionDuration(shouldPreventPopperTransition ? transitionableElements.concat(popper) : transitionableElements, 0);
5486
5487 currentMountCallback = function currentMountCallback() {
5488 if (!instance.state.isVisible) {
5489 return;
5490 } // Double update will apply correct mutations
5491
5492
5493 instance.popperInstance.update();
5494 instance.props.onMount(instance);
5495 instance.state.isMounted = true; // The content should fade in after the backdrop has mostly filled the
5496 // tooltip element. `clip-path` is the other alternative but is not well-
5497 // supported and is buggy on some devices.
5498
5499 content.style.transitionDelay = instance.popperChildren.backdrop ? Math.round(duration / 12) + "ms" : '';
5500
5501 if (instance.props.sticky) {
5502 makeSticky();
5503 }
5504
5505 setTransitionDuration([popper], instance.props.updateDuration);
5506 setTransitionDuration(transitionableElements, duration);
5507 setVisibilityState(transitionableElements, 'visible');
5508 onTransitionedIn(duration, function () {
5509 if (instance.props.aria) {
5510 var node = getEventListenersTarget();
5511 var attrName = "aria-" + instance.props.aria;
5512 var currentAttrValue = node.getAttribute(attrName);
5513 var nextAttrValue = currentAttrValue ? currentAttrValue + " " + tooltip.id : tooltip.id;
5514 node.setAttribute(attrName, nextAttrValue);
5515 }
5516
5517 instance.props.onShown(instance);
5518 instance.state.isShown = true;
5519 });
5520 };
5521
5522 mount();
5523 }
5524
5525 function hide(duration) {
5526 if (duration === void 0) {
5527 duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
5528 }
5529
5530
5531 var isAlreadyHidden = !instance.state.isVisible && !isBeingDestroyed;
5532 var isDestroyed = instance.state.isDestroyed;
5533 var isDisabled = !instance.state.isEnabled && !isBeingDestroyed;
5534
5535 if (isAlreadyHidden || isDestroyed || isDisabled) {
5536 return;
5537 }
5538
5539 if (instance.props.onHide(instance) === false && !isBeingDestroyed) {
5540 return;
5541 }
5542
5543 removeDocumentMouseDownListener();
5544 popper.style.visibility = 'hidden';
5545 instance.state.isVisible = false;
5546 instance.state.isShown = false;
5547 var transitionableElements = getTransitionableElements();
5548 setTransitionDuration(transitionableElements, duration);
5549 setVisibilityState(transitionableElements, 'hidden');
5550 onTransitionedOut(duration, function () {
5551 if (instance.props.aria) {
5552 var node = getEventListenersTarget();
5553 var attrName = "aria-" + instance.props.aria;
5554 var currentAttrValue = node.getAttribute(attrName);
5555 var nextAttrValue = currentAttrValue ? currentAttrValue.replace(tooltip.id, '').trim() : null;
5556
5557 if (nextAttrValue) {
5558 node.setAttribute(attrName, nextAttrValue);
5559 } else {
5560 node.removeAttribute(attrName);
5561 }
5562 }
5563
5564 instance.popperInstance.disableEventListeners();
5565 instance.popperInstance.options.placement = instance.props.placement;
5566 popper.parentNode.removeChild(popper);
5567 instance.props.onHidden(instance);
5568 instance.state.isMounted = false;
5569 });
5570 }
5571
5572 function destroy() {
5573
5574 if (instance.state.isDestroyed) {
5575 return;
5576 }
5577
5578 isBeingDestroyed = true;
5579 instance.hide(0);
5580 removeTriggersFromEventListenersTarget();
5581 delete reference._tippy;
5582
5583 if (instance.popperInstance) {
5584 instance.popperInstance.destroy();
5585 }
5586
5587 isBeingDestroyed = false;
5588 instance.state.isDestroyed = true;
5589 }
5590 }
5591
5592 /**
5593 * Exported module
5594 */
5595 function tippy(targets, optionalProps) {
5596
5597 bindGlobalEventListeners();
5598
5599 var props = _extends$1({}, defaultProps, {}, optionalProps);
5600
5601 var elements = getArrayOfElements(targets);
5602
5603 var instances = elements.reduce(function (acc, reference) {
5604 var instance = reference && createTippy(reference, props);
5605
5606 if (instance) {
5607
5608 acc.push(instance);
5609 }
5610
5611 return acc;
5612 }, []);
5613 return isRealElement(targets) ? instances[0] : instances;
5614 }
5615
5616 tippy.version = version;
5617 tippy.defaultProps = defaultProps;
5618 tippy.currentInput = currentInput;
5619 /**
5620 * Mutates the defaultProps object by setting the props specified
5621 */
5622
5623 tippy.setDefaultProps = function (partialProps) {
5624
5625 Object.keys(partialProps).forEach(function (key) {
5626 // @ts-ignore
5627 defaultProps[key] = partialProps[key];
5628 });
5629 };
5630 /**
5631 * Hides all visible poppers on the document
5632 */
5633
5634
5635 tippy.hideAll = function (_temp) {
5636 var _ref = _temp === void 0 ? {} : _temp,
5637 excludedReferenceOrInstance = _ref.exclude,
5638 duration = _ref.duration;
5639
5640 arrayFrom(document.querySelectorAll(POPPER_SELECTOR)).forEach(function (popper) {
5641 var instance = popper._tippy;
5642
5643 if (instance) {
5644 var isExcluded = false;
5645
5646 if (excludedReferenceOrInstance) {
5647 isExcluded = isReferenceElement(excludedReferenceOrInstance) ? instance.reference === excludedReferenceOrInstance : popper === excludedReferenceOrInstance.popper;
5648 }
5649
5650 if (!isExcluded) {
5651 instance.hide(duration);
5652 }
5653 }
5654 });
5655 };
5656 /**
5657 * Auto-init tooltips for elements with a `data-tippy="..."` attribute
5658 */
5659
5660
5661 function autoInit() {
5662 arrayFrom(document.querySelectorAll('[data-tippy]')).forEach(function (el) {
5663 var content = el.getAttribute('data-tippy');
5664
5665 if (content) {
5666 tippy(el, {
5667 content: content
5668 });
5669 }
5670 });
5671 }
5672
5673 if (isBrowser) {
5674 setTimeout(autoInit);
5675 }
5676
5677 /**!
5678 * tippy.js v5.0.0-beta.1
5679 * (c) 2017-2019 atomiks
5680 * MIT License
5681 */
5682
5683 var css = ".tippy-tooltip[data-animation=fade][data-state=hidden]{opacity:0}.tippy-iOS{cursor:pointer!important;-webkit-tap-highlight-color:transparent}.tippy-popper{pointer-events:none;max-width:calc(100% - 10px);transition-timing-function:cubic-bezier(.165,.84,.44,1)}.tippy-tooltip{position:relative;color:#fff;border-radius:.25rem;font-size:.875rem;line-height:1.4;background-color:#333;overflow:hidden;transition-property:visibility,opacity,transform;outline:0}.tippy-tooltip[data-placement^=top] .tippy-arrow{border-width:8px 8px 0;border-top-color:#333;margin:0 3px;transform-origin:50% 0;bottom:-7px}.tippy-tooltip[data-placement^=bottom] .tippy-arrow{border-width:0 8px 8px;border-bottom-color:#333;margin:0 3px;transform-origin:50% 7px;top:-7px}.tippy-tooltip[data-placement^=left] .tippy-arrow{border-width:8px 0 8px 8px;border-left-color:#333;margin:3px 0;transform-origin:0 50%;right:-7px}.tippy-tooltip[data-placement^=right] .tippy-arrow{border-width:8px 8px 8px 0;border-right-color:#333;margin:3px 0;transform-origin:7px 50%;left:-7px}.tippy-tooltip[data-arrow]{overflow:visible}.tippy-tooltip[data-animatefill]{background-color:transparent!important}.tippy-tooltip[data-interactive]{pointer-events:auto}.tippy-tooltip[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-tooltip[data-inertia][data-state=hidden]{transition-timing-function:ease}.tippy-arrow{border-color:transparent;border-style:solid;position:absolute}.tippy-arrow[data-state=hidden]{opacity:0}.tippy-content{padding:.3125rem .5625rem}";
5684
5685 /**
5686 * Injects a string of CSS styles to a style node in <head>
5687 */
5688 function injectCSS(css) {
5689 var style = document.createElement('style');
5690 style.textContent = css;
5691 style.setAttribute('data-tippy-stylesheet', '');
5692 var head = document.head;
5693 var firstStyleOrLinkTag = head.querySelector('style,link');
5694
5695 if (firstStyleOrLinkTag) {
5696 head.insertBefore(style, firstStyleOrLinkTag);
5697 } else {
5698 head.appendChild(style);
5699 }
5700 }
5701
5702 if (isBrowser) {
5703 injectCSS(css);
5704 }
5705
5706 /**
5707 * Ensure class prefix ends in `-`
5708 * @param {string} prefix The prefix to prepend to the class names generated by nano-css
5709 * @return {string} The prefix ending in `-`
5710 */
5711
5712 function normalizePrefix(prefix) {
5713 if (!isString(prefix) || prefix === '') {
5714 return '';
5715 }
5716
5717 return prefix.charAt(prefix.length - 1) !== '-' ? prefix + "-" : prefix;
5718 }
5719 /**
5720 * Checks if options.attachTo.element is a string, and if so, tries to find the element
5721 * @param {Step} step The step instance
5722 * @returns {{element, on}}
5723 * `element` is a qualified HTML Element
5724 * `on` is a string position value
5725 */
5726
5727 function parseAttachTo(step) {
5728 var options = step.options.attachTo || {};
5729
5730 var returnOpts = _extends({}, options);
5731
5732 if (isString(options.element)) {
5733 // Can't override the element in user opts reference because we can't
5734 // guarantee that the element will exist in the future.
5735 try {
5736 returnOpts.element = document.querySelector(options.element);
5737 } catch (e) {// TODO
5738 }
5739
5740 if (!returnOpts.element) {
5741 console.error("The element for this Shepherd step was not found " + options.element);
5742 }
5743 }
5744
5745 return returnOpts;
5746 }
5747 /**
5748 * Determines options for the tooltip and initializes
5749 * `step.tooltip` as a Tippy.js instance.
5750 * @param {Step} step The step instance
5751 */
5752
5753 function setupTooltip(step) {
5754 if (isUndefined(tippy)) {
5755 throw new Error('Using the attachment feature of Shepherd requires the Tippy.js library');
5756 }
5757
5758 if (step.tooltip) {
5759 step.tooltip.destroy();
5760 }
5761
5762 var attachToOpts = parseAttachTo(step);
5763 step.tooltip = _makeTippyInstance(attachToOpts, step);
5764 step.target = attachToOpts.element;
5765 }
5766 /**
5767 * Generates a `Tippy` instance from a set of base `attachTo` options
5768 * @param attachToOptions
5769 * @param {Step} step The step instance
5770 * @return {tippy|Instance | Instance[]} The final tippy instance
5771 * @private
5772 */
5773
5774 function _makeTippyInstance(attachToOptions, step) {
5775 var tippyOptions = {};
5776 var element = document.body;
5777
5778 if (!attachToOptions.element || !attachToOptions.on) {
5779 tippyOptions = makeCenteredTippy(step);
5780 } else {
5781 tippyOptions = makeAttachedTippyOptions(attachToOptions, step);
5782 element = attachToOptions.element;
5783 }
5784
5785 return tippy(element, tippyOptions);
5786 }
5787
5788 /**
5789 * Remove any leftover modal target classes and add the modal target class to the currentElement
5790 * @param {HTMLElement} currentElement The element for the current step
5791 * @param {string} classPrefix The prefix to add to the class name
5792 */
5793 function toggleShepherdModalClass(currentElement, classPrefix) {
5794 var shepherdModalTarget = document.querySelector("." + classPrefix + "shepherd-modal-target");
5795
5796 if (shepherdModalTarget) {
5797 shepherdModalTarget.classList.remove(classPrefix + "shepherd-modal-target");
5798 }
5799
5800 currentElement.classList.add(classPrefix + "shepherd-modal-target");
5801 }
5802
5803 var Component$1 = preact.Component;
5804
5805 var ShepherdButton =
5806 /*#__PURE__*/
5807 function (_Component) {
5808 _inheritsLoose(ShepherdButton, _Component);
5809
5810 function ShepherdButton() {
5811 return _Component.apply(this, arguments) || this;
5812 }
5813
5814 var _proto = ShepherdButton.prototype;
5815
5816 _proto.render = function render(props) {
5817 var classPrefix = props.classPrefix,
5818 config = props.config,
5819 step = props.step,
5820 styles = props.styles;
5821 var action = config.action,
5822 classes = config.classes,
5823 secondary = config.secondary,
5824 text = config.text;
5825 return preact.h("button", {
5826 className: (classes || '') + styles.button + (secondary ? " " + classPrefix + "shepherd-button-secondary" : ''),
5827 onClick: action ? action.bind(step.tour) : null,
5828 tabindex: "0"
5829 }, text);
5830 };
5831
5832 return ShepherdButton;
5833 }(Component$1);
5834
5835 var Component$2 = preact.Component;
5836
5837 var ShepherdFooter =
5838 /*#__PURE__*/
5839 function (_Component) {
5840 _inheritsLoose(ShepherdFooter, _Component);
5841
5842 function ShepherdFooter() {
5843 return _Component.apply(this, arguments) || this;
5844 }
5845
5846 var _proto = ShepherdFooter.prototype;
5847
5848 _proto.render = function render(props) {
5849 var classPrefix = props.classPrefix,
5850 step = props.step,
5851 styles = props.styles;
5852 var buttons = step.options.buttons;
5853 return preact.h("footer", {
5854 className: styles.footer.trim()
5855 }, this._addButtons(buttons, classPrefix, step, styles));
5856 };
5857
5858 _proto._addButtons = function _addButtons(buttons, classPrefix, step, styles) {
5859 if (buttons) {
5860 return buttons.map(function (config) {
5861 return preact.h(ShepherdButton, {
5862 classPrefix: classPrefix,
5863 config: config,
5864 key: config.toString(),
5865 step: step,
5866 styles: styles
5867 });
5868 });
5869 }
5870
5871 return null;
5872 };
5873
5874 return ShepherdFooter;
5875 }(Component$2);
5876
5877 var Component$3 = preact.Component;
5878
5879 var ShepherdHeader =
5880 /*#__PURE__*/
5881 function (_Component) {
5882 _inheritsLoose(ShepherdHeader, _Component);
5883
5884 function ShepherdHeader(props) {
5885 var _this;
5886
5887 _this = _Component.call(this, props) || this;
5888 _this.step = props.step;
5889 _this.handleCancelClick = _this.handleCancelClick.bind(_assertThisInitialized(_this));
5890 return _this;
5891 }
5892
5893 var _proto = ShepherdHeader.prototype;
5894
5895 _proto.render = function render(props) {
5896 var labelId = props.labelId,
5897 step = props.step,
5898 styles = props.styles;
5899 var _step$options = step.options,
5900 cancelIcon = _step$options.cancelIcon,
5901 title = _step$options.title;
5902 return preact.h("header", {
5903 className: styles.header.trim()
5904 }, this.constructor._addTitle(labelId, styles, title), this._addCancelLink(cancelIcon, styles));
5905 }
5906 /**
5907 * Add a click listener to the cancel link that cancels the tour
5908 */
5909 ;
5910
5911 _proto.handleCancelClick = function handleCancelClick(e) {
5912 e.preventDefault();
5913 this.step.cancel();
5914 };
5915
5916 ShepherdHeader._addTitle = function _addTitle(labelId, styles, title) {
5917 if (title) {
5918 return preact.h("h3", {
5919 id: labelId,
5920 className: styles.title.trim()
5921 }, title);
5922 }
5923
5924 return null;
5925 }
5926 /**
5927 * If enabled, add the cancel "x" icon
5928 * @param {object} cancelIcon The options for the cancel icon
5929 * @param styles
5930 * @return {null|*}
5931 * @private
5932 */
5933 ;
5934
5935 _proto._addCancelLink = function _addCancelLink(cancelIcon, styles) {
5936 if (cancelIcon && cancelIcon.enabled) {
5937 return preact.h("button", {
5938 "aria-label": cancelIcon.label ? cancelIcon.label : 'Close Tour',
5939 className: styles['cancel-icon'].trim(),
5940 onClick: this.handleCancelClick,
5941 type: "button"
5942 }, preact.h("span", {
5943 "aria-hidden": "true"
5944 }, "\xD7"));
5945 }
5946
5947 return null;
5948 };
5949
5950 return ShepherdHeader;
5951 }(Component$3);
5952
5953 var Component$4 = preact.Component;
5954
5955 var ShepherdText =
5956 /*#__PURE__*/
5957 function (_Component) {
5958 _inheritsLoose(ShepherdText, _Component);
5959
5960 function ShepherdText() {
5961 return _Component.apply(this, arguments) || this;
5962 }
5963
5964 var _proto = ShepherdText.prototype;
5965
5966 _proto.shouldComponentUpdate = function shouldComponentUpdate() {
5967 return false;
5968 };
5969
5970 _proto.componentDidMount = function componentDidMount() {
5971 var step = this.props.step;
5972 var text = step.options.text;
5973
5974 if (isFunction(text)) {
5975 text = text.call(step);
5976 }
5977
5978 if (isElement(text)) {
5979 this.base.appendChild(text);
5980 }
5981 };
5982
5983 _proto.render = function render(props) {
5984 var descriptionId = props.descriptionId,
5985 step = props.step,
5986 styles = props.styles;
5987 var text = step.options.text;
5988
5989 if (isFunction(text)) {
5990 text = text.call(step);
5991 }
5992
5993 return preact.h("div", {
5994 className: styles.text.trim(),
5995 dangerouslySetInnerHTML: {
5996 __html: !isElement(text) ? text : null
5997 },
5998 id: descriptionId
5999 });
6000 };
6001
6002 return ShepherdText;
6003 }(Component$4);
6004
6005 var Component$5 = preact.Component;
6006
6007 var ShepherdContent =
6008 /*#__PURE__*/
6009 function (_Component) {
6010 _inheritsLoose(ShepherdContent, _Component);
6011
6012 function ShepherdContent() {
6013 return _Component.apply(this, arguments) || this;
6014 }
6015
6016 var _proto = ShepherdContent.prototype;
6017
6018 _proto.render = function render(props) {
6019 var classPrefix = props.classPrefix,
6020 descriptionId = props.descriptionId,
6021 labelId = props.labelId,
6022 step = props.step,
6023 styles = props.styles;
6024 return preact.h("div", {
6025 className: styles.content.trim()
6026 }, preact.h(ShepherdHeader, {
6027 labelId: labelId,
6028 step: step,
6029 styles: styles
6030 }), ShepherdContent._addShepherdText(descriptionId, step, styles), ShepherdContent._addShepherdFooter(classPrefix, step, styles));
6031 };
6032
6033 ShepherdContent._addShepherdText = function _addShepherdText(descriptionId, step, styles) {
6034 if (!isUndefined(step.options.text)) {
6035 return preact.h(ShepherdText, {
6036 descriptionId: descriptionId,
6037 step: step,
6038 styles: styles
6039 });
6040 }
6041
6042 return null;
6043 };
6044
6045 ShepherdContent._addShepherdFooter = function _addShepherdFooter(classPrefix, step, styles) {
6046 if (Array.isArray(step.options.buttons) && step.options.buttons.length) {
6047 return preact.h(ShepherdFooter, {
6048 classPrefix: classPrefix,
6049 step: step,
6050 styles: styles
6051 });
6052 }
6053
6054 return null;
6055 };
6056
6057 return ShepherdContent;
6058 }(Component$5);
6059
6060 var Component$6 = preact.Component;
6061 var KEY_TAB = 9;
6062 var KEY_ESC = 27;
6063 var LEFT_ARROW = 37;
6064 var RIGHT_ARROW = 39;
6065
6066 var ShepherdElement =
6067 /*#__PURE__*/
6068 function (_Component) {
6069 _inheritsLoose(ShepherdElement, _Component);
6070
6071 function ShepherdElement(props) {
6072 var _this;
6073
6074 _this = _Component.call(this, props) || this;
6075 _this.step = props.step;
6076 _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
6077 return _this;
6078 }
6079
6080 var _proto = ShepherdElement.prototype;
6081
6082 _proto.componentDidMount = function componentDidMount() {
6083 // Get all elements that are focusable
6084 var focusableElements = this.element.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]');
6085 var firstFocusableElement = focusableElements[0];
6086 var lastFocusableElement = focusableElements[focusableElements.length - 1];
6087 this.focusableElements = focusableElements;
6088 this.firstFocusableElement = firstFocusableElement;
6089 this.lastFocusableElement = lastFocusableElement;
6090 };
6091
6092 _proto.render = function render(props) {
6093 var _dataStepId,
6094 _this2 = this;
6095
6096 var classes = props.classes,
6097 classPrefix = props.classPrefix,
6098 descriptionId = props.descriptionId,
6099 labelId = props.labelId,
6100 step = props.step,
6101 styles = props.styles;
6102 var dataStepId = (_dataStepId = {}, _dataStepId["data-" + classPrefix + "shepherd-step-id"] = step.id, _dataStepId);
6103 return preact.h("div", _extends({
6104 "aria-describedby": !isUndefined(step.options.text) ? descriptionId : null,
6105 "aria-labeledby": step.options.title ? labelId : null,
6106 className: classes + styles.element
6107 }, dataStepId, {
6108 onKeyDown: this.handleKeyDown,
6109 ref: function ref(c) {
6110 return _this2.element = c;
6111 },
6112 role: "dialog",
6113 tabindex: "0"
6114 }), preact.h(ShepherdContent, {
6115 classPrefix: classPrefix,
6116 descriptionId: descriptionId,
6117 labelId: labelId,
6118 step: step,
6119 styles: styles
6120 }));
6121 }
6122 /**
6123 * Setup keydown events to allow closing the modal with ESC
6124 *
6125 * Borrowed from this great post! https://bitsofco.de/accessible-modal-dialog/
6126 *
6127 * @private
6128 */
6129 ;
6130
6131 _proto.handleKeyDown = function handleKeyDown(e) {
6132 var tour = this.step.tour;
6133
6134 switch (e.keyCode) {
6135 case KEY_TAB:
6136 if (this.focusableElements.length === 1) {
6137 e.preventDefault();
6138 break;
6139 } // Backward tab
6140
6141
6142 if (e.shiftKey) {
6143 if (document.activeElement === this.firstFocusableElement) {
6144 e.preventDefault();
6145 this.lastFocusableElement.focus();
6146 }
6147 } else {
6148 if (document.activeElement === this.lastFocusableElement) {
6149 e.preventDefault();
6150 this.firstFocusableElement.focus();
6151 }
6152 }
6153
6154 break;
6155
6156 case KEY_ESC:
6157 if (tour.options.exitOnEsc) {
6158 this.step.cancel();
6159 }
6160
6161 break;
6162
6163 case LEFT_ARROW:
6164 if (tour.options.keyboardNavigation) {
6165 tour.back();
6166 }
6167
6168 break;
6169
6170 case RIGHT_ARROW:
6171 if (tour.options.keyboardNavigation) {
6172 tour.next();
6173 }
6174
6175 break;
6176
6177 default:
6178 break;
6179 }
6180 };
6181
6182 return ShepherdElement;
6183 }(Component$6);
6184
6185 if (!Element.prototype.matches) {
6186 Element.prototype.matches =
6187 Element.prototype.matchesSelector ||
6188 Element.prototype.msMatchesSelector ||
6189 Element.prototype.webkitMatchesSelector;
6190 }
6191
6192 var smoothscroll = createCommonjsModule(function (module, exports) {
6193 /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */
6194 (function () {
6195
6196 // polyfill
6197 function polyfill() {
6198 // aliases
6199 var w = window;
6200 var d = document;
6201
6202 // return if scroll behavior is supported and polyfill is not forced
6203 if (
6204 'scrollBehavior' in d.documentElement.style &&
6205 w.__forceSmoothScrollPolyfill__ !== true
6206 ) {
6207 return;
6208 }
6209
6210 // globals
6211 var Element = w.HTMLElement || w.Element;
6212 var SCROLL_TIME = 468;
6213
6214 // object gathering original scroll methods
6215 var original = {
6216 scroll: w.scroll || w.scrollTo,
6217 scrollBy: w.scrollBy,
6218 elementScroll: Element.prototype.scroll || scrollElement,
6219 scrollIntoView: Element.prototype.scrollIntoView
6220 };
6221
6222 // define timing method
6223 var now =
6224 w.performance && w.performance.now
6225 ? w.performance.now.bind(w.performance)
6226 : Date.now;
6227
6228 /**
6229 * indicates if a the current browser is made by Microsoft
6230 * @method isMicrosoftBrowser
6231 * @param {String} userAgent
6232 * @returns {Boolean}
6233 */
6234 function isMicrosoftBrowser(userAgent) {
6235 var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];
6236
6237 return new RegExp(userAgentPatterns.join('|')).test(userAgent);
6238 }
6239
6240 /*
6241 * IE has rounding bug rounding down clientHeight and clientWidth and
6242 * rounding up scrollHeight and scrollWidth causing false positives
6243 * on hasScrollableSpace
6244 */
6245 var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;
6246
6247 /**
6248 * changes scroll position inside an element
6249 * @method scrollElement
6250 * @param {Number} x
6251 * @param {Number} y
6252 * @returns {undefined}
6253 */
6254 function scrollElement(x, y) {
6255 this.scrollLeft = x;
6256 this.scrollTop = y;
6257 }
6258
6259 /**
6260 * returns result of applying ease math function to a number
6261 * @method ease
6262 * @param {Number} k
6263 * @returns {Number}
6264 */
6265 function ease(k) {
6266 return 0.5 * (1 - Math.cos(Math.PI * k));
6267 }
6268
6269 /**
6270 * indicates if a smooth behavior should be applied
6271 * @method shouldBailOut
6272 * @param {Number|Object} firstArg
6273 * @returns {Boolean}
6274 */
6275 function shouldBailOut(firstArg) {
6276 if (
6277 firstArg === null ||
6278 typeof firstArg !== 'object' ||
6279 firstArg.behavior === undefined ||
6280 firstArg.behavior === 'auto' ||
6281 firstArg.behavior === 'instant'
6282 ) {
6283 // first argument is not an object/null
6284 // or behavior is auto, instant or undefined
6285 return true;
6286 }
6287
6288 if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {
6289 // first argument is an object and behavior is smooth
6290 return false;
6291 }
6292
6293 // throw error when behavior is not supported
6294 throw new TypeError(
6295 'behavior member of ScrollOptions ' +
6296 firstArg.behavior +
6297 ' is not a valid value for enumeration ScrollBehavior.'
6298 );
6299 }
6300
6301 /**
6302 * indicates if an element has scrollable space in the provided axis
6303 * @method hasScrollableSpace
6304 * @param {Node} el
6305 * @param {String} axis
6306 * @returns {Boolean}
6307 */
6308 function hasScrollableSpace(el, axis) {
6309 if (axis === 'Y') {
6310 return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
6311 }
6312
6313 if (axis === 'X') {
6314 return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
6315 }
6316 }
6317
6318 /**
6319 * indicates if an element has a scrollable overflow property in the axis
6320 * @method canOverflow
6321 * @param {Node} el
6322 * @param {String} axis
6323 * @returns {Boolean}
6324 */
6325 function canOverflow(el, axis) {
6326 var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];
6327
6328 return overflowValue === 'auto' || overflowValue === 'scroll';
6329 }
6330
6331 /**
6332 * indicates if an element can be scrolled in either axis
6333 * @method isScrollable
6334 * @param {Node} el
6335 * @param {String} axis
6336 * @returns {Boolean}
6337 */
6338 function isScrollable(el) {
6339 var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');
6340 var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');
6341
6342 return isScrollableY || isScrollableX;
6343 }
6344
6345 /**
6346 * finds scrollable parent of an element
6347 * @method findScrollableParent
6348 * @param {Node} el
6349 * @returns {Node} el
6350 */
6351 function findScrollableParent(el) {
6352 while (el !== d.body && isScrollable(el) === false) {
6353 el = el.parentNode || el.host;
6354 }
6355
6356 return el;
6357 }
6358
6359 /**
6360 * self invoked function that, given a context, steps through scrolling
6361 * @method step
6362 * @param {Object} context
6363 * @returns {undefined}
6364 */
6365 function step(context) {
6366 var time = now();
6367 var value;
6368 var currentX;
6369 var currentY;
6370 var elapsed = (time - context.startTime) / SCROLL_TIME;
6371
6372 // avoid elapsed times higher than one
6373 elapsed = elapsed > 1 ? 1 : elapsed;
6374
6375 // apply easing to elapsed time
6376 value = ease(elapsed);
6377
6378 currentX = context.startX + (context.x - context.startX) * value;
6379 currentY = context.startY + (context.y - context.startY) * value;
6380
6381 context.method.call(context.scrollable, currentX, currentY);
6382
6383 // scroll more if we have not reached our destination
6384 if (currentX !== context.x || currentY !== context.y) {
6385 w.requestAnimationFrame(step.bind(w, context));
6386 }
6387 }
6388
6389 /**
6390 * scrolls window or element with a smooth behavior
6391 * @method smoothScroll
6392 * @param {Object|Node} el
6393 * @param {Number} x
6394 * @param {Number} y
6395 * @returns {undefined}
6396 */
6397 function smoothScroll(el, x, y) {
6398 var scrollable;
6399 var startX;
6400 var startY;
6401 var method;
6402 var startTime = now();
6403
6404 // define scroll context
6405 if (el === d.body) {
6406 scrollable = w;
6407 startX = w.scrollX || w.pageXOffset;
6408 startY = w.scrollY || w.pageYOffset;
6409 method = original.scroll;
6410 } else {
6411 scrollable = el;
6412 startX = el.scrollLeft;
6413 startY = el.scrollTop;
6414 method = scrollElement;
6415 }
6416
6417 // scroll looping over a frame
6418 step({
6419 scrollable: scrollable,
6420 method: method,
6421 startTime: startTime,
6422 startX: startX,
6423 startY: startY,
6424 x: x,
6425 y: y
6426 });
6427 }
6428
6429 // ORIGINAL METHODS OVERRIDES
6430 // w.scroll and w.scrollTo
6431 w.scroll = w.scrollTo = function() {
6432 // avoid action when no arguments are passed
6433 if (arguments[0] === undefined) {
6434 return;
6435 }
6436
6437 // avoid smooth behavior if not required
6438 if (shouldBailOut(arguments[0]) === true) {
6439 original.scroll.call(
6440 w,
6441 arguments[0].left !== undefined
6442 ? arguments[0].left
6443 : typeof arguments[0] !== 'object'
6444 ? arguments[0]
6445 : w.scrollX || w.pageXOffset,
6446 // use top prop, second argument if present or fallback to scrollY
6447 arguments[0].top !== undefined
6448 ? arguments[0].top
6449 : arguments[1] !== undefined
6450 ? arguments[1]
6451 : w.scrollY || w.pageYOffset
6452 );
6453
6454 return;
6455 }
6456
6457 // LET THE SMOOTHNESS BEGIN!
6458 smoothScroll.call(
6459 w,
6460 d.body,
6461 arguments[0].left !== undefined
6462 ? ~~arguments[0].left
6463 : w.scrollX || w.pageXOffset,
6464 arguments[0].top !== undefined
6465 ? ~~arguments[0].top
6466 : w.scrollY || w.pageYOffset
6467 );
6468 };
6469
6470 // w.scrollBy
6471 w.scrollBy = function() {
6472 // avoid action when no arguments are passed
6473 if (arguments[0] === undefined) {
6474 return;
6475 }
6476
6477 // avoid smooth behavior if not required
6478 if (shouldBailOut(arguments[0])) {
6479 original.scrollBy.call(
6480 w,
6481 arguments[0].left !== undefined
6482 ? arguments[0].left
6483 : typeof arguments[0] !== 'object' ? arguments[0] : 0,
6484 arguments[0].top !== undefined
6485 ? arguments[0].top
6486 : arguments[1] !== undefined ? arguments[1] : 0
6487 );
6488
6489 return;
6490 }
6491
6492 // LET THE SMOOTHNESS BEGIN!
6493 smoothScroll.call(
6494 w,
6495 d.body,
6496 ~~arguments[0].left + (w.scrollX || w.pageXOffset),
6497 ~~arguments[0].top + (w.scrollY || w.pageYOffset)
6498 );
6499 };
6500
6501 // Element.prototype.scroll and Element.prototype.scrollTo
6502 Element.prototype.scroll = Element.prototype.scrollTo = function() {
6503 // avoid action when no arguments are passed
6504 if (arguments[0] === undefined) {
6505 return;
6506 }
6507
6508 // avoid smooth behavior if not required
6509 if (shouldBailOut(arguments[0]) === true) {
6510 // if one number is passed, throw error to match Firefox implementation
6511 if (typeof arguments[0] === 'number' && arguments[1] === undefined) {
6512 throw new SyntaxError('Value could not be converted');
6513 }
6514
6515 original.elementScroll.call(
6516 this,
6517 // use left prop, first number argument or fallback to scrollLeft
6518 arguments[0].left !== undefined
6519 ? ~~arguments[0].left
6520 : typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft,
6521 // use top prop, second argument or fallback to scrollTop
6522 arguments[0].top !== undefined
6523 ? ~~arguments[0].top
6524 : arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop
6525 );
6526
6527 return;
6528 }
6529
6530 var left = arguments[0].left;
6531 var top = arguments[0].top;
6532
6533 // LET THE SMOOTHNESS BEGIN!
6534 smoothScroll.call(
6535 this,
6536 this,
6537 typeof left === 'undefined' ? this.scrollLeft : ~~left,
6538 typeof top === 'undefined' ? this.scrollTop : ~~top
6539 );
6540 };
6541
6542 // Element.prototype.scrollBy
6543 Element.prototype.scrollBy = function() {
6544 // avoid action when no arguments are passed
6545 if (arguments[0] === undefined) {
6546 return;
6547 }
6548
6549 // avoid smooth behavior if not required
6550 if (shouldBailOut(arguments[0]) === true) {
6551 original.elementScroll.call(
6552 this,
6553 arguments[0].left !== undefined
6554 ? ~~arguments[0].left + this.scrollLeft
6555 : ~~arguments[0] + this.scrollLeft,
6556 arguments[0].top !== undefined
6557 ? ~~arguments[0].top + this.scrollTop
6558 : ~~arguments[1] + this.scrollTop
6559 );
6560
6561 return;
6562 }
6563
6564 this.scroll({
6565 left: ~~arguments[0].left + this.scrollLeft,
6566 top: ~~arguments[0].top + this.scrollTop,
6567 behavior: arguments[0].behavior
6568 });
6569 };
6570
6571 // Element.prototype.scrollIntoView
6572 Element.prototype.scrollIntoView = function() {
6573 // avoid smooth behavior if not required
6574 if (shouldBailOut(arguments[0]) === true) {
6575 original.scrollIntoView.call(
6576 this,
6577 arguments[0] === undefined ? true : arguments[0]
6578 );
6579
6580 return;
6581 }
6582
6583 // LET THE SMOOTHNESS BEGIN!
6584 var scrollableParent = findScrollableParent(this);
6585 var parentRects = scrollableParent.getBoundingClientRect();
6586 var clientRects = this.getBoundingClientRect();
6587
6588 if (scrollableParent !== d.body) {
6589 // reveal element inside parent
6590 smoothScroll.call(
6591 this,
6592 scrollableParent,
6593 scrollableParent.scrollLeft + clientRects.left - parentRects.left,
6594 scrollableParent.scrollTop + clientRects.top - parentRects.top
6595 );
6596
6597 // reveal parent in viewport unless is fixed
6598 if (w.getComputedStyle(scrollableParent).position !== 'fixed') {
6599 w.scrollBy({
6600 left: parentRects.left,
6601 top: parentRects.top,
6602 behavior: 'smooth'
6603 });
6604 }
6605 } else {
6606 // reveal element in viewport
6607 w.scrollBy({
6608 left: clientRects.left,
6609 top: clientRects.top,
6610 behavior: 'smooth'
6611 });
6612 }
6613 };
6614 }
6615
6616 {
6617 // commonjs
6618 module.exports = { polyfill: polyfill };
6619 }
6620
6621 }());
6622 });
6623 var smoothscroll_1 = smoothscroll.polyfill;
6624
6625 smoothscroll.polyfill();
6626 var render$1 = preact.render;
6627 /**
6628 * Creates incremented ID for each newly created step
6629 *
6630 * @return {Function} A function that returns the unique id for the step
6631 * @private
6632 */
6633
6634 var uniqueId = function () {
6635 var id = 0;
6636 return function () {
6637 return ++id;
6638 };
6639 }();
6640 /**
6641 * A class representing steps to be added to a tour.
6642 * @extends {Evented}
6643 */
6644
6645
6646 var Step =
6647 /*#__PURE__*/
6648 function (_Evented) {
6649 _inheritsLoose(Step, _Evented);
6650
6651 /**
6652 * Create a step
6653 * @param {Tour} tour The tour for the step
6654 * @param {Object} options The options for the step
6655 * @param {Object} options.attachTo What element the step should be attached to on the page.
6656 * It should be an object with the properties `element` and `on`, where `element` is an element selector string
6657 * or a DOM element and `on` is the optional direction to place the Tippy tooltip.
6658 *
6659 * ```js
6660 * const new Step(tour, {
6661 * attachTo: { element: '.some .selector-path', on: 'left' },
6662 * ...moreOptions
6663 * })'
6664 * ```
6665 *
6666 * If you don’t specify an attachTo the element will appear in the middle of the screen.
6667 * If you omit the `on` portion of `attachTo`, the element will still be highlighted, but the tooltip will appear
6668 * in the middle of the screen, without an arrow pointing to the target.
6669 * @param {HTMLElement|string} options.attachTo.element
6670 * @param {string} options.attachTo.on
6671 * @param {Object} options.advanceOn An action on the page which should advance shepherd to the next step.
6672 * It should be an object with a string `selector` and an `event` name
6673 * ```js
6674 * const new Step(tour, {
6675 * advanceOn: { selector: '.some .selector-path', event: 'click' },
6676 * ...moreOptions
6677 * })'
6678 * ```
6679 * `event` doesn’t have to be an event inside the tour, it can be any event fired on any element on the page.
6680 * You can also always manually advance the Tour by calling `myTour.next()`.
6681 * @param {function} options.beforeShowPromise A function that returns a promise.
6682 * When the promise resolves, the rest of the `show` code for the step will execute.
6683 * @param {Object[]} options.buttons An array of buttons to add to the step. These will be rendered in a
6684 * footer below the main body text.
6685 * @param {function} options.buttons.button.action A function executed when the button is clicked on.
6686 * It is automatically bound to the `tour` the step is associated with, so things like `this.next` will
6687 * work inside the action.
6688 * You can use action to skip steps or navigate to specific steps, with something like:
6689 * ```js
6690 * action() {
6691 * return this.show('some_step_name');
6692 * }
6693 * ```
6694 * @param {string} options.buttons.button.classes Extra classes to apply to the `<a>`
6695 * @param {boolean} options.buttons.button.secondary If true, a shepherd-button-secondary class is applied to the button
6696 * @param {string} options.buttons.button.text The HTML text of the button
6697 * @param {boolean} options.canClickTarget A boolean, that when set to false, will set `pointer-events: none` on the target
6698 * @param {object} options.cancelIcon Options for the cancel icon
6699 * @param {boolean} options.cancelIcon.enabled Should a cancel “✕” be shown in the header of the step?
6700 * @param {string} options.cancelIcon.label The label to add for `aria-label`
6701 * @param {string} options.classes A string of extra classes to add to the step's content element.
6702 * @param {string} options.highlightClass An extra class to apply to the `attachTo` element when it is
6703 * highlighted (that is, when its step is active). You can then target that selector in your CSS.
6704 * @param {string} options.id The string to use as the `id` for the step.
6705 * @param {Object} options.tippyOptions Extra [options to pass to tippy.js]{@link https://atomiks.github.io/tippyjs/#all-options}
6706 * @param {boolean|Object} options.scrollTo Should the element be scrolled to when this step is shown? If true, uses the default `scrollIntoView`,
6707 * if an object, passes that object as the params to `scrollIntoView` i.e. `{behavior: 'smooth', block: 'center'}`
6708 * @param {function} options.scrollToHandler A function that lets you override the default scrollTo behavior and
6709 * define a custom action to do the scrolling, and possibly other logic.
6710 * @param {function} options.showOn A function that, when it returns `true`, will show the step.
6711 * If it returns false, the step will be skipped.
6712 * @param {string} options.text The text in the body of the step. It can be one of three types:
6713 * ```
6714 * - HTML string
6715 * - `HTMLElement` object
6716 * - `Function` to be executed when the step is built. It must return one the two options above.
6717 * ```
6718 * @param {string} options.title The step's title. It becomes an `h3` at the top of the step.
6719 * @param {Object} options.when You can define `show`, `hide`, etc events inside `when`. For example:
6720 * ```js
6721 * when: {
6722 * show: function() {
6723 * window.scrollTo(0, 0);
6724 * }
6725 * }
6726 * ```
6727 * @param {Number} options.modalOverlayOpeningPadding An amount of padding to add around the modal overlay opening
6728 * @return {Step} The newly created Step instance
6729 */
6730 function Step(tour, options) {
6731 var _this;
6732
6733 if (options === void 0) {
6734 options = {};
6735 }
6736
6737 _this = _Evented.call(this, tour, options) || this;
6738 _this.tour = tour;
6739 _this.classPrefix = _this.tour.options ? normalizePrefix(_this.tour.options.classPrefix) : '';
6740 _this.styles = tour.styles;
6741 autoBind(_assertThisInitialized(_this));
6742
6743 _this._setOptions(options);
6744
6745 return _assertThisInitialized(_this) || _assertThisInitialized(_this);
6746 }
6747 /**
6748 * Cancel the tour
6749 * Triggers the `cancel` event
6750 */
6751
6752
6753 var _proto = Step.prototype;
6754
6755 _proto.cancel = function cancel() {
6756 this.tour.cancel();
6757 this.trigger('cancel');
6758 }
6759 /**
6760 * Complete the tour
6761 * Triggers the `complete` event
6762 */
6763 ;
6764
6765 _proto.complete = function complete() {
6766 this.tour.complete();
6767 this.trigger('complete');
6768 }
6769 /**
6770 * Remove the step, delete the step's element, and destroy the tippy instance for the step
6771 * Triggers `destroy` event
6772 */
6773 ;
6774
6775 _proto.destroy = function destroy() {
6776 if (this.tooltip) {
6777 this.tooltip.destroy();
6778 this.tooltip = null;
6779 }
6780
6781 if (isElement(this.el) && this.el.parentNode) {
6782 this.el.parentNode.removeChild(this.el);
6783 this.el = null;
6784 }
6785
6786 if (this.target) {
6787 this._updateStepTargetOnHide();
6788 }
6789
6790 this.trigger('destroy');
6791 }
6792 /**
6793 * Returns the tour for the step
6794 * @return {Tour} The tour instance
6795 */
6796 ;
6797
6798 _proto.getTour = function getTour() {
6799 return this.tour;
6800 }
6801 /**
6802 * Hide the step and destroy the tippy instance
6803 */
6804 ;
6805
6806 _proto.hide = function hide() {
6807 this.tour.modal.hide();
6808 this.trigger('before-hide');
6809 document.body.removeAttribute("data-" + this.classPrefix + "shepherd-step");
6810
6811 if (this.target) {
6812 this._updateStepTargetOnHide();
6813 }
6814
6815 if (this.tooltip) {
6816 this.tooltip.hide();
6817 }
6818
6819 this.trigger('hide');
6820 }
6821 /**
6822 * Check if the step is open and visible
6823 * @return {boolean} True if the step is open and visible
6824 */
6825 ;
6826
6827 _proto.isOpen = function isOpen() {
6828 return Boolean(this.tooltip && this.tooltip.state && this.tooltip.state.isVisible);
6829 }
6830 /**
6831 * Wraps `_show` and ensures `beforeShowPromise` resolves before calling show
6832 * @return {*|Promise}
6833 */
6834 ;
6835
6836 _proto.show = function show() {
6837 var _this2 = this;
6838
6839 if (isFunction(this.options.beforeShowPromise)) {
6840 var beforeShowPromise = this.options.beforeShowPromise();
6841
6842 if (!isUndefined(beforeShowPromise)) {
6843 return beforeShowPromise.then(function () {
6844 return _this2._show();
6845 });
6846 }
6847 }
6848
6849 this._show();
6850 }
6851 /**
6852 * Creates Shepherd element for step based on options
6853 *
6854 * @return {Element} The DOM element for the step tooltip
6855 * @private
6856 */
6857 ;
6858
6859 _proto._createTooltipContent = function _createTooltipContent() {
6860 var cancelIconEnabled = getValue(this, 'options.cancelIcon.enabled');
6861 var classes = this.options.classes || '';
6862 var descriptionId = this.id + "-description";
6863 var labelId = this.id + "-label";
6864
6865 if (cancelIconEnabled) {
6866 classes += " " + this.classPrefix + "shepherd-has-cancel-icon";
6867 }
6868
6869 return render$1(preact.h(ShepherdElement, {
6870 classPrefix: this.classPrefix,
6871 classes: classes,
6872 descriptionId: descriptionId,
6873 labelId: labelId,
6874 step: this,
6875 styles: this.styles
6876 }), null);
6877 }
6878 /**
6879 * If a custom scrollToHandler is defined, call that, otherwise do the generic
6880 * scrollIntoView call.
6881 *
6882 * @param {boolean|Object} scrollToOptions If true, uses the default `scrollIntoView`,
6883 * if an object, passes that object as the params to `scrollIntoView` i.e. `{ behavior: 'smooth', block: 'center' }`
6884 * @private
6885 */
6886 ;
6887
6888 _proto._scrollTo = function _scrollTo(scrollToOptions) {
6889 var _parseAttachTo = parseAttachTo(this),
6890 element = _parseAttachTo.element;
6891
6892 if (isFunction(this.options.scrollToHandler)) {
6893 this.options.scrollToHandler(element);
6894 } else if (isElement(element)) {
6895 element.scrollIntoView(scrollToOptions);
6896 }
6897 }
6898 /**
6899 * Sets the options for the step, maps `when` to events, sets up buttons
6900 * @param {Object} options The options for the step
6901 * @private
6902 */
6903 ;
6904
6905 _proto._setOptions = function _setOptions(options) {
6906 var _this3 = this;
6907
6908 if (options === void 0) {
6909 options = {};
6910 }
6911
6912 this.options = options;
6913 var when = this.options.when;
6914 this.destroy();
6915 this.id = this.options.id || "step-" + uniqueId();
6916
6917 if (when) {
6918 Object.keys(when).forEach(function (event) {
6919 _this3.on(event, when[event], _this3);
6920 });
6921 }
6922 }
6923 /**
6924 * Create the element and set up the tippy instance
6925 * @private
6926 */
6927 ;
6928
6929 _proto._setupElements = function _setupElements() {
6930 if (!isUndefined(this.el)) {
6931 this.destroy();
6932 }
6933
6934 this.el = this._createTooltipContent();
6935
6936 if (this.options.advanceOn) {
6937 bindAdvance(this);
6938 }
6939
6940 setupTooltip(this);
6941 }
6942 /**
6943 * Triggers `before-show`, generates the tooltip DOM content,
6944 * sets up a tippy instance for the tooltip, then triggers `show`.
6945 * @private
6946 */
6947 ;
6948
6949 _proto._show = function _show() {
6950 var _this4 = this;
6951
6952 this.trigger('before-show');
6953
6954 if (!this.el) {
6955 this._setupElements();
6956 }
6957
6958 this.tour.modal.setupForStep(this);
6959
6960 this._styleTargetElementForStep(this);
6961
6962 var target = this.target || document.body;
6963 target.classList.add(this.classPrefix + "shepherd-enabled", this.classPrefix + "shepherd-target");
6964 document.body.setAttribute("data-" + this.classPrefix + "shepherd-step", this.id);
6965
6966 if (this.options.scrollTo) {
6967 setTimeout(function () {
6968 _this4._scrollTo(_this4.options.scrollTo);
6969 });
6970 }
6971
6972 this.tooltip.show();
6973 this.trigger('show');
6974 this.el.focus();
6975 }
6976 /**
6977 * Modulates the styles of the passed step's target element, based on the step's options and
6978 * the tour's `modal` option, to visually emphasize the element
6979 *
6980 * @param step The step object that attaches to the element
6981 * @private
6982 */
6983 ;
6984
6985 _proto._styleTargetElementForStep = function _styleTargetElementForStep(step) {
6986 var targetElement = step.target;
6987
6988 if (!targetElement) {
6989 return;
6990 }
6991
6992 toggleShepherdModalClass(targetElement, step.classPrefix);
6993
6994 if (step.options.highlightClass) {
6995 targetElement.classList.add(step.options.highlightClass);
6996 }
6997
6998 if (step.options.canClickTarget === false) {
6999 targetElement.style.pointerEvents = 'none';
7000 }
7001 }
7002 /**
7003 * When a step is hidden, remove the highlightClass and 'shepherd-enabled'
7004 * and 'shepherd-target' classes
7005 * @private
7006 */
7007 ;
7008
7009 _proto._updateStepTargetOnHide = function _updateStepTargetOnHide() {
7010 if (this.options.highlightClass) {
7011 this.target.classList.remove(this.options.highlightClass);
7012 }
7013
7014 this.target.classList.remove(this.classPrefix + "shepherd-enabled", this.classPrefix + "shepherd-target");
7015 };
7016
7017 return Step;
7018 }(Evented);
7019
7020 var bodyScrollLock_min = createCommonjsModule(function (module, exports) {
7021 !function(e,t){t(exports);}(commonjsGlobal,function(exports){function r(e){if(Array.isArray(e)){for(var t=0,o=Array(e.length);t<e.length;t++)o[t]=e[t];return o}return Array.from(e)}Object.defineProperty(exports,"__esModule",{value:!0});var l=!1;if("undefined"!=typeof window){var e={get passive(){l=!0;}};window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e);}var d="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),c=[],u=!1,a=-1,s=void 0,v=void 0,f=function(t){return c.some(function(e){return !(!e.options.allowTouchMove||!e.options.allowTouchMove(t))})},m=function(e){var t=e||window.event;return !!f(t.target)||(1<t.touches.length||(t.preventDefault&&t.preventDefault(),!1))},o=function(){setTimeout(function(){void 0!==v&&(document.body.style.paddingRight=v,v=void 0),void 0!==s&&(document.body.style.overflow=s,s=void 0);});};exports.disableBodyScroll=function(i,e){if(d){if(!i)return void console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");if(i&&!c.some(function(e){return e.targetElement===i})){var t={targetElement:i,options:e||{}};c=[].concat(r(c),[t]),i.ontouchstart=function(e){1===e.targetTouches.length&&(a=e.targetTouches[0].clientY);},i.ontouchmove=function(e){var t,o,n,r;1===e.targetTouches.length&&(o=i,r=(t=e).targetTouches[0].clientY-a,!f(t.target)&&(o&&0===o.scrollTop&&0<r?m(t):(n=o)&&n.scrollHeight-n.scrollTop<=n.clientHeight&&r<0?m(t):t.stopPropagation()));},u||(document.addEventListener("touchmove",m,l?{passive:!1}:void 0),u=!0);}}else{n=e,setTimeout(function(){if(void 0===v){var e=!!n&&!0===n.reserveScrollBarGap,t=window.innerWidth-document.documentElement.clientWidth;e&&0<t&&(v=document.body.style.paddingRight,document.body.style.paddingRight=t+"px");}void 0===s&&(s=document.body.style.overflow,document.body.style.overflow="hidden");});var o={targetElement:i,options:e||{}};c=[].concat(r(c),[o]);}var n;},exports.clearAllBodyScrollLocks=function(){d?(c.forEach(function(e){e.targetElement.ontouchstart=null,e.targetElement.ontouchmove=null;}),u&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1),c=[],a=-1):(o(),c=[]);},exports.enableBodyScroll=function(t){if(d){if(!t)return void console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");t.ontouchstart=null,t.ontouchmove=null,c=c.filter(function(e){return e.targetElement!==t}),u&&0===c.length&&(document.removeEventListener("touchmove",m,l?{passive:!1}:void 0),u=!1);}else(c=c.filter(function(e){return e.targetElement!==t})).length||o();};});
7022 });
7023
7024 var bodyScrollLock = unwrapExports(bodyScrollLock_min);
7025
7026 var defaults = {
7027 trigger: 'manual',
7028 arrow: true,
7029 animation: 'fade',
7030 duration: 420,
7031 flip: true,
7032 animateFill: false,
7033 // https://atomiks.github.io/tippyjs/#animate-fill-option
7034 interactive: true,
7035 // https://atomiks.github.io/tippyjs/#interactive-option
7036 hideOnClick: 'toggle',
7037 // https://atomiks.github.io/tippyjs/#hide-on-click-option
7038 multiple: true // https://atomiks.github.io/tippyjs/#multiple-option
7039
7040 };
7041
7042 /**
7043 * Cleanup the steps and set pointerEvents back to 'auto'
7044 * @param tour The tour object
7045 */
7046 function cleanupSteps(tour) {
7047 if (tour) {
7048 var steps = tour.steps;
7049 steps.forEach(function (step) {
7050 if (step.options && step.options.canClickTarget === false && step.options.attachTo) {
7051 var stepElement = step.target;
7052
7053 if (stepElement instanceof HTMLElement) {
7054 stepElement.style.pointerEvents = 'auto';
7055 }
7056 }
7057 });
7058 }
7059 }
7060
7061 function _extends$3() {
7062 _extends$3 = Object.assign || function (target) {
7063 for (var i = 1; i < arguments.length; i++) {
7064 var source = arguments[i];
7065
7066 for (var key in source) {
7067 if (Object.prototype.hasOwnProperty.call(source, key)) {
7068 target[key] = source[key];
7069 }
7070 }
7071 }
7072
7073 return target;
7074 };
7075
7076 return _extends$3.apply(this, arguments);
7077 }
7078
7079 function _assertThisInitialized$1(self) {
7080 if (self === void 0) {
7081 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7082 }
7083
7084 return self;
7085 }
7086
7087 function _inheritsLoose$1(subClass, superClass) {
7088 subClass.prototype = Object.create(superClass.prototype);
7089 subClass.prototype.constructor = subClass;
7090 subClass.__proto__ = superClass;
7091 }
7092
7093 function _getPrototypeOf(o) {
7094 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
7095 return o.__proto__ || Object.getPrototypeOf(o);
7096 };
7097 return _getPrototypeOf(o);
7098 }
7099
7100 function _setPrototypeOf(o, p) {
7101 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
7102 o.__proto__ = p;
7103 return o;
7104 };
7105
7106 return _setPrototypeOf(o, p);
7107 }
7108
7109 function _isNativeFunction(fn) {
7110 return Function.toString.call(fn).indexOf("[native code]") !== -1;
7111 }
7112
7113 function isNativeReflectConstruct() {
7114 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
7115 if (Reflect.construct.sham) return false;
7116 if (typeof Proxy === "function") return true;
7117
7118 try {
7119 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
7120 return true;
7121 } catch (e) {
7122 return false;
7123 }
7124 }
7125
7126 function _construct(Parent, args, Class) {
7127 if (isNativeReflectConstruct()) {
7128 _construct = Reflect.construct;
7129 } else {
7130 _construct = function _construct(Parent, args, Class) {
7131 var a = [null];
7132 a.push.apply(a, args);
7133 var Constructor = Function.bind.apply(Parent, a);
7134 var instance = new Constructor();
7135 if (Class) _setPrototypeOf(instance, Class.prototype);
7136 return instance;
7137 };
7138 }
7139
7140 return _construct.apply(null, arguments);
7141 }
7142
7143 function _wrapNativeSuper(Class) {
7144 var _cache = typeof Map === "function" ? new Map() : undefined;
7145
7146 _wrapNativeSuper = function _wrapNativeSuper(Class) {
7147 if (Class === null || !_isNativeFunction(Class)) return Class;
7148
7149 if (typeof Class !== "function") {
7150 throw new TypeError("Super expression must either be null or a function");
7151 }
7152
7153 if (typeof _cache !== "undefined") {
7154 if (_cache.has(Class)) return _cache.get(Class);
7155
7156 _cache.set(Class, Wrapper);
7157 }
7158
7159 function Wrapper() {
7160 return _construct(Class, arguments, _getPrototypeOf(this).constructor);
7161 }
7162
7163 Wrapper.prototype = Object.create(Class.prototype, {
7164 constructor: {
7165 value: Wrapper,
7166 enumerable: false,
7167 writable: true,
7168 configurable: true
7169 }
7170 });
7171 return _setPrototypeOf(Wrapper, Class);
7172 };
7173
7174 return _wrapNativeSuper(Class);
7175 }
7176
7177 /**
7178 * Create an error file out of errors.md for development and a simple web link to the full errors
7179 * in production mode.
7180 * @private
7181 */
7182
7183
7184 var PolishedError =
7185 /*#__PURE__*/
7186 function (_Error) {
7187 _inheritsLoose$1(PolishedError, _Error);
7188
7189 function PolishedError(code) {
7190 var _this;
7191
7192 {
7193 _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/master/src/internalHelpers/errors.md#" + code + " for more information.") || this;
7194 }
7195
7196 return _assertThisInitialized$1(_this);
7197 }
7198
7199 return PolishedError;
7200 }(
7201 /*#__PURE__*/
7202 _wrapNativeSuper(Error));
7203
7204 function colorToInt(color) {
7205 return Math.round(color * 255);
7206 }
7207
7208 function convertToInt(red, green, blue) {
7209 return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
7210 }
7211
7212 function hslToRgb(hue, saturation, lightness, convert) {
7213 if (convert === void 0) {
7214 convert = convertToInt;
7215 }
7216
7217 if (saturation === 0) {
7218 // achromatic
7219 return convert(lightness, lightness, lightness);
7220 } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
7221
7222
7223 var huePrime = (hue % 360 + 360) % 360 / 60;
7224 var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
7225 var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
7226 var red = 0;
7227 var green = 0;
7228 var blue = 0;
7229
7230 if (huePrime >= 0 && huePrime < 1) {
7231 red = chroma;
7232 green = secondComponent;
7233 } else if (huePrime >= 1 && huePrime < 2) {
7234 red = secondComponent;
7235 green = chroma;
7236 } else if (huePrime >= 2 && huePrime < 3) {
7237 green = chroma;
7238 blue = secondComponent;
7239 } else if (huePrime >= 3 && huePrime < 4) {
7240 green = secondComponent;
7241 blue = chroma;
7242 } else if (huePrime >= 4 && huePrime < 5) {
7243 red = secondComponent;
7244 blue = chroma;
7245 } else if (huePrime >= 5 && huePrime < 6) {
7246 red = chroma;
7247 blue = secondComponent;
7248 }
7249
7250 var lightnessModification = lightness - chroma / 2;
7251 var finalRed = red + lightnessModification;
7252 var finalGreen = green + lightnessModification;
7253 var finalBlue = blue + lightnessModification;
7254 return convert(finalRed, finalGreen, finalBlue);
7255 }
7256
7257 var namedColorMap = {
7258 aliceblue: 'f0f8ff',
7259 antiquewhite: 'faebd7',
7260 aqua: '00ffff',
7261 aquamarine: '7fffd4',
7262 azure: 'f0ffff',
7263 beige: 'f5f5dc',
7264 bisque: 'ffe4c4',
7265 black: '000',
7266 blanchedalmond: 'ffebcd',
7267 blue: '0000ff',
7268 blueviolet: '8a2be2',
7269 brown: 'a52a2a',
7270 burlywood: 'deb887',
7271 cadetblue: '5f9ea0',
7272 chartreuse: '7fff00',
7273 chocolate: 'd2691e',
7274 coral: 'ff7f50',
7275 cornflowerblue: '6495ed',
7276 cornsilk: 'fff8dc',
7277 crimson: 'dc143c',
7278 cyan: '00ffff',
7279 darkblue: '00008b',
7280 darkcyan: '008b8b',
7281 darkgoldenrod: 'b8860b',
7282 darkgray: 'a9a9a9',
7283 darkgreen: '006400',
7284 darkgrey: 'a9a9a9',
7285 darkkhaki: 'bdb76b',
7286 darkmagenta: '8b008b',
7287 darkolivegreen: '556b2f',
7288 darkorange: 'ff8c00',
7289 darkorchid: '9932cc',
7290 darkred: '8b0000',
7291 darksalmon: 'e9967a',
7292 darkseagreen: '8fbc8f',
7293 darkslateblue: '483d8b',
7294 darkslategray: '2f4f4f',
7295 darkslategrey: '2f4f4f',
7296 darkturquoise: '00ced1',
7297 darkviolet: '9400d3',
7298 deeppink: 'ff1493',
7299 deepskyblue: '00bfff',
7300 dimgray: '696969',
7301 dimgrey: '696969',
7302 dodgerblue: '1e90ff',
7303 firebrick: 'b22222',
7304 floralwhite: 'fffaf0',
7305 forestgreen: '228b22',
7306 fuchsia: 'ff00ff',
7307 gainsboro: 'dcdcdc',
7308 ghostwhite: 'f8f8ff',
7309 gold: 'ffd700',
7310 goldenrod: 'daa520',
7311 gray: '808080',
7312 green: '008000',
7313 greenyellow: 'adff2f',
7314 grey: '808080',
7315 honeydew: 'f0fff0',
7316 hotpink: 'ff69b4',
7317 indianred: 'cd5c5c',
7318 indigo: '4b0082',
7319 ivory: 'fffff0',
7320 khaki: 'f0e68c',
7321 lavender: 'e6e6fa',
7322 lavenderblush: 'fff0f5',
7323 lawngreen: '7cfc00',
7324 lemonchiffon: 'fffacd',
7325 lightblue: 'add8e6',
7326 lightcoral: 'f08080',
7327 lightcyan: 'e0ffff',
7328 lightgoldenrodyellow: 'fafad2',
7329 lightgray: 'd3d3d3',
7330 lightgreen: '90ee90',
7331 lightgrey: 'd3d3d3',
7332 lightpink: 'ffb6c1',
7333 lightsalmon: 'ffa07a',
7334 lightseagreen: '20b2aa',
7335 lightskyblue: '87cefa',
7336 lightslategray: '789',
7337 lightslategrey: '789',
7338 lightsteelblue: 'b0c4de',
7339 lightyellow: 'ffffe0',
7340 lime: '0f0',
7341 limegreen: '32cd32',
7342 linen: 'faf0e6',
7343 magenta: 'f0f',
7344 maroon: '800000',
7345 mediumaquamarine: '66cdaa',
7346 mediumblue: '0000cd',
7347 mediumorchid: 'ba55d3',
7348 mediumpurple: '9370db',
7349 mediumseagreen: '3cb371',
7350 mediumslateblue: '7b68ee',
7351 mediumspringgreen: '00fa9a',
7352 mediumturquoise: '48d1cc',
7353 mediumvioletred: 'c71585',
7354 midnightblue: '191970',
7355 mintcream: 'f5fffa',
7356 mistyrose: 'ffe4e1',
7357 moccasin: 'ffe4b5',
7358 navajowhite: 'ffdead',
7359 navy: '000080',
7360 oldlace: 'fdf5e6',
7361 olive: '808000',
7362 olivedrab: '6b8e23',
7363 orange: 'ffa500',
7364 orangered: 'ff4500',
7365 orchid: 'da70d6',
7366 palegoldenrod: 'eee8aa',
7367 palegreen: '98fb98',
7368 paleturquoise: 'afeeee',
7369 palevioletred: 'db7093',
7370 papayawhip: 'ffefd5',
7371 peachpuff: 'ffdab9',
7372 peru: 'cd853f',
7373 pink: 'ffc0cb',
7374 plum: 'dda0dd',
7375 powderblue: 'b0e0e6',
7376 purple: '800080',
7377 rebeccapurple: '639',
7378 red: 'f00',
7379 rosybrown: 'bc8f8f',
7380 royalblue: '4169e1',
7381 saddlebrown: '8b4513',
7382 salmon: 'fa8072',
7383 sandybrown: 'f4a460',
7384 seagreen: '2e8b57',
7385 seashell: 'fff5ee',
7386 sienna: 'a0522d',
7387 silver: 'c0c0c0',
7388 skyblue: '87ceeb',
7389 slateblue: '6a5acd',
7390 slategray: '708090',
7391 slategrey: '708090',
7392 snow: 'fffafa',
7393 springgreen: '00ff7f',
7394 steelblue: '4682b4',
7395 tan: 'd2b48c',
7396 teal: '008080',
7397 thistle: 'd8bfd8',
7398 tomato: 'ff6347',
7399 turquoise: '40e0d0',
7400 violet: 'ee82ee',
7401 wheat: 'f5deb3',
7402 white: 'fff',
7403 whitesmoke: 'f5f5f5',
7404 yellow: 'ff0',
7405 yellowgreen: '9acd32'
7406 /**
7407 * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
7408 * @private
7409 */
7410
7411 };
7412
7413 function nameToHex(color) {
7414 if (typeof color !== 'string') return color;
7415 var normalizedColorName = color.toLowerCase();
7416 return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
7417 }
7418
7419 var hexRegex = /^#[a-fA-F0-9]{6}$/;
7420 var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
7421 var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
7422 var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
7423 var rgbRegex = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
7424 var rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
7425 var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i;
7426 var hslaRegex = /^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;
7427 /**
7428 * Returns an RgbColor or RgbaColor object. This utility function is only useful
7429 * if want to extract a color component. With the color util `toColorString` you
7430 * can convert a RgbColor or RgbaColor object back to a string.
7431 *
7432 * @example
7433 * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
7434 * const color1 = parseToRgb('rgb(255, 0, 0)');
7435 * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
7436 * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
7437 */
7438
7439 function parseToRgb(color) {
7440 if (typeof color !== 'string') {
7441 throw new PolishedError(3);
7442 }
7443
7444 var normalizedColor = nameToHex(color);
7445
7446 if (normalizedColor.match(hexRegex)) {
7447 return {
7448 red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
7449 green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
7450 blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
7451 };
7452 }
7453
7454 if (normalizedColor.match(hexRgbaRegex)) {
7455 var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
7456 return {
7457 red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
7458 green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
7459 blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
7460 alpha: alpha
7461 };
7462 }
7463
7464 if (normalizedColor.match(reducedHexRegex)) {
7465 return {
7466 red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
7467 green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
7468 blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
7469 };
7470 }
7471
7472 if (normalizedColor.match(reducedRgbaHexRegex)) {
7473 var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
7474
7475 return {
7476 red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
7477 green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
7478 blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
7479 alpha: _alpha
7480 };
7481 }
7482
7483 var rgbMatched = rgbRegex.exec(normalizedColor);
7484
7485 if (rgbMatched) {
7486 return {
7487 red: parseInt("" + rgbMatched[1], 10),
7488 green: parseInt("" + rgbMatched[2], 10),
7489 blue: parseInt("" + rgbMatched[3], 10)
7490 };
7491 }
7492
7493 var rgbaMatched = rgbaRegex.exec(normalizedColor);
7494
7495 if (rgbaMatched) {
7496 return {
7497 red: parseInt("" + rgbaMatched[1], 10),
7498 green: parseInt("" + rgbaMatched[2], 10),
7499 blue: parseInt("" + rgbaMatched[3], 10),
7500 alpha: parseFloat("" + rgbaMatched[4])
7501 };
7502 }
7503
7504 var hslMatched = hslRegex.exec(normalizedColor);
7505
7506 if (hslMatched) {
7507 var hue = parseInt("" + hslMatched[1], 10);
7508 var saturation = parseInt("" + hslMatched[2], 10) / 100;
7509 var lightness = parseInt("" + hslMatched[3], 10) / 100;
7510 var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
7511 var hslRgbMatched = rgbRegex.exec(rgbColorString);
7512
7513 if (!hslRgbMatched) {
7514 throw new PolishedError(4, normalizedColor, rgbColorString);
7515 }
7516
7517 return {
7518 red: parseInt("" + hslRgbMatched[1], 10),
7519 green: parseInt("" + hslRgbMatched[2], 10),
7520 blue: parseInt("" + hslRgbMatched[3], 10)
7521 };
7522 }
7523
7524 var hslaMatched = hslaRegex.exec(normalizedColor);
7525
7526 if (hslaMatched) {
7527 var _hue = parseInt("" + hslaMatched[1], 10);
7528
7529 var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
7530
7531 var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
7532
7533 var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
7534
7535 var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
7536
7537 if (!_hslRgbMatched) {
7538 throw new PolishedError(4, normalizedColor, _rgbColorString);
7539 }
7540
7541 return {
7542 red: parseInt("" + _hslRgbMatched[1], 10),
7543 green: parseInt("" + _hslRgbMatched[2], 10),
7544 blue: parseInt("" + _hslRgbMatched[3], 10),
7545 alpha: parseFloat("" + hslaMatched[4])
7546 };
7547 }
7548
7549 throw new PolishedError(5);
7550 }
7551
7552 function rgbToHsl(color) {
7553 // make sure rgb are contained in a set of [0, 255]
7554 var red = color.red / 255;
7555 var green = color.green / 255;
7556 var blue = color.blue / 255;
7557 var max = Math.max(red, green, blue);
7558 var min = Math.min(red, green, blue);
7559 var lightness = (max + min) / 2;
7560
7561 if (max === min) {
7562 // achromatic
7563 if (color.alpha !== undefined) {
7564 return {
7565 hue: 0,
7566 saturation: 0,
7567 lightness: lightness,
7568 alpha: color.alpha
7569 };
7570 } else {
7571 return {
7572 hue: 0,
7573 saturation: 0,
7574 lightness: lightness
7575 };
7576 }
7577 }
7578
7579 var hue;
7580 var delta = max - min;
7581 var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
7582
7583 switch (max) {
7584 case red:
7585 hue = (green - blue) / delta + (green < blue ? 6 : 0);
7586 break;
7587
7588 case green:
7589 hue = (blue - red) / delta + 2;
7590 break;
7591
7592 default:
7593 // blue case
7594 hue = (red - green) / delta + 4;
7595 break;
7596 }
7597
7598 hue *= 60;
7599
7600 if (color.alpha !== undefined) {
7601 return {
7602 hue: hue,
7603 saturation: saturation,
7604 lightness: lightness,
7605 alpha: color.alpha
7606 };
7607 }
7608
7609 return {
7610 hue: hue,
7611 saturation: saturation,
7612 lightness: lightness
7613 };
7614 }
7615
7616 /**
7617 * Returns an HslColor or HslaColor object. This utility function is only useful
7618 * if want to extract a color component. With the color util `toColorString` you
7619 * can convert a HslColor or HslaColor object back to a string.
7620 *
7621 * @example
7622 * // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
7623 * const color1 = parseToHsl('rgb(255, 0, 0)');
7624 * // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
7625 * const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
7626 */
7627 function parseToHsl(color) {
7628 // Note: At a later stage we can optimize this function as right now a hsl
7629 // color would be parsed converted to rgb values and converted back to hsl.
7630 return rgbToHsl(parseToRgb(color));
7631 }
7632
7633 /**
7634 * Reduces hex values if possible e.g. #ff8866 to #f86
7635 * @private
7636 */
7637 var reduceHexValue = function reduceHexValue(value) {
7638 if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
7639 return "#" + value[1] + value[3] + value[5];
7640 }
7641
7642 return value;
7643 };
7644
7645 function numberToHex(value) {
7646 var hex = value.toString(16);
7647 return hex.length === 1 ? "0" + hex : hex;
7648 }
7649
7650 function colorToHex(color) {
7651 return numberToHex(Math.round(color * 255));
7652 }
7653
7654 function convertToHex(red, green, blue) {
7655 return reduceHexValue("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
7656 }
7657
7658 function hslToHex(hue, saturation, lightness) {
7659 return hslToRgb(hue, saturation, lightness, convertToHex);
7660 }
7661
7662 /**
7663 * Returns a string value for the color. The returned result is the smallest possible hex notation.
7664 *
7665 * @example
7666 * // Styles as object usage
7667 * const styles = {
7668 * background: hsl(359, 0.75, 0.4),
7669 * background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
7670 * }
7671 *
7672 * // styled-components usage
7673 * const div = styled.div`
7674 * background: ${hsl(359, 0.75, 0.4)};
7675 * background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
7676 * `
7677 *
7678 * // CSS in JS Output
7679 *
7680 * element {
7681 * background: "#b3191c";
7682 * background: "#b3191c";
7683 * }
7684 */
7685 function hsl(value, saturation, lightness) {
7686 if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
7687 return hslToHex(value, saturation, lightness);
7688 } else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
7689 return hslToHex(value.hue, value.saturation, value.lightness);
7690 }
7691
7692 throw new PolishedError(1);
7693 }
7694
7695 /**
7696 * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
7697 *
7698 * @example
7699 * // Styles as object usage
7700 * const styles = {
7701 * background: hsla(359, 0.75, 0.4, 0.7),
7702 * background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
7703 * background: hsla(359, 0.75, 0.4, 1),
7704 * }
7705 *
7706 * // styled-components usage
7707 * const div = styled.div`
7708 * background: ${hsla(359, 0.75, 0.4, 0.7)};
7709 * background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
7710 * background: ${hsla(359, 0.75, 0.4, 1)};
7711 * `
7712 *
7713 * // CSS in JS Output
7714 *
7715 * element {
7716 * background: "rgba(179,25,28,0.7)";
7717 * background: "rgba(179,25,28,0.7)";
7718 * background: "#b3191c";
7719 * }
7720 */
7721 function hsla(value, saturation, lightness, alpha) {
7722 if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
7723 return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
7724 } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
7725 return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
7726 }
7727
7728 throw new PolishedError(2);
7729 }
7730
7731 /**
7732 * Returns a string value for the color. The returned result is the smallest possible hex notation.
7733 *
7734 * @example
7735 * // Styles as object usage
7736 * const styles = {
7737 * background: rgb(255, 205, 100),
7738 * background: rgb({ red: 255, green: 205, blue: 100 }),
7739 * }
7740 *
7741 * // styled-components usage
7742 * const div = styled.div`
7743 * background: ${rgb(255, 205, 100)};
7744 * background: ${rgb({ red: 255, green: 205, blue: 100 })};
7745 * `
7746 *
7747 * // CSS in JS Output
7748 *
7749 * element {
7750 * background: "#ffcd64";
7751 * background: "#ffcd64";
7752 * }
7753 */
7754 function rgb(value, green, blue) {
7755 if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
7756 return reduceHexValue("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
7757 } else if (typeof value === 'object' && green === undefined && blue === undefined) {
7758 return reduceHexValue("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
7759 }
7760
7761 throw new PolishedError(6);
7762 }
7763
7764 /**
7765 * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
7766 *
7767 * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
7768 *
7769 * @example
7770 * // Styles as object usage
7771 * const styles = {
7772 * background: rgba(255, 205, 100, 0.7),
7773 * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
7774 * background: rgba(255, 205, 100, 1),
7775 * background: rgba('#ffffff', 0.4),
7776 * background: rgba('black', 0.7),
7777 * }
7778 *
7779 * // styled-components usage
7780 * const div = styled.div`
7781 * background: ${rgba(255, 205, 100, 0.7)};
7782 * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
7783 * background: ${rgba(255, 205, 100, 1)};
7784 * background: ${rgba('#ffffff', 0.4)};
7785 * background: ${rgba('black', 0.7)};
7786 * `
7787 *
7788 * // CSS in JS Output
7789 *
7790 * element {
7791 * background: "rgba(255,205,100,0.7)";
7792 * background: "rgba(255,205,100,0.7)";
7793 * background: "#ffcd64";
7794 * background: "rgba(255,255,255,0.4)";
7795 * background: "rgba(0,0,0,0.7)";
7796 * }
7797 */
7798 function rgba(firstValue, secondValue, thirdValue, fourthValue) {
7799 if (typeof firstValue === 'string' && typeof secondValue === 'number') {
7800 var rgbValue = parseToRgb(firstValue);
7801 return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
7802 } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
7803 return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
7804 } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
7805 return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
7806 }
7807
7808 throw new PolishedError(7);
7809 }
7810
7811 var isRgb = function isRgb(color) {
7812 return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
7813 };
7814
7815 var isRgba = function isRgba(color) {
7816 return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
7817 };
7818
7819 var isHsl = function isHsl(color) {
7820 return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
7821 };
7822
7823 var isHsla = function isHsla(color) {
7824 return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
7825 };
7826 /**
7827 * Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
7828 * This util is useful in case you only know on runtime which color object is
7829 * used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
7830 *
7831 * @example
7832 * // Styles as object usage
7833 * const styles = {
7834 * background: toColorString({ red: 255, green: 205, blue: 100 }),
7835 * background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
7836 * background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
7837 * background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
7838 * }
7839 *
7840 * // styled-components usage
7841 * const div = styled.div`
7842 * background: ${toColorString({ red: 255, green: 205, blue: 100 })};
7843 * background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
7844 * background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
7845 * background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
7846 * `
7847 *
7848 * // CSS in JS Output
7849 * element {
7850 * background: "#ffcd64";
7851 * background: "rgba(255,205,100,0.72)";
7852 * background: "#00f";
7853 * background: "rgba(179,25,25,0.72)";
7854 * }
7855 */
7856
7857
7858 function toColorString(color) {
7859 if (typeof color !== 'object') throw new PolishedError(8);
7860 if (isRgba(color)) return rgba(color);
7861 if (isRgb(color)) return rgb(color);
7862 if (isHsla(color)) return hsla(color);
7863 if (isHsl(color)) return hsl(color);
7864 throw new PolishedError(8);
7865 }
7866
7867 // Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
7868 // eslint-disable-next-line no-unused-vars
7869 // eslint-disable-next-line no-unused-vars
7870 // eslint-disable-next-line no-redeclare
7871 function curried(f, length, acc) {
7872 return function fn() {
7873 // eslint-disable-next-line prefer-rest-params
7874 var combined = acc.concat(Array.prototype.slice.call(arguments));
7875 return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
7876 };
7877 } // eslint-disable-next-line no-redeclare
7878
7879
7880 function curry(f) {
7881 // eslint-disable-line no-redeclare
7882 return curried(f, f.length, []);
7883 }
7884
7885 function guard(lowerBoundary, upperBoundary, value) {
7886 return Math.max(lowerBoundary, Math.min(upperBoundary, value));
7887 }
7888
7889 /**
7890 * Returns a string value for the darkened color.
7891 *
7892 * @example
7893 * // Styles as object usage
7894 * const styles = {
7895 * background: darken(0.2, '#FFCD64'),
7896 * background: darken('0.2', 'rgba(255,205,100,0.7)'),
7897 * }
7898 *
7899 * // styled-components usage
7900 * const div = styled.div`
7901 * background: ${darken(0.2, '#FFCD64')};
7902 * background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
7903 * `
7904 *
7905 * // CSS in JS Output
7906 *
7907 * element {
7908 * background: "#ffbd31";
7909 * background: "rgba(255,189,49,0.7)";
7910 * }
7911 */
7912
7913 function darken(amount, color) {
7914 if (color === 'transparent') return color;
7915 var hslColor = parseToHsl(color);
7916 return toColorString(_extends$3({}, hslColor, {
7917 lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
7918 }));
7919 } // prettier-ignore
7920
7921
7922 var curriedDarken =
7923 /*#__PURE__*/
7924 curry
7925 /* ::<number | string, string, string> */
7926 (darken);
7927
7928 /**
7929 * Decreases the intensity of a color. Its range is between 0 to 1. The first
7930 * argument of the desaturate function is the amount by how much the color
7931 * intensity should be decreased.
7932 *
7933 * @example
7934 * // Styles as object usage
7935 * const styles = {
7936 * background: desaturate(0.2, '#CCCD64'),
7937 * background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
7938 * }
7939 *
7940 * // styled-components usage
7941 * const div = styled.div`
7942 * background: ${desaturate(0.2, '#CCCD64')};
7943 * background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
7944 * `
7945 *
7946 * // CSS in JS Output
7947 * element {
7948 * background: "#b8b979";
7949 * background: "rgba(184,185,121,0.7)";
7950 * }
7951 */
7952
7953 function desaturate(amount, color) {
7954 if (color === 'transparent') return color;
7955 var hslColor = parseToHsl(color);
7956 return toColorString(_extends$3({}, hslColor, {
7957 saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
7958 }));
7959 } // prettier-ignore
7960
7961
7962 var curriedDesaturate =
7963 /*#__PURE__*/
7964 curry
7965 /* ::<number | string, string, string> */
7966 (desaturate);
7967
7968 /**
7969 * Returns a number (float) representing the luminance of a color.
7970 *
7971 * @example
7972 * // Styles as object usage
7973 * const styles = {
7974 * background: getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff',
7975 * background: getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
7976 * 'rgba(58, 133, 255, 1)' :
7977 * 'rgba(255, 57, 149, 1)',
7978 * }
7979 *
7980 * // styled-components usage
7981 * const div = styled.div`
7982 * background: ${getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff'};
7983 * background: ${getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
7984 * 'rgba(58, 133, 255, 1)' :
7985 * 'rgba(255, 57, 149, 1)'};
7986 *
7987 * // CSS in JS Output
7988 *
7989 * div {
7990 * background: "#CCCD64";
7991 * background: "rgba(58, 133, 255, 1)";
7992 * }
7993 */
7994
7995 function getLuminance(color) {
7996 if (color === 'transparent') return 0;
7997 var rgbColor = parseToRgb(color);
7998
7999 var _Object$keys$map = Object.keys(rgbColor).map(function (key) {
8000 var channel = rgbColor[key] / 255;
8001 return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
8002 }),
8003 r = _Object$keys$map[0],
8004 g = _Object$keys$map[1],
8005 b = _Object$keys$map[2];
8006
8007 return parseFloat((0.2126 * r + 0.7152 * g + 0.0722 * b).toFixed(3));
8008 }
8009
8010 /**
8011 * Returns a string value for the lightened color.
8012 *
8013 * @example
8014 * // Styles as object usage
8015 * const styles = {
8016 * background: lighten(0.2, '#CCCD64'),
8017 * background: lighten('0.2', 'rgba(204,205,100,0.7)'),
8018 * }
8019 *
8020 * // styled-components usage
8021 * const div = styled.div`
8022 * background: ${lighten(0.2, '#FFCD64')};
8023 * background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
8024 * `
8025 *
8026 * // CSS in JS Output
8027 *
8028 * element {
8029 * background: "#e5e6b1";
8030 * background: "rgba(229,230,177,0.7)";
8031 * }
8032 */
8033
8034 function lighten(amount, color) {
8035 if (color === 'transparent') return color;
8036 var hslColor = parseToHsl(color);
8037 return toColorString(_extends$3({}, hslColor, {
8038 lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
8039 }));
8040 } // prettier-ignore
8041
8042
8043 var curriedLighten =
8044 /*#__PURE__*/
8045 curry
8046 /* ::<number | string, string, string> */
8047 (lighten);
8048
8049 /**
8050 * Returns black or white (or optional light and dark return colors) for best contrast depending on the luminosity of the given color.
8051 * Follows [W3C specs for readability](https://www.w3.org/TR/WCAG20-TECHS/G18.html).
8052 *
8053 * @example
8054 * // Styles as object usage
8055 * const styles = {
8056 * color: readableColor('#000'),
8057 * color: readableColor('black', '#001', '#ff8'),
8058 * color: readableColor('white', '#001', '#ff8'),
8059 * }
8060 *
8061 * // styled-components usage
8062 * const div = styled.div`
8063 * color: ${readableColor('#000')};
8064 * color: ${readableColor('black', '#001', '#ff8')};
8065 * color: ${readableColor('white', '#001', '#ff8')};
8066 * `
8067 *
8068 * // CSS in JS Output
8069 *
8070 * element {
8071 * color: "#fff";
8072 * color: "#ff8";
8073 * color: "#001";
8074 * }
8075 */
8076
8077 function readableColor(color, lightReturnColor, darkReturnColor) {
8078 if (lightReturnColor === void 0) {
8079 lightReturnColor = '#000';
8080 }
8081
8082 if (darkReturnColor === void 0) {
8083 darkReturnColor = '#fff';
8084 }
8085
8086 return getLuminance(color) > 0.179 ? lightReturnColor : darkReturnColor;
8087 }
8088
8089 /**
8090 * Decreases the opacity of a color. Its range for the amount is between 0 to 1.
8091 *
8092 *
8093 * @example
8094 * // Styles as object usage
8095 * const styles = {
8096 * background: transparentize(0.1, '#fff');
8097 * background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
8098 * background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
8099 * }
8100 *
8101 * // styled-components usage
8102 * const div = styled.div`
8103 * background: ${transparentize(0.1, '#fff')};
8104 * background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')},
8105 * background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')},
8106 * `
8107 *
8108 * // CSS in JS Output
8109 *
8110 * element {
8111 * background: "rgba(255,255,255,0.9)";
8112 * background: "rgba(255,255,255,0.8)";
8113 * background: "rgba(255,0,0,0.3)";
8114 * }
8115 */
8116
8117 function transparentize(amount, color) {
8118 if (color === 'transparent') return color;
8119 var parsedColor = parseToRgb(color);
8120 var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
8121
8122 var colorWithAlpha = _extends$3({}, parsedColor, {
8123 alpha: guard(0, 1, (alpha * 100 - parseFloat(amount) * 100) / 100)
8124 });
8125
8126 return rgba(colorWithAlpha);
8127 } // prettier-ignore
8128
8129
8130 var curriedTransparentize =
8131 /*#__PURE__*/
8132 curry
8133 /* ::<number | string, string, string> */
8134 (transparentize);
8135
8136 var styles = {
8137 arrowSize: 2.1,
8138 overlayOpacity: 0.25,
8139 shepherdButtonBorderRadius: '3px',
8140 shepherdElementBorderRadius: '5px',
8141 shepherdElementMaxHeight: '100%',
8142 shepherdElementMaxWidth: '100%',
8143 shepherdElementZIndex: 999901,
8144 shepherdTextBackground: '#ffffff',
8145 shepherdTextLineHeight: '1.3em',
8146 shepherdTextFontSize: '1rem',
8147 shepherdThemePrimary: '#3288e6'
8148 };
8149 function getVariables(options) {
8150 if (options.styleVariables) {
8151 _extends(styles, options.styleVariables);
8152 }
8153
8154 if (!styles.shepherdHeaderBackground) {
8155 styles.shepherdHeaderBackground = curriedDarken(0.1, styles.shepherdTextBackground);
8156 }
8157
8158 if (!styles.shepherdThemeSecondary) {
8159 styles.shepherdThemeSecondary = curriedDesaturate(0.7, curriedLighten(0.4, styles.shepherdThemePrimary));
8160 }
8161
8162 _setTextColors();
8163
8164 return styles;
8165 }
8166 /**
8167 * Set all the text colors to contrasting ones, for readability, if not already defined.
8168 * @private
8169 */
8170
8171 function _setTextColors() {
8172 if (!styles.shepherdThemeTextPrimary) {
8173 styles.shepherdThemeTextPrimary = curriedTransparentize(0.25, readableColor(styles.shepherdThemePrimary));
8174 }
8175
8176 if (!styles.shepherdThemeTextSecondary) {
8177 styles.shepherdThemeTextSecondary = curriedTransparentize(0.25, readableColor(styles.shepherdThemeSecondary));
8178 }
8179
8180 if (!styles.shepherdThemeTextHeader) {
8181 styles.shepherdThemeTextHeader = curriedTransparentize(0.25, readableColor(styles.shepherdHeaderBackground));
8182 }
8183
8184 if (!styles.shepherdThemeTextColor) {
8185 styles.shepherdThemeTextColor = curriedTransparentize(0.25, readableColor(styles.shepherdTextBackground));
8186 }
8187 }
8188
8189 /**
8190 * Code refactored from Mozilla Developer Network:
8191 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
8192 */
8193
8194 function assign$1(target, firstSource) {
8195 if (target === undefined || target === null) {
8196 throw new TypeError('Cannot convert first argument to object');
8197 }
8198
8199 var to = Object(target);
8200 for (var i = 1; i < arguments.length; i++) {
8201 var nextSource = arguments[i];
8202 if (nextSource === undefined || nextSource === null) {
8203 continue;
8204 }
8205
8206 var keysArray = Object.keys(Object(nextSource));
8207 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
8208 var nextKey = keysArray[nextIndex];
8209 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
8210 if (desc !== undefined && desc.enumerable) {
8211 to[nextKey] = nextSource[nextKey];
8212 }
8213 }
8214 }
8215 return to;
8216 }
8217
8218 function polyfill$1() {
8219 if (!Object.assign) {
8220 Object.defineProperty(Object, 'assign', {
8221 enumerable: false,
8222 configurable: true,
8223 writable: true,
8224 value: assign$1
8225 });
8226 }
8227 }
8228
8229 var es6ObjectAssign = {
8230 assign: assign$1,
8231 polyfill: polyfill$1
8232 };
8233 var es6ObjectAssign_1 = es6ObjectAssign.assign;
8234
8235 var KEBAB_REGEX = /[A-Z]/g;
8236
8237 var _hash = function hash(str) {
8238 var hash = 5381,
8239 i = str.length;
8240
8241 while (i) {
8242 hash = hash * 33 ^ str.charCodeAt(--i);
8243 }
8244
8245 return '_' + (hash >>> 0).toString(36);
8246 };
8247
8248 var create$2 = function create(config) {
8249 config = config || {};
8250 var assign = config.assign || Object.assign;
8251 var client = typeof window === 'object'; // Check if we are really in browser environment.
8252
8253 var renderer = assign({
8254 raw: '',
8255 pfx: '_',
8256 client: client,
8257 assign: assign,
8258 stringify: JSON.stringify,
8259 kebab: function kebab(prop) {
8260 return prop.replace(KEBAB_REGEX, '-$&').toLowerCase();
8261 },
8262 decl: function decl(key, value) {
8263 key = renderer.kebab(key);
8264 return key + ':' + value + ';';
8265 },
8266 hash: function hash(obj) {
8267 return _hash(renderer.stringify(obj));
8268 },
8269 selector: function selector(parent, _selector) {
8270 return parent + (_selector[0] === ':' ? '' : ' ') + _selector;
8271 },
8272 putRaw: function putRaw(rawCssRule) {
8273 renderer.raw += rawCssRule;
8274 }
8275 }, config);
8276
8277 if (renderer.client) {
8278 if (!renderer.sh) document.head.appendChild(renderer.sh = document.createElement('style'));
8279
8280 renderer.putRaw = function (rawCssRule) {
8281 // .insertRule() is faster than .appendChild(), that's why we use it in PROD.
8282 // But CSS injected using .insertRule() is not displayed in Chrome Devtools,
8283 // that's why we use .appendChild in DEV.
8284 {
8285 var sheet = renderer.sh.sheet; // Unknown pseudo-selectors will throw, this try/catch swallows all errors.
8286
8287 try {
8288 sheet.insertRule(rawCssRule, sheet.cssRules.length); // eslint-disable-next-line no-empty
8289 } catch (error) {}
8290 }
8291 };
8292 }
8293
8294 renderer.put = function (selector, decls, atrule) {
8295 var str = '';
8296 var prop, value;
8297 var postponed = [];
8298
8299 for (prop in decls) {
8300 value = decls[prop];
8301
8302 if (value instanceof Object && !(value instanceof Array)) {
8303 postponed.push(prop);
8304 } else {
8305 {
8306 str += renderer.decl(prop, value, selector, atrule);
8307 }
8308 }
8309 }
8310
8311 if (str) {
8312 {
8313 str = selector + '{' + str + '}';
8314 }
8315
8316 renderer.putRaw(atrule ? atrule + '{' + str + '}' : str);
8317 }
8318
8319 for (var i = 0; i < postponed.length; i++) {
8320 prop = postponed[i];
8321
8322 if (prop[0] === "@" && prop !== "@font-face") {
8323 renderer.putAt(selector, decls[prop], prop);
8324 } else {
8325 renderer.put(renderer.selector(selector, prop), decls[prop], atrule);
8326 }
8327 }
8328 };
8329
8330 renderer.putAt = renderer.put;
8331 return renderer;
8332 };
8333
8334 var addon = function addon(renderer) {
8335 var cache = {};
8336
8337 renderer.cache = function (css) {
8338 if (!css) return '';
8339 var key = renderer.hash(css);
8340
8341 if (!cache[key]) {
8342 cache[key] = renderer.rule(css, key);
8343 }
8344
8345 return cache[key];
8346 };
8347 };
8348
8349 var addon$1 = function addon(renderer) {
8350 renderer.selector = function (parentSelectors, selector) {
8351 var parents = parentSelectors.split(',');
8352 var result = [];
8353 var selectors = selector.split(',');
8354 var len1 = parents.length;
8355 var len2 = selectors.length;
8356 var i, j, sel, pos, parent, replacedSelector;
8357
8358 for (i = 0; i < len2; i++) {
8359 sel = selectors[i];
8360 pos = sel.indexOf('&');
8361
8362 if (pos > -1) {
8363 for (j = 0; j < len1; j++) {
8364 parent = parents[j];
8365 replacedSelector = sel.replace(/&/g, parent);
8366 result.push(replacedSelector);
8367 }
8368 } else {
8369 for (j = 0; j < len1; j++) {
8370 parent = parents[j];
8371
8372 if (parent) {
8373 result.push(parent + ' ' + sel);
8374 } else {
8375 result.push(sel);
8376 }
8377 }
8378 }
8379 }
8380
8381 return result.join(',');
8382 };
8383 };
8384
8385 var addon$2 = function addon(renderer) {
8386
8387 renderer.rule = function (css, block) {
8388
8389 block = block || renderer.hash(css);
8390 block = renderer.pfx + block;
8391 renderer.put('.' + block, css);
8392 return ' ' + block;
8393 };
8394 };
8395
8396 var addon$3 = function addon(renderer) {
8397
8398 renderer.sheet = function (map, block) {
8399 var result = {};
8400
8401 if (!block) {
8402 block = renderer.hash(map);
8403 }
8404
8405 var onElementModifier = function onElementModifier(elementModifier) {
8406 var styles = map[elementModifier];
8407
8408 {
8409 Object.defineProperty(result, elementModifier, {
8410 configurable: true,
8411 enumerable: true,
8412 get: function get() {
8413 var classNames = renderer.rule(styles, block + '-' + elementModifier);
8414 Object.defineProperty(result, elementModifier, {
8415 value: classNames,
8416 enumerable: true
8417 });
8418 return classNames;
8419 }
8420 });
8421 }
8422 };
8423
8424 for (var elementModifier in map) {
8425 onElementModifier(elementModifier);
8426 }
8427
8428 return result;
8429 };
8430 };
8431
8432 var nano = create$2({
8433 assign: es6ObjectAssign_1,
8434 h: h,
8435 pfx: ''
8436 });
8437 addon(nano);
8438 addon$1(nano);
8439 addon$2(nano);
8440 addon$3(nano);
8441 var rule = nano.rule,
8442 sheet = nano.sheet;
8443
8444 function buttonStyles(classPrefix, variables, includeStyles) {
8445 if (includeStyles) {
8446 var _button;
8447
8448 return {
8449 button: (_button = {
8450 background: variables.shepherdThemePrimary,
8451 borderRadius: variables.shepherdButtonBorderRadius,
8452 border: 0,
8453 color: variables.shepherdThemeTextPrimary,
8454 cursor: 'pointer',
8455 display: 'inline-block',
8456 fontFamily: 'inherit',
8457 fontSize: '0.8em',
8458 letterSpacing: '0.1em',
8459 lineHeight: '1em',
8460 marginRight: '0.5em',
8461 padding: '0.75em 2em',
8462 textTransform: 'uppercase',
8463 transition: 'all 0.5s ease',
8464 verticalAlign: 'middle',
8465 '&:hover': {
8466 background: curriedDarken(0.1, variables.shepherdThemePrimary)
8467 }
8468 }, _button["&." + classPrefix + "shepherd-button-secondary"] = {
8469 background: variables.shepherdThemeSecondary,
8470 color: variables.shepherdThemeTextSecondary,
8471 '&:hover': {
8472 background: curriedDarken(0.1, variables.shepherdThemeSecondary),
8473 color: curriedDarken(0.1, variables.shepherdThemeTextSecondary)
8474 }
8475 }, _button)
8476 };
8477 }
8478
8479 return {
8480 button: {}
8481 };
8482 }
8483
8484 function contentStyles(variables, includeStyles) {
8485 if (includeStyles) {
8486 return {
8487 content: {
8488 background: variables.shepherdTextBackground,
8489 borderRadius: variables.shepherdElementBorderRadius,
8490 fontSize: 'inherit',
8491 outline: 'none',
8492 padding: 0
8493 }
8494 };
8495 }
8496
8497 return {
8498 content: {}
8499 };
8500 }
8501
8502 function elementStyles() {
8503 return {
8504 element: {
8505 'outline': 'none',
8506 // We need box-sizing: border-box on shepherd-element and everything under it
8507 '&, *': {
8508 '&, &:after, &:before': {
8509 boxSizing: 'border-box'
8510 }
8511 }
8512 }
8513 };
8514 }
8515
8516 function footerStyles(classPrefix, variables, includeStyles) {
8517 if (includeStyles) {
8518 var _footer;
8519
8520 return {
8521 footer: (_footer = {
8522 borderBottomLeftRadius: variables.shepherdElementBorderRadius,
8523 borderBottomRightRadius: variables.shepherdElementBorderRadius,
8524 display: 'flex',
8525 justifyContent: 'flex-end',
8526 padding: '0 0.75em 0.75em'
8527 }, _footer["." + classPrefix + "shepherd-button"] = {
8528 '&:last-child': {
8529 marginRight: 0
8530 }
8531 }, _footer)
8532 };
8533 }
8534
8535 return {
8536 footer: {}
8537 };
8538 }
8539
8540 /**
8541 * Check the luminance of the color and lighten or darken accordingly
8542 * @param {string} color The color to check
8543 * @return {string} The lightened or darkened color
8544 */
8545
8546 function getLighterOrDarker(color) {
8547 var l = getLuminance(color);
8548
8549 if (l > 0.6) {
8550 return curriedDarken(l / 2, color);
8551 }
8552
8553 return curriedLighten((1 - l) / 2, color);
8554 }
8555
8556 function headerStyles(classPrefix, variables, includeStyles) {
8557 var _header, _cancelIcon;
8558
8559 var header = (_header = {
8560 alignItems: 'center',
8561 borderTopLeftRadius: variables.shepherdElementBorderRadius,
8562 borderTopRightRadius: variables.shepherdElementBorderRadius,
8563 display: 'flex',
8564 justifyContent: 'flex-end',
8565 lineHeight: '2em',
8566 padding: '0.75em 0.75em 0'
8567 }, _header["." + classPrefix + "shepherd-has-title ." + classPrefix + "shepherd-content &"] = {
8568 background: variables.shepherdHeaderBackground,
8569 padding: '1em'
8570 }, _header);
8571 var title = {
8572 color: variables.shepherdThemeTextHeader,
8573 display: 'flex',
8574 flex: '1 0 auto',
8575 fontSize: '1.1em',
8576 fontWeight: 'normal',
8577 margin: 0,
8578 padding: 0,
8579 position: 'relative',
8580 verticalAlign: 'middle'
8581 };
8582 var styles = {
8583 'cancel-icon': (_cancelIcon = {
8584 background: 'transparent',
8585 border: 'none',
8586 color: getLighterOrDarker(variables.shepherdThemeTextColor),
8587 fontSize: '2em',
8588 fontWeight: 'normal',
8589 margin: 0,
8590 padding: 0,
8591 position: 'relative',
8592 textDecoration: 'none',
8593 transition: 'color 0.5s ease',
8594 verticalAlign: 'middle',
8595 '&:hover': {
8596 color: variables.shepherdThemeTextColor,
8597 cursor: 'pointer'
8598 }
8599 }, _cancelIcon["." + classPrefix + "shepherd-has-title ." + classPrefix + "shepherd-content &"] = {
8600 color: getLighterOrDarker(variables.shepherdThemeTextHeader),
8601 '&:hover': {
8602 color: variables.shepherdThemeTextHeader
8603 }
8604 }, _cancelIcon)
8605 };
8606
8607 if (includeStyles) {
8608 styles = _extends({}, styles, {
8609 header: header,
8610 title: title
8611 });
8612 } else {
8613 styles = _extends({}, styles, {
8614 header: {},
8615 title: {}
8616 });
8617 }
8618
8619 return styles;
8620 }
8621
8622 function modalStyles(classPrefix, variables) {
8623 var _modalOverlayContai;
8624
8625 return {
8626 'modal-overlay-container': (_modalOverlayContai = {
8627 '-ms-filter': 'progid:dximagetransform.microsoft.gradient.alpha(Opacity=50)',
8628 filter: 'alpha(opacity=35)',
8629 height: 0,
8630 left: 0,
8631 opacity: 0,
8632 overflow: 'hidden',
8633 position: 'fixed',
8634 top: 0,
8635 transition: 'all 0.3s ease-out, height 0ms 0.3s, opacity 0.3s 0ms',
8636 width: '100vw',
8637 zIndex: variables.shepherdElementZIndex - 2
8638 }, _modalOverlayContai["." + classPrefix + "shepherd-modal-is-visible &"] = {
8639 height: '100vh',
8640 opacity: variables.overlayOpacity,
8641 transition: 'all 0.3s ease-out, height 0s 0s, opacity 0.3s 0s'
8642 }, _modalOverlayContai),
8643 'modal-mask-rect': {
8644 height: '100vh',
8645 width: '100vw'
8646 }
8647 };
8648 }
8649
8650 function textStyles(variables, includeStyles) {
8651 if (includeStyles) {
8652 return {
8653 text: {
8654 color: variables.shepherdThemeTextColor,
8655 fontSize: variables.shepherdTextFontSize,
8656 lineHeight: variables.shepherdTextLineHeight,
8657 padding: '0.75em',
8658 p: {
8659 marginTop: 0,
8660 '&:last-child': {
8661 marginBottom: 0
8662 }
8663 }
8664 }
8665 };
8666 }
8667
8668 return {
8669 text: {}
8670 };
8671 }
8672
8673 function generateStyles(options) {
8674 var _ref, _active, _xPlacementTop, _ref2, _xPlacementBott, _xPlacementLeft, _xPlacementRigh, _ref3, _extends2, _rule;
8675
8676 var variables = getVariables(options);
8677 var classPrefix = normalizePrefix(options.classPrefix);
8678 var tippyPrefix = normalizePrefix(options.tippyClassPrefix);
8679 var includeStyles = options.includeStyles;
8680
8681 var styles = _extends({
8682 active: (_active = {}, _active["&." + classPrefix + "shepherd-modal-is-visible"] = (_ref = {}, _ref[":not(." + classPrefix + "shepherd-target)"] = {
8683 pointerEvents: 'none'
8684 }, _ref["." + classPrefix + "shepherd-button, ." + classPrefix + "shepherd-cancel-icon, ." + classPrefix + "shepherd-element, ." + classPrefix + "shepherd-target"] = {
8685 pointerEvents: 'auto',
8686 '*': {
8687 pointerEvents: 'auto'
8688 }
8689 }, _ref), _active)
8690 }, buttonStyles(classPrefix, variables, includeStyles), {}, contentStyles(variables, includeStyles), {}, elementStyles(), {}, footerStyles(classPrefix, variables, includeStyles), {}, headerStyles(classPrefix, variables, includeStyles), {}, modalStyles(classPrefix, variables), {}, textStyles(variables, includeStyles));
8691
8692 if (variables.useDropShadow) {
8693 styles.element.filter = 'drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2))';
8694 }
8695
8696 var classes = sheet(styles, classPrefix + "shepherd");
8697 var arrowMargin = "calc((" + variables.arrowSize + " / 2.1) * 16px)";
8698 var popperThemeArrows = {
8699 '&[x-placement^="top"]': (_xPlacementTop = {
8700 marginBottom: arrowMargin
8701 }, _xPlacementTop["." + tippyPrefix + "tippy-arrow"] = {
8702 borderTopColor: variables.shepherdTextBackground
8703 }, _xPlacementTop),
8704 '&[x-placement^="bottom"]': (_xPlacementBott = {
8705 marginTop: arrowMargin
8706 }, _xPlacementBott["." + tippyPrefix + "tippy-arrow"] = {
8707 borderBottomColor: variables.shepherdTextBackground
8708 }, _xPlacementBott["&." + classPrefix + "shepherd-has-title"] = (_ref2 = {}, _ref2["." + tippyPrefix + "tippy-arrow"] = {
8709 borderBottomColor: variables.shepherdHeaderBackground
8710 }, _ref2), _xPlacementBott),
8711 '&[x-placement^="left"]': (_xPlacementLeft = {
8712 marginRight: arrowMargin
8713 }, _xPlacementLeft["." + tippyPrefix + "tippy-arrow"] = {
8714 borderLeftColor: variables.shepherdTextBackground
8715 }, _xPlacementLeft),
8716 '&[x-placement^="right"]': (_xPlacementRigh = {
8717 marginLeft: arrowMargin
8718 }, _xPlacementRigh["." + tippyPrefix + "tippy-arrow"] = {
8719 borderRightColor: variables.shepherdTextBackground
8720 }, _xPlacementRigh)
8721 }; // We have to add the root shepherd class separately
8722
8723 classes.shepherd = rule((_rule = {}, _rule["&." + tippyPrefix + "tippy-popper"] = _extends({}, popperThemeArrows, (_extends2 = {
8724 zIndex: variables.shepherdElementZIndex
8725 }, _extends2["." + tippyPrefix + "tippy-tooltip"] = (_ref3 = {
8726 backgroundColor: variables.shepherdTextBackground
8727 }, _ref3["." + tippyPrefix + "tippy-arrow"] = {
8728 transform: "scale(" + variables.arrowSize + ")",
8729 zIndex: variables.shepherdElementZIndex + 1
8730 }, _ref3["." + tippyPrefix + "tippy-content"] = {
8731 maxHeight: variables.shepherdElementMaxHeight,
8732 maxWidth: variables.shepherdElementMaxWidth,
8733 padding: 0,
8734 textAlign: 'center'
8735 }, _ref3), _extends2)), _rule), classPrefix + "shepherd");
8736 return classes;
8737 }
8738
8739 var Component$7 = preact.Component;
8740
8741 var ShepherdModal =
8742 /*#__PURE__*/
8743 function (_Component) {
8744 _inheritsLoose(ShepherdModal, _Component);
8745
8746 function ShepherdModal(props) {
8747 var _this;
8748
8749 _this = _Component.call(this, props) || this;
8750 _this._onScreenChange = null;
8751 _this.classPrefix = props.classPrefix;
8752 autoBind(_assertThisInitialized(_this)); // Setup initial state
8753
8754 _this.closeModalOpening();
8755
8756 return _this;
8757 }
8758
8759 var _proto = ShepherdModal.prototype;
8760
8761 _proto.render = function render(props, state) {
8762 var classPrefix = props.classPrefix,
8763 styles = props.styles;
8764 return preact.h("svg", {
8765 className: styles['modal-overlay-container'],
8766 onTouchMove: ShepherdModal.handlePreventModalOverlayTouch
8767 }, preact.h("defs", null, preact.h("mask", {
8768 className: classPrefix + "shepherd-modal-mask",
8769 height: "100%",
8770 id: classPrefix + "shepherd-modal-mask",
8771 width: "100%",
8772 x: "0",
8773 y: "0"
8774 }, preact.h("rect", {
8775 className: styles['modal-mask-rect'],
8776 fill: "#FFFFFF",
8777 height: "100%",
8778 width: "100%",
8779 x: "0",
8780 y: "0"
8781 }), preact.h("rect", {
8782 className: classPrefix + "shepherd-modal-mask-opening",
8783 fill: "#000000",
8784 height: state.openingProperties.height,
8785 x: state.openingProperties.x,
8786 y: state.openingProperties.y,
8787 width: state.openingProperties.width
8788 }))), preact.h("rect", {
8789 height: "100%",
8790 width: "100%",
8791 x: "0",
8792 y: "0",
8793 mask: "url(#" + classPrefix + "shepherd-modal-mask)"
8794 }));
8795 };
8796
8797 _proto.closeModalOpening = function closeModalOpening() {
8798 this.setState({
8799 openingProperties: {
8800 height: 0,
8801 x: 0,
8802 y: 0,
8803 width: 0
8804 }
8805 });
8806 }
8807 /**
8808 * Hide the modal overlay
8809 */
8810 ;
8811
8812 _proto.hide = function hide() {
8813 document.body.classList.remove(this.classPrefix + "shepherd-modal-is-visible"); // Ensure we cleanup all event listeners when we hide the modal
8814
8815 this._cleanupStepEventListeners();
8816 }
8817 /**
8818 * Uses the bounds of the element we want the opening overtop of to set the dimensions of the opening and position it
8819 * @param {HTMLElement} targetElement The element the opening will expose
8820 * @param {Number} modalOverlayOpeningPadding An amount of padding to add around the modal overlay opening
8821 */
8822 ;
8823
8824 _proto.positionModalOpening = function positionModalOpening(targetElement, modalOverlayOpeningPadding) {
8825 if (modalOverlayOpeningPadding === void 0) {
8826 modalOverlayOpeningPadding = 0;
8827 }
8828
8829 if (targetElement.getBoundingClientRect) {
8830 var _targetElement$getBou = targetElement.getBoundingClientRect(),
8831 x = _targetElement$getBou.x,
8832 y = _targetElement$getBou.y,
8833 width = _targetElement$getBou.width,
8834 height = _targetElement$getBou.height,
8835 left = _targetElement$getBou.left,
8836 top = _targetElement$getBou.top; // getBoundingClientRect is not consistent. Some browsers use x and y, while others use left and top
8837
8838
8839 this.setState({
8840 openingProperties: {
8841 x: (x || left) - modalOverlayOpeningPadding,
8842 y: (y || top) - modalOverlayOpeningPadding,
8843 width: width + modalOverlayOpeningPadding * 2,
8844 height: height + modalOverlayOpeningPadding * 2
8845 }
8846 });
8847 }
8848 }
8849 /**
8850 * If modal is enabled, setup the svg mask opening and modal overlay for the step
8851 * @param {Step} step The step instance
8852 */
8853 ;
8854
8855 _proto.setupForStep = function setupForStep(step) {
8856 // Ensure we move listeners from the previous step, before we setup new ones
8857 this._cleanupStepEventListeners();
8858
8859 if (step.tour.options.useModalOverlay) {
8860 this._styleForStep(step);
8861
8862 this.show();
8863 } else {
8864 this.hide();
8865 }
8866 }
8867 /**
8868 * Show the modal overlay
8869 */
8870 ;
8871
8872 _proto.show = function show() {
8873 document.body.classList.add(this.classPrefix + "shepherd-modal-is-visible");
8874 }
8875 /**
8876 * Add touchmove event listener
8877 * @private
8878 */
8879 ;
8880
8881 _proto._addStepEventListeners = function _addStepEventListeners() {
8882 // Prevents window from moving on touch.
8883 window.addEventListener('touchmove', ShepherdModal._preventModalBodyTouch, {
8884 passive: false
8885 });
8886 }
8887 /**
8888 * Cancel the requestAnimationFrame loop and remove touchmove event listeners
8889 * @private
8890 */
8891 ;
8892
8893 _proto._cleanupStepEventListeners = function _cleanupStepEventListeners() {
8894 if (this.rafId) {
8895 cancelAnimationFrame(this.rafId);
8896 this.rafId = undefined;
8897 }
8898
8899 window.removeEventListener('touchmove', ShepherdModal._preventModalBodyTouch, {
8900 passive: false
8901 });
8902 }
8903 /**
8904 * Style the modal for the step
8905 * @param {Step} step The step to style the opening for
8906 * @private
8907 */
8908 ;
8909
8910 _proto._styleForStep = function _styleForStep(step) {
8911 var _this2 = this;
8912
8913 var modalOverlayOpeningPadding = step.options.modalOverlayOpeningPadding;
8914
8915 if (step.target) {
8916 // Setup recursive function to call requestAnimationFrame to update the modal opening position
8917 var rafLoop = function rafLoop() {
8918 _this2.rafId = undefined;
8919
8920 _this2.positionModalOpening(step.target, modalOverlayOpeningPadding);
8921
8922 _this2.rafId = requestAnimationFrame(rafLoop);
8923 };
8924
8925 rafLoop();
8926
8927 this._addStepEventListeners();
8928 } else {
8929 this.closeModalOpening();
8930 }
8931 };
8932
8933 ShepherdModal._preventModalBodyTouch = function _preventModalBodyTouch(e) {
8934 e.preventDefault();
8935 };
8936
8937 ShepherdModal.handlePreventModalOverlayTouch = function handlePreventModalOverlayTouch(e) {
8938 e.stopPropagation();
8939 };
8940
8941 return ShepherdModal;
8942 }(Component$7);
8943
8944 var render$2 = preact.render;
8945 /**
8946 * Creates incremented ID for each newly created tour
8947 *
8948 * @return {Function} A function that returns the unique id for the tour
8949 * @private
8950 */
8951
8952 var uniqueId$1 = function () {
8953 var id = 0;
8954 return function () {
8955 return ++id;
8956 };
8957 }();
8958
8959 var Shepherd = new Evented();
8960 /**
8961 * Class representing the site tour
8962 * @extends {Evented}
8963 */
8964
8965 var Tour =
8966 /*#__PURE__*/
8967 function (_Evented) {
8968 _inheritsLoose(Tour, _Evented);
8969
8970 /**
8971 * @param {Object} options The options for the tour
8972 * @param {boolean} options.confirmCancel If true, will issue a `window.confirm` before cancelling
8973 * @param {string} options.confirmCancelMessage The message to display in the confirm dialog
8974 * @param {string} options.classPrefix The prefix to add to all the `shepherd-*` class names.
8975 * @param {Object} options.defaultStepOptions Default options for Steps ({@link Step#constructor}), created through `addStep`
8976 * @param {boolean} options.disableScroll When set to true, will keep the user from scrolling with the scrollbar,
8977 * mousewheel, arrow keys, etc. You may want to use this to ensure you are driving the scroll position with the tour.
8978 * @param {boolean} options.exitOnEsc Exiting the tour with the escape key will be enabled unless this is explicitly
8979 * set to false.
8980 * @param {boolean} options.includeStyles If false, the majority of the Shepherd styles will not be included.
8981 * You may want to use this option if you find yourself overriding a lot of the Shepherd styles.
8982 * @param {boolean} options.keyboardNavigation Navigating the tour via left and right arrow keys will be enabled
8983 * unless this is explicitly set to false.
8984 * @param {HTMLElement} options.modalContainer An optional container element for the modal.
8985 * If not set, the modal will be appended to `document.body`.
8986 * @param {object[] | Step[]} options.steps An array of step options objects or Step instances to initialize the tour with
8987 * @param {object} options.styleVariables An object hash of style variables to override
8988 * @param {string} options.tourName An optional "name" for the tour. This will be appended to the the tour's
8989 * dynamically generated `id` property -- which is also set on the `body` element as the `data-shepherd-active-tour` attribute
8990 * whenever the tour becomes active.
8991 * @param {boolean} options.useModalOverlay Whether or not steps should be placed above a darkened
8992 * modal overlay. If true, the overlay will create an opening around the target element so that it
8993 * can remain interactive
8994 * @returns {Tour}
8995 */
8996 function Tour(options) {
8997 var _this;
8998
8999 if (options === void 0) {
9000 options = {};
9001 }
9002
9003 _this = _Evented.call(this, options) || this;
9004 autoBind(_assertThisInitialized(_this));
9005 var defaultTourOptions = {
9006 exitOnEsc: true,
9007 includeStyles: true,
9008 keyboardNavigation: true
9009 };
9010 _this.options = _extends({}, defaultTourOptions, options);
9011 _this.classPrefix = _this.options ? normalizePrefix(_this.options.classPrefix) : '';
9012 _this.styles = generateStyles(_this.options);
9013 _this.steps = [];
9014
9015 _this.addSteps(_this.options.steps); // Pass these events onto the global Shepherd object
9016
9017
9018 var events = ['active', 'cancel', 'complete', 'inactive', 'show', 'start'];
9019 events.map(function (event) {
9020 (function (e) {
9021 _this.on(e, function (opts) {
9022 opts = opts || {};
9023 opts.tour = _assertThisInitialized(_this);
9024 Shepherd.trigger(e, opts);
9025 });
9026 })(event);
9027 });
9028 var existingModal = document.querySelector("." + _this.classPrefix + "shepherd-modal-overlay-container");
9029 render$2(preact.h(ShepherdModal, {
9030 classPrefix: _this.classPrefix,
9031 ref: function ref(c) {
9032 return _this.modal = c;
9033 },
9034 styles: _this.styles
9035 }), options.modalContainer || document.body, existingModal);
9036
9037 _this._setTooltipDefaults();
9038
9039 _this._setTourID();
9040
9041 return _assertThisInitialized(_this) || _assertThisInitialized(_this);
9042 }
9043 /**
9044 * Adds a new step to the tour
9045 * @param {Object|Step} options An object containing step options or a Step instance
9046 * @return {Step} The newly added step
9047 */
9048
9049
9050 var _proto = Tour.prototype;
9051
9052 _proto.addStep = function addStep(options) {
9053 var step = options;
9054
9055 if (!(step instanceof Step)) {
9056 step = this._setupStep(step);
9057 } else {
9058 step.tour = this;
9059 }
9060
9061 this.steps.push(step);
9062 return step;
9063 }
9064 /**
9065 * Add multiple steps to the tour
9066 * @param {Array<object> | Array<Step>} steps The steps to add to the tour
9067 */
9068 ;
9069
9070 _proto.addSteps = function addSteps(steps) {
9071 var _this2 = this;
9072
9073 if (Array.isArray(steps)) {
9074 steps.forEach(function (step) {
9075 _this2.addStep(step);
9076 });
9077 }
9078
9079 return this;
9080 }
9081 /**
9082 * Go to the previous step in the tour
9083 */
9084 ;
9085
9086 _proto.back = function back() {
9087 var index = this.steps.indexOf(this.currentStep);
9088 this.show(index - 1, false);
9089 }
9090 /**
9091 * Calls _done() triggering the 'cancel' event
9092 * If `confirmCancel` is true, will show a window.confirm before cancelling
9093 */
9094 ;
9095
9096 _proto.cancel = function cancel() {
9097 if (this.options.confirmCancel) {
9098 var cancelMessage = this.options.confirmCancelMessage || 'Are you sure you want to stop the tour?';
9099 var stopTour = window.confirm(cancelMessage);
9100
9101 if (stopTour) {
9102 this._done('cancel');
9103 }
9104 } else {
9105 this._done('cancel');
9106 }
9107 }
9108 /**
9109 * Calls _done() triggering the `complete` event
9110 */
9111 ;
9112
9113 _proto.complete = function complete() {
9114 this._done('complete');
9115 }
9116 /**
9117 * Gets the step from a given id
9118 * @param {Number|String} id The id of the step to retrieve
9119 * @return {Step} The step corresponding to the `id`
9120 */
9121 ;
9122
9123 _proto.getById = function getById(id) {
9124 return this.steps.find(function (step) {
9125 return step.id === id;
9126 });
9127 }
9128 /**
9129 * Gets the current step
9130 * @returns {Step|null}
9131 */
9132 ;
9133
9134 _proto.getCurrentStep = function getCurrentStep() {
9135 return this.currentStep;
9136 }
9137 /**
9138 * Hide the current step
9139 */
9140 ;
9141
9142 _proto.hide = function hide() {
9143 var currentStep = this.getCurrentStep();
9144
9145 if (currentStep) {
9146 return currentStep.hide();
9147 }
9148 }
9149 /**
9150 * Check if the tour is active
9151 * @return {boolean}
9152 */
9153 ;
9154
9155 _proto.isActive = function isActive() {
9156 return Shepherd.activeTour === this;
9157 }
9158 /**
9159 * Go to the next step in the tour
9160 * If we are at the end, call `complete`
9161 */
9162 ;
9163
9164 _proto.next = function next() {
9165 var index = this.steps.indexOf(this.currentStep);
9166
9167 if (index === this.steps.length - 1) {
9168 this.complete();
9169 } else {
9170 this.show(index + 1, true);
9171 }
9172 }
9173 /**
9174 * Removes the step from the tour
9175 * @param {String} name The id for the step to remove
9176 */
9177 ;
9178
9179 _proto.removeStep = function removeStep(name) {
9180 var _this3 = this;
9181
9182 var current = this.getCurrentStep(); // Find the step, destroy it and remove it from this.steps
9183
9184 this.steps.some(function (step, i) {
9185 if (step.id === name) {
9186 if (step.isOpen()) {
9187 step.hide();
9188 }
9189
9190 step.destroy();
9191
9192 _this3.steps.splice(i, 1);
9193
9194 return true;
9195 }
9196 });
9197
9198 if (current && current.id === name) {
9199 this.currentStep = undefined; // If we have steps left, show the first one, otherwise just cancel the tour
9200
9201 this.steps.length ? this.show(0) : this.cancel();
9202 }
9203 }
9204 /**
9205 * Show a specific step in the tour
9206 * @param {Number|String} key The key to look up the step by
9207 * @param {Boolean} forward True if we are going forward, false if backward
9208 */
9209 ;
9210
9211 _proto.show = function show(key, forward) {
9212 if (key === void 0) {
9213 key = 0;
9214 }
9215
9216 if (forward === void 0) {
9217 forward = true;
9218 }
9219
9220 var step = isString(key) ? this.getById(key) : this.steps[key];
9221
9222 if (step) {
9223 this._updateStateBeforeShow();
9224
9225 var shouldSkipStep = isFunction(step.options.showOn) && !step.options.showOn(); // If `showOn` returns false, we want to skip the step, otherwise, show the step like normal
9226
9227 if (shouldSkipStep) {
9228 this._skipStep(step, forward);
9229 } else {
9230 this.trigger('show', {
9231 step: step,
9232 previous: this.currentStep
9233 });
9234 this.currentStep = step;
9235 step.show();
9236 }
9237 }
9238 }
9239 /**
9240 * Start the tour
9241 */
9242 ;
9243
9244 _proto.start = function start() {
9245 this.trigger('start');
9246
9247 if (this.options.disableScroll) {
9248 bodyScrollLock.disableBodyScroll();
9249 } // Save the focused element before the tour opens
9250
9251
9252 this.focusedElBeforeOpen = document.activeElement;
9253 this.currentStep = null;
9254
9255 this._setupActiveTour();
9256
9257 this.next();
9258 }
9259 /**
9260 * Called whenever the tour is cancelled or completed, basically anytime we exit the tour
9261 * @param {String} event The event name to trigger
9262 * @private
9263 */
9264 ;
9265
9266 _proto._done = function _done(event) {
9267 var index = this.steps.indexOf(this.currentStep);
9268
9269 if (Array.isArray(this.steps)) {
9270 this.steps.forEach(function (step) {
9271 return step.destroy();
9272 });
9273 }
9274
9275 cleanupSteps(this);
9276 this.trigger(event, {
9277 index: index
9278 });
9279 Shepherd.activeTour = null;
9280
9281 this._removeBodyAttrs();
9282
9283 this.trigger('inactive', {
9284 tour: this
9285 });
9286
9287 if (this.options.disableScroll) {
9288 bodyScrollLock.clearAllBodyScrollLocks();
9289 }
9290
9291 this.modal.hide(); // Focus the element that was focused before the tour started
9292
9293 if (isElement(this.focusedElBeforeOpen)) {
9294 this.focusedElBeforeOpen.focus();
9295 }
9296 }
9297 /**
9298 * Make this tour "active"
9299 * @private
9300 */
9301 ;
9302
9303 _proto._setupActiveTour = function _setupActiveTour() {
9304 this._addBodyAttrs();
9305
9306 this.trigger('active', {
9307 tour: this
9308 });
9309 Shepherd.activeTour = this;
9310 }
9311 /**
9312 * Setup a new step object
9313 * @param {Object} stepOptions The object describing the options for the step
9314 * @return {Step} The step instance
9315 * @private
9316 */
9317 ;
9318
9319 _proto._setupStep = function _setupStep(stepOptions) {
9320 stepOptions = _extends({}, this.options.defaultStepOptions, stepOptions);
9321 return new Step(this, stepOptions);
9322 }
9323 /**
9324 * Called when `showOn` evaluates to false, to skip the step
9325 * @param {Step} step The step to skip
9326 * @param {Boolean} forward True if we are going forward, false if backward
9327 * @private
9328 */
9329 ;
9330
9331 _proto._skipStep = function _skipStep(step, forward) {
9332 var index = this.steps.indexOf(step);
9333 var nextIndex = forward ? index + 1 : index - 1;
9334 this.show(nextIndex, forward);
9335 }
9336 /**
9337 * Set the tippy defaults
9338 * @private
9339 */
9340 ;
9341
9342 _proto._setTooltipDefaults = function _setTooltipDefaults() {
9343 tippy.setDefaultProps(defaults);
9344 }
9345 /**
9346 * Before showing, hide the current step and if the tour is not
9347 * already active, call `this._setupActiveTour`.
9348 * @private
9349 */
9350 ;
9351
9352 _proto._updateStateBeforeShow = function _updateStateBeforeShow() {
9353 if (this.currentStep) {
9354 this.currentStep.hide();
9355 }
9356
9357 if (!this.isActive()) {
9358 this._setupActiveTour();
9359 }
9360 }
9361 /**
9362 * Sets this.id to `${tourName}--${uuid}`
9363 * @private
9364 */
9365 ;
9366
9367 _proto._setTourID = function _setTourID() {
9368 var tourName = this.options.tourName || 'tour';
9369 var uuid = uniqueId$1();
9370 this.id = tourName + "--" + uuid;
9371 }
9372 /**
9373 * Adds the data-shepherd-active-tour attribute and the 'shepherd-active'
9374 * class to the body.
9375 * @private
9376 */
9377 ;
9378
9379 _proto._addBodyAttrs = function _addBodyAttrs() {
9380 document.body.setAttribute("data-" + this.classPrefix + "shepherd-active-tour", this.id);
9381 document.body.classList.add(this.styles.active.trim());
9382 }
9383 /**
9384 * Removes the data-shepherd-active-tour attribute and the 'shepherd-active'
9385 * class from the body.
9386 * @private
9387 */
9388 ;
9389
9390 _proto._removeBodyAttrs = function _removeBodyAttrs() {
9391 document.body.removeAttribute("data-" + this.classPrefix + "shepherd-active-tour");
9392 document.body.classList.remove(this.styles.active.trim());
9393 };
9394
9395 return Tour;
9396 }(Evented);
9397
9398 _extends(Shepherd, {
9399 Tour: Tour,
9400 Step: Step
9401 });
9402
9403 return Shepherd;
9404
9405 }));
9406 //# sourceMappingURL=shepherd.js.map
9407