diff --git a/README.md b/README.md index 758c60c..b092f92 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,8 @@ Responsible for defining global configuration. Look for full example here - [con - **`filters`** filtering items based on specific aggregations i.e. {tags: ['drama' , 'historical']} - **`filter`** function responsible for items filtering. The way of working is similar to js [native filter function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). [See example](/docs/configuration.md) + +- **`filters_query`** boolean filtering i.e. (tags:novel OR tags:80s) AND category:Western - **`isExactSearch`** set to `true` if you want to always show exact search matches. See [lunr stemmer](https://github.com/olivernn/lunr.js/issues/328) and [lunr stopWordFilter](https://github.com/olivernn/lunr.js/issues/233). diff --git a/dist/itemsjs.js b/dist/itemsjs.js index a805fa8..4676dcc 100644 --- a/dist/itemsjs.js +++ b/dist/itemsjs.js @@ -3,7 +3,315 @@ module.exports = require('./src/index'); -},{"./src/index":8}],2:[function(require,module,exports){ +},{"./src/index":9}],2:[function(require,module,exports){ +// Boolean-parser.js +// ----------------- +// License: MIT +// More information on what this does, and how the whole library works can be +// found in the README.md or on the github page. +// https://github.com/riichard/boolean-parser-js/blob/master/README.md + +// Return true if arrays are equal +function _arraysAreEqual(arrA, arrB) { + if (!Array.isArray(arrA) || !Array.isArray(arrB)) + { + throw new TypeError("both parameters have to be an array"); + } + if (arrA.length !== arrB.length) + { + return false; + } + for (var i = 0; i < arrA.length; i++) { + // No deep equal necessary + if (arrA[i] !== arrB[i]){ + return false; + } + } + return true; +} + +// This function converts a boolean query to a 2 dimensional array. +// a AND (b OR c) +// Becomes: +// [[a, b],[a,c]] +// This works recursively and generates an array of all possible combination +// of a matching query. +// The output is meant to be easily parsed to see if there are any matches. +// There are more efficient ways to match content to this query, though this is +// the one that is most easy to maintain and limits risk of side-effects. +// Especially when considering recursively nested queries. +function parseBooleanQuery(searchPhrase) { + + // Remove outer brackets if they exist. EX: (a OR b) -> a OR b + searchPhrase = removeOuterBrackets(searchPhrase); + + // remove double whitespaces + searchPhrase = removeDoubleWhiteSpace(searchPhrase); + + // Split the phrase on the term 'OR', but don't do this on 'OR' that's in + // between brackets. EX: a OR (b OR c) should not parse the `OR` in between b + // and c. + var ors = splitRoot('OR', searchPhrase); + + // Each parsed string returns a parsed array in this map function. + var orPath = ors.map(function(andQuery) { + + // Split on the word 'AND'. Yet again, don't split `AND` that's written in + // between brackets. We'll parse those later recursively. + var ands = splitRoot('AND', andQuery); + + // All nested parsed queries will be stored in `nestedPaths`. + // Nested means 'in between brackets'. + var nestedPaths = []; + + // All that's not nested will be stored in the andPath array. + // This array contains words that will later be merged with the parsed + // queries from nestedPaths. + var andPath = []; + + // Iterate trough all the strings from the AND query + for (var i = 0; i < ands.length; i++) { + // If the string contains brackets, parse it recursively, and add it to + // `nestedPaths`. + if (containsBrackets(ands[i])) { + nestedPaths.push(parseBooleanQuery(ands[i])); + } + + // If it doesn't. Push the word to `andPath`. + else { + andPath.push(ands[i]); + } + } + + // Merge the andPath and the nested OR paths together as one `AND` path + nestedPaths.push([andPath]); + + // Merge all `ANDs` and `ORs` together in one OR query + return orsAndMerge(nestedPaths); + }); + + // Merge all OR query paths together into one Array. + return mergeOrs(orPath); +} + +// Removes double whitespace in a string +// In: a b c\nd\te +// Out: a b c d e +function removeDoubleWhiteSpace(phrase) { + return phrase.replace(/[\s]+/g, ' '); +} + +// Merges 2 or paths together in an AND fashion +// in: +// orPathA: [ [ a ], [ b ] ] +// orPathB: [ [ c, d ], [ e ] ] +// out: +// [ +// [ a, c, d ], +// [ b, c, d], +// [ a, e ], +// [ b, e ] +// ] +function orAndOrMerge(orPathA, orPathB) { + var result = []; + orPathA.forEach(function(andPathA) { + orPathB.forEach(function(andPathB) { + result.push(andAndMerge(andPathA, andPathB)); + }); + }); + + return result; +} + +// Merges multiple OR paths into one OR path, in an AND fashion +// in: +// [ +// [ [ a ], [ b ] ], +// [ [ c, d ], [ e ] ] +// [ [ f ] ] +// ] +// out: +// [ +// [ a, c, d, f ], +// [ b, c, d, f ], +// [ a, e, f ], +// [ b, e, f ] +// ] +function orsAndMerge(ors) { + var result = [[]]; + for (var i = 0; i < ors.length; i++) { + result = orAndOrMerge(result, ors[i]); + } + + return result; +} + +// Removes duplicate and paths within an or path +// in: +// [ [ a, b ], [ c ], [ b, a ] ] +// out: +// [ [ a, b ], [ c ] ] +// +// with order matters +// in: +// [ [ a, b ], [ c ], [ b, a ] ] +// out: +// [ [ a, b ], [ c ], [ b, a ] ] +function deduplicateOr(orPath, orderMatters) { + var path = orderMatters ? + orPath : + orPath.map(function(item) { return item.sort() }); + + return path.reduce(function(memo, current){ + for (var i = 0; i < memo.length; i++) { + if (_arraysAreEqual(memo[i], current)) { + return memo; + } + } + memo.push(current); + return memo; + }, []); +} + +// in -> x = [ a, b ], y = [ c, d ] +// out -> [ a, b, c, d ] +function andAndMerge(a, b) { + return a.concat(b); +} + +// Merges an array of OR queries, containing AND queries to a single OR query +// In: +// [ [ [ a, b ], [ c ] ], +// [ [ d ] ], +// [ [ e ], [ f, g ] ] ] +// Out: +// [ [ a, b ], [ c ], [ d ], [ e ], [ f, g ] ] +function mergeOrs(ors) { + var result = ors[0]; + for (var i = 1; i < ors.length; i++) { + result = result.concat(ors[i]); + } + + return result; +} + +// Removes the bracket at the beginning and end of a string. Only if they both +// exist. Otherwise it returns the original phrase. +// Ex: (a OR b) -> a OR b +// But yet doesn't remove the brackets when the last bracket isn't linked to +// the first bracket. +// Ex: (a OR b) AND (x OR y) -> (a OR b) AND (x OR y) +function removeOuterBrackets(phrase) { + // If the first character is a bracket + if (phrase.charAt(0) === '(') { + + // Now we'll see if the closing bracket to the first character is the last + // character. If so. Remove the brackets. Otherwise, leave it as it is. + // We'll check that by incrementing the counter with every opening bracket, + // and decrement it with each closing bracket. + // When the counter hits 0. We are at the end bracket. + var counter = 0; + for (var i = 0; i < phrase.length; i++) { + + // Increment the counter at each '(' + if (phrase.charAt(i) === '(') counter++; + + // Decrement the counter at each ')' + else if (phrase.charAt(i) === ')') counter--; + + // If the counter is at 0, we are at the closing bracket. + if (counter === 0) { + + // If we are not at the end of the sentence, Return the + // phrase as-is without modifying it + if (i !== phrase.length - 1) { + return phrase; + } + + // If we are at the end, return the phrase without the surrounding brackets. + else { + return phrase.substring(1, phrase.length - 1); + } + } + } + + } + + return phrase; +} + +// Returns boolean true when string contains brackets '(' or ')', at any +// position within the string +// Ex: (b AND c) -> true +// Ex: b AND c -> false +function containsBrackets(str) { + return !!~str.search(/\(|\)/); +} + +// Splits a phrase into multiple strings by a split term. Like the split +// function. +// But then ignores the split terms that occur in between brackets +// Example when splitting on AND: +// In: a AND (b AND c) +// Out: ['a', '(b AND c)'] +// We do this by using the built in 'split' function. But as soon as we notice +// our string contains brackets, we create a temporary string, append any +// folling string from the `split` results. And stop doing that when we counted +// as many opening brackets as closing brackets. Then append that string to the +// results as a single string. +function splitRoot(splitTerm, phrase) { + var termSplit = phrase.split(' ' + splitTerm + ' '); + var result = []; + var tempNested = []; + for (var i = 0; i < termSplit.length; i++) { + + // If we are dealing with a split in a nested query, + // add it to the tempNested array, and rebuild the incorrectly parsed nested query + // later, by re-joining the array with the `splitTerm`, to make it look + // like it's original state. + if (containsBrackets(termSplit[i]) || tempNested.length > 0) { + tempNested.push(termSplit[i]); + + // When the tempNested contains just as much opening brackets as closing + // brackets, we can declare it as 'complete'. + var tempNestedString = '' + tempNested; + var countOpeningBrackets = (tempNestedString.match(/\(/g) || []).length; + var countClosingBrackets = (tempNestedString.match(/\)/g) || []).length; + + // If the amouth of opening brackets is the same as the amount of + // closing brackets, then the string is complete. + if (countOpeningBrackets === countClosingBrackets) { + result.push(tempNested.join(' ' + splitTerm + ' ')); + + // Clear the tempNested for the next round + tempNested = []; + } + } + + // In case we are NOT dealing with a nested query + else { + result.push(termSplit[i]); + } + } + + return result; +} + +// Export all functions as a module +module.exports = { + deduplicateOr: deduplicateOr, + andAndMerge: andAndMerge, + orAndOrMerge: orAndOrMerge, + orsAndMerge: orsAndMerge, + mergeOrs: mergeOrs, + splitRoot: splitRoot, + removeDoubleWhiteSpace: removeDoubleWhiteSpace, + removeOuterBrackets: removeOuterBrackets, + parseBooleanQuery: parseBooleanQuery, + containsBrackets: containsBrackets +}; + +},{}],3:[function(require,module,exports){ /* FastBitSet.js : a fast bit set implementation in JavaScript. * (c) the authors * Licensed under the Apache License, Version 2.0. @@ -544,7 +852,7 @@ FastBitSet.prototype.union_size = function (otherbitmap) { module.exports = FastBitSet; -},{}],3:[function(require,module,exports){ +},{}],4:[function(require,module,exports){ (function (global){(function (){ /** * @license @@ -17757,7 +18065,7 @@ module.exports = FastBitSet; }.call(this)); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],4:[function(require,module,exports){ +},{}],5:[function(require,module,exports){ /** * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 1.0.0 * Copyright (C) 2017 Oliver Nightingale @@ -19812,7 +20120,7 @@ lunr.TokenStore.prototype.toJSON = function () { })) })(); -},{}],5:[function(require,module,exports){ +},{}],6:[function(require,module,exports){ "use strict"; var _ = require('lodash'); @@ -19893,8 +20201,16 @@ Facets.prototype = { var temp_facet = _.clone(this.facets); temp_facet.not_ids = helpers.facets_ids(temp_facet['bits_data'], input.not_filters, config); + var temp_data; var filters = helpers.input_to_facet_filters(input, config); - var temp_data = helpers.matrix(this.facets, filters); + temp_data = helpers.matrix(this.facets, filters); + + if (input.filters_query) { + var _filters = helpers.parse_boolean_query(input.filters_query); + + temp_data = helpers.filters_matrix(temp_data, _filters); + } + temp_facet['bits_data_temp'] = temp_data['bits_data_temp']; _.mapValues(temp_facet['bits_data_temp'], function (values, key) { @@ -19909,17 +20225,24 @@ Facets.prototype = { }); }); /** - * calculating ids + * calculating ids (for a list of items) + * facets ids is faster and filter ids because filter ids makes union each to each filters + * filter ids needs to be used if there is filters query */ - temp_facet.ids = helpers.facets_ids(temp_facet['bits_data_temp'], input.filters, config); + if (input.filters_query) { + temp_facet.ids = helpers.filters_ids(temp_facet['bits_data_temp']); + } else { + temp_facet.ids = helpers.facets_ids(temp_facet['bits_data_temp'], input.filters); + } + return temp_facet; } }; module.exports = Facets; -},{"./helpers":7,"fastbitset":2,"lodash":3}],6:[function(require,module,exports){ +},{"./helpers":8,"fastbitset":3,"lodash":4}],7:[function(require,module,exports){ "use strict"; var _ = require('lodash'); @@ -20021,7 +20344,7 @@ Fulltext.prototype = { }; module.exports = Fulltext; -},{"lodash":3,"lunr":4}],7:[function(require,module,exports){ +},{"lodash":4,"lunr":5}],8:[function(require,module,exports){ "use strict"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } @@ -20034,6 +20357,8 @@ var _ = require('lodash'); var FastBitSet = require('fastbitset'); +var booleanParser = require('boolean-parser'); + var clone = function clone(val) { try { return JSON.parse(JSON.stringify(val)); @@ -20069,6 +20394,57 @@ var combination_indexes = function combination_indexes(facets, filters) { return indexes; }; + +var filters_matrix = function filters_matrix(facets, query_filters) { + var temp_facet = _.clone(facets); + + if (!temp_facet['is_temp_copied']) { + _.mapValues(temp_facet['bits_data'], function (values, key) { + _.mapValues(temp_facet['bits_data'][key], function (facet_indexes, key2) { + temp_facet['bits_data_temp'][key][key2] = temp_facet['bits_data'][key][key2]; + }); + }); + } + + var union = null; + ; + /** + * process only conjunctive filters + */ + + _.mapValues(query_filters, function (conjunction) { + var conjunctive_index = null; + + _.mapValues(conjunction, function (filter) { + var filter_key = filter[0]; + var filter_val = filter[1]; + + if (!temp_facet['bits_data_temp'][filter_key]) { + throw new Error('Panic. The key does not exist in facets lists.'); + } + + if (conjunctive_index && temp_facet['bits_data_temp'][filter_key][filter_val]) { + conjunctive_index = temp_facet['bits_data_temp'][filter_key][filter_val].new_intersection(conjunctive_index); + } else if (conjunctive_index && !temp_facet['bits_data_temp'][filter_key][filter_val]) { + conjunctive_index = new FastBitSet([]); + } else { + conjunctive_index = temp_facet['bits_data_temp'][filter_key][filter_val]; + } + }); + + union = (union || new FastBitSet([])).new_union(conjunctive_index || new FastBitSet([])); + }); + + if (union !== null) { + _.mapValues(temp_facet['bits_data_temp'], function (values, key) { + _.mapValues(temp_facet['bits_data_temp'][key], function (facet_indexes, key2) { + temp_facet['bits_data_temp'][key][key2] = temp_facet['bits_data_temp'][key][key2].new_intersection(union); + }); + }); + } + + return temp_facet; +}; /* * returns facets and ids */ @@ -20085,6 +20461,7 @@ var matrix = function matrix(facets, filters) { }); }); + temp_facet['is_temp_copied'] = true; var conjunctive_index; var disjunctive_indexes = combination_indexes(facets, filters); /** @@ -20113,14 +20490,7 @@ var matrix = function matrix(facets, filters) { temp_facet['bits_data_temp'][key][key2] = temp_facet['bits_data_temp'][key][key2].new_intersection(conjunctive_index); }); }); - } // cross all combination indexes with conjunctive index - - /*if (conjunctive_index) { - _.mapValues(disjunctive_indexes, function(disjunctive_index, disjunctive_key) { - disjunctive_indexes[disjunctive_key] = conjunctive_index.new_intersection(disjunctive_indexes[disjunctive_key]); - }); - }*/ - + } /** * process only negative filters */ @@ -20223,10 +20593,26 @@ var index = function index(items, fields) { }); return facets; }; +/** + * calculates ids for filters + */ + + +var filters_ids = function filters_ids(facets_data) { + var output = new FastBitSet([]); + + _.mapValues(facets_data, function (values, key) { + _.mapValues(facets_data[key], function (facet_indexes, key2) { + output = output.new_union(facets_data[key][key2]); + }); + }); + + return output; +}; /** * calculates ids for facets * if there is no facet input then return null to not save resources for OR calculation - * null means facets haven't crossed searched items + * null means facets haven't matched searched items */ @@ -20235,7 +20621,6 @@ var facets_ids = function facets_ids(facets_data, filters) { var i = 0; _.mapValues(filters, function (filters, field) { - //console.log(facets_data); filters.forEach(function (filter) { ++i; output = output.new_union(facets_data[field][filter]); @@ -20299,7 +20684,7 @@ var getBuckets = function getBuckets(data, input, aggregations) { _.chain(v).toPairs().forEach(function (v2) { if (isNaN(v2[0])) { throw new Error("You cant use chars to calculate the facet_stats."); - } // Doc_count + } // Doc_count if (v2[1].array().length > 0) { @@ -20388,18 +20773,45 @@ var input_to_facet_filters = function input_to_facet_filters(input, config) { return filters; }; +var parse_boolean_query = function parse_boolean_query(query) { + var result = parse_boolean_query_temp(query); + return result; +}; + +var parse_boolean_query_temp = function parse_boolean_query_temp(query) { + var result = booleanParser.parseBooleanQuery(query); + return _.map(result, function (v1) { + if (Array.isArray(v1)) { + return _.map(v1, function (v2) { + if (Array.isArray(v2)) { + return _.map(v2, function (v3) { + return v3; + }); + } else { + return v2.split(':'); + } + }); + } else { + return v1.split(':'); + } + }); +}; + +module.exports.parse_boolean_query = parse_boolean_query; module.exports.input_to_facet_filters = input_to_facet_filters; module.exports.facets_ids = facets_ids; +module.exports.filters_ids = filters_ids; module.exports.clone = clone; module.exports.humanize = humanize; module.exports.index = index; module.exports.combination_indexes = combination_indexes; module.exports.matrix = matrix; +module.exports.filters_matrix = filters_matrix; module.exports.getBuckets = getBuckets; module.exports.getFacets = getBuckets; module.exports.mergeAggregations = mergeAggregations; -},{"fastbitset":2,"lodash":3}],8:[function(require,module,exports){ +},{"boolean-parser":2,"fastbitset":3,"lodash":4}],9:[function(require,module,exports){ "use strict"; var service = require('./lib'); @@ -20471,7 +20883,7 @@ module.exports = function itemsjs(items, configuration) { }; }; -},{"./facets":5,"./fulltext":6,"./helpers":7,"./lib":9}],9:[function(require,module,exports){ +},{"./facets":6,"./fulltext":7,"./helpers":8,"./lib":10}],10:[function(require,module,exports){ "use strict"; var _ = require('lodash'); @@ -20697,5 +21109,5 @@ module.exports.aggregation = function (items, input, configuration, fulltext, fa }; }; -},{"./helpers":7,"fastbitset":2,"lodash":3}]},{},[1])(1) +},{"./helpers":8,"fastbitset":3,"lodash":4}]},{},[1])(1) }); diff --git a/dist/itemsjs.min.js b/dist/itemsjs.min.js index e385ff5..073a677 100644 --- a/dist/itemsjs.min.js +++ b/dist/itemsjs.min.js @@ -1 +1 @@ -(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.itemsjs=e()}})(function(){var e=Math.floor,t=Math.max,n=Math.min,r;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o>>5]|=1<>>5]^=1<>>5]&=~(1<>>5]&1<>>5],n=t|1<>>5]=n,(n^t)>>>e},o.prototype.trim=function(){let e=this.words.length;for(;0>>5;t++)this.words[t]=0},o.prototype.hammingWeight=function(e){return e-=1431655765&e>>>1,e=(858993459&e)+(858993459&e>>>2),16843009*(252645135&e+(e>>>4))>>>24},o.prototype.hammingWeight4=function(e,t,n,r){return e-=1431655765&e>>>1,t-=1431655765&t>>>1,n-=1431655765&n>>>1,r-=1431655765&r>>>1,e=(858993459&e)+(858993459&e>>>2),t=(858993459&t)+(858993459&t>>>2),n=(858993459&n)+(858993459&n>>>2),r=(858993459&r)+(858993459&r>>>2),e=252645135&e+(e>>>4),t=252645135&t+(t>>>4),n=252645135&n+(n>>>4),r=252645135&r+(r>>>4),16843009*(e+t+n+r)>>>24},o.prototype.size=function(){let e=0;const t=this.words.length,n=this.words;for(let r=0;r=t;--r)e.words[r]=this.words[r];return e.words=e.words.slice(0,this.words.length),e},o.prototype.new_difference=function(e){return this.clone().difference(e)},o.prototype.difference_size=function(e){const t=n(this.words.length,e.words.length);let r=0,o=0;for(;o=t;--r)this.words[r]=e.words[r];return this},o.prototype.new_change=function(e){const r=Object.create(o.prototype),i=t(this.words.length,e.words.length);r.words=Array(i);const d=n(this.words.length,e.words.length);let s=0;for(;s+7e.words.length?this:e,d=i.words.length;for(;o"']/g,pt=RegExp(at.source),ut=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,ct=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ft=/^\w*$/,yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mt=/[\\^$.*+?()[\]{}|]/g,wt=RegExp(mt.source),kt=/^\s+/,xt=/\s/,bt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,vt=/\{\n\/\* \[wrapped with (.+)\] \*/,St=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,It=/[()=,{}\[\]\/\s]/,jt=/\\(\\)?/g,zt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,At=/\w*$/,Et=/^[-+]0x[0-9a-f]+$/i,Ot=/^0b[01]+$/i,Ft=/^\[object .+?Constructor\]$/,Nt=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Pt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ct=/($^)/,Rt=/['\n\r\u2028\u2029\\]/g,Vt="\\ud800-\\udfff",Lt="\\u2700-\\u27bf",Bt="a-z\\xdf-\\xf6\\xf8-\\xff",Ut="A-Z\\xc0-\\xd6\\xd8-\\xde",Dt="\\xac\\xb1\\xd7\\xf7"+"\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf"+"\\u2000-\\u206f"+" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",qt="['\u2019]",Mt="["+Dt+"]",$t="["+("\\u0300-\\u036f"+"\\ufe20-\\ufe2f"+"\\u20d0-\\u20ff")+"]",Jt="\\d+",Kt="["+Bt+"]",Ht="[^"+Vt+Dt+Jt+Lt+Bt+Ut+"]",Gt="\\ud83c[\\udffb-\\udfff]",Zt="[^"+Vt+"]",Yt="(?:\\ud83c[\\udde6-\\uddff]){2}",Qt="[\\ud800-\\udbff][\\udc00-\\udfff]",Xt="["+Ut+"]",en="(?:"+Kt+"|"+Ht+")",tn="(?:"+qt+"(?:d|ll|m|re|s|t|ve))?",nn="(?:"+qt+"(?:D|LL|M|RE|S|T|VE))?",rn="(?:"+$t+"|"+Gt+")"+"?",on="["+"\\ufe0e\\ufe0f"+"]?",dn="(?:"+"\\u200d"+"(?:"+[Zt,Yt,Qt].join("|")+")"+on+rn+")*",sn=on+rn+dn,an="(?:"+["["+Lt+"]",Yt,Qt].join("|")+")"+sn,ln="(?:"+[Zt+$t+"?",$t,Yt,Qt,"["+Vt+"]"].join("|")+")",pn=/['’]/g,un=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g,hn=RegExp(Gt+"(?="+Gt+")|"+ln+sn,"g"),cn=RegExp([Xt+"?"+Kt+"+"+tn+"(?="+[Mt,Xt,"$"].join("|")+")","(?:"+Xt+"|"+Ht+")"+"+"+nn+"(?="+[Mt,Xt+en,"$"].join("|")+")",Xt+"?"+en+"+"+tn,Xt+"+"+nn,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Jt,an].join("|"),"g"),gn=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/,_n=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fn=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],yn=-1,mn={};mn[Ze]=mn[Ye]=mn[Qe]=mn[Xe]=mn[et]=mn[tt]=mn[nt]=mn[rt]=mn[ot]=!0,mn[Fe]=mn[Ne]=mn[He]=mn[We]=mn[Ge]=mn[Pe]=mn[Ce]=mn[Re]=mn[Le]=mn[Be]=mn[Ue]=mn[qe]=mn[Me]=mn[$e]=mn[Ke]=!1;var wn={};wn[Fe]=wn[Ne]=wn[He]=wn[Ge]=wn[We]=wn[Pe]=wn[Ze]=wn[Ye]=wn[Qe]=wn[Xe]=wn[et]=wn[Le]=wn[Be]=wn[Ue]=wn[qe]=wn[Me]=wn[$e]=wn[Je]=wn[tt]=wn[nt]=wn[rt]=wn[ot]=!0,wn[Ce]=wn[Re]=wn[Ke]=!1;var kn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xn=parseFloat,bn=parseInt,vn="object"==typeof o&&o&&o.Object===Object&&o,Sn="object"==typeof self&&self&&self.Object===Object&&self,Tn=vn||Sn||Function("return this")(),In="object"==typeof d&&d&&!d.nodeType&&d,jn=In&&"object"==typeof i&&i&&!i.nodeType&&i,zn=jn&&jn.exports===In,An=zn&&vn.process,En=function(){try{var e=jn&&jn.require&&jn.require("util").types;return e?e:An&&An.binding&&An.binding("util")}catch(t){}}(),On=En&&En.isArrayBuffer,Fn=En&&En.isDate,Nn=En&&En.isMap,Wn=En&&En.isRegExp,Pn=En&&En.isSet,Cn=En&&En.isTypedArray,Rn=A("length"),Vn=E({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Ln=E({"&":"&","<":"<",">":">",'"':""","'":"'"}),Bn=E({"&":"&","<":"<",">":">",""":"\"","'":"'"}),Un=function r(o){function i(e){if(Li(e)&&!za(e)&&!(e instanceof x)){if(e instanceof _)return e;if(Ad.call(e,"__wrapped__"))return li(e)}return new _(e)}function d(){}function _(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function x(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ee,this.__views__=[]}function E(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Zt(e,t,n,r,o,i){var d=t&ue,s=t&he,a;if(n&&(a=o?n(e,r,o,i):n(e)),void 0!==a)return a;if(!Vi(e))return e;var p=za(e);if(!p){var u=Vs(e),h=u==Re||u==Ve;if(Ea(e))return Nr(e,d);if(u!=Ue&&u!=Fe&&(!h||o)){if(!wn[u])return o?e:{};a=Vo(e,u,d)}else if(a=s||h?{}:Ro(e),!d)return s?Jr(e,Jt(a,e)):$r(e,$t(a,e))}else if(a=Co(e),!d)return qr(e,a);i||(i=new xt);var c=i.get(e);if(c)return c;i.set(e,a),Wa(e)?e.forEach(function(r){a.add(Zt(r,t,n,r,e,i))}):Fa(e)&&e.forEach(function(r,o){a.set(o,Zt(r,t,n,o,e,i))});var g=t&ce?s?To:So:s?ed:Xi,_=p?void 0:g(e);return l(_||e,function(r,o){_&&(o=r,r=e[o]),Dt(a,o,Zt(r,t,n,o,e,i))}),a}function Yt(e){var t=Xi(e);return function(n){return Qt(n,e,t)}}function Qt(e,t,n){var r=n.length;if(null==e)return!r;for(e=kd(e);r--;){var o=n[r],i=t[o],d=e[o];if(void 0===d&&!(o in e)||!i(d))return!1}return!0}function Xt(e,t,n){if("function"!=typeof e)throw new vd(ae);return Us(function(){e.apply(void 0,n)},t)}function en(e,t,n,r){var o=-1,i=c,d=!0,s=e.length,a=[],l=t.length;if(!s)return a;n&&(t=f(t,R(n))),r?(i=g,d=!1):t.length>=se&&(i=L,d=!1,t=new ie(t));outer:for(;++on&&(n=-n>o?0:o+n),r=void 0===r||r>o?o:Ji(r),0>r&&(r+=o),r=n>r?0:Ki(r);nt}function kn(e,t){return null!=e&&Ad.call(e,t)}function vn(e,t){return null!=e&&t in kd(e)}function Sn(e,t,n){return e>=is(t,n)&&et?n:0,Uo(t,n)?e[t]:void 0}function tr(e,t,n){t=t.length?f(t,function(e){return za(e)?function(t){return hn(t,1===e.length?e[0]:e)}:e}):[ad];var r=-1;t=f(t,R(zo()));var o=Gn(e,function(e){var n=f(t,function(t){return t(e)});return{criteria:n,index:++r,value:e}});return F(o,function(e,t){return Br(e,t,n)})}function nr(e,t){return rr(e,t,function(t,n){return Qi(e,n)})}function rr(e,t,n){for(var r=-1,o=t.length,i={};++rt||t>ze)return n;do t%2&&(n+=e),t=Qd(t/2),t&&(e+=e);while(t);return n}function pr(e,t){return Ds(Xo(e,t,ad),e+"")}function ur(e){return Vt(rd(e))}function hr(e,t){var n=rd(e);return ii(n,Gt(t,0,n.length))}function cr(e,t,n,r){if(!Vi(e))return e;t=Or(t,e);for(var o=-1,i=t.length,d=e;null!=d&&++ot&&(t=-t>o?0:o+t),n=n>o?o:n,0>n&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=_d(o);++r>>1){for(;r>>1,d=e[i];null!==d&&!qi(d)&&(n?d<=t:d=se){var l=t?null:Ws(e);if(l)return Y(l);d=!1,o=L,a=new ie}else a=t?[]:s;outer:for(;++rr)return r?br(e[0]):[];for(var o=-1,i=_d(r);++o=r?e:_r(e,t,n)}function Nr(e,t){if(t)return e.slice();var n=e.length,r=Ld?Ld(n):new e.constructor(n);return e.copy(r),r}function Wr(e){var t=new e.constructor(e.byteLength);return new Vd(t).set(new Vd(e)),t}function Pr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Cr(e){var t=new e.constructor(e.source,At.exec(e));return t.lastIndex=e.lastIndex,t}function Rr(e){return Ss?kd(Ss.call(e)):{}}function Vr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Lr(e,t){if(e!==t){var n=void 0!==e,r=null===e,o=e===e,i=qi(e),d=void 0!==t,s=null===t,a=t===t,l=qi(t);if(!s&&!l&&!i&&e>t||i&&d&&a&&!s&&!l||r&&d&&a||!n&&a||!o)return 1;if(!r&&!i&&!l&&e=s)return a;var l=n[r];return a*("desc"==l?-1:1)}return e.index-t.index}function Ur(e,t,n,r){for(var o=-1,i=e.length,d=n.length,s=-1,a=t.length,l=os(i-d,0),p=_d(a+l),u=!r;++so?void 0:i,o=1),t=kd(t);++ri&&d[0]!==l&&d[i-1]!==l?[]:Z(d,l);if(i-=p.length,in)return n?lr(t,e):t;var r=lr(t,Yd(e/te(t)));return $(t)?Fr(ne(r),0,e).join(""):r.slice(0,e)}function po(e,t,n,r){function o(){for(var t=-1,a=arguments.length,l=-1,p=r.length,u=_d(p+a),h=this&&this!==Tn&&this instanceof o?d:e;++ls))return!1;var l=i.get(e),p=i.get(t);if(l&&p)return l==t&&p==e;var u=-1,h=!0,c=n&_e?new ie:void 0;for(i.set(e,t),i.set(t,e);++ut.length?e:hn(e,_r(t,0,-1))}function ti(e,t){for(var n=e.length,r=is(t.length,n),o=qr(e),i;r--;)i=t[r],e[r]=Uo(i,n)?o[i]:void 0;return e}function ni(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"==t?void 0:e[t]}function ri(e,t,n){var r=t+"";return Ds(e,Lo(r,ai(Wo(r),n)))}function oi(e){var t=0,n=0;return function(){var r=ds(),o=16-(r-n);if(n=r,!(0=800)return arguments[0];return e.apply(void 0,arguments)}}function ii(e,t){var n=-1,r=e.length;for(t=void 0===t?r:t;++no&&(o=os(r+o,0)),S(e,zo(t,3),o)}function ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r-1;return void 0!==n&&(o=Ji(n),o=0>n?os(r+o,0):is(o,r-1)),S(e,zo(t,3),o,!0)}function hi(e){var t=null==e?0:e.length;return t?dn(e,1):[]}function ci(e){return e&&e.length?e[0]:void 0}function gi(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function _i(e,t){return e&&e.length&&t&&t.length?ir(e,t):e}function fi(e){return null==e?e:ls.call(e)}function yi(e){if(!(e&&e.length))return[];var t=0;return e=h(e,function(e){if(Ni(e))return t=os(e.length,t),!0}),W(t,function(t){return f(e,A(t))})}function mi(e,t){if(!(e&&e.length))return[];var n=yi(e);return null==t?n:f(n,function(e){return s(t,void 0,e)})}function wi(e){var t=i(e);return t.__chain__=!0,t}function ki(e,t){return t(e)}function xi(e,t){var n=za(e)?l:js;return n(e,zo(t,3))}function bi(e,t){var n=za(e)?p:zs;return n(e,zo(t,3))}function vi(e,t){var n=za(e)?f:Gn;return n(e,zo(t,3))}function Si(e,t,n){return t=n?void 0:t,t=e&&null==t?e.length:t,fo(e,ve,void 0,void 0,void 0,void 0,t)}function Ti(e,t){var n;if("function"!=typeof t)throw new vd(ae);return e=Ji(e),function(){return 0<--e&&(n=t.apply(this,arguments)),1>=e&&(t=void 0),n}}function Ii(e,t,n){t=n?void 0:t;var r=fo(e,we,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=Ii.placeholder,r}function ji(e,t,n){t=n?void 0:t;var r=fo(e,ke,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=ji.placeholder,r}function zi(e,t,n){function r(t){var n=g,r=_;return g=_=void 0,p=t,y=e.apply(r,n),y}function o(e){return p=e,m=Us(s,t),u?r(e):y}function i(e){var n=e-w,r=e-p,o=t-n;return h?is(o,f-r):o}function d(e){var n=e-w,r=e-p;return void 0==w||n>=t||0>n||h&&r>=f}function s(){var e=fa();return d(e)?a(e):void(m=Us(s,i(e)))}function a(e){return(m=void 0,c&&g)?r(e):(g=_=void 0,y)}function l(){var e=fa(),n=d(e);if(g=arguments,_=this,w=e,n){if(void 0===m)return o(w);if(h)return Ns(m),m=Us(s,t),r(w)}return void 0===m&&(m=Us(s,t)),y}var p=0,u=!1,h=!1,c=!0,g,_,f,y,m,w;if("function"!=typeof e)throw new vd(ae);return t=Hi(t)||0,Vi(n)&&(u=!!n.leading,h="maxWait"in n,f=h?os(Hi(n.maxWait)||0,t):f,c="trailing"in n?!!n.trailing:c),l.cancel=function(){void 0!==m&&Ns(m),p=0,g=w=_=m=void 0},l.flush=function(){return void 0===m?y:a(fa())},l}function Ai(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new vd(ae);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var d=e.apply(this,r);return n.cache=i.set(o,d)||i,d};return n.cache=new(Ai.Cache||oe),n}function Ei(e){if("function"!=typeof e)throw new vd(ae);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2]);}return!e.apply(this,t)}}function Oi(e,t){return e===t||e!==e&&t!==t}function Fi(e){return null!=e&&Ri(e.length)&&!Pi(e)}function Ni(e){return Li(e)&&Fi(e)}function Wi(e){if(!Li(e))return!1;var t=gn(e);return t==Ce||t=="[object DOMException]"||"string"==typeof e.message&&"string"==typeof e.name&&!Ui(e)}function Pi(e){if(!Vi(e))return!1;var t=gn(e);return t==Re||t==Ve||t=="[object AsyncFunction]"||t=="[object Proxy]"}function Ci(e){return"number"==typeof e&&e==Ji(e)}function Ri(e){return"number"==typeof e&&-1e?-1:1;return t*1.7976931348623157e308}return e===e?e:0}function Ji(e){var t=$i(e),n=t%1;return t===t?n?t-n:t:0}function Ki(e){return e?Gt(Ji(e),0,Ee):0}function Hi(e){if("number"==typeof e)return e;if(qi(e))return Ae;if(Vi(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Vi(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=C(e);var n=Ot.test(e);return n||Nt.test(e)?bn(e.slice(2),n?2:8):Et.test(e)?Ae:+e}function Gi(e){return Mr(e,ed(e))}function Zi(e){return null==e?"":xr(e)}function Yi(e,t,n){var r=null==e?void 0:hn(e,t);return void 0===r?n:r}function Qi(e,t){return null!=e&&Po(e,t,vn)}function Xi(e){return Fi(e)?Tt(e):Jn(e)}function ed(e){return Fi(e)?Tt(e,!0):Kn(e)}function td(e,t){if(null==e)return{};var n=f(To(e),function(e){return[e]});return t=zo(t),rr(e,n,function(e,n){return t(e,n[0])})}function nd(e,t,n){t=Or(t,e);var r=-1,o=t.length;for(o||(o=1,e=void 0);++rn)return!1;var r=t.length-1;return n==r?t.pop():qd.call(t,n,1),--this.size,!0},X.prototype.get=function(e){var t=this.__data__,n=qt(t,e);return 0>n?void 0:t[n][1]},X.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},oe.prototype.clear=function(){this.size=0,this.__data__={hash:new E,map:new(us||X),string:new E}},oe.prototype["delete"]=function(e){var t=Ao(this,e)["delete"](e);return this.size-=t?1:0,t},oe.prototype.get=function(e){return Ao(this,e).get(e)},oe.prototype.has=function(e){return Ao(this,e).has(e)},oe.prototype.set=function(e,t){var n=Ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ie.prototype.add=ie.prototype.push=function(e){return this.__data__.set(e,le),this},ie.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.clear=function(){this.__data__=new X,this.size=0},xt.prototype["delete"]=function(e){var t=this.__data__,n=t["delete"](e);return this.size=t.size,n},xt.prototype.get=function(e){return this.__data__.get(e)},xt.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof X){var r=n.__data__;if(!us||r.length=t}),ja=En(function(){return arguments}())?En:function(e){return Li(e)&&Ad.call(e,"callee")&&!Dd.call(e,"callee")},za=_d.isArray,Aa=On?R(On):function(e){return Li(e)&&gn(e)==He},Ea=es||gd,Oa=Fn?R(Fn):function(e){return Li(e)&&gn(e)==Pe},Fa=Nn?R(Nn):function(e){return Li(e)&&Vs(e)==Le},Na=Wn?R(Wn):function(e){return Li(e)&&gn(e)==qe},Wa=Pn?R(Pn):function(e){return Li(e)&&Vs(e)==Me},Pa=Cn?R(Cn):function(e){return Li(e)&&Ri(e.length)&&!!mn[gn(e)]},Ca=ho(Hn),Ra=ho(function(e,t){return e<=t}),Va=Hr(function(e,t){if(Ko(t)||Fi(t))return void Mr(t,Xi(t),e);for(var n in t)Ad.call(t,n)&&Dt(e,n,t[n])}),La=Hr(function(e,t){Mr(t,ed(t),e)}),Ba=Hr(function(e,t,n,r){Mr(t,ed(t),e,r)}),Ua=Hr(function(e,t,n,r){Mr(t,Xi(t),e,r)}),Da=vo(Ht),qa=pr(function(e,t){e=kd(e);var n=-1,r=t.length,o=2--e)return t.apply(this,arguments)}},i.ary=Si,i.assign=Va,i.assignIn=La,i.assignInWith=Ba,i.assignWith=Ua,i.at=Da,i.before=Ti,i.bind=ya,i.bindAll=ll,i.bindKey=ma,i.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return za(e)?e:[e]},i.chain=wi,i.chunk=function(e,t,n){t=(n?Do(e,t,n):void 0===t)?1:os(Ji(t),0);var r=null==e?0:e.length;if(!r||1>t)return[];for(var o=0,i=0,d=_d(Yd(r/t));ot?0:t,r)):[]},i.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0,0>t?0:t)):[]},i.dropRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0,!0):[]},i.dropWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0):[]},i.fill=function(e,t,n,r){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&Do(e,t,n)&&(n=0,r=o),rn(e,t,n,r)):[]},i.filter=function(e,t){var n=za(e)?h:on;return n(e,zo(t,3))},i.flatMap=function(e,t){return dn(vi(e,t),1)},i.flatMapDeep=function(e,t){return dn(vi(e,t),je)},i.flatMapDepth=function(e,t,n){return n=void 0===n?1:Ji(n),dn(vi(e,t),n)},i.flatten=hi,i.flattenDeep=function(e){var t=null==e?0:e.length;return t?dn(e,je):[]},i.flattenDepth=function(e,t){var n=null==e?0:e.length;return n?(t=void 0===t?1:Ji(t),dn(e,t)):[]},i.flip=function(e){return fo(e,Te)},i.flow=pl,i.flowRight=ul,i.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={},o;++t>>0,!n)?[]:(e=Zi(e),e&&("string"==typeof t||null!=t&&!Na(t))&&(t=xr(t),!t&&$(e))?Fr(ne(e),0,n):e.split(t,n))},i.spread=function(e,t){if("function"!=typeof e)throw new vd(ae);return t=null==t?0:os(Ji(t),0),pr(function(n){var r=n[t],o=Fr(n,0,t);return r&&y(o,r),s(e,this,o)})},i.tail=function(e){var t=null==e?0:e.length;return t?_r(e,1,t):[]},i.take=function(e,t,n){return e&&e.length?(t=n||void 0===t?1:Ji(t),_r(e,0,0>t?0:t)):[]},i.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0>t?0:t,r)):[]},i.takeRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!1,!0):[]},i.takeWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3)):[]},i.tap=function(e,t){return t(e),e},i.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new vd(ae);return Vi(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),zi(e,t,{leading:r,maxWait:t,trailing:o})},i.thru=ki,i.toArray=Mi,i.toPairs=Qa,i.toPairsIn=Xa,i.toPath=function(e){return za(e)?f(e,di):qi(e)?[e]:qr(qs(Zi(e)))},i.toPlainObject=Gi,i.transform=function(e,t,n){var r=za(e),o=r||Ea(e)||Pa(e);if(t=zo(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Vi(e)?Pi(i)?Is(Bd(e)):{}:{}}return(o?l:sn)(e,function(e,r,o){return t(n,e,r,o)}),n},i.unary=function(e){return Si(e,1)},i.union=Qs,i.unionBy=Xs,i.unionWith=ea,i.uniq=function(e){return e&&e.length?br(e):[]},i.uniqBy=function(e,t){return e&&e.length?br(e,zo(t,2)):[]},i.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?br(e,void 0,t):[]},i.unset=function(e,t){return null==e||vr(e,t)},i.unzip=yi,i.unzipWith=mi,i.update=function(e,t,n){return null==e?e:Sr(e,t,Er(n))},i.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:Sr(e,t,Er(n),r)},i.values=rd,i.valuesIn=function(e){return null==e?[]:V(e,ed(e))},i.without=ta,i.words=dd,i.wrap=function(e,t){return ba(Er(t),e)},i.xor=na,i.xorBy=ra,i.xorWith=oa,i.zip=ia,i.zipObject=function(e,t){return zr(e||[],t||[],Dt)},i.zipObjectDeep=function(e,t){return zr(e||[],t||[],cr)},i.zipWith=da,i.entries=Qa,i.entriesIn=Xa,i.extend=La,i.extendWith=Ba,pd(i,i),i.add=wl,i.attempt=al,i.camelCase=el,i.capitalize=od,i.ceil=kl,i.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=Hi(n),n=n===n?n:0),void 0!==t&&(t=Hi(t),t=t===t?t:0),Gt(Hi(e),t,n)},i.clone=function(e){return Zt(e,ce)},i.cloneDeep=function(e){return Zt(e,ue|ce)},i.cloneDeepWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ue|ce,t)},i.cloneWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ce,t)},i.conformsTo=function(e,t){return null==t||Qt(e,t,Xi(t))},i.deburr=id,i.defaultTo=function(e,t){return null==e||e!==e?t:e},i.divide=xl,i.endsWith=function(e,t,n){e=Zi(e),t=xr(t);var r=e.length;n=void 0===n?r:Gt(Ji(n),0,r);var o=n;return n-=t.length,0<=n&&e.slice(n,o)==t},i.eq=Oi,i.escape=function(e){return e=Zi(e),e&&ut.test(e)?e.replace(lt,Ln):e},i.escapeRegExp=function(e){return e=Zi(e),e&&wt.test(e)?e.replace(mt,"\\$&"):e},i.every=function(e,t,n){var r=za(e)?u:tn;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.find=la,i.findIndex=pi,i.findKey=function(e,t){return v(e,zo(t,3),sn)},i.findLast=pa,i.findLastIndex=ui,i.findLastKey=function(e,t){return v(e,zo(t,3),an)},i.floor=bl,i.forEach=xi,i.forEachRight=bi,i.forIn=function(e,t){return null==e?e:As(e,zo(t,3),ed)},i.forInRight=function(e,t){return null==e?e:Es(e,zo(t,3),ed)},i.forOwn=function(e,t){return e&&sn(e,zo(t,3))},i.forOwnRight=function(e,t){return e&&an(e,zo(t,3))},i.get=Yi,i.gt=Ta,i.gte=Ia,i.has=function(e,t){return null!=e&&Po(e,t,kn)},i.hasIn=Qi,i.head=ci,i.identity=ad,i.includes=function(e,t,n,r){e=Fi(e)?e:rd(e),n=n&&!r?Ji(n):0;var o=e.length;return 0>n&&(n=os(o+n,0)),Di(e)?n<=o&&-1o&&(o=os(r+o,0)),T(e,t,o)},i.inRange=function(e,t,n){return t=$i(t),void 0===n?(n=t,t=0):n=$i(n),e=Hi(e),Sn(e,t,n)},i.invoke=Ka,i.isArguments=ja,i.isArray=za,i.isArrayBuffer=Aa,i.isArrayLike=Fi,i.isArrayLikeObject=Ni,i.isBoolean=function(e){return!0===e||!1===e||Li(e)&&gn(e)==We},i.isBuffer=Ea,i.isDate=Oa,i.isElement=function(e){return Li(e)&&1===e.nodeType&&!Ui(e)},i.isEmpty=function(e){if(null==e)return!0;if(Fi(e)&&(za(e)||"string"==typeof e||"function"==typeof e.splice||Ea(e)||Pa(e)||ja(e)))return!e.length;var t=Vs(e);if(t==Le||t==Me)return!e.size;if(Ko(e))return!Jn(e).length;for(var n in e)if(Ad.call(e,n))return!1;return!0},i.isEqual=function(e,t){return Rn(e,t)},i.isEqualWith=function(e,t,n){n="function"==typeof n?n:void 0;var r=n?n(e,t):void 0;return void 0===r?Rn(e,t,void 0,n):!!r},i.isError=Wi,i.isFinite=function(e){return"number"==typeof e&&ts(e)},i.isFunction=Pi,i.isInteger=Ci,i.isLength=Ri,i.isMap=Fa,i.isMatch=function(e,t){return e===t||qn(e,t,Eo(t))},i.isMatchWith=function(e,t,n){return n="function"==typeof n?n:void 0,qn(e,t,Eo(t),n)},i.isNaN=function(e){return Bi(e)&&e!=+e},i.isNative=function(e){if(Ls(e))throw new yd("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mn(e)},i.isNil=function(e){return null==e},i.isNull=function(e){return null===e},i.isNumber=Bi,i.isObject=Vi,i.isObjectLike=Li,i.isPlainObject=Ui,i.isRegExp=Na,i.isSafeInteger=function(e){return Ci(e)&&e>=-ze&&e<=ze},i.isSet=Wa,i.isString=Di,i.isSymbol=qi,i.isTypedArray=Pa,i.isUndefined=function(e){return void 0===e},i.isWeakMap=function(e){return Li(e)&&Vs(e)==Ke},i.isWeakSet=function(e){return Li(e)&&gn(e)=="[object WeakSet]"},i.join=function(e,t){return null==e?"":ns.call(e,t)},i.kebabCase=tl,i.last=gi,i.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return void 0!==n&&(o=Ji(n),o=0>o?os(r+o,0):is(o,r-1)),t===t?ee(e,t,o):S(e,j,o,!0)},i.lowerCase=nl,i.lowerFirst=rl,i.lt=Ca,i.lte=Ra,i.max=function(e){return e&&e.length?nn(e,ad,_n):void 0},i.maxBy=function(e,t){return e&&e.length?nn(e,zo(t,2),_n):void 0},i.mean=function(e){return z(e,ad)},i.meanBy=function(e,t){return z(e,zo(t,2))},i.min=function(e){return e&&e.length?nn(e,ad,Hn):void 0},i.minBy=function(e,t){return e&&e.length?nn(e,zo(t,2),Hn):void 0},i.stubArray=cd,i.stubFalse=gd,i.stubObject=function(){return{}},i.stubString=function(){return""},i.stubTrue=function(){return!0},i.multiply=vl,i.nth=function(e,t){return e&&e.length?er(e,Ji(t)):void 0},i.noConflict=function(){return Tn._===this&&(Tn._=Wd),this},i.noop=ud,i.now=fa,i.pad=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return lo(Qd(o),n)+e+lo(Yd(o),n)},i.padEnd=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=as();return is(e+o*(t-e+xn("1e-"+((o+"").length-1))),t)}return sr(e,t)},i.reduce=function(e,t,n){var r=za(e)?m:O,o=3>arguments.length;return r(e,zo(t,4),n,o,js)},i.reduceRight=function(e,t,n){var r=za(e)?w:O,o=3>arguments.length;return r(e,zo(t,4),n,o,zs)},i.repeat=function(e,t,n){return t=(n?Do(e,t,n):void 0===t)?1:Ji(t),lr(Zi(e),t)},i.replace=function(){var e=arguments,t=Zi(e[0]);return 3>e.length?t:t.replace(e[1],e[2])},i.result=nd,i.round=Sl,i.runInContext=r,i.sample=function(e){var t=za(e)?Vt:ur;return t(e)},i.size=function(e){if(null==e)return 0;if(Fi(e))return Di(e)?te(e):e.length;var t=Vs(e);return t==Le||t==Me?e.size:Jn(e).length},i.snakeCase=ol,i.some=function(e,t,n){var r=za(e)?k:fr;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.sortedIndex=function(e,t){return yr(e,t)},i.sortedIndexBy=function(e,t,n){return mr(e,t,zo(n,2))},i.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=yr(e,t);if(re||e>ze)return[];var n=Ee,r=is(e,Ee);t=zo(t),e-=Ee;for(var o=W(r,t);++n=i)return e;var s=n-te(r);if(1>s)return r;var a=d?Fr(d,0,s).join(""):e.slice(0,s);if(void 0===o)return a+r;if(d&&(s+=a.length-s),Na(o)){if(e.slice(s).search(o)){var l=a,p;for(o.global||(o=xd(o.source,Zi(At.exec(o))+"g")),o.lastIndex=0;p=o.exec(l);)var u=p.index;a=a.slice(0,void 0===u?s:u)}}else if(e.indexOf(xr(o),s)!=s){var h=a.lastIndexOf(o);-1n.__dir__?"Right":"")}),n},x.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),l(["filter","map","takeWhile"],function(e,t){var n=t+1;x.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:zo(e,3),type:n}),t.__filtered__=t.__filtered__||n==Ie||n==3,t}}),l(["head","last"],function(e,t){var n="take"+(t?"Right":"");x.prototype[e]=function(){return this[n](1).value()[0]}}),l(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");x.prototype[e]=function(){return this.__filtered__?new x(this):this[n](1)}}),x.prototype.compact=function(){return this.filter(ad)},x.prototype.find=function(e){return this.filter(e).head()},x.prototype.findLast=function(e){return this.reverse().find(e)},x.prototype.invokeMap=pr(function(e,t){return"function"==typeof e?new x(this):this.map(function(n){return An(n,e,t)})}),x.prototype.reject=function(e){return this.filter(Ei(zo(e)))},x.prototype.slice=function(e,t){e=Ji(e);var n=this;return n.__filtered__&&(0t)?new x(n):(0>e?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(t=Ji(t),n=0>t?n.dropRight(-t):n.take(t-e)),n)},x.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},x.prototype.toArray=function(){return this.take(Ee)},sn(x.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=i[r?"take"+("last"==t?"Right":""):t],d=r||/^find/.test(t);o&&(i.prototype[t]=function(){var t=this.__wrapped__,s=r?[1]:arguments,a=t instanceof x,l=s[0],p=a||za(t),u=function(e){var t=o.apply(i,y([e],s));return r&&h?t[0]:t};p&&n&&"function"==typeof l&&1!=l.length&&(a=p=!1);var h=this.__chain__,c=!!this.__actions__.length,g=d&&!h,f=a&&!c;if(!d&&p){t=f?t:new x(this);var m=e.apply(t,s);return m.__actions__.push({func:ki,args:[u],thisArg:void 0}),new _(m,h)}return g&&f?e.apply(this,s):(m=this.thru(u),g?r?m.value()[0]:m.value():m)})}),l(["pop","push","shift","sort","splice","unshift"],function(e){var t=Sd[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);i.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(za(o)?o:[],e)}return this[n](function(n){return t.apply(za(n)?n:[],e)})}}),sn(x.prototype,function(e,t){var n=i[t];if(n){var r=n.name+"";Ad.call(ys,r)||(ys[r]=[]),ys[r].push({name:t,func:n})}}),ys[oo(void 0,ye).name]=[{name:"wrapper",func:void 0}],x.prototype.clone=function(){var e=new x(this.__wrapped__);return e.__actions__=qr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qr(this.__views__),e},x.prototype.reverse=function(){if(this.__filtered__){var e=new x(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},x.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=za(e),r=0>t,o=n?e.length:0,i=No(0,o,this.__views__),d=i.start,s=i.end,a=s-d,l=r?s:d-1,p=this.__iteratees__,u=p.length,h=0,c=is(a,this.__takeCount__);if(!n||!r&&o==a&&c==a)return Ir(e,this.__actions__);var g=[];outer:for(;a--&&h=this.__values__.length,t=e?void 0:this.__values__[this.__index__++];return{done:e,value:t}},i.prototype.plant=function(e){for(var t=this,n,r;t instanceof d;){r=li(t),r.__index__=0,r.__values__=void 0,n?o.__wrapped__=r:n=r;var o=r;t=t.__wrapped__}return o.__wrapped__=e,n},i.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof x){var t=e;return this.__actions__.length&&(t=new x(this)),t=t.reverse(),t.__actions__.push({func:ki,args:[fi],thisArg:void 0}),new _(t,this.__chain__)}return this.thru(fi)},i.prototype.toJSON=i.prototype.valueOf=i.prototype.value=function(){return Ir(this.__wrapped__,this.__actions__)},i.prototype.first=i.prototype.head,$d&&(i.prototype[$d]=function(){return this}),i}();"function"==typeof r&&"object"==typeof r.amd&&r.amd?(Tn._=Un,r(function(){return Un})):jn?((jn.exports=Un)._=Un,In._=Un):Tn._=Un}).call(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],4:[function(n,o,i){(function(){var n=Math.log,d=function(e){var t=new d.Index;return t.pipeline.add(d.trimmer,d.stopWordFilter,d.stemmer),e&&e.call(t,t),t};d.version="1.0.0",d.utils={},d.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),d.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},d.EventEmitter=function(){this.events={}},d.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},d.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},d.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)})}},d.EventEmitter.prototype.hasHandler=function(e){return e in this.events},d.tokenizer=function(e){return arguments.length&&null!=e&&void 0!=e?Array.isArray(e)?e.map(function(e){return d.utils.asString(e).toLowerCase()}):e.toString().trim().toLowerCase().split(d.tokenizer.separator):[]},d.tokenizer.separator=/[\s\-]+/,d.tokenizer.load=function(e){var t=this.registeredFunctions[e];if(!t)throw new Error("Cannot load un-registered function: "+e);return t},d.tokenizer.label="default",d.tokenizer.registeredFunctions={default:d.tokenizer},d.tokenizer.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing tokenizer: "+t),e.label=t,this.registeredFunctions[t]=e},d.Pipeline=function(){this._stack=[]},d.Pipeline.registeredFunctions={},d.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing registered function: "+t),e.label=t,d.Pipeline.registeredFunctions[e.label]=e},d.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||d.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},d.Pipeline.load=function(e){var t=new d.Pipeline;return e.forEach(function(e){var n=d.Pipeline.registeredFunctions[e];if(n)t.add(n);else throw new Error("Cannot load un-registered function: "+e)}),t},d.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){d.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},d.Pipeline.prototype.after=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");++n,this._stack.splice(n,0,t)},d.Pipeline.prototype.before=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},d.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1==t||this._stack.splice(t,1)},d.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,o=0,i;on.idx?n=n.next:(r+=t.val*n.val,t=t.next,n=n.next);return r},d.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},d.SortedSet=function(){this.length=0,this.elements=[]},d.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},d.SortedSet.prototype.add=function(){var e,t;for(e=0;et&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i]}return d===t?i:-1},d.SortedSet.prototype.locationFor=function(t){for(var n=0,r=this.elements.length,o=r-n,i=n+e(o/2),d=this.elements[i];1t&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i];return d>t?i:do-1||r>i-1);){if(s[n]===a[r]){t.add(s[n]),n++,r++;continue}if(s[n]a[r]){r++;continue}}return t},d.SortedSet.prototype.clone=function(){var e=new d.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},d.SortedSet.prototype.union=function(e){var t,n,r;this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone();for(var o=0,i=n.toArray();on.length)return n;if(w=n.substr(0,1),"y"==w&&(n=w.toUpperCase()+n.substr(1)),I=l,j=p,I.test(n)?n=n.replace(I,"$1$2"):j.test(n)&&(n=n.replace(j,"$1$2")),I=u,j=h,I.test(n)){var E=I.exec(n);I=i,I.test(E[1])&&(I=c,n=n.replace(I,""))}else if(j.test(n)){var E=j.exec(n);r=E[1],j=a,j.test(r)&&(n=r,j=g,z=_,A=f,j.test(n)?n+="e":z.test(n)?(I=c,n=n.replace(I,"")):A.test(n)&&(n+="e"))}if(I=y,I.test(n)){var E=I.exec(n);r=E[1],n=r+"i"}if(I=m,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+e[o])}if(I=k,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+t[o])}if(I=x,j=b,I.test(n)){var E=I.exec(n);r=E[1],I=d,I.test(r)&&(n=r)}else if(j.test(n)){var E=j.exec(n);r=E[1]+E[2],j=d,j.test(r)&&(n=r)}if(I=v,I.test(n)){var E=I.exec(n);r=E[1],I=d,j=s,z=T,(I.test(r)||j.test(r)&&!z.test(r))&&(n=r)}return I=S,j=d,I.test(n)&&j.test(n)&&(I=c,n=n.replace(I,"")),"y"==w&&(n=w.toLowerCase()+n.substr(1)),n}}(),d.Pipeline.registerFunction(d.stemmer,"stemmer"),d.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e]!==e)return e}},d.stopWordFilter=d.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),d.Pipeline.registerFunction(d.stopWordFilter,"stopWordFilter"),d.trimmer=function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")},d.Pipeline.registerFunction(d.trimmer,"trimmer"),d.TokenStore=function(){this.root={docs:{}},this.length=0},d.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},d.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e.charAt(0),o=e.slice(1);return r in n||(n[r]={docs:{}}),0===o.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(o,t,n[r])},d.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;n=d&&(p.push(e[u]),p[p.length-1].intersection_length=h.length)}return p=n.orderBy(p,["intersection_length"],["desc"]),{pagination:{per_page:o,page:s,total:p.length},data:{items:p.slice((s-1)*o,s*o)}}},t.exports.aggregation=function(e,n,o,i,d){var s=n.per_page||10,a=n.page||1;if(n.name&&(!o.aggregations||!o.aggregations[n.name]))throw new Error("Please define aggregation \"".concat(n.name,"\" in config"));var l=r.clone(n);if(l.page=1,l.per_page=0,!n.name)throw new Error("field name is required");o.aggregations[n.name].size=1e4;var p=t.exports.search(e,l,o,i,d),u=p.data.aggregations[n.name].buckets;return{pagination:{per_page:s,page:a,total:u.length},data:{buckets:u.slice((a-1)*s,a*s)}}}},{"./helpers":7,fastbitset:2,lodash:3}]},{},[1])(1)}); \ No newline at end of file +(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.itemsjs=e()}})(function(){var e=Math.floor,t=Math.max,n=Math.min,r;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o>>5]|=1<>>5]^=1<>>5]&=~(1<>>5]&1<>>5],n=t|1<>>5]=n,(n^t)>>>e},o.prototype.trim=function(){let e=this.words.length;for(;0>>5;t++)this.words[t]=0},o.prototype.hammingWeight=function(e){return e-=1431655765&e>>>1,e=(858993459&e)+(858993459&e>>>2),16843009*(252645135&e+(e>>>4))>>>24},o.prototype.hammingWeight4=function(e,t,n,r){return e-=1431655765&e>>>1,t-=1431655765&t>>>1,n-=1431655765&n>>>1,r-=1431655765&r>>>1,e=(858993459&e)+(858993459&e>>>2),t=(858993459&t)+(858993459&t>>>2),n=(858993459&n)+(858993459&n>>>2),r=(858993459&r)+(858993459&r>>>2),e=252645135&e+(e>>>4),t=252645135&t+(t>>>4),n=252645135&n+(n>>>4),r=252645135&r+(r>>>4),16843009*(e+t+n+r)>>>24},o.prototype.size=function(){let e=0;const t=this.words.length,n=this.words;for(let r=0;r=t;--r)e.words[r]=this.words[r];return e.words=e.words.slice(0,this.words.length),e},o.prototype.new_difference=function(e){return this.clone().difference(e)},o.prototype.difference_size=function(e){const t=n(this.words.length,e.words.length);let r=0,o=0;for(;o=t;--r)this.words[r]=e.words[r];return this},o.prototype.new_change=function(e){const r=Object.create(o.prototype),i=t(this.words.length,e.words.length);r.words=Array(i);const d=n(this.words.length,e.words.length);let s=0;for(;s+7e.words.length?this:e,d=i.words.length;for(;o"']/g,pt=RegExp(at.source),ut=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,ct=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ft=/^\w*$/,yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mt=/[\\^$.*+?()[\]{}|]/g,wt=RegExp(mt.source),kt=/^\s+/,xt=/\s/,bt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,vt=/\{\n\/\* \[wrapped with (.+)\] \*/,St=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,It=/[()=,{}\[\]\/\s]/,jt=/\\(\\)?/g,At=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,Ot=/^[-+]0x[0-9a-f]+$/i,Et=/^0b[01]+$/i,Nt=/^\[object .+?Constructor\]$/,Ft=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Pt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Vt=/($^)/,Ct=/['\n\r\u2028\u2029\\]/g,Rt="\\ud800-\\udfff",Bt="\\u2700-\\u27bf",Lt="a-z\\xdf-\\xf6\\xf8-\\xff",Ut="A-Z\\xc0-\\xd6\\xd8-\\xde",Dt="\\xac\\xb1\\xd7\\xf7"+"\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf"+"\\u2000-\\u206f"+" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",qt="['\u2019]",Mt="["+Dt+"]",$t="["+("\\u0300-\\u036f"+"\\ufe20-\\ufe2f"+"\\u20d0-\\u20ff")+"]",Jt="\\d+",Kt="["+Lt+"]",Ht="[^"+Rt+Dt+Jt+Bt+Lt+Ut+"]",Gt="\\ud83c[\\udffb-\\udfff]",Zt="[^"+Rt+"]",Yt="(?:\\ud83c[\\udde6-\\uddff]){2}",Qt="[\\ud800-\\udbff][\\udc00-\\udfff]",Xt="["+Ut+"]",en="(?:"+Kt+"|"+Ht+")",tn="(?:"+qt+"(?:d|ll|m|re|s|t|ve))?",nn="(?:"+qt+"(?:D|LL|M|RE|S|T|VE))?",rn="(?:"+$t+"|"+Gt+")"+"?",on="["+"\\ufe0e\\ufe0f"+"]?",dn="(?:"+"\\u200d"+"(?:"+[Zt,Yt,Qt].join("|")+")"+on+rn+")*",sn=on+rn+dn,an="(?:"+["["+Bt+"]",Yt,Qt].join("|")+")"+sn,ln="(?:"+[Zt+$t+"?",$t,Yt,Qt,"["+Rt+"]"].join("|")+")",pn=/['’]/g,un=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g,hn=RegExp(Gt+"(?="+Gt+")|"+ln+sn,"g"),cn=RegExp([Xt+"?"+Kt+"+"+tn+"(?="+[Mt,Xt,"$"].join("|")+")","(?:"+Xt+"|"+Ht+")"+"+"+nn+"(?="+[Mt,Xt+en,"$"].join("|")+")",Xt+"?"+en+"+"+tn,Xt+"+"+nn,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Jt,an].join("|"),"g"),gn=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/,_n=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fn=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],yn=-1,mn={};mn[Ze]=mn[Ye]=mn[Qe]=mn[Xe]=mn[et]=mn[tt]=mn[nt]=mn[rt]=mn[ot]=!0,mn[Ne]=mn[Fe]=mn[He]=mn[We]=mn[Ge]=mn[Pe]=mn[Ve]=mn[Ce]=mn[Be]=mn[Le]=mn[Ue]=mn[qe]=mn[Me]=mn[$e]=mn[Ke]=!1;var wn={};wn[Ne]=wn[Fe]=wn[He]=wn[Ge]=wn[We]=wn[Pe]=wn[Ze]=wn[Ye]=wn[Qe]=wn[Xe]=wn[et]=wn[Be]=wn[Le]=wn[Ue]=wn[qe]=wn[Me]=wn[$e]=wn[Je]=wn[tt]=wn[nt]=wn[rt]=wn[ot]=!0,wn[Ve]=wn[Ce]=wn[Ke]=!1;var kn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xn=parseFloat,bn=parseInt,vn="object"==typeof o&&o&&o.Object===Object&&o,Sn="object"==typeof self&&self&&self.Object===Object&&self,Tn=vn||Sn||Function("return this")(),In="object"==typeof d&&d&&!d.nodeType&&d,jn=In&&"object"==typeof i&&i&&!i.nodeType&&i,An=jn&&jn.exports===In,zn=An&&vn.process,On=function(){try{var e=jn&&jn.require&&jn.require("util").types;return e?e:zn&&zn.binding&&zn.binding("util")}catch(t){}}(),En=On&&On.isArrayBuffer,Nn=On&&On.isDate,Fn=On&&On.isMap,Wn=On&&On.isRegExp,Pn=On&&On.isSet,Vn=On&&On.isTypedArray,Cn=z("length"),Rn=O({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Bn=O({"&":"&","<":"<",">":">",'"':""","'":"'"}),Ln=O({"&":"&","<":"<",">":">",""":"\"","'":"'"}),Un=function r(o){function i(e){if(Bi(e)&&!Aa(e)&&!(e instanceof x)){if(e instanceof _)return e;if(zd.call(e,"__wrapped__"))return li(e)}return new _(e)}function d(){}function _(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function x(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Oe,this.__views__=[]}function O(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Zt(e,t,n,r,o,i){var d=t&ue,s=t&he,a;if(n&&(a=o?n(e,r,o,i):n(e)),void 0!==a)return a;if(!Ri(e))return e;var p=Aa(e);if(!p){var u=Rs(e),h=u==Ce||u==Re;if(Oa(e))return Fr(e,d);if(u!=Ue&&u!=Ne&&(!h||o)){if(!wn[u])return o?e:{};a=Ro(e,u,d)}else if(a=s||h?{}:Co(e),!d)return s?Jr(e,Jt(a,e)):$r(e,$t(a,e))}else if(a=Vo(e),!d)return qr(e,a);i||(i=new xt);var c=i.get(e);if(c)return c;i.set(e,a),Wa(e)?e.forEach(function(r){a.add(Zt(r,t,n,r,e,i))}):Na(e)&&e.forEach(function(r,o){a.set(o,Zt(r,t,n,o,e,i))});var g=t&ce?s?To:So:s?ed:Xi,_=p?void 0:g(e);return l(_||e,function(r,o){_&&(o=r,r=e[o]),Dt(a,o,Zt(r,t,n,o,e,i))}),a}function Yt(e){var t=Xi(e);return function(n){return Qt(n,e,t)}}function Qt(e,t,n){var r=n.length;if(null==e)return!r;for(e=kd(e);r--;){var o=n[r],i=t[o],d=e[o];if(void 0===d&&!(o in e)||!i(d))return!1}return!0}function Xt(e,t,n){if("function"!=typeof e)throw new vd(ae);return Us(function(){e.apply(void 0,n)},t)}function en(e,t,n,r){var o=-1,i=c,d=!0,s=e.length,a=[],l=t.length;if(!s)return a;n&&(t=f(t,C(n))),r?(i=g,d=!1):t.length>=se&&(i=B,d=!1,t=new ie(t));outer:for(;++on&&(n=-n>o?0:o+n),r=void 0===r||r>o?o:Ji(r),0>r&&(r+=o),r=n>r?0:Ki(r);nt}function kn(e,t){return null!=e&&zd.call(e,t)}function vn(e,t){return null!=e&&t in kd(e)}function Sn(e,t,n){return e>=is(t,n)&&et?n:0,Uo(t,n)?e[t]:void 0}function tr(e,t,n){t=t.length?f(t,function(e){return Aa(e)?function(t){return hn(t,1===e.length?e[0]:e)}:e}):[ad];var r=-1;t=f(t,C(Ao()));var o=Gn(e,function(e){var n=f(t,function(t){return t(e)});return{criteria:n,index:++r,value:e}});return N(o,function(e,t){return Lr(e,t,n)})}function nr(e,t){return rr(e,t,function(t,n){return Qi(e,n)})}function rr(e,t,n){for(var r=-1,o=t.length,i={};++rt||t>Ae)return n;do t%2&&(n+=e),t=Qd(t/2),t&&(e+=e);while(t);return n}function pr(e,t){return Ds(Xo(e,t,ad),e+"")}function ur(e){return Rt(rd(e))}function hr(e,t){var n=rd(e);return ii(n,Gt(t,0,n.length))}function cr(e,t,n,r){if(!Ri(e))return e;t=Er(t,e);for(var o=-1,i=t.length,d=e;null!=d&&++ot&&(t=-t>o?0:o+t),n=n>o?o:n,0>n&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=_d(o);++r>>1){for(;r>>1,d=e[i];null!==d&&!qi(d)&&(n?d<=t:d=se){var l=t?null:Ws(e);if(l)return Y(l);d=!1,o=B,a=new ie}else a=t?[]:s;outer:for(;++rr)return r?br(e[0]):[];for(var o=-1,i=_d(r);++o=r?e:_r(e,t,n)}function Fr(e,t){if(t)return e.slice();var n=e.length,r=Bd?Bd(n):new e.constructor(n);return e.copy(r),r}function Wr(e){var t=new e.constructor(e.byteLength);return new Rd(t).set(new Rd(e)),t}function Pr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Vr(e){var t=new e.constructor(e.source,zt.exec(e));return t.lastIndex=e.lastIndex,t}function Cr(e){return Ss?kd(Ss.call(e)):{}}function Rr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Br(e,t){if(e!==t){var n=void 0!==e,r=null===e,o=e===e,i=qi(e),d=void 0!==t,s=null===t,a=t===t,l=qi(t);if(!s&&!l&&!i&&e>t||i&&d&&a&&!s&&!l||r&&d&&a||!n&&a||!o)return 1;if(!r&&!i&&!l&&e=s)return a;var l=n[r];return a*("desc"==l?-1:1)}return e.index-t.index}function Ur(e,t,n,r){for(var o=-1,i=e.length,d=n.length,s=-1,a=t.length,l=os(i-d,0),p=_d(a+l),u=!r;++so?void 0:i,o=1),t=kd(t);++ri&&d[0]!==l&&d[i-1]!==l?[]:Z(d,l);if(i-=p.length,in)return n?lr(t,e):t;var r=lr(t,Yd(e/te(t)));return $(t)?Nr(ne(r),0,e).join(""):r.slice(0,e)}function po(e,t,n,r){function o(){for(var t=-1,a=arguments.length,l=-1,p=r.length,u=_d(p+a),h=this&&this!==Tn&&this instanceof o?d:e;++ls))return!1;var l=i.get(e),p=i.get(t);if(l&&p)return l==t&&p==e;var u=-1,h=!0,c=n&_e?new ie:void 0;for(i.set(e,t),i.set(t,e);++ut.length?e:hn(e,_r(t,0,-1))}function ti(e,t){for(var n=e.length,r=is(t.length,n),o=qr(e),i;r--;)i=t[r],e[r]=Uo(i,n)?o[i]:void 0;return e}function ni(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"==t?void 0:e[t]}function ri(e,t,n){var r=t+"";return Ds(e,Bo(r,ai(Wo(r),n)))}function oi(e){var t=0,n=0;return function(){var r=ds(),o=16-(r-n);if(n=r,!(0=800)return arguments[0];return e.apply(void 0,arguments)}}function ii(e,t){var n=-1,r=e.length;for(t=void 0===t?r:t;++no&&(o=os(r+o,0)),S(e,Ao(t,3),o)}function ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r-1;return void 0!==n&&(o=Ji(n),o=0>n?os(r+o,0):is(o,r-1)),S(e,Ao(t,3),o,!0)}function hi(e){var t=null==e?0:e.length;return t?dn(e,1):[]}function ci(e){return e&&e.length?e[0]:void 0}function gi(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function _i(e,t){return e&&e.length&&t&&t.length?ir(e,t):e}function fi(e){return null==e?e:ls.call(e)}function yi(e){if(!(e&&e.length))return[];var t=0;return e=h(e,function(e){if(Fi(e))return t=os(e.length,t),!0}),W(t,function(t){return f(e,z(t))})}function mi(e,t){if(!(e&&e.length))return[];var n=yi(e);return null==t?n:f(n,function(e){return s(t,void 0,e)})}function wi(e){var t=i(e);return t.__chain__=!0,t}function ki(e,t){return t(e)}function xi(e,t){var n=Aa(e)?l:js;return n(e,Ao(t,3))}function bi(e,t){var n=Aa(e)?p:As;return n(e,Ao(t,3))}function vi(e,t){var n=Aa(e)?f:Gn;return n(e,Ao(t,3))}function Si(e,t,n){return t=n?void 0:t,t=e&&null==t?e.length:t,fo(e,ve,void 0,void 0,void 0,void 0,t)}function Ti(e,t){var n;if("function"!=typeof t)throw new vd(ae);return e=Ji(e),function(){return 0<--e&&(n=t.apply(this,arguments)),1>=e&&(t=void 0),n}}function Ii(e,t,n){t=n?void 0:t;var r=fo(e,we,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=Ii.placeholder,r}function ji(e,t,n){t=n?void 0:t;var r=fo(e,ke,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=ji.placeholder,r}function Ai(e,t,n){function r(t){var n=g,r=_;return g=_=void 0,p=t,y=e.apply(r,n),y}function o(e){return p=e,m=Us(s,t),u?r(e):y}function i(e){var n=e-w,r=e-p,o=t-n;return h?is(o,f-r):o}function d(e){var n=e-w,r=e-p;return void 0==w||n>=t||0>n||h&&r>=f}function s(){var e=fa();return d(e)?a(e):void(m=Us(s,i(e)))}function a(e){return(m=void 0,c&&g)?r(e):(g=_=void 0,y)}function l(){var e=fa(),n=d(e);if(g=arguments,_=this,w=e,n){if(void 0===m)return o(w);if(h)return Fs(m),m=Us(s,t),r(w)}return void 0===m&&(m=Us(s,t)),y}var p=0,u=!1,h=!1,c=!0,g,_,f,y,m,w;if("function"!=typeof e)throw new vd(ae);return t=Hi(t)||0,Ri(n)&&(u=!!n.leading,h="maxWait"in n,f=h?os(Hi(n.maxWait)||0,t):f,c="trailing"in n?!!n.trailing:c),l.cancel=function(){void 0!==m&&Fs(m),p=0,g=w=_=m=void 0},l.flush=function(){return void 0===m?y:a(fa())},l}function zi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new vd(ae);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var d=e.apply(this,r);return n.cache=i.set(o,d)||i,d};return n.cache=new(zi.Cache||oe),n}function Oi(e){if("function"!=typeof e)throw new vd(ae);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2]);}return!e.apply(this,t)}}function Ei(e,t){return e===t||e!==e&&t!==t}function Ni(e){return null!=e&&Ci(e.length)&&!Pi(e)}function Fi(e){return Bi(e)&&Ni(e)}function Wi(e){if(!Bi(e))return!1;var t=gn(e);return t==Ve||t=="[object DOMException]"||"string"==typeof e.message&&"string"==typeof e.name&&!Ui(e)}function Pi(e){if(!Ri(e))return!1;var t=gn(e);return t==Ce||t==Re||t=="[object AsyncFunction]"||t=="[object Proxy]"}function Vi(e){return"number"==typeof e&&e==Ji(e)}function Ci(e){return"number"==typeof e&&-1e?-1:1;return t*1.7976931348623157e308}return e===e?e:0}function Ji(e){var t=$i(e),n=t%1;return t===t?n?t-n:t:0}function Ki(e){return e?Gt(Ji(e),0,Oe):0}function Hi(e){if("number"==typeof e)return e;if(qi(e))return ze;if(Ri(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ri(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=V(e);var n=Et.test(e);return n||Ft.test(e)?bn(e.slice(2),n?2:8):Ot.test(e)?ze:+e}function Gi(e){return Mr(e,ed(e))}function Zi(e){return null==e?"":xr(e)}function Yi(e,t,n){var r=null==e?void 0:hn(e,t);return void 0===r?n:r}function Qi(e,t){return null!=e&&Po(e,t,vn)}function Xi(e){return Ni(e)?Tt(e):Jn(e)}function ed(e){return Ni(e)?Tt(e,!0):Kn(e)}function td(e,t){if(null==e)return{};var n=f(To(e),function(e){return[e]});return t=Ao(t),rr(e,n,function(e,n){return t(e,n[0])})}function nd(e,t,n){t=Er(t,e);var r=-1,o=t.length;for(o||(o=1,e=void 0);++rn)return!1;var r=t.length-1;return n==r?t.pop():qd.call(t,n,1),--this.size,!0},X.prototype.get=function(e){var t=this.__data__,n=qt(t,e);return 0>n?void 0:t[n][1]},X.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},oe.prototype.clear=function(){this.size=0,this.__data__={hash:new O,map:new(us||X),string:new O}},oe.prototype["delete"]=function(e){var t=zo(this,e)["delete"](e);return this.size-=t?1:0,t},oe.prototype.get=function(e){return zo(this,e).get(e)},oe.prototype.has=function(e){return zo(this,e).has(e)},oe.prototype.set=function(e,t){var n=zo(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ie.prototype.add=ie.prototype.push=function(e){return this.__data__.set(e,le),this},ie.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.clear=function(){this.__data__=new X,this.size=0},xt.prototype["delete"]=function(e){var t=this.__data__,n=t["delete"](e);return this.size=t.size,n},xt.prototype.get=function(e){return this.__data__.get(e)},xt.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof X){var r=n.__data__;if(!us||r.length=t}),ja=On(function(){return arguments}())?On:function(e){return Bi(e)&&zd.call(e,"callee")&&!Dd.call(e,"callee")},Aa=_d.isArray,za=En?C(En):function(e){return Bi(e)&&gn(e)==He},Oa=es||gd,Ea=Nn?C(Nn):function(e){return Bi(e)&&gn(e)==Pe},Na=Fn?C(Fn):function(e){return Bi(e)&&Rs(e)==Be},Fa=Wn?C(Wn):function(e){return Bi(e)&&gn(e)==qe},Wa=Pn?C(Pn):function(e){return Bi(e)&&Rs(e)==Me},Pa=Vn?C(Vn):function(e){return Bi(e)&&Ci(e.length)&&!!mn[gn(e)]},Va=ho(Hn),Ca=ho(function(e,t){return e<=t}),Ra=Hr(function(e,t){if(Ko(t)||Ni(t))return void Mr(t,Xi(t),e);for(var n in t)zd.call(t,n)&&Dt(e,n,t[n])}),Ba=Hr(function(e,t){Mr(t,ed(t),e)}),La=Hr(function(e,t,n,r){Mr(t,ed(t),e,r)}),Ua=Hr(function(e,t,n,r){Mr(t,Xi(t),e,r)}),Da=vo(Ht),qa=pr(function(e,t){e=kd(e);var n=-1,r=t.length,o=2--e)return t.apply(this,arguments)}},i.ary=Si,i.assign=Ra,i.assignIn=Ba,i.assignInWith=La,i.assignWith=Ua,i.at=Da,i.before=Ti,i.bind=ya,i.bindAll=ll,i.bindKey=ma,i.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Aa(e)?e:[e]},i.chain=wi,i.chunk=function(e,t,n){t=(n?Do(e,t,n):void 0===t)?1:os(Ji(t),0);var r=null==e?0:e.length;if(!r||1>t)return[];for(var o=0,i=0,d=_d(Yd(r/t));ot?0:t,r)):[]},i.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0,0>t?0:t)):[]},i.dropRightWhile=function(e,t){return e&&e.length?Tr(e,Ao(t,3),!0,!0):[]},i.dropWhile=function(e,t){return e&&e.length?Tr(e,Ao(t,3),!0):[]},i.fill=function(e,t,n,r){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&Do(e,t,n)&&(n=0,r=o),rn(e,t,n,r)):[]},i.filter=function(e,t){var n=Aa(e)?h:on;return n(e,Ao(t,3))},i.flatMap=function(e,t){return dn(vi(e,t),1)},i.flatMapDeep=function(e,t){return dn(vi(e,t),je)},i.flatMapDepth=function(e,t,n){return n=void 0===n?1:Ji(n),dn(vi(e,t),n)},i.flatten=hi,i.flattenDeep=function(e){var t=null==e?0:e.length;return t?dn(e,je):[]},i.flattenDepth=function(e,t){var n=null==e?0:e.length;return n?(t=void 0===t?1:Ji(t),dn(e,t)):[]},i.flip=function(e){return fo(e,Te)},i.flow=pl,i.flowRight=ul,i.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={},o;++t>>0,!n)?[]:(e=Zi(e),e&&("string"==typeof t||null!=t&&!Fa(t))&&(t=xr(t),!t&&$(e))?Nr(ne(e),0,n):e.split(t,n))},i.spread=function(e,t){if("function"!=typeof e)throw new vd(ae);return t=null==t?0:os(Ji(t),0),pr(function(n){var r=n[t],o=Nr(n,0,t);return r&&y(o,r),s(e,this,o)})},i.tail=function(e){var t=null==e?0:e.length;return t?_r(e,1,t):[]},i.take=function(e,t,n){return e&&e.length?(t=n||void 0===t?1:Ji(t),_r(e,0,0>t?0:t)):[]},i.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0>t?0:t,r)):[]},i.takeRightWhile=function(e,t){return e&&e.length?Tr(e,Ao(t,3),!1,!0):[]},i.takeWhile=function(e,t){return e&&e.length?Tr(e,Ao(t,3)):[]},i.tap=function(e,t){return t(e),e},i.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new vd(ae);return Ri(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Ai(e,t,{leading:r,maxWait:t,trailing:o})},i.thru=ki,i.toArray=Mi,i.toPairs=Qa,i.toPairsIn=Xa,i.toPath=function(e){return Aa(e)?f(e,di):qi(e)?[e]:qr(qs(Zi(e)))},i.toPlainObject=Gi,i.transform=function(e,t,n){var r=Aa(e),o=r||Oa(e)||Pa(e);if(t=Ao(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Ri(e)?Pi(i)?Is(Ld(e)):{}:{}}return(o?l:sn)(e,function(e,r,o){return t(n,e,r,o)}),n},i.unary=function(e){return Si(e,1)},i.union=Qs,i.unionBy=Xs,i.unionWith=ea,i.uniq=function(e){return e&&e.length?br(e):[]},i.uniqBy=function(e,t){return e&&e.length?br(e,Ao(t,2)):[]},i.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?br(e,void 0,t):[]},i.unset=function(e,t){return null==e||vr(e,t)},i.unzip=yi,i.unzipWith=mi,i.update=function(e,t,n){return null==e?e:Sr(e,t,Or(n))},i.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:Sr(e,t,Or(n),r)},i.values=rd,i.valuesIn=function(e){return null==e?[]:R(e,ed(e))},i.without=ta,i.words=dd,i.wrap=function(e,t){return ba(Or(t),e)},i.xor=na,i.xorBy=ra,i.xorWith=oa,i.zip=ia,i.zipObject=function(e,t){return Ar(e||[],t||[],Dt)},i.zipObjectDeep=function(e,t){return Ar(e||[],t||[],cr)},i.zipWith=da,i.entries=Qa,i.entriesIn=Xa,i.extend=Ba,i.extendWith=La,pd(i,i),i.add=wl,i.attempt=al,i.camelCase=el,i.capitalize=od,i.ceil=kl,i.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=Hi(n),n=n===n?n:0),void 0!==t&&(t=Hi(t),t=t===t?t:0),Gt(Hi(e),t,n)},i.clone=function(e){return Zt(e,ce)},i.cloneDeep=function(e){return Zt(e,ue|ce)},i.cloneDeepWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ue|ce,t)},i.cloneWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ce,t)},i.conformsTo=function(e,t){return null==t||Qt(e,t,Xi(t))},i.deburr=id,i.defaultTo=function(e,t){return null==e||e!==e?t:e},i.divide=xl,i.endsWith=function(e,t,n){e=Zi(e),t=xr(t);var r=e.length;n=void 0===n?r:Gt(Ji(n),0,r);var o=n;return n-=t.length,0<=n&&e.slice(n,o)==t},i.eq=Ei,i.escape=function(e){return e=Zi(e),e&&ut.test(e)?e.replace(lt,Bn):e},i.escapeRegExp=function(e){return e=Zi(e),e&&wt.test(e)?e.replace(mt,"\\$&"):e},i.every=function(e,t,n){var r=Aa(e)?u:tn;return n&&Do(e,t,n)&&(t=void 0),r(e,Ao(t,3))},i.find=la,i.findIndex=pi,i.findKey=function(e,t){return v(e,Ao(t,3),sn)},i.findLast=pa,i.findLastIndex=ui,i.findLastKey=function(e,t){return v(e,Ao(t,3),an)},i.floor=bl,i.forEach=xi,i.forEachRight=bi,i.forIn=function(e,t){return null==e?e:zs(e,Ao(t,3),ed)},i.forInRight=function(e,t){return null==e?e:Os(e,Ao(t,3),ed)},i.forOwn=function(e,t){return e&&sn(e,Ao(t,3))},i.forOwnRight=function(e,t){return e&&an(e,Ao(t,3))},i.get=Yi,i.gt=Ta,i.gte=Ia,i.has=function(e,t){return null!=e&&Po(e,t,kn)},i.hasIn=Qi,i.head=ci,i.identity=ad,i.includes=function(e,t,n,r){e=Ni(e)?e:rd(e),n=n&&!r?Ji(n):0;var o=e.length;return 0>n&&(n=os(o+n,0)),Di(e)?n<=o&&-1o&&(o=os(r+o,0)),T(e,t,o)},i.inRange=function(e,t,n){return t=$i(t),void 0===n?(n=t,t=0):n=$i(n),e=Hi(e),Sn(e,t,n)},i.invoke=Ka,i.isArguments=ja,i.isArray=Aa,i.isArrayBuffer=za,i.isArrayLike=Ni,i.isArrayLikeObject=Fi,i.isBoolean=function(e){return!0===e||!1===e||Bi(e)&&gn(e)==We},i.isBuffer=Oa,i.isDate=Ea,i.isElement=function(e){return Bi(e)&&1===e.nodeType&&!Ui(e)},i.isEmpty=function(e){if(null==e)return!0;if(Ni(e)&&(Aa(e)||"string"==typeof e||"function"==typeof e.splice||Oa(e)||Pa(e)||ja(e)))return!e.length;var t=Rs(e);if(t==Be||t==Me)return!e.size;if(Ko(e))return!Jn(e).length;for(var n in e)if(zd.call(e,n))return!1;return!0},i.isEqual=function(e,t){return Cn(e,t)},i.isEqualWith=function(e,t,n){n="function"==typeof n?n:void 0;var r=n?n(e,t):void 0;return void 0===r?Cn(e,t,void 0,n):!!r},i.isError=Wi,i.isFinite=function(e){return"number"==typeof e&&ts(e)},i.isFunction=Pi,i.isInteger=Vi,i.isLength=Ci,i.isMap=Na,i.isMatch=function(e,t){return e===t||qn(e,t,Oo(t))},i.isMatchWith=function(e,t,n){return n="function"==typeof n?n:void 0,qn(e,t,Oo(t),n)},i.isNaN=function(e){return Li(e)&&e!=+e},i.isNative=function(e){if(Bs(e))throw new yd("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mn(e)},i.isNil=function(e){return null==e},i.isNull=function(e){return null===e},i.isNumber=Li,i.isObject=Ri,i.isObjectLike=Bi,i.isPlainObject=Ui,i.isRegExp=Fa,i.isSafeInteger=function(e){return Vi(e)&&e>=-Ae&&e<=Ae},i.isSet=Wa,i.isString=Di,i.isSymbol=qi,i.isTypedArray=Pa,i.isUndefined=function(e){return void 0===e},i.isWeakMap=function(e){return Bi(e)&&Rs(e)==Ke},i.isWeakSet=function(e){return Bi(e)&&gn(e)=="[object WeakSet]"},i.join=function(e,t){return null==e?"":ns.call(e,t)},i.kebabCase=tl,i.last=gi,i.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return void 0!==n&&(o=Ji(n),o=0>o?os(r+o,0):is(o,r-1)),t===t?ee(e,t,o):S(e,j,o,!0)},i.lowerCase=nl,i.lowerFirst=rl,i.lt=Va,i.lte=Ca,i.max=function(e){return e&&e.length?nn(e,ad,_n):void 0},i.maxBy=function(e,t){return e&&e.length?nn(e,Ao(t,2),_n):void 0},i.mean=function(e){return A(e,ad)},i.meanBy=function(e,t){return A(e,Ao(t,2))},i.min=function(e){return e&&e.length?nn(e,ad,Hn):void 0},i.minBy=function(e,t){return e&&e.length?nn(e,Ao(t,2),Hn):void 0},i.stubArray=cd,i.stubFalse=gd,i.stubObject=function(){return{}},i.stubString=function(){return""},i.stubTrue=function(){return!0},i.multiply=vl,i.nth=function(e,t){return e&&e.length?er(e,Ji(t)):void 0},i.noConflict=function(){return Tn._===this&&(Tn._=Wd),this},i.noop=ud,i.now=fa,i.pad=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return lo(Qd(o),n)+e+lo(Yd(o),n)},i.padEnd=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=as();return is(e+o*(t-e+xn("1e-"+((o+"").length-1))),t)}return sr(e,t)},i.reduce=function(e,t,n){var r=Aa(e)?m:E,o=3>arguments.length;return r(e,Ao(t,4),n,o,js)},i.reduceRight=function(e,t,n){var r=Aa(e)?w:E,o=3>arguments.length;return r(e,Ao(t,4),n,o,As)},i.repeat=function(e,t,n){return t=(n?Do(e,t,n):void 0===t)?1:Ji(t),lr(Zi(e),t)},i.replace=function(){var e=arguments,t=Zi(e[0]);return 3>e.length?t:t.replace(e[1],e[2])},i.result=nd,i.round=Sl,i.runInContext=r,i.sample=function(e){var t=Aa(e)?Rt:ur;return t(e)},i.size=function(e){if(null==e)return 0;if(Ni(e))return Di(e)?te(e):e.length;var t=Rs(e);return t==Be||t==Me?e.size:Jn(e).length},i.snakeCase=ol,i.some=function(e,t,n){var r=Aa(e)?k:fr;return n&&Do(e,t,n)&&(t=void 0),r(e,Ao(t,3))},i.sortedIndex=function(e,t){return yr(e,t)},i.sortedIndexBy=function(e,t,n){return mr(e,t,Ao(n,2))},i.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=yr(e,t);if(re||e>Ae)return[];var n=Oe,r=is(e,Oe);t=Ao(t),e-=Oe;for(var o=W(r,t);++n=i)return e;var s=n-te(r);if(1>s)return r;var a=d?Nr(d,0,s).join(""):e.slice(0,s);if(void 0===o)return a+r;if(d&&(s+=a.length-s),Fa(o)){if(e.slice(s).search(o)){var l=a,p;for(o.global||(o=xd(o.source,Zi(zt.exec(o))+"g")),o.lastIndex=0;p=o.exec(l);)var u=p.index;a=a.slice(0,void 0===u?s:u)}}else if(e.indexOf(xr(o),s)!=s){var h=a.lastIndexOf(o);-1n.__dir__?"Right":"")}),n},x.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),l(["filter","map","takeWhile"],function(e,t){var n=t+1;x.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ao(e,3),type:n}),t.__filtered__=t.__filtered__||n==Ie||n==3,t}}),l(["head","last"],function(e,t){var n="take"+(t?"Right":"");x.prototype[e]=function(){return this[n](1).value()[0]}}),l(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");x.prototype[e]=function(){return this.__filtered__?new x(this):this[n](1)}}),x.prototype.compact=function(){return this.filter(ad)},x.prototype.find=function(e){return this.filter(e).head()},x.prototype.findLast=function(e){return this.reverse().find(e)},x.prototype.invokeMap=pr(function(e,t){return"function"==typeof e?new x(this):this.map(function(n){return zn(n,e,t)})}),x.prototype.reject=function(e){return this.filter(Oi(Ao(e)))},x.prototype.slice=function(e,t){e=Ji(e);var n=this;return n.__filtered__&&(0t)?new x(n):(0>e?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(t=Ji(t),n=0>t?n.dropRight(-t):n.take(t-e)),n)},x.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},x.prototype.toArray=function(){return this.take(Oe)},sn(x.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=i[r?"take"+("last"==t?"Right":""):t],d=r||/^find/.test(t);o&&(i.prototype[t]=function(){var t=this.__wrapped__,s=r?[1]:arguments,a=t instanceof x,l=s[0],p=a||Aa(t),u=function(e){var t=o.apply(i,y([e],s));return r&&h?t[0]:t};p&&n&&"function"==typeof l&&1!=l.length&&(a=p=!1);var h=this.__chain__,c=!!this.__actions__.length,g=d&&!h,f=a&&!c;if(!d&&p){t=f?t:new x(this);var m=e.apply(t,s);return m.__actions__.push({func:ki,args:[u],thisArg:void 0}),new _(m,h)}return g&&f?e.apply(this,s):(m=this.thru(u),g?r?m.value()[0]:m.value():m)})}),l(["pop","push","shift","sort","splice","unshift"],function(e){var t=Sd[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);i.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(Aa(o)?o:[],e)}return this[n](function(n){return t.apply(Aa(n)?n:[],e)})}}),sn(x.prototype,function(e,t){var n=i[t];if(n){var r=n.name+"";zd.call(ys,r)||(ys[r]=[]),ys[r].push({name:t,func:n})}}),ys[oo(void 0,ye).name]=[{name:"wrapper",func:void 0}],x.prototype.clone=function(){var e=new x(this.__wrapped__);return e.__actions__=qr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qr(this.__views__),e},x.prototype.reverse=function(){if(this.__filtered__){var e=new x(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},x.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Aa(e),r=0>t,o=n?e.length:0,i=Fo(0,o,this.__views__),d=i.start,s=i.end,a=s-d,l=r?s:d-1,p=this.__iteratees__,u=p.length,h=0,c=is(a,this.__takeCount__);if(!n||!r&&o==a&&c==a)return Ir(e,this.__actions__);var g=[];outer:for(;a--&&h=this.__values__.length,t=e?void 0:this.__values__[this.__index__++];return{done:e,value:t}},i.prototype.plant=function(e){for(var t=this,n,r;t instanceof d;){r=li(t),r.__index__=0,r.__values__=void 0,n?o.__wrapped__=r:n=r;var o=r;t=t.__wrapped__}return o.__wrapped__=e,n},i.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof x){var t=e;return this.__actions__.length&&(t=new x(this)),t=t.reverse(),t.__actions__.push({func:ki,args:[fi],thisArg:void 0}),new _(t,this.__chain__)}return this.thru(fi)},i.prototype.toJSON=i.prototype.valueOf=i.prototype.value=function(){return Ir(this.__wrapped__,this.__actions__)},i.prototype.first=i.prototype.head,$d&&(i.prototype[$d]=function(){return this}),i}();"function"==typeof r&&"object"==typeof r.amd&&r.amd?(Tn._=Un,r(function(){return Un})):jn?((jn.exports=Un)._=Un,In._=Un):Tn._=Un}).call(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],5:[function(n,o,i){(function(){var n=Math.log,d=function(e){var t=new d.Index;return t.pipeline.add(d.trimmer,d.stopWordFilter,d.stemmer),e&&e.call(t,t),t};d.version="1.0.0",d.utils={},d.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),d.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},d.EventEmitter=function(){this.events={}},d.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},d.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},d.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)})}},d.EventEmitter.prototype.hasHandler=function(e){return e in this.events},d.tokenizer=function(e){return arguments.length&&null!=e&&void 0!=e?Array.isArray(e)?e.map(function(e){return d.utils.asString(e).toLowerCase()}):e.toString().trim().toLowerCase().split(d.tokenizer.separator):[]},d.tokenizer.separator=/[\s\-]+/,d.tokenizer.load=function(e){var t=this.registeredFunctions[e];if(!t)throw new Error("Cannot load un-registered function: "+e);return t},d.tokenizer.label="default",d.tokenizer.registeredFunctions={default:d.tokenizer},d.tokenizer.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing tokenizer: "+t),e.label=t,this.registeredFunctions[t]=e},d.Pipeline=function(){this._stack=[]},d.Pipeline.registeredFunctions={},d.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing registered function: "+t),e.label=t,d.Pipeline.registeredFunctions[e.label]=e},d.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||d.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},d.Pipeline.load=function(e){var t=new d.Pipeline;return e.forEach(function(e){var n=d.Pipeline.registeredFunctions[e];if(n)t.add(n);else throw new Error("Cannot load un-registered function: "+e)}),t},d.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){d.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},d.Pipeline.prototype.after=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");++n,this._stack.splice(n,0,t)},d.Pipeline.prototype.before=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},d.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1==t||this._stack.splice(t,1)},d.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,o=0,i;on.idx?n=n.next:(r+=t.val*n.val,t=t.next,n=n.next);return r},d.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},d.SortedSet=function(){this.length=0,this.elements=[]},d.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},d.SortedSet.prototype.add=function(){var e,t;for(e=0;et&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i]}return d===t?i:-1},d.SortedSet.prototype.locationFor=function(t){for(var n=0,r=this.elements.length,o=r-n,i=n+e(o/2),d=this.elements[i];1t&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i];return d>t?i:do-1||r>i-1);){if(s[n]===a[r]){t.add(s[n]),n++,r++;continue}if(s[n]a[r]){r++;continue}}return t},d.SortedSet.prototype.clone=function(){var e=new d.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},d.SortedSet.prototype.union=function(e){var t,n,r;this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone();for(var o=0,i=n.toArray();on.length)return n;if(w=n.substr(0,1),"y"==w&&(n=w.toUpperCase()+n.substr(1)),I=l,j=p,I.test(n)?n=n.replace(I,"$1$2"):j.test(n)&&(n=n.replace(j,"$1$2")),I=u,j=h,I.test(n)){var O=I.exec(n);I=i,I.test(O[1])&&(I=c,n=n.replace(I,""))}else if(j.test(n)){var O=j.exec(n);r=O[1],j=a,j.test(r)&&(n=r,j=g,A=_,z=f,j.test(n)?n+="e":A.test(n)?(I=c,n=n.replace(I,"")):z.test(n)&&(n+="e"))}if(I=y,I.test(n)){var O=I.exec(n);r=O[1],n=r+"i"}if(I=m,I.test(n)){var O=I.exec(n);r=O[1],o=O[2],I=i,I.test(r)&&(n=r+e[o])}if(I=k,I.test(n)){var O=I.exec(n);r=O[1],o=O[2],I=i,I.test(r)&&(n=r+t[o])}if(I=x,j=b,I.test(n)){var O=I.exec(n);r=O[1],I=d,I.test(r)&&(n=r)}else if(j.test(n)){var O=j.exec(n);r=O[1]+O[2],j=d,j.test(r)&&(n=r)}if(I=v,I.test(n)){var O=I.exec(n);r=O[1],I=d,j=s,A=T,(I.test(r)||j.test(r)&&!A.test(r))&&(n=r)}return I=S,j=d,I.test(n)&&j.test(n)&&(I=c,n=n.replace(I,"")),"y"==w&&(n=w.toLowerCase()+n.substr(1)),n}}(),d.Pipeline.registerFunction(d.stemmer,"stemmer"),d.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e]!==e)return e}},d.stopWordFilter=d.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),d.Pipeline.registerFunction(d.stopWordFilter,"stopWordFilter"),d.trimmer=function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")},d.Pipeline.registerFunction(d.trimmer,"trimmer"),d.TokenStore=function(){this.root={docs:{}},this.length=0},d.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},d.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e.charAt(0),o=e.slice(1);return r in n||(n[r]={docs:{}}),0===o.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(o,t,n[r])},d.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;n=d&&(p.push(e[u]),p[p.length-1].intersection_length=h.length)}return p=n.orderBy(p,["intersection_length"],["desc"]),{pagination:{per_page:o,page:s,total:p.length},data:{items:p.slice((s-1)*o,s*o)}}},t.exports.aggregation=function(e,n,o,i,d){var s=n.per_page||10,a=n.page||1;if(n.name&&(!o.aggregations||!o.aggregations[n.name]))throw new Error("Please define aggregation \"".concat(n.name,"\" in config"));var l=r.clone(n);if(l.page=1,l.per_page=0,!n.name)throw new Error("field name is required");o.aggregations[n.name].size=1e4;var p=t.exports.search(e,l,o,i,d),u=p.data.aggregations[n.name].buckets;return{pagination:{per_page:s,page:a,total:u.length},data:{buckets:u.slice((a-1)*s,a*s)}}}},{"./helpers":8,fastbitset:3,lodash:4}]},{},[1])(1)}); diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..103070d --- /dev/null +++ b/docs/development.md @@ -0,0 +1,12 @@ +# Development guide + +### CDN + +Version pushed to NPM repository + +https://unpkg.com/itemsjs@2.1.15/dist/itemsjs.min.js + +Useful if we needs to test branch version in browser + +https://cdn.jsdelivr.net/gh/itemsapi/itemsjs@{branch-name}/dist/itemsjs.min.js + diff --git a/package-lock.json b/package-lock.json index 188d652..8f4e9be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "itemsjs", - "version": "2.1.12", + "version": "2.1.15", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "2.1.12", + "version": "2.1.15", "license": "Apache-2.0", "dependencies": { + "boolean-parser": "^0.0.2", "fastbitset": "^0.4.0", "lodash": "^4.17.21", "lunr": "^1.0.0" @@ -2101,6 +2102,11 @@ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", "dev": true }, + "node_modules/boolean-parser": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/boolean-parser/-/boolean-parser-0.0.2.tgz", + "integrity": "sha512-e06Mqk6t7DOXaEo3s+RATvv7ZNt5brRQ2os4NUHVkVCzUD0Z7Gw4AL4AFA/gT3WaLhrobmGvRVh1/UuJiY3sKg==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -8385,6 +8391,11 @@ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", "dev": true }, + "boolean-parser": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/boolean-parser/-/boolean-parser-0.0.2.tgz", + "integrity": "sha512-e06Mqk6t7DOXaEo3s+RATvv7ZNt5brRQ2os4NUHVkVCzUD0Z7Gw4AL4AFA/gT3WaLhrobmGvRVh1/UuJiY3sKg==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", diff --git a/package.json b/package.json index a51ce71..52d22eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "itemsjs", - "version": "2.1.15", + "version": "2.1.16", "description": "Created to perform fast search on small json dataset (up to 1000 elements).", "main": "lib/index.js", "scripts": { @@ -17,6 +17,7 @@ "author": "Mateusz Rzepa", "license": "Apache-2.0", "dependencies": { + "boolean-parser": "^0.0.2", "fastbitset": "^0.4.0", "lodash": "^4.17.21", "lunr": "^1.0.0" diff --git a/src/facets.js b/src/facets.js index bb54864..b09b1ac 100644 --- a/src/facets.js +++ b/src/facets.js @@ -78,9 +78,15 @@ Facets.prototype = { temp_facet.not_ids = helpers.facets_ids(temp_facet['bits_data'], input.not_filters, config); + let temp_data; + const filters = helpers.input_to_facet_filters(input, config); + temp_data = helpers.matrix(this.facets, filters); - const temp_data = helpers.matrix(this.facets, filters); + if (input.filters_query) { + const filters = helpers.parse_boolean_query(input.filters_query); + temp_data = helpers.filters_matrix(temp_data, filters); + } temp_facet['bits_data_temp'] = temp_data['bits_data_temp']; @@ -98,9 +104,15 @@ Facets.prototype = { }); /** - * calculating ids + * calculating ids (for a list of items) + * facets ids is faster and filter ids because filter ids makes union each to each filters + * filter ids needs to be used if there is filters query */ - temp_facet.ids = helpers.facets_ids(temp_facet['bits_data_temp'], input.filters, config); + if (input.filters_query) { + temp_facet.ids = helpers.filters_ids(temp_facet['bits_data_temp']); + } else { + temp_facet.ids = helpers.facets_ids(temp_facet['bits_data_temp'], input.filters); + } return temp_facet; } diff --git a/src/helpers.js b/src/helpers.js index 24412bd..fd6778d 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,5 +1,6 @@ const _ = require('lodash'); const FastBitSet = require('fastbitset'); +const booleanParser = require('boolean-parser'); const clone = function(val) { @@ -46,6 +47,63 @@ const combination_indexes = function(facets, filters) { return indexes; }; + +const filters_matrix = function(facets, query_filters) { + const temp_facet = _.clone(facets); + + if (!temp_facet['is_temp_copied']) { + _.mapValues(temp_facet['bits_data'], function(values, key) { + _.mapValues(temp_facet['bits_data'][key], function(facet_indexes, key2) { + temp_facet['bits_data_temp'][key][key2] = temp_facet['bits_data'][key][key2]; + }); + }); + } + + let union = null; ; + + /** + * process only conjunctive filters + */ + _.mapValues(query_filters, function(conjunction) { + + let conjunctive_index = null; + + _.mapValues(conjunction, function(filter) { + + const filter_key = filter[0]; + const filter_val = filter[1]; + + if (!temp_facet['bits_data_temp'][filter_key]) { + throw new Error('Panic. The key does not exist in facets lists.') + } + + + if (conjunctive_index && temp_facet['bits_data_temp'][filter_key][filter_val]) { + conjunctive_index = temp_facet['bits_data_temp'][filter_key][filter_val].new_intersection(conjunctive_index); + } else if (conjunctive_index && !temp_facet['bits_data_temp'][filter_key][filter_val]) { + conjunctive_index = new FastBitSet([]); + } else { + conjunctive_index = temp_facet['bits_data_temp'][filter_key][filter_val]; + } + }); + + union = (union || new FastBitSet([])).new_union(conjunctive_index || new FastBitSet([])); + }); + + if (union !== null) { + + _.mapValues(temp_facet['bits_data_temp'], function(values, key) { + _.mapValues(temp_facet['bits_data_temp'][key], function(facet_indexes, key2) { + temp_facet['bits_data_temp'][key][key2] = temp_facet['bits_data_temp'][key][key2].new_intersection(union); + }); + }); + } + + return temp_facet; +} + + + /* * returns facets and ids */ @@ -60,6 +118,7 @@ const matrix = function(facets, filters) { }); }); + temp_facet['is_temp_copied'] = true; let conjunctive_index; const disjunctive_indexes = combination_indexes(facets, filters); @@ -94,13 +153,6 @@ const matrix = function(facets, filters) { }); } - // cross all combination indexes with conjunctive index - /*if (conjunctive_index) { - _.mapValues(disjunctive_indexes, function(disjunctive_index, disjunctive_key) { - disjunctive_indexes[disjunctive_key] = conjunctive_index.new_intersection(disjunctive_indexes[disjunctive_key]); - }); - }*/ - /** * process only negative filters */ @@ -226,10 +278,27 @@ const index = function(items, fields) { return facets; }; +/** + * calculates ids for filters + */ +const filters_ids = function(facets_data) { + + let output = new FastBitSet([]); + + _.mapValues(facets_data, function(values, key) { + _.mapValues(facets_data[key], function(facet_indexes, key2) { + output = output.new_union(facets_data[key][key2]); + }); + }); + + return output; +}; + + /** * calculates ids for facets * if there is no facet input then return null to not save resources for OR calculation - * null means facets haven't crossed searched items + * null means facets haven't matched searched items */ const facets_ids = function(facets_data, filters) { @@ -238,8 +307,6 @@ const facets_ids = function(facets_data, filters) { _.mapValues(filters, function(filters, field) { - //console.log(facets_data); - filters.forEach(filter => { ++i; @@ -313,7 +380,7 @@ const getBuckets = function(data, input, aggregations) { throw new Error("You cant use chars to calculate the facet_stats."); } - // Doc_count + // Doc_count if(v2[1].array().length > 0) { v2[1].forEach(doc_count => { facet_stats.push(parseInt(v2[0])); @@ -329,7 +396,7 @@ const getBuckets = function(data, input, aggregations) { sum: _.sumBy(facet_stats), }; } - + return { name: k, title: title || humanize(k), @@ -404,13 +471,44 @@ const input_to_facet_filters = function(input, config) { return filters; }; +const parse_boolean_query = function (query) { + const result = parse_boolean_query_temp(query); + return result; +} + +const parse_boolean_query_temp = function (query) { + + const result = booleanParser.parseBooleanQuery(query); + + return _.map(result, v1 => { + + if (Array.isArray(v1)) { + + return _.map(v1, v2 => { + if (Array.isArray(v2)) { + return _.map(v2, v3 => { + return v3; + }) + } else { + return v2.split(':'); + } + }) + } else { + return v1.split(':'); + } + }) +} + +module.exports.parse_boolean_query = parse_boolean_query; module.exports.input_to_facet_filters = input_to_facet_filters; module.exports.facets_ids = facets_ids; +module.exports.filters_ids = filters_ids; module.exports.clone = clone; module.exports.humanize = humanize; module.exports.index = index; module.exports.combination_indexes = combination_indexes; module.exports.matrix = matrix; +module.exports.filters_matrix = filters_matrix; module.exports.getBuckets = getBuckets; module.exports.getFacets = getBuckets; module.exports.mergeAggregations = mergeAggregations; diff --git a/tests/filtersMatrixSpec.js b/tests/filtersMatrixSpec.js new file mode 100644 index 0000000..36a83fb --- /dev/null +++ b/tests/filtersMatrixSpec.js @@ -0,0 +1,136 @@ +'use strict'; + +const assert = require('assert'); +const Facets = require('./../src/facets'); +const helpers = require('./../src/helpers'); +const FastBitSet = require('fastbitset'); + +describe('filtering matrix (9 rows in dataset)', function() { + + const items = [ + {a: 1, b: 2, c: 3, d: 3}, + {a: 1, b: 3, c: 3, d: 3}, + {a: 2, b: 3, c: 3, d: 3}, + {a: 1, b: 2, c: 3, d: 3}, + {a: 2, b: 3, c: 3, d: 3}, + {a: 1, b: 2, c: 3, d: 3}, + {a: 1, b: 3, c: 3, d: 3}, + {a: 2, b: 3, c: 3, d: 3}, + {a: 2, b: 2, c: 3, d: 3} + ]; + + const fields = ['a', 'b', 'c']; + + it('checks matrix with no argument provided', function test(done) { + + const data = helpers.index(items, fields); + + const result = helpers.filters_matrix(data); + assert.deepEqual(result.bits_data_temp.a['1'].array(), [1, 2, 4, 6, 7]); + assert.deepEqual(result.bits_data_temp.a['2'].array(), [3, 5, 8, 9]); + assert.deepEqual(result.bits_data_temp.b['2'].array(), [1, 4, 6, 9]); + assert.deepEqual(result.bits_data_temp.b['3'].array(), [2, 3, 5, 7, 8]); + assert.deepEqual(result.bits_data_temp.c['3'].array(), [1, 2, 3, 4, 5, 6, 7, 8, 9]); + + const ids = helpers.filters_ids(result.bits_data_temp); + assert.deepEqual(ids.array(), [1, 2, 3, 4, 5, 6, 7, 8, 9]); + + done(); + }); + + it('filters matrix with one value', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('(a:2)'); + + const result = helpers.filters_matrix(data, filters); + assert.deepEqual(result.bits_data_temp.a['1'].array(), []); + assert.deepEqual(result.bits_data_temp.a['2'].array(), [3, 5, 8, 9]); + assert.deepEqual(result.bits_data_temp.b['2'].array(), [9]); + assert.deepEqual(result.bits_data_temp.b['3'].array(), [3, 5, 8]); + assert.deepEqual(result.bits_data_temp.c['3'].array(), [3, 5, 8, 9]); + + const ids = helpers.filters_ids(result.bits_data_temp); + assert.deepEqual(ids.array(), [3, 5, 8, 9]); + + done(); + }); + + it('makes OR which returns all rows', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('(a:2) OR c:3'); + + const result = helpers.filters_matrix(data, filters); + assert.deepEqual(result.bits_data_temp.a['1'].array(), [1, 2, 4, 6, 7]); + assert.deepEqual(result.bits_data_temp.a['2'].array(), [3, 5, 8, 9]); + assert.deepEqual(result.bits_data_temp.b['2'].array(), [1, 4, 6, 9]); + assert.deepEqual(result.bits_data_temp.b['3'].array(), [2, 3, 5, 7, 8]); + assert.deepEqual(result.bits_data_temp.c['3'].array(), [1, 2, 3, 4, 5, 6, 7, 8, 9]); + + const ids = helpers.filters_ids(result.bits_data_temp); + assert.deepEqual(ids.array(), [1, 2, 3, 4, 5, 6, 7, 8, 9]); + + done(); + }); + + it('makes AND which returns no result', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('a:2 AND a:1'); + + const result = helpers.filters_matrix(data, filters); + assert.deepEqual(result.bits_data_temp.a['1'].array(), []); + assert.deepEqual(result.bits_data_temp.a['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['3'].array(), []); + assert.deepEqual(result.bits_data_temp.c['3'].array(), []); + + const ids = helpers.filters_ids(result.bits_data_temp); + assert.deepEqual(ids.array(), []); + + done(); + }); + + it('makes AND with not existing value', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('a:2 AND a:10'); + + const result = helpers.filters_matrix(data, filters); + assert.deepEqual(result.bits_data_temp.a['1'].array(), []); + assert.deepEqual(result.bits_data_temp.a['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['3'].array(), []); + assert.deepEqual(result.bits_data_temp.c['3'].array(), []); + done(); + }); + + it('filters not existing value', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('a:10'); + + const result = helpers.filters_matrix(data, filters); + assert.deepEqual(result.bits_data_temp.a['1'].array(), []); + assert.deepEqual(result.bits_data_temp.a['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['2'].array(), []); + assert.deepEqual(result.bits_data_temp.b['3'].array(), []); + assert.deepEqual(result.bits_data_temp.c['3'].array(), []); + done(); + }); + + it('filters not existing key', function test(done) { + + const data = helpers.index(items, fields); + const filters = helpers.parse_boolean_query('e:10'); + + try { + helpers.filters_matrix(data, filters); + } catch (err) { + assert.equal(err.message, 'Panic. The key does not exist in facets lists.'); + } + done(); + }); + +}); diff --git a/tests/matrixSpec.js b/tests/matrixSpec.js index c0e4a11..05b5e0b 100644 --- a/tests/matrixSpec.js +++ b/tests/matrixSpec.js @@ -5,7 +5,7 @@ const Facets = require('./../src/facets'); const helpers = require('./../src/helpers'); const FastBitSet = require('fastbitset'); -describe('filtering and generating facets', function() { +describe('filtering and generating facets with matrix (9 rows in dataset)', function() { const items = [ {a: 1, b: 2, c: 3, d: 3}, @@ -21,7 +21,7 @@ describe('filtering and generating facets', function() { const fields = ['a', 'b', 'c']; - it('checks matrix without filters applied', function test(done) { + it('checks matrix with no argument provided', function test(done) { const data = helpers.index(items, fields); @@ -34,7 +34,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with filters', function test(done) { + it('checks matrix with some values', function test(done) { const data = helpers.index(items, fields); @@ -51,7 +51,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with one empty filter', function test(done) { + it('checks matrix with one not existing value', function test(done) { const data = helpers.index(items, fields); @@ -64,7 +64,8 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with one empty filter and check again', function test(done) { + + it('checks matrix with one not existing value and check again with another values', function test(done) { const data = helpers.index(items, fields); @@ -80,7 +81,7 @@ describe('filtering and generating facets', function() { }); - it('checks matrix with disjunctive filters', function test(done) { + it('checks matrix with disjunctive values', function test(done) { const data = helpers.index(items, fields); @@ -97,7 +98,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with disjunctive filters (ittocean case)', function test(done) { + it('checks matrix with disjunctive values (ittocean case)', function test(done) { const data = helpers.index(items, fields); @@ -116,7 +117,7 @@ describe('filtering and generating facets', function() { }); }); -describe('filtering and generating facets', function() { +describe('filtering and generating facets for another dataset (3 rows in dataset)', function() { const items = [ {a: 1, b: 1, c: 3}, @@ -126,7 +127,7 @@ describe('filtering and generating facets', function() { const fields = ['a', 'b', 'c']; - it('checks matrix with disjunctive filters', function test(done) { + it('checks matrix with disjunctive values', function test(done) { const data = helpers.index(items, fields); @@ -141,7 +142,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with one disjunctive filters', function test(done) { + it('checks matrix with one disjunctive value', function test(done) { const data = helpers.index(items, fields); @@ -156,7 +157,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with many disjunctive filters', function test(done) { + it('checks matrix with many disjunctive values', function test(done) { const data = helpers.index(items, fields); const result = helpers.matrix(data, [[['a', 1]], [['b', 1]], [['c', 3]]]); @@ -170,7 +171,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with negative filters', function test(done) { + it('checks matrix with negative filter values', function test(done) { const data = helpers.index(items, fields); const result = helpers.matrix(data, [['a', '-', 1]]); @@ -184,7 +185,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with negative filters 2', function test(done) { + it('checks matrix with negative filter values (2)', function test(done) { const data = helpers.index(items, fields); const result = helpers.matrix(data, [['a', '-', 1], ['b', '-', 2]]); @@ -199,7 +200,7 @@ describe('filtering and generating facets', function() { }); }); -describe('filtering and generating facets', function() { +describe('filtering and generating facets (4 rows in dataset)', function() { const items = [ { a: 1, b: 3 }, @@ -210,7 +211,7 @@ describe('filtering and generating facets', function() { const fields = ['a', 'b']; - it('checks matrix with disjunctive filters', function test(done) { + it('checks matrix with disjunctive values', function test(done) { const data = helpers.index(items, fields); @@ -223,7 +224,7 @@ describe('filtering and generating facets', function() { }); - xit('checks matrix with disjunctive filters', function test(done) { + xit('checks matrix with disjunctive values', function test(done) { const data = helpers.index(items, fields); @@ -235,7 +236,7 @@ describe('filtering and generating facets', function() { done(); }); - it('checks matrix with disjunctive filters', function test(done) { + it('checks matrix with disjunctive values', function test(done) { const data = helpers.index(items, fields); diff --git a/tests/parserSpec.js b/tests/parserSpec.js new file mode 100644 index 0000000..bb627f0 --- /dev/null +++ b/tests/parserSpec.js @@ -0,0 +1,148 @@ +'use strict'; + +const assert = require('assert'); +const helpers = require('./../src/helpers'); + +describe('parsing filters to matrix', function() { + + it('makes conjunction', function test(done) { + + const result = helpers.input_to_facet_filters({ + filters: { + tags: ['novel', '90s'] + } + }, { + tags: { + conjunction: true + } + }); + + assert.deepEqual([ [ 'tags', 'novel' ], [ 'tags', '90s' ] ], result); + done(); + }); + + it('makes disjunction', function test(done) { + + const result = helpers.input_to_facet_filters({ + filters: { + tags: ['novel', '90s'] + } + }, { + tags: { + conjunction: false + } + }); + + //assert.deepEqual([ [ [ 'tags', 'novel' ] ], [ [ 'tags', '90s' ] ] ], result); + assert.deepEqual([ [ [ 'tags', 'novel' ], [ 'tags', '90s' ] ] ], result); + done(); + }); + + it('makes conjuction and disjunction', function test(done) { + + const result = helpers.input_to_facet_filters({ + filters: { + tags: ['novel'], + category: ['Western'] + } + }, { + tags: { + conjunction: false + }, + category: { + conjunction: true + } + }); + + assert.deepEqual([ [ [ 'tags', 'novel' ] ], [ 'category', 'Western' ]], result); + done(); + }); + + it('makes disjunction for two different groups', function test(done) { + + const result = helpers.input_to_facet_filters({ + filters: { + tags: ['novel'], + category: ['Western'] + } + }, { + tags: { + conjunction: false + }, + category: { + conjunction: false + } + }); + + assert.deepEqual([ [ [ 'tags', 'novel' ] ], [[ 'category', 'Western' ]]], result); + done(); + }); + + it('makes negative filter', function test(done) { + + const result = helpers.input_to_facet_filters({ + not_filters: { + tags: ['novel', '90s'] + } + }, { + tags: { + conjunction: true + } + }); + + assert.deepEqual([ [ 'tags', '-', 'novel' ], [ 'tags', '-', '90s' ] ], result); + done(); + }); + + it('makes conjuction and disjunction and negative filter', function test(done) { + + const result = helpers.input_to_facet_filters({ + filters: { + tags: ['novel'], + category: ['Western'] + }, + not_filters: { + tags: ['80s'] + } + }, { + tags: { + conjunction: false + }, + category: { + conjunction: true + } + }); + + assert.deepEqual([ [ [ 'tags', 'novel' ] ], [ 'category', 'Western' ], [ 'tags', '-', '80s' ]], result); + done(); + }); +}); + +describe('parsing boolean queries', function() { + + it('normalize query - accepts small letters operator etc remove white spaces', function test(done) { + + done(); + }); + + it('makes conjunction', function test(done) { + + const result = helpers.parse_boolean_query('(tags:novel AND tags:90s)'); + assert.deepEqual([ [ ['tags', 'novel' ], [ 'tags', '90s' ] ] ], result); + done(); + }); + + it('makes disjunction', function test(done) { + + const result = helpers.parse_boolean_query('(tags:novel OR tags:90s)'); + assert.deepEqual([ [ [ 'tags', 'novel' ] ], [ [ 'tags', '90s' ] ] ], result); + done(); + }); + + it('makes conjunction and disjunction', function test(done) { + + const result = helpers.parse_boolean_query('tags:novel OR category:Western'); + assert.deepEqual([ [ [ 'tags', 'novel' ] ], [ [ 'category', 'Western' ] ] ], result); + done(); + }); +}); diff --git a/tests/searchSpec.js b/tests/searchSpec.js index c029448..4e7efbf 100644 --- a/tests/searchSpec.js +++ b/tests/searchSpec.js @@ -85,6 +85,52 @@ describe('search', function() { done(); }); + it('searches with filters query', function test(done) { + + const itemsjs = require('./../index')(items, configuration); + + const result = itemsjs.search({ + filters_query: 'tags:c' + }); + + assert.equal(result.data.items.length, 3); + assert.equal(result.data.aggregations.tags.buckets[0].doc_count, 3); + + done(); + }); + + it('searches with filters query and filters', function test(done) { + + const itemsjs = require('./../index')(items, configuration); + + const result = itemsjs.search({ + filters_query: 'tags:c', + filters: { + tags: ['z'] + } + }); + + assert.equal(result.data.items.length, 1); + assert.equal(result.data.aggregations.tags.buckets[0].doc_count, 1); + + done(); + }); + + + it('searches with filters query not existing value', function test(done) { + + const itemsjs = require('./../index')(items, configuration); + + const result = itemsjs.search({ + filters_query: 'tags:not_existing' + }); + + assert.equal(result.data.items.length, 0); + assert.equal(result.data.aggregations.tags.buckets[0].doc_count, 0); + + done(); + }); + it('searches with filter and query', function test(done) { const itemsjs = require('./../index')(items, configuration); diff --git a/yarn.lock b/yarn.lock index df7c722..5bac5d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1441,6 +1441,11 @@ "resolved" "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz" "version" "5.2.0" +"boolean-parser@^0.0.2": + "integrity" "sha512-e06Mqk6t7DOXaEo3s+RATvv7ZNt5brRQ2os4NUHVkVCzUD0Z7Gw4AL4AFA/gT3WaLhrobmGvRVh1/UuJiY3sKg==" + "resolved" "https://registry.npmjs.org/boolean-parser/-/boolean-parser-0.0.2.tgz" + "version" "0.0.2" + "brace-expansion@^1.1.7": "integrity" "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==" "resolved" "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz"