diff --git a/package.json b/package.json index d1b7771..1d68a53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choices.js", - "version": "5.0.0", + "version": "5.1.0", "description": "A vanilla JS customisable text input/select box plugin", "main": "./public/assets/scripts/choices.min.js", "types": "./types/index.d.ts", diff --git a/public/assets/scripts/choices.js b/public/assets/scripts/choices.js index aac6c15..e0f208c 100644 --- a/public/assets/scripts/choices.js +++ b/public/assets/scripts/choices.js @@ -802,7 +802,7 @@ var TEMPLATES = { var _classNames3; localClasses = (0, _classnames.default)(globalClasses.item, (_classNames3 = {}, _defineProperty(_classNames3, globalClasses.highlightedState, data.highlighted), _defineProperty(_classNames3, globalClasses.itemSelectable, !data.disabled), _defineProperty(_classNames3, globalClasses.placeholder, data.placeholder), _classNames3)); - return (0, _utils.strToEl)("\n \n ").concat(data.label, "\n Remove item\n \n \n ")); + return (0, _utils.strToEl)("\n \n ").concat(data.label, "\n Remove item\n \n \n ")); } return (0, _utils.strToEl)("\n \n ").concat(data.label, "\n \n ")); @@ -839,7 +839,7 @@ var TEMPLATES = { return (0, _utils.strToEl)("\n
\n ").concat(label, "\n
\n ")); }, option: function option(data) { - return (0, _utils.strToEl)("\n \n ")); + return (0, _utils.strToEl)("\n \n ")); } }; exports.TEMPLATES = TEMPLATES; @@ -3701,14 +3701,12 @@ function () { label: o.innerHTML, selected: o.selected, disabled: o.disabled || o.parentNode.disabled, - placeholder: o.hasAttribute('placeholder') + placeholder: o.hasAttribute('placeholder'), + customProperties: o.getAttribute('data-custom-properties') }); }); // If sorting is enabled or the user is searching, filter choices - if (this.config.shouldSort) { - allChoices.sort(filter); - } // Determine whether there is a selected choice - + if (this.config.shouldSort) allChoices.sort(filter); // Determine whether there is a selected choice var hasSelectedChoice = allChoices.some(function (choice) { return choice.selected; @@ -3897,7 +3895,7 @@ module.exports = Choices; /***/ (function(module, exports, __webpack_require__) { /*! - * Fuse.js v3.4.1 - Lightweight fuzzy-search (http://fusejs.io) + * Fuse.js v3.4.2 - Lightweight fuzzy-search (http://fusejs.io) * * Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 @@ -4004,14 +4002,16 @@ return /******/ (function(modules) { // webpackBootstrap /*! no static exports found */ /***/ (function(module, exports) { -module.exports = (matchmask = [], minMatchCharLength = 1) => { - let matchedIndices = []; - let start = -1; - let end = -1; - let i = 0; +module.exports = function () { + var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; + var matchedIndices = []; + var start = -1; + var end = -1; + var i = 0; - for (let len = matchmask.length; i < len; i += 1) { - let match = matchmask[i]; + for (var len = matchmask.length; i < len; i += 1) { + var match = matchmask[i]; if (match && start === -1) { start = i; @@ -4043,16 +4043,16 @@ module.exports = (matchmask = [], minMatchCharLength = 1) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = pattern => { - let mask = {}; - let len = pattern.length; +module.exports = function (pattern) { + var mask = {}; + var len = pattern.length; - for (let i = 0; i < len; i += 1) { + for (var i = 0; i < len; i += 1) { mask[pattern.charAt(i)] = 0; } - for (let i = 0; i < len; i += 1) { - mask[pattern.charAt(i)] |= 1 << len - i - 1; + for (var _i = 0; _i < len; _i += 1) { + mask[pattern.charAt(_i)] |= 1 << len - _i - 1; } return mask; @@ -4067,17 +4067,18 @@ module.exports = pattern => { /*! no static exports found */ /***/ (function(module, exports) { -const SPECIAL_CHARS_REGEX = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; +var SPECIAL_CHARS_REGEX = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; -module.exports = (text, pattern, tokenSeparator = / +/g) => { - let regex = new RegExp(pattern.replace(SPECIAL_CHARS_REGEX, '\\$&').replace(tokenSeparator, '|')); - let matches = text.match(regex); - let isMatch = !!matches; - let matchedIndices = []; +module.exports = function (text, pattern) { + var tokenSeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : / +/g; + var regex = new RegExp(pattern.replace(SPECIAL_CHARS_REGEX, '\\$&').replace(tokenSeparator, '|')); + var matches = text.match(regex); + var isMatch = !!matches; + var matchedIndices = []; if (isMatch) { - for (let i = 0, matchesLen = matches.length; i < matchesLen; i += 1) { - let match = matches[i]; + for (var i = 0, matchesLen = matches.length; i < matchesLen; i += 1) { + var match = matches[i]; matchedIndices.push([text.indexOf(match), match.length - 1]); } } @@ -4085,8 +4086,8 @@ module.exports = (text, pattern, tokenSeparator = / +/g) => { return { // TODO: revisit this score score: isMatch ? 0.5 : 1, - isMatch, - matchedIndices + isMatch: isMatch, + matchedIndices: matchedIndices }; }; @@ -4099,14 +4100,17 @@ module.exports = (text, pattern, tokenSeparator = / +/g) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = (pattern, { - errors = 0, - currentLocation = 0, - expectedLocation = 0, - distance = 100 -}) => { - const accuracy = errors / pattern.length; - const proximity = Math.abs(expectedLocation - currentLocation); +module.exports = function (pattern, _ref) { + var _ref$errors = _ref.errors, + errors = _ref$errors === void 0 ? 0 : _ref$errors, + _ref$currentLocation = _ref.currentLocation, + currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation, + _ref$expectedLocation = _ref.expectedLocation, + expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance; + var accuracy = errors / pattern.length; + var proximity = Math.abs(expectedLocation - currentLocation); if (!distance) { // Dodge divide by zero error. @@ -4125,77 +4129,82 @@ module.exports = (pattern, { /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const bitapScore = __webpack_require__(/*! ./bitap_score */ "./src/bitap/bitap_score.js"); +var bitapScore = __webpack_require__(/*! ./bitap_score */ "./src/bitap/bitap_score.js"); -const matchedIndices = __webpack_require__(/*! ./bitap_matched_indices */ "./src/bitap/bitap_matched_indices.js"); +var matchedIndices = __webpack_require__(/*! ./bitap_matched_indices */ "./src/bitap/bitap_matched_indices.js"); -module.exports = (text, pattern, patternAlphabet, { - location = 0, - distance = 100, - threshold = 0.6, - findAllMatches = false, - minMatchCharLength = 1 -}) => { - const expectedLocation = location; // Set starting location at beginning text and initialize the alphabet. +module.exports = function (text, pattern, patternAlphabet, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng; + var expectedLocation = location; // Set starting location at beginning text and initialize the alphabet. - const textLen = text.length; // Highest score beyond which we give up. + var textLen = text.length; // Highest score beyond which we give up. - let currentThreshold = threshold; // Is there a nearby exact match? (speedup) + var currentThreshold = threshold; // Is there a nearby exact match? (speedup) - let bestLocation = text.indexOf(pattern, expectedLocation); - const patternLen = pattern.length; // a mask of the matches + var bestLocation = text.indexOf(pattern, expectedLocation); + var patternLen = pattern.length; // a mask of the matches - const matchMask = []; + var matchMask = []; - for (let i = 0; i < textLen; i += 1) { + for (var i = 0; i < textLen; i += 1) { matchMask[i] = 0; } if (bestLocation !== -1) { - let score = bitapScore(pattern, { + var score = bitapScore(pattern, { errors: 0, currentLocation: bestLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); currentThreshold = Math.min(score, currentThreshold); // What about in the other direction? (speed up) bestLocation = text.lastIndexOf(pattern, expectedLocation + patternLen); if (bestLocation !== -1) { - let score = bitapScore(pattern, { + var _score = bitapScore(pattern, { errors: 0, currentLocation: bestLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); - currentThreshold = Math.min(score, currentThreshold); + + currentThreshold = Math.min(_score, currentThreshold); } } // Reset the best location bestLocation = -1; - let lastBitArr = []; - let finalScore = 1; - let binMax = patternLen + textLen; - const mask = 1 << patternLen - 1; + var lastBitArr = []; + var finalScore = 1; + var binMax = patternLen + textLen; + var mask = 1 << patternLen - 1; - for (let i = 0; i < patternLen; i += 1) { + for (var _i = 0; _i < patternLen; _i += 1) { // Scan for the best match; each iteration allows for one more error. // Run a binary search to determine how far from the match location we can stray // at this error level. - let binMin = 0; - let binMid = binMax; + var binMin = 0; + var binMid = binMax; while (binMin < binMid) { - const score = bitapScore(pattern, { - errors: i, + var _score3 = bitapScore(pattern, { + errors: _i, currentLocation: expectedLocation + binMid, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); - if (score <= currentThreshold) { + if (_score3 <= currentThreshold) { binMin = binMid; } else { binMax = binMid; @@ -4206,15 +4215,15 @@ module.exports = (text, pattern, patternAlphabet, { binMax = binMid; - let start = Math.max(1, expectedLocation - binMid + 1); - let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; // Initialize the bit array + var start = Math.max(1, expectedLocation - binMid + 1); + var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; // Initialize the bit array - let bitArr = Array(finish + 2); - bitArr[finish + 1] = (1 << i) - 1; + var bitArr = Array(finish + 2); + bitArr[finish + 1] = (1 << _i) - 1; - for (let j = finish; j >= start; j -= 1) { - let currentLocation = j - 1; - let charMatch = patternAlphabet[text.charAt(currentLocation)]; + for (var j = finish; j >= start; j -= 1) { + var currentLocation = j - 1; + var charMatch = patternAlphabet[text.charAt(currentLocation)]; if (charMatch) { matchMask[currentLocation] = 1; @@ -4223,16 +4232,16 @@ module.exports = (text, pattern, patternAlphabet, { bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch; // Subsequent passes: fuzzy match - if (i !== 0) { + if (_i !== 0) { bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1]; } if (bitArr[j] & mask) { finalScore = bitapScore(pattern, { - errors: i, - currentLocation, - expectedLocation, - distance + errors: _i, + currentLocation: currentLocation, + expectedLocation: expectedLocation, + distance: distance }); // This match will almost certainly be better than any existing match. // But check anyway. @@ -4252,14 +4261,15 @@ module.exports = (text, pattern, patternAlphabet, { } // No hope for a (better) match at greater error levels. - const score = bitapScore(pattern, { - errors: i + 1, + var _score2 = bitapScore(pattern, { + errors: _i + 1, currentLocation: expectedLocation, - expectedLocation, - distance + expectedLocation: expectedLocation, + distance: distance }); // console.log('score', score, finalScore) - if (score > currentThreshold) { + + if (_score2 > currentThreshold) { break; } @@ -4284,46 +4294,50 @@ module.exports = (text, pattern, patternAlphabet, { /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const bitapRegexSearch = __webpack_require__(/*! ./bitap_regex_search */ "./src/bitap/bitap_regex_search.js"); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -const bitapSearch = __webpack_require__(/*! ./bitap_search */ "./src/bitap/bitap_search.js"); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } -const patternAlphabet = __webpack_require__(/*! ./bitap_pattern_alphabet */ "./src/bitap/bitap_pattern_alphabet.js"); +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var bitapRegexSearch = __webpack_require__(/*! ./bitap_regex_search */ "./src/bitap/bitap_regex_search.js"); + +var bitapSearch = __webpack_require__(/*! ./bitap_search */ "./src/bitap/bitap_search.js"); + +var patternAlphabet = __webpack_require__(/*! ./bitap_pattern_alphabet */ "./src/bitap/bitap_pattern_alphabet.js"); + +var Bitap = +/*#__PURE__*/ +function () { + function Bitap(pattern, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$maxPatternLength = _ref.maxPatternLength, + maxPatternLength = _ref$maxPatternLength === void 0 ? 32 : _ref$maxPatternLength, + _ref$isCaseSensitive = _ref.isCaseSensitive, + isCaseSensitive = _ref$isCaseSensitive === void 0 ? false : _ref$isCaseSensitive, + _ref$tokenSeparator = _ref.tokenSeparator, + tokenSeparator = _ref$tokenSeparator === void 0 ? / +/g : _ref$tokenSeparator, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng; + + _classCallCheck(this, Bitap); -class Bitap { - constructor(pattern, { - // Approximately where in the text is the pattern expected to be found? - location = 0, - // Determines how close the match must be to the fuzzy location (specified above). - // An exact letter match which is 'distance' characters away from the fuzzy location - // would score as a complete mismatch. A distance of '0' requires the match be at - // the exact location specified, a threshold of '1000' would require a perfect match - // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. - distance = 100, - // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match - // (of both letters and location), a threshold of '1.0' would match anything. - threshold = 0.6, - // Machine word size - maxPatternLength = 32, - // Indicates whether comparisons should be case sensitive. - isCaseSensitive = false, - // Regex used to separate words when searching. Only applicable when `tokenize` is `true`. - tokenSeparator = / +/g, - // When true, the algorithm continues searching to the end of the input even if a perfect - // match is found before the end of the same input. - findAllMatches = false, - // Minimum number of characters that must be matched before a result is considered a match - minMatchCharLength = 1 - }) { this.options = { - location, - distance, - threshold, - maxPatternLength, - isCaseSensitive, - tokenSeparator, - findAllMatches, - minMatchCharLength + location: location, + distance: distance, + threshold: threshold, + maxPatternLength: maxPatternLength, + isCaseSensitive: isCaseSensitive, + tokenSeparator: tokenSeparator, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength }; this.pattern = this.options.isCaseSensitive ? pattern : pattern.toLowerCase(); @@ -4332,48 +4346,50 @@ class Bitap { } } - search(text) { - if (!this.options.isCaseSensitive) { - text = text.toLowerCase(); - } // Exact match + _createClass(Bitap, [{ + key: "search", + value: function search(text) { + if (!this.options.isCaseSensitive) { + text = text.toLowerCase(); + } // Exact match - if (this.pattern === text) { - return { - isMatch: true, - score: 0, - matchedIndices: [[0, text.length - 1]] - }; - } // When pattern length is greater than the machine word length, just do a a regex comparison + if (this.pattern === text) { + return { + isMatch: true, + score: 0, + matchedIndices: [[0, text.length - 1]] + }; + } // When pattern length is greater than the machine word length, just do a a regex comparison - const { - maxPatternLength, - tokenSeparator - } = this.options; + var _this$options = this.options, + maxPatternLength = _this$options.maxPatternLength, + tokenSeparator = _this$options.tokenSeparator; - if (this.pattern.length > maxPatternLength) { - return bitapRegexSearch(text, this.pattern, tokenSeparator); - } // Otherwise, use Bitap algorithm + if (this.pattern.length > maxPatternLength) { + return bitapRegexSearch(text, this.pattern, tokenSeparator); + } // Otherwise, use Bitap algorithm - const { - location, - distance, - threshold, - findAllMatches, - minMatchCharLength - } = this.options; - return bitapSearch(text, this.pattern, this.patternAlphabet, { - location, - distance, - threshold, - findAllMatches, - minMatchCharLength - }); - } + var _this$options2 = this.options, + location = _this$options2.location, + distance = _this$options2.distance, + threshold = _this$options2.threshold, + findAllMatches = _this$options2.findAllMatches, + minMatchCharLength = _this$options2.minMatchCharLength; + return bitapSearch(text, this.pattern, this.patternAlphabet, { + location: location, + distance: distance, + threshold: threshold, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength + }); + } + }]); -} // let x = new Bitap("od mn war", {}) + return Bitap; +}(); // let x = new Bitap("od mn war", {}) // let result = x.search("Old Man's War") // console.log(result) @@ -4389,30 +4405,30 @@ module.exports = Bitap; /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const isArray = __webpack_require__(/*! ./is_array */ "./src/helpers/is_array.js"); +var isArray = __webpack_require__(/*! ./is_array */ "./src/helpers/is_array.js"); -const deepValue = (obj, path, list) => { +var deepValue = function deepValue(obj, path, list) { if (!path) { // If there's no path left, we've gotten to the object we care about. list.push(obj); } else { - const dotIndex = path.indexOf('.'); - let firstSegment = path; - let remaining = null; + var dotIndex = path.indexOf('.'); + var firstSegment = path; + var remaining = null; if (dotIndex !== -1) { firstSegment = path.slice(0, dotIndex); remaining = path.slice(dotIndex + 1); } - const value = obj[firstSegment]; + var value = obj[firstSegment]; if (value !== null && value !== undefined) { if (!remaining && (typeof value === 'string' || typeof value === 'number')) { list.push(value.toString()); } else if (isArray(value)) { // Search each item in the array. - for (let i = 0, len = value.length; i < len; i += 1) { + for (var i = 0, len = value.length; i < len; i += 1) { deepValue(value[i], remaining, list); } } else if (remaining) { @@ -4425,7 +4441,7 @@ const deepValue = (obj, path, list) => { return list; }; -module.exports = (obj, path) => { +module.exports = function (obj, path) { return deepValue(obj, path, []); }; @@ -4438,7 +4454,9 @@ module.exports = (obj, path) => { /*! no static exports found */ /***/ (function(module, exports) { -module.exports = obj => !Array.isArray ? Object.prototype.toString.call(obj) === '[object Array]' : Array.isArray(obj); +module.exports = function (obj) { + return !Array.isArray ? Object.prototype.toString.call(obj) === '[object Array]' : Array.isArray(obj); +}; /***/ }), @@ -4449,476 +4467,502 @@ module.exports = obj => !Array.isArray ? Object.prototype.toString.call(obj) === /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -const Bitap = __webpack_require__(/*! ./bitap */ "./src/bitap/index.js"); +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } -const deepValue = __webpack_require__(/*! ./helpers/deep_value */ "./src/helpers/deep_value.js"); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -const isArray = __webpack_require__(/*! ./helpers/is_array */ "./src/helpers/is_array.js"); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var Bitap = __webpack_require__(/*! ./bitap */ "./src/bitap/index.js"); + +var deepValue = __webpack_require__(/*! ./helpers/deep_value */ "./src/helpers/deep_value.js"); + +var isArray = __webpack_require__(/*! ./helpers/is_array */ "./src/helpers/is_array.js"); + +var Fuse = +/*#__PURE__*/ +function () { + function Fuse(list, _ref) { + var _ref$location = _ref.location, + location = _ref$location === void 0 ? 0 : _ref$location, + _ref$distance = _ref.distance, + distance = _ref$distance === void 0 ? 100 : _ref$distance, + _ref$threshold = _ref.threshold, + threshold = _ref$threshold === void 0 ? 0.6 : _ref$threshold, + _ref$maxPatternLength = _ref.maxPatternLength, + maxPatternLength = _ref$maxPatternLength === void 0 ? 32 : _ref$maxPatternLength, + _ref$caseSensitive = _ref.caseSensitive, + caseSensitive = _ref$caseSensitive === void 0 ? false : _ref$caseSensitive, + _ref$tokenSeparator = _ref.tokenSeparator, + tokenSeparator = _ref$tokenSeparator === void 0 ? / +/g : _ref$tokenSeparator, + _ref$findAllMatches = _ref.findAllMatches, + findAllMatches = _ref$findAllMatches === void 0 ? false : _ref$findAllMatches, + _ref$minMatchCharLeng = _ref.minMatchCharLength, + minMatchCharLength = _ref$minMatchCharLeng === void 0 ? 1 : _ref$minMatchCharLeng, + _ref$id = _ref.id, + id = _ref$id === void 0 ? null : _ref$id, + _ref$keys = _ref.keys, + keys = _ref$keys === void 0 ? [] : _ref$keys, + _ref$shouldSort = _ref.shouldSort, + shouldSort = _ref$shouldSort === void 0 ? true : _ref$shouldSort, + _ref$getFn = _ref.getFn, + getFn = _ref$getFn === void 0 ? deepValue : _ref$getFn, + _ref$sortFn = _ref.sortFn, + sortFn = _ref$sortFn === void 0 ? function (a, b) { + return a.score - b.score; + } : _ref$sortFn, + _ref$tokenize = _ref.tokenize, + tokenize = _ref$tokenize === void 0 ? false : _ref$tokenize, + _ref$matchAllTokens = _ref.matchAllTokens, + matchAllTokens = _ref$matchAllTokens === void 0 ? false : _ref$matchAllTokens, + _ref$includeMatches = _ref.includeMatches, + includeMatches = _ref$includeMatches === void 0 ? false : _ref$includeMatches, + _ref$includeScore = _ref.includeScore, + includeScore = _ref$includeScore === void 0 ? false : _ref$includeScore, + _ref$verbose = _ref.verbose, + verbose = _ref$verbose === void 0 ? false : _ref$verbose; + + _classCallCheck(this, Fuse); -class Fuse { - constructor(list, { - // Approximately where in the text is the pattern expected to be found? - location = 0, - // Determines how close the match must be to the fuzzy location (specified above). - // An exact letter match which is 'distance' characters away from the fuzzy location - // would score as a complete mismatch. A distance of '0' requires the match be at - // the exact location specified, a threshold of '1000' would require a perfect match - // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. - distance = 100, - // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match - // (of both letters and location), a threshold of '1.0' would match anything. - threshold = 0.6, - // Machine word size - maxPatternLength = 32, - // Indicates whether comparisons should be case sensitive. - caseSensitive = false, - // Regex used to separate words when searching. Only applicable when `tokenize` is `true`. - tokenSeparator = / +/g, - // When true, the algorithm continues searching to the end of the input even if a perfect - // match is found before the end of the same input. - findAllMatches = false, - // Minimum number of characters that must be matched before a result is considered a match - minMatchCharLength = 1, - // The name of the identifier property. If specified, the returned result will be a list - // of the items' dentifiers, otherwise it will be a list of the items. - id = null, - // List of properties that will be searched. This also supports nested properties. - keys = [], - // Whether to sort the result list, by score - shouldSort = true, - // The get function to use when fetching an object's properties. - // The default will search nested paths *ie foo.bar.baz* - getFn = deepValue, - // Default sort function - sortFn = (a, b) => a.score - b.score, - // When true, the search algorithm will search individual words **and** the full string, - // computing the final score as a function of both. Note that when `tokenize` is `true`, - // the `threshold`, `distance`, and `location` are inconsequential for individual tokens. - tokenize = false, - // When true, the result set will only include records that match all tokens. Will only work - // if `tokenize` is also true. - matchAllTokens = false, - includeMatches = false, - includeScore = false, - // Will print to the console. Useful for debugging. - verbose = false - }) { this.options = { - location, - distance, - threshold, - maxPatternLength, + location: location, + distance: distance, + threshold: threshold, + maxPatternLength: maxPatternLength, isCaseSensitive: caseSensitive, - tokenSeparator, - findAllMatches, - minMatchCharLength, - id, - keys, - includeMatches, - includeScore, - shouldSort, - getFn, - sortFn, - verbose, - tokenize, - matchAllTokens + tokenSeparator: tokenSeparator, + findAllMatches: findAllMatches, + minMatchCharLength: minMatchCharLength, + id: id, + keys: keys, + includeMatches: includeMatches, + includeScore: includeScore, + shouldSort: shouldSort, + getFn: getFn, + sortFn: sortFn, + verbose: verbose, + tokenize: tokenize, + matchAllTokens: matchAllTokens }; this.setCollection(list); } - setCollection(list) { - this.list = list; - return list; - } - - search(pattern, opts = { - limit: false - }) { - this._log(`---------\nSearch pattern: "${pattern}"`); - - const { - tokenSearchers, - fullSearcher - } = this._prepareSearchers(pattern); - - let { - weights, - results - } = this._search(tokenSearchers, fullSearcher); - - this._computeScore(weights, results); - - if (this.options.shouldSort) { - this._sort(results); + _createClass(Fuse, [{ + key: "setCollection", + value: function setCollection(list) { + this.list = list; + return list; } + }, { + key: "search", + value: function search(pattern) { + var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { + limit: false + }; - if (opts.limit && typeof opts.limit === 'number') { - results = results.slice(0, opts.limit); - } + this._log("---------\nSearch pattern: \"".concat(pattern, "\"")); - return this._format(results); - } + var _this$_prepareSearche = this._prepareSearchers(pattern), + tokenSearchers = _this$_prepareSearche.tokenSearchers, + fullSearcher = _this$_prepareSearche.fullSearcher; - _prepareSearchers(pattern = '') { - const tokenSearchers = []; + var _this$_search = this._search(tokenSearchers, fullSearcher), + weights = _this$_search.weights, + results = _this$_search.results; - if (this.options.tokenize) { - // Tokenize on the separator - const tokens = pattern.split(this.options.tokenSeparator); + this._computeScore(weights, results); - for (let i = 0, len = tokens.length; i < len; i += 1) { - tokenSearchers.push(new Bitap(tokens[i], this.options)); + if (this.options.shouldSort) { + this._sort(results); } + + if (opts.limit && typeof opts.limit === 'number') { + results = results.slice(0, opts.limit); + } + + return this._format(results); } + }, { + key: "_prepareSearchers", + value: function _prepareSearchers() { + var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var tokenSearchers = []; - let fullSearcher = new Bitap(pattern, this.options); - return { - tokenSearchers, - fullSearcher - }; - } + if (this.options.tokenize) { + // Tokenize on the separator + var tokens = pattern.split(this.options.tokenSeparator); - _search(tokenSearchers = [], fullSearcher) { - const list = this.list; - const resultMap = {}; - const results = []; // Check the first item in the list, if it's a string, then we assume - // that every item in the list is also a string, and thus it's a flattened array. + for (var i = 0, len = tokens.length; i < len; i += 1) { + tokenSearchers.push(new Bitap(tokens[i], this.options)); + } + } - if (typeof list[0] === 'string') { - // Iterate over every item - for (let i = 0, len = list.length; i < len; i += 1) { - this._analyze({ - key: '', - value: list[i], - record: i, - index: i - }, { - resultMap, - results, - tokenSearchers, - fullSearcher - }); + var fullSearcher = new Bitap(pattern, this.options); + return { + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }; + } + }, { + key: "_search", + value: function _search() { + var tokenSearchers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var fullSearcher = arguments.length > 1 ? arguments[1] : undefined; + var list = this.list; + var resultMap = {}; + var results = []; // Check the first item in the list, if it's a string, then we assume + // that every item in the list is also a string, and thus it's a flattened array. + + if (typeof list[0] === 'string') { + // Iterate over every item + for (var i = 0, len = list.length; i < len; i += 1) { + this._analyze({ + key: '', + value: list[i], + record: i, + index: i + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); + } + + return { + weights: null, + results: results + }; + } // Otherwise, the first item is an Object (hopefully), and thus the searching + // is done on the values of the keys of each item. + + + var weights = {}; + + for (var _i = 0, _len = list.length; _i < _len; _i += 1) { + var item = list[_i]; // Iterate over every key + + for (var j = 0, keysLen = this.options.keys.length; j < keysLen; j += 1) { + var key = this.options.keys[j]; + + if (typeof key !== 'string') { + weights[key.name] = { + weight: 1 - key.weight || 1 + }; + + if (key.weight <= 0 || key.weight > 1) { + throw new Error('Key weight has to be > 0 and <= 1'); + } + + key = key.name; + } else { + weights[key] = { + weight: 1 + }; + } + + this._analyze({ + key: key, + value: this.options.getFn(item, key), + record: item, + index: _i + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); + } } return { - weights: null, - results + weights: weights, + results: results }; - } // Otherwise, the first item is an Object (hopefully), and thus the searching - // is done on the values of the keys of each item. - - - const weights = {}; - - for (let i = 0, len = list.length; i < len; i += 1) { - let item = list[i]; // Iterate over every key - - for (let j = 0, keysLen = this.options.keys.length; j < keysLen; j += 1) { - let key = this.options.keys[j]; - - if (typeof key !== 'string') { - weights[key.name] = { - weight: 1 - key.weight || 1 - }; - - if (key.weight <= 0 || key.weight > 1) { - throw new Error('Key weight has to be > 0 and <= 1'); - } - - key = key.name; - } else { - weights[key] = { - weight: 1 - }; - } - - this._analyze({ - key, - value: this.options.getFn(item, key), - record: item, - index: i - }, { - resultMap, - results, - tokenSearchers, - fullSearcher - }); - } } - - return { - weights, - results - }; - } - - _analyze({ - key, - arrayIndex = -1, - value, - record, - index }, { - tokenSearchers = [], - fullSearcher = [], - resultMap = {}, - results = [] - }) { - // Check if the texvaluet can be searched - if (value === undefined || value === null) { - return; - } + key: "_analyze", + value: function _analyze(_ref2, _ref3) { + var key = _ref2.key, + _ref2$arrayIndex = _ref2.arrayIndex, + arrayIndex = _ref2$arrayIndex === void 0 ? -1 : _ref2$arrayIndex, + value = _ref2.value, + record = _ref2.record, + index = _ref2.index; + var _ref3$tokenSearchers = _ref3.tokenSearchers, + tokenSearchers = _ref3$tokenSearchers === void 0 ? [] : _ref3$tokenSearchers, + _ref3$fullSearcher = _ref3.fullSearcher, + fullSearcher = _ref3$fullSearcher === void 0 ? [] : _ref3$fullSearcher, + _ref3$resultMap = _ref3.resultMap, + resultMap = _ref3$resultMap === void 0 ? {} : _ref3$resultMap, + _ref3$results = _ref3.results, + results = _ref3$results === void 0 ? [] : _ref3$results; - let exists = false; - let averageScore = -1; - let numTextMatches = 0; + // Check if the texvaluet can be searched + if (value === undefined || value === null) { + return; + } - if (typeof value === 'string') { - this._log(`\nKey: ${key === '' ? '-' : key}`); + var exists = false; + var averageScore = -1; + var numTextMatches = 0; - let mainSearchResult = fullSearcher.search(value); + if (typeof value === 'string') { + this._log("\nKey: ".concat(key === '' ? '-' : key)); - this._log(`Full text: "${value}", score: ${mainSearchResult.score}`); + var mainSearchResult = fullSearcher.search(value); - if (this.options.tokenize) { - let words = value.split(this.options.tokenSeparator); - let scores = []; + this._log("Full text: \"".concat(value, "\", score: ").concat(mainSearchResult.score)); - for (let i = 0; i < tokenSearchers.length; i += 1) { - let tokenSearcher = tokenSearchers[i]; + if (this.options.tokenize) { + var words = value.split(this.options.tokenSeparator); + var scores = []; - this._log(`\nPattern: "${tokenSearcher.pattern}"`); // let tokenScores = [] + for (var i = 0; i < tokenSearchers.length; i += 1) { + var tokenSearcher = tokenSearchers[i]; + + this._log("\nPattern: \"".concat(tokenSearcher.pattern, "\"")); // let tokenScores = [] - let hasMatchInText = false; + var hasMatchInText = false; - for (let j = 0; j < words.length; j += 1) { - let word = words[j]; - let tokenSearchResult = tokenSearcher.search(word); - let obj = {}; + for (var j = 0; j < words.length; j += 1) { + var word = words[j]; + var tokenSearchResult = tokenSearcher.search(word); + var obj = {}; - if (tokenSearchResult.isMatch) { - obj[word] = tokenSearchResult.score; - exists = true; - hasMatchInText = true; - scores.push(tokenSearchResult.score); - } else { - obj[word] = 1; + if (tokenSearchResult.isMatch) { + obj[word] = tokenSearchResult.score; + exists = true; + hasMatchInText = true; + scores.push(tokenSearchResult.score); + } else { + obj[word] = 1; - if (!this.options.matchAllTokens) { - scores.push(1); + if (!this.options.matchAllTokens) { + scores.push(1); + } } + + this._log("Token: \"".concat(word, "\", score: ").concat(obj[word])); // tokenScores.push(obj) + } - this._log(`Token: "${word}", score: ${obj[word]}`); // tokenScores.push(obj) - + if (hasMatchInText) { + numTextMatches += 1; + } } - if (hasMatchInText) { - numTextMatches += 1; + averageScore = scores[0]; + var scoresLen = scores.length; + + for (var _i2 = 1; _i2 < scoresLen; _i2 += 1) { + averageScore += scores[_i2]; } + + averageScore = averageScore / scoresLen; + + this._log('Token score average:', averageScore); } - averageScore = scores[0]; - let scoresLen = scores.length; + var finalScore = mainSearchResult.score; - for (let i = 1; i < scoresLen; i += 1) { - averageScore += scores[i]; + if (averageScore > -1) { + finalScore = (finalScore + averageScore) / 2; } - averageScore = averageScore / scoresLen; + this._log('Score average:', finalScore); - this._log('Token score average:', averageScore); - } + var checkTextMatches = this.options.tokenize && this.options.matchAllTokens ? numTextMatches >= tokenSearchers.length : true; - let finalScore = mainSearchResult.score; - - if (averageScore > -1) { - finalScore = (finalScore + averageScore) / 2; - } - - this._log('Score average:', finalScore); - - let checkTextMatches = this.options.tokenize && this.options.matchAllTokens ? numTextMatches >= tokenSearchers.length : true; - - this._log(`\nCheck Matches: ${checkTextMatches}`); // If a match is found, add the item to , including its score + this._log("\nCheck Matches: ".concat(checkTextMatches)); // If a match is found, add the item to , including its score - if ((exists || mainSearchResult.isMatch) && checkTextMatches) { - // Check if the item already exists in our results - let existingResult = resultMap[index]; + if ((exists || mainSearchResult.isMatch) && checkTextMatches) { + // Check if the item already exists in our results + var existingResult = resultMap[index]; - if (existingResult) { - // Use the lowest score - // existingResult.score, bitapResult.score - existingResult.output.push({ - key, - arrayIndex, - value, - score: finalScore, - matchedIndices: mainSearchResult.matchedIndices - }); - } else { - // Add it to the raw result list - resultMap[index] = { - item: record, - output: [{ - key, - arrayIndex, - value, + if (existingResult) { + // Use the lowest score + // existingResult.score, bitapResult.score + existingResult.output.push({ + key: key, + arrayIndex: arrayIndex, + value: value, score: finalScore, matchedIndices: mainSearchResult.matchedIndices - }] - }; - results.push(resultMap[index]); + }); + } else { + // Add it to the raw result list + resultMap[index] = { + item: record, + output: [{ + key: key, + arrayIndex: arrayIndex, + value: value, + score: finalScore, + matchedIndices: mainSearchResult.matchedIndices + }] + }; + results.push(resultMap[index]); + } + } + } else if (isArray(value)) { + for (var _i3 = 0, len = value.length; _i3 < len; _i3 += 1) { + this._analyze({ + key: key, + arrayIndex: _i3, + value: value[_i3], + record: record, + index: index + }, { + resultMap: resultMap, + results: results, + tokenSearchers: tokenSearchers, + fullSearcher: fullSearcher + }); } } - } else if (isArray(value)) { - for (let i = 0, len = value.length; i < len; i += 1) { - this._analyze({ - key, - arrayIndex: i, - value: value[i], - record, - index - }, { - resultMap, - results, - tokenSearchers, - fullSearcher + } + }, { + key: "_computeScore", + value: function _computeScore(weights, results) { + this._log('\n\nComputing score:\n'); + + for (var i = 0, len = results.length; i < len; i += 1) { + var output = results[i].output; + var scoreLen = output.length; + var currScore = 1; + var bestScore = 1; + + for (var j = 0; j < scoreLen; j += 1) { + var weight = weights ? weights[output[j].key].weight : 1; + var score = weight === 1 ? output[j].score : output[j].score || 0.001; + var nScore = score * weight; + + if (weight !== 1) { + bestScore = Math.min(bestScore, nScore); + } else { + output[j].nScore = nScore; + currScore *= nScore; + } + } + + results[i].score = bestScore === 1 ? currScore : bestScore; + + this._log(results[i]); + } + } + }, { + key: "_sort", + value: function _sort(results) { + this._log('\n\nSorting....'); + + results.sort(this.options.sortFn); + } + }, { + key: "_format", + value: function _format(results) { + var finalOutput = []; + + if (this.options.verbose) { + var cache = []; + + this._log('\n\nOutput:\n\n', JSON.stringify(results, function (key, value) { + if (_typeof(value) === 'object' && value !== null) { + if (cache.indexOf(value) !== -1) { + // Circular reference found, discard key + return; + } // Store value in our collection + + + cache.push(value); + } + + return value; + })); + + cache = null; + } + + var transformers = []; + + if (this.options.includeMatches) { + transformers.push(function (result, data) { + var output = result.output; + data.matches = []; + + for (var i = 0, len = output.length; i < len; i += 1) { + var item = output[i]; + + if (item.matchedIndices.length === 0) { + continue; + } + + var obj = { + indices: item.matchedIndices, + value: item.value + }; + + if (item.key) { + obj.key = item.key; + } + + if (item.hasOwnProperty('arrayIndex') && item.arrayIndex > -1) { + obj.arrayIndex = item.arrayIndex; + } + + data.matches.push(obj); + } }); } - } - } - _computeScore(weights, results) { - this._log('\n\nComputing score:\n'); - - for (let i = 0, len = results.length; i < len; i += 1) { - const output = results[i].output; - const scoreLen = output.length; - let currScore = 1; - let bestScore = 1; - - for (let j = 0; j < scoreLen; j += 1) { - let weight = weights ? weights[output[j].key].weight : 1; - let score = weight === 1 ? output[j].score : output[j].score || 0.001; - let nScore = score * weight; - - if (weight !== 1) { - bestScore = Math.min(bestScore, nScore); - } else { - output[j].nScore = nScore; - currScore *= nScore; - } + if (this.options.includeScore) { + transformers.push(function (result, data) { + data.score = result.score; + }); } - results[i].score = bestScore === 1 ? currScore : bestScore; + for (var i = 0, len = results.length; i < len; i += 1) { + var result = results[i]; - this._log(results[i]); - } - } - - _sort(results) { - this._log('\n\nSorting....'); - - results.sort(this.options.sortFn); - } - - _format(results) { - const finalOutput = []; - - if (this.options.verbose) { - let cache = []; - - this._log('\n\nOutput:\n\n', JSON.stringify(results, function (key, value) { - if (typeof value === 'object' && value !== null) { - if (cache.indexOf(value) !== -1) { - // Circular reference found, discard key - return; - } // Store value in our collection - - - cache.push(value); + if (this.options.id) { + result.item = this.options.getFn(result.item, this.options.id)[0]; } - return value; - })); - - cache = null; - } - - let transformers = []; - - if (this.options.includeMatches) { - transformers.push((result, data) => { - const output = result.output; - data.matches = []; - - for (let i = 0, len = output.length; i < len; i += 1) { - let item = output[i]; - - if (item.matchedIndices.length === 0) { - continue; - } - - let obj = { - indices: item.matchedIndices, - value: item.value - }; - - if (item.key) { - obj.key = item.key; - } - - if (item.hasOwnProperty('arrayIndex') && item.arrayIndex > -1) { - obj.arrayIndex = item.arrayIndex; - } - - data.matches.push(obj); + if (!transformers.length) { + finalOutput.push(result.item); + continue; } - }); - } - if (this.options.includeScore) { - transformers.push((result, data) => { - data.score = result.score; - }); - } + var data = { + item: result.item + }; - for (let i = 0, len = results.length; i < len; i += 1) { - const result = results[i]; + for (var j = 0, _len2 = transformers.length; j < _len2; j += 1) { + transformers[j](result, data); + } - if (this.options.id) { - result.item = this.options.getFn(result.item, this.options.id)[0]; + finalOutput.push(data); } - if (!transformers.length) { - finalOutput.push(result.item); - continue; - } - - const data = { - item: result.item - }; - - for (let j = 0, len = transformers.length; j < len; j += 1) { - transformers[j](result, data); - } - - finalOutput.push(data); + return finalOutput; } + }, { + key: "_log", + value: function _log() { + if (this.options.verbose) { + var _console; - return finalOutput; - } - - _log() { - if (this.options.verbose) { - console.log(...arguments); + (_console = console).log.apply(_console, arguments); + } } - } + }]); -} + return Fuse; +}(); module.exports = Fuse; diff --git a/public/assets/scripts/choices.min.js b/public/assets/scripts/choices.min.js index 05a72bc..14790a5 100644 --- a/public/assets/scripts/choices.min.js +++ b/public/assets/scripts/choices.min.js @@ -1,7 +1,7 @@ -/*! choices.js v5.0.0 | (c) 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Choices=t():e.Choices=t()}(window,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/assets/scripts/",n(n.s=9)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doKeysMatch=t.cloneObject=t.existsInArray=t.isIE11=t.fetchFromObject=t.reduceToValues=t.getWindowHeight=t.regexFilter=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.calcWidthOfInput=t.strToEl=t.stripHTML=t.isScrolledIntoView=t.getAdjacentEl=t.findAncestorByAttrName=t.findAncestor=t.wrap=t.extend=t.isElement=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0;var i=function(e,t){return Math.floor(Math.random()*(t-e)+e)};t.getRandomNumber=i;var r=function(e){for(var t="",n=0;n2&&void 0!==arguments[2]?arguments[2]:1;if(e&&t){var i=e.parentNode.parentNode,r=Array.from(i.querySelectorAll(t)),o=r.indexOf(e);return r[o+(n>0?1:-1)]}};t.isScrolledIntoView=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e)return n>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop};var a=function(e){return e.replace(/&/g,"&").replace(/>/g,"&rt;").replace(/".concat(a(n),""));if(r.style.position="absolute",r.style.padding="0",r.style.top="-9999px",r.style.left="-9999px",r.style.width="auto",r.style.whiteSpace="pre",document.body.contains(e)&&window.getComputedStyle){var o=window.getComputedStyle(e);o&&(r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontWeight=o.fontWeight,r.style.fontStyle=o.fontStyle,r.style.letterSpacing=o.letterSpacing,r.style.textTransform=o.textTransform,r.style.padding=o.padding)}document.body.appendChild(r),requestAnimationFrame(function(){n&&r.offsetWidth!==e.offsetWidth&&(i=r.offsetWidth+4),document.body.removeChild(r),t.call(void 0,"".concat(i,"px"))})}else t.call(void 0,"".concat(i,"px"))};t.sortByAlpha=function(e,t){var n=(e.label||e.value).toLowerCase(),i=(t.label||t.value).toLowerCase();return ni?1:0};t.sortByScore=function(e,t){return e.score-t.score};t.dispatchEvent=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0});return e.dispatchEvent(i)};t.regexFilter=function(e,t){return!(!e||!t)&&new RegExp(t.source,"i").test(e)};t.getWindowHeight=function(){var e=document.body,t=document.documentElement;return Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)};t.reduceToValues=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"value";return e.reduce(function(e,n){return e.push(n[t]),e},[])};t.fetchFromObject=function e(t,n){var i=n.indexOf(".");return i>-1?e(t[n.substring(0,i)],n.substr(i+1)):t[n]};t.isIE11=function(){return!(!navigator.userAgent.match(/Trident/)||!navigator.userAgent.match(/rv[ :]11/))};t.existsInArray=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"value";return e.some(function(e){return s("String",t)?e[n]===t.trim():e[n]===t})};t.cloneObject=function(e){return JSON.parse(JSON.stringify(e))};t.doKeysMatch=function(e,t){var n=Object.keys(e).sort(),i=Object.keys(t).sort();return JSON.stringify(n)===JSON.stringify(i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var i=n(0),r={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"};t.DEFAULT_CLASSNAMES=r;var o={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,removeItems:!0,removeItemButton:!1,editItems:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,regexFilter:null,shouldSort:!0,shouldSortItems:!1,sortFn:i.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,i.stripHTML)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},itemComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},callbackOnInit:null,callbackOnCreateTemplates:null,classNames:r};t.DEFAULT_CONFIG=o;t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice"};t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL"};t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34};t.SCROLLING_SPEED=4},function(e,t,n){"use strict";(function(e,i){var r,o=n(7);r="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:i;var s=Object(o.a)(r);t.a=s}).call(this,n(3),n(16)(e))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=n(0);function r(e,t){for(var n=0;n