UNPKG

254 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactBootstrapTypeahead = {}, global.React, global.ReactDOM));
5})(this, (function (exports, React, ReactDOM) { 'use strict';
6
7 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9 function _interopNamespace(e) {
10 if (e && e.__esModule) return e;
11 var n = Object.create(null);
12 if (e) {
13 Object.keys(e).forEach(function (k) {
14 if (k !== 'default') {
15 var d = Object.getOwnPropertyDescriptor(e, k);
16 Object.defineProperty(n, k, d.get ? d : {
17 enumerable: true,
18 get: function () { return e[k]; }
19 });
20 }
21 });
22 }
23 n["default"] = e;
24 return Object.freeze(n);
25 }
26
27 var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28 var React__namespace = /*#__PURE__*/_interopNamespace(React);
29 var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
30
31 function ownKeys(object, enumerableOnly) {
32 var keys = Object.keys(object);
33
34 if (Object.getOwnPropertySymbols) {
35 var symbols = Object.getOwnPropertySymbols(object);
36 enumerableOnly && (symbols = symbols.filter(function (sym) {
37 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
38 })), keys.push.apply(keys, symbols);
39 }
40
41 return keys;
42 }
43
44 function _objectSpread2(target) {
45 for (var i = 1; i < arguments.length; i++) {
46 var source = null != arguments[i] ? arguments[i] : {};
47 i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
48 _defineProperty(target, key, source[key]);
49 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
50 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
51 });
52 }
53
54 return target;
55 }
56
57 function _classCallCheck(instance, Constructor) {
58 if (!(instance instanceof Constructor)) {
59 throw new TypeError("Cannot call a class as a function");
60 }
61 }
62
63 function _defineProperties(target, props) {
64 for (var i = 0; i < props.length; i++) {
65 var descriptor = props[i];
66 descriptor.enumerable = descriptor.enumerable || false;
67 descriptor.configurable = true;
68 if ("value" in descriptor) descriptor.writable = true;
69 Object.defineProperty(target, descriptor.key, descriptor);
70 }
71 }
72
73 function _createClass(Constructor, protoProps, staticProps) {
74 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
75 if (staticProps) _defineProperties(Constructor, staticProps);
76 Object.defineProperty(Constructor, "prototype", {
77 writable: false
78 });
79 return Constructor;
80 }
81
82 function _defineProperty(obj, key, value) {
83 if (key in obj) {
84 Object.defineProperty(obj, key, {
85 value: value,
86 enumerable: true,
87 configurable: true,
88 writable: true
89 });
90 } else {
91 obj[key] = value;
92 }
93
94 return obj;
95 }
96
97 function _extends() {
98 _extends = Object.assign || function (target) {
99 for (var i = 1; i < arguments.length; i++) {
100 var source = arguments[i];
101
102 for (var key in source) {
103 if (Object.prototype.hasOwnProperty.call(source, key)) {
104 target[key] = source[key];
105 }
106 }
107 }
108
109 return target;
110 };
111
112 return _extends.apply(this, arguments);
113 }
114
115 function _inherits(subClass, superClass) {
116 if (typeof superClass !== "function" && superClass !== null) {
117 throw new TypeError("Super expression must either be null or a function");
118 }
119
120 subClass.prototype = Object.create(superClass && superClass.prototype, {
121 constructor: {
122 value: subClass,
123 writable: true,
124 configurable: true
125 }
126 });
127 Object.defineProperty(subClass, "prototype", {
128 writable: false
129 });
130 if (superClass) _setPrototypeOf(subClass, superClass);
131 }
132
133 function _getPrototypeOf(o) {
134 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
135 return o.__proto__ || Object.getPrototypeOf(o);
136 };
137 return _getPrototypeOf(o);
138 }
139
140 function _setPrototypeOf(o, p) {
141 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
142 o.__proto__ = p;
143 return o;
144 };
145
146 return _setPrototypeOf(o, p);
147 }
148
149 function _isNativeReflectConstruct() {
150 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
151 if (Reflect.construct.sham) return false;
152 if (typeof Proxy === "function") return true;
153
154 try {
155 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
156 return true;
157 } catch (e) {
158 return false;
159 }
160 }
161
162 function _objectWithoutPropertiesLoose(source, excluded) {
163 if (source == null) return {};
164 var target = {};
165 var sourceKeys = Object.keys(source);
166 var key, i;
167
168 for (i = 0; i < sourceKeys.length; i++) {
169 key = sourceKeys[i];
170 if (excluded.indexOf(key) >= 0) continue;
171 target[key] = source[key];
172 }
173
174 return target;
175 }
176
177 function _objectWithoutProperties(source, excluded) {
178 if (source == null) return {};
179
180 var target = _objectWithoutPropertiesLoose(source, excluded);
181
182 var key, i;
183
184 if (Object.getOwnPropertySymbols) {
185 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
186
187 for (i = 0; i < sourceSymbolKeys.length; i++) {
188 key = sourceSymbolKeys[i];
189 if (excluded.indexOf(key) >= 0) continue;
190 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
191 target[key] = source[key];
192 }
193 }
194
195 return target;
196 }
197
198 function _assertThisInitialized(self) {
199 if (self === void 0) {
200 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
201 }
202
203 return self;
204 }
205
206 function _possibleConstructorReturn(self, call) {
207 if (call && (typeof call === "object" || typeof call === "function")) {
208 return call;
209 } else if (call !== void 0) {
210 throw new TypeError("Derived constructors may only return object or undefined");
211 }
212
213 return _assertThisInitialized(self);
214 }
215
216 function _createSuper(Derived) {
217 var hasNativeReflectConstruct = _isNativeReflectConstruct();
218
219 return function _createSuperInternal() {
220 var Super = _getPrototypeOf(Derived),
221 result;
222
223 if (hasNativeReflectConstruct) {
224 var NewTarget = _getPrototypeOf(this).constructor;
225
226 result = Reflect.construct(Super, arguments, NewTarget);
227 } else {
228 result = Super.apply(this, arguments);
229 }
230
231 return _possibleConstructorReturn(this, result);
232 };
233 }
234
235 function _slicedToArray(arr, i) {
236 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
237 }
238
239 function _arrayWithHoles(arr) {
240 if (Array.isArray(arr)) return arr;
241 }
242
243 function _iterableToArrayLimit(arr, i) {
244 var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
245
246 if (_i == null) return;
247 var _arr = [];
248 var _n = true;
249 var _d = false;
250
251 var _s, _e;
252
253 try {
254 for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
255 _arr.push(_s.value);
256
257 if (i && _arr.length === i) break;
258 }
259 } catch (err) {
260 _d = true;
261 _e = err;
262 } finally {
263 try {
264 if (!_n && _i["return"] != null) _i["return"]();
265 } finally {
266 if (_d) throw _e;
267 }
268 }
269
270 return _arr;
271 }
272
273 function _unsupportedIterableToArray(o, minLen) {
274 if (!o) return;
275 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
276 var n = Object.prototype.toString.call(o).slice(8, -1);
277 if (n === "Object" && o.constructor) n = o.constructor.name;
278 if (n === "Map" || n === "Set") return Array.from(o);
279 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
280 }
281
282 function _arrayLikeToArray(arr, len) {
283 if (len == null || len > arr.length) len = arr.length;
284
285 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
286
287 return arr2;
288 }
289
290 function _nonIterableRest() {
291 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
292 }
293
294 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
295
296 /**
297 * lodash (Custom Build) <https://lodash.com/>
298 * Build: `lodash modularize exports="npm" -o ./`
299 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
300 * Released under MIT license <https://lodash.com/license>
301 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
302 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
303 */
304
305 /** Used as the `TypeError` message for "Functions" methods. */
306 var FUNC_ERROR_TEXT = 'Expected a function';
307
308 /** Used as references for various `Number` constants. */
309 var NAN = 0 / 0;
310
311 /** `Object#toString` result references. */
312 var symbolTag = '[object Symbol]';
313
314 /** Used to match leading and trailing whitespace. */
315 var reTrim = /^\s+|\s+$/g;
316
317 /** Used to detect bad signed hexadecimal string values. */
318 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
319
320 /** Used to detect binary string values. */
321 var reIsBinary = /^0b[01]+$/i;
322
323 /** Used to detect octal string values. */
324 var reIsOctal = /^0o[0-7]+$/i;
325
326 /** Built-in method references without a dependency on `root`. */
327 var freeParseInt = parseInt;
328
329 /** Detect free variable `global` from Node.js. */
330 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
331
332 /** Detect free variable `self`. */
333 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
334
335 /** Used as a reference to the global object. */
336 var root = freeGlobal || freeSelf || Function('return this')();
337
338 /** Used for built-in method references. */
339 var objectProto = Object.prototype;
340
341 /**
342 * Used to resolve the
343 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
344 * of values.
345 */
346 var objectToString = objectProto.toString;
347
348 /* Built-in method references for those with the same name as other `lodash` methods. */
349 var nativeMax = Math.max,
350 nativeMin = Math.min;
351
352 /**
353 * Gets the timestamp of the number of milliseconds that have elapsed since
354 * the Unix epoch (1 January 1970 00:00:00 UTC).
355 *
356 * @static
357 * @memberOf _
358 * @since 2.4.0
359 * @category Date
360 * @returns {number} Returns the timestamp.
361 * @example
362 *
363 * _.defer(function(stamp) {
364 * console.log(_.now() - stamp);
365 * }, _.now());
366 * // => Logs the number of milliseconds it took for the deferred invocation.
367 */
368 var now = function() {
369 return root.Date.now();
370 };
371
372 /**
373 * Creates a debounced function that delays invoking `func` until after `wait`
374 * milliseconds have elapsed since the last time the debounced function was
375 * invoked. The debounced function comes with a `cancel` method to cancel
376 * delayed `func` invocations and a `flush` method to immediately invoke them.
377 * Provide `options` to indicate whether `func` should be invoked on the
378 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
379 * with the last arguments provided to the debounced function. Subsequent
380 * calls to the debounced function return the result of the last `func`
381 * invocation.
382 *
383 * **Note:** If `leading` and `trailing` options are `true`, `func` is
384 * invoked on the trailing edge of the timeout only if the debounced function
385 * is invoked more than once during the `wait` timeout.
386 *
387 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
388 * until to the next tick, similar to `setTimeout` with a timeout of `0`.
389 *
390 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
391 * for details over the differences between `_.debounce` and `_.throttle`.
392 *
393 * @static
394 * @memberOf _
395 * @since 0.1.0
396 * @category Function
397 * @param {Function} func The function to debounce.
398 * @param {number} [wait=0] The number of milliseconds to delay.
399 * @param {Object} [options={}] The options object.
400 * @param {boolean} [options.leading=false]
401 * Specify invoking on the leading edge of the timeout.
402 * @param {number} [options.maxWait]
403 * The maximum time `func` is allowed to be delayed before it's invoked.
404 * @param {boolean} [options.trailing=true]
405 * Specify invoking on the trailing edge of the timeout.
406 * @returns {Function} Returns the new debounced function.
407 * @example
408 *
409 * // Avoid costly calculations while the window size is in flux.
410 * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
411 *
412 * // Invoke `sendMail` when clicked, debouncing subsequent calls.
413 * jQuery(element).on('click', _.debounce(sendMail, 300, {
414 * 'leading': true,
415 * 'trailing': false
416 * }));
417 *
418 * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
419 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
420 * var source = new EventSource('/stream');
421 * jQuery(source).on('message', debounced);
422 *
423 * // Cancel the trailing debounced invocation.
424 * jQuery(window).on('popstate', debounced.cancel);
425 */
426 function debounce$1(func, wait, options) {
427 var lastArgs,
428 lastThis,
429 maxWait,
430 result,
431 timerId,
432 lastCallTime,
433 lastInvokeTime = 0,
434 leading = false,
435 maxing = false,
436 trailing = true;
437
438 if (typeof func != 'function') {
439 throw new TypeError(FUNC_ERROR_TEXT);
440 }
441 wait = toNumber(wait) || 0;
442 if (isObject(options)) {
443 leading = !!options.leading;
444 maxing = 'maxWait' in options;
445 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
446 trailing = 'trailing' in options ? !!options.trailing : trailing;
447 }
448
449 function invokeFunc(time) {
450 var args = lastArgs,
451 thisArg = lastThis;
452
453 lastArgs = lastThis = undefined;
454 lastInvokeTime = time;
455 result = func.apply(thisArg, args);
456 return result;
457 }
458
459 function leadingEdge(time) {
460 // Reset any `maxWait` timer.
461 lastInvokeTime = time;
462 // Start the timer for the trailing edge.
463 timerId = setTimeout(timerExpired, wait);
464 // Invoke the leading edge.
465 return leading ? invokeFunc(time) : result;
466 }
467
468 function remainingWait(time) {
469 var timeSinceLastCall = time - lastCallTime,
470 timeSinceLastInvoke = time - lastInvokeTime,
471 result = wait - timeSinceLastCall;
472
473 return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
474 }
475
476 function shouldInvoke(time) {
477 var timeSinceLastCall = time - lastCallTime,
478 timeSinceLastInvoke = time - lastInvokeTime;
479
480 // Either this is the first call, activity has stopped and we're at the
481 // trailing edge, the system time has gone backwards and we're treating
482 // it as the trailing edge, or we've hit the `maxWait` limit.
483 return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
484 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
485 }
486
487 function timerExpired() {
488 var time = now();
489 if (shouldInvoke(time)) {
490 return trailingEdge(time);
491 }
492 // Restart the timer.
493 timerId = setTimeout(timerExpired, remainingWait(time));
494 }
495
496 function trailingEdge(time) {
497 timerId = undefined;
498
499 // Only invoke if we have `lastArgs` which means `func` has been
500 // debounced at least once.
501 if (trailing && lastArgs) {
502 return invokeFunc(time);
503 }
504 lastArgs = lastThis = undefined;
505 return result;
506 }
507
508 function cancel() {
509 if (timerId !== undefined) {
510 clearTimeout(timerId);
511 }
512 lastInvokeTime = 0;
513 lastArgs = lastCallTime = lastThis = timerId = undefined;
514 }
515
516 function flush() {
517 return timerId === undefined ? result : trailingEdge(now());
518 }
519
520 function debounced() {
521 var time = now(),
522 isInvoking = shouldInvoke(time);
523
524 lastArgs = arguments;
525 lastThis = this;
526 lastCallTime = time;
527
528 if (isInvoking) {
529 if (timerId === undefined) {
530 return leadingEdge(lastCallTime);
531 }
532 if (maxing) {
533 // Handle invocations in a tight loop.
534 timerId = setTimeout(timerExpired, wait);
535 return invokeFunc(lastCallTime);
536 }
537 }
538 if (timerId === undefined) {
539 timerId = setTimeout(timerExpired, wait);
540 }
541 return result;
542 }
543 debounced.cancel = cancel;
544 debounced.flush = flush;
545 return debounced;
546 }
547
548 /**
549 * Checks if `value` is the
550 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
551 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
552 *
553 * @static
554 * @memberOf _
555 * @since 0.1.0
556 * @category Lang
557 * @param {*} value The value to check.
558 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
559 * @example
560 *
561 * _.isObject({});
562 * // => true
563 *
564 * _.isObject([1, 2, 3]);
565 * // => true
566 *
567 * _.isObject(_.noop);
568 * // => true
569 *
570 * _.isObject(null);
571 * // => false
572 */
573 function isObject(value) {
574 var type = typeof value;
575 return !!value && (type == 'object' || type == 'function');
576 }
577
578 /**
579 * Checks if `value` is object-like. A value is object-like if it's not `null`
580 * and has a `typeof` result of "object".
581 *
582 * @static
583 * @memberOf _
584 * @since 4.0.0
585 * @category Lang
586 * @param {*} value The value to check.
587 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
588 * @example
589 *
590 * _.isObjectLike({});
591 * // => true
592 *
593 * _.isObjectLike([1, 2, 3]);
594 * // => true
595 *
596 * _.isObjectLike(_.noop);
597 * // => false
598 *
599 * _.isObjectLike(null);
600 * // => false
601 */
602 function isObjectLike(value) {
603 return !!value && typeof value == 'object';
604 }
605
606 /**
607 * Checks if `value` is classified as a `Symbol` primitive or object.
608 *
609 * @static
610 * @memberOf _
611 * @since 4.0.0
612 * @category Lang
613 * @param {*} value The value to check.
614 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
615 * @example
616 *
617 * _.isSymbol(Symbol.iterator);
618 * // => true
619 *
620 * _.isSymbol('abc');
621 * // => false
622 */
623 function isSymbol(value) {
624 return typeof value == 'symbol' ||
625 (isObjectLike(value) && objectToString.call(value) == symbolTag);
626 }
627
628 /**
629 * Converts `value` to a number.
630 *
631 * @static
632 * @memberOf _
633 * @since 4.0.0
634 * @category Lang
635 * @param {*} value The value to process.
636 * @returns {number} Returns the number.
637 * @example
638 *
639 * _.toNumber(3.2);
640 * // => 3.2
641 *
642 * _.toNumber(Number.MIN_VALUE);
643 * // => 5e-324
644 *
645 * _.toNumber(Infinity);
646 * // => Infinity
647 *
648 * _.toNumber('3.2');
649 * // => 3.2
650 */
651 function toNumber(value) {
652 if (typeof value == 'number') {
653 return value;
654 }
655 if (isSymbol(value)) {
656 return NAN;
657 }
658 if (isObject(value)) {
659 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
660 value = isObject(other) ? (other + '') : other;
661 }
662 if (typeof value != 'string') {
663 return value === 0 ? value : +value;
664 }
665 value = value.replace(reTrim, '');
666 var isBinary = reIsBinary.test(value);
667 return (isBinary || reIsOctal.test(value))
668 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
669 : (reIsBadHex.test(value) ? NAN : +value);
670 }
671
672 var lodash_debounce = debounce$1;
673
674 var propTypes$b = {exports: {}};
675
676 var reactIs = {exports: {}};
677
678 var reactIs_development = {};
679
680 /** @license React v16.13.1
681 * react-is.development.js
682 *
683 * Copyright (c) Facebook, Inc. and its affiliates.
684 *
685 * This source code is licensed under the MIT license found in the
686 * LICENSE file in the root directory of this source tree.
687 */
688
689 var hasRequiredReactIs_development;
690
691 function requireReactIs_development () {
692 if (hasRequiredReactIs_development) return reactIs_development;
693 hasRequiredReactIs_development = 1;
694
695
696
697 {
698 (function() {
699
700 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
701 // nor polyfill, then a plain number is used for performance.
702 var hasSymbol = typeof Symbol === 'function' && Symbol.for;
703 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
704 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
705 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
706 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
707 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
708 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
709 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
710 // (unstable) APIs that have been removed. Can we remove the symbols?
711
712 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
713 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
714 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
715 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
716 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
717 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
718 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
719 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
720 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
721 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
722 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
723
724 function isValidElementType(type) {
725 return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
726 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
727 }
728
729 function typeOf(object) {
730 if (typeof object === 'object' && object !== null) {
731 var $$typeof = object.$$typeof;
732
733 switch ($$typeof) {
734 case REACT_ELEMENT_TYPE:
735 var type = object.type;
736
737 switch (type) {
738 case REACT_ASYNC_MODE_TYPE:
739 case REACT_CONCURRENT_MODE_TYPE:
740 case REACT_FRAGMENT_TYPE:
741 case REACT_PROFILER_TYPE:
742 case REACT_STRICT_MODE_TYPE:
743 case REACT_SUSPENSE_TYPE:
744 return type;
745
746 default:
747 var $$typeofType = type && type.$$typeof;
748
749 switch ($$typeofType) {
750 case REACT_CONTEXT_TYPE:
751 case REACT_FORWARD_REF_TYPE:
752 case REACT_LAZY_TYPE:
753 case REACT_MEMO_TYPE:
754 case REACT_PROVIDER_TYPE:
755 return $$typeofType;
756
757 default:
758 return $$typeof;
759 }
760
761 }
762
763 case REACT_PORTAL_TYPE:
764 return $$typeof;
765 }
766 }
767
768 return undefined;
769 } // AsyncMode is deprecated along with isAsyncMode
770
771 var AsyncMode = REACT_ASYNC_MODE_TYPE;
772 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
773 var ContextConsumer = REACT_CONTEXT_TYPE;
774 var ContextProvider = REACT_PROVIDER_TYPE;
775 var Element = REACT_ELEMENT_TYPE;
776 var ForwardRef = REACT_FORWARD_REF_TYPE;
777 var Fragment = REACT_FRAGMENT_TYPE;
778 var Lazy = REACT_LAZY_TYPE;
779 var Memo = REACT_MEMO_TYPE;
780 var Portal = REACT_PORTAL_TYPE;
781 var Profiler = REACT_PROFILER_TYPE;
782 var StrictMode = REACT_STRICT_MODE_TYPE;
783 var Suspense = REACT_SUSPENSE_TYPE;
784 var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
785
786 function isAsyncMode(object) {
787 {
788 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
789 hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
790
791 console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
792 }
793 }
794
795 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
796 }
797 function isConcurrentMode(object) {
798 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
799 }
800 function isContextConsumer(object) {
801 return typeOf(object) === REACT_CONTEXT_TYPE;
802 }
803 function isContextProvider(object) {
804 return typeOf(object) === REACT_PROVIDER_TYPE;
805 }
806 function isElement(object) {
807 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
808 }
809 function isForwardRef(object) {
810 return typeOf(object) === REACT_FORWARD_REF_TYPE;
811 }
812 function isFragment(object) {
813 return typeOf(object) === REACT_FRAGMENT_TYPE;
814 }
815 function isLazy(object) {
816 return typeOf(object) === REACT_LAZY_TYPE;
817 }
818 function isMemo(object) {
819 return typeOf(object) === REACT_MEMO_TYPE;
820 }
821 function isPortal(object) {
822 return typeOf(object) === REACT_PORTAL_TYPE;
823 }
824 function isProfiler(object) {
825 return typeOf(object) === REACT_PROFILER_TYPE;
826 }
827 function isStrictMode(object) {
828 return typeOf(object) === REACT_STRICT_MODE_TYPE;
829 }
830 function isSuspense(object) {
831 return typeOf(object) === REACT_SUSPENSE_TYPE;
832 }
833
834 reactIs_development.AsyncMode = AsyncMode;
835 reactIs_development.ConcurrentMode = ConcurrentMode;
836 reactIs_development.ContextConsumer = ContextConsumer;
837 reactIs_development.ContextProvider = ContextProvider;
838 reactIs_development.Element = Element;
839 reactIs_development.ForwardRef = ForwardRef;
840 reactIs_development.Fragment = Fragment;
841 reactIs_development.Lazy = Lazy;
842 reactIs_development.Memo = Memo;
843 reactIs_development.Portal = Portal;
844 reactIs_development.Profiler = Profiler;
845 reactIs_development.StrictMode = StrictMode;
846 reactIs_development.Suspense = Suspense;
847 reactIs_development.isAsyncMode = isAsyncMode;
848 reactIs_development.isConcurrentMode = isConcurrentMode;
849 reactIs_development.isContextConsumer = isContextConsumer;
850 reactIs_development.isContextProvider = isContextProvider;
851 reactIs_development.isElement = isElement;
852 reactIs_development.isForwardRef = isForwardRef;
853 reactIs_development.isFragment = isFragment;
854 reactIs_development.isLazy = isLazy;
855 reactIs_development.isMemo = isMemo;
856 reactIs_development.isPortal = isPortal;
857 reactIs_development.isProfiler = isProfiler;
858 reactIs_development.isStrictMode = isStrictMode;
859 reactIs_development.isSuspense = isSuspense;
860 reactIs_development.isValidElementType = isValidElementType;
861 reactIs_development.typeOf = typeOf;
862 })();
863 }
864 return reactIs_development;
865 }
866
867 var hasRequiredReactIs;
868
869 function requireReactIs () {
870 if (hasRequiredReactIs) return reactIs.exports;
871 hasRequiredReactIs = 1;
872 (function (module) {
873
874 {
875 module.exports = requireReactIs_development();
876 }
877 } (reactIs));
878 return reactIs.exports;
879 }
880
881 /*
882 object-assign
883 (c) Sindre Sorhus
884 @license MIT
885 */
886
887 var objectAssign;
888 var hasRequiredObjectAssign;
889
890 function requireObjectAssign () {
891 if (hasRequiredObjectAssign) return objectAssign;
892 hasRequiredObjectAssign = 1;
893 /* eslint-disable no-unused-vars */
894 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
895 var hasOwnProperty = Object.prototype.hasOwnProperty;
896 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
897
898 function toObject(val) {
899 if (val === null || val === undefined) {
900 throw new TypeError('Object.assign cannot be called with null or undefined');
901 }
902
903 return Object(val);
904 }
905
906 function shouldUseNative() {
907 try {
908 if (!Object.assign) {
909 return false;
910 }
911
912 // Detect buggy property enumeration order in older V8 versions.
913
914 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
915 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
916 test1[5] = 'de';
917 if (Object.getOwnPropertyNames(test1)[0] === '5') {
918 return false;
919 }
920
921 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
922 var test2 = {};
923 for (var i = 0; i < 10; i++) {
924 test2['_' + String.fromCharCode(i)] = i;
925 }
926 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
927 return test2[n];
928 });
929 if (order2.join('') !== '0123456789') {
930 return false;
931 }
932
933 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
934 var test3 = {};
935 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
936 test3[letter] = letter;
937 });
938 if (Object.keys(Object.assign({}, test3)).join('') !==
939 'abcdefghijklmnopqrst') {
940 return false;
941 }
942
943 return true;
944 } catch (err) {
945 // We don't expect any of the above to throw, but better to be safe.
946 return false;
947 }
948 }
949
950 objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
951 var from;
952 var to = toObject(target);
953 var symbols;
954
955 for (var s = 1; s < arguments.length; s++) {
956 from = Object(arguments[s]);
957
958 for (var key in from) {
959 if (hasOwnProperty.call(from, key)) {
960 to[key] = from[key];
961 }
962 }
963
964 if (getOwnPropertySymbols) {
965 symbols = getOwnPropertySymbols(from);
966 for (var i = 0; i < symbols.length; i++) {
967 if (propIsEnumerable.call(from, symbols[i])) {
968 to[symbols[i]] = from[symbols[i]];
969 }
970 }
971 }
972 }
973
974 return to;
975 };
976 return objectAssign;
977 }
978
979 /**
980 * Copyright (c) 2013-present, Facebook, Inc.
981 *
982 * This source code is licensed under the MIT license found in the
983 * LICENSE file in the root directory of this source tree.
984 */
985
986 var ReactPropTypesSecret_1;
987 var hasRequiredReactPropTypesSecret;
988
989 function requireReactPropTypesSecret () {
990 if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
991 hasRequiredReactPropTypesSecret = 1;
992
993 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
994
995 ReactPropTypesSecret_1 = ReactPropTypesSecret;
996 return ReactPropTypesSecret_1;
997 }
998
999 var has;
1000 var hasRequiredHas;
1001
1002 function requireHas () {
1003 if (hasRequiredHas) return has;
1004 hasRequiredHas = 1;
1005 has = Function.call.bind(Object.prototype.hasOwnProperty);
1006 return has;
1007 }
1008
1009 /**
1010 * Copyright (c) 2013-present, Facebook, Inc.
1011 *
1012 * This source code is licensed under the MIT license found in the
1013 * LICENSE file in the root directory of this source tree.
1014 */
1015
1016 var checkPropTypes_1;
1017 var hasRequiredCheckPropTypes;
1018
1019 function requireCheckPropTypes () {
1020 if (hasRequiredCheckPropTypes) return checkPropTypes_1;
1021 hasRequiredCheckPropTypes = 1;
1022
1023 var printWarning = function() {};
1024
1025 {
1026 var ReactPropTypesSecret = requireReactPropTypesSecret();
1027 var loggedTypeFailures = {};
1028 var has = requireHas();
1029
1030 printWarning = function(text) {
1031 var message = 'Warning: ' + text;
1032 if (typeof console !== 'undefined') {
1033 console.error(message);
1034 }
1035 try {
1036 // --- Welcome to debugging React ---
1037 // This error was thrown as a convenience so that you can use this stack
1038 // to find the callsite that caused this warning to fire.
1039 throw new Error(message);
1040 } catch (x) { /**/ }
1041 };
1042 }
1043
1044 /**
1045 * Assert that the values match with the type specs.
1046 * Error messages are memorized and will only be shown once.
1047 *
1048 * @param {object} typeSpecs Map of name to a ReactPropType
1049 * @param {object} values Runtime values that need to be type-checked
1050 * @param {string} location e.g. "prop", "context", "child context"
1051 * @param {string} componentName Name of the component for error messages.
1052 * @param {?Function} getStack Returns the component stack.
1053 * @private
1054 */
1055 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
1056 {
1057 for (var typeSpecName in typeSpecs) {
1058 if (has(typeSpecs, typeSpecName)) {
1059 var error;
1060 // Prop type validation may throw. In case they do, we don't want to
1061 // fail the render phase where it didn't fail before. So we log it.
1062 // After these have been cleaned up, we'll let them throw.
1063 try {
1064 // This is intentionally an invariant that gets caught. It's the same
1065 // behavior as without this statement except with a better message.
1066 if (typeof typeSpecs[typeSpecName] !== 'function') {
1067 var err = Error(
1068 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
1069 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
1070 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
1071 );
1072 err.name = 'Invariant Violation';
1073 throw err;
1074 }
1075 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
1076 } catch (ex) {
1077 error = ex;
1078 }
1079 if (error && !(error instanceof Error)) {
1080 printWarning(
1081 (componentName || 'React class') + ': type specification of ' +
1082 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
1083 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
1084 'You may have forgotten to pass an argument to the type checker ' +
1085 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
1086 'shape all require an argument).'
1087 );
1088 }
1089 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
1090 // Only monitor this failure once because there tends to be a lot of the
1091 // same error.
1092 loggedTypeFailures[error.message] = true;
1093
1094 var stack = getStack ? getStack() : '';
1095
1096 printWarning(
1097 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
1098 );
1099 }
1100 }
1101 }
1102 }
1103 }
1104
1105 /**
1106 * Resets warning cache when testing.
1107 *
1108 * @private
1109 */
1110 checkPropTypes.resetWarningCache = function() {
1111 {
1112 loggedTypeFailures = {};
1113 }
1114 };
1115
1116 checkPropTypes_1 = checkPropTypes;
1117 return checkPropTypes_1;
1118 }
1119
1120 /**
1121 * Copyright (c) 2013-present, Facebook, Inc.
1122 *
1123 * This source code is licensed under the MIT license found in the
1124 * LICENSE file in the root directory of this source tree.
1125 */
1126
1127 var factoryWithTypeCheckers;
1128 var hasRequiredFactoryWithTypeCheckers;
1129
1130 function requireFactoryWithTypeCheckers () {
1131 if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
1132 hasRequiredFactoryWithTypeCheckers = 1;
1133
1134 var ReactIs = requireReactIs();
1135 var assign = requireObjectAssign();
1136
1137 var ReactPropTypesSecret = requireReactPropTypesSecret();
1138 var has = requireHas();
1139 var checkPropTypes = requireCheckPropTypes();
1140
1141 var printWarning = function() {};
1142
1143 {
1144 printWarning = function(text) {
1145 var message = 'Warning: ' + text;
1146 if (typeof console !== 'undefined') {
1147 console.error(message);
1148 }
1149 try {
1150 // --- Welcome to debugging React ---
1151 // This error was thrown as a convenience so that you can use this stack
1152 // to find the callsite that caused this warning to fire.
1153 throw new Error(message);
1154 } catch (x) {}
1155 };
1156 }
1157
1158 function emptyFunctionThatReturnsNull() {
1159 return null;
1160 }
1161
1162 factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
1163 /* global Symbol */
1164 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1165 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1166
1167 /**
1168 * Returns the iterator method function contained on the iterable object.
1169 *
1170 * Be sure to invoke the function with the iterable as context:
1171 *
1172 * var iteratorFn = getIteratorFn(myIterable);
1173 * if (iteratorFn) {
1174 * var iterator = iteratorFn.call(myIterable);
1175 * ...
1176 * }
1177 *
1178 * @param {?object} maybeIterable
1179 * @return {?function}
1180 */
1181 function getIteratorFn(maybeIterable) {
1182 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1183 if (typeof iteratorFn === 'function') {
1184 return iteratorFn;
1185 }
1186 }
1187
1188 /**
1189 * Collection of methods that allow declaration and validation of props that are
1190 * supplied to React components. Example usage:
1191 *
1192 * var Props = require('ReactPropTypes');
1193 * var MyArticle = React.createClass({
1194 * propTypes: {
1195 * // An optional string prop named "description".
1196 * description: Props.string,
1197 *
1198 * // A required enum prop named "category".
1199 * category: Props.oneOf(['News','Photos']).isRequired,
1200 *
1201 * // A prop named "dialog" that requires an instance of Dialog.
1202 * dialog: Props.instanceOf(Dialog).isRequired
1203 * },
1204 * render: function() { ... }
1205 * });
1206 *
1207 * A more formal specification of how these methods are used:
1208 *
1209 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1210 * decl := ReactPropTypes.{type}(.isRequired)?
1211 *
1212 * Each and every declaration produces a function with the same signature. This
1213 * allows the creation of custom validation functions. For example:
1214 *
1215 * var MyLink = React.createClass({
1216 * propTypes: {
1217 * // An optional string or URI prop named "href".
1218 * href: function(props, propName, componentName) {
1219 * var propValue = props[propName];
1220 * if (propValue != null && typeof propValue !== 'string' &&
1221 * !(propValue instanceof URI)) {
1222 * return new Error(
1223 * 'Expected a string or an URI for ' + propName + ' in ' +
1224 * componentName
1225 * );
1226 * }
1227 * }
1228 * },
1229 * render: function() {...}
1230 * });
1231 *
1232 * @internal
1233 */
1234
1235 var ANONYMOUS = '<<anonymous>>';
1236
1237 // Important!
1238 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
1239 var ReactPropTypes = {
1240 array: createPrimitiveTypeChecker('array'),
1241 bigint: createPrimitiveTypeChecker('bigint'),
1242 bool: createPrimitiveTypeChecker('boolean'),
1243 func: createPrimitiveTypeChecker('function'),
1244 number: createPrimitiveTypeChecker('number'),
1245 object: createPrimitiveTypeChecker('object'),
1246 string: createPrimitiveTypeChecker('string'),
1247 symbol: createPrimitiveTypeChecker('symbol'),
1248
1249 any: createAnyTypeChecker(),
1250 arrayOf: createArrayOfTypeChecker,
1251 element: createElementTypeChecker(),
1252 elementType: createElementTypeTypeChecker(),
1253 instanceOf: createInstanceTypeChecker,
1254 node: createNodeChecker(),
1255 objectOf: createObjectOfTypeChecker,
1256 oneOf: createEnumTypeChecker,
1257 oneOfType: createUnionTypeChecker,
1258 shape: createShapeTypeChecker,
1259 exact: createStrictShapeTypeChecker,
1260 };
1261
1262 /**
1263 * inlined Object.is polyfill to avoid requiring consumers ship their own
1264 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1265 */
1266 /*eslint-disable no-self-compare*/
1267 function is(x, y) {
1268 // SameValue algorithm
1269 if (x === y) {
1270 // Steps 1-5, 7-10
1271 // Steps 6.b-6.e: +0 != -0
1272 return x !== 0 || 1 / x === 1 / y;
1273 } else {
1274 // Step 6.a: NaN == NaN
1275 return x !== x && y !== y;
1276 }
1277 }
1278 /*eslint-enable no-self-compare*/
1279
1280 /**
1281 * We use an Error-like object for backward compatibility as people may call
1282 * PropTypes directly and inspect their output. However, we don't use real
1283 * Errors anymore. We don't inspect their stack anyway, and creating them
1284 * is prohibitively expensive if they are created too often, such as what
1285 * happens in oneOfType() for any type before the one that matched.
1286 */
1287 function PropTypeError(message, data) {
1288 this.message = message;
1289 this.data = data && typeof data === 'object' ? data: {};
1290 this.stack = '';
1291 }
1292 // Make `instanceof Error` still work for returned errors.
1293 PropTypeError.prototype = Error.prototype;
1294
1295 function createChainableTypeChecker(validate) {
1296 {
1297 var manualPropTypeCallCache = {};
1298 var manualPropTypeWarningCount = 0;
1299 }
1300 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
1301 componentName = componentName || ANONYMOUS;
1302 propFullName = propFullName || propName;
1303
1304 if (secret !== ReactPropTypesSecret) {
1305 if (throwOnDirectAccess) {
1306 // New behavior only for users of `prop-types` package
1307 var err = new Error(
1308 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1309 'Use `PropTypes.checkPropTypes()` to call them. ' +
1310 'Read more at http://fb.me/use-check-prop-types'
1311 );
1312 err.name = 'Invariant Violation';
1313 throw err;
1314 } else if (typeof console !== 'undefined') {
1315 // Old behavior for people using React.PropTypes
1316 var cacheKey = componentName + ':' + propName;
1317 if (
1318 !manualPropTypeCallCache[cacheKey] &&
1319 // Avoid spamming the console because they are often not actionable except for lib authors
1320 manualPropTypeWarningCount < 3
1321 ) {
1322 printWarning(
1323 'You are manually calling a React.PropTypes validation ' +
1324 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
1325 'and will throw in the standalone `prop-types` package. ' +
1326 'You may be seeing this warning due to a third-party PropTypes ' +
1327 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
1328 );
1329 manualPropTypeCallCache[cacheKey] = true;
1330 manualPropTypeWarningCount++;
1331 }
1332 }
1333 }
1334 if (props[propName] == null) {
1335 if (isRequired) {
1336 if (props[propName] === null) {
1337 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
1338 }
1339 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
1340 }
1341 return null;
1342 } else {
1343 return validate(props, propName, componentName, location, propFullName);
1344 }
1345 }
1346
1347 var chainedCheckType = checkType.bind(null, false);
1348 chainedCheckType.isRequired = checkType.bind(null, true);
1349
1350 return chainedCheckType;
1351 }
1352
1353 function createPrimitiveTypeChecker(expectedType) {
1354 function validate(props, propName, componentName, location, propFullName, secret) {
1355 var propValue = props[propName];
1356 var propType = getPropType(propValue);
1357 if (propType !== expectedType) {
1358 // `propValue` being instance of, say, date/regexp, pass the 'object'
1359 // check, but we can offer a more precise error message here rather than
1360 // 'of type `object`'.
1361 var preciseType = getPreciseType(propValue);
1362
1363 return new PropTypeError(
1364 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
1365 {expectedType: expectedType}
1366 );
1367 }
1368 return null;
1369 }
1370 return createChainableTypeChecker(validate);
1371 }
1372
1373 function createAnyTypeChecker() {
1374 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
1375 }
1376
1377 function createArrayOfTypeChecker(typeChecker) {
1378 function validate(props, propName, componentName, location, propFullName) {
1379 if (typeof typeChecker !== 'function') {
1380 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
1381 }
1382 var propValue = props[propName];
1383 if (!Array.isArray(propValue)) {
1384 var propType = getPropType(propValue);
1385 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
1386 }
1387 for (var i = 0; i < propValue.length; i++) {
1388 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
1389 if (error instanceof Error) {
1390 return error;
1391 }
1392 }
1393 return null;
1394 }
1395 return createChainableTypeChecker(validate);
1396 }
1397
1398 function createElementTypeChecker() {
1399 function validate(props, propName, componentName, location, propFullName) {
1400 var propValue = props[propName];
1401 if (!isValidElement(propValue)) {
1402 var propType = getPropType(propValue);
1403 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
1404 }
1405 return null;
1406 }
1407 return createChainableTypeChecker(validate);
1408 }
1409
1410 function createElementTypeTypeChecker() {
1411 function validate(props, propName, componentName, location, propFullName) {
1412 var propValue = props[propName];
1413 if (!ReactIs.isValidElementType(propValue)) {
1414 var propType = getPropType(propValue);
1415 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
1416 }
1417 return null;
1418 }
1419 return createChainableTypeChecker(validate);
1420 }
1421
1422 function createInstanceTypeChecker(expectedClass) {
1423 function validate(props, propName, componentName, location, propFullName) {
1424 if (!(props[propName] instanceof expectedClass)) {
1425 var expectedClassName = expectedClass.name || ANONYMOUS;
1426 var actualClassName = getClassName(props[propName]);
1427 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
1428 }
1429 return null;
1430 }
1431 return createChainableTypeChecker(validate);
1432 }
1433
1434 function createEnumTypeChecker(expectedValues) {
1435 if (!Array.isArray(expectedValues)) {
1436 {
1437 if (arguments.length > 1) {
1438 printWarning(
1439 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
1440 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
1441 );
1442 } else {
1443 printWarning('Invalid argument supplied to oneOf, expected an array.');
1444 }
1445 }
1446 return emptyFunctionThatReturnsNull;
1447 }
1448
1449 function validate(props, propName, componentName, location, propFullName) {
1450 var propValue = props[propName];
1451 for (var i = 0; i < expectedValues.length; i++) {
1452 if (is(propValue, expectedValues[i])) {
1453 return null;
1454 }
1455 }
1456
1457 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1458 var type = getPreciseType(value);
1459 if (type === 'symbol') {
1460 return String(value);
1461 }
1462 return value;
1463 });
1464 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
1465 }
1466 return createChainableTypeChecker(validate);
1467 }
1468
1469 function createObjectOfTypeChecker(typeChecker) {
1470 function validate(props, propName, componentName, location, propFullName) {
1471 if (typeof typeChecker !== 'function') {
1472 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
1473 }
1474 var propValue = props[propName];
1475 var propType = getPropType(propValue);
1476 if (propType !== 'object') {
1477 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
1478 }
1479 for (var key in propValue) {
1480 if (has(propValue, key)) {
1481 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1482 if (error instanceof Error) {
1483 return error;
1484 }
1485 }
1486 }
1487 return null;
1488 }
1489 return createChainableTypeChecker(validate);
1490 }
1491
1492 function createUnionTypeChecker(arrayOfTypeCheckers) {
1493 if (!Array.isArray(arrayOfTypeCheckers)) {
1494 printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ;
1495 return emptyFunctionThatReturnsNull;
1496 }
1497
1498 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1499 var checker = arrayOfTypeCheckers[i];
1500 if (typeof checker !== 'function') {
1501 printWarning(
1502 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
1503 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
1504 );
1505 return emptyFunctionThatReturnsNull;
1506 }
1507 }
1508
1509 function validate(props, propName, componentName, location, propFullName) {
1510 var expectedTypes = [];
1511 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1512 var checker = arrayOfTypeCheckers[i];
1513 var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
1514 if (checkerResult == null) {
1515 return null;
1516 }
1517 if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
1518 expectedTypes.push(checkerResult.data.expectedType);
1519 }
1520 }
1521 var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
1522 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
1523 }
1524 return createChainableTypeChecker(validate);
1525 }
1526
1527 function createNodeChecker() {
1528 function validate(props, propName, componentName, location, propFullName) {
1529 if (!isNode(props[propName])) {
1530 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
1531 }
1532 return null;
1533 }
1534 return createChainableTypeChecker(validate);
1535 }
1536
1537 function invalidValidatorError(componentName, location, propFullName, key, type) {
1538 return new PropTypeError(
1539 (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
1540 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
1541 );
1542 }
1543
1544 function createShapeTypeChecker(shapeTypes) {
1545 function validate(props, propName, componentName, location, propFullName) {
1546 var propValue = props[propName];
1547 var propType = getPropType(propValue);
1548 if (propType !== 'object') {
1549 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1550 }
1551 for (var key in shapeTypes) {
1552 var checker = shapeTypes[key];
1553 if (typeof checker !== 'function') {
1554 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1555 }
1556 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1557 if (error) {
1558 return error;
1559 }
1560 }
1561 return null;
1562 }
1563 return createChainableTypeChecker(validate);
1564 }
1565
1566 function createStrictShapeTypeChecker(shapeTypes) {
1567 function validate(props, propName, componentName, location, propFullName) {
1568 var propValue = props[propName];
1569 var propType = getPropType(propValue);
1570 if (propType !== 'object') {
1571 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1572 }
1573 // We need to check all keys in case some are required but missing from props.
1574 var allKeys = assign({}, props[propName], shapeTypes);
1575 for (var key in allKeys) {
1576 var checker = shapeTypes[key];
1577 if (has(shapeTypes, key) && typeof checker !== 'function') {
1578 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1579 }
1580 if (!checker) {
1581 return new PropTypeError(
1582 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1583 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1584 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1585 );
1586 }
1587 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1588 if (error) {
1589 return error;
1590 }
1591 }
1592 return null;
1593 }
1594
1595 return createChainableTypeChecker(validate);
1596 }
1597
1598 function isNode(propValue) {
1599 switch (typeof propValue) {
1600 case 'number':
1601 case 'string':
1602 case 'undefined':
1603 return true;
1604 case 'boolean':
1605 return !propValue;
1606 case 'object':
1607 if (Array.isArray(propValue)) {
1608 return propValue.every(isNode);
1609 }
1610 if (propValue === null || isValidElement(propValue)) {
1611 return true;
1612 }
1613
1614 var iteratorFn = getIteratorFn(propValue);
1615 if (iteratorFn) {
1616 var iterator = iteratorFn.call(propValue);
1617 var step;
1618 if (iteratorFn !== propValue.entries) {
1619 while (!(step = iterator.next()).done) {
1620 if (!isNode(step.value)) {
1621 return false;
1622 }
1623 }
1624 } else {
1625 // Iterator will provide entry [k,v] tuples rather than values.
1626 while (!(step = iterator.next()).done) {
1627 var entry = step.value;
1628 if (entry) {
1629 if (!isNode(entry[1])) {
1630 return false;
1631 }
1632 }
1633 }
1634 }
1635 } else {
1636 return false;
1637 }
1638
1639 return true;
1640 default:
1641 return false;
1642 }
1643 }
1644
1645 function isSymbol(propType, propValue) {
1646 // Native Symbol.
1647 if (propType === 'symbol') {
1648 return true;
1649 }
1650
1651 // falsy value can't be a Symbol
1652 if (!propValue) {
1653 return false;
1654 }
1655
1656 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1657 if (propValue['@@toStringTag'] === 'Symbol') {
1658 return true;
1659 }
1660
1661 // Fallback for non-spec compliant Symbols which are polyfilled.
1662 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1663 return true;
1664 }
1665
1666 return false;
1667 }
1668
1669 // Equivalent of `typeof` but with special handling for array and regexp.
1670 function getPropType(propValue) {
1671 var propType = typeof propValue;
1672 if (Array.isArray(propValue)) {
1673 return 'array';
1674 }
1675 if (propValue instanceof RegExp) {
1676 // Old webkits (at least until Android 4.0) return 'function' rather than
1677 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1678 // passes PropTypes.object.
1679 return 'object';
1680 }
1681 if (isSymbol(propType, propValue)) {
1682 return 'symbol';
1683 }
1684 return propType;
1685 }
1686
1687 // This handles more types than `getPropType`. Only used for error messages.
1688 // See `createPrimitiveTypeChecker`.
1689 function getPreciseType(propValue) {
1690 if (typeof propValue === 'undefined' || propValue === null) {
1691 return '' + propValue;
1692 }
1693 var propType = getPropType(propValue);
1694 if (propType === 'object') {
1695 if (propValue instanceof Date) {
1696 return 'date';
1697 } else if (propValue instanceof RegExp) {
1698 return 'regexp';
1699 }
1700 }
1701 return propType;
1702 }
1703
1704 // Returns a string that is postfixed to a warning about an invalid type.
1705 // For example, "undefined" or "of type array"
1706 function getPostfixForTypeWarning(value) {
1707 var type = getPreciseType(value);
1708 switch (type) {
1709 case 'array':
1710 case 'object':
1711 return 'an ' + type;
1712 case 'boolean':
1713 case 'date':
1714 case 'regexp':
1715 return 'a ' + type;
1716 default:
1717 return type;
1718 }
1719 }
1720
1721 // Returns class name of the object, if any.
1722 function getClassName(propValue) {
1723 if (!propValue.constructor || !propValue.constructor.name) {
1724 return ANONYMOUS;
1725 }
1726 return propValue.constructor.name;
1727 }
1728
1729 ReactPropTypes.checkPropTypes = checkPropTypes;
1730 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
1731 ReactPropTypes.PropTypes = ReactPropTypes;
1732
1733 return ReactPropTypes;
1734 };
1735 return factoryWithTypeCheckers;
1736 }
1737
1738 /**
1739 * Copyright (c) 2013-present, Facebook, Inc.
1740 *
1741 * This source code is licensed under the MIT license found in the
1742 * LICENSE file in the root directory of this source tree.
1743 */
1744
1745 {
1746 var ReactIs = requireReactIs();
1747
1748 // By explicitly using `prop-types` you are opting into new development behavior.
1749 // http://fb.me/prop-types-in-prod
1750 var throwOnDirectAccess = true;
1751 propTypes$b.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
1752 }
1753
1754 /**
1755 * Returns a function that triggers a component update. the hook equivalent to
1756 * `this.forceUpdate()` in a class component. In most cases using a state value directly
1757 * is preferable but may be required in some advanced usages of refs for interop or
1758 * when direct DOM manipulation is required.
1759 *
1760 * ```ts
1761 * const forceUpdate = useForceUpdate();
1762 *
1763 * const updateOnClick = useCallback(() => {
1764 * forceUpdate()
1765 * }, [forceUpdate])
1766 *
1767 * return <button type="button" onClick={updateOnClick}>Hi there</button>
1768 * ```
1769 */
1770
1771 function useForceUpdate() {
1772 // The toggling state value is designed to defeat React optimizations for skipping
1773 // updates when they are stricting equal to the last state value
1774 var _useReducer = React.useReducer(function (state) {
1775 return !state;
1776 }, false),
1777 dispatch = _useReducer[1];
1778
1779 return dispatch;
1780 }
1781
1782 /**
1783 * Store the last of some value. Tracked via a `Ref` only updating it
1784 * after the component renders.
1785 *
1786 * Helpful if you need to compare a prop value to it's previous value during render.
1787 *
1788 * ```ts
1789 * function Component(props) {
1790 * const lastProps = usePrevious(props)
1791 *
1792 * if (lastProps.foo !== props.foo)
1793 * resetValueFromProps(props.foo)
1794 * }
1795 * ```
1796 *
1797 * @param value the value to track
1798 */
1799
1800 function usePrevious(value) {
1801 var ref = React.useRef(null);
1802 React.useEffect(function () {
1803 ref.current = value;
1804 });
1805 return ref.current;
1806 }
1807
1808 var DEFAULT_LABELKEY = 'label';
1809 var SIZES = ['lg', 'sm'];
1810
1811 /**
1812 * Copyright (c) 2013-present, Facebook, Inc.
1813 *
1814 * This source code is licensed under the MIT license found in the
1815 * LICENSE file in the root directory of this source tree.
1816 */
1817
1818 var invariant = function(condition, format, a, b, c, d, e, f) {
1819 {
1820 if (format === undefined) {
1821 throw new Error('invariant requires an error message argument');
1822 }
1823 }
1824
1825 if (!condition) {
1826 var error;
1827 if (format === undefined) {
1828 error = new Error(
1829 'Minified exception occurred; use the non-minified dev environment ' +
1830 'for the full error message and additional helpful warnings.'
1831 );
1832 } else {
1833 var args = [a, b, c, d, e, f];
1834 var argIndex = 0;
1835 error = new Error(
1836 format.replace(/%s/g, function() { return args[argIndex++]; })
1837 );
1838 error.name = 'Invariant Violation';
1839 }
1840
1841 error.framesToPop = 1; // we don't care about invariant's own frame
1842 throw error;
1843 }
1844 };
1845
1846 var invariant_1 = invariant;
1847
1848 function getStringLabelKey(labelKey) {
1849 return typeof labelKey === 'string' ? labelKey : DEFAULT_LABELKEY;
1850 }
1851
1852 /**
1853 * Check if an object has the given property in a type-safe way.
1854 */
1855 function hasOwnProperty(obj, prop) {
1856 return Object.prototype.hasOwnProperty.call(obj, prop);
1857 }
1858
1859 var idCounter = 0; // eslint-disable-next-line @typescript-eslint/ban-types
1860
1861 function isFunction(value) {
1862 return typeof value === 'function';
1863 }
1864 function isString(value) {
1865 return typeof value === 'string';
1866 } // eslint-disable-next-line @typescript-eslint/no-empty-function
1867
1868 function noop$1() {}
1869 function pick(obj, keys) {
1870 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1871 var result = {};
1872 keys.forEach(function (key) {
1873 result[key] = obj[key];
1874 });
1875 return result;
1876 }
1877 function uniqueId(prefix) {
1878 idCounter += 1;
1879 return (prefix == null ? '' : String(prefix)) + idCounter;
1880 }
1881
1882 /**
1883 * Retrieves the display string from an option. Options can be the string
1884 * themselves, or an object with a defined display string. Anything else throws
1885 * an error.
1886 */
1887 function getOptionLabel(option, labelKey) {
1888 // Handle internally created options first.
1889 if (!isString(option) && (hasOwnProperty(option, 'paginationOption') || hasOwnProperty(option, 'customOption'))) {
1890 return option[getStringLabelKey(labelKey)];
1891 }
1892
1893 var optionLabel;
1894
1895 if (isFunction(labelKey)) {
1896 optionLabel = labelKey(option);
1897 } else if (isString(option)) {
1898 optionLabel = option;
1899 } else {
1900 // `option` is an object and `labelKey` is a string.
1901 optionLabel = option[labelKey];
1902 }
1903
1904 !isString(optionLabel) ? invariant_1(false, 'One or more options does not have a valid label string. Check the ' + '`labelKey` prop to ensure that it matches the correct option key and ' + 'provides a string for filtering and display.') : void 0;
1905 return optionLabel;
1906 }
1907
1908 function addCustomOption(results, props) {
1909 var allowNew = props.allowNew,
1910 labelKey = props.labelKey,
1911 text = props.text;
1912
1913 if (!allowNew || !text.trim()) {
1914 return false;
1915 } // If the consumer has provided a callback, use that to determine whether or
1916 // not to add the custom option.
1917
1918
1919 if (isFunction(allowNew)) {
1920 return allowNew(results, props);
1921 } // By default, don't add the custom option if there is an exact text match
1922 // with an existing option.
1923
1924
1925 return !results.some(function (o) {
1926 return getOptionLabel(o, labelKey) === text;
1927 });
1928 }
1929
1930 // do not edit .js files directly - edit src/index.jst
1931
1932
1933
1934 var fastDeepEqual = function equal(a, b) {
1935 if (a === b) return true;
1936
1937 if (a && b && typeof a == 'object' && typeof b == 'object') {
1938 if (a.constructor !== b.constructor) return false;
1939
1940 var length, i, keys;
1941 if (Array.isArray(a)) {
1942 length = a.length;
1943 if (length != b.length) return false;
1944 for (i = length; i-- !== 0;)
1945 if (!equal(a[i], b[i])) return false;
1946 return true;
1947 }
1948
1949
1950
1951 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
1952 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
1953 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
1954
1955 keys = Object.keys(a);
1956 length = keys.length;
1957 if (length !== Object.keys(b).length) return false;
1958
1959 for (i = length; i-- !== 0;)
1960 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
1961
1962 for (i = length; i-- !== 0;) {
1963 var key = keys[i];
1964
1965 if (!equal(a[key], b[key])) return false;
1966 }
1967
1968 return true;
1969 }
1970
1971 // true if both NaN, false otherwise
1972 return a!==a && b!==b;
1973 };
1974
1975 function getOptionProperty(option, key) {
1976 if (isString(option)) {
1977 return undefined;
1978 }
1979
1980 return option[key];
1981 }
1982
1983 /**
1984 * Licensed under the Apache License, Version 2.0 (the "License");
1985 * you may not use this file except in compliance with the License.
1986 * You may obtain a copy of the License at
1987 *
1988 * http://www.apache.org/licenses/LICENSE-2.0
1989 *
1990 * Unless required by applicable law or agreed to in writing, software
1991 * distributed under the License is distributed on an "AS IS" BASIS,
1992 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1993 * See the License for the specific language governing permissions and
1994 * limitations under the License.
1995 *
1996 * Taken from: http://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/18391901#18391901
1997 */
1998 // prettier-ignore
1999 var map = [{
2000 base: 'A',
2001 letters: "A\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F"
2002 }, {
2003 base: 'AA',
2004 letters: "\uA732"
2005 }, {
2006 base: 'AE',
2007 letters: "\xC6\u01FC\u01E2"
2008 }, {
2009 base: 'AO',
2010 letters: "\uA734"
2011 }, {
2012 base: 'AU',
2013 letters: "\uA736"
2014 }, {
2015 base: 'AV',
2016 letters: "\uA738\uA73A"
2017 }, {
2018 base: 'AY',
2019 letters: "\uA73C"
2020 }, {
2021 base: 'B',
2022 letters: "B\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181"
2023 }, {
2024 base: 'C',
2025 letters: "C\u24B8\uFF23\u0106\u0108\u010A\u010C\xC7\u1E08\u0187\u023B\uA73E"
2026 }, {
2027 base: 'D',
2028 letters: "D\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\xD0"
2029 }, {
2030 base: 'DZ',
2031 letters: "\u01F1\u01C4"
2032 }, {
2033 base: 'Dz',
2034 letters: "\u01F2\u01C5"
2035 }, {
2036 base: 'E',
2037 letters: "E\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E"
2038 }, {
2039 base: 'F',
2040 letters: "F\u24BB\uFF26\u1E1E\u0191\uA77B"
2041 }, {
2042 base: 'G',
2043 letters: "G\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E"
2044 }, {
2045 base: 'H',
2046 letters: "H\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
2047 }, {
2048 base: 'I',
2049 letters: "I\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
2050 }, {
2051 base: 'J',
2052 letters: "J\u24BF\uFF2A\u0134\u0248"
2053 }, {
2054 base: 'K',
2055 letters: "K\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
2056 }, {
2057 base: 'L',
2058 letters: "L\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
2059 }, {
2060 base: 'LJ',
2061 letters: "\u01C7"
2062 }, {
2063 base: 'Lj',
2064 letters: "\u01C8"
2065 }, {
2066 base: 'M',
2067 letters: "M\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C"
2068 }, {
2069 base: 'N',
2070 letters: "N\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4"
2071 }, {
2072 base: 'NJ',
2073 letters: "\u01CA"
2074 }, {
2075 base: 'Nj',
2076 letters: "\u01CB"
2077 }, {
2078 base: 'O',
2079 letters: "O\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C"
2080 }, {
2081 base: 'OI',
2082 letters: "\u01A2"
2083 }, {
2084 base: 'OO',
2085 letters: "\uA74E"
2086 }, {
2087 base: 'OU',
2088 letters: "\u0222"
2089 }, {
2090 base: 'OE',
2091 letters: "\x8C\u0152"
2092 }, {
2093 base: 'oe',
2094 letters: "\x9C\u0153"
2095 }, {
2096 base: 'P',
2097 letters: "P\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
2098 }, {
2099 base: 'Q',
2100 letters: "Q\u24C6\uFF31\uA756\uA758\u024A"
2101 }, {
2102 base: 'R',
2103 letters: "R\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
2104 }, {
2105 base: 'S',
2106 letters: "S\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
2107 }, {
2108 base: 'T',
2109 letters: "T\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
2110 }, {
2111 base: 'TZ',
2112 letters: "\uA728"
2113 }, {
2114 base: 'U',
2115 letters: "U\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244"
2116 }, {
2117 base: 'V',
2118 letters: "V\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
2119 }, {
2120 base: 'VY',
2121 letters: "\uA760"
2122 }, {
2123 base: 'W',
2124 letters: "W\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
2125 }, {
2126 base: 'X',
2127 letters: "X\u24CD\uFF38\u1E8A\u1E8C"
2128 }, {
2129 base: 'Y',
2130 letters: "Y\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
2131 }, {
2132 base: 'Z',
2133 letters: "Z\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
2134 }, {
2135 base: 'a',
2136 letters: "a\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250"
2137 }, {
2138 base: 'aa',
2139 letters: "\uA733"
2140 }, {
2141 base: 'ae',
2142 letters: "\xE6\u01FD\u01E3"
2143 }, {
2144 base: 'ao',
2145 letters: "\uA735"
2146 }, {
2147 base: 'au',
2148 letters: "\uA737"
2149 }, {
2150 base: 'av',
2151 letters: "\uA739\uA73B"
2152 }, {
2153 base: 'ay',
2154 letters: "\uA73D"
2155 }, {
2156 base: 'b',
2157 letters: "b\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253"
2158 }, {
2159 base: 'c',
2160 letters: "c\u24D2\uFF43\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
2161 }, {
2162 base: 'd',
2163 letters: "d\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A"
2164 }, {
2165 base: 'dz',
2166 letters: "\u01F3\u01C6"
2167 }, {
2168 base: 'e',
2169 letters: "e\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD"
2170 }, {
2171 base: 'f',
2172 letters: "f\u24D5\uFF46\u1E1F\u0192\uA77C"
2173 }, {
2174 base: 'g',
2175 letters: "g\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F"
2176 }, {
2177 base: 'h',
2178 letters: "h\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
2179 }, {
2180 base: 'hv',
2181 letters: "\u0195"
2182 }, {
2183 base: 'i',
2184 letters: "i\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
2185 }, {
2186 base: 'j',
2187 letters: "j\u24D9\uFF4A\u0135\u01F0\u0249"
2188 }, {
2189 base: 'k',
2190 letters: "k\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
2191 }, {
2192 base: 'l',
2193 letters: "l\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747"
2194 }, {
2195 base: 'lj',
2196 letters: "\u01C9"
2197 }, {
2198 base: 'm',
2199 letters: "m\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
2200 }, {
2201 base: 'n',
2202 letters: "n\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5"
2203 }, {
2204 base: 'nj',
2205 letters: "\u01CC"
2206 }, {
2207 base: 'o',
2208 letters: "o\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\u0254\uA74B\uA74D\u0275"
2209 }, {
2210 base: 'oi',
2211 letters: "\u01A3"
2212 }, {
2213 base: 'ou',
2214 letters: "\u0223"
2215 }, {
2216 base: 'oo',
2217 letters: "\uA74F"
2218 }, {
2219 base: 'p',
2220 letters: "p\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755"
2221 }, {
2222 base: 'q',
2223 letters: "q\u24E0\uFF51\u024B\uA757\uA759"
2224 }, {
2225 base: 'r',
2226 letters: "r\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
2227 }, {
2228 base: 's',
2229 letters: "s\u24E2\uFF53\xDF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B"
2230 }, {
2231 base: 't',
2232 letters: "t\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
2233 }, {
2234 base: 'tz',
2235 letters: "\uA729"
2236 }, {
2237 base: 'u',
2238 letters: "u\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289"
2239 }, {
2240 base: 'v',
2241 letters: "v\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
2242 }, {
2243 base: 'vy',
2244 letters: "\uA761"
2245 }, {
2246 base: 'w',
2247 letters: "w\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
2248 }, {
2249 base: 'x',
2250 letters: "x\u24E7\uFF58\u1E8B\u1E8D"
2251 }, {
2252 base: 'y',
2253 letters: "y\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
2254 }, {
2255 base: 'z',
2256 letters: "z\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
2257 }].reduce(function (acc, _ref) {
2258 var base = _ref.base,
2259 letters = _ref.letters;
2260 letters.split('').forEach(function (letter) {
2261 acc[letter] = base;
2262 });
2263 return acc;
2264 }, {}); // "what?" version ... http://jsperf.com/diacritics/12
2265
2266 function stripDiacritics(str) {
2267 return str.normalize('NFD').replace(/[\u0300-\u036F]/g, '') // Remove combining diacritics
2268
2269 /* eslint-disable-next-line no-control-regex */
2270 .replace(/[^\u0000-\u007E]/g, function (a) {
2271 return map[a] || a;
2272 });
2273 }
2274
2275 /**
2276 * Copyright (c) 2014-present, Facebook, Inc.
2277 *
2278 * This source code is licensed under the MIT license found in the
2279 * LICENSE file in the root directory of this source tree.
2280 */
2281
2282 var warning = function() {};
2283
2284 {
2285 var printWarning = function printWarning(format, args) {
2286 var len = arguments.length;
2287 args = new Array(len > 1 ? len - 1 : 0);
2288 for (var key = 1; key < len; key++) {
2289 args[key - 1] = arguments[key];
2290 }
2291 var argIndex = 0;
2292 var message = 'Warning: ' +
2293 format.replace(/%s/g, function() {
2294 return args[argIndex++];
2295 });
2296 if (typeof console !== 'undefined') {
2297 console.error(message);
2298 }
2299 try {
2300 // --- Welcome to debugging React ---
2301 // This error was thrown as a convenience so that you can use this stack
2302 // to find the callsite that caused this warning to fire.
2303 throw new Error(message);
2304 } catch (x) {}
2305 };
2306
2307 warning = function(condition, format, args) {
2308 var len = arguments.length;
2309 args = new Array(len > 2 ? len - 2 : 0);
2310 for (var key = 2; key < len; key++) {
2311 args[key - 2] = arguments[key];
2312 }
2313 if (format === undefined) {
2314 throw new Error(
2315 '`warning(condition, format, ...args)` requires a warning ' +
2316 'message argument'
2317 );
2318 }
2319 if (!condition) {
2320 printWarning.apply(null, [format].concat(args));
2321 }
2322 };
2323 }
2324
2325 var warning_1 = warning;
2326
2327 // @flow
2328 var warned = {};
2329 /**
2330 * Copied from: https://github.com/ReactTraining/react-router/blob/master/modules/routerWarning.js
2331 */
2332
2333 function warn(falseToWarn, message) {
2334 // Only issue deprecation warnings once.
2335 if (!falseToWarn && message.indexOf('deprecated') !== -1) {
2336 if (warned[message]) {
2337 return;
2338 }
2339
2340 warned[message] = true;
2341 }
2342
2343 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2344 args[_key - 2] = arguments[_key];
2345 }
2346
2347 warning_1.apply(void 0, [falseToWarn, "[react-bootstrap-typeahead] ".concat(message)].concat(args));
2348 }
2349
2350 function isMatch(input, string, props) {
2351 var searchStr = input;
2352 var str = string;
2353
2354 if (!props.caseSensitive) {
2355 searchStr = searchStr.toLowerCase();
2356 str = str.toLowerCase();
2357 }
2358
2359 if (props.ignoreDiacritics) {
2360 searchStr = stripDiacritics(searchStr);
2361 str = stripDiacritics(str);
2362 }
2363
2364 return str.indexOf(searchStr) !== -1;
2365 }
2366 /**
2367 * Default algorithm for filtering results.
2368 */
2369
2370
2371 function defaultFilterBy(option, props) {
2372 var filterBy = props.filterBy,
2373 labelKey = props.labelKey,
2374 multiple = props.multiple,
2375 selected = props.selected,
2376 text = props.text; // Don't show selected options in the menu for the multi-select case.
2377
2378 if (multiple && selected.some(function (o) {
2379 return fastDeepEqual(o, option);
2380 })) {
2381 return false;
2382 }
2383
2384 if (isFunction(labelKey)) {
2385 return isMatch(text, labelKey(option), props);
2386 }
2387
2388 var fields = filterBy.slice();
2389
2390 if (isString(labelKey)) {
2391 // Add the `labelKey` field to the list of fields if it isn't already there.
2392 if (fields.indexOf(labelKey) === -1) {
2393 fields.unshift(labelKey);
2394 }
2395 }
2396
2397 if (isString(option)) {
2398 warn(fields.length <= 1, 'You cannot filter by properties when `option` is a string.');
2399 return isMatch(text, option, props);
2400 }
2401
2402 return fields.some(function (field) {
2403 var value = getOptionProperty(option, field);
2404
2405 if (!isString(value)) {
2406 warn(false, 'Fields passed to `filterBy` should have string values. Value will ' + 'be converted to a string; results may be unexpected.');
2407 value = String(value);
2408 }
2409
2410 return isMatch(text, value, props);
2411 });
2412 }
2413
2414 /**
2415 * Check if an input type is selectable, based on WHATWG spec.
2416 *
2417 * See:
2418 * - https://stackoverflow.com/questions/21177489/selectionstart-selectionend-on-input-type-number-no-longer-allowed-in-chrome/24175357
2419 * - https://html.spec.whatwg.org/multipage/input.html#do-not-apply
2420 */
2421 function isSelectable(inputNode) {
2422 return inputNode.selectionStart != null;
2423 }
2424
2425 function defaultSelectHint(e, selectHint) {
2426 var shouldSelectHint = false;
2427
2428 if (e.key === 'ArrowRight') {
2429 // For selectable input types ("text", "search"), only select the hint if
2430 // it's at the end of the input value. For non-selectable types ("email",
2431 // "number"), always select the hint.
2432 shouldSelectHint = isSelectable(e.currentTarget) ? e.currentTarget.selectionStart === e.currentTarget.value.length : true;
2433 }
2434
2435 if (e.key === 'Tab') {
2436 // Prevent input from blurring on TAB.
2437 e.preventDefault();
2438 shouldSelectHint = true;
2439 }
2440
2441 return selectHint ? selectHint(shouldSelectHint, e) : shouldSelectHint;
2442 }
2443
2444 // eslint-disable-next-line @typescript-eslint/no-explicit-any
2445 function getDisplayName(Component) {
2446 return Component.displayName || Component.name || 'Component';
2447 }
2448
2449 var CASE_INSENSITIVE = 'i';
2450 var COMBINING_MARKS = /[\u0300-\u036F]/;
2451 // Export for testing.
2452 function escapeStringRegexp(str) {
2453 !(typeof str === 'string') ? invariant_1(false, '`escapeStringRegexp` expected a string.') : void 0; // Escape characters with special meaning either inside or outside character
2454 // sets. Use a simple backslash escape when it’s always valid, and a \unnnn
2455 // escape when the simpler form would be disallowed by Unicode patterns’
2456 // stricter grammar.
2457
2458 return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
2459 }
2460 function getMatchBounds(subject, str) {
2461 var search = new RegExp(escapeStringRegexp(stripDiacritics(str)), CASE_INSENSITIVE);
2462 var matches = search.exec(stripDiacritics(subject));
2463
2464 if (!matches) {
2465 return null;
2466 }
2467
2468 var start = matches.index;
2469 var matchLength = matches[0].length; // Account for combining marks, which changes the indices.
2470
2471 if (COMBINING_MARKS.test(subject)) {
2472 // Starting at the beginning of the subject string, check for the number of
2473 // combining marks and increment the start index whenever one is found.
2474 for (var ii = 0; ii <= start; ii++) {
2475 if (COMBINING_MARKS.test(subject[ii])) {
2476 start += 1;
2477 }
2478 } // Similarly, increment the length of the match string if it contains a
2479 // combining mark.
2480
2481
2482 for (var _ii = start; _ii <= start + matchLength; _ii++) {
2483 if (COMBINING_MARKS.test(subject[_ii])) {
2484 matchLength += 1;
2485 }
2486 }
2487 }
2488
2489 return {
2490 end: start + matchLength,
2491 start: start
2492 };
2493 }
2494
2495 function getHintText(_ref) {
2496 var activeIndex = _ref.activeIndex,
2497 initialItem = _ref.initialItem,
2498 isFocused = _ref.isFocused,
2499 isMenuShown = _ref.isMenuShown,
2500 labelKey = _ref.labelKey,
2501 multiple = _ref.multiple,
2502 selected = _ref.selected,
2503 text = _ref.text;
2504
2505 // Don't display a hint under the following conditions:
2506 if ( // No text entered.
2507 !text || // The input is not focused.
2508 !isFocused || // The menu is hidden.
2509 !isMenuShown || // No item in the menu.
2510 !initialItem || // The initial item is a custom option.
2511 !isString(initialItem) && hasOwnProperty(initialItem, 'customOption') || // One of the menu items is active.
2512 activeIndex > -1 || // There's already a selection in single-select mode.
2513 !!selected.length && !multiple) {
2514 return '';
2515 }
2516
2517 var initialItemStr = getOptionLabel(initialItem, labelKey);
2518 var bounds = getMatchBounds(initialItemStr.toLowerCase(), text.toLowerCase());
2519
2520 if (!(bounds && bounds.start === 0)) {
2521 return '';
2522 } // Text matching is case- and accent-insensitive, so to display the hint
2523 // correctly, splice the input string with the hint string.
2524
2525
2526 return text + initialItemStr.slice(bounds.end, initialItemStr.length);
2527 }
2528
2529 var classnames = {exports: {}};
2530
2531 /*!
2532 Copyright (c) 2018 Jed Watson.
2533 Licensed under the MIT License (MIT), see
2534 http://jedwatson.github.io/classnames
2535 */
2536
2537 (function (module) {
2538 /* global define */
2539
2540 (function () {
2541
2542 var hasOwn = {}.hasOwnProperty;
2543
2544 function classNames() {
2545 var classes = [];
2546
2547 for (var i = 0; i < arguments.length; i++) {
2548 var arg = arguments[i];
2549 if (!arg) continue;
2550
2551 var argType = typeof arg;
2552
2553 if (argType === 'string' || argType === 'number') {
2554 classes.push(arg);
2555 } else if (Array.isArray(arg)) {
2556 if (arg.length) {
2557 var inner = classNames.apply(null, arg);
2558 if (inner) {
2559 classes.push(inner);
2560 }
2561 }
2562 } else if (argType === 'object') {
2563 if (arg.toString === Object.prototype.toString) {
2564 for (var key in arg) {
2565 if (hasOwn.call(arg, key) && arg[key]) {
2566 classes.push(key);
2567 }
2568 }
2569 } else {
2570 classes.push(arg.toString());
2571 }
2572 }
2573 }
2574
2575 return classes.join(' ');
2576 }
2577
2578 if (module.exports) {
2579 classNames.default = classNames;
2580 module.exports = classNames;
2581 } else {
2582 window.classNames = classNames;
2583 }
2584 }());
2585 } (classnames));
2586
2587 var cx = classnames.exports;
2588
2589 function getMenuItemId() {
2590 var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2591 var position = arguments.length > 1 ? arguments[1] : undefined;
2592 return "".concat(id, "-item-").concat(position);
2593 }
2594
2595 var _excluded$e = ["activeIndex", "id", "isFocused", "isMenuShown", "multiple", "onClick", "onFocus", "placeholder"];
2596
2597 var getInputProps = function getInputProps(_ref) {
2598 var activeIndex = _ref.activeIndex,
2599 id = _ref.id,
2600 isFocused = _ref.isFocused,
2601 isMenuShown = _ref.isMenuShown,
2602 multiple = _ref.multiple,
2603 onClick = _ref.onClick,
2604 onFocus = _ref.onFocus,
2605 placeholder = _ref.placeholder,
2606 props = _objectWithoutProperties(_ref, _excluded$e);
2607
2608 return function () {
2609 var _cx;
2610
2611 var inputProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2612 var className = hasOwnProperty(inputProps, 'className') ? String(inputProps.className) : undefined;
2613 return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
2614 // These props can be overridden by values in `inputProps`.
2615 autoComplete: 'off',
2616 placeholder: placeholder,
2617 type: 'text'
2618 }, inputProps), props), {}, {
2619 'aria-activedescendant': activeIndex >= 0 ? getMenuItemId(id, activeIndex) : undefined,
2620 'aria-autocomplete': 'both',
2621 'aria-expanded': isMenuShown,
2622 'aria-haspopup': 'listbox',
2623 'aria-multiselectable': multiple || undefined,
2624 'aria-owns': isMenuShown ? id : undefined,
2625 className: cx((_cx = {}, _defineProperty(_cx, className || '', !multiple), _defineProperty(_cx, "focus", isFocused), _cx))
2626 }, multiple && {
2627 inputClassName: className
2628 }), {}, {
2629 onClick: onClick,
2630 onFocus: onFocus,
2631 role: 'combobox'
2632 });
2633 };
2634 };
2635
2636 function getInputText(props) {
2637 var activeItem = props.activeItem,
2638 labelKey = props.labelKey,
2639 multiple = props.multiple,
2640 selected = props.selected,
2641 text = props.text;
2642
2643 if (activeItem) {
2644 // Display the input value if the pagination item is active.
2645 return getOptionLabel(activeItem, labelKey);
2646 }
2647
2648 if (!multiple && selected.length && selected[0]) {
2649 return getOptionLabel(selected[0], labelKey);
2650 }
2651
2652 return text;
2653 }
2654
2655 function getIsOnlyResult(props) {
2656 var allowNew = props.allowNew,
2657 highlightOnlyResult = props.highlightOnlyResult,
2658 results = props.results;
2659
2660 if (!highlightOnlyResult || allowNew) {
2661 return false;
2662 }
2663
2664 return results.length === 1 && !getOptionProperty(results[0], 'disabled');
2665 }
2666
2667 /**
2668 * Truncates the result set based on `maxResults` and returns the new set.
2669 */
2670 function getTruncatedOptions(options, maxResults) {
2671 if (!maxResults || maxResults >= options.length) {
2672 return options;
2673 }
2674
2675 return options.slice(0, maxResults);
2676 }
2677
2678 function isDisabledOption(index, items) {
2679 var option = items[index];
2680 return !!option && !isString(option) && hasOwnProperty(option, 'disabled');
2681 }
2682 function skipDisabledOptions(currentIndex, key, items) {
2683 var newIndex = currentIndex;
2684
2685 while (isDisabledOption(newIndex, items)) {
2686 newIndex += key === 'ArrowUp' ? -1 : 1;
2687 }
2688
2689 return newIndex;
2690 }
2691 function getUpdatedActiveIndex(currentIndex, key, items) {
2692 var newIndex = currentIndex; // Increment or decrement index based on user keystroke.
2693
2694 newIndex += key === 'ArrowUp' ? -1 : 1; // Skip over any disabled options.
2695
2696 newIndex = skipDisabledOptions(newIndex, key, items); // If we've reached the end, go back to the beginning or vice-versa.
2697
2698 if (newIndex === items.length) {
2699 newIndex = -1;
2700 } else if (newIndex === -2) {
2701 newIndex = items.length - 1; // Skip over any disabled options.
2702
2703 newIndex = skipDisabledOptions(newIndex, key, items);
2704 }
2705
2706 return newIndex;
2707 }
2708
2709 function isShown(_ref) {
2710 var open = _ref.open,
2711 minLength = _ref.minLength,
2712 showMenu = _ref.showMenu,
2713 text = _ref.text;
2714
2715 // If menu visibility is controlled via props, that value takes precedence.
2716 if (open || open === false) {
2717 return open;
2718 }
2719
2720 if (text.length < minLength) {
2721 return false;
2722 }
2723
2724 return showMenu;
2725 }
2726
2727 /**
2728 * Prevent the main input from blurring when a menu item or the clear button is
2729 * clicked. (#226 & #310)
2730 */
2731 function preventInputBlur(e) {
2732 e.preventDefault();
2733 }
2734
2735 function isSizeLarge(size) {
2736 return size === 'lg';
2737 }
2738 function isSizeSmall(size) {
2739 return size === 'sm';
2740 }
2741
2742 var _excluded$d = ["className", "isInvalid", "isValid", "size"];
2743
2744 /**
2745 * Returns Bootstrap classnames from `size` and validation props, along
2746 * with pass-through props.
2747 */
2748 function propsWithBsClassName(_ref) {
2749 var className = _ref.className,
2750 isInvalid = _ref.isInvalid,
2751 isValid = _ref.isValid,
2752 size = _ref.size,
2753 props = _objectWithoutProperties(_ref, _excluded$d);
2754
2755 return _objectSpread2(_objectSpread2({}, props), {}, {
2756 className: cx('form-control', 'rbt-input', {
2757 'form-control-lg': isSizeLarge(size),
2758 'form-control-sm': isSizeSmall(size),
2759 'is-invalid': isInvalid,
2760 'is-valid': isValid
2761 }, className)
2762 });
2763 }
2764
2765 function validateSelectedPropChange(prevSelected, selected) {
2766 var uncontrolledToControlled = !prevSelected && selected;
2767 var controlledToUncontrolled = prevSelected && !selected;
2768 var from, to, precedent;
2769
2770 if (uncontrolledToControlled) {
2771 from = 'uncontrolled';
2772 to = 'controlled';
2773 precedent = 'an';
2774 } else {
2775 from = 'controlled';
2776 to = 'uncontrolled';
2777 precedent = 'a';
2778 }
2779
2780 var message = "You are changing ".concat(precedent, " ").concat(from, " typeahead to be ").concat(to, ". ") + "Input elements should not switch from ".concat(from, " to ").concat(to, " (or vice versa). ") + 'Decide between using a controlled or uncontrolled element for the ' + 'lifetime of the component.';
2781 warn(!(uncontrolledToControlled || controlledToUncontrolled), message);
2782 }
2783
2784 var INPUT_PROPS_BLACKLIST = [{
2785 alt: 'onBlur',
2786 prop: 'onBlur'
2787 }, {
2788 alt: 'onInputChange',
2789 prop: 'onChange'
2790 }, {
2791 alt: 'onFocus',
2792 prop: 'onFocus'
2793 }, {
2794 alt: 'onKeyDown',
2795 prop: 'onKeyDown'
2796 }];
2797 var sizeType = propTypes$b.exports.oneOf(SIZES);
2798
2799 /**
2800 * Allows additional warnings or messaging related to prop validation.
2801 */
2802 function checkPropType(validator, callback) {
2803 return function (props, propName, componentName) {
2804 propTypes$b.exports.checkPropTypes(_defineProperty({}, propName, validator), props, 'prop', componentName);
2805 isFunction(callback) && callback(props, propName, componentName);
2806 };
2807 }
2808 function caseSensitiveType(props) {
2809 var caseSensitive = props.caseSensitive,
2810 filterBy = props.filterBy;
2811 warn(!caseSensitive || typeof filterBy !== 'function', 'Your `filterBy` function will override the `caseSensitive` prop.');
2812 }
2813 function defaultInputValueType(props) {
2814 var defaultInputValue = props.defaultInputValue,
2815 defaultSelected = props.defaultSelected,
2816 multiple = props.multiple,
2817 selected = props.selected;
2818 var name = defaultSelected.length ? 'defaultSelected' : 'selected';
2819 warn(!(!multiple && defaultInputValue && (defaultSelected.length || selected && selected.length)), "`defaultInputValue` will be overridden by the value from `".concat(name, "`."));
2820 }
2821 function defaultSelectedType(props) {
2822 var defaultSelected = props.defaultSelected,
2823 multiple = props.multiple;
2824 warn(multiple || defaultSelected.length <= 1, 'You are passing multiple options to the `defaultSelected` prop of a ' + 'Typeahead in single-select mode. The selections will be truncated to a ' + 'single selection.');
2825 }
2826 function highlightOnlyResultType(_ref) {
2827 var allowNew = _ref.allowNew,
2828 highlightOnlyResult = _ref.highlightOnlyResult;
2829 warn(!(highlightOnlyResult && allowNew), '`highlightOnlyResult` will not work with `allowNew`.');
2830 }
2831 function ignoreDiacriticsType(props) {
2832 var filterBy = props.filterBy,
2833 ignoreDiacritics = props.ignoreDiacritics;
2834 warn(ignoreDiacritics || typeof filterBy !== 'function', 'Your `filterBy` function will override the `ignoreDiacritics` prop.');
2835 }
2836 function inputPropsType(_ref2) {
2837 var inputProps = _ref2.inputProps;
2838
2839 if (!(inputProps && Object.prototype.toString.call(inputProps) === '[object Object]')) {
2840 return;
2841 } // Blacklisted properties.
2842
2843
2844 INPUT_PROPS_BLACKLIST.forEach(function (_ref3) {
2845 var alt = _ref3.alt,
2846 prop = _ref3.prop;
2847 var msg = alt ? " Use the top-level `".concat(alt, "` prop instead.") : null;
2848 warn(!inputProps[prop], "The `".concat(prop, "` property of `inputProps` will be ignored.").concat(msg));
2849 });
2850 }
2851 function isRequiredForA11y(props, propName, componentName) {
2852 warn(props[propName] != null, "The prop `".concat(propName, "` is required to make `").concat(componentName, "` ") + 'accessible for users of assistive technologies such as screen readers.');
2853 }
2854 function labelKeyType(_ref4) {
2855 var allowNew = _ref4.allowNew,
2856 labelKey = _ref4.labelKey;
2857 warn(!(isFunction(labelKey) && allowNew), '`labelKey` must be a string when `allowNew={true}`.');
2858 }
2859 var optionType = propTypes$b.exports.oneOfType([propTypes$b.exports.object, propTypes$b.exports.string]);
2860 function selectedType(_ref5) {
2861 var multiple = _ref5.multiple,
2862 onChange = _ref5.onChange,
2863 selected = _ref5.selected;
2864 warn(multiple || !selected || selected.length <= 1, 'You are passing multiple options to the `selected` prop of a Typeahead ' + 'in single-select mode. This may lead to unexpected behaviors or errors.');
2865 warn(!selected || selected && isFunction(onChange), 'You provided a `selected` prop without an `onChange` handler. If you ' + 'want the typeahead to be uncontrolled, use `defaultSelected`. ' + 'Otherwise, set `onChange`.');
2866 }
2867
2868 var _excluded$c = ["allowNew", "delay", "emptyLabel", "isLoading", "minLength", "onInputChange", "onSearch", "options", "promptText", "searchText", "useCache"];
2869 var propTypes$a = {
2870 /**
2871 * Delay, in milliseconds, before performing search.
2872 */
2873 delay: propTypes$b.exports.number,
2874
2875 /**
2876 * Whether or not a request is currently pending. Necessary for the
2877 * container to know when new results are available.
2878 */
2879 isLoading: propTypes$b.exports.bool.isRequired,
2880
2881 /**
2882 * Number of input characters that must be entered before showing results.
2883 */
2884 minLength: propTypes$b.exports.number,
2885
2886 /**
2887 * Callback to perform when the search is executed.
2888 */
2889 onSearch: propTypes$b.exports.func.isRequired,
2890
2891 /**
2892 * Options to be passed to the typeahead. Will typically be the query
2893 * results, but can also be initial default options.
2894 */
2895 options: propTypes$b.exports.arrayOf(optionType),
2896
2897 /**
2898 * Message displayed in the menu when there is no user input.
2899 */
2900 promptText: propTypes$b.exports.node,
2901
2902 /**
2903 * Message displayed in the menu while the request is pending.
2904 */
2905 searchText: propTypes$b.exports.node,
2906
2907 /**
2908 * Whether or not the component should cache query results.
2909 */
2910 useCache: propTypes$b.exports.bool
2911 };
2912
2913 /**
2914 * Logic that encapsulates common behavior and functionality around
2915 * asynchronous searches, including:
2916 *
2917 * - Debouncing user input
2918 * - Optional query caching
2919 * - Search prompt and empty results behaviors
2920 */
2921 function useAsync(props) {
2922 var allowNew = props.allowNew,
2923 _props$delay = props.delay,
2924 delay = _props$delay === void 0 ? 200 : _props$delay,
2925 emptyLabel = props.emptyLabel,
2926 isLoading = props.isLoading,
2927 _props$minLength = props.minLength,
2928 minLength = _props$minLength === void 0 ? 2 : _props$minLength,
2929 onInputChange = props.onInputChange,
2930 onSearch = props.onSearch,
2931 _props$options = props.options,
2932 options = _props$options === void 0 ? [] : _props$options,
2933 _props$promptText = props.promptText,
2934 promptText = _props$promptText === void 0 ? 'Type to search...' : _props$promptText,
2935 _props$searchText = props.searchText,
2936 searchText = _props$searchText === void 0 ? 'Searching...' : _props$searchText,
2937 _props$useCache = props.useCache,
2938 useCache = _props$useCache === void 0 ? true : _props$useCache,
2939 otherProps = _objectWithoutProperties(props, _excluded$c);
2940
2941 var cacheRef = React.useRef({});
2942 var handleSearchDebouncedRef = React.useRef(null);
2943 var queryRef = React.useRef(props.defaultInputValue || '');
2944 var forceUpdate = useForceUpdate();
2945 var prevProps = usePrevious(props);
2946 var handleSearch = React.useCallback(function (query) {
2947 queryRef.current = query;
2948
2949 if (!query || minLength && query.length < minLength) {
2950 return;
2951 } // Use cached results, if applicable.
2952
2953
2954 if (useCache && cacheRef.current[query]) {
2955 // Re-render the component with the cached results.
2956 forceUpdate();
2957 return;
2958 } // Perform the search.
2959
2960
2961 onSearch(query);
2962 }, [forceUpdate, minLength, onSearch, useCache]); // Set the debounced search function.
2963
2964 React.useEffect(function () {
2965 handleSearchDebouncedRef.current = lodash_debounce(handleSearch, delay);
2966 return function () {
2967 handleSearchDebouncedRef.current && handleSearchDebouncedRef.current.cancel();
2968 };
2969 }, [delay, handleSearch]);
2970 React.useEffect(function () {
2971 // Ensure that we've gone from a loading to a completed state. Otherwise
2972 // an empty response could get cached if the component updates during the
2973 // request (eg: if the parent re-renders for some reason).
2974 if (!isLoading && prevProps && prevProps.isLoading && useCache) {
2975 cacheRef.current[queryRef.current] = options;
2976 }
2977 });
2978
2979 var getEmptyLabel = function getEmptyLabel() {
2980 if (!queryRef.current.length) {
2981 return promptText;
2982 }
2983
2984 if (isLoading) {
2985 return searchText;
2986 }
2987
2988 return emptyLabel;
2989 };
2990
2991 var handleInputChange = React.useCallback(function (query, e) {
2992 onInputChange && onInputChange(query, e);
2993 handleSearchDebouncedRef.current && handleSearchDebouncedRef.current(query);
2994 }, [onInputChange]);
2995 var cachedQuery = cacheRef.current[queryRef.current];
2996 return _objectSpread2(_objectSpread2({}, otherProps), {}, {
2997 // Disable custom selections during a search if `allowNew` isn't a function.
2998 allowNew: isFunction(allowNew) ? allowNew : allowNew && !isLoading,
2999 emptyLabel: getEmptyLabel(),
3000 isLoading: isLoading,
3001 minLength: minLength,
3002 onInputChange: handleInputChange,
3003 options: useCache && cachedQuery ? cachedQuery : options
3004 });
3005 }
3006 function withAsync(Component) {
3007 var AsyncTypeahead = /*#__PURE__*/React.forwardRef(function (props, ref) {
3008 return /*#__PURE__*/React__default["default"].createElement(Component, _extends({}, props, useAsync(props), {
3009 ref: ref
3010 }));
3011 });
3012 AsyncTypeahead.displayName = "withAsync(".concat(getDisplayName(Component), ")"); // @ts-ignore
3013
3014 AsyncTypeahead.propTypes = propTypes$a;
3015 return AsyncTypeahead;
3016 }
3017
3018 /* eslint-disable no-bitwise, no-cond-assign */
3019
3020 /**
3021 * Checks if an element contains another given element.
3022 *
3023 * @param context the context element
3024 * @param node the element to check
3025 */
3026 function contains$1(context, node) {
3027 // HTML DOM and SVG DOM may have different support levels,
3028 // so we need to check on context instead of a document root element.
3029 if (context.contains) return context.contains(node);
3030 if (context.compareDocumentPosition) return context === node || !!(context.compareDocumentPosition(node) & 16);
3031 }
3032
3033 var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
3034
3035 /* eslint-disable no-return-assign */
3036 var optionsSupported = false;
3037 var onceSupported = false;
3038
3039 try {
3040 var options = {
3041 get passive() {
3042 return optionsSupported = true;
3043 },
3044
3045 get once() {
3046 // eslint-disable-next-line no-multi-assign
3047 return onceSupported = optionsSupported = true;
3048 }
3049
3050 };
3051
3052 if (canUseDOM) {
3053 window.addEventListener('test', options, options);
3054 window.removeEventListener('test', options, true);
3055 }
3056 } catch (e) {
3057 /* */
3058 }
3059
3060 /**
3061 * An `addEventListener` ponyfill, supports the `once` option
3062 *
3063 * @param node the element
3064 * @param eventName the event name
3065 * @param handle the handler
3066 * @param options event options
3067 */
3068 function addEventListener(node, eventName, handler, options) {
3069 if (options && typeof options !== 'boolean' && !onceSupported) {
3070 var once = options.once,
3071 capture = options.capture;
3072 var wrappedHandler = handler;
3073
3074 if (!onceSupported && once) {
3075 wrappedHandler = handler.__once || function onceHandler(event) {
3076 this.removeEventListener(eventName, onceHandler, capture);
3077 handler.call(this, event);
3078 };
3079
3080 handler.__once = wrappedHandler;
3081 }
3082
3083 node.addEventListener(eventName, wrappedHandler, optionsSupported ? options : capture);
3084 }
3085
3086 node.addEventListener(eventName, handler, options);
3087 }
3088
3089 /**
3090 * A `removeEventListener` ponyfill
3091 *
3092 * @param node the element
3093 * @param eventName the event name
3094 * @param handle the handler
3095 * @param options event options
3096 */
3097 function removeEventListener(node, eventName, handler, options) {
3098 var capture = options && typeof options !== 'boolean' ? options.capture : options;
3099 node.removeEventListener(eventName, handler, capture);
3100
3101 if (handler.__once) {
3102 node.removeEventListener(eventName, handler.__once, capture);
3103 }
3104 }
3105
3106 function listen(node, eventName, handler, options) {
3107 addEventListener(node, eventName, handler, options);
3108 return function () {
3109 removeEventListener(node, eventName, handler, options);
3110 };
3111 }
3112
3113 /**
3114 * Creates a `Ref` whose value is updated in an effect, ensuring the most recent
3115 * value is the one rendered with. Generally only required for Concurrent mode usage
3116 * where previous work in `render()` may be discarded before being used.
3117 *
3118 * This is safe to access in an event handler.
3119 *
3120 * @param value The `Ref` value
3121 */
3122
3123 function useCommittedRef(value) {
3124 var ref = React.useRef(value);
3125 React.useEffect(function () {
3126 ref.current = value;
3127 }, [value]);
3128 return ref;
3129 }
3130
3131 function useEventCallback(fn) {
3132 var ref = useCommittedRef(fn);
3133 return React.useCallback(function () {
3134 return ref.current && ref.current.apply(ref, arguments);
3135 }, [ref]);
3136 }
3137
3138 /**
3139 * Returns the owner document of a given element.
3140 *
3141 * @param node the element
3142 */
3143 function ownerDocument$1(node) {
3144 return node && node.ownerDocument || document;
3145 }
3146
3147 function safeFindDOMNode(componentOrElement) {
3148 if (componentOrElement && 'setState' in componentOrElement) {
3149 return ReactDOM__default["default"].findDOMNode(componentOrElement);
3150 }
3151
3152 return componentOrElement != null ? componentOrElement : null;
3153 }
3154
3155 var ownerDocument = (function (componentOrElement) {
3156 return ownerDocument$1(safeFindDOMNode(componentOrElement));
3157 });
3158
3159 var escapeKeyCode = 27;
3160
3161 var noop = function noop() {};
3162
3163 function isLeftClickEvent(event) {
3164 return event.button === 0;
3165 }
3166
3167 function isModifiedEvent(event) {
3168 return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
3169 }
3170
3171 var getRefTarget = function getRefTarget(ref) {
3172 return ref && ('current' in ref ? ref.current : ref);
3173 };
3174
3175 /**
3176 * The `useRootClose` hook registers your callback on the document
3177 * when rendered. Powers the `<Overlay/>` component. This is used achieve modal
3178 * style behavior where your callback is triggered when the user tries to
3179 * interact with the rest of the document or hits the `esc` key.
3180 *
3181 * @param {Ref<HTMLElement>| HTMLElement} ref The element boundary
3182 * @param {function} onRootClose
3183 * @param {object=} options
3184 * @param {boolean=} options.disabled
3185 * @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on
3186 */
3187 function useRootClose(ref, onRootClose, _temp) {
3188 var _ref = _temp === void 0 ? {} : _temp,
3189 disabled = _ref.disabled,
3190 _ref$clickTrigger = _ref.clickTrigger,
3191 clickTrigger = _ref$clickTrigger === void 0 ? 'click' : _ref$clickTrigger;
3192
3193 var preventMouseRootCloseRef = React.useRef(false);
3194 var onClose = onRootClose || noop;
3195 var handleMouseCapture = React.useCallback(function (e) {
3196 var _e$composedPath$;
3197
3198 var currentTarget = getRefTarget(ref);
3199 warning_1(!!currentTarget, 'RootClose captured a close event but does not have a ref to compare it to. ' + 'useRootClose(), should be passed a ref that resolves to a DOM node');
3200 preventMouseRootCloseRef.current = !currentTarget || isModifiedEvent(e) || !isLeftClickEvent(e) || !!contains$1(currentTarget, (_e$composedPath$ = e.composedPath == null ? void 0 : e.composedPath()[0]) != null ? _e$composedPath$ : e.target);
3201 }, [ref]);
3202 var handleMouse = useEventCallback(function (e) {
3203 if (!preventMouseRootCloseRef.current) {
3204 onClose(e);
3205 }
3206 });
3207 var handleKeyUp = useEventCallback(function (e) {
3208 if (e.keyCode === escapeKeyCode) {
3209 onClose(e);
3210 }
3211 });
3212 React.useEffect(function () {
3213 if (disabled || ref == null) return undefined; // Store the current event to avoid triggering handlers immediately
3214 // https://github.com/facebook/react/issues/20074
3215
3216 var currentEvent = window.event;
3217 var doc = ownerDocument(getRefTarget(ref)); // Use capture for this listener so it fires before React's listener, to
3218 // avoid false positives in the contains() check below if the target DOM
3219 // element is removed in the React mouse callback.
3220
3221 var removeMouseCaptureListener = listen(doc, clickTrigger, handleMouseCapture, true);
3222 var removeMouseListener = listen(doc, clickTrigger, function (e) {
3223 // skip if this event is the same as the one running when we added the handlers
3224 if (e === currentEvent) {
3225 currentEvent = undefined;
3226 return;
3227 }
3228
3229 handleMouse(e);
3230 });
3231 var removeKeyupListener = listen(doc, 'keyup', function (e) {
3232 // skip if this event is the same as the one running when we added the handlers
3233 if (e === currentEvent) {
3234 currentEvent = undefined;
3235 return;
3236 }
3237
3238 handleKeyUp(e);
3239 });
3240 var mobileSafariHackListeners = [];
3241
3242 if ('ontouchstart' in doc.documentElement) {
3243 mobileSafariHackListeners = [].slice.call(doc.body.children).map(function (el) {
3244 return listen(el, 'mousemove', noop);
3245 });
3246 }
3247
3248 return function () {
3249 removeMouseCaptureListener();
3250 removeMouseListener();
3251 removeKeyupListener();
3252 mobileSafariHackListeners.forEach(function (remove) {
3253 return remove();
3254 });
3255 };
3256 }, [ref, disabled, clickTrigger, handleMouseCapture, handleMouse, handleKeyUp]);
3257 }
3258
3259 var defaultContext = {
3260 activeIndex: -1,
3261 hintText: '',
3262 id: '',
3263 initialItem: null,
3264 inputNode: null,
3265 isOnlyResult: false,
3266 onActiveItemChange: noop$1,
3267 onAdd: noop$1,
3268 onInitialItemChange: noop$1,
3269 onMenuItemClick: noop$1,
3270 setItem: noop$1
3271 };
3272 var TypeaheadContext = /*#__PURE__*/React.createContext(defaultContext);
3273 var useTypeaheadContext = function useTypeaheadContext() {
3274 return React.useContext(TypeaheadContext);
3275 };
3276
3277 var inputPropKeys = ['activeIndex', 'disabled', 'id', 'inputRef', 'isFocused', 'isMenuShown', 'multiple', 'onBlur', 'onChange', 'onClick', 'onFocus', 'onKeyDown', 'placeholder'];
3278 var propKeys = ['activeIndex', 'hideMenu', 'isMenuShown', 'labelKey', 'onClear', 'onHide', 'onRemove', 'results', 'selected', 'text', 'toggleMenu'];
3279 var contextKeys = ['activeIndex', 'id', 'initialItem', 'inputNode', 'onActiveItemChange', 'onAdd', 'onInitialItemChange', 'onMenuItemClick', 'setItem'];
3280
3281 var TypeaheadManager = function TypeaheadManager(props) {
3282 var allowNew = props.allowNew,
3283 children = props.children,
3284 initialItem = props.initialItem,
3285 isMenuShown = props.isMenuShown,
3286 onAdd = props.onAdd,
3287 onInitialItemChange = props.onInitialItemChange,
3288 onKeyDown = props.onKeyDown,
3289 onMenuToggle = props.onMenuToggle,
3290 results = props.results,
3291 selectHint = props.selectHint;
3292 var hintText = getHintText(props);
3293 React.useEffect(function () {
3294 // Clear the initial item when there are no results.
3295 if (!(allowNew || results.length)) {
3296 onInitialItemChange();
3297 }
3298 });
3299 var isInitialRender = React.useRef(true);
3300 React.useEffect(function () {
3301 if (isInitialRender.current) {
3302 isInitialRender.current = false;
3303 return;
3304 }
3305
3306 onMenuToggle(isMenuShown);
3307 }, [isMenuShown, onMenuToggle]);
3308
3309 var handleKeyDown = function handleKeyDown(e) {
3310 onKeyDown(e);
3311
3312 if (!initialItem) {
3313 return;
3314 }
3315
3316 var addOnlyResult = e.key === 'Enter' && getIsOnlyResult(props);
3317 var shouldSelectHint = hintText && defaultSelectHint(e, selectHint);
3318
3319 if (addOnlyResult || shouldSelectHint) {
3320 onAdd(initialItem);
3321 }
3322 };
3323
3324 var childProps = _objectSpread2(_objectSpread2({}, pick(props, propKeys)), {}, {
3325 getInputProps: getInputProps(_objectSpread2(_objectSpread2({}, pick(props, inputPropKeys)), {}, {
3326 onKeyDown: handleKeyDown,
3327 value: getInputText(props)
3328 }))
3329 });
3330
3331 var contextValue = _objectSpread2(_objectSpread2({}, pick(props, contextKeys)), {}, {
3332 hintText: hintText,
3333 isOnlyResult: getIsOnlyResult(props)
3334 });
3335
3336 return /*#__PURE__*/React__default["default"].createElement(TypeaheadContext.Provider, {
3337 value: contextValue
3338 }, isFunction(children) ? children(childProps) : children);
3339 };
3340
3341 var _excluded$b = ["onChange"];
3342 var propTypes$9 = {
3343 /**
3344 * Allows the creation of new selections on the fly. Note that any new items
3345 * will be added to the list of selections, but not the list of original
3346 * options unless handled as such by `Typeahead`'s parent.
3347 *
3348 * If a function is specified, it will be used to determine whether a custom
3349 * option should be included. The return value should be true or false.
3350 */
3351 allowNew: propTypes$b.exports.oneOfType([propTypes$b.exports.bool, propTypes$b.exports.func]),
3352
3353 /**
3354 * Autofocus the input when the component initially mounts.
3355 */
3356 autoFocus: propTypes$b.exports.bool,
3357
3358 /**
3359 * Whether or not filtering should be case-sensitive.
3360 */
3361 caseSensitive: checkPropType(propTypes$b.exports.bool, caseSensitiveType),
3362
3363 /**
3364 * The initial value displayed in the text input.
3365 */
3366 defaultInputValue: checkPropType(propTypes$b.exports.string, defaultInputValueType),
3367
3368 /**
3369 * Whether or not the menu is displayed upon initial render.
3370 */
3371 defaultOpen: propTypes$b.exports.bool,
3372
3373 /**
3374 * Specify any pre-selected options. Use only if you want the component to
3375 * be uncontrolled.
3376 */
3377 defaultSelected: checkPropType(propTypes$b.exports.arrayOf(optionType), defaultSelectedType),
3378
3379 /**
3380 * Either an array of fields in `option` to search, or a custom filtering
3381 * callback.
3382 */
3383 filterBy: propTypes$b.exports.oneOfType([propTypes$b.exports.arrayOf(propTypes$b.exports.string.isRequired), propTypes$b.exports.func]),
3384
3385 /**
3386 * Highlights the menu item if there is only one result and allows selecting
3387 * that item by hitting enter. Does not work with `allowNew`.
3388 */
3389 highlightOnlyResult: checkPropType(propTypes$b.exports.bool, highlightOnlyResultType),
3390
3391 /**
3392 * An html id attribute, required for assistive technologies such as screen
3393 * readers.
3394 */
3395 id: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.number, propTypes$b.exports.string]), isRequiredForA11y),
3396
3397 /**
3398 * Whether the filter should ignore accents and other diacritical marks.
3399 */
3400 ignoreDiacritics: checkPropType(propTypes$b.exports.bool, ignoreDiacriticsType),
3401
3402 /**
3403 * Specify the option key to use for display or a function returning the
3404 * display string. By default, the selector will use the `label` key.
3405 */
3406 labelKey: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.string, propTypes$b.exports.func]), labelKeyType),
3407
3408 /**
3409 * Maximum number of results to display by default. Mostly done for
3410 * performance reasons so as not to render too many DOM nodes in the case of
3411 * large data sets.
3412 */
3413 maxResults: propTypes$b.exports.number,
3414
3415 /**
3416 * Number of input characters that must be entered before showing results.
3417 */
3418 minLength: propTypes$b.exports.number,
3419
3420 /**
3421 * Whether or not multiple selections are allowed.
3422 */
3423 multiple: propTypes$b.exports.bool,
3424
3425 /**
3426 * Invoked when the input is blurred. Receives an event.
3427 */
3428 onBlur: propTypes$b.exports.func,
3429
3430 /**
3431 * Invoked whenever items are added or removed. Receives an array of the
3432 * selected options.
3433 */
3434 onChange: propTypes$b.exports.func,
3435
3436 /**
3437 * Invoked when the input is focused. Receives an event.
3438 */
3439 onFocus: propTypes$b.exports.func,
3440
3441 /**
3442 * Invoked when the input value changes. Receives the string value of the
3443 * input.
3444 */
3445 onInputChange: propTypes$b.exports.func,
3446
3447 /**
3448 * Invoked when a key is pressed. Receives an event.
3449 */
3450 onKeyDown: propTypes$b.exports.func,
3451
3452 /**
3453 * Invoked when menu visibility changes.
3454 */
3455 onMenuToggle: propTypes$b.exports.func,
3456
3457 /**
3458 * Invoked when the pagination menu item is clicked. Receives an event.
3459 */
3460 onPaginate: propTypes$b.exports.func,
3461
3462 /**
3463 * Whether or not the menu should be displayed. `undefined` allows the
3464 * component to control visibility, while `true` and `false` show and hide
3465 * the menu, respectively.
3466 */
3467 open: propTypes$b.exports.bool,
3468
3469 /**
3470 * Full set of options, including pre-selected options. Must either be an
3471 * array of objects (recommended) or strings.
3472 */
3473 options: propTypes$b.exports.arrayOf(optionType).isRequired,
3474
3475 /**
3476 * Give user the ability to display additional results if the number of
3477 * results exceeds `maxResults`.
3478 */
3479 paginate: propTypes$b.exports.bool,
3480
3481 /**
3482 * The selected option(s) displayed in the input. Use this prop if you want
3483 * to control the component via its parent.
3484 */
3485 selected: checkPropType(propTypes$b.exports.arrayOf(optionType), selectedType)
3486 };
3487 var defaultProps$7 = {
3488 allowNew: false,
3489 autoFocus: false,
3490 caseSensitive: false,
3491 defaultInputValue: '',
3492 defaultOpen: false,
3493 defaultSelected: [],
3494 filterBy: [],
3495 highlightOnlyResult: false,
3496 ignoreDiacritics: true,
3497 labelKey: DEFAULT_LABELKEY,
3498 maxResults: 100,
3499 minLength: 0,
3500 multiple: false,
3501 onBlur: noop$1,
3502 onFocus: noop$1,
3503 onInputChange: noop$1,
3504 onKeyDown: noop$1,
3505 onMenuToggle: noop$1,
3506 onPaginate: noop$1,
3507 paginate: true
3508 };
3509 function getInitialState(props) {
3510 var defaultInputValue = props.defaultInputValue,
3511 defaultOpen = props.defaultOpen,
3512 defaultSelected = props.defaultSelected,
3513 maxResults = props.maxResults,
3514 multiple = props.multiple;
3515 var selected = props.selected ? props.selected.slice() : defaultSelected.slice();
3516 var text = defaultInputValue;
3517
3518 if (!multiple && selected.length) {
3519 // Set the text if an initial selection is passed in.
3520 text = getOptionLabel(selected[0], props.labelKey);
3521
3522 if (selected.length > 1) {
3523 // Limit to 1 selection in single-select mode.
3524 selected = selected.slice(0, 1);
3525 }
3526 }
3527
3528 return {
3529 activeIndex: -1,
3530 activeItem: undefined,
3531 initialItem: undefined,
3532 isFocused: false,
3533 selected: selected,
3534 showMenu: defaultOpen,
3535 shownResults: maxResults,
3536 text: text
3537 };
3538 }
3539 function clearTypeahead(state, props) {
3540 return _objectSpread2(_objectSpread2({}, getInitialState(props)), {}, {
3541 isFocused: state.isFocused,
3542 selected: [],
3543 text: ''
3544 });
3545 }
3546 function clickOrFocusInput(state) {
3547 return _objectSpread2(_objectSpread2({}, state), {}, {
3548 isFocused: true,
3549 showMenu: true
3550 });
3551 }
3552 function hideMenu(state, props) {
3553 var _getInitialState = getInitialState(props),
3554 activeIndex = _getInitialState.activeIndex,
3555 activeItem = _getInitialState.activeItem,
3556 initialItem = _getInitialState.initialItem,
3557 shownResults = _getInitialState.shownResults;
3558
3559 return _objectSpread2(_objectSpread2({}, state), {}, {
3560 activeIndex: activeIndex,
3561 activeItem: activeItem,
3562 initialItem: initialItem,
3563 showMenu: false,
3564 shownResults: shownResults
3565 });
3566 }
3567 function toggleMenu(state, props) {
3568 return state.showMenu ? hideMenu(state, props) : _objectSpread2(_objectSpread2({}, state), {}, {
3569 showMenu: true
3570 });
3571 }
3572 /**
3573 * Manually trigger the input's change event.
3574 * https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js/46012210#46012210
3575 */
3576
3577 function triggerInputChange(input, value) {
3578 var inputValue = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value');
3579 inputValue && inputValue.set && inputValue.set.call(input, value);
3580 var e = new Event('input', {
3581 bubbles: true
3582 });
3583 input.dispatchEvent(e);
3584 }
3585
3586 var Typeahead$1 = /*#__PURE__*/function (_React$Component) {
3587 _inherits(Typeahead, _React$Component);
3588
3589 var _super = _createSuper(Typeahead);
3590
3591 function Typeahead() {
3592 var _this;
3593
3594 _classCallCheck(this, Typeahead);
3595
3596 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3597 args[_key] = arguments[_key];
3598 }
3599
3600 _this = _super.call.apply(_super, [this].concat(args));
3601
3602 _defineProperty(_assertThisInitialized(_this), "state", getInitialState(_this.props));
3603
3604 _defineProperty(_assertThisInitialized(_this), "inputNode", null);
3605
3606 _defineProperty(_assertThisInitialized(_this), "isMenuShown", false);
3607
3608 _defineProperty(_assertThisInitialized(_this), "items", []);
3609
3610 _defineProperty(_assertThisInitialized(_this), "blur", function () {
3611 _this.inputNode && _this.inputNode.blur();
3612
3613 _this.hideMenu();
3614 });
3615
3616 _defineProperty(_assertThisInitialized(_this), "clear", function () {
3617 _this.setState(clearTypeahead);
3618 });
3619
3620 _defineProperty(_assertThisInitialized(_this), "focus", function () {
3621 _this.inputNode && _this.inputNode.focus();
3622 });
3623
3624 _defineProperty(_assertThisInitialized(_this), "getInput", function () {
3625 return _this.inputNode;
3626 });
3627
3628 _defineProperty(_assertThisInitialized(_this), "inputRef", function (inputNode) {
3629 _this.inputNode = inputNode;
3630 });
3631
3632 _defineProperty(_assertThisInitialized(_this), "setItem", function (item, position) {
3633 _this.items[position] = item;
3634 });
3635
3636 _defineProperty(_assertThisInitialized(_this), "hideMenu", function () {
3637 _this.setState(hideMenu);
3638 });
3639
3640 _defineProperty(_assertThisInitialized(_this), "toggleMenu", function () {
3641 _this.setState(toggleMenu);
3642 });
3643
3644 _defineProperty(_assertThisInitialized(_this), "_handleActiveIndexChange", function (activeIndex) {
3645 _this.setState(function (state) {
3646 return {
3647 activeIndex: activeIndex,
3648 activeItem: activeIndex >= 0 ? state.activeItem : undefined
3649 };
3650 });
3651 });
3652
3653 _defineProperty(_assertThisInitialized(_this), "_handleActiveItemChange", function (activeItem) {
3654 // Don't update the active item if it hasn't changed.
3655 if (!fastDeepEqual(activeItem, _this.state.activeItem)) {
3656 _this.setState({
3657 activeItem: activeItem
3658 });
3659 }
3660 });
3661
3662 _defineProperty(_assertThisInitialized(_this), "_handleBlur", function (e) {
3663 e.persist();
3664
3665 _this.setState({
3666 isFocused: false
3667 }, function () {
3668 return _this.props.onBlur(e);
3669 });
3670 });
3671
3672 _defineProperty(_assertThisInitialized(_this), "_handleChange", function (selected) {
3673 _this.props.onChange && _this.props.onChange(selected);
3674 });
3675
3676 _defineProperty(_assertThisInitialized(_this), "_handleClear", function () {
3677 _this.inputNode && triggerInputChange(_this.inputNode, '');
3678
3679 _this.setState(clearTypeahead, function () {
3680 // Change handler is automatically triggered for single selections but
3681 // not multi-selections.
3682 if (_this.props.multiple) {
3683 _this._handleChange([]);
3684 }
3685 });
3686 });
3687
3688 _defineProperty(_assertThisInitialized(_this), "_handleClick", function (e) {
3689 var _this$props$inputProp;
3690
3691 e.persist();
3692 var onClick = (_this$props$inputProp = _this.props.inputProps) === null || _this$props$inputProp === void 0 ? void 0 : _this$props$inputProp.onClick;
3693
3694 _this.setState(clickOrFocusInput, function () {
3695 return isFunction(onClick) && onClick(e);
3696 });
3697 });
3698
3699 _defineProperty(_assertThisInitialized(_this), "_handleFocus", function (e) {
3700 e.persist();
3701
3702 _this.setState(clickOrFocusInput, function () {
3703 return _this.props.onFocus(e);
3704 });
3705 });
3706
3707 _defineProperty(_assertThisInitialized(_this), "_handleInitialItemChange", function (initialItem) {
3708 // Don't update the initial item if it hasn't changed.
3709 if (!fastDeepEqual(initialItem, _this.state.initialItem)) {
3710 _this.setState({
3711 initialItem: initialItem
3712 });
3713 }
3714 });
3715
3716 _defineProperty(_assertThisInitialized(_this), "_handleInputChange", function (e) {
3717 e.persist();
3718 var text = e.currentTarget.value;
3719 var _this$props = _this.props,
3720 multiple = _this$props.multiple,
3721 onInputChange = _this$props.onInputChange; // Clear selections when the input value changes in single-select mode.
3722
3723 var shouldClearSelections = _this.state.selected.length && !multiple;
3724
3725 _this.setState(function (state, props) {
3726 var _getInitialState2 = getInitialState(props),
3727 activeIndex = _getInitialState2.activeIndex,
3728 activeItem = _getInitialState2.activeItem,
3729 shownResults = _getInitialState2.shownResults;
3730
3731 return {
3732 activeIndex: activeIndex,
3733 activeItem: activeItem,
3734 selected: shouldClearSelections ? [] : state.selected,
3735 showMenu: true,
3736 shownResults: shownResults,
3737 text: text
3738 };
3739 }, function () {
3740 onInputChange(text, e);
3741 shouldClearSelections && _this._handleChange([]);
3742 });
3743 });
3744
3745 _defineProperty(_assertThisInitialized(_this), "_handleKeyDown", function (e) {
3746 var activeItem = _this.state.activeItem; // Skip most actions when the menu is hidden.
3747
3748 if (!_this.isMenuShown) {
3749 if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
3750 _this.setState({
3751 showMenu: true
3752 });
3753 }
3754
3755 _this.props.onKeyDown(e);
3756
3757 return;
3758 }
3759
3760 switch (e.key) {
3761 case 'ArrowUp':
3762 case 'ArrowDown':
3763 // Prevent input cursor from going to the beginning when pressing up.
3764 e.preventDefault();
3765
3766 _this._handleActiveIndexChange(getUpdatedActiveIndex(_this.state.activeIndex, e.key, _this.items));
3767
3768 break;
3769
3770 case 'Enter':
3771 // Prevent form submission while menu is open.
3772 e.preventDefault();
3773 activeItem && _this._handleMenuItemSelect(activeItem, e);
3774 break;
3775
3776 case 'Escape':
3777 case 'Tab':
3778 // ESC simply hides the menu. TAB will blur the input and move focus to
3779 // the next item; hide the menu so it doesn't gain focus.
3780 _this.hideMenu();
3781
3782 break;
3783 }
3784
3785 _this.props.onKeyDown(e);
3786 });
3787
3788 _defineProperty(_assertThisInitialized(_this), "_handleMenuItemSelect", function (option, e) {
3789 if (getOptionProperty(option, 'paginationOption')) {
3790 _this._handlePaginate(e);
3791 } else {
3792 _this._handleSelectionAdd(option);
3793 }
3794 });
3795
3796 _defineProperty(_assertThisInitialized(_this), "_handlePaginate", function (e) {
3797 e.persist();
3798
3799 _this.setState(function (state, props) {
3800 return {
3801 shownResults: state.shownResults + props.maxResults
3802 };
3803 }, function () {
3804 return _this.props.onPaginate(e, _this.state.shownResults);
3805 });
3806 });
3807
3808 _defineProperty(_assertThisInitialized(_this), "_handleSelectionAdd", function (option) {
3809 var _this$props2 = _this.props,
3810 multiple = _this$props2.multiple,
3811 labelKey = _this$props2.labelKey;
3812 var selected;
3813 var selection = option;
3814 var text; // Add a unique id to the custom selection. Avoid doing this in `render` so
3815 // the id doesn't increment every time.
3816
3817 if (!isString(selection) && selection.customOption) {
3818 selection = _objectSpread2(_objectSpread2({}, selection), {}, {
3819 id: uniqueId('new-id-')
3820 });
3821 }
3822
3823 if (multiple) {
3824 // If multiple selections are allowed, add the new selection to the
3825 // existing selections.
3826 selected = _this.state.selected.concat(selection);
3827 text = '';
3828 } else {
3829 // If only a single selection is allowed, replace the existing selection
3830 // with the new one.
3831 selected = [selection];
3832 text = getOptionLabel(selection, labelKey);
3833 }
3834
3835 _this.setState(function (state, props) {
3836 return _objectSpread2(_objectSpread2({}, hideMenu(state, props)), {}, {
3837 initialItem: selection,
3838 selected: selected,
3839 text: text
3840 });
3841 }, function () {
3842 return _this._handleChange(selected);
3843 });
3844 });
3845
3846 _defineProperty(_assertThisInitialized(_this), "_handleSelectionRemove", function (selection) {
3847 var selected = _this.state.selected.filter(function (option) {
3848 return !fastDeepEqual(option, selection);
3849 }); // Make sure the input stays focused after the item is removed.
3850
3851
3852 _this.focus();
3853
3854 _this.setState(function (state, props) {
3855 return _objectSpread2(_objectSpread2({}, hideMenu(state, props)), {}, {
3856 selected: selected
3857 });
3858 }, function () {
3859 return _this._handleChange(selected);
3860 });
3861 });
3862
3863 return _this;
3864 }
3865
3866 _createClass(Typeahead, [{
3867 key: "componentDidMount",
3868 value: function componentDidMount() {
3869 this.props.autoFocus && this.focus();
3870 }
3871 }, {
3872 key: "componentDidUpdate",
3873 value: function componentDidUpdate(prevProps, prevState) {
3874 var _this$props3 = this.props,
3875 labelKey = _this$props3.labelKey,
3876 multiple = _this$props3.multiple,
3877 selected = _this$props3.selected;
3878 validateSelectedPropChange(selected, prevProps.selected); // Sync selections in state with those in props.
3879
3880 if (selected && !fastDeepEqual(selected, prevState.selected)) {
3881 this.setState({
3882 selected: selected
3883 });
3884
3885 if (!multiple) {
3886 this.setState({
3887 text: selected.length ? getOptionLabel(selected[0], labelKey) : ''
3888 });
3889 }
3890 }
3891 }
3892 }, {
3893 key: "render",
3894 value: function render() {
3895 var _this$props4 = this.props;
3896 _this$props4.onChange;
3897 var props = _objectWithoutProperties(_this$props4, _excluded$b);
3898
3899 var mergedPropsAndState = _objectSpread2(_objectSpread2({}, props), this.state);
3900
3901 var filterBy = mergedPropsAndState.filterBy,
3902 labelKey = mergedPropsAndState.labelKey,
3903 options = mergedPropsAndState.options,
3904 paginate = mergedPropsAndState.paginate,
3905 shownResults = mergedPropsAndState.shownResults,
3906 text = mergedPropsAndState.text;
3907 this.isMenuShown = isShown(mergedPropsAndState);
3908 this.items = []; // Reset items on re-render.
3909
3910 var results = [];
3911
3912 if (this.isMenuShown) {
3913 var cb = isFunction(filterBy) ? filterBy : defaultFilterBy;
3914 results = options.filter(function (option) {
3915 return cb(option, mergedPropsAndState);
3916 }); // This must come before results are truncated.
3917
3918 var shouldPaginate = paginate && results.length > shownResults; // Truncate results if necessary.
3919
3920 results = getTruncatedOptions(results, shownResults); // Add the custom option if necessary.
3921
3922 if (addCustomOption(results, mergedPropsAndState)) {
3923 results.push(_defineProperty({
3924 customOption: true
3925 }, getStringLabelKey(labelKey), text));
3926 } // Add the pagination item if necessary.
3927
3928
3929 if (shouldPaginate) {
3930 var _results$push2;
3931
3932 results.push((_results$push2 = {}, _defineProperty(_results$push2, getStringLabelKey(labelKey), ''), _defineProperty(_results$push2, "paginationOption", true), _results$push2));
3933 }
3934 }
3935
3936 return /*#__PURE__*/React__default["default"].createElement(TypeaheadManager, _extends({}, mergedPropsAndState, {
3937 hideMenu: this.hideMenu,
3938 inputNode: this.inputNode,
3939 inputRef: this.inputRef,
3940 isMenuShown: this.isMenuShown,
3941 onActiveItemChange: this._handleActiveItemChange,
3942 onAdd: this._handleSelectionAdd,
3943 onBlur: this._handleBlur,
3944 onChange: this._handleInputChange,
3945 onClear: this._handleClear,
3946 onClick: this._handleClick,
3947 onFocus: this._handleFocus,
3948 onHide: this.hideMenu,
3949 onInitialItemChange: this._handleInitialItemChange,
3950 onKeyDown: this._handleKeyDown,
3951 onMenuItemClick: this._handleMenuItemSelect,
3952 onRemove: this._handleSelectionRemove,
3953 results: results,
3954 setItem: this.setItem,
3955 toggleMenu: this.toggleMenu
3956 }));
3957 }
3958 }]);
3959
3960 return Typeahead;
3961 }(React__default["default"].Component);
3962
3963 _defineProperty(Typeahead$1, "propTypes", propTypes$9);
3964
3965 _defineProperty(Typeahead$1, "defaultProps", defaultProps$7);
3966
3967 var _excluded$a = ["className", "label", "onClick", "onKeyDown", "size"];
3968 var propTypes$8 = {
3969 label: propTypes$b.exports.string,
3970 onClick: propTypes$b.exports.func,
3971 onKeyDown: propTypes$b.exports.func,
3972 size: sizeType
3973 };
3974 var defaultProps$6 = {
3975 label: 'Clear'
3976 };
3977
3978 /**
3979 * ClearButton
3980 *
3981 * http://getbootstrap.com/css/#helper-classes-close
3982 */
3983 var ClearButton = function ClearButton(_ref) {
3984 var className = _ref.className,
3985 label = _ref.label,
3986 _onClick = _ref.onClick,
3987 _onKeyDown = _ref.onKeyDown,
3988 size = _ref.size,
3989 props = _objectWithoutProperties(_ref, _excluded$a);
3990
3991 return /*#__PURE__*/React__default["default"].createElement("button", _extends({}, props, {
3992 "aria-label": label,
3993 className: cx('close', 'btn-close', 'rbt-close', {
3994 'rbt-close-lg': isSizeLarge(size),
3995 'rbt-close-sm': isSizeSmall(size)
3996 }, className),
3997 onClick: function onClick(e) {
3998 e.stopPropagation();
3999 _onClick && _onClick(e);
4000 },
4001 onKeyDown: function onKeyDown(e) {
4002 // Prevent browser from navigating back.
4003 if (e.key === 'Backspace') {
4004 e.preventDefault();
4005 }
4006
4007 _onKeyDown && _onKeyDown(e);
4008 },
4009 type: "button"
4010 }), /*#__PURE__*/React__default["default"].createElement("span", {
4011 "aria-hidden": "true",
4012 className: "rbt-close-content"
4013 }, "\xD7"), /*#__PURE__*/React__default["default"].createElement("span", {
4014 className: "sr-only visually-hidden"
4015 }, label));
4016 };
4017
4018 ClearButton.propTypes = propTypes$8;
4019 ClearButton.defaultProps = defaultProps$6;
4020
4021 var propTypes$7 = {
4022 label: propTypes$b.exports.string
4023 };
4024 var defaultProps$5 = {
4025 label: 'Loading...'
4026 };
4027
4028 var Loader = function Loader(_ref) {
4029 var label = _ref.label;
4030 return /*#__PURE__*/React__default["default"].createElement("div", {
4031 className: "rbt-loader spinner-border spinner-border-sm",
4032 role: "status"
4033 }, /*#__PURE__*/React__default["default"].createElement("span", {
4034 className: "sr-only visually-hidden"
4035 }, label));
4036 };
4037
4038 Loader.propTypes = propTypes$7;
4039 Loader.defaultProps = defaultProps$5;
4040
4041 React__namespace.createContext();
4042 React__namespace.createContext();
4043
4044 /**
4045 * Simple ponyfill for Object.fromEntries
4046 */
4047
4048 var fromEntries = function fromEntries(entries) {
4049 return entries.reduce(function (acc, _ref) {
4050 var key = _ref[0],
4051 value = _ref[1];
4052 acc[key] = value;
4053 return acc;
4054 }, {});
4055 };
4056 /**
4057 * Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
4058 */
4059
4060 var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? React__namespace.useLayoutEffect : React__namespace.useEffect;
4061
4062 var top = 'top';
4063 var bottom = 'bottom';
4064 var right = 'right';
4065 var left = 'left';
4066 var auto = 'auto';
4067 var basePlacements = [top, bottom, right, left];
4068 var start = 'start';
4069 var end = 'end';
4070 var clippingParents = 'clippingParents';
4071 var viewport = 'viewport';
4072 var popper = 'popper';
4073 var reference = 'reference';
4074 var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
4075 return acc.concat([placement + "-" + start, placement + "-" + end]);
4076 }, []);
4077 var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
4078 return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
4079 }, []); // modifiers that need to read the DOM
4080
4081 var beforeRead = 'beforeRead';
4082 var read = 'read';
4083 var afterRead = 'afterRead'; // pure-logic modifiers
4084
4085 var beforeMain = 'beforeMain';
4086 var main = 'main';
4087 var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
4088
4089 var beforeWrite = 'beforeWrite';
4090 var write = 'write';
4091 var afterWrite = 'afterWrite';
4092 var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
4093
4094 function getNodeName(element) {
4095 return element ? (element.nodeName || '').toLowerCase() : null;
4096 }
4097
4098 function getWindow(node) {
4099 if (node == null) {
4100 return window;
4101 }
4102
4103 if (node.toString() !== '[object Window]') {
4104 var ownerDocument = node.ownerDocument;
4105 return ownerDocument ? ownerDocument.defaultView || window : window;
4106 }
4107
4108 return node;
4109 }
4110
4111 function isElement(node) {
4112 var OwnElement = getWindow(node).Element;
4113 return node instanceof OwnElement || node instanceof Element;
4114 }
4115
4116 function isHTMLElement(node) {
4117 var OwnElement = getWindow(node).HTMLElement;
4118 return node instanceof OwnElement || node instanceof HTMLElement;
4119 }
4120
4121 function isShadowRoot(node) {
4122 // IE 11 has no ShadowRoot
4123 if (typeof ShadowRoot === 'undefined') {
4124 return false;
4125 }
4126
4127 var OwnElement = getWindow(node).ShadowRoot;
4128 return node instanceof OwnElement || node instanceof ShadowRoot;
4129 }
4130
4131 // and applies them to the HTMLElements such as popper and arrow
4132
4133 function applyStyles(_ref) {
4134 var state = _ref.state;
4135 Object.keys(state.elements).forEach(function (name) {
4136 var style = state.styles[name] || {};
4137 var attributes = state.attributes[name] || {};
4138 var element = state.elements[name]; // arrow is optional + virtual elements
4139
4140 if (!isHTMLElement(element) || !getNodeName(element)) {
4141 return;
4142 } // Flow doesn't support to extend this property, but it's the most
4143 // effective way to apply styles to an HTMLElement
4144 // $FlowFixMe[cannot-write]
4145
4146
4147 Object.assign(element.style, style);
4148 Object.keys(attributes).forEach(function (name) {
4149 var value = attributes[name];
4150
4151 if (value === false) {
4152 element.removeAttribute(name);
4153 } else {
4154 element.setAttribute(name, value === true ? '' : value);
4155 }
4156 });
4157 });
4158 }
4159
4160 function effect$2(_ref2) {
4161 var state = _ref2.state;
4162 var initialStyles = {
4163 popper: {
4164 position: state.options.strategy,
4165 left: '0',
4166 top: '0',
4167 margin: '0'
4168 },
4169 arrow: {
4170 position: 'absolute'
4171 },
4172 reference: {}
4173 };
4174 Object.assign(state.elements.popper.style, initialStyles.popper);
4175 state.styles = initialStyles;
4176
4177 if (state.elements.arrow) {
4178 Object.assign(state.elements.arrow.style, initialStyles.arrow);
4179 }
4180
4181 return function () {
4182 Object.keys(state.elements).forEach(function (name) {
4183 var element = state.elements[name];
4184 var attributes = state.attributes[name] || {};
4185 var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
4186
4187 var style = styleProperties.reduce(function (style, property) {
4188 style[property] = '';
4189 return style;
4190 }, {}); // arrow is optional + virtual elements
4191
4192 if (!isHTMLElement(element) || !getNodeName(element)) {
4193 return;
4194 }
4195
4196 Object.assign(element.style, style);
4197 Object.keys(attributes).forEach(function (attribute) {
4198 element.removeAttribute(attribute);
4199 });
4200 });
4201 };
4202 } // eslint-disable-next-line import/no-unused-modules
4203
4204
4205 var applyStyles$1 = {
4206 name: 'applyStyles',
4207 enabled: true,
4208 phase: 'write',
4209 fn: applyStyles,
4210 effect: effect$2,
4211 requires: ['computeStyles']
4212 };
4213
4214 function getBasePlacement(placement) {
4215 return placement.split('-')[0];
4216 }
4217
4218 var max = Math.max;
4219 var min = Math.min;
4220 var round = Math.round;
4221
4222 function getBoundingClientRect(element, includeScale) {
4223 if (includeScale === void 0) {
4224 includeScale = false;
4225 }
4226
4227 var rect = element.getBoundingClientRect();
4228 var scaleX = 1;
4229 var scaleY = 1;
4230
4231 if (isHTMLElement(element) && includeScale) {
4232 var offsetHeight = element.offsetHeight;
4233 var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
4234 // Fallback to 1 in case both values are `0`
4235
4236 if (offsetWidth > 0) {
4237 scaleX = round(rect.width) / offsetWidth || 1;
4238 }
4239
4240 if (offsetHeight > 0) {
4241 scaleY = round(rect.height) / offsetHeight || 1;
4242 }
4243 }
4244
4245 return {
4246 width: rect.width / scaleX,
4247 height: rect.height / scaleY,
4248 top: rect.top / scaleY,
4249 right: rect.right / scaleX,
4250 bottom: rect.bottom / scaleY,
4251 left: rect.left / scaleX,
4252 x: rect.left / scaleX,
4253 y: rect.top / scaleY
4254 };
4255 }
4256
4257 // means it doesn't take into account transforms.
4258
4259 function getLayoutRect(element) {
4260 var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
4261 // Fixes https://github.com/popperjs/popper-core/issues/1223
4262
4263 var width = element.offsetWidth;
4264 var height = element.offsetHeight;
4265
4266 if (Math.abs(clientRect.width - width) <= 1) {
4267 width = clientRect.width;
4268 }
4269
4270 if (Math.abs(clientRect.height - height) <= 1) {
4271 height = clientRect.height;
4272 }
4273
4274 return {
4275 x: element.offsetLeft,
4276 y: element.offsetTop,
4277 width: width,
4278 height: height
4279 };
4280 }
4281
4282 function contains(parent, child) {
4283 var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
4284
4285 if (parent.contains(child)) {
4286 return true;
4287 } // then fallback to custom implementation with Shadow DOM support
4288 else if (rootNode && isShadowRoot(rootNode)) {
4289 var next = child;
4290
4291 do {
4292 if (next && parent.isSameNode(next)) {
4293 return true;
4294 } // $FlowFixMe[prop-missing]: need a better way to handle this...
4295
4296
4297 next = next.parentNode || next.host;
4298 } while (next);
4299 } // Give up, the result is false
4300
4301
4302 return false;
4303 }
4304
4305 function getComputedStyle$1(element) {
4306 return getWindow(element).getComputedStyle(element);
4307 }
4308
4309 function isTableElement(element) {
4310 return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
4311 }
4312
4313 function getDocumentElement(element) {
4314 // $FlowFixMe[incompatible-return]: assume body is always available
4315 return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
4316 element.document) || window.document).documentElement;
4317 }
4318
4319 function getParentNode(element) {
4320 if (getNodeName(element) === 'html') {
4321 return element;
4322 }
4323
4324 return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
4325 // $FlowFixMe[incompatible-return]
4326 // $FlowFixMe[prop-missing]
4327 element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
4328 element.parentNode || ( // DOM Element detected
4329 isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
4330 // $FlowFixMe[incompatible-call]: HTMLElement is a Node
4331 getDocumentElement(element) // fallback
4332
4333 );
4334 }
4335
4336 function getTrueOffsetParent(element) {
4337 if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
4338 getComputedStyle$1(element).position === 'fixed') {
4339 return null;
4340 }
4341
4342 return element.offsetParent;
4343 } // `.offsetParent` reports `null` for fixed elements, while absolute elements
4344 // return the containing block
4345
4346
4347 function getContainingBlock(element) {
4348 var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
4349 var isIE = navigator.userAgent.indexOf('Trident') !== -1;
4350
4351 if (isIE && isHTMLElement(element)) {
4352 // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
4353 var elementCss = getComputedStyle$1(element);
4354
4355 if (elementCss.position === 'fixed') {
4356 return null;
4357 }
4358 }
4359
4360 var currentNode = getParentNode(element);
4361
4362 while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
4363 var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that
4364 // create a containing block.
4365 // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
4366
4367 if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
4368 return currentNode;
4369 } else {
4370 currentNode = currentNode.parentNode;
4371 }
4372 }
4373
4374 return null;
4375 } // Gets the closest ancestor positioned element. Handles some edge cases,
4376 // such as table ancestors and cross browser bugs.
4377
4378
4379 function getOffsetParent(element) {
4380 var window = getWindow(element);
4381 var offsetParent = getTrueOffsetParent(element);
4382
4383 while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
4384 offsetParent = getTrueOffsetParent(offsetParent);
4385 }
4386
4387 if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) {
4388 return window;
4389 }
4390
4391 return offsetParent || getContainingBlock(element) || window;
4392 }
4393
4394 function getMainAxisFromPlacement(placement) {
4395 return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
4396 }
4397
4398 function within(min$1, value, max$1) {
4399 return max(min$1, min(value, max$1));
4400 }
4401 function withinMaxClamp(min, value, max) {
4402 var v = within(min, value, max);
4403 return v > max ? max : v;
4404 }
4405
4406 function getFreshSideObject() {
4407 return {
4408 top: 0,
4409 right: 0,
4410 bottom: 0,
4411 left: 0
4412 };
4413 }
4414
4415 function mergePaddingObject(paddingObject) {
4416 return Object.assign({}, getFreshSideObject(), paddingObject);
4417 }
4418
4419 function expandToHashMap(value, keys) {
4420 return keys.reduce(function (hashMap, key) {
4421 hashMap[key] = value;
4422 return hashMap;
4423 }, {});
4424 }
4425
4426 var toPaddingObject = function toPaddingObject(padding, state) {
4427 padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
4428 placement: state.placement
4429 })) : padding;
4430 return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
4431 };
4432
4433 function arrow(_ref) {
4434 var _state$modifiersData$;
4435
4436 var state = _ref.state,
4437 name = _ref.name,
4438 options = _ref.options;
4439 var arrowElement = state.elements.arrow;
4440 var popperOffsets = state.modifiersData.popperOffsets;
4441 var basePlacement = getBasePlacement(state.placement);
4442 var axis = getMainAxisFromPlacement(basePlacement);
4443 var isVertical = [left, right].indexOf(basePlacement) >= 0;
4444 var len = isVertical ? 'height' : 'width';
4445
4446 if (!arrowElement || !popperOffsets) {
4447 return;
4448 }
4449
4450 var paddingObject = toPaddingObject(options.padding, state);
4451 var arrowRect = getLayoutRect(arrowElement);
4452 var minProp = axis === 'y' ? top : left;
4453 var maxProp = axis === 'y' ? bottom : right;
4454 var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
4455 var startDiff = popperOffsets[axis] - state.rects.reference[axis];
4456 var arrowOffsetParent = getOffsetParent(arrowElement);
4457 var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
4458 var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
4459 // outside of the popper bounds
4460
4461 var min = paddingObject[minProp];
4462 var max = clientSize - arrowRect[len] - paddingObject[maxProp];
4463 var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
4464 var offset = within(min, center, max); // Prevents breaking syntax highlighting...
4465
4466 var axisProp = axis;
4467 state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
4468 }
4469
4470 function effect$1(_ref2) {
4471 var state = _ref2.state,
4472 options = _ref2.options;
4473 var _options$element = options.element,
4474 arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
4475
4476 if (arrowElement == null) {
4477 return;
4478 } // CSS selector
4479
4480
4481 if (typeof arrowElement === 'string') {
4482 arrowElement = state.elements.popper.querySelector(arrowElement);
4483
4484 if (!arrowElement) {
4485 return;
4486 }
4487 }
4488
4489 {
4490 if (!isHTMLElement(arrowElement)) {
4491 console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
4492 }
4493 }
4494
4495 if (!contains(state.elements.popper, arrowElement)) {
4496 {
4497 console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
4498 }
4499
4500 return;
4501 }
4502
4503 state.elements.arrow = arrowElement;
4504 } // eslint-disable-next-line import/no-unused-modules
4505
4506
4507 var arrow$1 = {
4508 name: 'arrow',
4509 enabled: true,
4510 phase: 'main',
4511 fn: arrow,
4512 effect: effect$1,
4513 requires: ['popperOffsets'],
4514 requiresIfExists: ['preventOverflow']
4515 };
4516
4517 function getVariation(placement) {
4518 return placement.split('-')[1];
4519 }
4520
4521 var unsetSides = {
4522 top: 'auto',
4523 right: 'auto',
4524 bottom: 'auto',
4525 left: 'auto'
4526 }; // Round the offsets to the nearest suitable subpixel based on the DPR.
4527 // Zooming can change the DPR, but it seems to report a value that will
4528 // cleanly divide the values into the appropriate subpixels.
4529
4530 function roundOffsetsByDPR(_ref) {
4531 var x = _ref.x,
4532 y = _ref.y;
4533 var win = window;
4534 var dpr = win.devicePixelRatio || 1;
4535 return {
4536 x: round(x * dpr) / dpr || 0,
4537 y: round(y * dpr) / dpr || 0
4538 };
4539 }
4540
4541 function mapToStyles(_ref2) {
4542 var _Object$assign2;
4543
4544 var popper = _ref2.popper,
4545 popperRect = _ref2.popperRect,
4546 placement = _ref2.placement,
4547 variation = _ref2.variation,
4548 offsets = _ref2.offsets,
4549 position = _ref2.position,
4550 gpuAcceleration = _ref2.gpuAcceleration,
4551 adaptive = _ref2.adaptive,
4552 roundOffsets = _ref2.roundOffsets,
4553 isFixed = _ref2.isFixed;
4554 var _offsets$x = offsets.x,
4555 x = _offsets$x === void 0 ? 0 : _offsets$x,
4556 _offsets$y = offsets.y,
4557 y = _offsets$y === void 0 ? 0 : _offsets$y;
4558
4559 var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
4560 x: x,
4561 y: y
4562 }) : {
4563 x: x,
4564 y: y
4565 };
4566
4567 x = _ref3.x;
4568 y = _ref3.y;
4569 var hasX = offsets.hasOwnProperty('x');
4570 var hasY = offsets.hasOwnProperty('y');
4571 var sideX = left;
4572 var sideY = top;
4573 var win = window;
4574
4575 if (adaptive) {
4576 var offsetParent = getOffsetParent(popper);
4577 var heightProp = 'clientHeight';
4578 var widthProp = 'clientWidth';
4579
4580 if (offsetParent === getWindow(popper)) {
4581 offsetParent = getDocumentElement(popper);
4582
4583 if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
4584 heightProp = 'scrollHeight';
4585 widthProp = 'scrollWidth';
4586 }
4587 } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
4588
4589
4590 offsetParent = offsetParent;
4591
4592 if (placement === top || (placement === left || placement === right) && variation === end) {
4593 sideY = bottom;
4594 var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
4595 offsetParent[heightProp];
4596 y -= offsetY - popperRect.height;
4597 y *= gpuAcceleration ? 1 : -1;
4598 }
4599
4600 if (placement === left || (placement === top || placement === bottom) && variation === end) {
4601 sideX = right;
4602 var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
4603 offsetParent[widthProp];
4604 x -= offsetX - popperRect.width;
4605 x *= gpuAcceleration ? 1 : -1;
4606 }
4607 }
4608
4609 var commonStyles = Object.assign({
4610 position: position
4611 }, adaptive && unsetSides);
4612
4613 var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
4614 x: x,
4615 y: y
4616 }) : {
4617 x: x,
4618 y: y
4619 };
4620
4621 x = _ref4.x;
4622 y = _ref4.y;
4623
4624 if (gpuAcceleration) {
4625 var _Object$assign;
4626
4627 return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
4628 }
4629
4630 return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
4631 }
4632
4633 function computeStyles(_ref5) {
4634 var state = _ref5.state,
4635 options = _ref5.options;
4636 var _options$gpuAccelerat = options.gpuAcceleration,
4637 gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
4638 _options$adaptive = options.adaptive,
4639 adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
4640 _options$roundOffsets = options.roundOffsets,
4641 roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
4642
4643 {
4644 var transitionProperty = getComputedStyle$1(state.elements.popper).transitionProperty || '';
4645
4646 if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
4647 return transitionProperty.indexOf(property) >= 0;
4648 })) {
4649 console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
4650 }
4651 }
4652
4653 var commonStyles = {
4654 placement: getBasePlacement(state.placement),
4655 variation: getVariation(state.placement),
4656 popper: state.elements.popper,
4657 popperRect: state.rects.popper,
4658 gpuAcceleration: gpuAcceleration,
4659 isFixed: state.options.strategy === 'fixed'
4660 };
4661
4662 if (state.modifiersData.popperOffsets != null) {
4663 state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
4664 offsets: state.modifiersData.popperOffsets,
4665 position: state.options.strategy,
4666 adaptive: adaptive,
4667 roundOffsets: roundOffsets
4668 })));
4669 }
4670
4671 if (state.modifiersData.arrow != null) {
4672 state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
4673 offsets: state.modifiersData.arrow,
4674 position: 'absolute',
4675 adaptive: false,
4676 roundOffsets: roundOffsets
4677 })));
4678 }
4679
4680 state.attributes.popper = Object.assign({}, state.attributes.popper, {
4681 'data-popper-placement': state.placement
4682 });
4683 } // eslint-disable-next-line import/no-unused-modules
4684
4685
4686 var computeStyles$1 = {
4687 name: 'computeStyles',
4688 enabled: true,
4689 phase: 'beforeWrite',
4690 fn: computeStyles,
4691 data: {}
4692 };
4693
4694 var passive = {
4695 passive: true
4696 };
4697
4698 function effect(_ref) {
4699 var state = _ref.state,
4700 instance = _ref.instance,
4701 options = _ref.options;
4702 var _options$scroll = options.scroll,
4703 scroll = _options$scroll === void 0 ? true : _options$scroll,
4704 _options$resize = options.resize,
4705 resize = _options$resize === void 0 ? true : _options$resize;
4706 var window = getWindow(state.elements.popper);
4707 var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
4708
4709 if (scroll) {
4710 scrollParents.forEach(function (scrollParent) {
4711 scrollParent.addEventListener('scroll', instance.update, passive);
4712 });
4713 }
4714
4715 if (resize) {
4716 window.addEventListener('resize', instance.update, passive);
4717 }
4718
4719 return function () {
4720 if (scroll) {
4721 scrollParents.forEach(function (scrollParent) {
4722 scrollParent.removeEventListener('scroll', instance.update, passive);
4723 });
4724 }
4725
4726 if (resize) {
4727 window.removeEventListener('resize', instance.update, passive);
4728 }
4729 };
4730 } // eslint-disable-next-line import/no-unused-modules
4731
4732
4733 var eventListeners = {
4734 name: 'eventListeners',
4735 enabled: true,
4736 phase: 'write',
4737 fn: function fn() {},
4738 effect: effect,
4739 data: {}
4740 };
4741
4742 var hash$1 = {
4743 left: 'right',
4744 right: 'left',
4745 bottom: 'top',
4746 top: 'bottom'
4747 };
4748 function getOppositePlacement(placement) {
4749 return placement.replace(/left|right|bottom|top/g, function (matched) {
4750 return hash$1[matched];
4751 });
4752 }
4753
4754 var hash = {
4755 start: 'end',
4756 end: 'start'
4757 };
4758 function getOppositeVariationPlacement(placement) {
4759 return placement.replace(/start|end/g, function (matched) {
4760 return hash[matched];
4761 });
4762 }
4763
4764 function getWindowScroll(node) {
4765 var win = getWindow(node);
4766 var scrollLeft = win.pageXOffset;
4767 var scrollTop = win.pageYOffset;
4768 return {
4769 scrollLeft: scrollLeft,
4770 scrollTop: scrollTop
4771 };
4772 }
4773
4774 function getWindowScrollBarX(element) {
4775 // If <html> has a CSS width greater than the viewport, then this will be
4776 // incorrect for RTL.
4777 // Popper 1 is broken in this case and never had a bug report so let's assume
4778 // it's not an issue. I don't think anyone ever specifies width on <html>
4779 // anyway.
4780 // Browsers where the left scrollbar doesn't cause an issue report `0` for
4781 // this (e.g. Edge 2019, IE11, Safari)
4782 return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
4783 }
4784
4785 function getViewportRect(element) {
4786 var win = getWindow(element);
4787 var html = getDocumentElement(element);
4788 var visualViewport = win.visualViewport;
4789 var width = html.clientWidth;
4790 var height = html.clientHeight;
4791 var x = 0;
4792 var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
4793 // can be obscured underneath it.
4794 // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
4795 // if it isn't open, so if this isn't available, the popper will be detected
4796 // to overflow the bottom of the screen too early.
4797
4798 if (visualViewport) {
4799 width = visualViewport.width;
4800 height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
4801 // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
4802 // errors due to floating point numbers, so we need to check precision.
4803 // Safari returns a number <= 0, usually < -1 when pinch-zoomed
4804 // Feature detection fails in mobile emulation mode in Chrome.
4805 // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
4806 // 0.001
4807 // Fallback here: "Not Safari" userAgent
4808
4809 if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
4810 x = visualViewport.offsetLeft;
4811 y = visualViewport.offsetTop;
4812 }
4813 }
4814
4815 return {
4816 width: width,
4817 height: height,
4818 x: x + getWindowScrollBarX(element),
4819 y: y
4820 };
4821 }
4822
4823 // of the `<html>` and `<body>` rect bounds if horizontally scrollable
4824
4825 function getDocumentRect(element) {
4826 var _element$ownerDocumen;
4827
4828 var html = getDocumentElement(element);
4829 var winScroll = getWindowScroll(element);
4830 var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
4831 var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
4832 var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
4833 var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
4834 var y = -winScroll.scrollTop;
4835
4836 if (getComputedStyle$1(body || html).direction === 'rtl') {
4837 x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
4838 }
4839
4840 return {
4841 width: width,
4842 height: height,
4843 x: x,
4844 y: y
4845 };
4846 }
4847
4848 function isScrollParent(element) {
4849 // Firefox wants us to check `-x` and `-y` variations as well
4850 var _getComputedStyle = getComputedStyle$1(element),
4851 overflow = _getComputedStyle.overflow,
4852 overflowX = _getComputedStyle.overflowX,
4853 overflowY = _getComputedStyle.overflowY;
4854
4855 return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
4856 }
4857
4858 function getScrollParent(node) {
4859 if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
4860 // $FlowFixMe[incompatible-return]: assume body is always available
4861 return node.ownerDocument.body;
4862 }
4863
4864 if (isHTMLElement(node) && isScrollParent(node)) {
4865 return node;
4866 }
4867
4868 return getScrollParent(getParentNode(node));
4869 }
4870
4871 /*
4872 given a DOM element, return the list of all scroll parents, up the list of ancesors
4873 until we get to the top window object. This list is what we attach scroll listeners
4874 to, because if any of these parent elements scroll, we'll need to re-calculate the
4875 reference element's position.
4876 */
4877
4878 function listScrollParents(element, list) {
4879 var _element$ownerDocumen;
4880
4881 if (list === void 0) {
4882 list = [];
4883 }
4884
4885 var scrollParent = getScrollParent(element);
4886 var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
4887 var win = getWindow(scrollParent);
4888 var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
4889 var updatedList = list.concat(target);
4890 return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
4891 updatedList.concat(listScrollParents(getParentNode(target)));
4892 }
4893
4894 function rectToClientRect(rect) {
4895 return Object.assign({}, rect, {
4896 left: rect.x,
4897 top: rect.y,
4898 right: rect.x + rect.width,
4899 bottom: rect.y + rect.height
4900 });
4901 }
4902
4903 function getInnerBoundingClientRect(element) {
4904 var rect = getBoundingClientRect(element);
4905 rect.top = rect.top + element.clientTop;
4906 rect.left = rect.left + element.clientLeft;
4907 rect.bottom = rect.top + element.clientHeight;
4908 rect.right = rect.left + element.clientWidth;
4909 rect.width = element.clientWidth;
4910 rect.height = element.clientHeight;
4911 rect.x = rect.left;
4912 rect.y = rect.top;
4913 return rect;
4914 }
4915
4916 function getClientRectFromMixedType(element, clippingParent) {
4917 return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
4918 } // A "clipping parent" is an overflowable container with the characteristic of
4919 // clipping (or hiding) overflowing elements with a position different from
4920 // `initial`
4921
4922
4923 function getClippingParents(element) {
4924 var clippingParents = listScrollParents(getParentNode(element));
4925 var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0;
4926 var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
4927
4928 if (!isElement(clipperElement)) {
4929 return [];
4930 } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
4931
4932
4933 return clippingParents.filter(function (clippingParent) {
4934 return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
4935 });
4936 } // Gets the maximum area that the element is visible in due to any number of
4937 // clipping parents
4938
4939
4940 function getClippingRect(element, boundary, rootBoundary) {
4941 var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
4942 var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
4943 var firstClippingParent = clippingParents[0];
4944 var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
4945 var rect = getClientRectFromMixedType(element, clippingParent);
4946 accRect.top = max(rect.top, accRect.top);
4947 accRect.right = min(rect.right, accRect.right);
4948 accRect.bottom = min(rect.bottom, accRect.bottom);
4949 accRect.left = max(rect.left, accRect.left);
4950 return accRect;
4951 }, getClientRectFromMixedType(element, firstClippingParent));
4952 clippingRect.width = clippingRect.right - clippingRect.left;
4953 clippingRect.height = clippingRect.bottom - clippingRect.top;
4954 clippingRect.x = clippingRect.left;
4955 clippingRect.y = clippingRect.top;
4956 return clippingRect;
4957 }
4958
4959 function computeOffsets(_ref) {
4960 var reference = _ref.reference,
4961 element = _ref.element,
4962 placement = _ref.placement;
4963 var basePlacement = placement ? getBasePlacement(placement) : null;
4964 var variation = placement ? getVariation(placement) : null;
4965 var commonX = reference.x + reference.width / 2 - element.width / 2;
4966 var commonY = reference.y + reference.height / 2 - element.height / 2;
4967 var offsets;
4968
4969 switch (basePlacement) {
4970 case top:
4971 offsets = {
4972 x: commonX,
4973 y: reference.y - element.height
4974 };
4975 break;
4976
4977 case bottom:
4978 offsets = {
4979 x: commonX,
4980 y: reference.y + reference.height
4981 };
4982 break;
4983
4984 case right:
4985 offsets = {
4986 x: reference.x + reference.width,
4987 y: commonY
4988 };
4989 break;
4990
4991 case left:
4992 offsets = {
4993 x: reference.x - element.width,
4994 y: commonY
4995 };
4996 break;
4997
4998 default:
4999 offsets = {
5000 x: reference.x,
5001 y: reference.y
5002 };
5003 }
5004
5005 var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
5006
5007 if (mainAxis != null) {
5008 var len = mainAxis === 'y' ? 'height' : 'width';
5009
5010 switch (variation) {
5011 case start:
5012 offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
5013 break;
5014
5015 case end:
5016 offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
5017 break;
5018 }
5019 }
5020
5021 return offsets;
5022 }
5023
5024 function detectOverflow(state, options) {
5025 if (options === void 0) {
5026 options = {};
5027 }
5028
5029 var _options = options,
5030 _options$placement = _options.placement,
5031 placement = _options$placement === void 0 ? state.placement : _options$placement,
5032 _options$boundary = _options.boundary,
5033 boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
5034 _options$rootBoundary = _options.rootBoundary,
5035 rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
5036 _options$elementConte = _options.elementContext,
5037 elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
5038 _options$altBoundary = _options.altBoundary,
5039 altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
5040 _options$padding = _options.padding,
5041 padding = _options$padding === void 0 ? 0 : _options$padding;
5042 var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
5043 var altContext = elementContext === popper ? reference : popper;
5044 var popperRect = state.rects.popper;
5045 var element = state.elements[altBoundary ? altContext : elementContext];
5046 var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
5047 var referenceClientRect = getBoundingClientRect(state.elements.reference);
5048 var popperOffsets = computeOffsets({
5049 reference: referenceClientRect,
5050 element: popperRect,
5051 strategy: 'absolute',
5052 placement: placement
5053 });
5054 var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
5055 var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
5056 // 0 or negative = within the clipping rect
5057
5058 var overflowOffsets = {
5059 top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
5060 bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
5061 left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
5062 right: elementClientRect.right - clippingClientRect.right + paddingObject.right
5063 };
5064 var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
5065
5066 if (elementContext === popper && offsetData) {
5067 var offset = offsetData[placement];
5068 Object.keys(overflowOffsets).forEach(function (key) {
5069 var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
5070 var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
5071 overflowOffsets[key] += offset[axis] * multiply;
5072 });
5073 }
5074
5075 return overflowOffsets;
5076 }
5077
5078 function computeAutoPlacement(state, options) {
5079 if (options === void 0) {
5080 options = {};
5081 }
5082
5083 var _options = options,
5084 placement = _options.placement,
5085 boundary = _options.boundary,
5086 rootBoundary = _options.rootBoundary,
5087 padding = _options.padding,
5088 flipVariations = _options.flipVariations,
5089 _options$allowedAutoP = _options.allowedAutoPlacements,
5090 allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
5091 var variation = getVariation(placement);
5092 var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
5093 return getVariation(placement) === variation;
5094 }) : basePlacements;
5095 var allowedPlacements = placements$1.filter(function (placement) {
5096 return allowedAutoPlacements.indexOf(placement) >= 0;
5097 });
5098
5099 if (allowedPlacements.length === 0) {
5100 allowedPlacements = placements$1;
5101
5102 {
5103 console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
5104 }
5105 } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
5106
5107
5108 var overflows = allowedPlacements.reduce(function (acc, placement) {
5109 acc[placement] = detectOverflow(state, {
5110 placement: placement,
5111 boundary: boundary,
5112 rootBoundary: rootBoundary,
5113 padding: padding
5114 })[getBasePlacement(placement)];
5115 return acc;
5116 }, {});
5117 return Object.keys(overflows).sort(function (a, b) {
5118 return overflows[a] - overflows[b];
5119 });
5120 }
5121
5122 function getExpandedFallbackPlacements(placement) {
5123 if (getBasePlacement(placement) === auto) {
5124 return [];
5125 }
5126
5127 var oppositePlacement = getOppositePlacement(placement);
5128 return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
5129 }
5130
5131 function flip(_ref) {
5132 var state = _ref.state,
5133 options = _ref.options,
5134 name = _ref.name;
5135
5136 if (state.modifiersData[name]._skip) {
5137 return;
5138 }
5139
5140 var _options$mainAxis = options.mainAxis,
5141 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
5142 _options$altAxis = options.altAxis,
5143 checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
5144 specifiedFallbackPlacements = options.fallbackPlacements,
5145 padding = options.padding,
5146 boundary = options.boundary,
5147 rootBoundary = options.rootBoundary,
5148 altBoundary = options.altBoundary,
5149 _options$flipVariatio = options.flipVariations,
5150 flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
5151 allowedAutoPlacements = options.allowedAutoPlacements;
5152 var preferredPlacement = state.options.placement;
5153 var basePlacement = getBasePlacement(preferredPlacement);
5154 var isBasePlacement = basePlacement === preferredPlacement;
5155 var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
5156 var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
5157 return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
5158 placement: placement,
5159 boundary: boundary,
5160 rootBoundary: rootBoundary,
5161 padding: padding,
5162 flipVariations: flipVariations,
5163 allowedAutoPlacements: allowedAutoPlacements
5164 }) : placement);
5165 }, []);
5166 var referenceRect = state.rects.reference;
5167 var popperRect = state.rects.popper;
5168 var checksMap = new Map();
5169 var makeFallbackChecks = true;
5170 var firstFittingPlacement = placements[0];
5171
5172 for (var i = 0; i < placements.length; i++) {
5173 var placement = placements[i];
5174
5175 var _basePlacement = getBasePlacement(placement);
5176
5177 var isStartVariation = getVariation(placement) === start;
5178 var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
5179 var len = isVertical ? 'width' : 'height';
5180 var overflow = detectOverflow(state, {
5181 placement: placement,
5182 boundary: boundary,
5183 rootBoundary: rootBoundary,
5184 altBoundary: altBoundary,
5185 padding: padding
5186 });
5187 var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
5188
5189 if (referenceRect[len] > popperRect[len]) {
5190 mainVariationSide = getOppositePlacement(mainVariationSide);
5191 }
5192
5193 var altVariationSide = getOppositePlacement(mainVariationSide);
5194 var checks = [];
5195
5196 if (checkMainAxis) {
5197 checks.push(overflow[_basePlacement] <= 0);
5198 }
5199
5200 if (checkAltAxis) {
5201 checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
5202 }
5203
5204 if (checks.every(function (check) {
5205 return check;
5206 })) {
5207 firstFittingPlacement = placement;
5208 makeFallbackChecks = false;
5209 break;
5210 }
5211
5212 checksMap.set(placement, checks);
5213 }
5214
5215 if (makeFallbackChecks) {
5216 // `2` may be desired in some cases – research later
5217 var numberOfChecks = flipVariations ? 3 : 1;
5218
5219 var _loop = function _loop(_i) {
5220 var fittingPlacement = placements.find(function (placement) {
5221 var checks = checksMap.get(placement);
5222
5223 if (checks) {
5224 return checks.slice(0, _i).every(function (check) {
5225 return check;
5226 });
5227 }
5228 });
5229
5230 if (fittingPlacement) {
5231 firstFittingPlacement = fittingPlacement;
5232 return "break";
5233 }
5234 };
5235
5236 for (var _i = numberOfChecks; _i > 0; _i--) {
5237 var _ret = _loop(_i);
5238
5239 if (_ret === "break") break;
5240 }
5241 }
5242
5243 if (state.placement !== firstFittingPlacement) {
5244 state.modifiersData[name]._skip = true;
5245 state.placement = firstFittingPlacement;
5246 state.reset = true;
5247 }
5248 } // eslint-disable-next-line import/no-unused-modules
5249
5250
5251 var flip$1 = {
5252 name: 'flip',
5253 enabled: true,
5254 phase: 'main',
5255 fn: flip,
5256 requiresIfExists: ['offset'],
5257 data: {
5258 _skip: false
5259 }
5260 };
5261
5262 function getSideOffsets(overflow, rect, preventedOffsets) {
5263 if (preventedOffsets === void 0) {
5264 preventedOffsets = {
5265 x: 0,
5266 y: 0
5267 };
5268 }
5269
5270 return {
5271 top: overflow.top - rect.height - preventedOffsets.y,
5272 right: overflow.right - rect.width + preventedOffsets.x,
5273 bottom: overflow.bottom - rect.height + preventedOffsets.y,
5274 left: overflow.left - rect.width - preventedOffsets.x
5275 };
5276 }
5277
5278 function isAnySideFullyClipped(overflow) {
5279 return [top, right, bottom, left].some(function (side) {
5280 return overflow[side] >= 0;
5281 });
5282 }
5283
5284 function hide(_ref) {
5285 var state = _ref.state,
5286 name = _ref.name;
5287 var referenceRect = state.rects.reference;
5288 var popperRect = state.rects.popper;
5289 var preventedOffsets = state.modifiersData.preventOverflow;
5290 var referenceOverflow = detectOverflow(state, {
5291 elementContext: 'reference'
5292 });
5293 var popperAltOverflow = detectOverflow(state, {
5294 altBoundary: true
5295 });
5296 var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
5297 var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
5298 var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
5299 var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
5300 state.modifiersData[name] = {
5301 referenceClippingOffsets: referenceClippingOffsets,
5302 popperEscapeOffsets: popperEscapeOffsets,
5303 isReferenceHidden: isReferenceHidden,
5304 hasPopperEscaped: hasPopperEscaped
5305 };
5306 state.attributes.popper = Object.assign({}, state.attributes.popper, {
5307 'data-popper-reference-hidden': isReferenceHidden,
5308 'data-popper-escaped': hasPopperEscaped
5309 });
5310 } // eslint-disable-next-line import/no-unused-modules
5311
5312
5313 var hide$1 = {
5314 name: 'hide',
5315 enabled: true,
5316 phase: 'main',
5317 requiresIfExists: ['preventOverflow'],
5318 fn: hide
5319 };
5320
5321 function distanceAndSkiddingToXY(placement, rects, offset) {
5322 var basePlacement = getBasePlacement(placement);
5323 var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
5324
5325 var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
5326 placement: placement
5327 })) : offset,
5328 skidding = _ref[0],
5329 distance = _ref[1];
5330
5331 skidding = skidding || 0;
5332 distance = (distance || 0) * invertDistance;
5333 return [left, right].indexOf(basePlacement) >= 0 ? {
5334 x: distance,
5335 y: skidding
5336 } : {
5337 x: skidding,
5338 y: distance
5339 };
5340 }
5341
5342 function offset(_ref2) {
5343 var state = _ref2.state,
5344 options = _ref2.options,
5345 name = _ref2.name;
5346 var _options$offset = options.offset,
5347 offset = _options$offset === void 0 ? [0, 0] : _options$offset;
5348 var data = placements.reduce(function (acc, placement) {
5349 acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
5350 return acc;
5351 }, {});
5352 var _data$state$placement = data[state.placement],
5353 x = _data$state$placement.x,
5354 y = _data$state$placement.y;
5355
5356 if (state.modifiersData.popperOffsets != null) {
5357 state.modifiersData.popperOffsets.x += x;
5358 state.modifiersData.popperOffsets.y += y;
5359 }
5360
5361 state.modifiersData[name] = data;
5362 } // eslint-disable-next-line import/no-unused-modules
5363
5364
5365 var offset$1 = {
5366 name: 'offset',
5367 enabled: true,
5368 phase: 'main',
5369 requires: ['popperOffsets'],
5370 fn: offset
5371 };
5372
5373 function popperOffsets(_ref) {
5374 var state = _ref.state,
5375 name = _ref.name;
5376 // Offsets are the actual position the popper needs to have to be
5377 // properly positioned near its reference element
5378 // This is the most basic placement, and will be adjusted by
5379 // the modifiers in the next step
5380 state.modifiersData[name] = computeOffsets({
5381 reference: state.rects.reference,
5382 element: state.rects.popper,
5383 strategy: 'absolute',
5384 placement: state.placement
5385 });
5386 } // eslint-disable-next-line import/no-unused-modules
5387
5388
5389 var popperOffsets$1 = {
5390 name: 'popperOffsets',
5391 enabled: true,
5392 phase: 'read',
5393 fn: popperOffsets,
5394 data: {}
5395 };
5396
5397 function getAltAxis(axis) {
5398 return axis === 'x' ? 'y' : 'x';
5399 }
5400
5401 function preventOverflow(_ref) {
5402 var state = _ref.state,
5403 options = _ref.options,
5404 name = _ref.name;
5405 var _options$mainAxis = options.mainAxis,
5406 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
5407 _options$altAxis = options.altAxis,
5408 checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
5409 boundary = options.boundary,
5410 rootBoundary = options.rootBoundary,
5411 altBoundary = options.altBoundary,
5412 padding = options.padding,
5413 _options$tether = options.tether,
5414 tether = _options$tether === void 0 ? true : _options$tether,
5415 _options$tetherOffset = options.tetherOffset,
5416 tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
5417 var overflow = detectOverflow(state, {
5418 boundary: boundary,
5419 rootBoundary: rootBoundary,
5420 padding: padding,
5421 altBoundary: altBoundary
5422 });
5423 var basePlacement = getBasePlacement(state.placement);
5424 var variation = getVariation(state.placement);
5425 var isBasePlacement = !variation;
5426 var mainAxis = getMainAxisFromPlacement(basePlacement);
5427 var altAxis = getAltAxis(mainAxis);
5428 var popperOffsets = state.modifiersData.popperOffsets;
5429 var referenceRect = state.rects.reference;
5430 var popperRect = state.rects.popper;
5431 var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
5432 placement: state.placement
5433 })) : tetherOffset;
5434 var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
5435 mainAxis: tetherOffsetValue,
5436 altAxis: tetherOffsetValue
5437 } : Object.assign({
5438 mainAxis: 0,
5439 altAxis: 0
5440 }, tetherOffsetValue);
5441 var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
5442 var data = {
5443 x: 0,
5444 y: 0
5445 };
5446
5447 if (!popperOffsets) {
5448 return;
5449 }
5450
5451 if (checkMainAxis) {
5452 var _offsetModifierState$;
5453
5454 var mainSide = mainAxis === 'y' ? top : left;
5455 var altSide = mainAxis === 'y' ? bottom : right;
5456 var len = mainAxis === 'y' ? 'height' : 'width';
5457 var offset = popperOffsets[mainAxis];
5458 var min$1 = offset + overflow[mainSide];
5459 var max$1 = offset - overflow[altSide];
5460 var additive = tether ? -popperRect[len] / 2 : 0;
5461 var minLen = variation === start ? referenceRect[len] : popperRect[len];
5462 var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
5463 // outside the reference bounds
5464
5465 var arrowElement = state.elements.arrow;
5466 var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
5467 width: 0,
5468 height: 0
5469 };
5470 var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
5471 var arrowPaddingMin = arrowPaddingObject[mainSide];
5472 var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
5473 // to include its full size in the calculation. If the reference is small
5474 // and near the edge of a boundary, the popper can overflow even if the
5475 // reference is not overflowing as well (e.g. virtual elements with no
5476 // width or height)
5477
5478 var arrowLen = within(0, referenceRect[len], arrowRect[len]);
5479 var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
5480 var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
5481 var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
5482 var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
5483 var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
5484 var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
5485 var tetherMax = offset + maxOffset - offsetModifierValue;
5486 var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
5487 popperOffsets[mainAxis] = preventedOffset;
5488 data[mainAxis] = preventedOffset - offset;
5489 }
5490
5491 if (checkAltAxis) {
5492 var _offsetModifierState$2;
5493
5494 var _mainSide = mainAxis === 'x' ? top : left;
5495
5496 var _altSide = mainAxis === 'x' ? bottom : right;
5497
5498 var _offset = popperOffsets[altAxis];
5499
5500 var _len = altAxis === 'y' ? 'height' : 'width';
5501
5502 var _min = _offset + overflow[_mainSide];
5503
5504 var _max = _offset - overflow[_altSide];
5505
5506 var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
5507
5508 var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
5509
5510 var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
5511
5512 var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
5513
5514 var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
5515
5516 popperOffsets[altAxis] = _preventedOffset;
5517 data[altAxis] = _preventedOffset - _offset;
5518 }
5519
5520 state.modifiersData[name] = data;
5521 } // eslint-disable-next-line import/no-unused-modules
5522
5523
5524 var preventOverflow$1 = {
5525 name: 'preventOverflow',
5526 enabled: true,
5527 phase: 'main',
5528 fn: preventOverflow,
5529 requiresIfExists: ['offset']
5530 };
5531
5532 function getHTMLElementScroll(element) {
5533 return {
5534 scrollLeft: element.scrollLeft,
5535 scrollTop: element.scrollTop
5536 };
5537 }
5538
5539 function getNodeScroll(node) {
5540 if (node === getWindow(node) || !isHTMLElement(node)) {
5541 return getWindowScroll(node);
5542 } else {
5543 return getHTMLElementScroll(node);
5544 }
5545 }
5546
5547 function isElementScaled(element) {
5548 var rect = element.getBoundingClientRect();
5549 var scaleX = round(rect.width) / element.offsetWidth || 1;
5550 var scaleY = round(rect.height) / element.offsetHeight || 1;
5551 return scaleX !== 1 || scaleY !== 1;
5552 } // Returns the composite rect of an element relative to its offsetParent.
5553 // Composite means it takes into account transforms as well as layout.
5554
5555
5556 function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
5557 if (isFixed === void 0) {
5558 isFixed = false;
5559 }
5560
5561 var isOffsetParentAnElement = isHTMLElement(offsetParent);
5562 var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
5563 var documentElement = getDocumentElement(offsetParent);
5564 var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
5565 var scroll = {
5566 scrollLeft: 0,
5567 scrollTop: 0
5568 };
5569 var offsets = {
5570 x: 0,
5571 y: 0
5572 };
5573
5574 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
5575 if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
5576 isScrollParent(documentElement)) {
5577 scroll = getNodeScroll(offsetParent);
5578 }
5579
5580 if (isHTMLElement(offsetParent)) {
5581 offsets = getBoundingClientRect(offsetParent, true);
5582 offsets.x += offsetParent.clientLeft;
5583 offsets.y += offsetParent.clientTop;
5584 } else if (documentElement) {
5585 offsets.x = getWindowScrollBarX(documentElement);
5586 }
5587 }
5588
5589 return {
5590 x: rect.left + scroll.scrollLeft - offsets.x,
5591 y: rect.top + scroll.scrollTop - offsets.y,
5592 width: rect.width,
5593 height: rect.height
5594 };
5595 }
5596
5597 function order(modifiers) {
5598 var map = new Map();
5599 var visited = new Set();
5600 var result = [];
5601 modifiers.forEach(function (modifier) {
5602 map.set(modifier.name, modifier);
5603 }); // On visiting object, check for its dependencies and visit them recursively
5604
5605 function sort(modifier) {
5606 visited.add(modifier.name);
5607 var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
5608 requires.forEach(function (dep) {
5609 if (!visited.has(dep)) {
5610 var depModifier = map.get(dep);
5611
5612 if (depModifier) {
5613 sort(depModifier);
5614 }
5615 }
5616 });
5617 result.push(modifier);
5618 }
5619
5620 modifiers.forEach(function (modifier) {
5621 if (!visited.has(modifier.name)) {
5622 // check for visited object
5623 sort(modifier);
5624 }
5625 });
5626 return result;
5627 }
5628
5629 function orderModifiers(modifiers) {
5630 // order based on dependencies
5631 var orderedModifiers = order(modifiers); // order based on phase
5632
5633 return modifierPhases.reduce(function (acc, phase) {
5634 return acc.concat(orderedModifiers.filter(function (modifier) {
5635 return modifier.phase === phase;
5636 }));
5637 }, []);
5638 }
5639
5640 function debounce(fn) {
5641 var pending;
5642 return function () {
5643 if (!pending) {
5644 pending = new Promise(function (resolve) {
5645 Promise.resolve().then(function () {
5646 pending = undefined;
5647 resolve(fn());
5648 });
5649 });
5650 }
5651
5652 return pending;
5653 };
5654 }
5655
5656 function format(str) {
5657 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5658 args[_key - 1] = arguments[_key];
5659 }
5660
5661 return [].concat(args).reduce(function (p, c) {
5662 return p.replace(/%s/, c);
5663 }, str);
5664 }
5665
5666 var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
5667 var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
5668 var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
5669 function validateModifiers(modifiers) {
5670 modifiers.forEach(function (modifier) {
5671 [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
5672 .filter(function (value, index, self) {
5673 return self.indexOf(value) === index;
5674 }).forEach(function (key) {
5675 switch (key) {
5676 case 'name':
5677 if (typeof modifier.name !== 'string') {
5678 console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
5679 }
5680
5681 break;
5682
5683 case 'enabled':
5684 if (typeof modifier.enabled !== 'boolean') {
5685 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
5686 }
5687
5688 break;
5689
5690 case 'phase':
5691 if (modifierPhases.indexOf(modifier.phase) < 0) {
5692 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
5693 }
5694
5695 break;
5696
5697 case 'fn':
5698 if (typeof modifier.fn !== 'function') {
5699 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
5700 }
5701
5702 break;
5703
5704 case 'effect':
5705 if (modifier.effect != null && typeof modifier.effect !== 'function') {
5706 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
5707 }
5708
5709 break;
5710
5711 case 'requires':
5712 if (modifier.requires != null && !Array.isArray(modifier.requires)) {
5713 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
5714 }
5715
5716 break;
5717
5718 case 'requiresIfExists':
5719 if (!Array.isArray(modifier.requiresIfExists)) {
5720 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
5721 }
5722
5723 break;
5724
5725 case 'options':
5726 case 'data':
5727 break;
5728
5729 default:
5730 console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
5731 return "\"" + s + "\"";
5732 }).join(', ') + "; but \"" + key + "\" was provided.");
5733 }
5734
5735 modifier.requires && modifier.requires.forEach(function (requirement) {
5736 if (modifiers.find(function (mod) {
5737 return mod.name === requirement;
5738 }) == null) {
5739 console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
5740 }
5741 });
5742 });
5743 });
5744 }
5745
5746 function uniqueBy(arr, fn) {
5747 var identifiers = new Set();
5748 return arr.filter(function (item) {
5749 var identifier = fn(item);
5750
5751 if (!identifiers.has(identifier)) {
5752 identifiers.add(identifier);
5753 return true;
5754 }
5755 });
5756 }
5757
5758 function mergeByName(modifiers) {
5759 var merged = modifiers.reduce(function (merged, current) {
5760 var existing = merged[current.name];
5761 merged[current.name] = existing ? Object.assign({}, existing, current, {
5762 options: Object.assign({}, existing.options, current.options),
5763 data: Object.assign({}, existing.data, current.data)
5764 }) : current;
5765 return merged;
5766 }, {}); // IE11 does not support Object.values
5767
5768 return Object.keys(merged).map(function (key) {
5769 return merged[key];
5770 });
5771 }
5772
5773 var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
5774 var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
5775 var DEFAULT_OPTIONS = {
5776 placement: 'bottom',
5777 modifiers: [],
5778 strategy: 'absolute'
5779 };
5780
5781 function areValidElements() {
5782 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5783 args[_key] = arguments[_key];
5784 }
5785
5786 return !args.some(function (element) {
5787 return !(element && typeof element.getBoundingClientRect === 'function');
5788 });
5789 }
5790
5791 function popperGenerator(generatorOptions) {
5792 if (generatorOptions === void 0) {
5793 generatorOptions = {};
5794 }
5795
5796 var _generatorOptions = generatorOptions,
5797 _generatorOptions$def = _generatorOptions.defaultModifiers,
5798 defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
5799 _generatorOptions$def2 = _generatorOptions.defaultOptions,
5800 defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
5801 return function createPopper(reference, popper, options) {
5802 if (options === void 0) {
5803 options = defaultOptions;
5804 }
5805
5806 var state = {
5807 placement: 'bottom',
5808 orderedModifiers: [],
5809 options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
5810 modifiersData: {},
5811 elements: {
5812 reference: reference,
5813 popper: popper
5814 },
5815 attributes: {},
5816 styles: {}
5817 };
5818 var effectCleanupFns = [];
5819 var isDestroyed = false;
5820 var instance = {
5821 state: state,
5822 setOptions: function setOptions(setOptionsAction) {
5823 var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
5824 cleanupModifierEffects();
5825 state.options = Object.assign({}, defaultOptions, state.options, options);
5826 state.scrollParents = {
5827 reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
5828 popper: listScrollParents(popper)
5829 }; // Orders the modifiers based on their dependencies and `phase`
5830 // properties
5831
5832 var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
5833
5834 state.orderedModifiers = orderedModifiers.filter(function (m) {
5835 return m.enabled;
5836 }); // Validate the provided modifiers so that the consumer will get warned
5837 // if one of the modifiers is invalid for any reason
5838
5839 {
5840 var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
5841 var name = _ref.name;
5842 return name;
5843 });
5844 validateModifiers(modifiers);
5845
5846 if (getBasePlacement(state.options.placement) === auto) {
5847 var flipModifier = state.orderedModifiers.find(function (_ref2) {
5848 var name = _ref2.name;
5849 return name === 'flip';
5850 });
5851
5852 if (!flipModifier) {
5853 console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
5854 }
5855 }
5856
5857 var _getComputedStyle = getComputedStyle$1(popper),
5858 marginTop = _getComputedStyle.marginTop,
5859 marginRight = _getComputedStyle.marginRight,
5860 marginBottom = _getComputedStyle.marginBottom,
5861 marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
5862 // cause bugs with positioning, so we'll warn the consumer
5863
5864
5865 if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
5866 return parseFloat(margin);
5867 })) {
5868 console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
5869 }
5870 }
5871
5872 runModifierEffects();
5873 return instance.update();
5874 },
5875 // Sync update – it will always be executed, even if not necessary. This
5876 // is useful for low frequency updates where sync behavior simplifies the
5877 // logic.
5878 // For high frequency updates (e.g. `resize` and `scroll` events), always
5879 // prefer the async Popper#update method
5880 forceUpdate: function forceUpdate() {
5881 if (isDestroyed) {
5882 return;
5883 }
5884
5885 var _state$elements = state.elements,
5886 reference = _state$elements.reference,
5887 popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
5888 // anymore
5889
5890 if (!areValidElements(reference, popper)) {
5891 {
5892 console.error(INVALID_ELEMENT_ERROR);
5893 }
5894
5895 return;
5896 } // Store the reference and popper rects to be read by modifiers
5897
5898
5899 state.rects = {
5900 reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
5901 popper: getLayoutRect(popper)
5902 }; // Modifiers have the ability to reset the current update cycle. The
5903 // most common use case for this is the `flip` modifier changing the
5904 // placement, which then needs to re-run all the modifiers, because the
5905 // logic was previously ran for the previous placement and is therefore
5906 // stale/incorrect
5907
5908 state.reset = false;
5909 state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
5910 // is filled with the initial data specified by the modifier. This means
5911 // it doesn't persist and is fresh on each update.
5912 // To ensure persistent data, use `${name}#persistent`
5913
5914 state.orderedModifiers.forEach(function (modifier) {
5915 return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
5916 });
5917 var __debug_loops__ = 0;
5918
5919 for (var index = 0; index < state.orderedModifiers.length; index++) {
5920 {
5921 __debug_loops__ += 1;
5922
5923 if (__debug_loops__ > 100) {
5924 console.error(INFINITE_LOOP_ERROR);
5925 break;
5926 }
5927 }
5928
5929 if (state.reset === true) {
5930 state.reset = false;
5931 index = -1;
5932 continue;
5933 }
5934
5935 var _state$orderedModifie = state.orderedModifiers[index],
5936 fn = _state$orderedModifie.fn,
5937 _state$orderedModifie2 = _state$orderedModifie.options,
5938 _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
5939 name = _state$orderedModifie.name;
5940
5941 if (typeof fn === 'function') {
5942 state = fn({
5943 state: state,
5944 options: _options,
5945 name: name,
5946 instance: instance
5947 }) || state;
5948 }
5949 }
5950 },
5951 // Async and optimistically optimized update – it will not be executed if
5952 // not necessary (debounced to run at most once-per-tick)
5953 update: debounce(function () {
5954 return new Promise(function (resolve) {
5955 instance.forceUpdate();
5956 resolve(state);
5957 });
5958 }),
5959 destroy: function destroy() {
5960 cleanupModifierEffects();
5961 isDestroyed = true;
5962 }
5963 };
5964
5965 if (!areValidElements(reference, popper)) {
5966 {
5967 console.error(INVALID_ELEMENT_ERROR);
5968 }
5969
5970 return instance;
5971 }
5972
5973 instance.setOptions(options).then(function (state) {
5974 if (!isDestroyed && options.onFirstUpdate) {
5975 options.onFirstUpdate(state);
5976 }
5977 }); // Modifiers have the ability to execute arbitrary code before the first
5978 // update cycle runs. They will be executed in the same order as the update
5979 // cycle. This is useful when a modifier adds some persistent data that
5980 // other modifiers need to use, but the modifier is run after the dependent
5981 // one.
5982
5983 function runModifierEffects() {
5984 state.orderedModifiers.forEach(function (_ref3) {
5985 var name = _ref3.name,
5986 _ref3$options = _ref3.options,
5987 options = _ref3$options === void 0 ? {} : _ref3$options,
5988 effect = _ref3.effect;
5989
5990 if (typeof effect === 'function') {
5991 var cleanupFn = effect({
5992 state: state,
5993 name: name,
5994 instance: instance,
5995 options: options
5996 });
5997
5998 var noopFn = function noopFn() {};
5999
6000 effectCleanupFns.push(cleanupFn || noopFn);
6001 }
6002 });
6003 }
6004
6005 function cleanupModifierEffects() {
6006 effectCleanupFns.forEach(function (fn) {
6007 return fn();
6008 });
6009 effectCleanupFns = [];
6010 }
6011
6012 return instance;
6013 };
6014 }
6015
6016 var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
6017 var createPopper = /*#__PURE__*/popperGenerator({
6018 defaultModifiers: defaultModifiers
6019 }); // eslint-disable-next-line import/no-unused-modules
6020
6021 /* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
6022
6023 var hasElementType = typeof Element !== 'undefined';
6024 var hasMap = typeof Map === 'function';
6025 var hasSet = typeof Set === 'function';
6026 var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
6027
6028 // Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
6029
6030 function equal(a, b) {
6031 // START: fast-deep-equal es6/index.js 3.1.1
6032 if (a === b) return true;
6033
6034 if (a && b && typeof a == 'object' && typeof b == 'object') {
6035 if (a.constructor !== b.constructor) return false;
6036
6037 var length, i, keys;
6038 if (Array.isArray(a)) {
6039 length = a.length;
6040 if (length != b.length) return false;
6041 for (i = length; i-- !== 0;)
6042 if (!equal(a[i], b[i])) return false;
6043 return true;
6044 }
6045
6046 // START: Modifications:
6047 // 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
6048 // to co-exist with es5.
6049 // 2. Replace `for of` with es5 compliant iteration using `for`.
6050 // Basically, take:
6051 //
6052 // ```js
6053 // for (i of a.entries())
6054 // if (!b.has(i[0])) return false;
6055 // ```
6056 //
6057 // ... and convert to:
6058 //
6059 // ```js
6060 // it = a.entries();
6061 // while (!(i = it.next()).done)
6062 // if (!b.has(i.value[0])) return false;
6063 // ```
6064 //
6065 // **Note**: `i` access switches to `i.value`.
6066 var it;
6067 if (hasMap && (a instanceof Map) && (b instanceof Map)) {
6068 if (a.size !== b.size) return false;
6069 it = a.entries();
6070 while (!(i = it.next()).done)
6071 if (!b.has(i.value[0])) return false;
6072 it = a.entries();
6073 while (!(i = it.next()).done)
6074 if (!equal(i.value[1], b.get(i.value[0]))) return false;
6075 return true;
6076 }
6077
6078 if (hasSet && (a instanceof Set) && (b instanceof Set)) {
6079 if (a.size !== b.size) return false;
6080 it = a.entries();
6081 while (!(i = it.next()).done)
6082 if (!b.has(i.value[0])) return false;
6083 return true;
6084 }
6085 // END: Modifications
6086
6087 if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
6088 length = a.length;
6089 if (length != b.length) return false;
6090 for (i = length; i-- !== 0;)
6091 if (a[i] !== b[i]) return false;
6092 return true;
6093 }
6094
6095 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
6096 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
6097 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
6098
6099 keys = Object.keys(a);
6100 length = keys.length;
6101 if (length !== Object.keys(b).length) return false;
6102
6103 for (i = length; i-- !== 0;)
6104 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
6105 // END: fast-deep-equal
6106
6107 // START: react-fast-compare
6108 // custom handling for DOM elements
6109 if (hasElementType && a instanceof Element) return false;
6110
6111 // custom handling for React/Preact
6112 for (i = length; i-- !== 0;) {
6113 if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
6114 // React-specific: avoid traversing React elements' _owner
6115 // Preact-specific: avoid traversing Preact elements' __v and __o
6116 // __v = $_original / $_vnode
6117 // __o = $_owner
6118 // These properties contain circular references and are not needed when
6119 // comparing the actual elements (and not their owners)
6120 // .$$typeof and ._store on just reasonable markers of elements
6121
6122 continue;
6123 }
6124
6125 // all other properties should be traversed as usual
6126 if (!equal(a[keys[i]], b[keys[i]])) return false;
6127 }
6128 // END: react-fast-compare
6129
6130 // START: fast-deep-equal
6131 return true;
6132 }
6133
6134 return a !== a && b !== b;
6135 }
6136 // end fast-deep-equal
6137
6138 var reactFastCompare = function isEqual(a, b) {
6139 try {
6140 return equal(a, b);
6141 } catch (error) {
6142 if (((error.message || '').match(/stack|recursion/i))) {
6143 // warn on circular references, don't crash
6144 // browsers give this different errors name and messages:
6145 // chrome/safari: "RangeError", "Maximum call stack size exceeded"
6146 // firefox: "InternalError", too much recursion"
6147 // edge: "Error", "Out of stack space"
6148 console.warn('react-fast-compare cannot handle circular refs');
6149 return false;
6150 }
6151 // some other error. we should definitely know about these
6152 throw error;
6153 }
6154 };
6155
6156 var EMPTY_MODIFIERS = [];
6157 var usePopper = function usePopper(referenceElement, popperElement, options) {
6158 if (options === void 0) {
6159 options = {};
6160 }
6161
6162 var prevOptions = React__namespace.useRef(null);
6163 var optionsWithDefaults = {
6164 onFirstUpdate: options.onFirstUpdate,
6165 placement: options.placement || 'bottom',
6166 strategy: options.strategy || 'absolute',
6167 modifiers: options.modifiers || EMPTY_MODIFIERS
6168 };
6169
6170 var _React$useState = React__namespace.useState({
6171 styles: {
6172 popper: {
6173 position: optionsWithDefaults.strategy,
6174 left: '0',
6175 top: '0'
6176 },
6177 arrow: {
6178 position: 'absolute'
6179 }
6180 },
6181 attributes: {}
6182 }),
6183 state = _React$useState[0],
6184 setState = _React$useState[1];
6185
6186 var updateStateModifier = React__namespace.useMemo(function () {
6187 return {
6188 name: 'updateState',
6189 enabled: true,
6190 phase: 'write',
6191 fn: function fn(_ref) {
6192 var state = _ref.state;
6193 var elements = Object.keys(state.elements);
6194 setState({
6195 styles: fromEntries(elements.map(function (element) {
6196 return [element, state.styles[element] || {}];
6197 })),
6198 attributes: fromEntries(elements.map(function (element) {
6199 return [element, state.attributes[element]];
6200 }))
6201 });
6202 },
6203 requires: ['computeStyles']
6204 };
6205 }, []);
6206 var popperOptions = React__namespace.useMemo(function () {
6207 var newOptions = {
6208 onFirstUpdate: optionsWithDefaults.onFirstUpdate,
6209 placement: optionsWithDefaults.placement,
6210 strategy: optionsWithDefaults.strategy,
6211 modifiers: [].concat(optionsWithDefaults.modifiers, [updateStateModifier, {
6212 name: 'applyStyles',
6213 enabled: false
6214 }])
6215 };
6216
6217 if (reactFastCompare(prevOptions.current, newOptions)) {
6218 return prevOptions.current || newOptions;
6219 } else {
6220 prevOptions.current = newOptions;
6221 return newOptions;
6222 }
6223 }, [optionsWithDefaults.onFirstUpdate, optionsWithDefaults.placement, optionsWithDefaults.strategy, optionsWithDefaults.modifiers, updateStateModifier]);
6224 var popperInstanceRef = React__namespace.useRef();
6225 useIsomorphicLayoutEffect(function () {
6226 if (popperInstanceRef.current) {
6227 popperInstanceRef.current.setOptions(popperOptions);
6228 }
6229 }, [popperOptions]);
6230 useIsomorphicLayoutEffect(function () {
6231 if (referenceElement == null || popperElement == null) {
6232 return;
6233 }
6234
6235 var createPopper$1 = options.createPopper || createPopper;
6236 var popperInstance = createPopper$1(referenceElement, popperElement, popperOptions);
6237 popperInstanceRef.current = popperInstance;
6238 return function () {
6239 popperInstance.destroy();
6240 popperInstanceRef.current = null;
6241 };
6242 }, [referenceElement, popperElement, options.createPopper]);
6243 return {
6244 state: popperInstanceRef.current ? popperInstanceRef.current.state : null,
6245 styles: state.styles,
6246 attributes: state.attributes,
6247 update: popperInstanceRef.current ? popperInstanceRef.current.update : null,
6248 forceUpdate: popperInstanceRef.current ? popperInstanceRef.current.forceUpdate : null
6249 };
6250 };
6251
6252 var _excluded$9 = ["referenceElement"];
6253 var alignValues = ['justify', 'left', 'right'];
6254 // `Element` is not defined during server-side rendering, so shim it here.
6255
6256 /* istanbul ignore next */
6257 var SafeElement = typeof Element === 'undefined' ? noop$1 : Element;
6258 var propTypes$6 = {
6259 /**
6260 * Specify menu alignment. The default value is `justify`, which makes the
6261 * menu as wide as the input and truncates long values. Specifying `left`
6262 * or `right` will align the menu to that side and the width will be
6263 * determined by the length of menu item values.
6264 */
6265 align: propTypes$b.exports.oneOf(alignValues),
6266 children: propTypes$b.exports.func.isRequired,
6267
6268 /**
6269 * Specify whether the menu should appear above the input.
6270 */
6271 dropup: propTypes$b.exports.bool,
6272
6273 /**
6274 * Whether or not to automatically adjust the position of the menu when it
6275 * reaches the viewport boundaries.
6276 */
6277 flip: propTypes$b.exports.bool,
6278 isMenuShown: propTypes$b.exports.bool,
6279 positionFixed: propTypes$b.exports.bool,
6280 // @ts-ignore
6281 referenceElement: propTypes$b.exports.instanceOf(SafeElement)
6282 };
6283 var defaultProps$4 = {
6284 align: 'justify',
6285 dropup: false,
6286 flip: false,
6287 isMenuShown: false,
6288 positionFixed: false
6289 };
6290 var setPopperWidth = {
6291 enabled: true,
6292 fn: function fn(data) {
6293 // eslint-disable-next-line no-param-reassign
6294 data.state.styles.popper.width = "".concat(data.state.rects.reference.width, "px");
6295 },
6296 name: 'setPopperWidth',
6297 phase: 'write'
6298 };
6299 function getModifiers(props) {
6300 var modifiers = [{
6301 enabled: !!props.flip,
6302 name: 'flip'
6303 }];
6304
6305 if (props.align !== 'right' && props.align !== 'left') {
6306 modifiers.push(setPopperWidth);
6307 }
6308
6309 return modifiers;
6310 }
6311 function getPlacement(props) {
6312 var x = props.align === 'right' ? 'end' : 'start';
6313 var y = props.dropup ? 'top' : 'bottom';
6314 return "".concat(y, "-").concat(x);
6315 }
6316
6317 var Overlay = function Overlay(_ref) {
6318 var referenceElement = _ref.referenceElement,
6319 props = _objectWithoutProperties(_ref, _excluded$9);
6320
6321 var _useState = React.useState(null),
6322 _useState2 = _slicedToArray(_useState, 2),
6323 popperElement = _useState2[0],
6324 attachRef = _useState2[1];
6325
6326 var _usePopper = usePopper(referenceElement, popperElement, {
6327 modifiers: getModifiers(props),
6328 placement: getPlacement(props),
6329 strategy: props.positionFixed ? 'fixed' : 'absolute'
6330 }),
6331 attributes = _usePopper.attributes,
6332 styles = _usePopper.styles,
6333 forceUpdate = _usePopper.forceUpdate;
6334
6335 var refElementHeight = referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetHeight; // Re-position the popper if the height of the reference element changes.
6336 // Exclude `forceUpdate` from dependencies since it changes with each render.
6337
6338 React.useEffect(function () {
6339 forceUpdate && forceUpdate();
6340 }, [refElementHeight]); // eslint-disable-line
6341
6342 if (!props.isMenuShown) {
6343 return null;
6344 }
6345
6346 return props.children(_objectSpread2(_objectSpread2({}, attributes.popper), {}, {
6347 innerRef: attachRef,
6348 style: styles.popper
6349 }));
6350 };
6351
6352 Overlay.propTypes = propTypes$6;
6353 Overlay.defaultProps = defaultProps$4;
6354
6355 var _excluded$8 = ["onBlur", "onClick", "onFocus", "onRemove", "option"];
6356 var propTypes$5 = {
6357 onBlur: propTypes$b.exports.func,
6358 onClick: propTypes$b.exports.func,
6359 onFocus: propTypes$b.exports.func,
6360 onRemove: propTypes$b.exports.func,
6361 option: optionType.isRequired
6362 };
6363 function useToken(_ref) {
6364 var onBlur = _ref.onBlur,
6365 onClick = _ref.onClick,
6366 onFocus = _ref.onFocus,
6367 onRemove = _ref.onRemove,
6368 option = _ref.option,
6369 props = _objectWithoutProperties(_ref, _excluded$8);
6370
6371 var _useState = React.useState(false),
6372 _useState2 = _slicedToArray(_useState, 2),
6373 active = _useState2[0],
6374 setActive = _useState2[1];
6375
6376 var _useState3 = React.useState(null),
6377 _useState4 = _slicedToArray(_useState3, 2),
6378 rootElement = _useState4[0],
6379 attachRef = _useState4[1];
6380
6381 var handleBlur = function handleBlur(e) {
6382 setActive(false);
6383 onBlur && onBlur(e);
6384 };
6385
6386 var handleClick = function handleClick(e) {
6387 setActive(true);
6388 onClick && onClick(e);
6389 };
6390
6391 var handleFocus = function handleFocus(e) {
6392 setActive(true);
6393 onFocus && onFocus(e);
6394 };
6395
6396 var handleRemove = function handleRemove() {
6397 onRemove && onRemove(option);
6398 };
6399
6400 var handleKeyDown = function handleKeyDown(e) {
6401 if (e.key === 'Backspace' && active) {
6402 // Prevent browser from going back.
6403 e.preventDefault();
6404 handleRemove();
6405 }
6406 };
6407
6408 useRootClose(rootElement, handleBlur, _objectSpread2(_objectSpread2({}, props), {}, {
6409 disabled: !active
6410 }));
6411 return {
6412 active: active,
6413 onBlur: handleBlur,
6414 onClick: handleClick,
6415 onFocus: handleFocus,
6416 onKeyDown: handleKeyDown,
6417 onRemove: isFunction(onRemove) ? handleRemove : undefined,
6418 ref: attachRef
6419 };
6420 }
6421 /* istanbul ignore next */
6422
6423 function withToken(Component) {
6424 var displayName = "withToken(".concat(getDisplayName(Component), ")");
6425
6426 var WrappedToken = function WrappedToken(props) {
6427 return /*#__PURE__*/React__default["default"].createElement(Component, _extends({}, props, useToken(props)));
6428 };
6429
6430 WrappedToken.displayName = displayName;
6431 WrappedToken.propTypes = propTypes$5;
6432 return WrappedToken;
6433 }
6434
6435 var _excluded$7 = ["active", "children", "className", "onRemove", "tabIndex"],
6436 _excluded2 = ["children", "option", "readOnly"],
6437 _excluded3 = ["ref"];
6438 var InteractiveToken = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6439 var active = _ref.active,
6440 children = _ref.children,
6441 className = _ref.className,
6442 onRemove = _ref.onRemove,
6443 tabIndex = _ref.tabIndex,
6444 props = _objectWithoutProperties(_ref, _excluded$7);
6445
6446 return /*#__PURE__*/React__default["default"].createElement("div", _extends({}, props, {
6447 className: cx('rbt-token', 'rbt-token-removeable', {
6448 'rbt-token-active': !!active
6449 }, className),
6450 ref: ref,
6451 tabIndex: tabIndex || 0
6452 }), children, /*#__PURE__*/React__default["default"].createElement(ClearButton, {
6453 className: "rbt-token-remove-button",
6454 label: "Remove",
6455 onClick: onRemove,
6456 tabIndex: -1
6457 }));
6458 });
6459
6460 var StaticToken = function StaticToken(_ref2) {
6461 var children = _ref2.children,
6462 className = _ref2.className,
6463 disabled = _ref2.disabled,
6464 href = _ref2.href;
6465 var classnames = cx('rbt-token', {
6466 'rbt-token-disabled': disabled
6467 }, className);
6468
6469 if (href && !disabled) {
6470 return /*#__PURE__*/React__default["default"].createElement("a", {
6471 className: classnames,
6472 href: href
6473 }, children);
6474 }
6475
6476 return /*#__PURE__*/React__default["default"].createElement("div", {
6477 className: classnames
6478 }, children);
6479 };
6480
6481 /**
6482 * Individual token component, generally displayed within the
6483 * `TypeaheadInputMulti` component, but can also be rendered on its own.
6484 */
6485 var Token = function Token(_ref3) {
6486 var children = _ref3.children,
6487 option = _ref3.option,
6488 readOnly = _ref3.readOnly,
6489 props = _objectWithoutProperties(_ref3, _excluded2);
6490
6491 var _useToken = useToken(_objectSpread2(_objectSpread2({}, props), {}, {
6492 option: option
6493 })),
6494 ref = _useToken.ref,
6495 tokenProps = _objectWithoutProperties(_useToken, _excluded3);
6496
6497 var child = /*#__PURE__*/React__default["default"].createElement("div", {
6498 className: "rbt-token-label"
6499 }, children);
6500 return !props.disabled && !readOnly && isFunction(tokenProps.onRemove) ? /*#__PURE__*/React__default["default"].createElement(InteractiveToken, _extends({}, props, tokenProps, {
6501 ref: ref
6502 }), child) : /*#__PURE__*/React__default["default"].createElement(StaticToken, props, child);
6503 };
6504
6505 // 'borderStyle', etc.), so generate these from the individual values.
6506
6507 function interpolateStyle(styles, attr) {
6508 var subattr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
6509
6510 // Title-case the sub-attribute.
6511 if (subattr) {
6512 /* eslint-disable-next-line no-param-reassign */
6513 subattr = subattr.replace(subattr[0], subattr[0].toUpperCase());
6514 }
6515
6516 return ['Top', 'Right', 'Bottom', 'Left'].map(function (dir) {
6517 return styles["".concat(attr).concat(dir).concat(subattr)];
6518 }).join(' ');
6519 }
6520
6521 function copyStyles(inputNode, hintNode) {
6522 var inputStyle = window.getComputedStyle(inputNode);
6523 /* eslint-disable no-param-reassign */
6524
6525 hintNode.style.borderStyle = interpolateStyle(inputStyle, 'border', 'style');
6526 hintNode.style.borderWidth = interpolateStyle(inputStyle, 'border', 'width');
6527 hintNode.style.fontSize = inputStyle.fontSize;
6528 hintNode.style.fontWeight = inputStyle.fontWeight;
6529 hintNode.style.height = inputStyle.height;
6530 hintNode.style.lineHeight = inputStyle.lineHeight;
6531 hintNode.style.margin = interpolateStyle(inputStyle, 'margin');
6532 hintNode.style.padding = interpolateStyle(inputStyle, 'padding');
6533 /* eslint-enable no-param-reassign */
6534 }
6535
6536 var useHint = function useHint() {
6537 var _useTypeaheadContext = useTypeaheadContext(),
6538 hintText = _useTypeaheadContext.hintText,
6539 inputNode = _useTypeaheadContext.inputNode;
6540
6541 var hintRef = React.useRef(null);
6542 React.useEffect(function () {
6543 if (inputNode && hintRef.current) {
6544 copyStyles(inputNode, hintRef.current);
6545 }
6546 });
6547 return {
6548 hintRef: hintRef,
6549 hintText: hintText
6550 };
6551 };
6552
6553 var Hint = function Hint(_ref) {
6554 var children = _ref.children,
6555 className = _ref.className;
6556
6557 var _useHint = useHint(),
6558 hintRef = _useHint.hintRef,
6559 hintText = _useHint.hintText;
6560
6561 return /*#__PURE__*/React__default["default"].createElement("div", {
6562 className: className,
6563 style: {
6564 display: 'flex',
6565 flex: 1,
6566 height: '100%',
6567 position: 'relative'
6568 }
6569 }, children, /*#__PURE__*/React__default["default"].createElement("input", {
6570 "aria-hidden": true,
6571 className: "rbt-input-hint",
6572 ref: hintRef,
6573 readOnly: true,
6574 style: {
6575 backgroundColor: 'transparent',
6576 borderColor: 'transparent',
6577 boxShadow: 'none',
6578 color: 'rgba(0, 0, 0, 0.54)',
6579 left: 0,
6580 pointerEvents: 'none',
6581 position: 'absolute',
6582 top: 0,
6583 width: '100%'
6584 },
6585 tabIndex: -1,
6586 value: hintText
6587 }));
6588 };
6589
6590 var Input = /*#__PURE__*/React.forwardRef(function (props, ref) {
6591 return /*#__PURE__*/React__default["default"].createElement("input", _extends({}, props, {
6592 className: cx('rbt-input-main', props.className),
6593 ref: ref
6594 }));
6595 });
6596
6597 var _excluded$6 = ["children", "className", "inputClassName", "inputRef", "referenceElementRef", "selected"];
6598
6599 function TypeaheadInputMulti(props) {
6600 var wrapperRef = React__default["default"].useRef(null);
6601 var inputElem = React__default["default"].useRef(null);
6602
6603 var _propsWithBsClassName = propsWithBsClassName(props),
6604 children = _propsWithBsClassName.children,
6605 className = _propsWithBsClassName.className,
6606 inputClassName = _propsWithBsClassName.inputClassName;
6607 _propsWithBsClassName.inputRef;
6608 var referenceElementRef = _propsWithBsClassName.referenceElementRef,
6609 selected = _propsWithBsClassName.selected,
6610 rest = _objectWithoutProperties(_propsWithBsClassName, _excluded$6);
6611
6612 function getInputRef(input) {
6613 inputElem.current = input;
6614 props.inputRef(input);
6615 }
6616 /**
6617 * Forward click or focus events on the container element to the input.
6618 */
6619
6620
6621 function handleContainerClickOrFocus(e) {
6622 // Don't focus the input if it's disabled.
6623 if (props.disabled) {
6624 e.currentTarget.blur();
6625 return;
6626 }
6627
6628 var inputNode = inputElem.current;
6629
6630 if (!inputNode || // Ignore if the clicked element is a child of the container, ie: a token
6631 // or the input itself.
6632 e.currentTarget.contains(e.target) && e.currentTarget !== e.target) {
6633 return;
6634 }
6635
6636 if (isSelectable(inputNode)) {
6637 // Move cursor to the end if the user clicks outside the actual input.
6638 inputNode.selectionStart = inputNode.value.length;
6639 }
6640
6641 inputNode.focus();
6642 }
6643
6644 function handleKeyDown(e) {
6645 if (e.key === 'Backspace' && selected.length && !props.value) {
6646 var _wrapperRef$current;
6647
6648 // Prevent browser from going back.
6649 e.preventDefault(); // If the input is selected and there is no text, focus the last
6650 // token when the user hits backspace.
6651
6652 var wrapperChildren = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.children;
6653
6654 if (wrapperChildren !== null && wrapperChildren !== void 0 && wrapperChildren.length) {
6655 var lastToken = wrapperChildren[wrapperChildren.length - 2];
6656 lastToken === null || lastToken === void 0 ? void 0 : lastToken.focus();
6657 }
6658 }
6659
6660 props.onKeyDown && props.onKeyDown(e);
6661 }
6662
6663 return /*#__PURE__*/React__default["default"].createElement("div", {
6664 className: cx('rbt-input-multi', {
6665 disabled: props.disabled
6666 }, className),
6667 onClick: handleContainerClickOrFocus,
6668 onFocus: handleContainerClickOrFocus,
6669 ref: referenceElementRef,
6670 tabIndex: -1
6671 }, /*#__PURE__*/React__default["default"].createElement("div", {
6672 className: "rbt-input-wrapper",
6673 ref: wrapperRef
6674 }, children, /*#__PURE__*/React__default["default"].createElement(Hint, null, /*#__PURE__*/React__default["default"].createElement(Input, _extends({}, rest, {
6675 className: inputClassName,
6676 onKeyDown: handleKeyDown,
6677 ref: getInputRef,
6678 style: {
6679 backgroundColor: 'transparent',
6680 border: 0,
6681 boxShadow: 'none',
6682 cursor: 'inherit',
6683 outline: 'none',
6684 padding: 0,
6685 width: '100%',
6686 zIndex: 1
6687 }
6688 })))));
6689 }
6690
6691 var _excluded$5 = ["inputRef", "referenceElementRef"];
6692
6693 var TypeaheadInputSingle = function TypeaheadInputSingle(_ref) {
6694 var inputRef = _ref.inputRef,
6695 referenceElementRef = _ref.referenceElementRef,
6696 props = _objectWithoutProperties(_ref, _excluded$5);
6697
6698 return /*#__PURE__*/React__default["default"].createElement(Hint, null, /*#__PURE__*/React__default["default"].createElement(Input, _extends({}, propsWithBsClassName(props), {
6699 ref: function ref(node) {
6700 inputRef(node);
6701 referenceElementRef(node);
6702 }
6703 })));
6704 };
6705
6706 var propTypes$4 = {
6707 children: propTypes$b.exports.string.isRequired,
6708 highlightClassName: propTypes$b.exports.string,
6709 search: propTypes$b.exports.string.isRequired
6710 };
6711 var defaultProps$3 = {
6712 highlightClassName: 'rbt-highlight-text'
6713 };
6714
6715 /**
6716 * Stripped-down version of https://github.com/helior/react-highlighter
6717 *
6718 * Results are already filtered by the time the component is used internally so
6719 * we can safely ignore case and diacritical marks for the purposes of matching.
6720 */
6721 var Highlighter = function Highlighter(_ref) {
6722 var children = _ref.children,
6723 highlightClassName = _ref.highlightClassName,
6724 search = _ref.search;
6725
6726 if (!search || !children) {
6727 return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children);
6728 }
6729
6730 var matchCount = 0;
6731 var remaining = children;
6732 var highlighterChildren = [];
6733
6734 while (remaining) {
6735 var bounds = getMatchBounds(remaining, search); // No match anywhere in the remaining string, stop.
6736
6737 if (!bounds) {
6738 highlighterChildren.push(remaining);
6739 break;
6740 } // Capture the string that leads up to a match.
6741
6742
6743 var nonMatch = remaining.slice(0, bounds.start);
6744
6745 if (nonMatch) {
6746 highlighterChildren.push(nonMatch);
6747 } // Capture the matching string.
6748
6749
6750 var match = remaining.slice(bounds.start, bounds.end);
6751 highlighterChildren.push( /*#__PURE__*/React__default["default"].createElement("mark", {
6752 className: highlightClassName,
6753 key: matchCount
6754 }, match));
6755 matchCount += 1; // And if there's anything left over, continue the loop.
6756
6757 remaining = remaining.slice(bounds.end);
6758 }
6759
6760 return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, highlighterChildren);
6761 };
6762
6763 Highlighter.propTypes = propTypes$4;
6764 Highlighter.defaultProps = defaultProps$3;
6765
6766 function t(t){return "object"==typeof t&&null!=t&&1===t.nodeType}function e(t,e){return (!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function n(t,n){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return e(r.overflowY,n)||e(r.overflowX,n)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return !1}function r(t,e,n,r,i,o,l,d){return o<t&&l>e||o>t&&l<e?0:o<=t&&d<=n||l>=e&&d>=n?o-t-r:l>e&&d<n||o<t&&d>n?l-e+i:0}function compute(e,i){var o=window,l=i.scrollMode,d=i.block,u=i.inline,h=i.boundary,a=i.skipOverflowHiddenElements,c="function"==typeof h?h:function(t){return t!==h};if(!t(e))throw new TypeError("Invalid target");for(var f=document.scrollingElement||document.documentElement,s=[],p=e;t(p)&&c(p);){if((p=p.parentElement)===f){s.push(p);break}null!=p&&p===document.body&&n(p)&&!n(document.documentElement)||null!=p&&n(p,a)&&s.push(p);}for(var m=o.visualViewport?o.visualViewport.width:innerWidth,g=o.visualViewport?o.visualViewport.height:innerHeight,w=window.scrollX||pageXOffset,v=window.scrollY||pageYOffset,W=e.getBoundingClientRect(),b=W.height,H=W.width,y=W.top,E=W.right,M=W.bottom,V=W.left,x="start"===d||"nearest"===d?y:"end"===d?M:y+b/2,I="center"===u?V+H/2:"end"===u?E:V,C=[],T=0;T<s.length;T++){var k=s[T],B=k.getBoundingClientRect(),D=B.height,O=B.width,R=B.top,X=B.right,Y=B.bottom,L=B.left;if("if-needed"===l&&y>=0&&V>=0&&M<=g&&E<=m&&y>=R&&M<=Y&&V>=L&&E<=X)return C;var S=getComputedStyle(k),j=parseInt(S.borderLeftWidth,10),q=parseInt(S.borderTopWidth,10),z=parseInt(S.borderRightWidth,10),A=parseInt(S.borderBottomWidth,10),F=0,G=0,J="offsetWidth"in k?k.offsetWidth-k.clientWidth-j-z:0,K="offsetHeight"in k?k.offsetHeight-k.clientHeight-q-A:0;if(f===k)F="start"===d?x:"end"===d?x-g:"nearest"===d?r(v,v+g,g,q,A,v+x,v+x+b,b):x-g/2,G="start"===u?I:"center"===u?I-m/2:"end"===u?I-m:r(w,w+m,m,j,z,w+I,w+I+H,H),F=Math.max(0,F+v),G=Math.max(0,G+w);else {F="start"===d?x-R-q:"end"===d?x-Y+A+K:"nearest"===d?r(R,Y,D,q,A+K,x,x+b,b):x-(R+D/2)+K/2,G="start"===u?I-L-j:"center"===u?I-(L+O/2)+J/2:"end"===u?I-X+z+J:r(L,X,O,j,z+J,I,I+H,H);var N=k.scrollLeft,P=k.scrollTop;x+=P-(F=Math.max(0,Math.min(P+F,k.scrollHeight-D+K))),I+=N-(G=Math.max(0,Math.min(N+G,k.scrollWidth-O+J)));}C.push({el:k,top:F,left:G});}return C}
6767
6768 function isOptionsObject(options) {
6769 return options === Object(options) && Object.keys(options).length !== 0;
6770 }
6771
6772 function defaultBehavior(actions, behavior) {
6773 if (behavior === void 0) {
6774 behavior = 'auto';
6775 }
6776
6777 var canSmoothScroll = ('scrollBehavior' in document.body.style);
6778 actions.forEach(function (_ref) {
6779 var el = _ref.el,
6780 top = _ref.top,
6781 left = _ref.left;
6782
6783 if (el.scroll && canSmoothScroll) {
6784 el.scroll({
6785 top: top,
6786 left: left,
6787 behavior: behavior
6788 });
6789 } else {
6790 el.scrollTop = top;
6791 el.scrollLeft = left;
6792 }
6793 });
6794 }
6795
6796 function getOptions(options) {
6797 if (options === false) {
6798 return {
6799 block: 'end',
6800 inline: 'nearest'
6801 };
6802 }
6803
6804 if (isOptionsObject(options)) {
6805 return options;
6806 }
6807
6808 return {
6809 block: 'start',
6810 inline: 'nearest'
6811 };
6812 }
6813
6814 function scrollIntoView(target, options) {
6815 var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
6816
6817 if (isOptionsObject(options) && typeof options.behavior === 'function') {
6818 return options.behavior(isTargetAttached ? compute(target, options) : []);
6819 }
6820
6821 if (!isTargetAttached) {
6822 return;
6823 }
6824
6825 var computeOptions = getOptions(options);
6826 return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);
6827 }
6828
6829 var _excluded$4 = ["label", "onClick", "option", "position"];
6830 var propTypes$3 = {
6831 option: optionType.isRequired,
6832 position: propTypes$b.exports.number
6833 };
6834 function useItem(_ref) {
6835 var label = _ref.label,
6836 onClick = _ref.onClick,
6837 option = _ref.option,
6838 position = _ref.position,
6839 props = _objectWithoutProperties(_ref, _excluded$4);
6840
6841 var _useTypeaheadContext = useTypeaheadContext(),
6842 activeIndex = _useTypeaheadContext.activeIndex,
6843 id = _useTypeaheadContext.id,
6844 isOnlyResult = _useTypeaheadContext.isOnlyResult,
6845 onActiveItemChange = _useTypeaheadContext.onActiveItemChange,
6846 onInitialItemChange = _useTypeaheadContext.onInitialItemChange,
6847 onMenuItemClick = _useTypeaheadContext.onMenuItemClick,
6848 setItem = _useTypeaheadContext.setItem;
6849
6850 var itemRef = React.useRef(null);
6851 React.useEffect(function () {
6852 if (position === 0) {
6853 onInitialItemChange(option);
6854 }
6855 });
6856 React.useEffect(function () {
6857 if (position === activeIndex) {
6858 onActiveItemChange(option); // Automatically scroll the menu as the user keys through it.
6859
6860 var node = itemRef.current;
6861 node && scrollIntoView(node, {
6862 block: 'nearest',
6863 boundary: node.parentNode,
6864 inline: 'nearest',
6865 scrollMode: 'if-needed'
6866 });
6867 }
6868 });
6869 var handleClick = React.useCallback(function (e) {
6870 onMenuItemClick(option, e);
6871 onClick && onClick(e);
6872 }, [onClick, onMenuItemClick, option]);
6873 var active = isOnlyResult || activeIndex === position; // Update the item's position in the item stack.
6874
6875 setItem(option, position);
6876 return _objectSpread2(_objectSpread2({}, props), {}, {
6877 active: active,
6878 'aria-label': label,
6879 'aria-selected': active,
6880 id: getMenuItemId(id, position),
6881 onClick: handleClick,
6882 onMouseDown: preventInputBlur,
6883 ref: itemRef,
6884 role: 'option'
6885 });
6886 }
6887 /* istanbul ignore next */
6888
6889 function withItem(Component) {
6890 var WrappedMenuItem = function WrappedMenuItem(props) {
6891 return /*#__PURE__*/React__default["default"].createElement(Component, _extends({}, props, useItem(props)));
6892 };
6893
6894 WrappedMenuItem.displayName = "withItem(".concat(getDisplayName(Component), ")");
6895 WrappedMenuItem.propTypes = propTypes$3;
6896 return WrappedMenuItem;
6897 }
6898
6899 var _excluded$3 = ["active", "children", "className", "disabled", "onClick"];
6900 var BaseMenuItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6901 var active = _ref.active,
6902 children = _ref.children,
6903 className = _ref.className,
6904 disabled = _ref.disabled,
6905 _onClick = _ref.onClick,
6906 props = _objectWithoutProperties(_ref, _excluded$3);
6907
6908 return /*#__PURE__*/React__default["default"].createElement("a", _extends({}, props, {
6909 className: cx('dropdown-item', {
6910 active: active,
6911 disabled: disabled
6912 }, className),
6913 href: props.href || '#',
6914 onClick: function onClick(e) {
6915 e.preventDefault();
6916 !disabled && _onClick && _onClick(e);
6917 },
6918 ref: ref
6919 }), children);
6920 });
6921 function MenuItem(props) {
6922 return /*#__PURE__*/React__default["default"].createElement(BaseMenuItem, useItem(props));
6923 }
6924
6925 var _excluded$2 = ["emptyLabel", "innerRef", "maxHeight", "style"];
6926
6927 var MenuDivider = function MenuDivider() {
6928 return /*#__PURE__*/React__default["default"].createElement("div", {
6929 className: "dropdown-divider",
6930 role: "separator"
6931 });
6932 };
6933
6934 var MenuHeader = function MenuHeader(props) {
6935 return (
6936 /*#__PURE__*/
6937 // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
6938 React__default["default"].createElement("div", _extends({}, props, {
6939 className: "dropdown-header",
6940 role: "heading"
6941 }))
6942 );
6943 };
6944
6945 var propTypes$2 = {
6946 'aria-label': propTypes$b.exports.string,
6947
6948 /**
6949 * Message to display in the menu if there are no valid results.
6950 */
6951 emptyLabel: propTypes$b.exports.node,
6952
6953 /**
6954 * Needed for accessibility.
6955 */
6956 id: checkPropType(propTypes$b.exports.oneOfType([propTypes$b.exports.number, propTypes$b.exports.string]), isRequiredForA11y),
6957
6958 /**
6959 * Maximum height of the dropdown menu.
6960 */
6961 maxHeight: propTypes$b.exports.string
6962 };
6963 var defaultProps$2 = {
6964 'aria-label': 'menu-options'
6965 };
6966
6967 /**
6968 * Menu component that handles empty state when passed a set of results.
6969 */
6970 var Menu = function Menu(_ref) {
6971 var _ref$emptyLabel = _ref.emptyLabel,
6972 emptyLabel = _ref$emptyLabel === void 0 ? 'No matches found.' : _ref$emptyLabel,
6973 innerRef = _ref.innerRef,
6974 _ref$maxHeight = _ref.maxHeight,
6975 maxHeight = _ref$maxHeight === void 0 ? '300px' : _ref$maxHeight,
6976 style = _ref.style,
6977 props = _objectWithoutProperties(_ref, _excluded$2);
6978
6979 var children = React.Children.count(props.children) === 0 ? /*#__PURE__*/React__default["default"].createElement(BaseMenuItem, {
6980 disabled: true,
6981 role: "option"
6982 }, emptyLabel) : props.children;
6983 return (
6984 /*#__PURE__*/
6985
6986 /* eslint-disable jsx-a11y/interactive-supports-focus */
6987 React__default["default"].createElement("div", _extends({}, props, {
6988 className: cx('rbt-menu', 'dropdown-menu', 'show', props.className),
6989 onMouseDown: // Prevent input from blurring when clicking on the menu scrollbar.
6990 preventInputBlur,
6991 ref: innerRef,
6992 role: "listbox",
6993 style: _objectSpread2(_objectSpread2({}, style), {}, {
6994 display: 'block',
6995 maxHeight: maxHeight,
6996 overflow: 'auto'
6997 })
6998 }), children)
6999 /* eslint-enable jsx-a11y/interactive-supports-focus */
7000
7001 );
7002 };
7003
7004 Menu.propTypes = propTypes$2;
7005 Menu.defaultProps = defaultProps$2;
7006 Menu.Divider = MenuDivider;
7007 Menu.Header = MenuHeader;
7008
7009 var _excluded$1 = ["labelKey", "newSelectionPrefix", "options", "paginationText", "renderMenuItemChildren", "text"];
7010 var propTypes$1 = {
7011 /**
7012 * Provides the ability to specify a prefix before the user-entered text to
7013 * indicate that the selection will be new. No-op unless `allowNew={true}`.
7014 */
7015 newSelectionPrefix: propTypes$b.exports.node,
7016
7017 /**
7018 * Prompt displayed when large data sets are paginated.
7019 */
7020 paginationText: propTypes$b.exports.node,
7021
7022 /**
7023 * Provides a hook for customized rendering of menu item contents.
7024 */
7025 renderMenuItemChildren: propTypes$b.exports.func
7026 };
7027 var defaultProps$1 = {
7028 newSelectionPrefix: 'New selection: ',
7029 paginationText: 'Display additional results...',
7030 renderMenuItemChildren: function renderMenuItemChildren(option, props) {
7031 return /*#__PURE__*/React__default["default"].createElement(Highlighter, {
7032 search: props.text
7033 }, getOptionLabel(option, props.labelKey));
7034 }
7035 };
7036
7037 var TypeaheadMenu = function TypeaheadMenu(props) {
7038 var labelKey = props.labelKey,
7039 newSelectionPrefix = props.newSelectionPrefix,
7040 options = props.options,
7041 paginationText = props.paginationText,
7042 renderMenuItemChildren = props.renderMenuItemChildren,
7043 text = props.text,
7044 menuProps = _objectWithoutProperties(props, _excluded$1);
7045
7046 var renderMenuItem = function renderMenuItem(option, position) {
7047 var label = getOptionLabel(option, labelKey);
7048 var menuItemProps = {
7049 disabled: !!getOptionProperty(option, 'disabled'),
7050 label: label,
7051 option: option,
7052 position: position
7053 };
7054
7055 if (getOptionProperty(option, 'customOption')) {
7056 return /*#__PURE__*/React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
7057 className: "rbt-menu-custom-option",
7058 key: position,
7059 label: label
7060 }), newSelectionPrefix, /*#__PURE__*/React__default["default"].createElement(Highlighter, {
7061 search: text
7062 }, label));
7063 }
7064
7065 if (getOptionProperty(option, 'paginationOption')) {
7066 return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
7067 key: "pagination-option-divider"
7068 }, /*#__PURE__*/React__default["default"].createElement(Menu.Divider, null), /*#__PURE__*/React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
7069 className: "rbt-menu-pagination-option",
7070 label: // TODO: Fix how (aria-)labels are passed to `MenuItem`.
7071 // `paginationText` can be a ReactNode.
7072 isString(paginationText) ? paginationText : ''
7073 }), paginationText));
7074 }
7075
7076 return /*#__PURE__*/React__default["default"].createElement(MenuItem, _extends({}, menuItemProps, {
7077 key: position
7078 }), renderMenuItemChildren(option, props, position));
7079 };
7080
7081 return /*#__PURE__*/React__default["default"].createElement(Menu, _extends({}, menuProps, {
7082 key: // Force a re-render if the text changes to ensure that menu
7083 // positioning updates correctly.
7084 text
7085 }), options.map(renderMenuItem));
7086 };
7087
7088 TypeaheadMenu.propTypes = propTypes$1;
7089 TypeaheadMenu.defaultProps = defaultProps$1;
7090
7091 var _excluded = ["children", "onRootClose"];
7092 var propTypes = {
7093 /**
7094 * Displays a button to clear the input when there are selections.
7095 */
7096 clearButton: propTypes$b.exports.bool,
7097
7098 /**
7099 * Props to be applied directly to the input. `onBlur`, `onChange`,
7100 * `onFocus`, and `onKeyDown` are ignored.
7101 */
7102 inputProps: checkPropType(propTypes$b.exports.object, inputPropsType),
7103
7104 /**
7105 * Bootstrap 4 only. Adds the `is-invalid` classname to the `form-control`.
7106 */
7107 isInvalid: propTypes$b.exports.bool,
7108
7109 /**
7110 * Indicate whether an asynchronous data fetch is happening.
7111 */
7112 isLoading: propTypes$b.exports.bool,
7113
7114 /**
7115 * Bootstrap 4 only. Adds the `is-valid` classname to the `form-control`.
7116 */
7117 isValid: propTypes$b.exports.bool,
7118
7119 /**
7120 * Callback for custom input rendering.
7121 */
7122 renderInput: propTypes$b.exports.func,
7123
7124 /**
7125 * Callback for custom menu rendering.
7126 */
7127 renderMenu: propTypes$b.exports.func,
7128
7129 /**
7130 * Callback for custom menu rendering.
7131 */
7132 renderToken: propTypes$b.exports.func,
7133
7134 /**
7135 * Specifies the size of the input.
7136 */
7137 size: sizeType
7138 };
7139 var defaultProps = {
7140 isLoading: false
7141 };
7142
7143 var defaultRenderMenu = function defaultRenderMenu(results, menuProps, props) {
7144 return /*#__PURE__*/React__default["default"].createElement(TypeaheadMenu, _extends({}, menuProps, {
7145 labelKey: props.labelKey,
7146 options: results,
7147 text: props.text
7148 }));
7149 };
7150
7151 var defaultRenderToken = function defaultRenderToken(option, props, idx) {
7152 return /*#__PURE__*/React__default["default"].createElement(Token, {
7153 disabled: props.disabled,
7154 key: idx,
7155 onRemove: props.onRemove,
7156 option: option,
7157 tabIndex: props.tabIndex
7158 }, getOptionLabel(option, props.labelKey));
7159 };
7160
7161 var overlayPropKeys = ['align', 'dropup', 'flip', 'positionFixed'];
7162
7163 function getOverlayProps(props) {
7164 return pick(props, overlayPropKeys);
7165 }
7166
7167 var RootClose = function RootClose(_ref) {
7168 var children = _ref.children,
7169 onRootClose = _ref.onRootClose,
7170 props = _objectWithoutProperties(_ref, _excluded);
7171
7172 var _useState = React.useState(null),
7173 _useState2 = _slicedToArray(_useState, 2),
7174 rootElement = _useState2[0],
7175 attachRef = _useState2[1];
7176
7177 useRootClose(rootElement, onRootClose, props);
7178 return children(attachRef);
7179 };
7180
7181 var TypeaheadComponent = /*#__PURE__*/function (_React$Component) {
7182 _inherits(TypeaheadComponent, _React$Component);
7183
7184 var _super = _createSuper(TypeaheadComponent);
7185
7186 function TypeaheadComponent() {
7187 var _this;
7188
7189 _classCallCheck(this, TypeaheadComponent);
7190
7191 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7192 args[_key] = arguments[_key];
7193 }
7194
7195 _this = _super.call.apply(_super, [this].concat(args));
7196
7197 _defineProperty(_assertThisInitialized(_this), "_referenceElement", null);
7198
7199 _defineProperty(_assertThisInitialized(_this), "referenceElementRef", function (referenceElement) {
7200 _this._referenceElement = referenceElement;
7201 });
7202
7203 _defineProperty(_assertThisInitialized(_this), "_renderInput", function (inputProps, props) {
7204 var _this$props = _this.props,
7205 isInvalid = _this$props.isInvalid,
7206 isValid = _this$props.isValid,
7207 multiple = _this$props.multiple,
7208 renderInput = _this$props.renderInput,
7209 renderToken = _this$props.renderToken,
7210 size = _this$props.size;
7211
7212 if (isFunction(renderInput)) {
7213 return renderInput(inputProps, props);
7214 }
7215
7216 var commonProps = _objectSpread2(_objectSpread2({}, inputProps), {}, {
7217 isInvalid: isInvalid,
7218 isValid: isValid,
7219 size: size
7220 });
7221
7222 if (!multiple) {
7223 return /*#__PURE__*/React__default["default"].createElement(TypeaheadInputSingle, commonProps);
7224 }
7225
7226 var labelKey = props.labelKey,
7227 onRemove = props.onRemove,
7228 selected = props.selected;
7229 return /*#__PURE__*/React__default["default"].createElement(TypeaheadInputMulti, _extends({}, commonProps, {
7230 placeholder: selected.length ? '' : inputProps.placeholder,
7231 selected: selected
7232 }), selected.map(function (option, idx) {
7233 return (renderToken || defaultRenderToken)(option, _objectSpread2(_objectSpread2({}, commonProps), {}, {
7234 labelKey: labelKey,
7235 onRemove: onRemove
7236 }), idx);
7237 }));
7238 });
7239
7240 _defineProperty(_assertThisInitialized(_this), "_renderMenu", function (results, menuProps, props) {
7241 var _this$props2 = _this.props,
7242 emptyLabel = _this$props2.emptyLabel,
7243 id = _this$props2.id,
7244 maxHeight = _this$props2.maxHeight,
7245 newSelectionPrefix = _this$props2.newSelectionPrefix,
7246 paginationText = _this$props2.paginationText,
7247 renderMenu = _this$props2.renderMenu,
7248 renderMenuItemChildren = _this$props2.renderMenuItemChildren;
7249 return (renderMenu || defaultRenderMenu)(results, _objectSpread2(_objectSpread2({}, menuProps), {}, {
7250 emptyLabel: emptyLabel,
7251 id: id,
7252 maxHeight: maxHeight,
7253 newSelectionPrefix: newSelectionPrefix,
7254 paginationText: paginationText,
7255 renderMenuItemChildren: renderMenuItemChildren
7256 }), props);
7257 });
7258
7259 _defineProperty(_assertThisInitialized(_this), "_renderAux", function (_ref2) {
7260 var onClear = _ref2.onClear,
7261 selected = _ref2.selected;
7262 var _this$props3 = _this.props,
7263 clearButton = _this$props3.clearButton,
7264 disabled = _this$props3.disabled,
7265 isLoading = _this$props3.isLoading,
7266 size = _this$props3.size;
7267 var content;
7268
7269 if (isLoading) {
7270 content = /*#__PURE__*/React__default["default"].createElement(Loader, null);
7271 } else if (clearButton && !disabled && selected.length) {
7272 content = /*#__PURE__*/React__default["default"].createElement(ClearButton, {
7273 onClick: onClear,
7274 onMouseDown: preventInputBlur,
7275 size: size
7276 });
7277 }
7278
7279 return content ? /*#__PURE__*/React__default["default"].createElement("div", {
7280 className: cx('rbt-aux', {
7281 'rbt-aux-lg': isSizeLarge(size)
7282 })
7283 }, content) : null;
7284 });
7285
7286 return _this;
7287 }
7288
7289 _createClass(TypeaheadComponent, [{
7290 key: "render",
7291 value: function render() {
7292 var _this2 = this;
7293
7294 var _this$props4 = this.props,
7295 children = _this$props4.children,
7296 className = _this$props4.className,
7297 instanceRef = _this$props4.instanceRef,
7298 open = _this$props4.open,
7299 options = _this$props4.options,
7300 style = _this$props4.style;
7301 return /*#__PURE__*/React__default["default"].createElement(Typeahead$1, _extends({}, this.props, {
7302 options: options,
7303 ref: instanceRef
7304 }), function (props) {
7305 var hideMenu = props.hideMenu,
7306 isMenuShown = props.isMenuShown,
7307 results = props.results;
7308
7309 var auxContent = _this2._renderAux(props);
7310
7311 return /*#__PURE__*/React__default["default"].createElement(RootClose, {
7312 disabled: open || !isMenuShown,
7313 onRootClose: hideMenu
7314 }, function (ref) {
7315 return /*#__PURE__*/React__default["default"].createElement("div", {
7316 className: cx('rbt', {
7317 'has-aux': !!auxContent
7318 }, className),
7319 ref: ref,
7320 style: _objectSpread2(_objectSpread2({}, style), {}, {
7321 outline: 'none',
7322 position: 'relative'
7323 }),
7324 tabIndex: -1
7325 }, _this2._renderInput(_objectSpread2(_objectSpread2({}, props.getInputProps(_this2.props.inputProps)), {}, {
7326 referenceElementRef: _this2.referenceElementRef
7327 }), props), /*#__PURE__*/React__default["default"].createElement(Overlay, _extends({}, getOverlayProps(_this2.props), {
7328 isMenuShown: isMenuShown,
7329 referenceElement: _this2._referenceElement
7330 }), function (menuProps) {
7331 return _this2._renderMenu(results, menuProps, props);
7332 }), auxContent, isFunction(children) ? children(props) : children);
7333 });
7334 });
7335 }
7336 }]);
7337
7338 return TypeaheadComponent;
7339 }(React__default["default"].Component);
7340
7341 _defineProperty(TypeaheadComponent, "propTypes", propTypes);
7342
7343 _defineProperty(TypeaheadComponent, "defaultProps", defaultProps);
7344
7345 var Typeahead = /*#__PURE__*/React.forwardRef(function (props, ref) {
7346 return /*#__PURE__*/React__default["default"].createElement(TypeaheadComponent, _extends({}, props, {
7347 instanceRef: ref
7348 }));
7349 });
7350
7351 var AsyncTypeahead = withAsync(Typeahead);
7352
7353 exports.AsyncTypeahead = AsyncTypeahead;
7354 exports.ClearButton = ClearButton;
7355 exports.Highlighter = Highlighter;
7356 exports.Hint = Hint;
7357 exports.Input = Input;
7358 exports.Loader = Loader;
7359 exports.Menu = Menu;
7360 exports.MenuItem = MenuItem;
7361 exports.Token = Token;
7362 exports.Typeahead = Typeahead;
7363 exports.TypeaheadInputMulti = TypeaheadInputMulti;
7364 exports.TypeaheadInputSingle = TypeaheadInputSingle;
7365 exports.TypeaheadMenu = TypeaheadMenu;
7366 exports.useAsync = useAsync;
7367 exports.useHint = useHint;
7368 exports.useItem = useItem;
7369 exports.useToken = useToken;
7370 exports.withAsync = withAsync;
7371 exports.withItem = withItem;
7372 exports.withToken = withToken;
7373
7374 Object.defineProperty(exports, '__esModule', { value: true });
7375
7376}));