{"version":3,"file":"instantsearch.production.min.js","sources":["../node_modules/lodash/_baseTimes.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/_baseIsArguments.js","../node_modules/lodash/isArguments.js","../node_modules/lodash/isArray.js","../node_modules/lodash/stubFalse.js","../node_modules/lodash/isBuffer.js","../node_modules/lodash/_isIndex.js","../node_modules/lodash/isLength.js","../node_modules/lodash/_baseIsTypedArray.js","../node_modules/lodash/_baseUnary.js","../node_modules/lodash/_nodeUtil.js","../node_modules/lodash/isTypedArray.js","../node_modules/lodash/_arrayLikeKeys.js","../node_modules/lodash/_isPrototype.js","../node_modules/lodash/_overArg.js","../node_modules/lodash/_nativeKeys.js","../node_modules/lodash/_baseKeys.js","../node_modules/lodash/isObject.js","../node_modules/lodash/isFunction.js","../node_modules/lodash/isArrayLike.js","../node_modules/lodash/keys.js","../node_modules/lodash/_arrayMap.js","../node_modules/lodash/_isMasked.js","../node_modules/lodash/_coreJsData.js","../node_modules/lodash/_toSource.js","../node_modules/lodash/_baseIsNative.js","../node_modules/lodash/_getValue.js","../node_modules/lodash/_getNative.js","../node_modules/lodash/_nativeCreate.js","../node_modules/lodash/_hashClear.js","../node_modules/lodash/_hashDelete.js","../node_modules/lodash/_hashGet.js","../node_modules/lodash/_hashHas.js","../node_modules/lodash/_hashSet.js","../node_modules/lodash/_Hash.js","../node_modules/lodash/_listCacheClear.js","../node_modules/lodash/eq.js","../node_modules/lodash/_assocIndexOf.js","../node_modules/lodash/_listCacheDelete.js","../node_modules/lodash/_listCacheGet.js","../node_modules/lodash/_listCacheHas.js","../node_modules/lodash/_listCacheSet.js","../node_modules/lodash/_ListCache.js","../node_modules/lodash/_Map.js","../node_modules/lodash/_isKeyable.js","../node_modules/lodash/_getMapData.js","../node_modules/lodash/_mapCacheDelete.js","../node_modules/lodash/_mapCacheGet.js","../node_modules/lodash/_mapCacheHas.js","../node_modules/lodash/_mapCacheSet.js","../node_modules/lodash/_MapCache.js","../node_modules/lodash/_mapCacheClear.js","../node_modules/lodash/_setCacheHas.js","../node_modules/lodash/_SetCache.js","../node_modules/lodash/_setCacheAdd.js","../node_modules/lodash/_baseFindIndex.js","../node_modules/lodash/_baseIsNaN.js","../node_modules/lodash/_strictIndexOf.js","../node_modules/lodash/_baseIndexOf.js","../node_modules/lodash/_arrayIncludes.js","../node_modules/lodash/_arrayIncludesWith.js","../node_modules/lodash/_cacheHas.js","../node_modules/lodash/_baseIntersection.js","../node_modules/lodash/identity.js","../node_modules/lodash/_apply.js","../node_modules/lodash/_overRest.js","../node_modules/lodash/constant.js","../node_modules/lodash/_defineProperty.js","../node_modules/lodash/_baseSetToString.js","../node_modules/lodash/_shortOut.js","../node_modules/lodash/_setToString.js","../node_modules/lodash/_baseRest.js","../node_modules/lodash/isArrayLikeObject.js","../node_modules/lodash/_castArrayLikeObject.js","../node_modules/lodash/intersection.js","../node_modules/lodash/_createBaseFor.js","../node_modules/lodash/_baseFor.js","../node_modules/lodash/_baseForOwn.js","../node_modules/lodash/_castFunction.js","../node_modules/lodash/forOwn.js","../node_modules/lodash/_arrayEach.js","../node_modules/lodash/_createBaseEach.js","../node_modules/lodash/_baseEach.js","../node_modules/lodash/forEach.js","../node_modules/lodash/_arrayFilter.js","../node_modules/lodash/_baseFilter.js","../node_modules/lodash/_stackDelete.js","../node_modules/lodash/_stackGet.js","../node_modules/lodash/_stackHas.js","../node_modules/lodash/_stackSet.js","../node_modules/lodash/_Stack.js","../node_modules/lodash/_stackClear.js","../node_modules/lodash/_arraySome.js","../node_modules/lodash/_equalArrays.js","../node_modules/lodash/_Uint8Array.js","../node_modules/lodash/_mapToArray.js","../node_modules/lodash/_setToArray.js","../node_modules/lodash/_equalByTag.js","../node_modules/lodash/_arrayPush.js","../node_modules/lodash/_baseGetAllKeys.js","../node_modules/lodash/stubArray.js","../node_modules/lodash/_getSymbols.js","../node_modules/lodash/_getAllKeys.js","../node_modules/lodash/_equalObjects.js","../node_modules/lodash/_DataView.js","../node_modules/lodash/_Promise.js","../node_modules/lodash/_Set.js","../node_modules/lodash/_WeakMap.js","../node_modules/lodash/_getTag.js","../node_modules/lodash/_baseIsEqualDeep.js","../node_modules/lodash/_baseIsEqual.js","../node_modules/lodash/_baseIsMatch.js","../node_modules/lodash/_isStrictComparable.js","../node_modules/lodash/_getMatchData.js","../node_modules/lodash/_matchesStrictComparable.js","../node_modules/lodash/_baseMatches.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/_isKey.js","../node_modules/lodash/memoize.js","../node_modules/lodash/_memoizeCapped.js","../node_modules/lodash/_stringToPath.js","../node_modules/lodash/_baseToString.js","../node_modules/lodash/toString.js","../node_modules/lodash/_castPath.js","../node_modules/lodash/_toKey.js","../node_modules/lodash/_baseGet.js","../node_modules/lodash/get.js","../node_modules/lodash/_baseHasIn.js","../node_modules/lodash/_hasPath.js","../node_modules/lodash/hasIn.js","../node_modules/lodash/_baseMatchesProperty.js","../node_modules/lodash/_baseProperty.js","../node_modules/lodash/_basePropertyDeep.js","../node_modules/lodash/property.js","../node_modules/lodash/_baseIteratee.js","../node_modules/lodash/filter.js","../node_modules/lodash/_baseMap.js","../node_modules/lodash/map.js","../node_modules/lodash/_arrayReduce.js","../node_modules/lodash/_baseReduce.js","../node_modules/lodash/reduce.js","../node_modules/lodash/_baseAssignValue.js","../node_modules/lodash/_assignValue.js","../node_modules/lodash/_copyObject.js","../node_modules/lodash/_baseAssign.js","../node_modules/lodash/_nativeKeysIn.js","../node_modules/lodash/_baseKeysIn.js","../node_modules/lodash/keysIn.js","../node_modules/lodash/_baseAssignIn.js","../node_modules/lodash/_cloneBuffer.js","../node_modules/lodash/_copyArray.js","../node_modules/lodash/_copySymbols.js","../node_modules/lodash/_getPrototype.js","../node_modules/lodash/_getSymbolsIn.js","../node_modules/lodash/_copySymbolsIn.js","../node_modules/lodash/_getAllKeysIn.js","../node_modules/lodash/_initCloneArray.js","../node_modules/lodash/_cloneArrayBuffer.js","../node_modules/lodash/_cloneDataView.js","../node_modules/lodash/_cloneRegExp.js","../node_modules/lodash/_cloneSymbol.js","../node_modules/lodash/_cloneTypedArray.js","../node_modules/lodash/_initCloneByTag.js","../node_modules/lodash/_baseCreate.js","../node_modules/lodash/_initCloneObject.js","../node_modules/lodash/_baseIsMap.js","../node_modules/lodash/isMap.js","../node_modules/lodash/_baseIsSet.js","../node_modules/lodash/isSet.js","../node_modules/lodash/_baseClone.js","../node_modules/lodash/last.js","../node_modules/lodash/_baseSlice.js","../node_modules/lodash/_parent.js","../node_modules/lodash/_baseUnset.js","../node_modules/lodash/isPlainObject.js","../node_modules/lodash/_customOmitClone.js","../node_modules/lodash/_isFlattenable.js","../node_modules/lodash/_baseFlatten.js","../node_modules/lodash/flatten.js","../node_modules/lodash/_flatRest.js","../node_modules/lodash/omit.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/toFinite.js","../node_modules/lodash/toInteger.js","../node_modules/lodash/indexOf.js","../node_modules/lodash/isNumber.js","../node_modules/lodash/isNaN.js","../node_modules/lodash/isEmpty.js","../node_modules/lodash/isEqual.js","../node_modules/lodash/isUndefined.js","../node_modules/lodash/isString.js","../node_modules/lodash/_createFind.js","../node_modules/lodash/findIndex.js","../node_modules/lodash/find.js","../node_modules/lodash/_castSlice.js","../node_modules/lodash/_charsEndIndex.js","../node_modules/lodash/_charsStartIndex.js","../node_modules/lodash/_asciiToArray.js","../node_modules/lodash/_hasUnicode.js","../node_modules/lodash/_unicodeToArray.js","../node_modules/lodash/_stringToArray.js","../node_modules/lodash/trim.js","../node_modules/lodash/_isIterateeCall.js","../node_modules/lodash/defaults.js","../node_modules/lodash/_assignMergeValue.js","../node_modules/lodash/_safeGet.js","../node_modules/lodash/toPlainObject.js","../node_modules/lodash/_baseMergeDeep.js","../node_modules/lodash/_baseMerge.js","../node_modules/lodash/_createAssigner.js","../node_modules/lodash/merge.js","../node_modules/algoliasearch-helper/src/functions/valToNumber.js","../node_modules/algoliasearch-helper/src/SearchParameters/filterState.js","../node_modules/algoliasearch-helper/src/SearchParameters/RefinementList.js","../node_modules/algoliasearch-helper/src/SearchParameters/index.js","../node_modules/lodash/compact.js","../node_modules/lodash/_baseSum.js","../node_modules/lodash/sumBy.js","../node_modules/lodash/_baseValues.js","../node_modules/lodash/values.js","../node_modules/lodash/includes.js","../node_modules/lodash/_baseSortBy.js","../node_modules/lodash/_compareAscending.js","../node_modules/lodash/_compareMultiple.js","../node_modules/lodash/_baseOrderBy.js","../node_modules/lodash/orderBy.js","../node_modules/lodash/_metaMap.js","../node_modules/lodash/_baseSetData.js","../node_modules/lodash/_createCtor.js","../node_modules/lodash/_createBind.js","../node_modules/lodash/_composeArgs.js","../node_modules/lodash/_composeArgsRight.js","../node_modules/lodash/_countHolders.js","../node_modules/lodash/_baseLodash.js","../node_modules/lodash/_LazyWrapper.js","../node_modules/lodash/noop.js","../node_modules/lodash/_getData.js","../node_modules/lodash/_realNames.js","../node_modules/lodash/_getFuncName.js","../node_modules/lodash/_LodashWrapper.js","../node_modules/lodash/_wrapperClone.js","../node_modules/lodash/wrapperLodash.js","../node_modules/lodash/_isLaziable.js","../node_modules/lodash/_setData.js","../node_modules/lodash/_getWrapDetails.js","../node_modules/lodash/_insertWrapDetails.js","../node_modules/lodash/_updateWrapDetails.js","../node_modules/lodash/_setWrapToString.js","../node_modules/lodash/_createRecurry.js","../node_modules/lodash/_getHolder.js","../node_modules/lodash/_reorder.js","../node_modules/lodash/_replaceHolders.js","../node_modules/lodash/_createHybrid.js","../node_modules/lodash/_createCurry.js","../node_modules/lodash/_createPartial.js","../node_modules/lodash/_mergeData.js","../node_modules/lodash/_createWrap.js","../node_modules/lodash/partial.js","../node_modules/lodash/partialRight.js","../node_modules/lodash/_baseClamp.js","../node_modules/algoliasearch-helper/src/functions/formatSort.js","../node_modules/lodash/startsWith.js","../node_modules/lodash/_baseSet.js","../node_modules/lodash/_basePickBy.js","../node_modules/lodash/pickBy.js","../node_modules/algoliasearch-helper/src/SearchResults/generate-hierarchical-tree.js","../node_modules/algoliasearch-helper/src/SearchResults/index.js","../node_modules/events/events.js","../node_modules/algoliasearch-helper/src/functions/inherits.js","../node_modules/algoliasearch-helper/src/DerivedHelper/index.js","../node_modules/algoliasearch-helper/src/requestBuilder.js","../node_modules/lodash/_baseInverter.js","../node_modules/qs/lib/utils.js","../node_modules/qs/lib/stringify.js","../node_modules/qs/lib/parse.js","../node_modules/lodash/_createInverter.js","../node_modules/lodash/invert.js","../node_modules/algoliasearch-helper/src/SearchParameters/shortener.js","../node_modules/qs/lib/formats.js","../node_modules/qs/lib/index.js","../node_modules/lodash/bind.js","../node_modules/lodash/_basePick.js","../node_modules/lodash/pick.js","../node_modules/lodash/mapKeys.js","../node_modules/lodash/mapValues.js","../node_modules/algoliasearch-helper/src/url.js","../node_modules/algoliasearch-helper/src/version.js","../node_modules/algoliasearch-helper/src/algoliasearch.helper.js","../node_modules/algoliasearch-helper/index.js","../src/lib/utils/getContainerNode.ts","../src/lib/utils/isDomElement.ts","../src/lib/utils/isSpecialClick.ts","../src/lib/utils/uniq.ts","../src/lib/utils/prepareTemplateProps.js","../node_modules/hogan.js/lib/compiler.js","../node_modules/hogan.js/lib/template.js","../node_modules/hogan.js/lib/hogan.js","../src/lib/utils/renderTemplate.js","../src/lib/utils/find.ts","../src/lib/utils/unescapeRefinement.ts","../src/lib/utils/getRefinements.ts","../src/lib/utils/clearRefinements.js","../src/lib/utils/escapeRefinement.ts","../src/lib/utils/checkRendering.ts","../src/lib/utils/getPropertyByPath.ts","../src/lib/utils/noop.ts","../src/lib/utils/isFiniteNumber.ts","../src/lib/utils/isPlainObject.ts","../src/lib/utils/range.ts","../src/lib/utils/isEqual.ts","../src/lib/utils/escape.ts","../src/lib/utils/documentation.ts","../src/lib/utils/logger.js","../src/lib/utils/geo-search.js","../src/lib/utils/hits-absolute-position.ts","../src/lib/utils/hits-query-id.ts","../src/lib/RoutingManager.ts","../src/lib/stateMappings/simple.ts","../src/lib/routers/history.ts","../src/lib/escape-highlight.ts","../src/lib/suit.ts","../src/helpers/highlight.ts","../src/helpers/snippet.ts","../src/lib/InstantSearch.js","../src/lib/version.ts","../src/lib/createHelpers.ts","../src/lib/utils/mergeDeep.ts","../src/connectors/clear-refinements/connectClearRefinements.js","../src/connectors/current-refinements/connectCurrentRefinements.js","../src/connectors/hierarchical-menu/connectHierarchicalMenu.js","../src/connectors/hits/connectHits.js","../src/lib/insights/client.ts","../node_modules/react-is/cjs/react-is.production.min.js","../node_modules/react-is/index.js","../node_modules/object-assign/index.js","../node_modules/prop-types/factoryWithTypeCheckers.js","../node_modules/prop-types/factoryWithThrowingShims.js","../node_modules/prop-types/index.js","../node_modules/prop-types/lib/ReactPropTypesSecret.js","../node_modules/preact/dist/preact.mjs","../node_modules/preact-compat/dist/preact-compat.es.js","../src/lib/insights/listener.tsx","../src/helpers/insights.ts","../src/connectors/hits/connectHitsWithInsights.ts","../src/connectors/hits-per-page/connectHitsPerPage.js","../src/connectors/infinite-hits/connectInfiniteHits.ts","../src/connectors/infinite-hits/connectInfiniteHitsWithInsights.ts","../src/connectors/menu/connectMenu.js","../src/connectors/numeric-menu/connectNumericMenu.js","../src/connectors/pagination/Paginator.js","../src/connectors/pagination/connectPagination.js","../src/connectors/range/connectRange.js","../src/connectors/refinement-list/connectRefinementList.js","../src/connectors/search-box/connectSearchBox.js","../src/connectors/sort-by/connectSortBy.js","../src/connectors/rating-menu/connectRatingMenu.js","../src/connectors/stats/connectStats.js","../src/connectors/toggleRefinement/connectToggleRefinement.js","../src/connectors/breadcrumb/connectBreadcrumb.js","../src/connectors/geo-search/connectGeoSearch.js","../src/connectors/powered-by/connectPoweredBy.js","../src/connectors/configure/connectConfigure.js","../src/connectors/autocomplete/connectAutocomplete.js","../src/connectors/query-rules/connectQueryRules.ts","../src/lib/voiceSearchHelper/index.ts","../src/connectors/voice-search/connectVoiceSearch.ts","../node_modules/classnames/index.js","../src/components/Template/Template.js","../src/components/ClearRefinements/ClearRefinements.js","../src/widgets/clear-refinements/defaultTemplates.js","../src/widgets/clear-refinements/clear-refinements.js","../src/components/CurrentRefinements/CurrentRefinements.js","../src/lib/utils/capitalize.ts","../src/widgets/current-refinements/current-refinements.js","../src/components/GeoSearchControls/GeoSearchButton.js","../src/components/GeoSearchControls/GeoSearchToggle.js","../src/components/GeoSearchControls/GeoSearchControls.js","../src/widgets/geo-search/GeoSearchRenderer.js","../src/widgets/geo-search/defaultTemplates.js","../src/widgets/geo-search/geo-search.js","../src/components/RefinementList/RefinementListItem.js","../src/components/SearchBox/SearchBox.js","../src/components/RefinementList/RefinementList.js","../src/widgets/hierarchical-menu/defaultTemplates.js","../src/widgets/hierarchical-menu/hierarchical-menu.js","../src/components/Hits/Hits.js","../src/widgets/hits/defaultTemplates.js","../src/widgets/hits/hits.js","../src/components/Selector/Selector.js","../src/widgets/hits-per-page/hits-per-page.js","../src/components/InfiniteHits/InfiniteHits.tsx","../src/widgets/infinite-hits/defaultTemplates.ts","../src/widgets/infinite-hits/infinite-hits.tsx","../src/widgets/menu/defaultTemplates.js","../src/widgets/menu/menu.js","../src/widgets/refinement-list/defaultTemplates.js","../src/widgets/refinement-list/refinement-list.js","../src/widgets/numeric-menu/defaultTemplates.js","../src/widgets/numeric-menu/numeric-menu.js","../src/components/Pagination/PaginationLink.js","../src/components/Pagination/Pagination.js","../src/widgets/pagination/pagination.js","../src/components/RangeInput/RangeInput.js","../src/widgets/range-input/range-input.js","../src/widgets/search-box/defaultTemplates.js","../src/widgets/search-box/search-box.js","../node_modules/preact-rheostat/lib/constants/SliderConstants.js","../node_modules/preact-rheostat/lib/algorithms/linear.js","../src/components/Slider/Pit.js","../node_modules/preact-rheostat/lib/Slider.js","../src/components/Slider/Slider.js","../src/widgets/range-slider/range-slider.js","../src/widgets/sort-by/sort-by.js","../src/widgets/rating-menu/defaultTemplates.js","../src/widgets/rating-menu/rating-menu.js","../src/components/Stats/Stats.js","../src/widgets/stats/defaultTemplates.js","../src/widgets/stats/stats.js","../src/components/ToggleRefinement/ToggleRefinement.js","../src/widgets/toggleRefinement/defaultTemplates.js","../src/widgets/toggleRefinement/toggleRefinement.js","../src/widgets/analytics/analytics.ts","../src/components/Breadcrumb/Breadcrumb.js","../src/widgets/breadcrumb/defaultTemplates.js","../src/widgets/breadcrumb/breadcrumb.js","../src/components/MenuSelect/MenuSelect.js","../src/widgets/menu-select/defaultTemplates.js","../src/widgets/menu-select/menu-select.js","../src/components/PoweredBy/PoweredBy.tsx","../src/widgets/powered-by/powered-by.js","../src/components/Panel/Panel.js","../src/widgets/panel/panel.js","../src/components/VoiceSearch/VoiceSearch.tsx","../src/widgets/voice-search/voice-search.tsx","../src/components/QueryRuleCustomData/QueryRuleCustomData.tsx","../src/widgets/query-rule-custom-data/query-rule-custom-data.tsx","../src/lib/main.js","../src/widgets/voice-search/defaultTemplates.js","../src/widgets/query-rule-context/query-rule-context.tsx","../src/widgets/configure/configure.js","../src/widgets/geo-search/createHTMLMarker.js"],"sourcesContent":["/**\n * The base implementation of `_.times` without support for iteratee shorthands\n * or max array length checks.\n *\n * @private\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the array of results.\n */\nfunction baseTimes(n, iteratee) {\n var index = -1,\n result = Array(n);\n\n while (++index < n) {\n result[index] = iteratee(index);\n }\n return result;\n}\n\nmodule.exports = baseTimes;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]';\n\n/**\n * The base implementation of `_.isArguments`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n */\nfunction baseIsArguments(value) {\n return isObjectLike(value) && baseGetTag(value) == argsTag;\n}\n\nmodule.exports = baseIsArguments;\n","var baseIsArguments = require('./_baseIsArguments'),\n isObjectLike = require('./isObjectLike');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&\n !propertyIsEnumerable.call(value, 'callee');\n};\n\nmodule.exports = isArguments;\n","/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\nmodule.exports = isArray;\n","/**\n * This method returns `false`.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {boolean} Returns `false`.\n * @example\n *\n * _.times(2, _.stubFalse);\n * // => [false, false]\n */\nfunction stubFalse() {\n return false;\n}\n\nmodule.exports = stubFalse;\n","var root = require('./_root'),\n stubFalse = require('./stubFalse');\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;\n\n/**\n * Checks if `value` is a buffer.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n * @example\n *\n * _.isBuffer(new Buffer(2));\n * // => true\n *\n * _.isBuffer(new Uint8Array(2));\n * // => false\n */\nvar isBuffer = nativeIsBuffer || stubFalse;\n\nmodule.exports = isBuffer;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** Used to detect unsigned integer values. */\nvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\n/**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\nfunction isIndex(value, length) {\n var type = typeof value;\n length = length == null ? MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type == 'number' ||\n (type != 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n}\n\nmodule.exports = isIndex;\n","/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\nmodule.exports = isLength;\n","var baseGetTag = require('./_baseGetTag'),\n isLength = require('./isLength'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values of typed arrays. */\nvar typedArrayTags = {};\ntypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\ntypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\ntypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\ntypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\ntypedArrayTags[uint32Tag] = true;\ntypedArrayTags[argsTag] = typedArrayTags[arrayTag] =\ntypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\ntypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\ntypedArrayTags[errorTag] = typedArrayTags[funcTag] =\ntypedArrayTags[mapTag] = typedArrayTags[numberTag] =\ntypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\ntypedArrayTags[setTag] = typedArrayTags[stringTag] =\ntypedArrayTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.isTypedArray` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n */\nfunction baseIsTypedArray(value) {\n return isObjectLike(value) &&\n isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n}\n\nmodule.exports = baseIsTypedArray;\n","/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\nmodule.exports = baseUnary;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Detect free variable `process` from Node.js. */\nvar freeProcess = moduleExports && freeGlobal.process;\n\n/** Used to access faster Node.js helpers. */\nvar nodeUtil = (function() {\n try {\n // Use `util.types` for Node.js 10+.\n var types = freeModule && freeModule.require && freeModule.require('util').types;\n\n if (types) {\n return types;\n }\n\n // Legacy `process.binding('util')` for Node.js < 10.\n return freeProcess && freeProcess.binding && freeProcess.binding('util');\n } catch (e) {}\n}());\n\nmodule.exports = nodeUtil;\n","var baseIsTypedArray = require('./_baseIsTypedArray'),\n baseUnary = require('./_baseUnary'),\n nodeUtil = require('./_nodeUtil');\n\n/* Node.js helper references. */\nvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\n/**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\nvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\nmodule.exports = isTypedArray;\n","var baseTimes = require('./_baseTimes'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isBuffer = require('./isBuffer'),\n isIndex = require('./_isIndex'),\n isTypedArray = require('./isTypedArray');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an array of the enumerable property names of the array-like `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @param {boolean} inherited Specify returning inherited property names.\n * @returns {Array} Returns the array of property names.\n */\nfunction arrayLikeKeys(value, inherited) {\n var isArr = isArray(value),\n isArg = !isArr && isArguments(value),\n isBuff = !isArr && !isArg && isBuffer(value),\n isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n skipIndexes = isArr || isArg || isBuff || isType,\n result = skipIndexes ? baseTimes(value.length, String) : [],\n length = result.length;\n\n for (var key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key == 'length' ||\n // Node.js 0.10 has enumerable non-index properties on buffers.\n (isBuff && (key == 'offset' || key == 'parent')) ||\n // PhantomJS 2 has enumerable non-index properties on typed arrays.\n (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n // Skip index properties.\n isIndex(key, length)\n ))) {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = arrayLikeKeys;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Checks if `value` is likely a prototype object.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n */\nfunction isPrototype(value) {\n var Ctor = value && value.constructor,\n proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;\n\n return value === proto;\n}\n\nmodule.exports = isPrototype;\n","/**\n * Creates a unary function that invokes `func` with its argument transformed.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {Function} transform The argument transform.\n * @returns {Function} Returns the new function.\n */\nfunction overArg(func, transform) {\n return function(arg) {\n return func(transform(arg));\n };\n}\n\nmodule.exports = overArg;\n","var overArg = require('./_overArg');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeKeys = overArg(Object.keys, Object);\n\nmodule.exports = nativeKeys;\n","var isPrototype = require('./_isPrototype'),\n nativeKeys = require('./_nativeKeys');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeys(object) {\n if (!isPrototype(object)) {\n return nativeKeys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = baseKeys;\n","/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","var baseGetTag = require('./_baseGetTag'),\n isObject = require('./isObject');\n\n/** `Object#toString` result references. */\nvar asyncTag = '[object AsyncFunction]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n proxyTag = '[object Proxy]';\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n if (!isObject(value)) {\n return false;\n }\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 9 which returns 'object' for typed arrays and other constructors.\n var tag = baseGetTag(value);\n return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n}\n\nmodule.exports = isFunction;\n","var isFunction = require('./isFunction'),\n isLength = require('./isLength');\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\nmodule.exports = isArrayLike;\n","var arrayLikeKeys = require('./_arrayLikeKeys'),\n baseKeys = require('./_baseKeys'),\n isArrayLike = require('./isArrayLike');\n\n/**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\nfunction keys(object) {\n return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n}\n\nmodule.exports = keys;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nmodule.exports = arrayMap;\n","var coreJsData = require('./_coreJsData');\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\nmodule.exports = isMasked;\n","var root = require('./_root');\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\nmodule.exports = coreJsData;\n","/** Used for built-in method references. */\nvar funcProto = Function.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to convert.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\nmodule.exports = toSource;\n","var isFunction = require('./isFunction'),\n isMasked = require('./_isMasked'),\n isObject = require('./isObject'),\n toSource = require('./_toSource');\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = isFunction(value) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\nmodule.exports = baseIsNative;\n","/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\nmodule.exports = getValue;\n","var baseIsNative = require('./_baseIsNative'),\n getValue = require('./_getValue');\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\nmodule.exports = getNative;\n","var getNative = require('./_getNative');\n\n/* Built-in method references that are verified to be native. */\nvar nativeCreate = getNative(Object, 'create');\n\nmodule.exports = nativeCreate;\n","var nativeCreate = require('./_nativeCreate');\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n this.size = 0;\n}\n\nmodule.exports = hashClear;\n","/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n var result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n}\n\nmodule.exports = hashDelete;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\nmodule.exports = hashGet;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);\n}\n\nmodule.exports = hashHas;\n","var nativeCreate = require('./_nativeCreate');\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\nmodule.exports = hashSet;\n","var hashClear = require('./_hashClear'),\n hashDelete = require('./_hashDelete'),\n hashGet = require('./_hashGet'),\n hashHas = require('./_hashHas'),\n hashSet = require('./_hashSet');\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\nmodule.exports = Hash;\n","/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n this.size = 0;\n}\n\nmodule.exports = listCacheClear;\n","/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\nmodule.exports = eq;\n","var eq = require('./eq');\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\nmodule.exports = assocIndexOf;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype;\n\n/** Built-in value references. */\nvar splice = arrayProto.splice;\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n --this.size;\n return true;\n}\n\nmodule.exports = listCacheDelete;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\nmodule.exports = listCacheGet;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\nmodule.exports = listCacheHas;\n","var assocIndexOf = require('./_assocIndexOf');\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\nmodule.exports = listCacheSet;\n","var listCacheClear = require('./_listCacheClear'),\n listCacheDelete = require('./_listCacheDelete'),\n listCacheGet = require('./_listCacheGet'),\n listCacheHas = require('./_listCacheHas'),\n listCacheSet = require('./_listCacheSet');\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\nmodule.exports = ListCache;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map');\n\nmodule.exports = Map;\n","/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\nmodule.exports = isKeyable;\n","var isKeyable = require('./_isKeyable');\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\nmodule.exports = getMapData;\n","var getMapData = require('./_getMapData');\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n var result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n}\n\nmodule.exports = mapCacheDelete;\n","var getMapData = require('./_getMapData');\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\nmodule.exports = mapCacheGet;\n","var getMapData = require('./_getMapData');\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\nmodule.exports = mapCacheHas;\n","var getMapData = require('./_getMapData');\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n var data = getMapData(this, key),\n size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n}\n\nmodule.exports = mapCacheSet;\n","var mapCacheClear = require('./_mapCacheClear'),\n mapCacheDelete = require('./_mapCacheDelete'),\n mapCacheGet = require('./_mapCacheGet'),\n mapCacheHas = require('./_mapCacheHas'),\n mapCacheSet = require('./_mapCacheSet');\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\nmodule.exports = MapCache;\n","var Hash = require('./_Hash'),\n ListCache = require('./_ListCache'),\n Map = require('./_Map');\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\nmodule.exports = mapCacheClear;\n","/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\nmodule.exports = setCacheHas;\n","var MapCache = require('./_MapCache'),\n setCacheAdd = require('./_setCacheAdd'),\n setCacheHas = require('./_setCacheHas');\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\nmodule.exports = SetCache;\n","/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\nmodule.exports = setCacheAdd;\n","/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\nmodule.exports = baseFindIndex;\n","/**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\nfunction baseIsNaN(value) {\n return value !== value;\n}\n\nmodule.exports = baseIsNaN;\n","/**\n * A specialized version of `_.indexOf` which performs strict equality\n * comparisons of values, i.e. `===`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction strictIndexOf(array, value, fromIndex) {\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n}\n\nmodule.exports = strictIndexOf;\n","var baseFindIndex = require('./_baseFindIndex'),\n baseIsNaN = require('./_baseIsNaN'),\n strictIndexOf = require('./_strictIndexOf');\n\n/**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseIndexOf(array, value, fromIndex) {\n return value === value\n ? strictIndexOf(array, value, fromIndex)\n : baseFindIndex(array, baseIsNaN, fromIndex);\n}\n\nmodule.exports = baseIndexOf;\n","var baseIndexOf = require('./_baseIndexOf');\n\n/**\n * A specialized version of `_.includes` for arrays without support for\n * specifying an index to search from.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludes(array, value) {\n var length = array == null ? 0 : array.length;\n return !!length && baseIndexOf(array, value, 0) > -1;\n}\n\nmodule.exports = arrayIncludes;\n","/**\n * This function is like `arrayIncludes` except that it accepts a comparator.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludesWith(array, value, comparator) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (comparator(value, array[index])) {\n return true;\n }\n }\n return false;\n}\n\nmodule.exports = arrayIncludesWith;\n","/**\n * Checks if a `cache` value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\nmodule.exports = cacheHas;\n","var SetCache = require('./_SetCache'),\n arrayIncludes = require('./_arrayIncludes'),\n arrayIncludesWith = require('./_arrayIncludesWith'),\n arrayMap = require('./_arrayMap'),\n baseUnary = require('./_baseUnary'),\n cacheHas = require('./_cacheHas');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMin = Math.min;\n\n/**\n * The base implementation of methods like `_.intersection`, without support\n * for iteratee shorthands, that accepts an array of arrays to inspect.\n *\n * @private\n * @param {Array} arrays The arrays to inspect.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of shared values.\n */\nfunction baseIntersection(arrays, iteratee, comparator) {\n var includes = comparator ? arrayIncludesWith : arrayIncludes,\n length = arrays[0].length,\n othLength = arrays.length,\n othIndex = othLength,\n caches = Array(othLength),\n maxLength = Infinity,\n result = [];\n\n while (othIndex--) {\n var array = arrays[othIndex];\n if (othIndex && iteratee) {\n array = arrayMap(array, baseUnary(iteratee));\n }\n maxLength = nativeMin(array.length, maxLength);\n caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))\n ? new SetCache(othIndex && array)\n : undefined;\n }\n array = arrays[0];\n\n var index = -1,\n seen = caches[0];\n\n outer:\n while (++index < length && result.length < maxLength) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (!(seen\n ? cacheHas(seen, computed)\n : includes(result, computed, comparator)\n )) {\n othIndex = othLength;\n while (--othIndex) {\n var cache = caches[othIndex];\n if (!(cache\n ? cacheHas(cache, computed)\n : includes(arrays[othIndex], computed, comparator))\n ) {\n continue outer;\n }\n }\n if (seen) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n}\n\nmodule.exports = baseIntersection;\n","/**\n * This method returns the first argument it receives.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Util\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'a': 1 };\n *\n * console.log(_.identity(object) === object);\n * // => true\n */\nfunction identity(value) {\n return value;\n}\n\nmodule.exports = identity;\n","/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\nmodule.exports = apply;\n","var apply = require('./_apply');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * A specialized version of `baseRest` which transforms the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @param {Function} transform The rest array transform.\n * @returns {Function} Returns the new function.\n */\nfunction overRest(func, start, transform) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = transform(array);\n return apply(func, this, otherArgs);\n };\n}\n\nmodule.exports = overRest;\n","/**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new constant function.\n * @example\n *\n * var objects = _.times(2, _.constant({ 'a': 1 }));\n *\n * console.log(objects);\n * // => [{ 'a': 1 }, { 'a': 1 }]\n *\n * console.log(objects[0] === objects[1]);\n * // => true\n */\nfunction constant(value) {\n return function() {\n return value;\n };\n}\n\nmodule.exports = constant;\n","var getNative = require('./_getNative');\n\nvar defineProperty = (function() {\n try {\n var func = getNative(Object, 'defineProperty');\n func({}, '', {});\n return func;\n } catch (e) {}\n}());\n\nmodule.exports = defineProperty;\n","var constant = require('./constant'),\n defineProperty = require('./_defineProperty'),\n identity = require('./identity');\n\n/**\n * The base implementation of `setToString` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar baseSetToString = !defineProperty ? identity : function(func, string) {\n return defineProperty(func, 'toString', {\n 'configurable': true,\n 'enumerable': false,\n 'value': constant(string),\n 'writable': true\n });\n};\n\nmodule.exports = baseSetToString;\n","/** Used to detect hot functions by number of calls within a span of milliseconds. */\nvar HOT_COUNT = 800,\n HOT_SPAN = 16;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeNow = Date.now;\n\n/**\n * Creates a function that'll short out and invoke `identity` instead\n * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`\n * milliseconds.\n *\n * @private\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new shortable function.\n */\nfunction shortOut(func) {\n var count = 0,\n lastCalled = 0;\n\n return function() {\n var stamp = nativeNow(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return arguments[0];\n }\n } else {\n count = 0;\n }\n return func.apply(undefined, arguments);\n };\n}\n\nmodule.exports = shortOut;\n","var baseSetToString = require('./_baseSetToString'),\n shortOut = require('./_shortOut');\n\n/**\n * Sets the `toString` method of `func` to return `string`.\n *\n * @private\n * @param {Function} func The function to modify.\n * @param {Function} string The `toString` result.\n * @returns {Function} Returns `func`.\n */\nvar setToString = shortOut(baseSetToString);\n\nmodule.exports = setToString;\n","var identity = require('./identity'),\n overRest = require('./_overRest'),\n setToString = require('./_setToString');\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n return setToString(overRest(func, start, identity), func + '');\n}\n\nmodule.exports = baseRest;\n","var isArrayLike = require('./isArrayLike'),\n isObjectLike = require('./isObjectLike');\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\nmodule.exports = isArrayLikeObject;\n","var isArrayLikeObject = require('./isArrayLikeObject');\n\n/**\n * Casts `value` to an empty array if it's not an array like object.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Array|Object} Returns the cast array-like object.\n */\nfunction castArrayLikeObject(value) {\n return isArrayLikeObject(value) ? value : [];\n}\n\nmodule.exports = castArrayLikeObject;\n","var arrayMap = require('./_arrayMap'),\n baseIntersection = require('./_baseIntersection'),\n baseRest = require('./_baseRest'),\n castArrayLikeObject = require('./_castArrayLikeObject');\n\n/**\n * Creates an array of unique values that are included in all given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order and references of result values are\n * determined by the first array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of intersecting values.\n * @example\n *\n * _.intersection([2, 1], [2, 3]);\n * // => [2]\n */\nvar intersection = baseRest(function(arrays) {\n var mapped = arrayMap(arrays, castArrayLikeObject);\n return (mapped.length && mapped[0] === arrays[0])\n ? baseIntersection(mapped)\n : [];\n});\n\nmodule.exports = intersection;\n","/**\n * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var index = -1,\n iterable = Object(object),\n props = keysFunc(object),\n length = props.length;\n\n while (length--) {\n var key = props[fromRight ? length : ++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n}\n\nmodule.exports = createBaseFor;\n","var createBaseFor = require('./_createBaseFor');\n\n/**\n * The base implementation of `baseForOwn` which iterates over `object`\n * properties returned by `keysFunc` and invokes `iteratee` for each property.\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\nvar baseFor = createBaseFor();\n\nmodule.exports = baseFor;\n","var baseFor = require('./_baseFor'),\n keys = require('./keys');\n\n/**\n * The base implementation of `_.forOwn` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\nfunction baseForOwn(object, iteratee) {\n return object && baseFor(object, iteratee, keys);\n}\n\nmodule.exports = baseForOwn;\n","var identity = require('./identity');\n\n/**\n * Casts `value` to `identity` if it's not a function.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {Function} Returns cast function.\n */\nfunction castFunction(value) {\n return typeof value == 'function' ? value : identity;\n}\n\nmodule.exports = castFunction;\n","var baseForOwn = require('./_baseForOwn'),\n castFunction = require('./_castFunction');\n\n/**\n * Iterates over own enumerable string keyed properties of an object and\n * invokes `iteratee` for each property. The iteratee is invoked with three\n * arguments: (value, key, object). Iteratee functions may exit iteration\n * early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @since 0.3.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns `object`.\n * @see _.forOwnRight\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\nfunction forOwn(object, iteratee) {\n return object && baseForOwn(object, castFunction(iteratee));\n}\n\nmodule.exports = forOwn;\n","/**\n * A specialized version of `_.forEach` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\nfunction arrayEach(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (iteratee(array[index], index, array) === false) {\n break;\n }\n }\n return array;\n}\n\nmodule.exports = arrayEach;\n","var isArrayLike = require('./isArrayLike');\n\n/**\n * Creates a `baseEach` or `baseEachRight` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\nfunction createBaseEach(eachFunc, fromRight) {\n return function(collection, iteratee) {\n if (collection == null) {\n return collection;\n }\n if (!isArrayLike(collection)) {\n return eachFunc(collection, iteratee);\n }\n var length = collection.length,\n index = fromRight ? length : -1,\n iterable = Object(collection);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n };\n}\n\nmodule.exports = createBaseEach;\n","var baseForOwn = require('./_baseForOwn'),\n createBaseEach = require('./_createBaseEach');\n\n/**\n * The base implementation of `_.forEach` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n */\nvar baseEach = createBaseEach(baseForOwn);\n\nmodule.exports = baseEach;\n","var arrayEach = require('./_arrayEach'),\n baseEach = require('./_baseEach'),\n castFunction = require('./_castFunction'),\n isArray = require('./isArray');\n\n/**\n * Iterates over elements of `collection` and invokes `iteratee` for each element.\n * The iteratee is invoked with three arguments: (value, index|key, collection).\n * Iteratee functions may exit iteration early by explicitly returning `false`.\n *\n * **Note:** As with other \"Collections\" methods, objects with a \"length\"\n * property are iterated like arrays. To avoid this behavior use `_.forIn`\n * or `_.forOwn` for object iteration.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @alias each\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array|Object} Returns `collection`.\n * @see _.forEachRight\n * @example\n *\n * _.forEach([1, 2], function(value) {\n * console.log(value);\n * });\n * // => Logs `1` then `2`.\n *\n * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {\n * console.log(key);\n * });\n * // => Logs 'a' then 'b' (iteration order is not guaranteed).\n */\nfunction forEach(collection, iteratee) {\n var func = isArray(collection) ? arrayEach : baseEach;\n return func(collection, castFunction(iteratee));\n}\n\nmodule.exports = forEach;\n","/**\n * A specialized version of `_.filter` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction arrayFilter(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = arrayFilter;\n","var baseEach = require('./_baseEach');\n\n/**\n * The base implementation of `_.filter` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\nfunction baseFilter(collection, predicate) {\n var result = [];\n baseEach(collection, function(value, index, collection) {\n if (predicate(value, index, collection)) {\n result.push(value);\n }\n });\n return result;\n}\n\nmodule.exports = baseFilter;\n","/**\n * Removes `key` and its value from the stack.\n *\n * @private\n * @name delete\n * @memberOf Stack\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction stackDelete(key) {\n var data = this.__data__,\n result = data['delete'](key);\n\n this.size = data.size;\n return result;\n}\n\nmodule.exports = stackDelete;\n","/**\n * Gets the stack value for `key`.\n *\n * @private\n * @name get\n * @memberOf Stack\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction stackGet(key) {\n return this.__data__.get(key);\n}\n\nmodule.exports = stackGet;\n","/**\n * Checks if a stack value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Stack\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction stackHas(key) {\n return this.__data__.has(key);\n}\n\nmodule.exports = stackHas;\n","var ListCache = require('./_ListCache'),\n Map = require('./_Map'),\n MapCache = require('./_MapCache');\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/**\n * Sets the stack `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Stack\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the stack cache instance.\n */\nfunction stackSet(key, value) {\n var data = this.__data__;\n if (data instanceof ListCache) {\n var pairs = data.__data__;\n if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n}\n\nmodule.exports = stackSet;\n","var ListCache = require('./_ListCache'),\n stackClear = require('./_stackClear'),\n stackDelete = require('./_stackDelete'),\n stackGet = require('./_stackGet'),\n stackHas = require('./_stackHas'),\n stackSet = require('./_stackSet');\n\n/**\n * Creates a stack cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Stack(entries) {\n var data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n}\n\n// Add methods to `Stack`.\nStack.prototype.clear = stackClear;\nStack.prototype['delete'] = stackDelete;\nStack.prototype.get = stackGet;\nStack.prototype.has = stackHas;\nStack.prototype.set = stackSet;\n\nmodule.exports = Stack;\n","var ListCache = require('./_ListCache');\n\n/**\n * Removes all key-value entries from the stack.\n *\n * @private\n * @name clear\n * @memberOf Stack\n */\nfunction stackClear() {\n this.__data__ = new ListCache;\n this.size = 0;\n}\n\nmodule.exports = stackClear;\n","/**\n * A specialized version of `_.some` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\nfunction arraySome(array, predicate) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n}\n\nmodule.exports = arraySome;\n","var SetCache = require('./_SetCache'),\n arraySome = require('./_arraySome'),\n cacheHas = require('./_cacheHas');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `array` and `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\nfunction equalArrays(array, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(array);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var index = -1,\n result = true,\n seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, arrValue, index, other, array, stack)\n : customizer(arrValue, othValue, index, array, other, stack);\n }\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (seen) {\n if (!arraySome(other, function(othValue, othIndex) {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, bitmask, customizer, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n}\n\nmodule.exports = equalArrays;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Uint8Array = root.Uint8Array;\n\nmodule.exports = Uint8Array;\n","/**\n * Converts `map` to its key-value pairs.\n *\n * @private\n * @param {Object} map The map to convert.\n * @returns {Array} Returns the key-value pairs.\n */\nfunction mapToArray(map) {\n var index = -1,\n result = Array(map.size);\n\n map.forEach(function(value, key) {\n result[++index] = [key, value];\n });\n return result;\n}\n\nmodule.exports = mapToArray;\n","/**\n * Converts `set` to an array of its values.\n *\n * @private\n * @param {Object} set The set to convert.\n * @returns {Array} Returns the values.\n */\nfunction setToArray(set) {\n var index = -1,\n result = Array(set.size);\n\n set.forEach(function(value) {\n result[++index] = value;\n });\n return result;\n}\n\nmodule.exports = setToArray;\n","var Symbol = require('./_Symbol'),\n Uint8Array = require('./_Uint8Array'),\n eq = require('./eq'),\n equalArrays = require('./_equalArrays'),\n mapToArray = require('./_mapToArray'),\n setToArray = require('./_setToArray');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]';\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n\n case arrayBufferTag:\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other))) {\n return false;\n }\n return true;\n\n case boolTag:\n case dateTag:\n case numberTag:\n // Coerce booleans to `1` or `0` and dates to milliseconds.\n // Invalid dates are coerced to `NaN`.\n return eq(+object, +other);\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings, primitives and objects,\n // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring\n // for more details.\n return object == (other + '');\n\n case mapTag:\n var convert = mapToArray;\n\n case setTag:\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG;\n convert || (convert = setToArray);\n\n if (object.size != other.size && !isPartial) {\n return false;\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n bitmask |= COMPARE_UNORDERED_FLAG;\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);\n stack['delete'](object);\n return result;\n\n case symbolTag:\n if (symbolValueOf) {\n return symbolValueOf.call(object) == symbolValueOf.call(other);\n }\n }\n return false;\n}\n\nmodule.exports = equalByTag;\n","/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\nmodule.exports = arrayPush;\n","var arrayPush = require('./_arrayPush'),\n isArray = require('./isArray');\n\n/**\n * The base implementation of `getAllKeys` and `getAllKeysIn` which uses\n * `keysFunc` and `symbolsFunc` to get the enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @param {Function} symbolsFunc The function to get the symbols of `object`.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction baseGetAllKeys(object, keysFunc, symbolsFunc) {\n var result = keysFunc(object);\n return isArray(object) ? result : arrayPush(result, symbolsFunc(object));\n}\n\nmodule.exports = baseGetAllKeys;\n","/**\n * This method returns a new empty array.\n *\n * @static\n * @memberOf _\n * @since 4.13.0\n * @category Util\n * @returns {Array} Returns the new empty array.\n * @example\n *\n * var arrays = _.times(2, _.stubArray);\n *\n * console.log(arrays);\n * // => [[], []]\n *\n * console.log(arrays[0] === arrays[1]);\n * // => false\n */\nfunction stubArray() {\n return [];\n}\n\nmodule.exports = stubArray;\n","var arrayFilter = require('./_arrayFilter'),\n stubArray = require('./stubArray');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Built-in value references. */\nvar propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbols = !nativeGetSymbols ? stubArray : function(object) {\n if (object == null) {\n return [];\n }\n object = Object(object);\n return arrayFilter(nativeGetSymbols(object), function(symbol) {\n return propertyIsEnumerable.call(object, symbol);\n });\n};\n\nmodule.exports = getSymbols;\n","var baseGetAllKeys = require('./_baseGetAllKeys'),\n getSymbols = require('./_getSymbols'),\n keys = require('./keys');\n\n/**\n * Creates an array of own enumerable property names and symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeys(object) {\n return baseGetAllKeys(object, keys, getSymbols);\n}\n\nmodule.exports = getAllKeys;\n","var getAllKeys = require('./_getAllKeys');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} stack Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction equalObjects(object, other, bitmask, customizer, equalFunc, stack) {\n var isPartial = bitmask & COMPARE_PARTIAL_FLAG,\n objProps = getAllKeys(object),\n objLength = objProps.length,\n othProps = getAllKeys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isPartial) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n // Assume cyclic values are equal.\n var stacked = stack.get(object);\n if (stacked && stack.get(other)) {\n return stacked == other;\n }\n var result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n var skipCtor = isPartial;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key];\n\n if (customizer) {\n var compared = isPartial\n ? customizer(othValue, objValue, key, other, object, stack)\n : customizer(objValue, othValue, key, object, other, stack);\n }\n // Recursively compare objects (susceptible to call stack limits).\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (result && !skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n}\n\nmodule.exports = equalObjects;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar DataView = getNative(root, 'DataView');\n\nmodule.exports = DataView;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Promise = getNative(root, 'Promise');\n\nmodule.exports = Promise;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar Set = getNative(root, 'Set');\n\nmodule.exports = Set;\n","var getNative = require('./_getNative'),\n root = require('./_root');\n\n/* Built-in method references that are verified to be native. */\nvar WeakMap = getNative(root, 'WeakMap');\n\nmodule.exports = WeakMap;\n","var DataView = require('./_DataView'),\n Map = require('./_Map'),\n Promise = require('./_Promise'),\n Set = require('./_Set'),\n WeakMap = require('./_WeakMap'),\n baseGetTag = require('./_baseGetTag'),\n toSource = require('./_toSource');\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n objectTag = '[object Object]',\n promiseTag = '[object Promise]',\n setTag = '[object Set]',\n weakMapTag = '[object WeakMap]';\n\nvar dataViewTag = '[object DataView]';\n\n/** Used to detect maps, sets, and weakmaps. */\nvar dataViewCtorString = toSource(DataView),\n mapCtorString = toSource(Map),\n promiseCtorString = toSource(Promise),\n setCtorString = toSource(Set),\n weakMapCtorString = toSource(WeakMap);\n\n/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nvar getTag = baseGetTag;\n\n// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.\nif ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||\n (Map && getTag(new Map) != mapTag) ||\n (Promise && getTag(Promise.resolve()) != promiseTag) ||\n (Set && getTag(new Set) != setTag) ||\n (WeakMap && getTag(new WeakMap) != weakMapTag)) {\n getTag = function(value) {\n var result = baseGetTag(value),\n Ctor = result == objectTag ? value.constructor : undefined,\n ctorString = Ctor ? toSource(Ctor) : '';\n\n if (ctorString) {\n switch (ctorString) {\n case dataViewCtorString: return dataViewTag;\n case mapCtorString: return mapTag;\n case promiseCtorString: return promiseTag;\n case setCtorString: return setTag;\n case weakMapCtorString: return weakMapTag;\n }\n }\n return result;\n };\n}\n\nmodule.exports = getTag;\n","var Stack = require('./_Stack'),\n equalArrays = require('./_equalArrays'),\n equalByTag = require('./_equalByTag'),\n equalObjects = require('./_equalObjects'),\n getTag = require('./_getTag'),\n isArray = require('./isArray'),\n isBuffer = require('./isBuffer'),\n isTypedArray = require('./isTypedArray');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.\n * @param {Function} customizer The function to customize comparisons.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Object} [stack] Tracks traversed `object` and `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\nfunction baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = objIsArr ? arrayTag : getTag(object),\n othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && isBuffer(object)) {\n if (!isBuffer(other)) {\n return false;\n }\n objIsArr = true;\n objIsObj = false;\n }\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)\n : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);\n }\n if (!(bitmask & COMPARE_PARTIAL_FLAG)) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n var objUnwrapped = objIsWrapped ? object.value() : object,\n othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);\n }\n }\n if (!isSameTag) {\n return false;\n }\n stack || (stack = new Stack);\n return equalObjects(object, other, bitmask, customizer, equalFunc, stack);\n}\n\nmodule.exports = baseIsEqualDeep;\n","var baseIsEqualDeep = require('./_baseIsEqualDeep'),\n isObjectLike = require('./isObjectLike');\n\n/**\n * The base implementation of `_.isEqual` which supports partial comparisons\n * and tracks traversed objects.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Unordered comparison\n * 2 - Partial comparison\n * @param {Function} [customizer] The function to customize comparisons.\n * @param {Object} [stack] Tracks traversed `value` and `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\nfunction baseIsEqual(value, other, bitmask, customizer, stack) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);\n}\n\nmodule.exports = baseIsEqual;\n","var Stack = require('./_Stack'),\n baseIsEqual = require('./_baseIsEqual');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * The base implementation of `_.isMatch` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Array} matchData The property names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparisons.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\nfunction baseIsMatch(object, source, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = Object(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var stack = new Stack;\n if (customizer) {\n var result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n}\n\nmodule.exports = baseIsMatch;\n","var isObject = require('./isObject');\n\n/**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\nfunction isStrictComparable(value) {\n return value === value && !isObject(value);\n}\n\nmodule.exports = isStrictComparable;\n","var isStrictComparable = require('./_isStrictComparable'),\n keys = require('./keys');\n\n/**\n * Gets the property names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\nfunction getMatchData(object) {\n var result = keys(object),\n length = result.length;\n\n while (length--) {\n var key = result[length],\n value = object[key];\n\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n}\n\nmodule.exports = getMatchData;\n","/**\n * A specialized version of `matchesProperty` for source values suitable\n * for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction matchesStrictComparable(key, srcValue) {\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n}\n\nmodule.exports = matchesStrictComparable;\n","var baseIsMatch = require('./_baseIsMatch'),\n getMatchData = require('./_getMatchData'),\n matchesStrictComparable = require('./_matchesStrictComparable');\n\n/**\n * The base implementation of `_.matches` which doesn't clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return function(object) {\n return object === source || baseIsMatch(object, source, matchData);\n };\n}\n\nmodule.exports = baseMatches;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used to match property names within property paths. */\nvar reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/;\n\n/**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\nfunction isKey(value, object) {\n if (isArray(value)) {\n return false;\n }\n var type = typeof value;\n if (type == 'number' || type == 'symbol' || type == 'boolean' ||\n value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n}\n\nmodule.exports = isKey;\n","var MapCache = require('./_MapCache');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided, it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is used as the map cache key. The `func`\n * is invoked with the `this` binding of the memoized function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the\n * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `clear`, `delete`, `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoized function.\n * @example\n *\n * var object = { 'a': 1, 'b': 2 };\n * var other = { 'c': 3, 'd': 4 };\n *\n * var values = _.memoize(_.values);\n * values(object);\n * // => [1, 2]\n *\n * values(other);\n * // => [3, 4]\n *\n * object.a = 2;\n * values(object);\n * // => [1, 2]\n *\n * // Modify the result cache.\n * values.cache.set(object, ['a', 'b']);\n * values(object);\n * // => ['a', 'b']\n *\n * // Replace `_.memoize.Cache`.\n * _.memoize.Cache = WeakMap;\n */\nfunction memoize(func, resolver) {\n if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result) || cache;\n return result;\n };\n memoized.cache = new (memoize.Cache || MapCache);\n return memoized;\n}\n\n// Expose `MapCache`.\nmemoize.Cache = MapCache;\n\nmodule.exports = memoize;\n","var memoize = require('./memoize');\n\n/** Used as the maximum memoize cache size. */\nvar MAX_MEMOIZE_SIZE = 500;\n\n/**\n * A specialized version of `_.memoize` which clears the memoized function's\n * cache when it exceeds `MAX_MEMOIZE_SIZE`.\n *\n * @private\n * @param {Function} func The function to have its output memoized.\n * @returns {Function} Returns the new memoized function.\n */\nfunction memoizeCapped(func) {\n var result = memoize(func, function(key) {\n if (cache.size === MAX_MEMOIZE_SIZE) {\n cache.clear();\n }\n return key;\n });\n\n var cache = result.cache;\n return result;\n}\n\nmodule.exports = memoizeCapped;\n","var memoizeCapped = require('./_memoizeCapped');\n\n/** Used to match property names within property paths. */\nvar rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g;\n\n/** Used to match backslashes in property paths. */\nvar reEscapeChar = /\\\\(\\\\)?/g;\n\n/**\n * Converts `string` to a property path array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the property path array.\n */\nvar stringToPath = memoizeCapped(function(string) {\n var result = [];\n if (string.charCodeAt(0) === 46 /* . */) {\n result.push('');\n }\n string.replace(rePropName, function(match, number, quote, subString) {\n result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n});\n\nmodule.exports = stringToPath;\n","var Symbol = require('./_Symbol'),\n arrayMap = require('./_arrayMap'),\n isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = baseToString;\n","var baseToString = require('./_baseToString');\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nmodule.exports = toString;\n","var isArray = require('./isArray'),\n isKey = require('./_isKey'),\n stringToPath = require('./_stringToPath'),\n toString = require('./toString');\n\n/**\n * Casts `value` to a path array if it's not one.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {Object} [object] The object to query keys on.\n * @returns {Array} Returns the cast property path array.\n */\nfunction castPath(value, object) {\n if (isArray(value)) {\n return value;\n }\n return isKey(value, object) ? [value] : stringToPath(toString(value));\n}\n\nmodule.exports = castPath;\n","var isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nfunction toKey(value) {\n if (typeof value == 'string' || isSymbol(value)) {\n return value;\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = toKey;\n","var castPath = require('./_castPath'),\n toKey = require('./_toKey');\n\n/**\n * The base implementation of `_.get` without support for default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @returns {*} Returns the resolved value.\n */\nfunction baseGet(object, path) {\n path = castPath(path, object);\n\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index++])];\n }\n return (index && index == length) ? object : undefined;\n}\n\nmodule.exports = baseGet;\n","var baseGet = require('./_baseGet');\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is\n * `undefined`, the `defaultValue` is returned in its place.\n *\n * @static\n * @memberOf _\n * @since 3.7.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned for `undefined` resolved values.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\nfunction get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, path);\n return result === undefined ? defaultValue : result;\n}\n\nmodule.exports = get;\n","/**\n * The base implementation of `_.hasIn` without support for deep paths.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {Array|string} key The key to check.\n * @returns {boolean} Returns `true` if `key` exists, else `false`.\n */\nfunction baseHasIn(object, key) {\n return object != null && key in Object(object);\n}\n\nmodule.exports = baseHasIn;\n","var castPath = require('./_castPath'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isIndex = require('./_isIndex'),\n isLength = require('./isLength'),\n toKey = require('./_toKey');\n\n/**\n * Checks if `path` exists on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @param {Function} hasFunc The function to check properties.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n */\nfunction hasPath(object, path, hasFunc) {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (isArray(object) || isArguments(object));\n}\n\nmodule.exports = hasPath;\n","var baseHasIn = require('./_baseHasIn'),\n hasPath = require('./_hasPath');\n\n/**\n * Checks if `path` is a direct or inherited property of `object`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` exists, else `false`.\n * @example\n *\n * var object = _.create({ 'a': _.create({ 'b': 2 }) });\n *\n * _.hasIn(object, 'a');\n * // => true\n *\n * _.hasIn(object, 'a.b');\n * // => true\n *\n * _.hasIn(object, ['a', 'b']);\n * // => true\n *\n * _.hasIn(object, 'b');\n * // => false\n */\nfunction hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n}\n\nmodule.exports = hasIn;\n","var baseIsEqual = require('./_baseIsEqual'),\n get = require('./get'),\n hasIn = require('./hasIn'),\n isKey = require('./_isKey'),\n isStrictComparable = require('./_isStrictComparable'),\n matchesStrictComparable = require('./_matchesStrictComparable'),\n toKey = require('./_toKey');\n\n/** Used to compose bitmasks for value comparisons. */\nvar COMPARE_PARTIAL_FLAG = 1,\n COMPARE_UNORDERED_FLAG = 2;\n\n/**\n * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new spec function.\n */\nfunction baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return function(object) {\n var objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);\n };\n}\n\nmodule.exports = baseMatchesProperty;\n","/**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n}\n\nmodule.exports = baseProperty;\n","var baseGet = require('./_baseGet');\n\n/**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n */\nfunction basePropertyDeep(path) {\n return function(object) {\n return baseGet(object, path);\n };\n}\n\nmodule.exports = basePropertyDeep;\n","var baseProperty = require('./_baseProperty'),\n basePropertyDeep = require('./_basePropertyDeep'),\n isKey = require('./_isKey'),\n toKey = require('./_toKey');\n\n/**\n * Creates a function that returns the value at `path` of a given object.\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Util\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new accessor function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': 2 } },\n * { 'a': { 'b': 1 } }\n * ];\n *\n * _.map(objects, _.property('a.b'));\n * // => [2, 1]\n *\n * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');\n * // => [1, 2]\n */\nfunction property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n}\n\nmodule.exports = property;\n","var baseMatches = require('./_baseMatches'),\n baseMatchesProperty = require('./_baseMatchesProperty'),\n identity = require('./identity'),\n isArray = require('./isArray'),\n property = require('./property');\n\n/**\n * The base implementation of `_.iteratee`.\n *\n * @private\n * @param {*} [value=_.identity] The value to convert to an iteratee.\n * @returns {Function} Returns the iteratee.\n */\nfunction baseIteratee(value) {\n // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.\n // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return identity;\n }\n if (typeof value == 'object') {\n return isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n}\n\nmodule.exports = baseIteratee;\n","var arrayFilter = require('./_arrayFilter'),\n baseFilter = require('./_baseFilter'),\n baseIteratee = require('./_baseIteratee'),\n isArray = require('./isArray');\n\n/**\n * Iterates over elements of `collection`, returning an array of all elements\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * **Note:** Unlike `_.remove`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n * @see _.reject\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * _.filter(users, function(o) { return !o.active; });\n * // => objects for ['fred']\n *\n * // The `_.matches` iteratee shorthand.\n * _.filter(users, { 'age': 36, 'active': true });\n * // => objects for ['barney']\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.filter(users, ['active', false]);\n * // => objects for ['fred']\n *\n * // The `_.property` iteratee shorthand.\n * _.filter(users, 'active');\n * // => objects for ['barney']\n */\nfunction filter(collection, predicate) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n return func(collection, baseIteratee(predicate, 3));\n}\n\nmodule.exports = filter;\n","var baseEach = require('./_baseEach'),\n isArrayLike = require('./isArrayLike');\n\n/**\n * The base implementation of `_.map` without support for iteratee shorthands.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction baseMap(collection, iteratee) {\n var index = -1,\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value, key, collection) {\n result[++index] = iteratee(value, key, collection);\n });\n return result;\n}\n\nmodule.exports = baseMap;\n","var arrayMap = require('./_arrayMap'),\n baseIteratee = require('./_baseIteratee'),\n baseMap = require('./_baseMap'),\n isArray = require('./isArray');\n\n/**\n * Creates an array of values by running each element in `collection` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.\n *\n * The guarded methods are:\n * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,\n * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,\n * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,\n * `template`, `trim`, `trimEnd`, `trimStart`, and `words`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * _.map([4, 8], square);\n * // => [16, 64]\n *\n * _.map({ 'a': 4, 'b': 8 }, square);\n * // => [16, 64] (iteration order is not guaranteed)\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * // The `_.property` iteratee shorthand.\n * _.map(users, 'user');\n * // => ['barney', 'fred']\n */\nfunction map(collection, iteratee) {\n var func = isArray(collection) ? arrayMap : baseMap;\n return func(collection, baseIteratee(iteratee, 3));\n}\n\nmodule.exports = map;\n","/**\n * A specialized version of `_.reduce` for arrays without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initAccum] Specify using the first element of `array` as\n * the initial value.\n * @returns {*} Returns the accumulated value.\n */\nfunction arrayReduce(array, iteratee, accumulator, initAccum) {\n var index = -1,\n length = array == null ? 0 : array.length;\n\n if (initAccum && length) {\n accumulator = array[++index];\n }\n while (++index < length) {\n accumulator = iteratee(accumulator, array[index], index, array);\n }\n return accumulator;\n}\n\nmodule.exports = arrayReduce;\n","/**\n * The base implementation of `_.reduce` and `_.reduceRight`, without support\n * for iteratee shorthands, which iterates over `collection` using `eachFunc`.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} accumulator The initial value.\n * @param {boolean} initAccum Specify using the first or last element of\n * `collection` as the initial value.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the accumulated value.\n */\nfunction baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {\n eachFunc(collection, function(value, index, collection) {\n accumulator = initAccum\n ? (initAccum = false, value)\n : iteratee(accumulator, value, index, collection);\n });\n return accumulator;\n}\n\nmodule.exports = baseReduce;\n","var arrayReduce = require('./_arrayReduce'),\n baseEach = require('./_baseEach'),\n baseIteratee = require('./_baseIteratee'),\n baseReduce = require('./_baseReduce'),\n isArray = require('./isArray');\n\n/**\n * Reduces `collection` to a value which is the accumulated result of running\n * each element in `collection` thru `iteratee`, where each successive\n * invocation is supplied the return value of the previous. If `accumulator`\n * is not given, the first element of `collection` is used as the initial\n * value. The iteratee is invoked with four arguments:\n * (accumulator, value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.reduce`, `_.reduceRight`, and `_.transform`.\n *\n * The guarded methods are:\n * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,\n * and `sortBy`\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @returns {*} Returns the accumulated value.\n * @see _.reduceRight\n * @example\n *\n * _.reduce([1, 2], function(sum, n) {\n * return sum + n;\n * }, 0);\n * // => 3\n *\n * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {\n * (result[value] || (result[value] = [])).push(key);\n * return result;\n * }, {});\n * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)\n */\nfunction reduce(collection, iteratee, accumulator) {\n var func = isArray(collection) ? arrayReduce : baseReduce,\n initAccum = arguments.length < 3;\n\n return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach);\n}\n\nmodule.exports = reduce;\n","var defineProperty = require('./_defineProperty');\n\n/**\n * The base implementation of `assignValue` and `assignMergeValue` without\n * value checks.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction baseAssignValue(object, key, value) {\n if (key == '__proto__' && defineProperty) {\n defineProperty(object, key, {\n 'configurable': true,\n 'enumerable': true,\n 'value': value,\n 'writable': true\n });\n } else {\n object[key] = value;\n }\n}\n\nmodule.exports = baseAssignValue;\n","var baseAssignValue = require('./_baseAssignValue'),\n eq = require('./eq');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Assigns `value` to `key` of `object` if the existing value is not equivalent\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignValue(object, key, value) {\n var objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n}\n\nmodule.exports = assignValue;\n","var assignValue = require('./_assignValue'),\n baseAssignValue = require('./_baseAssignValue');\n\n/**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property identifiers to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @param {Function} [customizer] The function to customize copied values.\n * @returns {Object} Returns `object`.\n */\nfunction copyObject(source, props, object, customizer) {\n var isNew = !object;\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n\n var newValue = customizer\n ? customizer(object[key], source[key], key, object, source)\n : undefined;\n\n if (newValue === undefined) {\n newValue = source[key];\n }\n if (isNew) {\n baseAssignValue(object, key, newValue);\n } else {\n assignValue(object, key, newValue);\n }\n }\n return object;\n}\n\nmodule.exports = copyObject;\n","var copyObject = require('./_copyObject'),\n keys = require('./keys');\n\n/**\n * The base implementation of `_.assign` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\nfunction baseAssign(object, source) {\n return object && copyObject(source, keys(source), object);\n}\n\nmodule.exports = baseAssign;\n","/**\n * This function is like\n * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n * except that it includes inherited enumerable properties.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction nativeKeysIn(object) {\n var result = [];\n if (object != null) {\n for (var key in Object(object)) {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = nativeKeysIn;\n","var isObject = require('./isObject'),\n isPrototype = require('./_isPrototype'),\n nativeKeysIn = require('./_nativeKeysIn');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\nfunction baseKeysIn(object) {\n if (!isObject(object)) {\n return nativeKeysIn(object);\n }\n var isProto = isPrototype(object),\n result = [];\n\n for (var key in object) {\n if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n}\n\nmodule.exports = baseKeysIn;\n","var arrayLikeKeys = require('./_arrayLikeKeys'),\n baseKeysIn = require('./_baseKeysIn'),\n isArrayLike = require('./isArrayLike');\n\n/**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\nfunction keysIn(object) {\n return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);\n}\n\nmodule.exports = keysIn;\n","var copyObject = require('./_copyObject'),\n keysIn = require('./keysIn');\n\n/**\n * The base implementation of `_.assignIn` without support for multiple sources\n * or `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\nfunction baseAssignIn(object, source) {\n return object && copyObject(source, keysIn(source), object);\n}\n\nmodule.exports = baseAssignIn;\n","var root = require('./_root');\n\n/** Detect free variable `exports`. */\nvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\n/** Detect free variable `module`. */\nvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\n/** Detect the popular CommonJS extension `module.exports`. */\nvar moduleExports = freeModule && freeModule.exports === freeExports;\n\n/** Built-in value references. */\nvar Buffer = moduleExports ? root.Buffer : undefined,\n allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;\n\n/**\n * Creates a clone of `buffer`.\n *\n * @private\n * @param {Buffer} buffer The buffer to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Buffer} Returns the cloned buffer.\n */\nfunction cloneBuffer(buffer, isDeep) {\n if (isDeep) {\n return buffer.slice();\n }\n var length = buffer.length,\n result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);\n\n buffer.copy(result);\n return result;\n}\n\nmodule.exports = cloneBuffer;\n","/**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\nfunction copyArray(source, array) {\n var index = -1,\n length = source.length;\n\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n}\n\nmodule.exports = copyArray;\n","var copyObject = require('./_copyObject'),\n getSymbols = require('./_getSymbols');\n\n/**\n * Copies own symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\nfunction copySymbols(source, object) {\n return copyObject(source, getSymbols(source), object);\n}\n\nmodule.exports = copySymbols;\n","var overArg = require('./_overArg');\n\n/** Built-in value references. */\nvar getPrototype = overArg(Object.getPrototypeOf, Object);\n\nmodule.exports = getPrototype;\n","var arrayPush = require('./_arrayPush'),\n getPrototype = require('./_getPrototype'),\n getSymbols = require('./_getSymbols'),\n stubArray = require('./stubArray');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeGetSymbols = Object.getOwnPropertySymbols;\n\n/**\n * Creates an array of the own and inherited enumerable symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of symbols.\n */\nvar getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {\n var result = [];\n while (object) {\n arrayPush(result, getSymbols(object));\n object = getPrototype(object);\n }\n return result;\n};\n\nmodule.exports = getSymbolsIn;\n","var copyObject = require('./_copyObject'),\n getSymbolsIn = require('./_getSymbolsIn');\n\n/**\n * Copies own and inherited symbols of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy symbols from.\n * @param {Object} [object={}] The object to copy symbols to.\n * @returns {Object} Returns `object`.\n */\nfunction copySymbolsIn(source, object) {\n return copyObject(source, getSymbolsIn(source), object);\n}\n\nmodule.exports = copySymbolsIn;\n","var baseGetAllKeys = require('./_baseGetAllKeys'),\n getSymbolsIn = require('./_getSymbolsIn'),\n keysIn = require('./keysIn');\n\n/**\n * Creates an array of own and inherited enumerable property names and\n * symbols of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names and symbols.\n */\nfunction getAllKeysIn(object) {\n return baseGetAllKeys(object, keysIn, getSymbolsIn);\n}\n\nmodule.exports = getAllKeysIn;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Initializes an array clone.\n *\n * @private\n * @param {Array} array The array to clone.\n * @returns {Array} Returns the initialized clone.\n */\nfunction initCloneArray(array) {\n var length = array.length,\n result = new array.constructor(length);\n\n // Add properties assigned by `RegExp#exec`.\n if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n result.index = array.index;\n result.input = array.input;\n }\n return result;\n}\n\nmodule.exports = initCloneArray;\n","var Uint8Array = require('./_Uint8Array');\n\n/**\n * Creates a clone of `arrayBuffer`.\n *\n * @private\n * @param {ArrayBuffer} arrayBuffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\nfunction cloneArrayBuffer(arrayBuffer) {\n var result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n}\n\nmodule.exports = cloneArrayBuffer;\n","var cloneArrayBuffer = require('./_cloneArrayBuffer');\n\n/**\n * Creates a clone of `dataView`.\n *\n * @private\n * @param {Object} dataView The data view to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned data view.\n */\nfunction cloneDataView(dataView, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;\n return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);\n}\n\nmodule.exports = cloneDataView;\n","/** Used to match `RegExp` flags from their coerced string values. */\nvar reFlags = /\\w*$/;\n\n/**\n * Creates a clone of `regexp`.\n *\n * @private\n * @param {Object} regexp The regexp to clone.\n * @returns {Object} Returns the cloned regexp.\n */\nfunction cloneRegExp(regexp) {\n var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));\n result.lastIndex = regexp.lastIndex;\n return result;\n}\n\nmodule.exports = cloneRegExp;\n","var Symbol = require('./_Symbol');\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;\n\n/**\n * Creates a clone of the `symbol` object.\n *\n * @private\n * @param {Object} symbol The symbol object to clone.\n * @returns {Object} Returns the cloned symbol object.\n */\nfunction cloneSymbol(symbol) {\n return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};\n}\n\nmodule.exports = cloneSymbol;\n","var cloneArrayBuffer = require('./_cloneArrayBuffer');\n\n/**\n * Creates a clone of `typedArray`.\n *\n * @private\n * @param {Object} typedArray The typed array to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the cloned typed array.\n */\nfunction cloneTypedArray(typedArray, isDeep) {\n var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n}\n\nmodule.exports = cloneTypedArray;\n","var cloneArrayBuffer = require('./_cloneArrayBuffer'),\n cloneDataView = require('./_cloneDataView'),\n cloneRegExp = require('./_cloneRegExp'),\n cloneSymbol = require('./_cloneSymbol'),\n cloneTypedArray = require('./_cloneTypedArray');\n\n/** `Object#toString` result references. */\nvar boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/**\n * Initializes an object clone based on its `toStringTag`.\n *\n * **Note:** This function only supports cloning values with tags of\n * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.\n *\n * @private\n * @param {Object} object The object to clone.\n * @param {string} tag The `toStringTag` of the object to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the initialized clone.\n */\nfunction initCloneByTag(object, tag, isDeep) {\n var Ctor = object.constructor;\n switch (tag) {\n case arrayBufferTag:\n return cloneArrayBuffer(object);\n\n case boolTag:\n case dateTag:\n return new Ctor(+object);\n\n case dataViewTag:\n return cloneDataView(object, isDeep);\n\n case float32Tag: case float64Tag:\n case int8Tag: case int16Tag: case int32Tag:\n case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:\n return cloneTypedArray(object, isDeep);\n\n case mapTag:\n return new Ctor;\n\n case numberTag:\n case stringTag:\n return new Ctor(object);\n\n case regexpTag:\n return cloneRegExp(object);\n\n case setTag:\n return new Ctor;\n\n case symbolTag:\n return cloneSymbol(object);\n }\n}\n\nmodule.exports = initCloneByTag;\n","var isObject = require('./isObject');\n\n/** Built-in value references. */\nvar objectCreate = Object.create;\n\n/**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} proto The object to inherit from.\n * @returns {Object} Returns the new object.\n */\nvar baseCreate = (function() {\n function object() {}\n return function(proto) {\n if (!isObject(proto)) {\n return {};\n }\n if (objectCreate) {\n return objectCreate(proto);\n }\n object.prototype = proto;\n var result = new object;\n object.prototype = undefined;\n return result;\n };\n}());\n\nmodule.exports = baseCreate;\n","var baseCreate = require('./_baseCreate'),\n getPrototype = require('./_getPrototype'),\n isPrototype = require('./_isPrototype');\n\n/**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\nfunction initCloneObject(object) {\n return (typeof object.constructor == 'function' && !isPrototype(object))\n ? baseCreate(getPrototype(object))\n : {};\n}\n\nmodule.exports = initCloneObject;\n","var getTag = require('./_getTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]';\n\n/**\n * The base implementation of `_.isMap` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n */\nfunction baseIsMap(value) {\n return isObjectLike(value) && getTag(value) == mapTag;\n}\n\nmodule.exports = baseIsMap;\n","var baseIsMap = require('./_baseIsMap'),\n baseUnary = require('./_baseUnary'),\n nodeUtil = require('./_nodeUtil');\n\n/* Node.js helper references. */\nvar nodeIsMap = nodeUtil && nodeUtil.isMap;\n\n/**\n * Checks if `value` is classified as a `Map` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a map, else `false`.\n * @example\n *\n * _.isMap(new Map);\n * // => true\n *\n * _.isMap(new WeakMap);\n * // => false\n */\nvar isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;\n\nmodule.exports = isMap;\n","var getTag = require('./_getTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar setTag = '[object Set]';\n\n/**\n * The base implementation of `_.isSet` without Node.js optimizations.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n */\nfunction baseIsSet(value) {\n return isObjectLike(value) && getTag(value) == setTag;\n}\n\nmodule.exports = baseIsSet;\n","var baseIsSet = require('./_baseIsSet'),\n baseUnary = require('./_baseUnary'),\n nodeUtil = require('./_nodeUtil');\n\n/* Node.js helper references. */\nvar nodeIsSet = nodeUtil && nodeUtil.isSet;\n\n/**\n * Checks if `value` is classified as a `Set` object.\n *\n * @static\n * @memberOf _\n * @since 4.3.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a set, else `false`.\n * @example\n *\n * _.isSet(new Set);\n * // => true\n *\n * _.isSet(new WeakSet);\n * // => false\n */\nvar isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;\n\nmodule.exports = isSet;\n","var Stack = require('./_Stack'),\n arrayEach = require('./_arrayEach'),\n assignValue = require('./_assignValue'),\n baseAssign = require('./_baseAssign'),\n baseAssignIn = require('./_baseAssignIn'),\n cloneBuffer = require('./_cloneBuffer'),\n copyArray = require('./_copyArray'),\n copySymbols = require('./_copySymbols'),\n copySymbolsIn = require('./_copySymbolsIn'),\n getAllKeys = require('./_getAllKeys'),\n getAllKeysIn = require('./_getAllKeysIn'),\n getTag = require('./_getTag'),\n initCloneArray = require('./_initCloneArray'),\n initCloneByTag = require('./_initCloneByTag'),\n initCloneObject = require('./_initCloneObject'),\n isArray = require('./isArray'),\n isBuffer = require('./isBuffer'),\n isMap = require('./isMap'),\n isObject = require('./isObject'),\n isSet = require('./isSet'),\n keys = require('./keys');\n\n/** Used to compose bitmasks for cloning. */\nvar CLONE_DEEP_FLAG = 1,\n CLONE_FLAT_FLAG = 2,\n CLONE_SYMBOLS_FLAG = 4;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n symbolTag = '[object Symbol]',\n weakMapTag = '[object WeakMap]';\n\nvar arrayBufferTag = '[object ArrayBuffer]',\n dataViewTag = '[object DataView]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n/** Used to identify `toStringTag` values supported by `_.clone`. */\nvar cloneableTags = {};\ncloneableTags[argsTag] = cloneableTags[arrayTag] =\ncloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =\ncloneableTags[boolTag] = cloneableTags[dateTag] =\ncloneableTags[float32Tag] = cloneableTags[float64Tag] =\ncloneableTags[int8Tag] = cloneableTags[int16Tag] =\ncloneableTags[int32Tag] = cloneableTags[mapTag] =\ncloneableTags[numberTag] = cloneableTags[objectTag] =\ncloneableTags[regexpTag] = cloneableTags[setTag] =\ncloneableTags[stringTag] = cloneableTags[symbolTag] =\ncloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =\ncloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;\ncloneableTags[errorTag] = cloneableTags[funcTag] =\ncloneableTags[weakMapTag] = false;\n\n/**\n * The base implementation of `_.clone` and `_.cloneDeep` which tracks\n * traversed objects.\n *\n * @private\n * @param {*} value The value to clone.\n * @param {boolean} bitmask The bitmask flags.\n * 1 - Deep clone\n * 2 - Flatten inherited properties\n * 4 - Clone symbols\n * @param {Function} [customizer] The function to customize cloning.\n * @param {string} [key] The key of `value`.\n * @param {Object} [object] The parent object of `value`.\n * @param {Object} [stack] Tracks traversed objects and their clone counterparts.\n * @returns {*} Returns the cloned value.\n */\nfunction baseClone(value, bitmask, customizer, key, object, stack) {\n var result,\n isDeep = bitmask & CLONE_DEEP_FLAG,\n isFlat = bitmask & CLONE_FLAT_FLAG,\n isFull = bitmask & CLONE_SYMBOLS_FLAG;\n\n if (customizer) {\n result = object ? customizer(value, key, object, stack) : customizer(value);\n }\n if (result !== undefined) {\n return result;\n }\n if (!isObject(value)) {\n return value;\n }\n var isArr = isArray(value);\n if (isArr) {\n result = initCloneArray(value);\n if (!isDeep) {\n return copyArray(value, result);\n }\n } else {\n var tag = getTag(value),\n isFunc = tag == funcTag || tag == genTag;\n\n if (isBuffer(value)) {\n return cloneBuffer(value, isDeep);\n }\n if (tag == objectTag || tag == argsTag || (isFunc && !object)) {\n result = (isFlat || isFunc) ? {} : initCloneObject(value);\n if (!isDeep) {\n return isFlat\n ? copySymbolsIn(value, baseAssignIn(result, value))\n : copySymbols(value, baseAssign(result, value));\n }\n } else {\n if (!cloneableTags[tag]) {\n return object ? value : {};\n }\n result = initCloneByTag(value, tag, isDeep);\n }\n }\n // Check for circular references and return its corresponding clone.\n stack || (stack = new Stack);\n var stacked = stack.get(value);\n if (stacked) {\n return stacked;\n }\n stack.set(value, result);\n\n if (isSet(value)) {\n value.forEach(function(subValue) {\n result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));\n });\n\n return result;\n }\n\n if (isMap(value)) {\n value.forEach(function(subValue, key) {\n result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));\n });\n\n return result;\n }\n\n var keysFunc = isFull\n ? (isFlat ? getAllKeysIn : getAllKeys)\n : (isFlat ? keysIn : keys);\n\n var props = isArr ? undefined : keysFunc(value);\n arrayEach(props || value, function(subValue, key) {\n if (props) {\n key = subValue;\n subValue = value[key];\n }\n // Recursively populate clone (susceptible to call stack limits).\n assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));\n });\n return result;\n}\n\nmodule.exports = baseClone;\n","/**\n * Gets the last element of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the last element of `array`.\n * @example\n *\n * _.last([1, 2, 3]);\n * // => 3\n */\nfunction last(array) {\n var length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n}\n\nmodule.exports = last;\n","/**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\nfunction baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = end > length ? length : end;\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n}\n\nmodule.exports = baseSlice;\n","var baseGet = require('./_baseGet'),\n baseSlice = require('./_baseSlice');\n\n/**\n * Gets the parent value at `path` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path to get the parent value of.\n * @returns {*} Returns the parent value.\n */\nfunction parent(object, path) {\n return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));\n}\n\nmodule.exports = parent;\n","var castPath = require('./_castPath'),\n last = require('./last'),\n parent = require('./_parent'),\n toKey = require('./_toKey');\n\n/**\n * The base implementation of `_.unset`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The property path to unset.\n * @returns {boolean} Returns `true` if the property is deleted, else `false`.\n */\nfunction baseUnset(object, path) {\n path = castPath(path, object);\n object = parent(object, path);\n return object == null || delete object[toKey(last(path))];\n}\n\nmodule.exports = baseUnset;\n","var baseGetTag = require('./_baseGetTag'),\n getPrototype = require('./_getPrototype'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar objectTag = '[object Object]';\n\n/** Used for built-in method references. */\nvar funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/** Used to infer the `Object` constructor. */\nvar objectCtorString = funcToString.call(Object);\n\n/**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @static\n * @memberOf _\n * @since 0.8.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\nfunction isPlainObject(value) {\n if (!isObjectLike(value) || baseGetTag(value) != objectTag) {\n return false;\n }\n var proto = getPrototype(value);\n if (proto === null) {\n return true;\n }\n var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;\n return typeof Ctor == 'function' && Ctor instanceof Ctor &&\n funcToString.call(Ctor) == objectCtorString;\n}\n\nmodule.exports = isPlainObject;\n","var isPlainObject = require('./isPlainObject');\n\n/**\n * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain\n * objects.\n *\n * @private\n * @param {*} value The value to inspect.\n * @param {string} key The key of the property to inspect.\n * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.\n */\nfunction customOmitClone(value) {\n return isPlainObject(value) ? undefined : value;\n}\n\nmodule.exports = customOmitClone;\n","var Symbol = require('./_Symbol'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray');\n\n/** Built-in value references. */\nvar spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;\n\n/**\n * Checks if `value` is a flattenable `arguments` object or array.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n */\nfunction isFlattenable(value) {\n return isArray(value) || isArguments(value) ||\n !!(spreadableSymbol && value && value[spreadableSymbol]);\n}\n\nmodule.exports = isFlattenable;\n","var arrayPush = require('./_arrayPush'),\n isFlattenable = require('./_isFlattenable');\n\n/**\n * The base implementation of `_.flatten` with support for restricting flattening.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {number} depth The maximum recursion depth.\n * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\nfunction baseFlatten(array, depth, predicate, isStrict, result) {\n var index = -1,\n length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n}\n\nmodule.exports = baseFlatten;\n","var baseFlatten = require('./_baseFlatten');\n\n/**\n * Flattens `array` a single level deep.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, [3, [4]], 5]]);\n * // => [1, 2, [3, [4]], 5]\n */\nfunction flatten(array) {\n var length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, 1) : [];\n}\n\nmodule.exports = flatten;\n","var flatten = require('./flatten'),\n overRest = require('./_overRest'),\n setToString = require('./_setToString');\n\n/**\n * A specialized version of `baseRest` which flattens the rest array.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @returns {Function} Returns the new function.\n */\nfunction flatRest(func) {\n return setToString(overRest(func, undefined, flatten), func + '');\n}\n\nmodule.exports = flatRest;\n","var arrayMap = require('./_arrayMap'),\n baseClone = require('./_baseClone'),\n baseUnset = require('./_baseUnset'),\n castPath = require('./_castPath'),\n copyObject = require('./_copyObject'),\n customOmitClone = require('./_customOmitClone'),\n flatRest = require('./_flatRest'),\n getAllKeysIn = require('./_getAllKeysIn');\n\n/** Used to compose bitmasks for cloning. */\nvar CLONE_DEEP_FLAG = 1,\n CLONE_FLAT_FLAG = 2,\n CLONE_SYMBOLS_FLAG = 4;\n\n/**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable property paths of `object` that are not omitted.\n *\n * **Note:** This method is considerably slower than `_.pick`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to omit.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.omit(object, ['a', 'c']);\n * // => { 'b': '2' }\n */\nvar omit = flatRest(function(object, paths) {\n var result = {};\n if (object == null) {\n return result;\n }\n var isDeep = false;\n paths = arrayMap(paths, function(path) {\n path = castPath(path, object);\n isDeep || (isDeep = path.length > 1);\n return path;\n });\n copyObject(object, getAllKeysIn(object), result);\n if (isDeep) {\n result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);\n }\n var length = paths.length;\n while (length--) {\n baseUnset(result, paths[length]);\n }\n return result;\n});\n\nmodule.exports = omit;\n","var isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var toNumber = require('./toNumber');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0,\n MAX_INTEGER = 1.7976931348623157e+308;\n\n/**\n * Converts `value` to a finite number.\n *\n * @static\n * @memberOf _\n * @since 4.12.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted number.\n * @example\n *\n * _.toFinite(3.2);\n * // => 3.2\n *\n * _.toFinite(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toFinite(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toFinite('3.2');\n * // => 3.2\n */\nfunction toFinite(value) {\n if (!value) {\n return value === 0 ? value : 0;\n }\n value = toNumber(value);\n if (value === INFINITY || value === -INFINITY) {\n var sign = (value < 0 ? -1 : 1);\n return sign * MAX_INTEGER;\n }\n return value === value ? value : 0;\n}\n\nmodule.exports = toFinite;\n","var toFinite = require('./toFinite');\n\n/**\n * Converts `value` to an integer.\n *\n * **Note:** This method is loosely based on\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.toInteger(3.2);\n * // => 3\n *\n * _.toInteger(Number.MIN_VALUE);\n * // => 0\n *\n * _.toInteger(Infinity);\n * // => 1.7976931348623157e+308\n *\n * _.toInteger('3.2');\n * // => 3\n */\nfunction toInteger(value) {\n var result = toFinite(value),\n remainder = result % 1;\n\n return result === result ? (remainder ? result - remainder : result) : 0;\n}\n\nmodule.exports = toInteger;\n","var baseIndexOf = require('./_baseIndexOf'),\n toInteger = require('./toInteger');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * Gets the index at which the first occurrence of `value` is found in `array`\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. If `fromIndex` is negative, it's used as the\n * offset from the end of `array`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.indexOf([1, 2, 1, 2], 2);\n * // => 1\n *\n * // Search from the `fromIndex`.\n * _.indexOf([1, 2, 1, 2], 2, 2);\n * // => 3\n */\nfunction indexOf(array, value, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseIndexOf(array, value, index);\n}\n\nmodule.exports = indexOf;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar numberTag = '[object Number]';\n\n/**\n * Checks if `value` is classified as a `Number` primitive or object.\n *\n * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are\n * classified as numbers, use the `_.isFinite` method.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a number, else `false`.\n * @example\n *\n * _.isNumber(3);\n * // => true\n *\n * _.isNumber(Number.MIN_VALUE);\n * // => true\n *\n * _.isNumber(Infinity);\n * // => true\n *\n * _.isNumber('3');\n * // => false\n */\nfunction isNumber(value) {\n return typeof value == 'number' ||\n (isObjectLike(value) && baseGetTag(value) == numberTag);\n}\n\nmodule.exports = isNumber;\n","var isNumber = require('./isNumber');\n\n/**\n * Checks if `value` is `NaN`.\n *\n * **Note:** This method is based on\n * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as\n * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for\n * `undefined` and other non-number values.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n * @example\n *\n * _.isNaN(NaN);\n * // => true\n *\n * _.isNaN(new Number(NaN));\n * // => true\n *\n * isNaN(undefined);\n * // => true\n *\n * _.isNaN(undefined);\n * // => false\n */\nfunction isNaN(value) {\n // An `NaN` primitive is the only value that is not equal to itself.\n // Perform the `toStringTag` check first to avoid errors with some\n // ActiveX objects in IE.\n return isNumber(value) && value != +value;\n}\n\nmodule.exports = isNaN;\n","var baseKeys = require('./_baseKeys'),\n getTag = require('./_getTag'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isArrayLike = require('./isArrayLike'),\n isBuffer = require('./isBuffer'),\n isPrototype = require('./_isPrototype'),\n isTypedArray = require('./isTypedArray');\n\n/** `Object#toString` result references. */\nvar mapTag = '[object Map]',\n setTag = '[object Set]';\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Checks if `value` is an empty object, collection, map, or set.\n *\n * Objects are considered empty if they have no own enumerable string keyed\n * properties.\n *\n * Array-like values such as `arguments` objects, arrays, buffers, strings, or\n * jQuery-like collections are considered empty if they have a `length` of `0`.\n * Similarly, maps and sets are considered empty if they have a `size` of `0`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty(null);\n * // => true\n *\n * _.isEmpty(true);\n * // => true\n *\n * _.isEmpty(1);\n * // => true\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({ 'a': 1 });\n * // => false\n */\nfunction isEmpty(value) {\n if (value == null) {\n return true;\n }\n if (isArrayLike(value) &&\n (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||\n isBuffer(value) || isTypedArray(value) || isArguments(value))) {\n return !value.length;\n }\n var tag = getTag(value);\n if (tag == mapTag || tag == setTag) {\n return !value.size;\n }\n if (isPrototype(value)) {\n return !baseKeys(value).length;\n }\n for (var key in value) {\n if (hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n return true;\n}\n\nmodule.exports = isEmpty;\n","var baseIsEqual = require('./_baseIsEqual');\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are compared by strict equality, i.e. `===`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.isEqual(object, other);\n * // => true\n *\n * object === other;\n * // => false\n */\nfunction isEqual(value, other) {\n return baseIsEqual(value, other);\n}\n\nmodule.exports = isEqual;\n","/**\n * Checks if `value` is `undefined`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n *\n * _.isUndefined(null);\n * // => false\n */\nfunction isUndefined(value) {\n return value === undefined;\n}\n\nmodule.exports = isUndefined;\n","var baseGetTag = require('./_baseGetTag'),\n isArray = require('./isArray'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar stringTag = '[object String]';\n\n/**\n * Checks if `value` is classified as a `String` primitive or object.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a string, else `false`.\n * @example\n *\n * _.isString('abc');\n * // => true\n *\n * _.isString(1);\n * // => false\n */\nfunction isString(value) {\n return typeof value == 'string' ||\n (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);\n}\n\nmodule.exports = isString;\n","var baseIteratee = require('./_baseIteratee'),\n isArrayLike = require('./isArrayLike'),\n keys = require('./keys');\n\n/**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} findIndexFunc The function to find the collection index.\n * @returns {Function} Returns the new find function.\n */\nfunction createFind(findIndexFunc) {\n return function(collection, predicate, fromIndex) {\n var iterable = Object(collection);\n if (!isArrayLike(collection)) {\n var iteratee = baseIteratee(predicate, 3);\n collection = keys(collection);\n predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n }\n var index = findIndexFunc(collection, predicate, fromIndex);\n return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n };\n}\n\nmodule.exports = createFind;\n","var baseFindIndex = require('./_baseFindIndex'),\n baseIteratee = require('./_baseIteratee'),\n toInteger = require('./toInteger');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\nfunction findIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, baseIteratee(predicate, 3), index);\n}\n\nmodule.exports = findIndex;\n","var createFind = require('./_createFind'),\n findIndex = require('./findIndex');\n\n/**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.find(users, function(o) { return o.age < 40; });\n * // => object for 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.find(users, { 'age': 1, 'active': true });\n * // => object for 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.find(users, ['active', false]);\n * // => object for 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.find(users, 'active');\n * // => object for 'barney'\n */\nvar find = createFind(findIndex);\n\nmodule.exports = find;\n","var baseSlice = require('./_baseSlice');\n\n/**\n * Casts `array` to a slice if it's needed.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {number} start The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the cast slice.\n */\nfunction castSlice(array, start, end) {\n var length = array.length;\n end = end === undefined ? length : end;\n return (!start && end >= length) ? array : baseSlice(array, start, end);\n}\n\nmodule.exports = castSlice;\n","var baseIndexOf = require('./_baseIndexOf');\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the last unmatched string symbol.\n */\nfunction charsEndIndex(strSymbols, chrSymbols) {\n var index = strSymbols.length;\n\n while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n}\n\nmodule.exports = charsEndIndex;\n","var baseIndexOf = require('./_baseIndexOf');\n\n/**\n * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol\n * that is not found in the character symbols.\n *\n * @private\n * @param {Array} strSymbols The string symbols to inspect.\n * @param {Array} chrSymbols The character symbols to find.\n * @returns {number} Returns the index of the first unmatched string symbol.\n */\nfunction charsStartIndex(strSymbols, chrSymbols) {\n var index = -1,\n length = strSymbols.length;\n\n while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}\n return index;\n}\n\nmodule.exports = charsStartIndex;\n","/**\n * Converts an ASCII `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction asciiToArray(string) {\n return string.split('');\n}\n\nmodule.exports = asciiToArray;\n","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsVarRange = '\\\\ufe0e\\\\ufe0f';\n\n/** Used to compose unicode capture groups. */\nvar rsZWJ = '\\\\u200d';\n\n/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */\nvar reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');\n\n/**\n * Checks if `string` contains Unicode symbols.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {boolean} Returns `true` if a symbol is found, else `false`.\n */\nfunction hasUnicode(string) {\n return reHasUnicode.test(string);\n}\n\nmodule.exports = hasUnicode;\n","/** Used to compose unicode character classes. */\nvar rsAstralRange = '\\\\ud800-\\\\udfff',\n rsComboMarksRange = '\\\\u0300-\\\\u036f',\n reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f',\n rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff',\n rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,\n rsVarRange = '\\\\ufe0e\\\\ufe0f';\n\n/** Used to compose unicode capture groups. */\nvar rsAstral = '[' + rsAstralRange + ']',\n rsCombo = '[' + rsComboRange + ']',\n rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]',\n rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',\n rsNonAstral = '[^' + rsAstralRange + ']',\n rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}',\n rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]',\n rsZWJ = '\\\\u200d';\n\n/** Used to compose unicode regexes. */\nvar reOptMod = rsModifier + '?',\n rsOptVar = '[' + rsVarRange + ']?',\n rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',\n rsSeq = rsOptVar + reOptMod + rsOptJoin,\n rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\n/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */\nvar reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');\n\n/**\n * Converts a Unicode `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction unicodeToArray(string) {\n return string.match(reUnicode) || [];\n}\n\nmodule.exports = unicodeToArray;\n","var asciiToArray = require('./_asciiToArray'),\n hasUnicode = require('./_hasUnicode'),\n unicodeToArray = require('./_unicodeToArray');\n\n/**\n * Converts `string` to an array.\n *\n * @private\n * @param {string} string The string to convert.\n * @returns {Array} Returns the converted array.\n */\nfunction stringToArray(string) {\n return hasUnicode(string)\n ? unicodeToArray(string)\n : asciiToArray(string);\n}\n\nmodule.exports = stringToArray;\n","var baseToString = require('./_baseToString'),\n castSlice = require('./_castSlice'),\n charsEndIndex = require('./_charsEndIndex'),\n charsStartIndex = require('./_charsStartIndex'),\n stringToArray = require('./_stringToArray'),\n toString = require('./toString');\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/**\n * Removes leading and trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trim(' abc ');\n * // => 'abc'\n *\n * _.trim('-_-abc-_-', '_-');\n * // => 'abc'\n *\n * _.map([' foo ', ' bar '], _.trim);\n * // => ['foo', 'bar']\n */\nfunction trim(string, chars, guard) {\n string = toString(string);\n if (string && (guard || chars === undefined)) {\n return string.replace(reTrim, '');\n }\n if (!string || !(chars = baseToString(chars))) {\n return string;\n }\n var strSymbols = stringToArray(string),\n chrSymbols = stringToArray(chars),\n start = charsStartIndex(strSymbols, chrSymbols),\n end = charsEndIndex(strSymbols, chrSymbols) + 1;\n\n return castSlice(strSymbols, start, end).join('');\n}\n\nmodule.exports = trim;\n","var eq = require('./eq'),\n isArrayLike = require('./isArrayLike'),\n isIndex = require('./_isIndex'),\n isObject = require('./isObject');\n\n/**\n * Checks if the given arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call,\n * else `false`.\n */\nfunction isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)\n ) {\n return eq(object[index], value);\n }\n return false;\n}\n\nmodule.exports = isIterateeCall;\n","var baseRest = require('./_baseRest'),\n eq = require('./eq'),\n isIterateeCall = require('./_isIterateeCall'),\n keysIn = require('./keysIn');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Assigns own and inherited enumerable string keyed properties of source\n * objects to the destination object for all destination properties that\n * resolve to `undefined`. Source objects are applied from left to right.\n * Once a property is set, additional values of the same property are ignored.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @see _.defaultsDeep\n * @example\n *\n * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });\n * // => { 'a': 1, 'b': 2 }\n */\nvar defaults = baseRest(function(object, sources) {\n object = Object(object);\n\n var index = -1;\n var length = sources.length;\n var guard = length > 2 ? sources[2] : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n length = 1;\n }\n\n while (++index < length) {\n var source = sources[index];\n var props = keysIn(source);\n var propsIndex = -1;\n var propsLength = props.length;\n\n while (++propsIndex < propsLength) {\n var key = props[propsIndex];\n var value = object[key];\n\n if (value === undefined ||\n (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {\n object[key] = source[key];\n }\n }\n }\n\n return object;\n});\n\nmodule.exports = defaults;\n","var baseAssignValue = require('./_baseAssignValue'),\n eq = require('./eq');\n\n/**\n * This function is like `assignValue` except that it doesn't assign\n * `undefined` values.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {string} key The key of the property to assign.\n * @param {*} value The value to assign.\n */\nfunction assignMergeValue(object, key, value) {\n if ((value !== undefined && !eq(object[key], value)) ||\n (value === undefined && !(key in object))) {\n baseAssignValue(object, key, value);\n }\n}\n\nmodule.exports = assignMergeValue;\n","/**\n * Gets the value at `key`, unless `key` is \"__proto__\".\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction safeGet(object, key) {\n if (key == '__proto__') {\n return;\n }\n\n return object[key];\n}\n\nmodule.exports = safeGet;\n","var copyObject = require('./_copyObject'),\n keysIn = require('./keysIn');\n\n/**\n * Converts `value` to a plain object flattening inherited enumerable string\n * keyed properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\nfunction toPlainObject(value) {\n return copyObject(value, keysIn(value));\n}\n\nmodule.exports = toPlainObject;\n","var assignMergeValue = require('./_assignMergeValue'),\n cloneBuffer = require('./_cloneBuffer'),\n cloneTypedArray = require('./_cloneTypedArray'),\n copyArray = require('./_copyArray'),\n initCloneObject = require('./_initCloneObject'),\n isArguments = require('./isArguments'),\n isArray = require('./isArray'),\n isArrayLikeObject = require('./isArrayLikeObject'),\n isBuffer = require('./isBuffer'),\n isFunction = require('./isFunction'),\n isObject = require('./isObject'),\n isPlainObject = require('./isPlainObject'),\n isTypedArray = require('./isTypedArray'),\n safeGet = require('./_safeGet'),\n toPlainObject = require('./toPlainObject');\n\n/**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {\n var objValue = safeGet(object, key),\n srcValue = safeGet(source, key),\n stacked = stack.get(srcValue);\n\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n var newValue = customizer\n ? customizer(objValue, srcValue, (key + ''), object, source, stack)\n : undefined;\n\n var isCommon = newValue === undefined;\n\n if (isCommon) {\n var isArr = isArray(srcValue),\n isBuff = !isArr && isBuffer(srcValue),\n isTyped = !isArr && !isBuff && isTypedArray(srcValue);\n\n newValue = srcValue;\n if (isArr || isBuff || isTyped) {\n if (isArray(objValue)) {\n newValue = objValue;\n }\n else if (isArrayLikeObject(objValue)) {\n newValue = copyArray(objValue);\n }\n else if (isBuff) {\n isCommon = false;\n newValue = cloneBuffer(srcValue, true);\n }\n else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n }\n else {\n newValue = [];\n }\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n }\n else if (!isObject(objValue) || isFunction(objValue)) {\n newValue = initCloneObject(srcValue);\n }\n }\n else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n}\n\nmodule.exports = baseMergeDeep;\n","var Stack = require('./_Stack'),\n assignMergeValue = require('./_assignMergeValue'),\n baseFor = require('./_baseFor'),\n baseMergeDeep = require('./_baseMergeDeep'),\n isObject = require('./isObject'),\n keysIn = require('./keysIn'),\n safeGet = require('./_safeGet');\n\n/**\n * The base implementation of `_.merge` without support for multiple sources.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {number} srcIndex The index of `source`.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Object} [stack] Tracks traversed source values and their merged\n * counterparts.\n */\nfunction baseMerge(object, source, srcIndex, customizer, stack) {\n if (object === source) {\n return;\n }\n baseFor(source, function(srcValue, key) {\n if (isObject(srcValue)) {\n stack || (stack = new Stack);\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n }\n else {\n var newValue = customizer\n ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)\n : undefined;\n\n if (newValue === undefined) {\n newValue = srcValue;\n }\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n}\n\nmodule.exports = baseMerge;\n","var baseRest = require('./_baseRest'),\n isIterateeCall = require('./_isIterateeCall');\n\n/**\n * Creates a function like `_.assign`.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\nfunction createAssigner(assigner) {\n return baseRest(function(object, sources) {\n var index = -1,\n length = sources.length,\n customizer = length > 1 ? sources[length - 1] : undefined,\n guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer == 'function')\n ? (length--, customizer)\n : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n });\n}\n\nmodule.exports = createAssigner;\n","var baseMerge = require('./_baseMerge'),\n createAssigner = require('./_createAssigner');\n\n/**\n * This method is like `_.assign` except that it recursively merges own and\n * inherited enumerable string keyed properties of source objects into the\n * destination object. Source properties that resolve to `undefined` are\n * skipped if a destination value exists. Array and plain object properties\n * are merged recursively. Other objects and value types are overridden by\n * assignment. Source objects are applied from left to right. Subsequent\n * sources overwrite property assignments of previous sources.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = {\n * 'a': [{ 'b': 2 }, { 'd': 4 }]\n * };\n *\n * var other = {\n * 'a': [{ 'c': 3 }, { 'e': 5 }]\n * };\n *\n * _.merge(object, other);\n * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }\n */\nvar merge = createAssigner(function(object, source, srcIndex) {\n baseMerge(object, source, srcIndex);\n});\n\nmodule.exports = merge;\n","'use strict';\n\nvar map = require('lodash/map');\nvar isNumber = require('lodash/isNumber');\nvar isString = require('lodash/isString');\nfunction valToNumber(v) {\n if (isNumber(v)) {\n return v;\n } else if (isString(v)) {\n return parseFloat(v);\n } else if (Array.isArray(v)) {\n return map(v, valToNumber);\n }\n\n throw new Error('The value should be a number, a parseable string or an array of those.');\n}\n\nmodule.exports = valToNumber;\n","'use strict';\n\nvar forEach = require('lodash/forEach');\nvar filter = require('lodash/filter');\nvar map = require('lodash/map');\nvar isEmpty = require('lodash/isEmpty');\nvar indexOf = require('lodash/indexOf');\n\nfunction filterState(state, filters) {\n var partialState = {};\n var attributeFilters = filter(filters, function(f) { return f.indexOf('attribute:') !== -1; });\n var attributes = map(attributeFilters, function(aF) { return aF.split(':')[1]; });\n\n if (indexOf(attributes, '*') === -1) {\n forEach(attributes, function(attr) {\n if (state.isConjunctiveFacet(attr) && state.isFacetRefined(attr)) {\n if (!partialState.facetsRefinements) partialState.facetsRefinements = {};\n partialState.facetsRefinements[attr] = state.facetsRefinements[attr];\n }\n\n if (state.isDisjunctiveFacet(attr) && state.isDisjunctiveFacetRefined(attr)) {\n if (!partialState.disjunctiveFacetsRefinements) partialState.disjunctiveFacetsRefinements = {};\n partialState.disjunctiveFacetsRefinements[attr] = state.disjunctiveFacetsRefinements[attr];\n }\n\n if (state.isHierarchicalFacet(attr) && state.isHierarchicalFacetRefined(attr)) {\n if (!partialState.hierarchicalFacetsRefinements) partialState.hierarchicalFacetsRefinements = {};\n partialState.hierarchicalFacetsRefinements[attr] = state.hierarchicalFacetsRefinements[attr];\n }\n\n var numericRefinements = state.getNumericRefinements(attr);\n if (!isEmpty(numericRefinements)) {\n if (!partialState.numericRefinements) partialState.numericRefinements = {};\n partialState.numericRefinements[attr] = state.numericRefinements[attr];\n }\n });\n } else {\n if (!isEmpty(state.numericRefinements)) {\n partialState.numericRefinements = state.numericRefinements;\n }\n if (!isEmpty(state.facetsRefinements)) partialState.facetsRefinements = state.facetsRefinements;\n if (!isEmpty(state.disjunctiveFacetsRefinements)) {\n partialState.disjunctiveFacetsRefinements = state.disjunctiveFacetsRefinements;\n }\n if (!isEmpty(state.hierarchicalFacetsRefinements)) {\n partialState.hierarchicalFacetsRefinements = state.hierarchicalFacetsRefinements;\n }\n }\n\n var searchParameters = filter(\n filters,\n function(f) {\n return f.indexOf('attribute:') === -1;\n }\n );\n\n forEach(\n searchParameters,\n function(parameterKey) {\n partialState[parameterKey] = state[parameterKey];\n }\n );\n\n return partialState;\n}\n\nmodule.exports = filterState;\n","'use strict';\n\n/**\n * Functions to manipulate refinement lists\n *\n * The RefinementList is not formally defined through a prototype but is based\n * on a specific structure.\n *\n * @module SearchParameters.refinementList\n *\n * @typedef {string[]} SearchParameters.refinementList.Refinements\n * @typedef {Object.} SearchParameters.refinementList.RefinementList\n */\n\nvar isUndefined = require('lodash/isUndefined');\nvar isString = require('lodash/isString');\nvar isFunction = require('lodash/isFunction');\nvar isEmpty = require('lodash/isEmpty');\nvar defaults = require('lodash/defaults');\n\nvar reduce = require('lodash/reduce');\nvar filter = require('lodash/filter');\nvar omit = require('lodash/omit');\n\nvar lib = {\n /**\n * Adds a refinement to a RefinementList\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} value the value of the refinement, if the value is not a string it will be converted\n * @return {RefinementList} a new and updated refinement list\n */\n addRefinement: function addRefinement(refinementList, attribute, value) {\n if (lib.isRefined(refinementList, attribute, value)) {\n return refinementList;\n }\n\n var valueAsString = '' + value;\n\n var facetRefinement = !refinementList[attribute] ?\n [valueAsString] :\n refinementList[attribute].concat(valueAsString);\n\n var mod = {};\n\n mod[attribute] = facetRefinement;\n\n return defaults({}, mod, refinementList);\n },\n /**\n * Removes refinement(s) for an attribute:\n * - if the value is specified removes the refinement for the value on the attribute\n * - if no value is specified removes all the refinements for this attribute\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} [value] the value of the refinement\n * @return {RefinementList} a new and updated refinement lst\n */\n removeRefinement: function removeRefinement(refinementList, attribute, value) {\n if (isUndefined(value)) {\n return lib.clearRefinement(refinementList, attribute);\n }\n\n var valueAsString = '' + value;\n\n return lib.clearRefinement(refinementList, function(v, f) {\n return attribute === f && valueAsString === v;\n });\n },\n /**\n * Toggles the refinement value for an attribute.\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} value the value of the refinement\n * @return {RefinementList} a new and updated list\n */\n toggleRefinement: function toggleRefinement(refinementList, attribute, value) {\n if (isUndefined(value)) throw new Error('toggleRefinement should be used with a value');\n\n if (lib.isRefined(refinementList, attribute, value)) {\n return lib.removeRefinement(refinementList, attribute, value);\n }\n\n return lib.addRefinement(refinementList, attribute, value);\n },\n /**\n * Clear all or parts of a RefinementList. Depending on the arguments, three\n * kinds of behavior can happen:\n * - if no attribute is provided: clears the whole list\n * - if an attribute is provided as a string: clears the list for the specific attribute\n * - if an attribute is provided as a function: discards the elements for which the function returns true\n * @param {RefinementList} refinementList the initial list\n * @param {string} [attribute] the attribute or function to discard\n * @param {string} [refinementType] optional parameter to give more context to the attribute function\n * @return {RefinementList} a new and updated refinement list\n */\n clearRefinement: function clearRefinement(refinementList, attribute, refinementType) {\n if (isUndefined(attribute)) {\n if (isEmpty(refinementList)) return refinementList;\n return {};\n } else if (isString(attribute)) {\n if (isEmpty(refinementList[attribute])) return refinementList;\n return omit(refinementList, attribute);\n } else if (isFunction(attribute)) {\n var hasChanged = false;\n\n var newRefinementList = reduce(refinementList, function(memo, values, key) {\n var facetList = filter(values, function(value) {\n return !attribute(value, key, refinementType);\n });\n\n if (!isEmpty(facetList)) {\n if (facetList.length !== values.length) hasChanged = true;\n memo[key] = facetList;\n }\n else hasChanged = true;\n\n return memo;\n }, {});\n\n if (hasChanged) return newRefinementList;\n return refinementList;\n }\n },\n /**\n * Test if the refinement value is used for the attribute. If no refinement value\n * is provided, test if the refinementList contains any refinement for the\n * given attribute.\n * @param {RefinementList} refinementList the list of refinement\n * @param {string} attribute name of the attribute\n * @param {string} [refinementValue] value of the filter/refinement\n * @return {boolean}\n */\n isRefined: function isRefined(refinementList, attribute, refinementValue) {\n var indexOf = require('lodash/indexOf');\n\n var containsRefinements = !!refinementList[attribute] &&\n refinementList[attribute].length > 0;\n\n if (isUndefined(refinementValue) || !containsRefinements) {\n return containsRefinements;\n }\n\n var refinementValueAsString = '' + refinementValue;\n\n return indexOf(refinementList[attribute], refinementValueAsString) !== -1;\n }\n};\n\nmodule.exports = lib;\n","'use strict';\n\nvar keys = require('lodash/keys');\nvar intersection = require('lodash/intersection');\nvar forOwn = require('lodash/forOwn');\nvar forEach = require('lodash/forEach');\nvar filter = require('lodash/filter');\nvar map = require('lodash/map');\nvar reduce = require('lodash/reduce');\nvar omit = require('lodash/omit');\nvar indexOf = require('lodash/indexOf');\nvar isNaN = require('lodash/isNaN');\nvar isEmpty = require('lodash/isEmpty');\nvar isEqual = require('lodash/isEqual');\nvar isUndefined = require('lodash/isUndefined');\nvar isString = require('lodash/isString');\nvar isFunction = require('lodash/isFunction');\nvar find = require('lodash/find');\nvar trim = require('lodash/trim');\n\nvar defaults = require('lodash/defaults');\nvar merge = require('lodash/merge');\n\nvar valToNumber = require('../functions/valToNumber');\n\nvar filterState = require('./filterState');\n\nvar RefinementList = require('./RefinementList');\n\n/**\n * like _.find but using _.isEqual to be able to use it\n * to find arrays.\n * @private\n * @param {any[]} array array to search into\n * @param {any} searchedValue the value we're looking for\n * @return {any} the searched value or undefined\n */\nfunction findArray(array, searchedValue) {\n return find(array, function(currentValue) {\n return isEqual(currentValue, searchedValue);\n });\n}\n\n/**\n * The facet list is the structure used to store the list of values used to\n * filter a single attribute.\n * @typedef {string[]} SearchParameters.FacetList\n */\n\n/**\n * Structure to store numeric filters with the operator as the key. The supported operators\n * are `=`, `>`, `<`, `>=`, `<=` and `!=`.\n * @typedef {Object.>} SearchParameters.OperatorList\n */\n\n/**\n * SearchParameters is the data structure that contains all the information\n * usable for making a search to Algolia API. It doesn't do the search itself,\n * nor does it contains logic about the parameters.\n * It is an immutable object, therefore it has been created in a way that each\n * changes does not change the object itself but returns a copy with the\n * modification.\n * This object should probably not be instantiated outside of the helper. It will\n * be provided when needed. This object is documented for reference as you'll\n * get it from events generated by the {@link AlgoliaSearchHelper}.\n * If need be, instantiate the Helper from the factory function {@link SearchParameters.make}\n * @constructor\n * @classdesc contains all the parameters of a search\n * @param {object|SearchParameters} newParameters existing parameters or partial object\n * for the properties of a new SearchParameters\n * @see SearchParameters.make\n * @example SearchParameters of the first query in\n * the instant search demo\n{\n \"query\": \"\",\n \"disjunctiveFacets\": [\n \"customerReviewCount\",\n \"category\",\n \"salePrice_range\",\n \"manufacturer\"\n ],\n \"maxValuesPerFacet\": 30,\n \"page\": 0,\n \"hitsPerPage\": 10,\n \"facets\": [\n \"type\",\n \"shipping\"\n ]\n}\n */\nfunction SearchParameters(newParameters) {\n var params = newParameters ? SearchParameters._parseNumbers(newParameters) : {};\n\n /**\n * Targeted index. This parameter is mandatory.\n * @member {string}\n */\n this.index = params.index || '';\n\n // Query\n /**\n * Query string of the instant search. The empty string is a valid query.\n * @member {string}\n * @see https://www.algolia.com/doc/rest#param-query\n */\n this.query = params.query || '';\n\n // Facets\n /**\n * This attribute contains the list of all the conjunctive facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * @member {string[]}\n */\n this.facets = params.facets || [];\n /**\n * This attribute contains the list of all the disjunctive facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * @member {string[]}\n */\n this.disjunctiveFacets = params.disjunctiveFacets || [];\n /**\n * This attribute contains the list of all the hierarchical facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * Hierarchical facets are a sub type of disjunctive facets that\n * let you filter faceted attributes hierarchically.\n * @member {string[]|object[]}\n */\n this.hierarchicalFacets = params.hierarchicalFacets || [];\n\n // Refinements\n /**\n * This attribute contains all the filters that need to be\n * applied on the conjunctive facets. Each facet must be properly\n * defined in the `facets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.facetsRefinements = params.facetsRefinements || {};\n /**\n * This attribute contains all the filters that need to be\n * excluded from the conjunctive facets. Each facet must be properly\n * defined in the `facets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters excluded for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.facetsExcludes = params.facetsExcludes || {};\n /**\n * This attribute contains all the filters that need to be\n * applied on the disjunctive facets. Each facet must be properly\n * defined in the `disjunctiveFacets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.disjunctiveFacetsRefinements = params.disjunctiveFacetsRefinements || {};\n /**\n * This attribute contains all the filters that need to be\n * applied on the numeric attributes.\n *\n * The key is the name of the attribute, and the value is the\n * filters to apply to this attribute.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `numericFilters` attribute.\n * @member {Object.}\n */\n this.numericRefinements = params.numericRefinements || {};\n /**\n * This attribute contains all the tags used to refine the query.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `tagFilters` attribute.\n * @member {string[]}\n */\n this.tagRefinements = params.tagRefinements || [];\n /**\n * This attribute contains all the filters that need to be\n * applied on the hierarchical facets. Each facet must be properly\n * defined in the `hierarchicalFacets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name. The FacetList values\n * are structured as a string that contain the values for each level\n * separated by the configured separator.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.hierarchicalFacetsRefinements = params.hierarchicalFacetsRefinements || {};\n\n /**\n * Contains the numeric filters in the raw format of the Algolia API. Setting\n * this parameter is not compatible with the usage of numeric filters methods.\n * @see https://www.algolia.com/doc/javascript#numericFilters\n * @member {string}\n */\n this.numericFilters = params.numericFilters;\n\n /**\n * Contains the tag filters in the raw format of the Algolia API. Setting this\n * parameter is not compatible with the of the add/remove/toggle methods of the\n * tag api.\n * @see https://www.algolia.com/doc/rest#param-tagFilters\n * @member {string}\n */\n this.tagFilters = params.tagFilters;\n\n /**\n * Contains the optional tag filters in the raw format of the Algolia API.\n * @see https://www.algolia.com/doc/rest#param-tagFilters\n * @member {string}\n */\n this.optionalTagFilters = params.optionalTagFilters;\n\n /**\n * Contains the optional facet filters in the raw format of the Algolia API.\n * @see https://www.algolia.com/doc/rest#param-tagFilters\n * @member {string}\n */\n this.optionalFacetFilters = params.optionalFacetFilters;\n\n\n // Misc. parameters\n /**\n * Number of hits to be returned by the search API\n * @member {number}\n * @see https://www.algolia.com/doc/rest#param-hitsPerPage\n */\n this.hitsPerPage = params.hitsPerPage;\n /**\n * Number of values for each faceted attribute\n * @member {number}\n * @see https://www.algolia.com/doc/rest#param-maxValuesPerFacet\n */\n this.maxValuesPerFacet = params.maxValuesPerFacet;\n /**\n * The current page number\n * @member {number}\n * @see https://www.algolia.com/doc/rest#param-page\n */\n this.page = params.page || 0;\n /**\n * How the query should be treated by the search engine.\n * Possible values: prefixAll, prefixLast, prefixNone\n * @see https://www.algolia.com/doc/rest#param-queryType\n * @member {string}\n */\n this.queryType = params.queryType;\n /**\n * How the typo tolerance behave in the search engine.\n * Possible values: true, false, min, strict\n * @see https://www.algolia.com/doc/rest#param-typoTolerance\n * @member {string}\n */\n this.typoTolerance = params.typoTolerance;\n\n /**\n * Number of characters to wait before doing one character replacement.\n * @see https://www.algolia.com/doc/rest#param-minWordSizefor1Typo\n * @member {number}\n */\n this.minWordSizefor1Typo = params.minWordSizefor1Typo;\n /**\n * Number of characters to wait before doing a second character replacement.\n * @see https://www.algolia.com/doc/rest#param-minWordSizefor2Typos\n * @member {number}\n */\n this.minWordSizefor2Typos = params.minWordSizefor2Typos;\n /**\n * Configure the precision of the proximity ranking criterion\n * @see https://www.algolia.com/doc/rest#param-minProximity\n */\n this.minProximity = params.minProximity;\n /**\n * Should the engine allow typos on numerics.\n * @see https://www.algolia.com/doc/rest#param-allowTyposOnNumericTokens\n * @member {boolean}\n */\n this.allowTyposOnNumericTokens = params.allowTyposOnNumericTokens;\n /**\n * Should the plurals be ignored\n * @see https://www.algolia.com/doc/rest#param-ignorePlurals\n * @member {boolean}\n */\n this.ignorePlurals = params.ignorePlurals;\n /**\n * Restrict which attribute is searched.\n * @see https://www.algolia.com/doc/rest#param-restrictSearchableAttributes\n * @member {string}\n */\n this.restrictSearchableAttributes = params.restrictSearchableAttributes;\n /**\n * Enable the advanced syntax.\n * @see https://www.algolia.com/doc/rest#param-advancedSyntax\n * @member {boolean}\n */\n this.advancedSyntax = params.advancedSyntax;\n /**\n * Enable the analytics\n * @see https://www.algolia.com/doc/rest#param-analytics\n * @member {boolean}\n */\n this.analytics = params.analytics;\n /**\n * Tag of the query in the analytics.\n * @see https://www.algolia.com/doc/rest#param-analyticsTags\n * @member {string}\n */\n this.analyticsTags = params.analyticsTags;\n /**\n * Enable the synonyms\n * @see https://www.algolia.com/doc/rest#param-synonyms\n * @member {boolean}\n */\n this.synonyms = params.synonyms;\n /**\n * Should the engine replace the synonyms in the highlighted results.\n * @see https://www.algolia.com/doc/rest#param-replaceSynonymsInHighlight\n * @member {boolean}\n */\n this.replaceSynonymsInHighlight = params.replaceSynonymsInHighlight;\n /**\n * Add some optional words to those defined in the dashboard\n * @see https://www.algolia.com/doc/rest#param-optionalWords\n * @member {string}\n */\n this.optionalWords = params.optionalWords;\n /**\n * Possible values are \"lastWords\" \"firstWords\" \"allOptional\" \"none\" (default)\n * @see https://www.algolia.com/doc/rest#param-removeWordsIfNoResults\n * @member {string}\n */\n this.removeWordsIfNoResults = params.removeWordsIfNoResults;\n /**\n * List of attributes to retrieve\n * @see https://www.algolia.com/doc/rest#param-attributesToRetrieve\n * @member {string}\n */\n this.attributesToRetrieve = params.attributesToRetrieve;\n /**\n * List of attributes to highlight\n * @see https://www.algolia.com/doc/rest#param-attributesToHighlight\n * @member {string}\n */\n this.attributesToHighlight = params.attributesToHighlight;\n /**\n * Code to be embedded on the left part of the highlighted results\n * @see https://www.algolia.com/doc/rest#param-highlightPreTag\n * @member {string}\n */\n this.highlightPreTag = params.highlightPreTag;\n /**\n * Code to be embedded on the right part of the highlighted results\n * @see https://www.algolia.com/doc/rest#param-highlightPostTag\n * @member {string}\n */\n this.highlightPostTag = params.highlightPostTag;\n /**\n * List of attributes to snippet\n * @see https://www.algolia.com/doc/rest#param-attributesToSnippet\n * @member {string}\n */\n this.attributesToSnippet = params.attributesToSnippet;\n /**\n * Enable the ranking informations in the response, set to 1 to activate\n * @see https://www.algolia.com/doc/rest#param-getRankingInfo\n * @member {number}\n */\n this.getRankingInfo = params.getRankingInfo;\n /**\n * Remove duplicates based on the index setting attributeForDistinct\n * @see https://www.algolia.com/doc/rest#param-distinct\n * @member {boolean|number}\n */\n this.distinct = params.distinct;\n /**\n * Center of the geo search.\n * @see https://www.algolia.com/doc/rest#param-aroundLatLng\n * @member {string}\n */\n this.aroundLatLng = params.aroundLatLng;\n /**\n * Center of the search, retrieve from the user IP.\n * @see https://www.algolia.com/doc/rest#param-aroundLatLngViaIP\n * @member {boolean}\n */\n this.aroundLatLngViaIP = params.aroundLatLngViaIP;\n /**\n * Radius of the geo search.\n * @see https://www.algolia.com/doc/rest#param-aroundRadius\n * @member {number}\n */\n this.aroundRadius = params.aroundRadius;\n /**\n * Precision of the geo search.\n * @see https://www.algolia.com/doc/rest#param-aroundPrecision\n * @member {number}\n */\n this.minimumAroundRadius = params.minimumAroundRadius;\n /**\n * Precision of the geo search.\n * @see https://www.algolia.com/doc/rest#param-minimumAroundRadius\n * @member {number}\n */\n this.aroundPrecision = params.aroundPrecision;\n /**\n * Geo search inside a box.\n * @see https://www.algolia.com/doc/rest#param-insideBoundingBox\n * @member {string}\n */\n this.insideBoundingBox = params.insideBoundingBox;\n /**\n * Geo search inside a polygon.\n * @see https://www.algolia.com/doc/rest#param-insidePolygon\n * @member {string}\n */\n this.insidePolygon = params.insidePolygon;\n /**\n * Allows to specify an ellipsis character for the snippet when we truncate the text\n * (added before and after if truncated).\n * The default value is an empty string and we recommend to set it to \"…\"\n * @see https://www.algolia.com/doc/rest#param-insidePolygon\n * @member {string}\n */\n this.snippetEllipsisText = params.snippetEllipsisText;\n /**\n * Allows to specify some attributes name on which exact won't be applied.\n * Attributes are separated with a comma (for example \"name,address\" ), you can also use a\n * JSON string array encoding (for example encodeURIComponent('[\"name\",\"address\"]') ).\n * By default the list is empty.\n * @see https://www.algolia.com/doc/rest#param-disableExactOnAttributes\n * @member {string|string[]}\n */\n this.disableExactOnAttributes = params.disableExactOnAttributes;\n /**\n * Applies 'exact' on single word queries if the word contains at least 3 characters\n * and is not a stop word.\n * Can take two values: true or false.\n * By default, its set to false.\n * @see https://www.algolia.com/doc/rest#param-enableExactOnSingleWordQuery\n * @member {boolean}\n */\n this.enableExactOnSingleWordQuery = params.enableExactOnSingleWordQuery;\n\n // Undocumented parameters, still needed otherwise we fail\n this.offset = params.offset;\n this.length = params.length;\n\n var self = this;\n forOwn(params, function checkForUnknownParameter(paramValue, paramName) {\n if (SearchParameters.PARAMETERS.indexOf(paramName) === -1) {\n self[paramName] = paramValue;\n }\n });\n}\n\n/**\n * List all the properties in SearchParameters and therefore all the known Algolia properties\n * This doesn't contain any beta/hidden features.\n * @private\n */\nSearchParameters.PARAMETERS = keys(new SearchParameters());\n\n/**\n * @private\n * @param {object} partialState full or part of a state\n * @return {object} a new object with the number keys as number\n */\nSearchParameters._parseNumbers = function(partialState) {\n // Do not reparse numbers in SearchParameters, they ought to be parsed already\n if (partialState instanceof SearchParameters) return partialState;\n\n var numbers = {};\n\n var numberKeys = [\n 'aroundPrecision',\n 'aroundRadius',\n 'getRankingInfo',\n 'minWordSizefor2Typos',\n 'minWordSizefor1Typo',\n 'page',\n 'maxValuesPerFacet',\n 'distinct',\n 'minimumAroundRadius',\n 'hitsPerPage',\n 'minProximity'\n ];\n\n forEach(numberKeys, function(k) {\n var value = partialState[k];\n if (isString(value)) {\n var parsedValue = parseFloat(value);\n numbers[k] = isNaN(parsedValue) ? value : parsedValue;\n }\n });\n\n // there's two formats of insideBoundingBox, we need to parse\n // the one which is an array of float geo rectangles\n if (Array.isArray(partialState.insideBoundingBox)) {\n numbers.insideBoundingBox = partialState.insideBoundingBox.map(function(geoRect) {\n return geoRect.map(function(value) {\n return parseFloat(value);\n });\n });\n }\n\n if (partialState.numericRefinements) {\n var numericRefinements = {};\n forEach(partialState.numericRefinements, function(operators, attribute) {\n numericRefinements[attribute] = {};\n forEach(operators, function(values, operator) {\n var parsedValues = map(values, function(v) {\n if (Array.isArray(v)) {\n return map(v, function(vPrime) {\n if (isString(vPrime)) {\n return parseFloat(vPrime);\n }\n return vPrime;\n });\n } else if (isString(v)) {\n return parseFloat(v);\n }\n return v;\n });\n numericRefinements[attribute][operator] = parsedValues;\n });\n });\n numbers.numericRefinements = numericRefinements;\n }\n\n return merge({}, partialState, numbers);\n};\n\n/**\n * Factory for SearchParameters\n * @param {object|SearchParameters} newParameters existing parameters or partial\n * object for the properties of a new SearchParameters\n * @return {SearchParameters} frozen instance of SearchParameters\n */\nSearchParameters.make = function makeSearchParameters(newParameters) {\n var instance = new SearchParameters(newParameters);\n\n forEach(newParameters.hierarchicalFacets, function(facet) {\n if (facet.rootPath) {\n var currentRefinement = instance.getHierarchicalRefinement(facet.name);\n\n if (currentRefinement.length > 0 && currentRefinement[0].indexOf(facet.rootPath) !== 0) {\n instance = instance.clearRefinements(facet.name);\n }\n\n // get it again in case it has been cleared\n currentRefinement = instance.getHierarchicalRefinement(facet.name);\n if (currentRefinement.length === 0) {\n instance = instance.toggleHierarchicalFacetRefinement(facet.name, facet.rootPath);\n }\n }\n });\n\n return instance;\n};\n\n/**\n * Validates the new parameters based on the previous state\n * @param {SearchParameters} currentState the current state\n * @param {object|SearchParameters} parameters the new parameters to set\n * @return {Error|null} Error if the modification is invalid, null otherwise\n */\nSearchParameters.validate = function(currentState, parameters) {\n var params = parameters || {};\n\n if (currentState.tagFilters && params.tagRefinements && params.tagRefinements.length > 0) {\n return new Error(\n '[Tags] Cannot switch from the managed tag API to the advanced API. It is probably ' +\n 'an error, if it is really what you want, you should first clear the tags with clearTags method.');\n }\n\n if (currentState.tagRefinements.length > 0 && params.tagFilters) {\n return new Error(\n '[Tags] Cannot switch from the advanced tag API to the managed API. It is probably ' +\n 'an error, if it is not, you should first clear the tags with clearTags method.');\n }\n\n if (currentState.numericFilters && params.numericRefinements && !isEmpty(params.numericRefinements)) {\n return new Error(\n \"[Numeric filters] Can't switch from the advanced to the managed API. It\" +\n ' is probably an error, if this is really what you want, you have to first' +\n ' clear the numeric filters.');\n }\n\n if (!isEmpty(currentState.numericRefinements) && params.numericFilters) {\n return new Error(\n \"[Numeric filters] Can't switch from the managed API to the advanced. It\" +\n ' is probably an error, if this is really what you want, you have to first' +\n ' clear the numeric filters.');\n }\n\n return null;\n};\n\nSearchParameters.prototype = {\n constructor: SearchParameters,\n\n /**\n * Remove all refinements (disjunctive + conjunctive + excludes + numeric filters)\n * @method\n * @param {undefined|string|SearchParameters.clearCallback} [attribute] optional string or function\n * - If not given, means to clear all the filters.\n * - If `string`, means to clear all refinements for the `attribute` named filter.\n * - If `function`, means to clear all the refinements that return truthy values.\n * @return {SearchParameters}\n */\n clearRefinements: function clearRefinements(attribute) {\n var clear = RefinementList.clearRefinement;\n var patch = {\n numericRefinements: this._clearNumericRefinements(attribute),\n facetsRefinements: clear(this.facetsRefinements, attribute, 'conjunctiveFacet'),\n facetsExcludes: clear(this.facetsExcludes, attribute, 'exclude'),\n disjunctiveFacetsRefinements: clear(this.disjunctiveFacetsRefinements, attribute, 'disjunctiveFacet'),\n hierarchicalFacetsRefinements: clear(this.hierarchicalFacetsRefinements, attribute, 'hierarchicalFacet')\n };\n if (patch.numericRefinements === this.numericRefinements &&\n patch.facetsRefinements === this.facetsRefinements &&\n patch.facetsExcludes === this.facetsExcludes &&\n patch.disjunctiveFacetsRefinements === this.disjunctiveFacetsRefinements &&\n patch.hierarchicalFacetsRefinements === this.hierarchicalFacetsRefinements) {\n return this;\n }\n return this.setQueryParameters(patch);\n },\n /**\n * Remove all the refined tags from the SearchParameters\n * @method\n * @return {SearchParameters}\n */\n clearTags: function clearTags() {\n if (this.tagFilters === undefined && this.tagRefinements.length === 0) return this;\n\n return this.setQueryParameters({\n tagFilters: undefined,\n tagRefinements: []\n });\n },\n /**\n * Set the index.\n * @method\n * @param {string} index the index name\n * @return {SearchParameters}\n */\n setIndex: function setIndex(index) {\n if (index === this.index) return this;\n\n return this.setQueryParameters({\n index: index\n });\n },\n /**\n * Query setter\n * @method\n * @param {string} newQuery value for the new query\n * @return {SearchParameters}\n */\n setQuery: function setQuery(newQuery) {\n if (newQuery === this.query) return this;\n\n return this.setQueryParameters({\n query: newQuery\n });\n },\n /**\n * Page setter\n * @method\n * @param {number} newPage new page number\n * @return {SearchParameters}\n */\n setPage: function setPage(newPage) {\n if (newPage === this.page) return this;\n\n return this.setQueryParameters({\n page: newPage\n });\n },\n /**\n * Facets setter\n * The facets are the simple facets, used for conjunctive (and) faceting.\n * @method\n * @param {string[]} facets all the attributes of the algolia records used for conjunctive faceting\n * @return {SearchParameters}\n */\n setFacets: function setFacets(facets) {\n return this.setQueryParameters({\n facets: facets\n });\n },\n /**\n * Disjunctive facets setter\n * Change the list of disjunctive (or) facets the helper chan handle.\n * @method\n * @param {string[]} facets all the attributes of the algolia records used for disjunctive faceting\n * @return {SearchParameters}\n */\n setDisjunctiveFacets: function setDisjunctiveFacets(facets) {\n return this.setQueryParameters({\n disjunctiveFacets: facets\n });\n },\n /**\n * HitsPerPage setter\n * Hits per page represents the number of hits retrieved for this query\n * @method\n * @param {number} n number of hits retrieved per page of results\n * @return {SearchParameters}\n */\n setHitsPerPage: function setHitsPerPage(n) {\n if (this.hitsPerPage === n) return this;\n\n return this.setQueryParameters({\n hitsPerPage: n\n });\n },\n /**\n * typoTolerance setter\n * Set the value of typoTolerance\n * @method\n * @param {string} typoTolerance new value of typoTolerance (\"true\", \"false\", \"min\" or \"strict\")\n * @return {SearchParameters}\n */\n setTypoTolerance: function setTypoTolerance(typoTolerance) {\n if (this.typoTolerance === typoTolerance) return this;\n\n return this.setQueryParameters({\n typoTolerance: typoTolerance\n });\n },\n /**\n * Add a numeric filter for a given attribute\n * When value is an array, they are combined with OR\n * When value is a single value, it will combined with AND\n * @method\n * @param {string} attribute attribute to set the filter on\n * @param {string} operator operator of the filter (possible values: =, >, >=, <, <=, !=)\n * @param {number | number[]} value value of the filter\n * @return {SearchParameters}\n * @example\n * // for price = 50 or 40\n * searchparameter.addNumericRefinement('price', '=', [50, 40]);\n * @example\n * // for size = 38 and 40\n * searchparameter.addNumericRefinement('size', '=', 38);\n * searchparameter.addNumericRefinement('size', '=', 40);\n */\n addNumericRefinement: function(attribute, operator, v) {\n var value = valToNumber(v);\n\n if (this.isNumericRefined(attribute, operator, value)) return this;\n\n var mod = merge({}, this.numericRefinements);\n\n mod[attribute] = merge({}, mod[attribute]);\n\n if (mod[attribute][operator]) {\n // Array copy\n mod[attribute][operator] = mod[attribute][operator].slice();\n // Add the element. Concat can't be used here because value can be an array.\n mod[attribute][operator].push(value);\n } else {\n mod[attribute][operator] = [value];\n }\n\n return this.setQueryParameters({\n numericRefinements: mod\n });\n },\n /**\n * Get the list of conjunctive refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getConjunctiveRefinements: function(facetName) {\n if (!this.isConjunctiveFacet(facetName)) {\n throw new Error(facetName + ' is not defined in the facets attribute of the helper configuration');\n }\n return this.facetsRefinements[facetName] || [];\n },\n /**\n * Get the list of disjunctive refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getDisjunctiveRefinements: function(facetName) {\n if (!this.isDisjunctiveFacet(facetName)) {\n throw new Error(\n facetName + ' is not defined in the disjunctiveFacets attribute of the helper configuration'\n );\n }\n return this.disjunctiveFacetsRefinements[facetName] || [];\n },\n /**\n * Get the list of hierarchical refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getHierarchicalRefinement: function(facetName) {\n // we send an array but we currently do not support multiple\n // hierarchicalRefinements for a hierarchicalFacet\n return this.hierarchicalFacetsRefinements[facetName] || [];\n },\n /**\n * Get the list of exclude refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getExcludeRefinements: function(facetName) {\n if (!this.isConjunctiveFacet(facetName)) {\n throw new Error(facetName + ' is not defined in the facets attribute of the helper configuration');\n }\n return this.facetsExcludes[facetName] || [];\n },\n\n /**\n * Remove all the numeric filter for a given (attribute, operator)\n * @method\n * @param {string} attribute attribute to set the filter on\n * @param {string} [operator] operator of the filter (possible values: =, >, >=, <, <=, !=)\n * @param {number} [number] the value to be removed\n * @return {SearchParameters}\n */\n removeNumericRefinement: function(attribute, operator, paramValue) {\n if (paramValue !== undefined) {\n var paramValueAsNumber = valToNumber(paramValue);\n if (!this.isNumericRefined(attribute, operator, paramValueAsNumber)) return this;\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return key === attribute && value.op === operator && isEqual(value.val, paramValueAsNumber);\n })\n });\n } else if (operator !== undefined) {\n if (!this.isNumericRefined(attribute, operator)) return this;\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return key === attribute && value.op === operator;\n })\n });\n }\n\n if (!this.isNumericRefined(attribute)) return this;\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return key === attribute;\n })\n });\n },\n /**\n * Get the list of numeric refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {SearchParameters.OperatorList[]} list of refinements\n */\n getNumericRefinements: function(facetName) {\n return this.numericRefinements[facetName] || {};\n },\n /**\n * Return the current refinement for the (attribute, operator)\n * @param {string} attribute attribute in the record\n * @param {string} operator operator applied on the refined values\n * @return {Array.} refined values\n */\n getNumericRefinement: function(attribute, operator) {\n return this.numericRefinements[attribute] && this.numericRefinements[attribute][operator];\n },\n /**\n * Clear numeric filters.\n * @method\n * @private\n * @param {string|SearchParameters.clearCallback} [attribute] optional string or function\n * - If not given, means to clear all the filters.\n * - If `string`, means to clear all refinements for the `attribute` named filter.\n * - If `function`, means to clear all the refinements that return truthy values.\n * @return {Object.}\n */\n _clearNumericRefinements: function _clearNumericRefinements(attribute) {\n if (isUndefined(attribute)) {\n if (isEmpty(this.numericRefinements)) return this.numericRefinements;\n return {};\n } else if (isString(attribute)) {\n if (isEmpty(this.numericRefinements[attribute])) return this.numericRefinements;\n return omit(this.numericRefinements, attribute);\n } else if (isFunction(attribute)) {\n var hasChanged = false;\n var newNumericRefinements = reduce(this.numericRefinements, function(memo, operators, key) {\n var operatorList = {};\n\n forEach(operators, function(values, operator) {\n var outValues = [];\n forEach(values, function(value) {\n var predicateResult = attribute({val: value, op: operator}, key, 'numeric');\n if (!predicateResult) outValues.push(value);\n });\n if (!isEmpty(outValues)) {\n if (outValues.length !== values.length) hasChanged = true;\n operatorList[operator] = outValues;\n }\n else hasChanged = true;\n });\n\n if (!isEmpty(operatorList)) memo[key] = operatorList;\n\n return memo;\n }, {});\n\n if (hasChanged) return newNumericRefinements;\n return this.numericRefinements;\n }\n },\n /**\n * Add a facet to the facets attribute of the helper configuration, if it\n * isn't already present.\n * @method\n * @param {string} facet facet name to add\n * @return {SearchParameters}\n */\n addFacet: function addFacet(facet) {\n if (this.isConjunctiveFacet(facet)) {\n return this;\n }\n\n return this.setQueryParameters({\n facets: this.facets.concat([facet])\n });\n },\n /**\n * Add a disjunctive facet to the disjunctiveFacets attribute of the helper\n * configuration, if it isn't already present.\n * @method\n * @param {string} facet disjunctive facet name to add\n * @return {SearchParameters}\n */\n addDisjunctiveFacet: function addDisjunctiveFacet(facet) {\n if (this.isDisjunctiveFacet(facet)) {\n return this;\n }\n\n return this.setQueryParameters({\n disjunctiveFacets: this.disjunctiveFacets.concat([facet])\n });\n },\n /**\n * Add a hierarchical facet to the hierarchicalFacets attribute of the helper\n * configuration.\n * @method\n * @param {object} hierarchicalFacet hierarchical facet to add\n * @return {SearchParameters}\n * @throws will throw an error if a hierarchical facet with the same name was already declared\n */\n addHierarchicalFacet: function addHierarchicalFacet(hierarchicalFacet) {\n if (this.isHierarchicalFacet(hierarchicalFacet.name)) {\n throw new Error(\n 'Cannot declare two hierarchical facets with the same name: `' + hierarchicalFacet.name + '`');\n }\n\n return this.setQueryParameters({\n hierarchicalFacets: this.hierarchicalFacets.concat([hierarchicalFacet])\n });\n },\n /**\n * Add a refinement on a \"normal\" facet\n * @method\n * @param {string} facet attribute to apply the faceting on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addFacetRefinement: function addFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.addRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Exclude a value from a \"normal\" facet\n * @method\n * @param {string} facet attribute to apply the exclusion on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addExcludeRefinement: function addExcludeRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.addRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Adds a refinement on a disjunctive facet.\n * @method\n * @param {string} facet attribute to apply the faceting on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addDisjunctiveFacetRefinement: function addDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n\n if (RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.addRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * addTagRefinement adds a tag to the list used to filter the results\n * @param {string} tag tag to be added\n * @return {SearchParameters}\n */\n addTagRefinement: function addTagRefinement(tag) {\n if (this.isTagRefined(tag)) return this;\n\n var modification = {\n tagRefinements: this.tagRefinements.concat(tag)\n };\n\n return this.setQueryParameters(modification);\n },\n /**\n * Remove a facet from the facets attribute of the helper configuration, if it\n * is present.\n * @method\n * @param {string} facet facet name to remove\n * @return {SearchParameters}\n */\n removeFacet: function removeFacet(facet) {\n if (!this.isConjunctiveFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n facets: filter(this.facets, function(f) {\n return f !== facet;\n })\n });\n },\n /**\n * Remove a disjunctive facet from the disjunctiveFacets attribute of the\n * helper configuration, if it is present.\n * @method\n * @param {string} facet disjunctive facet name to remove\n * @return {SearchParameters}\n */\n removeDisjunctiveFacet: function removeDisjunctiveFacet(facet) {\n if (!this.isDisjunctiveFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n disjunctiveFacets: filter(this.disjunctiveFacets, function(f) {\n return f !== facet;\n })\n });\n },\n /**\n * Remove a hierarchical facet from the hierarchicalFacets attribute of the\n * helper configuration, if it is present.\n * @method\n * @param {string} facet hierarchical facet name to remove\n * @return {SearchParameters}\n */\n removeHierarchicalFacet: function removeHierarchicalFacet(facet) {\n if (!this.isHierarchicalFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n hierarchicalFacets: filter(this.hierarchicalFacets, function(f) {\n return f.name !== facet;\n })\n });\n },\n /**\n * Remove a refinement set on facet. If a value is provided, it will clear the\n * refinement for the given value, otherwise it will clear all the refinement\n * values for the faceted attribute.\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} [value] value used to filter\n * @return {SearchParameters}\n */\n removeFacetRefinement: function removeFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.removeRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Remove a negative refinement on a facet\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} value value used to filter\n * @return {SearchParameters}\n */\n removeExcludeRefinement: function removeExcludeRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.removeRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Remove a refinement on a disjunctive facet\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} value value used to filter\n * @return {SearchParameters}\n */\n removeDisjunctiveFacetRefinement: function removeDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.removeRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * Remove a tag from the list of tag refinements\n * @method\n * @param {string} tag the tag to remove\n * @return {SearchParameters}\n */\n removeTagRefinement: function removeTagRefinement(tag) {\n if (!this.isTagRefined(tag)) return this;\n\n var modification = {\n tagRefinements: filter(this.tagRefinements, function(t) { return t !== tag; })\n };\n\n return this.setQueryParameters(modification);\n },\n /**\n * Generic toggle refinement method to use with facet, disjunctive facets\n * and hierarchical facets\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {SearchParameters}\n * @throws will throw an error if the facet is not declared in the settings of the helper\n * @deprecated since version 2.19.0, see {@link SearchParameters#toggleFacetRefinement}\n */\n toggleRefinement: function toggleRefinement(facet, value) {\n return this.toggleFacetRefinement(facet, value);\n },\n /**\n * Generic toggle refinement method to use with facet, disjunctive facets\n * and hierarchical facets\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {SearchParameters}\n * @throws will throw an error if the facet is not declared in the settings of the helper\n */\n toggleFacetRefinement: function toggleFacetRefinement(facet, value) {\n if (this.isHierarchicalFacet(facet)) {\n return this.toggleHierarchicalFacetRefinement(facet, value);\n } else if (this.isConjunctiveFacet(facet)) {\n return this.toggleConjunctiveFacetRefinement(facet, value);\n } else if (this.isDisjunctiveFacet(facet)) {\n return this.toggleDisjunctiveFacetRefinement(facet, value);\n }\n\n throw new Error('Cannot refine the undeclared facet ' + facet +\n '; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets');\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleConjunctiveFacetRefinement: function toggleConjunctiveFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.toggleRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleExcludeFacetRefinement: function toggleExcludeFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.toggleRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleDisjunctiveFacetRefinement: function toggleDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.toggleRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleHierarchicalFacetRefinement: function toggleHierarchicalFacetRefinement(facet, value) {\n if (!this.isHierarchicalFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration');\n }\n\n var separator = this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facet));\n\n var mod = {};\n\n var upOneOrMultipleLevel = this.hierarchicalFacetsRefinements[facet] !== undefined &&\n this.hierarchicalFacetsRefinements[facet].length > 0 && (\n // remove current refinement:\n // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`\n this.hierarchicalFacetsRefinements[facet][0] === value ||\n // remove a parent refinement of the current refinement:\n // - refinement was 'beer > IPA > Flying dog'\n // - call is toggleRefine('beer > IPA')\n // - refinement should be `beer`\n this.hierarchicalFacetsRefinements[facet][0].indexOf(value + separator) === 0\n );\n\n if (upOneOrMultipleLevel) {\n if (value.indexOf(separator) === -1) {\n // go back to root level\n mod[facet] = [];\n } else {\n mod[facet] = [value.slice(0, value.lastIndexOf(separator))];\n }\n } else {\n mod[facet] = [value];\n }\n\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaults({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n\n /**\n * Adds a refinement on a hierarchical facet.\n * @param {string} facet the facet name\n * @param {string} path the hierarchical facet path\n * @return {SearchParameter} the new state\n * @throws Error if the facet is not defined or if the facet is refined\n */\n addHierarchicalFacetRefinement: function(facet, path) {\n if (this.isHierarchicalFacetRefined(facet)) {\n throw new Error(facet + ' is already refined.');\n }\n var mod = {};\n mod[facet] = [path];\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaults({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n\n /**\n * Removes the refinement set on a hierarchical facet.\n * @param {string} facet the facet name\n * @return {SearchParameter} the new state\n * @throws Error if the facet is not defined or if the facet is not refined\n */\n removeHierarchicalFacetRefinement: function(facet) {\n if (!this.isHierarchicalFacetRefined(facet)) {\n throw new Error(facet + ' is not refined.');\n }\n var mod = {};\n mod[facet] = [];\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaults({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n /**\n * Switch the tag refinement\n * @method\n * @param {string} tag the tag to remove or add\n * @return {SearchParameters}\n */\n toggleTagRefinement: function toggleTagRefinement(tag) {\n if (this.isTagRefined(tag)) {\n return this.removeTagRefinement(tag);\n }\n\n return this.addTagRefinement(tag);\n },\n /**\n * Test if the facet name is from one of the disjunctive facets\n * @method\n * @param {string} facet facet name to test\n * @return {boolean}\n */\n isDisjunctiveFacet: function(facet) {\n return indexOf(this.disjunctiveFacets, facet) > -1;\n },\n /**\n * Test if the facet name is from one of the hierarchical facets\n * @method\n * @param {string} facetName facet name to test\n * @return {boolean}\n */\n isHierarchicalFacet: function(facetName) {\n return this.getHierarchicalFacetByName(facetName) !== undefined;\n },\n /**\n * Test if the facet name is from one of the conjunctive/normal facets\n * @method\n * @param {string} facet facet name to test\n * @return {boolean}\n */\n isConjunctiveFacet: function(facet) {\n return indexOf(this.facets, facet) > -1;\n },\n /**\n * Returns true if the facet is refined, either for a specific value or in\n * general.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value, optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} returns true if refined\n */\n isFacetRefined: function isFacetRefined(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n return RefinementList.isRefined(this.facetsRefinements, facet, value);\n },\n /**\n * Returns true if the facet contains exclusions or if a specific value is\n * excluded.\n *\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} [value] optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} returns true if refined\n */\n isExcludeRefined: function isExcludeRefined(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n return RefinementList.isRefined(this.facetsExcludes, facet, value);\n },\n /**\n * Returns true if the facet contains a refinement, or if a value passed is a\n * refinement for the facet.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value optional, will test if the value is used for refinement\n * if there is one, otherwise will test if the facet contains any refinement\n * @return {boolean}\n */\n isDisjunctiveFacetRefined: function isDisjunctiveFacetRefined(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n return RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value);\n },\n /**\n * Returns true if the facet contains a refinement, or if a value passed is a\n * refinement for the facet.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value optional, will test if the value is used for refinement\n * if there is one, otherwise will test if the facet contains any refinement\n * @return {boolean}\n */\n isHierarchicalFacetRefined: function isHierarchicalFacetRefined(facet, value) {\n if (!this.isHierarchicalFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration');\n }\n\n var refinements = this.getHierarchicalRefinement(facet);\n\n if (!value) {\n return refinements.length > 0;\n }\n\n return indexOf(refinements, value) !== -1;\n },\n /**\n * Test if the triple (attribute, operator, value) is already refined.\n * If only the attribute and the operator are provided, it tests if the\n * contains any refinement value.\n * @method\n * @param {string} attribute attribute for which the refinement is applied\n * @param {string} [operator] operator of the refinement\n * @param {string} [value] value of the refinement\n * @return {boolean} true if it is refined\n */\n isNumericRefined: function isNumericRefined(attribute, operator, value) {\n if (isUndefined(value) && isUndefined(operator)) {\n return !!this.numericRefinements[attribute];\n }\n\n var isOperatorDefined = this.numericRefinements[attribute] &&\n !isUndefined(this.numericRefinements[attribute][operator]);\n\n if (isUndefined(value) || !isOperatorDefined) {\n return isOperatorDefined;\n }\n\n var parsedValue = valToNumber(value);\n var isAttributeValueDefined = !isUndefined(\n findArray(this.numericRefinements[attribute][operator], parsedValue)\n );\n\n return isOperatorDefined && isAttributeValueDefined;\n },\n /**\n * Returns true if the tag refined, false otherwise\n * @method\n * @param {string} tag the tag to check\n * @return {boolean}\n */\n isTagRefined: function isTagRefined(tag) {\n return indexOf(this.tagRefinements, tag) !== -1;\n },\n /**\n * Returns the list of all disjunctive facets refined\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {string[]}\n */\n getRefinedDisjunctiveFacets: function getRefinedDisjunctiveFacets() {\n // attributes used for numeric filter can also be disjunctive\n var disjunctiveNumericRefinedFacets = intersection(\n keys(this.numericRefinements),\n this.disjunctiveFacets\n );\n\n return keys(this.disjunctiveFacetsRefinements)\n .concat(disjunctiveNumericRefinedFacets)\n .concat(this.getRefinedHierarchicalFacets());\n },\n /**\n * Returns the list of all disjunctive facets refined\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {string[]}\n */\n getRefinedHierarchicalFacets: function getRefinedHierarchicalFacets() {\n return intersection(\n // enforce the order between the two arrays,\n // so that refinement name index === hierarchical facet index\n map(this.hierarchicalFacets, 'name'),\n keys(this.hierarchicalFacetsRefinements)\n );\n },\n /**\n * Returned the list of all disjunctive facets not refined\n * @method\n * @return {string[]}\n */\n getUnrefinedDisjunctiveFacets: function() {\n var refinedFacets = this.getRefinedDisjunctiveFacets();\n\n return filter(this.disjunctiveFacets, function(f) {\n return indexOf(refinedFacets, f) === -1;\n });\n },\n\n managedParameters: [\n 'index',\n 'facets', 'disjunctiveFacets', 'facetsRefinements',\n 'facetsExcludes', 'disjunctiveFacetsRefinements',\n 'numericRefinements', 'tagRefinements', 'hierarchicalFacets', 'hierarchicalFacetsRefinements'\n ],\n getQueryParams: function getQueryParams() {\n var managedParameters = this.managedParameters;\n\n var queryParams = {};\n\n forOwn(this, function(paramValue, paramName) {\n if (indexOf(managedParameters, paramName) === -1 && paramValue !== undefined) {\n queryParams[paramName] = paramValue;\n }\n });\n\n return queryParams;\n },\n /**\n * Let the user retrieve any parameter value from the SearchParameters\n * @param {string} paramName name of the parameter\n * @return {any} the value of the parameter\n */\n getQueryParameter: function getQueryParameter(paramName) {\n if (!this.hasOwnProperty(paramName)) {\n throw new Error(\n \"Parameter '\" + paramName + \"' is not an attribute of SearchParameters \" +\n '(http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)');\n }\n\n return this[paramName];\n },\n /**\n * Let the user set a specific value for a given parameter. Will return the\n * same instance if the parameter is invalid or if the value is the same as the\n * previous one.\n * @method\n * @param {string} parameter the parameter name\n * @param {any} value the value to be set, must be compliant with the definition\n * of the attribute on the object\n * @return {SearchParameters} the updated state\n */\n setQueryParameter: function setParameter(parameter, value) {\n if (this[parameter] === value) return this;\n\n var modification = {};\n\n modification[parameter] = value;\n\n return this.setQueryParameters(modification);\n },\n /**\n * Let the user set any of the parameters with a plain object.\n * @method\n * @param {object} params all the keys and the values to be updated\n * @return {SearchParameters} a new updated instance\n */\n setQueryParameters: function setQueryParameters(params) {\n if (!params) return this;\n\n var error = SearchParameters.validate(this, params);\n\n if (error) {\n throw error;\n }\n\n var parsedParams = SearchParameters._parseNumbers(params);\n\n return this.mutateMe(function mergeWith(newInstance) {\n var ks = keys(params);\n\n forEach(ks, function(k) {\n newInstance[k] = parsedParams[k];\n });\n\n return newInstance;\n });\n },\n\n /**\n * Returns an object with only the selected attributes.\n * @param {string[]} filters filters to retrieve only a subset of the state. It\n * accepts strings that can be either attributes of the SearchParameters (e.g. hitsPerPage)\n * or attributes of the index with the notation 'attribute:nameOfMyAttribute'\n * @return {object}\n */\n filter: function(filters) {\n return filterState(this, filters);\n },\n /**\n * Helper function to make it easier to build new instances from a mutating\n * function\n * @private\n * @param {function} fn newMutableState -> previousState -> () function that will\n * change the value of the newMutable to the desired state\n * @return {SearchParameters} a new instance with the specified modifications applied\n */\n mutateMe: function mutateMe(fn) {\n var newState = new this.constructor(this);\n\n fn(newState, this);\n return newState;\n },\n\n /**\n * Helper function to get the hierarchicalFacet separator or the default one (`>`)\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.separator or `>` as default\n */\n _getHierarchicalFacetSortBy: function(hierarchicalFacet) {\n return hierarchicalFacet.sortBy || ['isRefined:desc', 'name:asc'];\n },\n\n /**\n * Helper function to get the hierarchicalFacet separator or the default one (`>`)\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.separator or `>` as default\n */\n _getHierarchicalFacetSeparator: function(hierarchicalFacet) {\n return hierarchicalFacet.separator || ' > ';\n },\n\n /**\n * Helper function to get the hierarchicalFacet prefix path or null\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.rootPath or null as default\n */\n _getHierarchicalRootPath: function(hierarchicalFacet) {\n return hierarchicalFacet.rootPath || null;\n },\n\n /**\n * Helper function to check if we show the parent level of the hierarchicalFacet\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.showParentLevel or true as default\n */\n _getHierarchicalShowParentLevel: function(hierarchicalFacet) {\n if (typeof hierarchicalFacet.showParentLevel === 'boolean') {\n return hierarchicalFacet.showParentLevel;\n }\n return true;\n },\n\n /**\n * Helper function to get the hierarchicalFacet by it's name\n * @param {string} hierarchicalFacetName\n * @return {object} a hierarchicalFacet\n */\n getHierarchicalFacetByName: function(hierarchicalFacetName) {\n return find(\n this.hierarchicalFacets,\n {name: hierarchicalFacetName}\n );\n },\n\n /**\n * Get the current breadcrumb for a hierarchical facet, as an array\n * @param {string} facetName Hierarchical facet name\n * @return {array.} the path as an array of string\n */\n getHierarchicalFacetBreadcrumb: function(facetName) {\n if (!this.isHierarchicalFacet(facetName)) {\n throw new Error(\n 'Cannot get the breadcrumb of an unknown hierarchical facet: `' + facetName + '`');\n }\n\n var refinement = this.getHierarchicalRefinement(facetName)[0];\n if (!refinement) return [];\n\n var separator = this._getHierarchicalFacetSeparator(\n this.getHierarchicalFacetByName(facetName)\n );\n var path = refinement.split(separator);\n return map(path, trim);\n },\n\n toString: function() {\n return JSON.stringify(this, null, 2);\n }\n};\n\n/**\n * Callback used for clearRefinement method\n * @callback SearchParameters.clearCallback\n * @param {OperatorList|FacetList} value the value of the filter\n * @param {string} key the current attribute name\n * @param {string} type `numeric`, `disjunctiveFacet`, `conjunctiveFacet`, `hierarchicalFacet` or `exclude`\n * depending on the type of facet\n * @return {boolean} `true` if the element should be removed. `false` otherwise.\n */\nmodule.exports = SearchParameters;\n","/**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\nfunction compact(array) {\n var index = -1,\n length = array == null ? 0 : array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[resIndex++] = value;\n }\n }\n return result;\n}\n\nmodule.exports = compact;\n","/**\n * The base implementation of `_.sum` and `_.sumBy` without support for\n * iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the sum.\n */\nfunction baseSum(array, iteratee) {\n var result,\n index = -1,\n length = array.length;\n\n while (++index < length) {\n var current = iteratee(array[index]);\n if (current !== undefined) {\n result = result === undefined ? current : (result + current);\n }\n }\n return result;\n}\n\nmodule.exports = baseSum;\n","var baseIteratee = require('./_baseIteratee'),\n baseSum = require('./_baseSum');\n\n/**\n * This method is like `_.sum` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the value to be summed.\n * The iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Math\n * @param {Array} array The array to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee invoked per element.\n * @returns {number} Returns the sum.\n * @example\n *\n * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];\n *\n * _.sumBy(objects, function(o) { return o.n; });\n * // => 20\n *\n * // The `_.property` iteratee shorthand.\n * _.sumBy(objects, 'n');\n * // => 20\n */\nfunction sumBy(array, iteratee) {\n return (array && array.length)\n ? baseSum(array, baseIteratee(iteratee, 2))\n : 0;\n}\n\nmodule.exports = sumBy;\n","var arrayMap = require('./_arrayMap');\n\n/**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\nfunction baseValues(object, props) {\n return arrayMap(props, function(key) {\n return object[key];\n });\n}\n\nmodule.exports = baseValues;\n","var baseValues = require('./_baseValues'),\n keys = require('./keys');\n\n/**\n * Creates an array of the own enumerable string keyed property values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.values(new Foo);\n * // => [1, 2] (iteration order is not guaranteed)\n *\n * _.values('hi');\n * // => ['h', 'i']\n */\nfunction values(object) {\n return object == null ? [] : baseValues(object, keys(object));\n}\n\nmodule.exports = values;\n","var baseIndexOf = require('./_baseIndexOf'),\n isArrayLike = require('./isArrayLike'),\n isString = require('./isString'),\n toInteger = require('./toInteger'),\n values = require('./values');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * Checks if `value` is in `collection`. If `collection` is a string, it's\n * checked for a substring of `value`, otherwise\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * is used for equality comparisons. If `fromIndex` is negative, it's used as\n * the offset from the end of `collection`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @param {*} value The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {boolean} Returns `true` if `value` is found, else `false`.\n * @example\n *\n * _.includes([1, 2, 3], 1);\n * // => true\n *\n * _.includes([1, 2, 3], 1, 2);\n * // => false\n *\n * _.includes({ 'a': 1, 'b': 2 }, 1);\n * // => true\n *\n * _.includes('abcd', 'bc');\n * // => true\n */\nfunction includes(collection, value, fromIndex, guard) {\n collection = isArrayLike(collection) ? collection : values(collection);\n fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;\n\n var length = collection.length;\n if (fromIndex < 0) {\n fromIndex = nativeMax(length + fromIndex, 0);\n }\n return isString(collection)\n ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)\n : (!!length && baseIndexOf(collection, value, fromIndex) > -1);\n}\n\nmodule.exports = includes;\n","/**\n * The base implementation of `_.sortBy` which uses `comparer` to define the\n * sort order of `array` and replaces criteria objects with their corresponding\n * values.\n *\n * @private\n * @param {Array} array The array to sort.\n * @param {Function} comparer The function to define sort order.\n * @returns {Array} Returns `array`.\n */\nfunction baseSortBy(array, comparer) {\n var length = array.length;\n\n array.sort(comparer);\n while (length--) {\n array[length] = array[length].value;\n }\n return array;\n}\n\nmodule.exports = baseSortBy;\n","var isSymbol = require('./isSymbol');\n\n/**\n * Compares values to sort them in ascending order.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {number} Returns the sort order indicator for `value`.\n */\nfunction compareAscending(value, other) {\n if (value !== other) {\n var valIsDefined = value !== undefined,\n valIsNull = value === null,\n valIsReflexive = value === value,\n valIsSymbol = isSymbol(value);\n\n var othIsDefined = other !== undefined,\n othIsNull = other === null,\n othIsReflexive = other === other,\n othIsSymbol = isSymbol(other);\n\n if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||\n (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||\n (valIsNull && othIsDefined && othIsReflexive) ||\n (!valIsDefined && othIsReflexive) ||\n !valIsReflexive) {\n return 1;\n }\n if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||\n (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||\n (othIsNull && valIsDefined && valIsReflexive) ||\n (!othIsDefined && valIsReflexive) ||\n !othIsReflexive) {\n return -1;\n }\n }\n return 0;\n}\n\nmodule.exports = compareAscending;\n","var compareAscending = require('./_compareAscending');\n\n/**\n * Used by `_.orderBy` to compare multiple properties of a value to another\n * and stable sort them.\n *\n * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,\n * specify an order of \"desc\" for descending or \"asc\" for ascending sort order\n * of corresponding values.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {boolean[]|string[]} orders The order to sort by for each property.\n * @returns {number} Returns the sort order indicator for `object`.\n */\nfunction compareMultiple(object, other, orders) {\n var index = -1,\n objCriteria = object.criteria,\n othCriteria = other.criteria,\n length = objCriteria.length,\n ordersLength = orders.length;\n\n while (++index < length) {\n var result = compareAscending(objCriteria[index], othCriteria[index]);\n if (result) {\n if (index >= ordersLength) {\n return result;\n }\n var order = orders[index];\n return result * (order == 'desc' ? -1 : 1);\n }\n }\n // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications\n // that causes it, under certain circumstances, to provide the same value for\n // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247\n // for more details.\n //\n // This also ensures a stable sort in V8 and other engines.\n // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.\n return object.index - other.index;\n}\n\nmodule.exports = compareMultiple;\n","var arrayMap = require('./_arrayMap'),\n baseIteratee = require('./_baseIteratee'),\n baseMap = require('./_baseMap'),\n baseSortBy = require('./_baseSortBy'),\n baseUnary = require('./_baseUnary'),\n compareMultiple = require('./_compareMultiple'),\n identity = require('./identity');\n\n/**\n * The base implementation of `_.orderBy` without param guards.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {string[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\nfunction baseOrderBy(collection, iteratees, orders) {\n var index = -1;\n iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));\n\n var result = baseMap(collection, function(value, key, collection) {\n var criteria = arrayMap(iteratees, function(iteratee) {\n return iteratee(value);\n });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return baseSortBy(result, function(object, other) {\n return compareMultiple(object, other, orders);\n });\n}\n\nmodule.exports = baseOrderBy;\n","var baseOrderBy = require('./_baseOrderBy'),\n isArray = require('./isArray');\n\n/**\n * This method is like `_.sortBy` except that it allows specifying the sort\n * orders of the iteratees to sort by. If `orders` is unspecified, all values\n * are sorted in ascending order. Otherwise, specify an order of \"desc\" for\n * descending or \"asc\" for ascending sort order of corresponding values.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]\n * The iteratees to sort by.\n * @param {string[]} [orders] The sort orders of `iteratees`.\n * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 34 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'barney', 'age': 36 }\n * ];\n *\n * // Sort by `user` in ascending order and by `age` in descending order.\n * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);\n * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]\n */\nfunction orderBy(collection, iteratees, orders, guard) {\n if (collection == null) {\n return [];\n }\n if (!isArray(iteratees)) {\n iteratees = iteratees == null ? [] : [iteratees];\n }\n orders = guard ? undefined : orders;\n if (!isArray(orders)) {\n orders = orders == null ? [] : [orders];\n }\n return baseOrderBy(collection, iteratees, orders);\n}\n\nmodule.exports = orderBy;\n","var WeakMap = require('./_WeakMap');\n\n/** Used to store function metadata. */\nvar metaMap = WeakMap && new WeakMap;\n\nmodule.exports = metaMap;\n","var identity = require('./identity'),\n metaMap = require('./_metaMap');\n\n/**\n * The base implementation of `setData` without support for hot loop shorting.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\nvar baseSetData = !metaMap ? identity : function(func, data) {\n metaMap.set(func, data);\n return func;\n};\n\nmodule.exports = baseSetData;\n","var baseCreate = require('./_baseCreate'),\n isObject = require('./isObject');\n\n/**\n * Creates a function that produces an instance of `Ctor` regardless of\n * whether it was invoked as part of a `new` expression or by `call` or `apply`.\n *\n * @private\n * @param {Function} Ctor The constructor to wrap.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createCtor(Ctor) {\n return function() {\n // Use a `switch` statement to work with class constructors. See\n // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist\n // for more details.\n var args = arguments;\n switch (args.length) {\n case 0: return new Ctor;\n case 1: return new Ctor(args[0]);\n case 2: return new Ctor(args[0], args[1]);\n case 3: return new Ctor(args[0], args[1], args[2]);\n case 4: return new Ctor(args[0], args[1], args[2], args[3]);\n case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);\n case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);\n case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);\n }\n var thisBinding = baseCreate(Ctor.prototype),\n result = Ctor.apply(thisBinding, args);\n\n // Mimic the constructor's `return` behavior.\n // See https://es5.github.io/#x13.2.2 for more details.\n return isObject(result) ? result : thisBinding;\n };\n}\n\nmodule.exports = createCtor;\n","var createCtor = require('./_createCtor'),\n root = require('./_root');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1;\n\n/**\n * Creates a function that wraps `func` to invoke it with the optional `this`\n * binding of `thisArg`.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createBind(func, bitmask, thisArg) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return fn.apply(isBind ? thisArg : this, arguments);\n }\n return wrapper;\n}\n\nmodule.exports = createBind;\n","/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * Creates an array that is the composition of partially applied arguments,\n * placeholders, and provided arguments into a single array of arguments.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to prepend to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\nfunction composeArgs(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersLength = holders.length,\n leftIndex = -1,\n leftLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(leftLength + rangeLength),\n isUncurried = !isCurried;\n\n while (++leftIndex < leftLength) {\n result[leftIndex] = partials[leftIndex];\n }\n while (++argsIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[holders[argsIndex]] = args[argsIndex];\n }\n }\n while (rangeLength--) {\n result[leftIndex++] = args[argsIndex++];\n }\n return result;\n}\n\nmodule.exports = composeArgs;\n","/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * This function is like `composeArgs` except that the arguments composition\n * is tailored for `_.partialRight`.\n *\n * @private\n * @param {Array} args The provided arguments.\n * @param {Array} partials The arguments to append to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @params {boolean} [isCurried] Specify composing for a curried function.\n * @returns {Array} Returns the new array of composed arguments.\n */\nfunction composeArgsRight(args, partials, holders, isCurried) {\n var argsIndex = -1,\n argsLength = args.length,\n holdersIndex = -1,\n holdersLength = holders.length,\n rightIndex = -1,\n rightLength = partials.length,\n rangeLength = nativeMax(argsLength - holdersLength, 0),\n result = Array(rangeLength + rightLength),\n isUncurried = !isCurried;\n\n while (++argsIndex < rangeLength) {\n result[argsIndex] = args[argsIndex];\n }\n var offset = argsIndex;\n while (++rightIndex < rightLength) {\n result[offset + rightIndex] = partials[rightIndex];\n }\n while (++holdersIndex < holdersLength) {\n if (isUncurried || argsIndex < argsLength) {\n result[offset + holders[holdersIndex]] = args[argsIndex++];\n }\n }\n return result;\n}\n\nmodule.exports = composeArgsRight;\n","/**\n * Gets the number of `placeholder` occurrences in `array`.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} placeholder The placeholder to search for.\n * @returns {number} Returns the placeholder count.\n */\nfunction countHolders(array, placeholder) {\n var length = array.length,\n result = 0;\n\n while (length--) {\n if (array[length] === placeholder) {\n ++result;\n }\n }\n return result;\n}\n\nmodule.exports = countHolders;\n","/**\n * The function whose prototype chain sequence wrappers inherit from.\n *\n * @private\n */\nfunction baseLodash() {\n // No operation performed.\n}\n\nmodule.exports = baseLodash;\n","var baseCreate = require('./_baseCreate'),\n baseLodash = require('./_baseLodash');\n\n/** Used as references for the maximum length and index of an array. */\nvar MAX_ARRAY_LENGTH = 4294967295;\n\n/**\n * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.\n *\n * @private\n * @constructor\n * @param {*} value The value to wrap.\n */\nfunction LazyWrapper(value) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__dir__ = 1;\n this.__filtered__ = false;\n this.__iteratees__ = [];\n this.__takeCount__ = MAX_ARRAY_LENGTH;\n this.__views__ = [];\n}\n\n// Ensure `LazyWrapper` is an instance of `baseLodash`.\nLazyWrapper.prototype = baseCreate(baseLodash.prototype);\nLazyWrapper.prototype.constructor = LazyWrapper;\n\nmodule.exports = LazyWrapper;\n","/**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\nfunction noop() {\n // No operation performed.\n}\n\nmodule.exports = noop;\n","var metaMap = require('./_metaMap'),\n noop = require('./noop');\n\n/**\n * Gets metadata for `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {*} Returns the metadata for `func`.\n */\nvar getData = !metaMap ? noop : function(func) {\n return metaMap.get(func);\n};\n\nmodule.exports = getData;\n","/** Used to lookup unminified function names. */\nvar realNames = {};\n\nmodule.exports = realNames;\n","var realNames = require('./_realNames');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Gets the name of `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {string} Returns the function name.\n */\nfunction getFuncName(func) {\n var result = (func.name + ''),\n array = realNames[result],\n length = hasOwnProperty.call(realNames, result) ? array.length : 0;\n\n while (length--) {\n var data = array[length],\n otherFunc = data.func;\n if (otherFunc == null || otherFunc == func) {\n return data.name;\n }\n }\n return result;\n}\n\nmodule.exports = getFuncName;\n","var baseCreate = require('./_baseCreate'),\n baseLodash = require('./_baseLodash');\n\n/**\n * The base constructor for creating `lodash` wrapper objects.\n *\n * @private\n * @param {*} value The value to wrap.\n * @param {boolean} [chainAll] Enable explicit method chain sequences.\n */\nfunction LodashWrapper(value, chainAll) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__chain__ = !!chainAll;\n this.__index__ = 0;\n this.__values__ = undefined;\n}\n\nLodashWrapper.prototype = baseCreate(baseLodash.prototype);\nLodashWrapper.prototype.constructor = LodashWrapper;\n\nmodule.exports = LodashWrapper;\n","var LazyWrapper = require('./_LazyWrapper'),\n LodashWrapper = require('./_LodashWrapper'),\n copyArray = require('./_copyArray');\n\n/**\n * Creates a clone of `wrapper`.\n *\n * @private\n * @param {Object} wrapper The wrapper to clone.\n * @returns {Object} Returns the cloned wrapper.\n */\nfunction wrapperClone(wrapper) {\n if (wrapper instanceof LazyWrapper) {\n return wrapper.clone();\n }\n var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);\n result.__actions__ = copyArray(wrapper.__actions__);\n result.__index__ = wrapper.__index__;\n result.__values__ = wrapper.__values__;\n return result;\n}\n\nmodule.exports = wrapperClone;\n","var LazyWrapper = require('./_LazyWrapper'),\n LodashWrapper = require('./_LodashWrapper'),\n baseLodash = require('./_baseLodash'),\n isArray = require('./isArray'),\n isObjectLike = require('./isObjectLike'),\n wrapperClone = require('./_wrapperClone');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates a `lodash` object which wraps `value` to enable implicit method\n * chain sequences. Methods that operate on and return arrays, collections,\n * and functions can be chained together. Methods that retrieve a single value\n * or may return a primitive value will automatically end the chain sequence\n * and return the unwrapped value. Otherwise, the value must be unwrapped\n * with `_#value`.\n *\n * Explicit chain sequences, which must be unwrapped with `_#value`, may be\n * enabled using `_.chain`.\n *\n * The execution of chained methods is lazy, that is, it's deferred until\n * `_#value` is implicitly or explicitly called.\n *\n * Lazy evaluation allows several methods to support shortcut fusion.\n * Shortcut fusion is an optimization to merge iteratee calls; this avoids\n * the creation of intermediate arrays and can greatly reduce the number of\n * iteratee executions. Sections of a chain sequence qualify for shortcut\n * fusion if the section is applied to an array and iteratees accept only\n * one argument. The heuristic for whether a section qualifies for shortcut\n * fusion is subject to change.\n *\n * Chaining is supported in custom builds as long as the `_#value` method is\n * directly or indirectly included in the build.\n *\n * In addition to lodash methods, wrappers have `Array` and `String` methods.\n *\n * The wrapper `Array` methods are:\n * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`\n *\n * The wrapper `String` methods are:\n * `replace` and `split`\n *\n * The wrapper methods that support shortcut fusion are:\n * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,\n * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,\n * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`\n *\n * The chainable wrapper methods are:\n * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,\n * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,\n * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,\n * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,\n * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,\n * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,\n * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,\n * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,\n * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,\n * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,\n * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,\n * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,\n * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,\n * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,\n * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,\n * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,\n * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,\n * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,\n * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,\n * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,\n * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,\n * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,\n * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,\n * `zipObject`, `zipObjectDeep`, and `zipWith`\n *\n * The wrapper methods that are **not** chainable by default are:\n * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,\n * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,\n * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,\n * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,\n * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,\n * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,\n * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,\n * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,\n * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,\n * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,\n * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,\n * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,\n * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,\n * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,\n * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,\n * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,\n * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,\n * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,\n * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,\n * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,\n * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,\n * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,\n * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,\n * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,\n * `upperFirst`, `value`, and `words`\n *\n * @name _\n * @constructor\n * @category Seq\n * @param {*} value The value to wrap in a `lodash` instance.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var wrapped = _([1, 2, 3]);\n *\n * // Returns an unwrapped value.\n * wrapped.reduce(_.add);\n * // => 6\n *\n * // Returns a wrapped value.\n * var squares = wrapped.map(square);\n *\n * _.isArray(squares);\n * // => false\n *\n * _.isArray(squares.value());\n * // => true\n */\nfunction lodash(value) {\n if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {\n if (value instanceof LodashWrapper) {\n return value;\n }\n if (hasOwnProperty.call(value, '__wrapped__')) {\n return wrapperClone(value);\n }\n }\n return new LodashWrapper(value);\n}\n\n// Ensure wrappers are instances of `baseLodash`.\nlodash.prototype = baseLodash.prototype;\nlodash.prototype.constructor = lodash;\n\nmodule.exports = lodash;\n","var LazyWrapper = require('./_LazyWrapper'),\n getData = require('./_getData'),\n getFuncName = require('./_getFuncName'),\n lodash = require('./wrapperLodash');\n\n/**\n * Checks if `func` has a lazy counterpart.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` has a lazy counterpart,\n * else `false`.\n */\nfunction isLaziable(func) {\n var funcName = getFuncName(func),\n other = lodash[funcName];\n\n if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {\n return false;\n }\n if (func === other) {\n return true;\n }\n var data = getData(other);\n return !!data && func === data[0];\n}\n\nmodule.exports = isLaziable;\n","var baseSetData = require('./_baseSetData'),\n shortOut = require('./_shortOut');\n\n/**\n * Sets metadata for `func`.\n *\n * **Note:** If this function becomes hot, i.e. is invoked a lot in a short\n * period of time, it will trip its breaker and transition to an identity\n * function to avoid garbage collection pauses in V8. See\n * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)\n * for more details.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\nvar setData = shortOut(baseSetData);\n\nmodule.exports = setData;\n","/** Used to match wrap detail comments. */\nvar reWrapDetails = /\\{\\n\\/\\* \\[wrapped with (.+)\\] \\*/,\n reSplitDetails = /,? & /;\n\n/**\n * Extracts wrapper details from the `source` body comment.\n *\n * @private\n * @param {string} source The source to inspect.\n * @returns {Array} Returns the wrapper details.\n */\nfunction getWrapDetails(source) {\n var match = source.match(reWrapDetails);\n return match ? match[1].split(reSplitDetails) : [];\n}\n\nmodule.exports = getWrapDetails;\n","/** Used to match wrap detail comments. */\nvar reWrapComment = /\\{(?:\\n\\/\\* \\[wrapped with .+\\] \\*\\/)?\\n?/;\n\n/**\n * Inserts wrapper `details` in a comment at the top of the `source` body.\n *\n * @private\n * @param {string} source The source to modify.\n * @returns {Array} details The details to insert.\n * @returns {string} Returns the modified source.\n */\nfunction insertWrapDetails(source, details) {\n var length = details.length;\n if (!length) {\n return source;\n }\n var lastIndex = length - 1;\n details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];\n details = details.join(length > 2 ? ', ' : ' ');\n return source.replace(reWrapComment, '{\\n/* [wrapped with ' + details + '] */\\n');\n}\n\nmodule.exports = insertWrapDetails;\n","var arrayEach = require('./_arrayEach'),\n arrayIncludes = require('./_arrayIncludes');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64,\n WRAP_ARY_FLAG = 128,\n WRAP_REARG_FLAG = 256,\n WRAP_FLIP_FLAG = 512;\n\n/** Used to associate wrap methods with their bit flags. */\nvar wrapFlags = [\n ['ary', WRAP_ARY_FLAG],\n ['bind', WRAP_BIND_FLAG],\n ['bindKey', WRAP_BIND_KEY_FLAG],\n ['curry', WRAP_CURRY_FLAG],\n ['curryRight', WRAP_CURRY_RIGHT_FLAG],\n ['flip', WRAP_FLIP_FLAG],\n ['partial', WRAP_PARTIAL_FLAG],\n ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],\n ['rearg', WRAP_REARG_FLAG]\n];\n\n/**\n * Updates wrapper `details` based on `bitmask` flags.\n *\n * @private\n * @returns {Array} details The details to modify.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Array} Returns `details`.\n */\nfunction updateWrapDetails(details, bitmask) {\n arrayEach(wrapFlags, function(pair) {\n var value = '_.' + pair[0];\n if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {\n details.push(value);\n }\n });\n return details.sort();\n}\n\nmodule.exports = updateWrapDetails;\n","var getWrapDetails = require('./_getWrapDetails'),\n insertWrapDetails = require('./_insertWrapDetails'),\n setToString = require('./_setToString'),\n updateWrapDetails = require('./_updateWrapDetails');\n\n/**\n * Sets the `toString` method of `wrapper` to mimic the source of `reference`\n * with wrapper details in a comment at the top of the source body.\n *\n * @private\n * @param {Function} wrapper The function to modify.\n * @param {Function} reference The reference function.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @returns {Function} Returns `wrapper`.\n */\nfunction setWrapToString(wrapper, reference, bitmask) {\n var source = (reference + '');\n return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));\n}\n\nmodule.exports = setWrapToString;\n","var isLaziable = require('./_isLaziable'),\n setData = require('./_setData'),\n setWrapToString = require('./_setWrapToString');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_BOUND_FLAG = 4,\n WRAP_CURRY_FLAG = 8,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64;\n\n/**\n * Creates a function that wraps `func` to continue currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {Function} wrapFunc The function to create the `func` wrapper.\n * @param {*} placeholder The placeholder value.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {\n var isCurry = bitmask & WRAP_CURRY_FLAG,\n newHolders = isCurry ? holders : undefined,\n newHoldersRight = isCurry ? undefined : holders,\n newPartials = isCurry ? partials : undefined,\n newPartialsRight = isCurry ? undefined : partials;\n\n bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);\n bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);\n\n if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {\n bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);\n }\n var newData = [\n func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,\n newHoldersRight, argPos, ary, arity\n ];\n\n var result = wrapFunc.apply(undefined, newData);\n if (isLaziable(func)) {\n setData(result, newData);\n }\n result.placeholder = placeholder;\n return setWrapToString(result, func, bitmask);\n}\n\nmodule.exports = createRecurry;\n","/**\n * Gets the argument placeholder value for `func`.\n *\n * @private\n * @param {Function} func The function to inspect.\n * @returns {*} Returns the placeholder value.\n */\nfunction getHolder(func) {\n var object = func;\n return object.placeholder;\n}\n\nmodule.exports = getHolder;\n","var copyArray = require('./_copyArray'),\n isIndex = require('./_isIndex');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMin = Math.min;\n\n/**\n * Reorder `array` according to the specified indexes where the element at\n * the first index is assigned as the first element, the element at\n * the second index is assigned as the second element, and so on.\n *\n * @private\n * @param {Array} array The array to reorder.\n * @param {Array} indexes The arranged array indexes.\n * @returns {Array} Returns `array`.\n */\nfunction reorder(array, indexes) {\n var arrLength = array.length,\n length = nativeMin(indexes.length, arrLength),\n oldArray = copyArray(array);\n\n while (length--) {\n var index = indexes[length];\n array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;\n }\n return array;\n}\n\nmodule.exports = reorder;\n","/** Used as the internal argument placeholder. */\nvar PLACEHOLDER = '__lodash_placeholder__';\n\n/**\n * Replaces all `placeholder` elements in `array` with an internal placeholder\n * and returns an array of their indexes.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {*} placeholder The placeholder to replace.\n * @returns {Array} Returns the new array of placeholder indexes.\n */\nfunction replaceHolders(array, placeholder) {\n var index = -1,\n length = array.length,\n resIndex = 0,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value === placeholder || value === PLACEHOLDER) {\n array[index] = PLACEHOLDER;\n result[resIndex++] = index;\n }\n }\n return result;\n}\n\nmodule.exports = replaceHolders;\n","var composeArgs = require('./_composeArgs'),\n composeArgsRight = require('./_composeArgsRight'),\n countHolders = require('./_countHolders'),\n createCtor = require('./_createCtor'),\n createRecurry = require('./_createRecurry'),\n getHolder = require('./_getHolder'),\n reorder = require('./_reorder'),\n replaceHolders = require('./_replaceHolders'),\n root = require('./_root');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_ARY_FLAG = 128,\n WRAP_FLIP_FLAG = 512;\n\n/**\n * Creates a function that wraps `func` to invoke it with optional `this`\n * binding of `thisArg`, partial application, and currying.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to\n * the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [partialsRight] The arguments to append to those provided\n * to the new function.\n * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {\n var isAry = bitmask & WRAP_ARY_FLAG,\n isBind = bitmask & WRAP_BIND_FLAG,\n isBindKey = bitmask & WRAP_BIND_KEY_FLAG,\n isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),\n isFlip = bitmask & WRAP_FLIP_FLAG,\n Ctor = isBindKey ? undefined : createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length;\n\n while (index--) {\n args[index] = arguments[index];\n }\n if (isCurried) {\n var placeholder = getHolder(wrapper),\n holdersCount = countHolders(args, placeholder);\n }\n if (partials) {\n args = composeArgs(args, partials, holders, isCurried);\n }\n if (partialsRight) {\n args = composeArgsRight(args, partialsRight, holdersRight, isCurried);\n }\n length -= holdersCount;\n if (isCurried && length < arity) {\n var newHolders = replaceHolders(args, placeholder);\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, thisArg,\n args, newHolders, argPos, ary, arity - length\n );\n }\n var thisBinding = isBind ? thisArg : this,\n fn = isBindKey ? thisBinding[func] : func;\n\n length = args.length;\n if (argPos) {\n args = reorder(args, argPos);\n } else if (isFlip && length > 1) {\n args.reverse();\n }\n if (isAry && ary < length) {\n args.length = ary;\n }\n if (this && this !== root && this instanceof wrapper) {\n fn = Ctor || createCtor(fn);\n }\n return fn.apply(thisBinding, args);\n }\n return wrapper;\n}\n\nmodule.exports = createHybrid;\n","var apply = require('./_apply'),\n createCtor = require('./_createCtor'),\n createHybrid = require('./_createHybrid'),\n createRecurry = require('./_createRecurry'),\n getHolder = require('./_getHolder'),\n replaceHolders = require('./_replaceHolders'),\n root = require('./_root');\n\n/**\n * Creates a function that wraps `func` to enable currying.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {number} arity The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createCurry(func, bitmask, arity) {\n var Ctor = createCtor(func);\n\n function wrapper() {\n var length = arguments.length,\n args = Array(length),\n index = length,\n placeholder = getHolder(wrapper);\n\n while (index--) {\n args[index] = arguments[index];\n }\n var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)\n ? []\n : replaceHolders(args, placeholder);\n\n length -= holders.length;\n if (length < arity) {\n return createRecurry(\n func, bitmask, createHybrid, wrapper.placeholder, undefined,\n args, holders, undefined, undefined, arity - length);\n }\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return apply(fn, this, args);\n }\n return wrapper;\n}\n\nmodule.exports = createCurry;\n","var apply = require('./_apply'),\n createCtor = require('./_createCtor'),\n root = require('./_root');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1;\n\n/**\n * Creates a function that wraps `func` to invoke it with the `this` binding\n * of `thisArg` and `partials` prepended to the arguments it receives.\n *\n * @private\n * @param {Function} func The function to wrap.\n * @param {number} bitmask The bitmask flags. See `createWrap` for more details.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} partials The arguments to prepend to those provided to\n * the new function.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createPartial(func, bitmask, thisArg, partials) {\n var isBind = bitmask & WRAP_BIND_FLAG,\n Ctor = createCtor(func);\n\n function wrapper() {\n var argsIndex = -1,\n argsLength = arguments.length,\n leftIndex = -1,\n leftLength = partials.length,\n args = Array(leftLength + argsLength),\n fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n\n while (++leftIndex < leftLength) {\n args[leftIndex] = partials[leftIndex];\n }\n while (argsLength--) {\n args[leftIndex++] = arguments[++argsIndex];\n }\n return apply(fn, isBind ? thisArg : this, args);\n }\n return wrapper;\n}\n\nmodule.exports = createPartial;\n","var composeArgs = require('./_composeArgs'),\n composeArgsRight = require('./_composeArgsRight'),\n replaceHolders = require('./_replaceHolders');\n\n/** Used as the internal argument placeholder. */\nvar PLACEHOLDER = '__lodash_placeholder__';\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_BOUND_FLAG = 4,\n WRAP_CURRY_FLAG = 8,\n WRAP_ARY_FLAG = 128,\n WRAP_REARG_FLAG = 256;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMin = Math.min;\n\n/**\n * Merges the function metadata of `source` into `data`.\n *\n * Merging metadata reduces the number of wrappers used to invoke a function.\n * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`\n * may be applied regardless of execution order. Methods like `_.ary` and\n * `_.rearg` modify function arguments, making the order in which they are\n * executed important, preventing the merging of metadata. However, we make\n * an exception for a safe combined case where curried functions have `_.ary`\n * and or `_.rearg` applied.\n *\n * @private\n * @param {Array} data The destination metadata.\n * @param {Array} source The source metadata.\n * @returns {Array} Returns `data`.\n */\nfunction mergeData(data, source) {\n var bitmask = data[1],\n srcBitmask = source[1],\n newBitmask = bitmask | srcBitmask,\n isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);\n\n var isCombo =\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||\n ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||\n ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));\n\n // Exit early if metadata can't be merged.\n if (!(isCommon || isCombo)) {\n return data;\n }\n // Use source `thisArg` if available.\n if (srcBitmask & WRAP_BIND_FLAG) {\n data[2] = source[2];\n // Set when currying a bound function.\n newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;\n }\n // Compose partial arguments.\n var value = source[3];\n if (value) {\n var partials = data[3];\n data[3] = partials ? composeArgs(partials, value, source[4]) : value;\n data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];\n }\n // Compose partial right arguments.\n value = source[5];\n if (value) {\n partials = data[5];\n data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;\n data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];\n }\n // Use source `argPos` if available.\n value = source[7];\n if (value) {\n data[7] = value;\n }\n // Use source `ary` if it's smaller.\n if (srcBitmask & WRAP_ARY_FLAG) {\n data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);\n }\n // Use source `arity` if one is not provided.\n if (data[9] == null) {\n data[9] = source[9];\n }\n // Use source `func` and merge bitmasks.\n data[0] = source[0];\n data[1] = newBitmask;\n\n return data;\n}\n\nmodule.exports = mergeData;\n","var baseSetData = require('./_baseSetData'),\n createBind = require('./_createBind'),\n createCurry = require('./_createCurry'),\n createHybrid = require('./_createHybrid'),\n createPartial = require('./_createPartial'),\n getData = require('./_getData'),\n mergeData = require('./_mergeData'),\n setData = require('./_setData'),\n setWrapToString = require('./_setWrapToString'),\n toInteger = require('./toInteger');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_BIND_KEY_FLAG = 2,\n WRAP_CURRY_FLAG = 8,\n WRAP_CURRY_RIGHT_FLAG = 16,\n WRAP_PARTIAL_FLAG = 32,\n WRAP_PARTIAL_RIGHT_FLAG = 64;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * Creates a function that either curries or invokes `func` with optional\n * `this` binding and partially applied arguments.\n *\n * @private\n * @param {Function|string} func The function or method name to wrap.\n * @param {number} bitmask The bitmask flags.\n * 1 - `_.bind`\n * 2 - `_.bindKey`\n * 4 - `_.curry` or `_.curryRight` of a bound function\n * 8 - `_.curry`\n * 16 - `_.curryRight`\n * 32 - `_.partial`\n * 64 - `_.partialRight`\n * 128 - `_.rearg`\n * 256 - `_.ary`\n * 512 - `_.flip`\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to be partially applied.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\nfunction createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {\n var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;\n if (!isBindKey && typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var length = partials ? partials.length : 0;\n if (!length) {\n bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);\n partials = holders = undefined;\n }\n ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);\n arity = arity === undefined ? arity : toInteger(arity);\n length -= holders ? holders.length : 0;\n\n if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {\n var partialsRight = partials,\n holdersRight = holders;\n\n partials = holders = undefined;\n }\n var data = isBindKey ? undefined : getData(func);\n\n var newData = [\n func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,\n argPos, ary, arity\n ];\n\n if (data) {\n mergeData(newData, data);\n }\n func = newData[0];\n bitmask = newData[1];\n thisArg = newData[2];\n partials = newData[3];\n holders = newData[4];\n arity = newData[9] = newData[9] === undefined\n ? (isBindKey ? 0 : func.length)\n : nativeMax(newData[9] - length, 0);\n\n if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {\n bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);\n }\n if (!bitmask || bitmask == WRAP_BIND_FLAG) {\n var result = createBind(func, bitmask, thisArg);\n } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {\n result = createCurry(func, bitmask, arity);\n } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {\n result = createPartial(func, bitmask, thisArg, partials);\n } else {\n result = createHybrid.apply(undefined, newData);\n }\n var setter = data ? baseSetData : setData;\n return setWrapToString(setter(result, newData), func, bitmask);\n}\n\nmodule.exports = createWrap;\n","var baseRest = require('./_baseRest'),\n createWrap = require('./_createWrap'),\n getHolder = require('./_getHolder'),\n replaceHolders = require('./_replaceHolders');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_PARTIAL_FLAG = 32;\n\n/**\n * Creates a function that invokes `func` with `partials` prepended to the\n * arguments it receives. This method is like `_.bind` except it does **not**\n * alter the `this` binding.\n *\n * The `_.partial.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 0.2.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var sayHelloTo = _.partial(greet, 'hello');\n * sayHelloTo('fred');\n * // => 'hello fred'\n *\n * // Partially applied with placeholders.\n * var greetFred = _.partial(greet, _, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n */\nvar partial = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partial));\n return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);\n});\n\n// Assign default placeholders.\npartial.placeholder = {};\n\nmodule.exports = partial;\n","var baseRest = require('./_baseRest'),\n createWrap = require('./_createWrap'),\n getHolder = require('./_getHolder'),\n replaceHolders = require('./_replaceHolders');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_PARTIAL_RIGHT_FLAG = 64;\n\n/**\n * This method is like `_.partial` except that partially applied arguments\n * are appended to the arguments it receives.\n *\n * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method doesn't set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @since 1.0.0\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * var greetFred = _.partialRight(greet, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n *\n * // Partially applied with placeholders.\n * var sayHelloTo = _.partialRight(greet, 'hello', _);\n * sayHelloTo('fred');\n * // => 'hello fred'\n */\nvar partialRight = baseRest(function(func, partials) {\n var holders = replaceHolders(partials, getHolder(partialRight));\n return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);\n});\n\n// Assign default placeholders.\npartialRight.placeholder = {};\n\nmodule.exports = partialRight;\n","/**\n * The base implementation of `_.clamp` which doesn't coerce arguments.\n *\n * @private\n * @param {number} number The number to clamp.\n * @param {number} [lower] The lower bound.\n * @param {number} upper The upper bound.\n * @returns {number} Returns the clamped number.\n */\nfunction baseClamp(number, lower, upper) {\n if (number === number) {\n if (upper !== undefined) {\n number = number <= upper ? number : upper;\n }\n if (lower !== undefined) {\n number = number >= lower ? number : lower;\n }\n }\n return number;\n}\n\nmodule.exports = baseClamp;\n","'use strict';\n\nvar reduce = require('lodash/reduce');\nvar find = require('lodash/find');\nvar startsWith = require('lodash/startsWith');\n\n/**\n * Transform sort format from user friendly notation to lodash format\n * @param {string[]} sortBy array of predicate of the form \"attribute:order\"\n * @return {array.} array containing 2 elements : attributes, orders\n */\nmodule.exports = function formatSort(sortBy, defaults) {\n return reduce(sortBy, function preparePredicate(out, sortInstruction) {\n var sortInstructions = sortInstruction.split(':');\n if (defaults && sortInstructions.length === 1) {\n var similarDefault = find(defaults, function(predicate) {\n return startsWith(predicate, sortInstruction[0]);\n });\n if (similarDefault) {\n sortInstructions = similarDefault.split(':');\n }\n }\n out[0].push(sortInstructions[0]);\n out[1].push(sortInstructions[1]);\n return out;\n }, [[], []]);\n};\n","var baseClamp = require('./_baseClamp'),\n baseToString = require('./_baseToString'),\n toInteger = require('./toInteger'),\n toString = require('./toString');\n\n/**\n * Checks if `string` starts with the given target string.\n *\n * @static\n * @memberOf _\n * @since 3.0.0\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {string} [target] The string to search for.\n * @param {number} [position=0] The position to search from.\n * @returns {boolean} Returns `true` if `string` starts with `target`,\n * else `false`.\n * @example\n *\n * _.startsWith('abc', 'a');\n * // => true\n *\n * _.startsWith('abc', 'b');\n * // => false\n *\n * _.startsWith('abc', 'b', 1);\n * // => true\n */\nfunction startsWith(string, target, position) {\n string = toString(string);\n position = position == null\n ? 0\n : baseClamp(toInteger(position), 0, string.length);\n\n target = baseToString(target);\n return string.slice(position, position + target.length) == target;\n}\n\nmodule.exports = startsWith;\n","var assignValue = require('./_assignValue'),\n castPath = require('./_castPath'),\n isIndex = require('./_isIndex'),\n isObject = require('./isObject'),\n toKey = require('./_toKey');\n\n/**\n * The base implementation of `_.set`.\n *\n * @private\n * @param {Object} object The object to modify.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @param {Function} [customizer] The function to customize path creation.\n * @returns {Object} Returns `object`.\n */\nfunction baseSet(object, path, value, customizer) {\n if (!isObject(object)) {\n return object;\n }\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n lastIndex = length - 1,\n nested = object;\n\n while (nested != null && ++index < length) {\n var key = toKey(path[index]),\n newValue = value;\n\n if (index != lastIndex) {\n var objValue = nested[key];\n newValue = customizer ? customizer(objValue, key, nested) : undefined;\n if (newValue === undefined) {\n newValue = isObject(objValue)\n ? objValue\n : (isIndex(path[index + 1]) ? [] : {});\n }\n }\n assignValue(nested, key, newValue);\n nested = nested[key];\n }\n return object;\n}\n\nmodule.exports = baseSet;\n","var baseGet = require('./_baseGet'),\n baseSet = require('./_baseSet'),\n castPath = require('./_castPath');\n\n/**\n * The base implementation of `_.pickBy` without support for iteratee shorthands.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @param {Function} predicate The function invoked per property.\n * @returns {Object} Returns the new object.\n */\nfunction basePickBy(object, paths, predicate) {\n var index = -1,\n length = paths.length,\n result = {};\n\n while (++index < length) {\n var path = paths[index],\n value = baseGet(object, path);\n\n if (predicate(value, path)) {\n baseSet(result, castPath(path, object), value);\n }\n }\n return result;\n}\n\nmodule.exports = basePickBy;\n","var arrayMap = require('./_arrayMap'),\n baseIteratee = require('./_baseIteratee'),\n basePickBy = require('./_basePickBy'),\n getAllKeysIn = require('./_getAllKeysIn');\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Object\n * @param {Object} object The source object.\n * @param {Function} [predicate=_.identity] The function invoked per property.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pickBy(object, _.isNumber);\n * // => { 'a': 1, 'c': 3 }\n */\nfunction pickBy(object, predicate) {\n if (object == null) {\n return {};\n }\n var props = arrayMap(getAllKeysIn(object), function(prop) {\n return [prop];\n });\n predicate = baseIteratee(predicate);\n return basePickBy(object, props, function(value, path) {\n return predicate(value, path[0]);\n });\n}\n\nmodule.exports = pickBy;\n","'use strict';\n\nmodule.exports = generateTrees;\n\nvar last = require('lodash/last');\nvar map = require('lodash/map');\nvar reduce = require('lodash/reduce');\nvar orderBy = require('lodash/orderBy');\nvar trim = require('lodash/trim');\nvar find = require('lodash/find');\nvar pickBy = require('lodash/pickBy');\n\nvar prepareHierarchicalFacetSortBy = require('../functions/formatSort');\n\nfunction generateTrees(state) {\n return function generate(hierarchicalFacetResult, hierarchicalFacetIndex) {\n var hierarchicalFacet = state.hierarchicalFacets[hierarchicalFacetIndex];\n var hierarchicalFacetRefinement = state.hierarchicalFacetsRefinements[hierarchicalFacet.name] &&\n state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0] || '';\n var hierarchicalSeparator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n var hierarchicalRootPath = state._getHierarchicalRootPath(hierarchicalFacet);\n var hierarchicalShowParentLevel = state._getHierarchicalShowParentLevel(hierarchicalFacet);\n var sortBy = prepareHierarchicalFacetSortBy(state._getHierarchicalFacetSortBy(hierarchicalFacet));\n\n var generateTreeFn = generateHierarchicalTree(sortBy, hierarchicalSeparator, hierarchicalRootPath,\n hierarchicalShowParentLevel, hierarchicalFacetRefinement);\n\n var results = hierarchicalFacetResult;\n\n if (hierarchicalRootPath) {\n results = hierarchicalFacetResult.slice(hierarchicalRootPath.split(hierarchicalSeparator).length);\n }\n\n return reduce(results, generateTreeFn, {\n name: state.hierarchicalFacets[hierarchicalFacetIndex].name,\n count: null, // root level, no count\n isRefined: true, // root level, always refined\n path: null, // root level, no path\n data: null\n });\n };\n}\n\nfunction generateHierarchicalTree(sortBy, hierarchicalSeparator, hierarchicalRootPath,\n hierarchicalShowParentLevel, currentRefinement) {\n return function generateTree(hierarchicalTree, hierarchicalFacetResult, currentHierarchicalLevel) {\n var parent = hierarchicalTree;\n\n if (currentHierarchicalLevel > 0) {\n var level = 0;\n\n parent = hierarchicalTree;\n\n while (level < currentHierarchicalLevel) {\n parent = parent && find(parent.data, {isRefined: true});\n level++;\n }\n }\n\n // we found a refined parent, let's add current level data under it\n if (parent) {\n // filter values in case an object has multiple categories:\n // {\n // categories: {\n // level0: ['beers', 'bières'],\n // level1: ['beers > IPA', 'bières > Belges']\n // }\n // }\n //\n // If parent refinement is `beers`, then we do not want to have `bières > Belges`\n // showing up\n\n var onlyMatchingValuesFn = filterFacetValues(parent.path || hierarchicalRootPath,\n currentRefinement, hierarchicalSeparator, hierarchicalRootPath, hierarchicalShowParentLevel);\n\n parent.data = orderBy(\n map(\n pickBy(hierarchicalFacetResult.data, onlyMatchingValuesFn),\n formatHierarchicalFacetValue(hierarchicalSeparator, currentRefinement)\n ),\n sortBy[0], sortBy[1]\n );\n }\n\n return hierarchicalTree;\n };\n}\n\nfunction filterFacetValues(parentPath, currentRefinement, hierarchicalSeparator, hierarchicalRootPath,\n hierarchicalShowParentLevel) {\n return function(facetCount, facetValue) {\n // we want the facetValue is a child of hierarchicalRootPath\n if (hierarchicalRootPath &&\n (facetValue.indexOf(hierarchicalRootPath) !== 0 || hierarchicalRootPath === facetValue)) {\n return false;\n }\n\n // we always want root levels (only when there is no prefix path)\n return !hierarchicalRootPath && facetValue.indexOf(hierarchicalSeparator) === -1 ||\n // if there is a rootPath, being root level mean 1 level under rootPath\n hierarchicalRootPath &&\n facetValue.split(hierarchicalSeparator).length - hierarchicalRootPath.split(hierarchicalSeparator).length === 1 ||\n // if current refinement is a root level and current facetValue is a root level,\n // keep the facetValue\n facetValue.indexOf(hierarchicalSeparator) === -1 &&\n currentRefinement.indexOf(hierarchicalSeparator) === -1 ||\n // currentRefinement is a child of the facet value\n currentRefinement.indexOf(facetValue) === 0 ||\n // facetValue is a child of the current parent, add it\n facetValue.indexOf(parentPath + hierarchicalSeparator) === 0 &&\n (hierarchicalShowParentLevel || facetValue.indexOf(currentRefinement) === 0);\n };\n}\n\nfunction formatHierarchicalFacetValue(hierarchicalSeparator, currentRefinement) {\n return function format(facetCount, facetValue) {\n return {\n name: trim(last(facetValue.split(hierarchicalSeparator))),\n path: facetValue,\n count: facetCount,\n isRefined: currentRefinement === facetValue || currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0,\n data: null\n };\n };\n}\n","'use strict';\n\nvar forEach = require('lodash/forEach');\nvar compact = require('lodash/compact');\nvar indexOf = require('lodash/indexOf');\nvar findIndex = require('lodash/findIndex');\nvar get = require('lodash/get');\n\nvar sumBy = require('lodash/sumBy');\nvar find = require('lodash/find');\nvar includes = require('lodash/includes');\nvar map = require('lodash/map');\nvar orderBy = require('lodash/orderBy');\n\nvar defaults = require('lodash/defaults');\nvar merge = require('lodash/merge');\n\nvar isFunction = require('lodash/isFunction');\n\nvar partial = require('lodash/partial');\nvar partialRight = require('lodash/partialRight');\n\nvar formatSort = require('../functions/formatSort');\n\nvar generateHierarchicalTree = require('./generate-hierarchical-tree');\n\n/**\n * @typedef SearchResults.Facet\n * @type {object}\n * @property {string} name name of the attribute in the record\n * @property {object} data the faceting data: value, number of entries\n * @property {object} stats undefined unless facet_stats is retrieved from algolia\n */\n\n/**\n * @typedef SearchResults.HierarchicalFacet\n * @type {object}\n * @property {string} name name of the current value given the hierarchical level, trimmed.\n * If root node, you get the facet name\n * @property {number} count number of objects matching this hierarchical value\n * @property {string} path the current hierarchical value full path\n * @property {boolean} isRefined `true` if the current value was refined, `false` otherwise\n * @property {HierarchicalFacet[]} data sub values for the current level\n */\n\n/**\n * @typedef SearchResults.FacetValue\n * @type {object}\n * @property {string} name the facet value itself\n * @property {number} count times this facet appears in the results\n * @property {boolean} isRefined is the facet currently selected\n * @property {boolean} isExcluded is the facet currently excluded (only for conjunctive facets)\n */\n\n/**\n * @typedef Refinement\n * @type {object}\n * @property {string} type the type of filter used:\n * `numeric`, `facet`, `exclude`, `disjunctive`, `hierarchical`\n * @property {string} attributeName name of the attribute used for filtering\n * @property {string} name the value of the filter\n * @property {number} numericValue the value as a number. Only for numeric filters.\n * @property {string} operator the operator used. Only for numeric filters.\n * @property {number} count the number of computed hits for this filter. Only on facets.\n * @property {boolean} exhaustive if the count is exhaustive\n */\n\nfunction getIndices(obj) {\n var indices = {};\n\n forEach(obj, function(val, idx) { indices[val] = idx; });\n\n return indices;\n}\n\nfunction assignFacetStats(dest, facetStats, key) {\n if (facetStats && facetStats[key]) {\n dest.stats = facetStats[key];\n }\n}\n\nfunction findMatchingHierarchicalFacetFromAttributeName(hierarchicalFacets, hierarchicalAttributeName) {\n return find(\n hierarchicalFacets,\n function facetKeyMatchesAttribute(hierarchicalFacet) {\n return includes(hierarchicalFacet.attributes, hierarchicalAttributeName);\n }\n );\n}\n\n/*eslint-disable */\n/**\n * Constructor for SearchResults\n * @class\n * @classdesc SearchResults contains the results of a query to Algolia using the\n * {@link AlgoliaSearchHelper}.\n * @param {SearchParameters} state state that led to the response\n * @param {array.} results the results from algolia client\n * @example SearchResults of the first query in\n * the instant search demo\n{\n \"hitsPerPage\": 10,\n \"processingTimeMS\": 2,\n \"facets\": [\n {\n \"name\": \"type\",\n \"data\": {\n \"HardGood\": 6627,\n \"BlackTie\": 550,\n \"Music\": 665,\n \"Software\": 131,\n \"Game\": 456,\n \"Movie\": 1571\n },\n \"exhaustive\": false\n },\n {\n \"exhaustive\": false,\n \"data\": {\n \"Free shipping\": 5507\n },\n \"name\": \"shipping\"\n }\n ],\n \"hits\": [\n {\n \"thumbnailImage\": \"http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_54x108_s.gif\",\n \"_highlightResult\": {\n \"shortDescription\": {\n \"matchLevel\": \"none\",\n \"value\": \"Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection\",\n \"matchedWords\": []\n },\n \"category\": {\n \"matchLevel\": \"none\",\n \"value\": \"Computer Security Software\",\n \"matchedWords\": []\n },\n \"manufacturer\": {\n \"matchedWords\": [],\n \"value\": \"Webroot\",\n \"matchLevel\": \"none\"\n },\n \"name\": {\n \"value\": \"Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows\",\n \"matchedWords\": [],\n \"matchLevel\": \"none\"\n }\n },\n \"image\": \"http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_105x210_sc.jpg\",\n \"shipping\": \"Free shipping\",\n \"bestSellingRank\": 4,\n \"shortDescription\": \"Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection\",\n \"url\": \"http://www.bestbuy.com/site/webroot-secureanywhere-internet-security-3-devi…d=1219060687969&skuId=1688832&cmp=RMX&ky=2d3GfEmNIzjA0vkzveHdZEBgpPCyMnLTJ\",\n \"name\": \"Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows\",\n \"category\": \"Computer Security Software\",\n \"salePrice_range\": \"1 - 50\",\n \"objectID\": \"1688832\",\n \"type\": \"Software\",\n \"customerReviewCount\": 5980,\n \"salePrice\": 49.99,\n \"manufacturer\": \"Webroot\"\n },\n ....\n ],\n \"nbHits\": 10000,\n \"disjunctiveFacets\": [\n {\n \"exhaustive\": false,\n \"data\": {\n \"5\": 183,\n \"12\": 112,\n \"7\": 149,\n ...\n },\n \"name\": \"customerReviewCount\",\n \"stats\": {\n \"max\": 7461,\n \"avg\": 157.939,\n \"min\": 1\n }\n },\n {\n \"data\": {\n \"Printer Ink\": 142,\n \"Wireless Speakers\": 60,\n \"Point & Shoot Cameras\": 48,\n ...\n },\n \"name\": \"category\",\n \"exhaustive\": false\n },\n {\n \"exhaustive\": false,\n \"data\": {\n \"> 5000\": 2,\n \"1 - 50\": 6524,\n \"501 - 2000\": 566,\n \"201 - 500\": 1501,\n \"101 - 200\": 1360,\n \"2001 - 5000\": 47\n },\n \"name\": \"salePrice_range\"\n },\n {\n \"data\": {\n \"Dynex™\": 202,\n \"Insignia™\": 230,\n \"PNY\": 72,\n ...\n },\n \"name\": \"manufacturer\",\n \"exhaustive\": false\n }\n ],\n \"query\": \"\",\n \"nbPages\": 100,\n \"page\": 0,\n \"index\": \"bestbuy\"\n}\n **/\n/*eslint-enable */\nfunction SearchResults(state, results) {\n var mainSubResponse = results[0];\n\n this._rawResults = results;\n\n /**\n * query used to generate the results\n * @member {string}\n */\n this.query = mainSubResponse.query;\n /**\n * The query as parsed by the engine given all the rules.\n * @member {string}\n */\n this.parsedQuery = mainSubResponse.parsedQuery;\n /**\n * all the records that match the search parameters. Each record is\n * augmented with a new attribute `_highlightResult`\n * which is an object keyed by attribute and with the following properties:\n * - `value` : the value of the facet highlighted (html)\n * - `matchLevel`: full, partial or none depending on how the query terms match\n * @member {object[]}\n */\n this.hits = mainSubResponse.hits;\n /**\n * index where the results come from\n * @member {string}\n */\n this.index = mainSubResponse.index;\n /**\n * number of hits per page requested\n * @member {number}\n */\n this.hitsPerPage = mainSubResponse.hitsPerPage;\n /**\n * total number of hits of this query on the index\n * @member {number}\n */\n this.nbHits = mainSubResponse.nbHits;\n /**\n * total number of pages with respect to the number of hits per page and the total number of hits\n * @member {number}\n */\n this.nbPages = mainSubResponse.nbPages;\n /**\n * current page\n * @member {number}\n */\n this.page = mainSubResponse.page;\n /**\n * sum of the processing time of all the queries\n * @member {number}\n */\n this.processingTimeMS = sumBy(results, 'processingTimeMS');\n /**\n * The position if the position was guessed by IP.\n * @member {string}\n * @example \"48.8637,2.3615\",\n */\n this.aroundLatLng = mainSubResponse.aroundLatLng;\n /**\n * The radius computed by Algolia.\n * @member {string}\n * @example \"126792922\",\n */\n this.automaticRadius = mainSubResponse.automaticRadius;\n /**\n * String identifying the server used to serve this request.\n * @member {string}\n * @example \"c7-use-2.algolia.net\",\n */\n this.serverUsed = mainSubResponse.serverUsed;\n /**\n * Boolean that indicates if the computation of the counts did time out.\n * @deprecated\n * @member {boolean}\n */\n this.timeoutCounts = mainSubResponse.timeoutCounts;\n /**\n * Boolean that indicates if the computation of the hits did time out.\n * @deprecated\n * @member {boolean}\n */\n this.timeoutHits = mainSubResponse.timeoutHits;\n\n /**\n * True if the counts of the facets is exhaustive\n * @member {boolean}\n */\n this.exhaustiveFacetsCount = mainSubResponse.exhaustiveFacetsCount;\n\n /**\n * True if the number of hits is exhaustive\n * @member {boolean}\n */\n this.exhaustiveNbHits = mainSubResponse.exhaustiveNbHits;\n\n\n /**\n * Contains the userData if they are set by a [query rule](https://www.algolia.com/doc/guides/query-rules/query-rules-overview/).\n * @member {object[]}\n */\n this.userData = mainSubResponse.userData;\n\n /**\n * queryID is the unique identifier of the query used to generate the current search results.\n * This value is only available if the `clickAnalytics` search parameter is set to `true`.\n * @member {string}\n */\n this.queryID = mainSubResponse.queryID;\n\n /**\n * disjunctive facets results\n * @member {SearchResults.Facet[]}\n */\n this.disjunctiveFacets = [];\n /**\n * disjunctive facets results\n * @member {SearchResults.HierarchicalFacet[]}\n */\n this.hierarchicalFacets = map(state.hierarchicalFacets, function initFutureTree() {\n return [];\n });\n /**\n * other facets results\n * @member {SearchResults.Facet[]}\n */\n this.facets = [];\n\n var disjunctiveFacets = state.getRefinedDisjunctiveFacets();\n\n var facetsIndices = getIndices(state.facets);\n var disjunctiveFacetsIndices = getIndices(state.disjunctiveFacets);\n var nextDisjunctiveResult = 1;\n\n var self = this;\n // Since we send request only for disjunctive facets that have been refined,\n // we get the facets informations from the first, general, response.\n forEach(mainSubResponse.facets, function(facetValueObject, facetKey) {\n var hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(\n state.hierarchicalFacets,\n facetKey\n );\n\n if (hierarchicalFacet) {\n // Place the hierarchicalFacet data at the correct index depending on\n // the attributes order that was defined at the helper initialization\n var facetIndex = hierarchicalFacet.attributes.indexOf(facetKey);\n var idxAttributeName = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});\n self.hierarchicalFacets[idxAttributeName][facetIndex] = {\n attribute: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n } else {\n var isFacetDisjunctive = indexOf(state.disjunctiveFacets, facetKey) !== -1;\n var isFacetConjunctive = indexOf(state.facets, facetKey) !== -1;\n var position;\n\n if (isFacetDisjunctive) {\n position = disjunctiveFacetsIndices[facetKey];\n self.disjunctiveFacets[position] = {\n name: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n assignFacetStats(self.disjunctiveFacets[position], mainSubResponse.facets_stats, facetKey);\n }\n if (isFacetConjunctive) {\n position = facetsIndices[facetKey];\n self.facets[position] = {\n name: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n assignFacetStats(self.facets[position], mainSubResponse.facets_stats, facetKey);\n }\n }\n });\n\n // Make sure we do not keep holes within the hierarchical facets\n this.hierarchicalFacets = compact(this.hierarchicalFacets);\n\n // aggregate the refined disjunctive facets\n forEach(disjunctiveFacets, function(disjunctiveFacet) {\n var result = results[nextDisjunctiveResult];\n var hierarchicalFacet = state.getHierarchicalFacetByName(disjunctiveFacet);\n\n // There should be only item in facets.\n forEach(result.facets, function(facetResults, dfacet) {\n var position;\n\n if (hierarchicalFacet) {\n position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});\n var attributeIndex = findIndex(self.hierarchicalFacets[position], {attribute: dfacet});\n\n // previous refinements and no results so not able to find it\n if (attributeIndex === -1) {\n return;\n }\n\n self.hierarchicalFacets[position][attributeIndex].data = merge(\n {},\n self.hierarchicalFacets[position][attributeIndex].data,\n facetResults\n );\n } else {\n position = disjunctiveFacetsIndices[dfacet];\n\n var dataFromMainRequest = mainSubResponse.facets && mainSubResponse.facets[dfacet] || {};\n\n self.disjunctiveFacets[position] = {\n name: dfacet,\n data: defaults({}, facetResults, dataFromMainRequest),\n exhaustive: result.exhaustiveFacetsCount\n };\n assignFacetStats(self.disjunctiveFacets[position], result.facets_stats, dfacet);\n\n if (state.disjunctiveFacetsRefinements[dfacet]) {\n forEach(state.disjunctiveFacetsRefinements[dfacet], function(refinementValue) {\n // add the disjunctive refinements if it is no more retrieved\n if (!self.disjunctiveFacets[position].data[refinementValue] &&\n indexOf(state.disjunctiveFacetsRefinements[dfacet], refinementValue) > -1) {\n self.disjunctiveFacets[position].data[refinementValue] = 0;\n }\n });\n }\n }\n });\n nextDisjunctiveResult++;\n });\n\n // if we have some root level values for hierarchical facets, merge them\n forEach(state.getRefinedHierarchicalFacets(), function(refinedFacet) {\n var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n\n var currentRefinement = state.getHierarchicalRefinement(refinedFacet);\n // if we are already at a root refinement (or no refinement at all), there is no\n // root level values request\n if (currentRefinement.length === 0 || currentRefinement[0].split(separator).length < 2) {\n return;\n }\n\n var result = results[nextDisjunctiveResult];\n\n forEach(result.facets, function(facetResults, dfacet) {\n var position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});\n var attributeIndex = findIndex(self.hierarchicalFacets[position], {attribute: dfacet});\n\n // previous refinements and no results so not able to find it\n if (attributeIndex === -1) {\n return;\n }\n\n // when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),\n // then the disjunctive values will be `beers` (count: 100),\n // but we do not want to display\n // | beers (100)\n // > IPA (5)\n // We want\n // | beers (5)\n // > IPA (5)\n var defaultData = {};\n\n if (currentRefinement.length > 0) {\n var root = currentRefinement[0].split(separator)[0];\n defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];\n }\n\n self.hierarchicalFacets[position][attributeIndex].data = defaults(\n defaultData,\n facetResults,\n self.hierarchicalFacets[position][attributeIndex].data\n );\n });\n\n nextDisjunctiveResult++;\n });\n\n // add the excludes\n forEach(state.facetsExcludes, function(excludes, facetName) {\n var position = facetsIndices[facetName];\n\n self.facets[position] = {\n name: facetName,\n data: mainSubResponse.facets[facetName],\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n forEach(excludes, function(facetValue) {\n self.facets[position] = self.facets[position] || {name: facetName};\n self.facets[position].data = self.facets[position].data || {};\n self.facets[position].data[facetValue] = 0;\n });\n });\n\n this.hierarchicalFacets = map(this.hierarchicalFacets, generateHierarchicalTree(state));\n\n this.facets = compact(this.facets);\n this.disjunctiveFacets = compact(this.disjunctiveFacets);\n\n this._state = state;\n}\n\n/**\n * Get a facet object with its name\n * @deprecated\n * @param {string} name name of the faceted attribute\n * @return {SearchResults.Facet} the facet object\n */\nSearchResults.prototype.getFacetByName = function(name) {\n var predicate = {name: name};\n\n return find(this.facets, predicate) ||\n find(this.disjunctiveFacets, predicate) ||\n find(this.hierarchicalFacets, predicate);\n};\n\n/**\n * Get the facet values of a specified attribute from a SearchResults object.\n * @private\n * @param {SearchResults} results the search results to search in\n * @param {string} attribute name of the faceted attribute to search for\n * @return {array|object} facet values. For the hierarchical facets it is an object.\n */\nfunction extractNormalizedFacetValues(results, attribute) {\n var predicate = {name: attribute};\n if (results._state.isConjunctiveFacet(attribute)) {\n var facet = find(results.facets, predicate);\n if (!facet) return [];\n\n return map(facet.data, function(v, k) {\n return {\n name: k,\n count: v,\n isRefined: results._state.isFacetRefined(attribute, k),\n isExcluded: results._state.isExcludeRefined(attribute, k)\n };\n });\n } else if (results._state.isDisjunctiveFacet(attribute)) {\n var disjunctiveFacet = find(results.disjunctiveFacets, predicate);\n if (!disjunctiveFacet) return [];\n\n return map(disjunctiveFacet.data, function(v, k) {\n return {\n name: k,\n count: v,\n isRefined: results._state.isDisjunctiveFacetRefined(attribute, k)\n };\n });\n } else if (results._state.isHierarchicalFacet(attribute)) {\n return find(results.hierarchicalFacets, predicate);\n }\n}\n\n/**\n * Sort nodes of a hierarchical facet results\n * @private\n * @param {HierarchicalFacet} node node to upon which we want to apply the sort\n */\nfunction recSort(sortFn, node) {\n if (!node.data || node.data.length === 0) {\n return node;\n }\n var children = map(node.data, partial(recSort, sortFn));\n var sortedChildren = sortFn(children);\n var newNode = merge({}, node, {data: sortedChildren});\n return newNode;\n}\n\nSearchResults.DEFAULT_SORT = ['isRefined:desc', 'count:desc', 'name:asc'];\n\nfunction vanillaSortFn(order, data) {\n return data.sort(order);\n}\n\n/**\n * Get a the list of values for a given facet attribute. Those values are sorted\n * refinement first, descending count (bigger value on top), and name ascending\n * (alphabetical order). The sort formula can overridden using either string based\n * predicates or a function.\n *\n * This method will return all the values returned by the Algolia engine plus all\n * the values already refined. This means that it can happen that the\n * `maxValuesPerFacet` [configuration](https://www.algolia.com/doc/rest-api/search#param-maxValuesPerFacet)\n * might not be respected if you have facet values that are already refined.\n * @param {string} attribute attribute name\n * @param {object} opts configuration options.\n * @param {Array. | function} opts.sortBy\n * When using strings, it consists of\n * the name of the [FacetValue](#SearchResults.FacetValue) or the\n * [HierarchicalFacet](#SearchResults.HierarchicalFacet) attributes with the\n * order (`asc` or `desc`). For example to order the value by count, the\n * argument would be `['count:asc']`.\n *\n * If only the attribute name is specified, the ordering defaults to the one\n * specified in the default value for this attribute.\n *\n * When not specified, the order is\n * ascending. This parameter can also be a function which takes two facet\n * values and should return a number, 0 if equal, 1 if the first argument is\n * bigger or -1 otherwise.\n *\n * The default value for this attribute `['isRefined:desc', 'count:desc', 'name:asc']`\n * @return {FacetValue[]|HierarchicalFacet} depending on the type of facet of\n * the attribute requested (hierarchical, disjunctive or conjunctive)\n * @example\n * helper.on('results', function(content){\n * //get values ordered only by name ascending using the string predicate\n * content.getFacetValues('city', {sortBy: ['name:asc']});\n * //get values ordered only by count ascending using a function\n * content.getFacetValues('city', {\n * // this is equivalent to ['count:asc']\n * sortBy: function(a, b) {\n * if (a.count === b.count) return 0;\n * if (a.count > b.count) return 1;\n * if (b.count > a.count) return -1;\n * }\n * });\n * });\n */\nSearchResults.prototype.getFacetValues = function(attribute, opts) {\n var facetValues = extractNormalizedFacetValues(this, attribute);\n if (!facetValues) throw new Error(attribute + ' is not a retrieved facet.');\n\n var options = defaults({}, opts, {sortBy: SearchResults.DEFAULT_SORT});\n\n if (Array.isArray(options.sortBy)) {\n var order = formatSort(options.sortBy, SearchResults.DEFAULT_SORT);\n if (Array.isArray(facetValues)) {\n return orderBy(facetValues, order[0], order[1]);\n }\n // If facetValues is not an array, it's an object thus a hierarchical facet object\n return recSort(partialRight(orderBy, order[0], order[1]), facetValues);\n } else if (isFunction(options.sortBy)) {\n if (Array.isArray(facetValues)) {\n return facetValues.sort(options.sortBy);\n }\n // If facetValues is not an array, it's an object thus a hierarchical facet object\n return recSort(partial(vanillaSortFn, options.sortBy), facetValues);\n }\n throw new Error(\n 'options.sortBy is optional but if defined it must be ' +\n 'either an array of string (predicates) or a sorting function'\n );\n};\n\n/**\n * Returns the facet stats if attribute is defined and the facet contains some.\n * Otherwise returns undefined.\n * @param {string} attribute name of the faceted attribute\n * @return {object} The stats of the facet\n */\nSearchResults.prototype.getFacetStats = function(attribute) {\n if (this._state.isConjunctiveFacet(attribute)) {\n return getFacetStatsIfAvailable(this.facets, attribute);\n } else if (this._state.isDisjunctiveFacet(attribute)) {\n return getFacetStatsIfAvailable(this.disjunctiveFacets, attribute);\n }\n\n throw new Error(attribute + ' is not present in `facets` or `disjunctiveFacets`');\n};\n\nfunction getFacetStatsIfAvailable(facetList, facetName) {\n var data = find(facetList, {name: facetName});\n return data && data.stats;\n}\n\n/**\n * Returns all refinements for all filters + tags. It also provides\n * additional information: count and exhausistivity for each filter.\n *\n * See the [refinement type](#Refinement) for an exhaustive view of the available\n * data.\n *\n * @return {Array.} all the refinements\n */\nSearchResults.prototype.getRefinements = function() {\n var state = this._state;\n var results = this;\n var res = [];\n\n forEach(state.facetsRefinements, function(refinements, attributeName) {\n forEach(refinements, function(name) {\n res.push(getRefinement(state, 'facet', attributeName, name, results.facets));\n });\n });\n\n forEach(state.facetsExcludes, function(refinements, attributeName) {\n forEach(refinements, function(name) {\n res.push(getRefinement(state, 'exclude', attributeName, name, results.facets));\n });\n });\n\n forEach(state.disjunctiveFacetsRefinements, function(refinements, attributeName) {\n forEach(refinements, function(name) {\n res.push(getRefinement(state, 'disjunctive', attributeName, name, results.disjunctiveFacets));\n });\n });\n\n forEach(state.hierarchicalFacetsRefinements, function(refinements, attributeName) {\n forEach(refinements, function(name) {\n res.push(getHierarchicalRefinement(state, attributeName, name, results.hierarchicalFacets));\n });\n });\n\n forEach(state.numericRefinements, function(operators, attributeName) {\n forEach(operators, function(values, operator) {\n forEach(values, function(value) {\n res.push({\n type: 'numeric',\n attributeName: attributeName,\n name: value,\n numericValue: value,\n operator: operator\n });\n });\n });\n });\n\n forEach(state.tagRefinements, function(name) {\n res.push({type: 'tag', attributeName: '_tags', name: name});\n });\n\n return res;\n};\n\nfunction getRefinement(state, type, attributeName, name, resultsFacets) {\n var facet = find(resultsFacets, {name: attributeName});\n var count = get(facet, 'data[' + name + ']');\n var exhaustive = get(facet, 'exhaustive');\n return {\n type: type,\n attributeName: attributeName,\n name: name,\n count: count || 0,\n exhaustive: exhaustive || false\n };\n}\n\nfunction getHierarchicalRefinement(state, attributeName, name, resultsFacets) {\n var facet = find(resultsFacets, {name: attributeName});\n var facetDeclaration = state.getHierarchicalFacetByName(attributeName);\n var splitted = name.split(facetDeclaration.separator);\n var configuredName = splitted[splitted.length - 1];\n for (var i = 0; facet !== undefined && i < splitted.length; ++i) {\n facet = find(facet.data, {name: splitted[i]});\n }\n var count = get(facet, 'count');\n var exhaustive = get(facet, 'exhaustive');\n return {\n type: 'hierarchical',\n attributeName: attributeName,\n name: configuredName,\n count: count || 0,\n exhaustive: exhaustive || false\n };\n}\n\nmodule.exports = SearchResults;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n","'use strict';\n\nfunction inherits(ctor, superCtor) {\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n}\n\nmodule.exports = inherits;\n","'use strict';\n\nvar events = require('events');\nvar inherits = require('../functions/inherits');\n\n/**\n * A DerivedHelper is a way to create sub requests to\n * Algolia from a main helper.\n * @class\n * @classdesc The DerivedHelper provides an event based interface for search callbacks:\n * - search: when a search is triggered using the `search()` method.\n * - result: when the response is retrieved from Algolia and is processed.\n * This event contains a {@link SearchResults} object and the\n * {@link SearchParameters} corresponding to this answer.\n */\nfunction DerivedHelper(mainHelper, fn) {\n this.main = mainHelper;\n this.fn = fn;\n this.lastResults = null;\n}\n\ninherits(DerivedHelper, events.EventEmitter);\n\n/**\n * Detach this helper from the main helper\n * @return {undefined}\n * @throws Error if the derived helper is already detached\n */\nDerivedHelper.prototype.detach = function() {\n this.removeAllListeners();\n this.main.detachDerivedHelper(this);\n};\n\nDerivedHelper.prototype.getModifiedState = function(parameters) {\n return this.fn(parameters);\n};\n\nmodule.exports = DerivedHelper;\n","'use strict';\n\nvar forEach = require('lodash/forEach');\nvar map = require('lodash/map');\nvar reduce = require('lodash/reduce');\nvar merge = require('lodash/merge');\n\nvar requestBuilder = {\n /**\n * Get all the queries to send to the client, those queries can used directly\n * with the Algolia client.\n * @private\n * @return {object[]} The queries\n */\n _getQueries: function getQueries(index, state) {\n var queries = [];\n\n // One query for the hits\n queries.push({\n indexName: index,\n params: requestBuilder._getHitsSearchParams(state)\n });\n\n // One for each disjunctive facets\n forEach(state.getRefinedDisjunctiveFacets(), function(refinedFacet) {\n queries.push({\n indexName: index,\n params: requestBuilder._getDisjunctiveFacetSearchParams(state, refinedFacet)\n });\n });\n\n // maybe more to get the root level of hierarchical facets when activated\n forEach(state.getRefinedHierarchicalFacets(), function(refinedFacet) {\n var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);\n\n var currentRefinement = state.getHierarchicalRefinement(refinedFacet);\n // if we are deeper than level 0 (starting from `beer > IPA`)\n // we want to get the root values\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {\n queries.push({\n indexName: index,\n params: requestBuilder._getDisjunctiveFacetSearchParams(state, refinedFacet, true)\n });\n }\n });\n\n return queries;\n },\n\n /**\n * Build search parameters used to fetch hits\n * @private\n * @return {object.}\n */\n _getHitsSearchParams: function(state) {\n var facets = state.facets\n .concat(state.disjunctiveFacets)\n .concat(requestBuilder._getHitsHierarchicalFacetsAttributes(state));\n\n\n var facetFilters = requestBuilder._getFacetFilters(state);\n var numericFilters = requestBuilder._getNumericFilters(state);\n var tagFilters = requestBuilder._getTagFilters(state);\n var additionalParams = {\n facets: facets,\n tagFilters: tagFilters\n };\n\n if (facetFilters.length > 0) {\n additionalParams.facetFilters = facetFilters;\n }\n\n if (numericFilters.length > 0) {\n additionalParams.numericFilters = numericFilters;\n }\n\n return merge(state.getQueryParams(), additionalParams);\n },\n\n /**\n * Build search parameters used to fetch a disjunctive facet\n * @private\n * @param {string} facet the associated facet name\n * @param {boolean} hierarchicalRootLevel ?? FIXME\n * @return {object}\n */\n _getDisjunctiveFacetSearchParams: function(state, facet, hierarchicalRootLevel) {\n var facetFilters = requestBuilder._getFacetFilters(state, facet, hierarchicalRootLevel);\n var numericFilters = requestBuilder._getNumericFilters(state, facet);\n var tagFilters = requestBuilder._getTagFilters(state);\n var additionalParams = {\n hitsPerPage: 1,\n page: 0,\n attributesToRetrieve: [],\n attributesToHighlight: [],\n attributesToSnippet: [],\n tagFilters: tagFilters,\n analytics: false,\n clickAnalytics: false\n };\n\n var hierarchicalFacet = state.getHierarchicalFacetByName(facet);\n\n if (hierarchicalFacet) {\n additionalParams.facets = requestBuilder._getDisjunctiveHierarchicalFacetAttribute(\n state,\n hierarchicalFacet,\n hierarchicalRootLevel\n );\n } else {\n additionalParams.facets = facet;\n }\n\n if (numericFilters.length > 0) {\n additionalParams.numericFilters = numericFilters;\n }\n\n if (facetFilters.length > 0) {\n additionalParams.facetFilters = facetFilters;\n }\n\n return merge(state.getQueryParams(), additionalParams);\n },\n\n /**\n * Return the numeric filters in an algolia request fashion\n * @private\n * @param {string} [facetName] the name of the attribute for which the filters should be excluded\n * @return {string[]} the numeric filters in the algolia format\n */\n _getNumericFilters: function(state, facetName) {\n if (state.numericFilters) {\n return state.numericFilters;\n }\n\n var numericFilters = [];\n\n forEach(state.numericRefinements, function(operators, attribute) {\n forEach(operators, function(values, operator) {\n if (facetName !== attribute) {\n forEach(values, function(value) {\n if (Array.isArray(value)) {\n var vs = map(value, function(v) {\n return attribute + operator + v;\n });\n numericFilters.push(vs);\n } else {\n numericFilters.push(attribute + operator + value);\n }\n });\n }\n });\n });\n\n return numericFilters;\n },\n\n /**\n * Return the tags filters depending\n * @private\n * @return {string}\n */\n _getTagFilters: function(state) {\n if (state.tagFilters) {\n return state.tagFilters;\n }\n\n return state.tagRefinements.join(',');\n },\n\n\n /**\n * Build facetFilters parameter based on current refinements. The array returned\n * contains strings representing the facet filters in the algolia format.\n * @private\n * @param {string} [facet] if set, the current disjunctive facet\n * @return {array.}\n */\n _getFacetFilters: function(state, facet, hierarchicalRootLevel) {\n var facetFilters = [];\n\n forEach(state.facetsRefinements, function(facetValues, facetName) {\n forEach(facetValues, function(facetValue) {\n facetFilters.push(facetName + ':' + facetValue);\n });\n });\n\n forEach(state.facetsExcludes, function(facetValues, facetName) {\n forEach(facetValues, function(facetValue) {\n facetFilters.push(facetName + ':-' + facetValue);\n });\n });\n\n forEach(state.disjunctiveFacetsRefinements, function(facetValues, facetName) {\n if (facetName === facet || !facetValues || facetValues.length === 0) return;\n var orFilters = [];\n\n forEach(facetValues, function(facetValue) {\n orFilters.push(facetName + ':' + facetValue);\n });\n\n facetFilters.push(orFilters);\n });\n\n forEach(state.hierarchicalFacetsRefinements, function(facetValues, facetName) {\n var facetValue = facetValues[0];\n\n if (facetValue === undefined) {\n return;\n }\n\n var hierarchicalFacet = state.getHierarchicalFacetByName(facetName);\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);\n var attributeToRefine;\n var attributesIndex;\n\n // we ask for parent facet values only when the `facet` is the current hierarchical facet\n if (facet === facetName) {\n // if we are at the root level already, no need to ask for facet values, we get them from\n // the hits query\n if (facetValue.indexOf(separator) === -1 || (!rootPath && hierarchicalRootLevel === true) ||\n (rootPath && rootPath.split(separator).length === facetValue.split(separator).length)) {\n return;\n }\n\n if (!rootPath) {\n attributesIndex = facetValue.split(separator).length - 2;\n facetValue = facetValue.slice(0, facetValue.lastIndexOf(separator));\n } else {\n attributesIndex = rootPath.split(separator).length - 1;\n facetValue = rootPath;\n }\n\n attributeToRefine = hierarchicalFacet.attributes[attributesIndex];\n } else {\n attributesIndex = facetValue.split(separator).length - 1;\n\n attributeToRefine = hierarchicalFacet.attributes[attributesIndex];\n }\n\n if (attributeToRefine) {\n facetFilters.push([attributeToRefine + ':' + facetValue]);\n }\n });\n\n return facetFilters;\n },\n\n _getHitsHierarchicalFacetsAttributes: function(state) {\n var out = [];\n\n return reduce(\n state.hierarchicalFacets,\n // ask for as much levels as there's hierarchical refinements\n function getHitsAttributesForHierarchicalFacet(allAttributes, hierarchicalFacet) {\n var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0];\n\n // if no refinement, ask for root level\n if (!hierarchicalRefinement) {\n allAttributes.push(hierarchicalFacet.attributes[0]);\n return allAttributes;\n }\n\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n var level = hierarchicalRefinement.split(separator).length;\n var newAttributes = hierarchicalFacet.attributes.slice(0, level + 1);\n\n return allAttributes.concat(newAttributes);\n }, out);\n },\n\n _getDisjunctiveHierarchicalFacetAttribute: function(state, hierarchicalFacet, rootLevel) {\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n if (rootLevel === true) {\n var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);\n var attributeIndex = 0;\n\n if (rootPath) {\n attributeIndex = rootPath.split(separator).length;\n }\n return [hierarchicalFacet.attributes[attributeIndex]];\n }\n\n var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0] || '';\n // if refinement is 'beers > IPA > Flying dog',\n // then we want `facets: ['beers > IPA']` as disjunctive facet (parent level values)\n\n var parentLevel = hierarchicalRefinement.split(separator).length - 1;\n return hierarchicalFacet.attributes.slice(0, parentLevel + 1);\n },\n\n getSearchForFacetQuery: function(facetName, query, maxFacetHits, state) {\n var stateForSearchForFacetValues = state.isDisjunctiveFacet(facetName) ?\n state.clearRefinements(facetName) :\n state;\n var searchForFacetSearchParameters = {\n facetQuery: query,\n facetName: facetName\n };\n if (typeof maxFacetHits === 'number') {\n searchForFacetSearchParameters.maxFacetHits = maxFacetHits;\n }\n var queries = merge(requestBuilder._getHitsSearchParams(stateForSearchForFacetValues), searchForFacetSearchParameters);\n return queries;\n }\n};\n\nmodule.exports = requestBuilder;\n","var baseForOwn = require('./_baseForOwn');\n\n/**\n * The base implementation of `_.invert` and `_.invertBy` which inverts\n * `object` with values transformed by `iteratee` and set by `setter`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} setter The function to set `accumulator` values.\n * @param {Function} iteratee The iteratee to transform values.\n * @param {Object} accumulator The initial inverted object.\n * @returns {Function} Returns `accumulator`.\n */\nfunction baseInverter(object, setter, iteratee, accumulator) {\n baseForOwn(object, function(value, key, object) {\n setter(accumulator, iteratee(value), key, object);\n });\n return accumulator;\n}\n\nmodule.exports = baseInverter;\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty;\nvar isArray = Array.isArray;\n\nvar hexTable = (function () {\n var array = [];\n for (var i = 0; i < 256; ++i) {\n array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());\n }\n\n return array;\n}());\n\nvar compactQueue = function compactQueue(queue) {\n while (queue.length > 1) {\n var item = queue.pop();\n var obj = item.obj[item.prop];\n\n if (isArray(obj)) {\n var compacted = [];\n\n for (var j = 0; j < obj.length; ++j) {\n if (typeof obj[j] !== 'undefined') {\n compacted.push(obj[j]);\n }\n }\n\n item.obj[item.prop] = compacted;\n }\n }\n};\n\nvar arrayToObject = function arrayToObject(source, options) {\n var obj = options && options.plainObjects ? Object.create(null) : {};\n for (var i = 0; i < source.length; ++i) {\n if (typeof source[i] !== 'undefined') {\n obj[i] = source[i];\n }\n }\n\n return obj;\n};\n\nvar merge = function merge(target, source, options) {\n if (!source) {\n return target;\n }\n\n if (typeof source !== 'object') {\n if (isArray(target)) {\n target.push(source);\n } else if (target && typeof target === 'object') {\n if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {\n target[source] = true;\n }\n } else {\n return [target, source];\n }\n\n return target;\n }\n\n if (!target || typeof target !== 'object') {\n return [target].concat(source);\n }\n\n var mergeTarget = target;\n if (isArray(target) && !isArray(source)) {\n mergeTarget = arrayToObject(target, options);\n }\n\n if (isArray(target) && isArray(source)) {\n source.forEach(function (item, i) {\n if (has.call(target, i)) {\n var targetItem = target[i];\n if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {\n target[i] = merge(targetItem, item, options);\n } else {\n target.push(item);\n }\n } else {\n target[i] = item;\n }\n });\n return target;\n }\n\n return Object.keys(source).reduce(function (acc, key) {\n var value = source[key];\n\n if (has.call(acc, key)) {\n acc[key] = merge(acc[key], value, options);\n } else {\n acc[key] = value;\n }\n return acc;\n }, mergeTarget);\n};\n\nvar assign = function assignSingleSource(target, source) {\n return Object.keys(source).reduce(function (acc, key) {\n acc[key] = source[key];\n return acc;\n }, target);\n};\n\nvar decode = function (str, decoder, charset) {\n var strWithoutPlus = str.replace(/\\+/g, ' ');\n if (charset === 'iso-8859-1') {\n // unescape never throws, no try...catch needed:\n return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);\n }\n // utf-8\n try {\n return decodeURIComponent(strWithoutPlus);\n } catch (e) {\n return strWithoutPlus;\n }\n};\n\nvar encode = function encode(str, defaultEncoder, charset) {\n // This code was originally written by Brian White (mscdex) for the io.js core querystring library.\n // It has been adapted here for stricter adherence to RFC 3986\n if (str.length === 0) {\n return str;\n }\n\n var string = typeof str === 'string' ? str : String(str);\n\n if (charset === 'iso-8859-1') {\n return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {\n return '%26%23' + parseInt($0.slice(2), 16) + '%3B';\n });\n }\n\n var out = '';\n for (var i = 0; i < string.length; ++i) {\n var c = string.charCodeAt(i);\n\n if (\n c === 0x2D // -\n || c === 0x2E // .\n || c === 0x5F // _\n || c === 0x7E // ~\n || (c >= 0x30 && c <= 0x39) // 0-9\n || (c >= 0x41 && c <= 0x5A) // a-z\n || (c >= 0x61 && c <= 0x7A) // A-Z\n ) {\n out += string.charAt(i);\n continue;\n }\n\n if (c < 0x80) {\n out = out + hexTable[c];\n continue;\n }\n\n if (c < 0x800) {\n out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);\n continue;\n }\n\n if (c < 0xD800 || c >= 0xE000) {\n out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);\n continue;\n }\n\n i += 1;\n c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));\n out += hexTable[0xF0 | (c >> 18)]\n + hexTable[0x80 | ((c >> 12) & 0x3F)]\n + hexTable[0x80 | ((c >> 6) & 0x3F)]\n + hexTable[0x80 | (c & 0x3F)];\n }\n\n return out;\n};\n\nvar compact = function compact(value) {\n var queue = [{ obj: { o: value }, prop: 'o' }];\n var refs = [];\n\n for (var i = 0; i < queue.length; ++i) {\n var item = queue[i];\n var obj = item.obj[item.prop];\n\n var keys = Object.keys(obj);\n for (var j = 0; j < keys.length; ++j) {\n var key = keys[j];\n var val = obj[key];\n if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {\n queue.push({ obj: obj, prop: key });\n refs.push(val);\n }\n }\n }\n\n compactQueue(queue);\n\n return value;\n};\n\nvar isRegExp = function isRegExp(obj) {\n return Object.prototype.toString.call(obj) === '[object RegExp]';\n};\n\nvar isBuffer = function isBuffer(obj) {\n if (!obj || typeof obj !== 'object') {\n return false;\n }\n\n return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));\n};\n\nvar combine = function combine(a, b) {\n return [].concat(a, b);\n};\n\nmodule.exports = {\n arrayToObject: arrayToObject,\n assign: assign,\n combine: combine,\n compact: compact,\n decode: decode,\n encode: encode,\n isBuffer: isBuffer,\n isRegExp: isRegExp,\n merge: merge\n};\n","'use strict';\n\nvar utils = require('./utils');\nvar formats = require('./formats');\nvar has = Object.prototype.hasOwnProperty;\n\nvar arrayPrefixGenerators = {\n brackets: function brackets(prefix) { // eslint-disable-line func-name-matching\n return prefix + '[]';\n },\n comma: 'comma',\n indices: function indices(prefix, key) { // eslint-disable-line func-name-matching\n return prefix + '[' + key + ']';\n },\n repeat: function repeat(prefix) { // eslint-disable-line func-name-matching\n return prefix;\n }\n};\n\nvar isArray = Array.isArray;\nvar push = Array.prototype.push;\nvar pushToArray = function (arr, valueOrArray) {\n push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);\n};\n\nvar toISO = Date.prototype.toISOString;\n\nvar defaults = {\n addQueryPrefix: false,\n allowDots: false,\n charset: 'utf-8',\n charsetSentinel: false,\n delimiter: '&',\n encode: true,\n encoder: utils.encode,\n encodeValuesOnly: false,\n formatter: formats.formatters[formats['default']],\n // deprecated\n indices: false,\n serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching\n return toISO.call(date);\n },\n skipNulls: false,\n strictNullHandling: false\n};\n\nvar stringify = function stringify( // eslint-disable-line func-name-matching\n object,\n prefix,\n generateArrayPrefix,\n strictNullHandling,\n skipNulls,\n encoder,\n filter,\n sort,\n allowDots,\n serializeDate,\n formatter,\n encodeValuesOnly,\n charset\n) {\n var obj = object;\n if (typeof filter === 'function') {\n obj = filter(prefix, obj);\n } else if (obj instanceof Date) {\n obj = serializeDate(obj);\n } else if (generateArrayPrefix === 'comma' && isArray(obj)) {\n obj = obj.join(',');\n }\n\n if (obj === null) {\n if (strictNullHandling) {\n return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;\n }\n\n obj = '';\n }\n\n if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {\n if (encoder) {\n var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset);\n return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))];\n }\n return [formatter(prefix) + '=' + formatter(String(obj))];\n }\n\n var values = [];\n\n if (typeof obj === 'undefined') {\n return values;\n }\n\n var objKeys;\n if (isArray(filter)) {\n objKeys = filter;\n } else {\n var keys = Object.keys(obj);\n objKeys = sort ? keys.sort(sort) : keys;\n }\n\n for (var i = 0; i < objKeys.length; ++i) {\n var key = objKeys[i];\n\n if (skipNulls && obj[key] === null) {\n continue;\n }\n\n if (isArray(obj)) {\n pushToArray(values, stringify(\n obj[key],\n typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,\n generateArrayPrefix,\n strictNullHandling,\n skipNulls,\n encoder,\n filter,\n sort,\n allowDots,\n serializeDate,\n formatter,\n encodeValuesOnly,\n charset\n ));\n } else {\n pushToArray(values, stringify(\n obj[key],\n prefix + (allowDots ? '.' + key : '[' + key + ']'),\n generateArrayPrefix,\n strictNullHandling,\n skipNulls,\n encoder,\n filter,\n sort,\n allowDots,\n serializeDate,\n formatter,\n encodeValuesOnly,\n charset\n ));\n }\n }\n\n return values;\n};\n\nvar normalizeStringifyOptions = function normalizeStringifyOptions(opts) {\n if (!opts) {\n return defaults;\n }\n\n if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {\n throw new TypeError('Encoder has to be a function.');\n }\n\n var charset = opts.charset || defaults.charset;\n if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {\n throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');\n }\n\n var format = formats['default'];\n if (typeof opts.format !== 'undefined') {\n if (!has.call(formats.formatters, opts.format)) {\n throw new TypeError('Unknown format option provided.');\n }\n format = opts.format;\n }\n var formatter = formats.formatters[format];\n\n var filter = defaults.filter;\n if (typeof opts.filter === 'function' || isArray(opts.filter)) {\n filter = opts.filter;\n }\n\n return {\n addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,\n allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,\n charset: charset,\n charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,\n delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,\n encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,\n encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,\n encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,\n filter: filter,\n formatter: formatter,\n serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,\n skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,\n sort: typeof opts.sort === 'function' ? opts.sort : null,\n strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling\n };\n};\n\nmodule.exports = function (object, opts) {\n var obj = object;\n var options = normalizeStringifyOptions(opts);\n\n var objKeys;\n var filter;\n\n if (typeof options.filter === 'function') {\n filter = options.filter;\n obj = filter('', obj);\n } else if (isArray(options.filter)) {\n filter = options.filter;\n objKeys = filter;\n }\n\n var keys = [];\n\n if (typeof obj !== 'object' || obj === null) {\n return '';\n }\n\n var arrayFormat;\n if (opts && opts.arrayFormat in arrayPrefixGenerators) {\n arrayFormat = opts.arrayFormat;\n } else if (opts && 'indices' in opts) {\n arrayFormat = opts.indices ? 'indices' : 'repeat';\n } else {\n arrayFormat = 'indices';\n }\n\n var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];\n\n if (!objKeys) {\n objKeys = Object.keys(obj);\n }\n\n if (options.sort) {\n objKeys.sort(options.sort);\n }\n\n for (var i = 0; i < objKeys.length; ++i) {\n var key = objKeys[i];\n\n if (options.skipNulls && obj[key] === null) {\n continue;\n }\n pushToArray(keys, stringify(\n obj[key],\n key,\n generateArrayPrefix,\n options.strictNullHandling,\n options.skipNulls,\n options.encode ? options.encoder : null,\n options.filter,\n options.sort,\n options.allowDots,\n options.serializeDate,\n options.formatter,\n options.encodeValuesOnly,\n options.charset\n ));\n }\n\n var joined = keys.join(options.delimiter);\n var prefix = options.addQueryPrefix === true ? '?' : '';\n\n if (options.charsetSentinel) {\n if (options.charset === 'iso-8859-1') {\n // encodeURIComponent('✓'), the \"numeric entity\" representation of a checkmark\n prefix += 'utf8=%26%2310003%3B&';\n } else {\n // encodeURIComponent('✓')\n prefix += 'utf8=%E2%9C%93&';\n }\n }\n\n return joined.length > 0 ? prefix + joined : '';\n};\n","'use strict';\n\nvar utils = require('./utils');\n\nvar has = Object.prototype.hasOwnProperty;\n\nvar defaults = {\n allowDots: false,\n allowPrototypes: false,\n arrayLimit: 20,\n charset: 'utf-8',\n charsetSentinel: false,\n comma: false,\n decoder: utils.decode,\n delimiter: '&',\n depth: 5,\n ignoreQueryPrefix: false,\n interpretNumericEntities: false,\n parameterLimit: 1000,\n parseArrays: true,\n plainObjects: false,\n strictNullHandling: false\n};\n\nvar interpretNumericEntities = function (str) {\n return str.replace(/&#(\\d+);/g, function ($0, numberStr) {\n return String.fromCharCode(parseInt(numberStr, 10));\n });\n};\n\n// This is what browsers will submit when the ✓ character occurs in an\n// application/x-www-form-urlencoded body and the encoding of the page containing\n// the form is iso-8859-1, or when the submitted form has an accept-charset\n// attribute of iso-8859-1. Presumably also with other charsets that do not contain\n// the ✓ character, such as us-ascii.\nvar isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')\n\n// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.\nvar charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')\n\nvar parseValues = function parseQueryStringValues(str, options) {\n var obj = {};\n var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\\?/, '') : str;\n var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;\n var parts = cleanStr.split(options.delimiter, limit);\n var skipIndex = -1; // Keep track of where the utf8 sentinel was found\n var i;\n\n var charset = options.charset;\n if (options.charsetSentinel) {\n for (i = 0; i < parts.length; ++i) {\n if (parts[i].indexOf('utf8=') === 0) {\n if (parts[i] === charsetSentinel) {\n charset = 'utf-8';\n } else if (parts[i] === isoSentinel) {\n charset = 'iso-8859-1';\n }\n skipIndex = i;\n i = parts.length; // The eslint settings do not allow break;\n }\n }\n }\n\n for (i = 0; i < parts.length; ++i) {\n if (i === skipIndex) {\n continue;\n }\n var part = parts[i];\n\n var bracketEqualsPos = part.indexOf(']=');\n var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;\n\n var key, val;\n if (pos === -1) {\n key = options.decoder(part, defaults.decoder, charset);\n val = options.strictNullHandling ? null : '';\n } else {\n key = options.decoder(part.slice(0, pos), defaults.decoder, charset);\n val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);\n }\n\n if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {\n val = interpretNumericEntities(val);\n }\n\n if (val && options.comma && val.indexOf(',') > -1) {\n val = val.split(',');\n }\n\n if (has.call(obj, key)) {\n obj[key] = utils.combine(obj[key], val);\n } else {\n obj[key] = val;\n }\n }\n\n return obj;\n};\n\nvar parseObject = function (chain, val, options) {\n var leaf = val;\n\n for (var i = chain.length - 1; i >= 0; --i) {\n var obj;\n var root = chain[i];\n\n if (root === '[]' && options.parseArrays) {\n obj = [].concat(leaf);\n } else {\n obj = options.plainObjects ? Object.create(null) : {};\n var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;\n var index = parseInt(cleanRoot, 10);\n if (!options.parseArrays && cleanRoot === '') {\n obj = { 0: leaf };\n } else if (\n !isNaN(index)\n && root !== cleanRoot\n && String(index) === cleanRoot\n && index >= 0\n && (options.parseArrays && index <= options.arrayLimit)\n ) {\n obj = [];\n obj[index] = leaf;\n } else {\n obj[cleanRoot] = leaf;\n }\n }\n\n leaf = obj;\n }\n\n return leaf;\n};\n\nvar parseKeys = function parseQueryStringKeys(givenKey, val, options) {\n if (!givenKey) {\n return;\n }\n\n // Transform dot notation to bracket notation\n var key = options.allowDots ? givenKey.replace(/\\.([^.[]+)/g, '[$1]') : givenKey;\n\n // The regex chunks\n\n var brackets = /(\\[[^[\\]]*])/;\n var child = /(\\[[^[\\]]*])/g;\n\n // Get the parent\n\n var segment = brackets.exec(key);\n var parent = segment ? key.slice(0, segment.index) : key;\n\n // Stash the parent if it exists\n\n var keys = [];\n if (parent) {\n // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties\n if (!options.plainObjects && has.call(Object.prototype, parent)) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n\n keys.push(parent);\n }\n\n // Loop through children appending to the array until we hit depth\n\n var i = 0;\n while ((segment = child.exec(key)) !== null && i < options.depth) {\n i += 1;\n if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {\n if (!options.allowPrototypes) {\n return;\n }\n }\n keys.push(segment[1]);\n }\n\n // If there's a remainder, just add whatever is left\n\n if (segment) {\n keys.push('[' + key.slice(segment.index) + ']');\n }\n\n return parseObject(keys, val, options);\n};\n\nvar normalizeParseOptions = function normalizeParseOptions(opts) {\n if (!opts) {\n return defaults;\n }\n\n if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {\n throw new TypeError('Decoder has to be a function.');\n }\n\n if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {\n throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');\n }\n var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;\n\n return {\n allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,\n allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,\n arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,\n charset: charset,\n charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,\n comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,\n decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,\n delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,\n depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth,\n ignoreQueryPrefix: opts.ignoreQueryPrefix === true,\n interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,\n parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,\n parseArrays: opts.parseArrays !== false,\n plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,\n strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling\n };\n};\n\nmodule.exports = function (str, opts) {\n var options = normalizeParseOptions(opts);\n\n if (str === '' || str === null || typeof str === 'undefined') {\n return options.plainObjects ? Object.create(null) : {};\n }\n\n var tempObj = typeof str === 'string' ? parseValues(str, options) : str;\n var obj = options.plainObjects ? Object.create(null) : {};\n\n // Iterate over the keys and setup the new object\n\n var keys = Object.keys(tempObj);\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var newObj = parseKeys(key, tempObj[key], options);\n obj = utils.merge(obj, newObj, options);\n }\n\n return utils.compact(obj);\n};\n","var baseInverter = require('./_baseInverter');\n\n/**\n * Creates a function like `_.invertBy`.\n *\n * @private\n * @param {Function} setter The function to set accumulator values.\n * @param {Function} toIteratee The function to resolve iteratees.\n * @returns {Function} Returns the new inverter function.\n */\nfunction createInverter(setter, toIteratee) {\n return function(object, iteratee) {\n return baseInverter(object, setter, toIteratee(iteratee), {});\n };\n}\n\nmodule.exports = createInverter;\n","var constant = require('./constant'),\n createInverter = require('./_createInverter'),\n identity = require('./identity');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Creates an object composed of the inverted keys and values of `object`.\n * If `object` contains duplicate values, subsequent values overwrite\n * property assignments of previous values.\n *\n * @static\n * @memberOf _\n * @since 0.7.0\n * @category Object\n * @param {Object} object The object to invert.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invert(object);\n * // => { '1': 'c', '2': 'b' }\n */\nvar invert = createInverter(function(result, value, key) {\n if (value != null &&\n typeof value.toString != 'function') {\n value = nativeObjectToString.call(value);\n }\n\n result[value] = key;\n}, constant(identity));\n\nmodule.exports = invert;\n","'use strict';\n\nvar invert = require('lodash/invert');\nvar keys = require('lodash/keys');\n\nvar keys2Short = {\n advancedSyntax: 'aS',\n allowTyposOnNumericTokens: 'aTONT',\n analyticsTags: 'aT',\n analytics: 'a',\n aroundLatLngViaIP: 'aLLVIP',\n aroundLatLng: 'aLL',\n aroundPrecision: 'aP',\n aroundRadius: 'aR',\n attributesToHighlight: 'aTH',\n attributesToRetrieve: 'aTR',\n attributesToSnippet: 'aTS',\n disjunctiveFacetsRefinements: 'dFR',\n disjunctiveFacets: 'dF',\n distinct: 'd',\n facetsExcludes: 'fE',\n facetsRefinements: 'fR',\n facets: 'f',\n getRankingInfo: 'gRI',\n hierarchicalFacetsRefinements: 'hFR',\n hierarchicalFacets: 'hF',\n highlightPostTag: 'hPoT',\n highlightPreTag: 'hPrT',\n hitsPerPage: 'hPP',\n ignorePlurals: 'iP',\n index: 'idx',\n insideBoundingBox: 'iBB',\n insidePolygon: 'iPg',\n length: 'l',\n maxValuesPerFacet: 'mVPF',\n minimumAroundRadius: 'mAR',\n minProximity: 'mP',\n minWordSizefor1Typo: 'mWS1T',\n minWordSizefor2Typos: 'mWS2T',\n numericFilters: 'nF',\n numericRefinements: 'nR',\n offset: 'o',\n optionalWords: 'oW',\n page: 'p',\n queryType: 'qT',\n query: 'q',\n removeWordsIfNoResults: 'rWINR',\n replaceSynonymsInHighlight: 'rSIH',\n restrictSearchableAttributes: 'rSA',\n synonyms: 's',\n tagFilters: 'tF',\n tagRefinements: 'tR',\n typoTolerance: 'tT',\n optionalTagFilters: 'oTF',\n optionalFacetFilters: 'oFF',\n snippetEllipsisText: 'sET',\n disableExactOnAttributes: 'dEOA',\n enableExactOnSingleWordQuery: 'eEOSWQ'\n};\n\nvar short2Keys = invert(keys2Short);\n\nmodule.exports = {\n /**\n * All the keys of the state, encoded.\n * @const\n */\n ENCODED_PARAMETERS: keys(short2Keys),\n /**\n * Decode a shorten attribute\n * @param {string} shortKey the shorten attribute\n * @return {string} the decoded attribute, undefined otherwise\n */\n decode: function(shortKey) {\n return short2Keys[shortKey];\n },\n /**\n * Encode an attribute into a short version\n * @param {string} key the attribute\n * @return {string} the shorten attribute\n */\n encode: function(key) {\n return keys2Short[key];\n }\n};\n","'use strict';\n\nvar replace = String.prototype.replace;\nvar percentTwenties = /%20/g;\n\nmodule.exports = {\n 'default': 'RFC3986',\n formatters: {\n RFC1738: function (value) {\n return replace.call(value, percentTwenties, '+');\n },\n RFC3986: function (value) {\n return value;\n }\n },\n RFC1738: 'RFC1738',\n RFC3986: 'RFC3986'\n};\n","'use strict';\n\nvar stringify = require('./stringify');\nvar parse = require('./parse');\nvar formats = require('./formats');\n\nmodule.exports = {\n formats: formats,\n parse: parse,\n stringify: stringify\n};\n","var baseRest = require('./_baseRest'),\n createWrap = require('./_createWrap'),\n getHolder = require('./_getHolder'),\n replaceHolders = require('./_replaceHolders');\n\n/** Used to compose bitmasks for function metadata. */\nvar WRAP_BIND_FLAG = 1,\n WRAP_PARTIAL_FLAG = 32;\n\n/**\n * Creates a function that invokes `func` with the `this` binding of `thisArg`\n * and `partials` prepended to the arguments it receives.\n *\n * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for partially applied arguments.\n *\n * **Note:** Unlike native `Function#bind`, this method doesn't set the \"length\"\n * property of bound functions.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to bind.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * function greet(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n *\n * var object = { 'user': 'fred' };\n *\n * var bound = _.bind(greet, object, 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * // Bound with placeholders.\n * var bound = _.bind(greet, object, _, '!');\n * bound('hi');\n * // => 'hi fred!'\n */\nvar bind = baseRest(function(func, thisArg, partials) {\n var bitmask = WRAP_BIND_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, getHolder(bind));\n bitmask |= WRAP_PARTIAL_FLAG;\n }\n return createWrap(func, bitmask, thisArg, partials, holders);\n});\n\n// Assign default placeholders.\nbind.placeholder = {};\n\nmodule.exports = bind;\n","var basePickBy = require('./_basePickBy'),\n hasIn = require('./hasIn');\n\n/**\n * The base implementation of `_.pick` without support for individual\n * property identifiers.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} paths The property paths to pick.\n * @returns {Object} Returns the new object.\n */\nfunction basePick(object, paths) {\n return basePickBy(object, paths, function(value, path) {\n return hasIn(object, path);\n });\n}\n\nmodule.exports = basePick;\n","var basePick = require('./_basePick'),\n flatRest = require('./_flatRest');\n\n/**\n * Creates an object composed of the picked `object` properties.\n *\n * @static\n * @since 0.1.0\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {...(string|string[])} [paths] The property paths to pick.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'a': 1, 'b': '2', 'c': 3 };\n *\n * _.pick(object, ['a', 'c']);\n * // => { 'a': 1, 'c': 3 }\n */\nvar pick = flatRest(function(object, paths) {\n return object == null ? {} : basePick(object, paths);\n});\n\nmodule.exports = pick;\n","var baseAssignValue = require('./_baseAssignValue'),\n baseForOwn = require('./_baseForOwn'),\n baseIteratee = require('./_baseIteratee');\n\n/**\n * The opposite of `_.mapValues`; this method creates an object with the\n * same values as `object` and keys generated by running each own enumerable\n * string keyed property of `object` thru `iteratee`. The iteratee is invoked\n * with three arguments: (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 3.8.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapValues\n * @example\n *\n * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {\n * return key + value;\n * });\n * // => { 'a1': 1, 'b2': 2 }\n */\nfunction mapKeys(object, iteratee) {\n var result = {};\n iteratee = baseIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, iteratee(value, key, object), value);\n });\n return result;\n}\n\nmodule.exports = mapKeys;\n","var baseAssignValue = require('./_baseAssignValue'),\n baseForOwn = require('./_baseForOwn'),\n baseIteratee = require('./_baseIteratee');\n\n/**\n * Creates an object with the same keys as `object` and values generated\n * by running each own enumerable string keyed property of `object` thru\n * `iteratee`. The iteratee is invoked with three arguments:\n * (value, key, object).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @returns {Object} Returns the new mapped object.\n * @see _.mapKeys\n * @example\n *\n * var users = {\n * 'fred': { 'user': 'fred', 'age': 40 },\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\n * };\n *\n * _.mapValues(users, function(o) { return o.age; });\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n *\n * // The `_.property` iteratee shorthand.\n * _.mapValues(users, 'age');\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n */\nfunction mapValues(object, iteratee) {\n var result = {};\n iteratee = baseIteratee(iteratee, 3);\n\n baseForOwn(object, function(value, key, object) {\n baseAssignValue(result, key, iteratee(value, key, object));\n });\n return result;\n}\n\nmodule.exports = mapValues;\n","'use strict';\n\n/**\n * Module containing the functions to serialize and deserialize\n * {SearchParameters} in the query string format\n * @module algoliasearchHelper.url\n */\n\nvar shortener = require('./SearchParameters/shortener');\nvar SearchParameters = require('./SearchParameters');\n\nvar qs = require('qs');\n\nvar bind = require('lodash/bind');\nvar forEach = require('lodash/forEach');\nvar pick = require('lodash/pick');\nvar map = require('lodash/map');\nvar mapKeys = require('lodash/mapKeys');\nvar mapValues = require('lodash/mapValues');\nvar isString = require('lodash/isString');\nvar isPlainObject = require('lodash/isPlainObject');\nvar isEmpty = require('lodash/isEmpty');\nvar invert = require('lodash/invert');\n\nvar encode = require('qs/lib/utils').encode;\n\nfunction recursiveEncode(input) {\n if (isPlainObject(input)) {\n return mapValues(input, recursiveEncode);\n }\n if (Array.isArray(input)) {\n return map(input, recursiveEncode);\n }\n if (isString(input)) {\n return encode(input);\n }\n return input;\n}\n\nvar refinementsParameters = ['dFR', 'fR', 'nR', 'hFR', 'tR'];\nvar stateKeys = shortener.ENCODED_PARAMETERS;\nfunction sortQueryStringValues(prefixRegexp, invertedMapping, a, b) {\n if (prefixRegexp !== null) {\n a = a.replace(prefixRegexp, '');\n b = b.replace(prefixRegexp, '');\n }\n\n a = invertedMapping[a] || a;\n b = invertedMapping[b] || b;\n\n if (stateKeys.indexOf(a) !== -1 || stateKeys.indexOf(b) !== -1) {\n if (a === 'q') return -1;\n if (b === 'q') return 1;\n\n var isARefinements = refinementsParameters.indexOf(a) !== -1;\n var isBRefinements = refinementsParameters.indexOf(b) !== -1;\n if (isARefinements && !isBRefinements) {\n return 1;\n } else if (isBRefinements && !isARefinements) {\n return -1;\n }\n }\n\n return a.localeCompare(b);\n}\n\n/**\n * Read a query string and return an object containing the state\n * @param {string} queryString the query string that will be decoded\n * @param {object} [options] accepted options :\n * - prefix : the prefix used for the saved attributes, you have to provide the\n * same that was used for serialization\n * - mapping : map short attributes to another value e.g. {q: 'query'}\n * @return {object} partial search parameters object (same properties than in the\n * SearchParameters but not exhaustive)\n */\nexports.getStateFromQueryString = function(queryString, options) {\n var prefixForParameters = options && options.prefix || '';\n var mapping = options && options.mapping || {};\n var invertedMapping = invert(mapping);\n\n var partialStateWithPrefix = qs.parse(queryString);\n var prefixRegexp = new RegExp('^' + prefixForParameters);\n var partialState = mapKeys(\n partialStateWithPrefix,\n function(v, k) {\n var hasPrefix = prefixForParameters && prefixRegexp.test(k);\n var unprefixedKey = hasPrefix ? k.replace(prefixRegexp, '') : k;\n var decodedKey = shortener.decode(invertedMapping[unprefixedKey] || unprefixedKey);\n return decodedKey || unprefixedKey;\n }\n );\n\n var partialStateWithParsedNumbers = SearchParameters._parseNumbers(partialState);\n\n return pick(partialStateWithParsedNumbers, SearchParameters.PARAMETERS);\n};\n\n/**\n * Retrieve an object of all the properties that are not understandable as helper\n * parameters.\n * @param {string} queryString the query string to read\n * @param {object} [options] the options\n * - prefixForParameters : prefix used for the helper configuration keys\n * - mapping : map short attributes to another value e.g. {q: 'query'}\n * @return {object} the object containing the parsed configuration that doesn't\n * to the helper\n */\nexports.getUnrecognizedParametersInQueryString = function(queryString, options) {\n var prefixForParameters = options && options.prefix;\n var mapping = options && options.mapping || {};\n var invertedMapping = invert(mapping);\n\n var foreignConfig = {};\n var config = qs.parse(queryString);\n if (prefixForParameters) {\n var prefixRegexp = new RegExp('^' + prefixForParameters);\n forEach(config, function(v, key) {\n if (!prefixRegexp.test(key)) foreignConfig[key] = v;\n });\n } else {\n forEach(config, function(v, key) {\n if (!shortener.decode(invertedMapping[key] || key)) foreignConfig[key] = v;\n });\n }\n\n return foreignConfig;\n};\n\n/**\n * Generate a query string for the state passed according to the options\n * @param {SearchParameters} state state to serialize\n * @param {object} [options] May contain the following parameters :\n * - prefix : prefix in front of the keys\n * - mapping : map short attributes to another value e.g. {q: 'query'}\n * - moreAttributes : more values to be added in the query string. Those values\n * won't be prefixed.\n * - safe : get safe urls for use in emails, chat apps or any application auto linking urls.\n * All parameters and values will be encoded in a way that it's safe to share them.\n * Default to false for legacy reasons ()\n * @return {string} the query string\n */\nexports.getQueryStringFromState = function(state, options) {\n var moreAttributes = options && options.moreAttributes;\n var prefixForParameters = options && options.prefix || '';\n var mapping = options && options.mapping || {};\n var safe = options && options.safe || false;\n var invertedMapping = invert(mapping);\n\n var stateForUrl = safe ? state : recursiveEncode(state);\n\n var encodedState = mapKeys(\n stateForUrl,\n function(v, k) {\n var shortK = shortener.encode(k);\n return prefixForParameters + (mapping[shortK] || shortK);\n }\n );\n\n var prefixRegexp = prefixForParameters === '' ? null : new RegExp('^' + prefixForParameters);\n var sort = bind(sortQueryStringValues, null, prefixRegexp, invertedMapping);\n if (!isEmpty(moreAttributes)) {\n var stateQs = qs.stringify(encodedState, {encode: safe, sort: sort});\n var moreQs = qs.stringify(moreAttributes, {encode: safe});\n if (!stateQs) return moreQs;\n return stateQs + '&' + moreQs;\n }\n\n return qs.stringify(encodedState, {encode: safe, sort: sort});\n};\n","'use strict';\n\nmodule.exports = '2.28.0';\n","'use strict';\n\nvar SearchParameters = require('./SearchParameters');\nvar SearchResults = require('./SearchResults');\nvar DerivedHelper = require('./DerivedHelper');\nvar requestBuilder = require('./requestBuilder');\n\nvar events = require('events');\nvar inherits = require('./functions/inherits');\n\nvar flatten = require('lodash/flatten');\nvar forEach = require('lodash/forEach');\nvar isEmpty = require('lodash/isEmpty');\nvar map = require('lodash/map');\n\nvar url = require('./url');\nvar version = require('./version');\n\n/**\n * Event triggered when a parameter is set or updated\n * @event AlgoliaSearchHelper#event:change\n * @property {SearchParameters} state the current parameters with the latest changes applied\n * @property {SearchResults} lastResults the previous results received from Algolia. `null` before\n * the first request\n * @example\n * helper.on('change', function(state, lastResults) {\n * console.log('The parameters have changed');\n * });\n */\n\n/**\n * Event triggered when a main search is sent to Algolia\n * @event AlgoliaSearchHelper#event:search\n * @property {SearchParameters} state the parameters used for this search\n * @property {SearchResults} lastResults the results from the previous search. `null` if\n * it is the first search.\n * @example\n * helper.on('search', function(state, lastResults) {\n * console.log('Search sent');\n * });\n */\n\n/**\n * Event triggered when a search using `searchForFacetValues` is sent to Algolia\n * @event AlgoliaSearchHelper#event:searchForFacetValues\n * @property {SearchParameters} state the parameters used for this search\n * it is the first search.\n * @property {string} facet the facet searched into\n * @property {string} query the query used to search in the facets\n * @example\n * helper.on('searchForFacetValues', function(state, facet, query) {\n * console.log('searchForFacetValues sent');\n * });\n */\n\n/**\n * Event triggered when a search using `searchOnce` is sent to Algolia\n * @event AlgoliaSearchHelper#event:searchOnce\n * @property {SearchParameters} state the parameters used for this search\n * it is the first search.\n * @example\n * helper.on('searchOnce', function(state) {\n * console.log('searchOnce sent');\n * });\n */\n\n/**\n * Event triggered when the results are retrieved from Algolia\n * @event AlgoliaSearchHelper#event:result\n * @property {SearchResults} results the results received from Algolia\n * @property {SearchParameters} state the parameters used to query Algolia. Those might\n * be different from the one in the helper instance (for example if the network is unreliable).\n * @example\n * helper.on('result', function(results, state) {\n * console.log('Search results received');\n * });\n */\n\n/**\n * Event triggered when Algolia sends back an error. For example, if an unknown parameter is\n * used, the error can be caught using this event.\n * @event AlgoliaSearchHelper#event:error\n * @property {Error} error the error returned by the Algolia.\n * @example\n * helper.on('error', function(error) {\n * console.log('Houston we got a problem.');\n * });\n */\n\n/**\n * Event triggered when the queue of queries have been depleted (with any result or outdated queries)\n * @event AlgoliaSearchHelper#event:searchQueueEmpty\n * @example\n * helper.on('searchQueueEmpty', function() {\n * console.log('No more search pending');\n * // This is received before the result event if we're not expecting new results\n * });\n *\n * helper.search();\n */\n\n/**\n * Initialize a new AlgoliaSearchHelper\n * @class\n * @classdesc The AlgoliaSearchHelper is a class that ease the management of the\n * search. It provides an event based interface for search callbacks:\n * - change: when the internal search state is changed.\n * This event contains a {@link SearchParameters} object and the\n * {@link SearchResults} of the last result if any.\n * - search: when a search is triggered using the `search()` method.\n * - result: when the response is retrieved from Algolia and is processed.\n * This event contains a {@link SearchResults} object and the\n * {@link SearchParameters} corresponding to this answer.\n * - error: when the response is an error. This event contains the error returned by the server.\n * @param {AlgoliaSearch} client an AlgoliaSearch client\n * @param {string} index the index name to query\n * @param {SearchParameters | object} options an object defining the initial\n * config of the search. It doesn't have to be a {SearchParameters},\n * just an object containing the properties you need from it.\n */\nfunction AlgoliaSearchHelper(client, index, options) {\n if (client.addAlgoliaAgent && !doesClientAgentContainsHelper(client)) {\n client.addAlgoliaAgent('JS Helper (' + version + ')');\n }\n\n this.setClient(client);\n var opts = options || {};\n opts.index = index;\n this.state = SearchParameters.make(opts);\n this.lastResults = null;\n this._queryId = 0;\n this._lastQueryIdReceived = -1;\n this.derivedHelpers = [];\n this._currentNbQueries = 0;\n}\n\ninherits(AlgoliaSearchHelper, events.EventEmitter);\n\n/**\n * Start the search with the parameters set in the state. When the\n * method is called, it triggers a `search` event. The results will\n * be available through the `result` event. If an error occurs, an\n * `error` will be fired instead.\n * @return {AlgoliaSearchHelper}\n * @fires search\n * @fires result\n * @fires error\n * @chainable\n */\nAlgoliaSearchHelper.prototype.search = function() {\n this._search();\n return this;\n};\n\n/**\n * Gets the search query parameters that would be sent to the Algolia Client\n * for the hits\n * @return {object} Query Parameters\n */\nAlgoliaSearchHelper.prototype.getQuery = function() {\n var state = this.state;\n return requestBuilder._getHitsSearchParams(state);\n};\n\n/**\n * Start a search using a modified version of the current state. This method does\n * not trigger the helper lifecycle and does not modify the state kept internally\n * by the helper. This second aspect means that the next search call will be the\n * same as a search call before calling searchOnce.\n * @param {object} options can contain all the parameters that can be set to SearchParameters\n * plus the index\n * @param {function} [callback] optional callback executed when the response from the\n * server is back.\n * @return {promise|undefined} if a callback is passed the method returns undefined\n * otherwise it returns a promise containing an object with two keys :\n * - content with a SearchResults\n * - state with the state used for the query as a SearchParameters\n * @example\n * // Changing the number of records returned per page to 1\n * // This example uses the callback API\n * var state = helper.searchOnce({hitsPerPage: 1},\n * function(error, content, state) {\n * // if an error occurred it will be passed in error, otherwise its value is null\n * // content contains the results formatted as a SearchResults\n * // state is the instance of SearchParameters used for this search\n * });\n * @example\n * // Changing the number of records returned per page to 1\n * // This example uses the promise API\n * var state1 = helper.searchOnce({hitsPerPage: 1})\n * .then(promiseHandler);\n *\n * function promiseHandler(res) {\n * // res contains\n * // {\n * // content : SearchResults\n * // state : SearchParameters (the one used for this specific search)\n * // }\n * }\n */\nAlgoliaSearchHelper.prototype.searchOnce = function(options, cb) {\n var tempState = !options ? this.state : this.state.setQueryParameters(options);\n var queries = requestBuilder._getQueries(tempState.index, tempState);\n var self = this;\n\n this._currentNbQueries++;\n\n this.emit('searchOnce', tempState);\n\n if (cb) {\n this.client\n .search(queries)\n .then(function(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) {\n self.emit('searchQueueEmpty');\n }\n\n cb(null, new SearchResults(tempState, content.results), tempState);\n })\n .catch(function(err) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) {\n self.emit('searchQueueEmpty');\n }\n\n cb(err, null, tempState);\n });\n\n return undefined;\n }\n\n return this.client.search(queries).then(function(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n return {\n content: new SearchResults(tempState, content.results),\n state: tempState,\n _originalResponse: content\n };\n }, function(e) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n throw e;\n });\n};\n\n/**\n * Structure of each result when using\n * [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)\n * @typedef FacetSearchHit\n * @type {object}\n * @property {string} value the facet value\n * @property {string} highlighted the facet value highlighted with the query string\n * @property {number} count number of occurrence of this facet value\n * @property {boolean} isRefined true if the value is already refined\n */\n\n/**\n * Structure of the data resolved by the\n * [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)\n * promise.\n * @typedef FacetSearchResult\n * @type {object}\n * @property {FacetSearchHit} facetHits the results for this search for facet values\n * @property {number} processingTimeMS time taken by the query inside the engine\n */\n\n/**\n * Search for facet values based on an query and the name of a faceted attribute. This\n * triggers a search and will return a promise. On top of using the query, it also sends\n * the parameters from the state so that the search is narrowed down to only the possible values.\n *\n * See the description of [FacetSearchResult](reference.html#FacetSearchResult)\n * @param {string} facet the name of the faceted attribute\n * @param {string} query the string query for the search\n * @param {number} [maxFacetHits] the maximum number values returned. Should be > 0 and <= 100\n * @param {object} [userState] the set of custom parameters to use on top of the current state. Setting a property to `undefined` removes\n * it in the generated query.\n * @return {promise.} the results of the search\n */\nAlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {\n var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';\n if (\n !clientHasSFFV &&\n typeof this.client.initIndex !== 'function'\n ) {\n throw new Error(\n 'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'\n );\n }\n var state = this.state.setQueryParameters(userState || {});\n var isDisjunctive = state.isDisjunctiveFacet(facet);\n var algoliaQuery = requestBuilder.getSearchForFacetQuery(facet, query, maxFacetHits, state);\n\n this._currentNbQueries++;\n var self = this;\n\n this.emit('searchForFacetValues', state, facet, query);\n var searchForFacetValuesPromise = clientHasSFFV\n ? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])\n : this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);\n\n return searchForFacetValuesPromise.then(function addIsRefined(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n\n content = Array.isArray(content) ? content[0] : content;\n\n content.facetHits = forEach(content.facetHits, function(f) {\n f.isRefined = isDisjunctive ?\n state.isDisjunctiveFacetRefined(facet, f.value) :\n state.isFacetRefined(facet, f.value);\n });\n\n return content;\n }, function(e) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n throw e;\n });\n};\n\n/**\n * Sets the text query used for the search.\n *\n * This method resets the current page to 0.\n * @param {string} q the user query\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setQuery = function(q) {\n this._change(this.state.setPage(0).setQuery(q));\n return this;\n};\n\n/**\n * Remove all the types of refinements except tags. A string can be provided to remove\n * only the refinements of a specific attribute. For more advanced use case, you can\n * provide a function instead. This function should follow the\n * [clearCallback definition](#SearchParameters.clearCallback).\n *\n * This method resets the current page to 0.\n * @param {string} [name] optional name of the facet / attribute on which we want to remove all refinements\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * // Removing all the refinements\n * helper.clearRefinements().search();\n * @example\n * // Removing all the filters on a the category attribute.\n * helper.clearRefinements('category').search();\n * @example\n * // Removing only the exclude filters on the category facet.\n * helper.clearRefinements(function(value, attribute, type) {\n * return type === 'exclude' && attribute === 'category';\n * }).search();\n */\nAlgoliaSearchHelper.prototype.clearRefinements = function(name) {\n this._change(this.state.setPage(0).clearRefinements(name));\n return this;\n};\n\n/**\n * Remove all the tag filters.\n *\n * This method resets the current page to 0.\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.clearTags = function() {\n this._change(this.state.setPage(0).clearTags());\n return this;\n};\n\n/**\n * Adds a disjunctive filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addDisjunctiveFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).addDisjunctiveFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addDisjunctiveFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.addDisjunctiveRefine = function() {\n return this.addDisjunctiveFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Adds a refinement on a hierarchical facet. It will throw\n * an exception if the facet is not defined or if the facet\n * is already refined.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet name\n * @param {string} path the hierarchical facet path\n * @return {AlgoliaSearchHelper}\n * @throws Error if the facet is not defined or if the facet is refined\n * @chainable\n * @fires change\n */\nAlgoliaSearchHelper.prototype.addHierarchicalFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).addHierarchicalFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * Adds a an numeric filter to an attribute with the `operator` and `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} attribute the attribute on which the numeric filter applies\n * @param {string} operator the operator of the filter\n * @param {number} value the value of the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addNumericRefinement = function(attribute, operator, value) {\n this._change(this.state.setPage(0).addNumericRefinement(attribute, operator, value));\n return this;\n};\n\n/**\n * Adds a filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).addFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.addRefine = function() {\n return this.addFacetRefinement.apply(this, arguments);\n};\n\n\n/**\n * Adds a an exclusion filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addFacetExclusion = function(facet, value) {\n this._change(this.state.setPage(0).addExcludeRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.addExclude = function() {\n return this.addFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Adds a tag filter with the `tag` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} tag the tag to add to the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addTag = function(tag) {\n this._change(this.state.setPage(0).addTagRefinement(tag));\n return this;\n};\n\n/**\n * Removes an numeric filter to an attribute with the `operator` and `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * Some parameters are optional, triggering different behavior:\n * - if the value is not provided, then all the numeric value will be removed for the\n * specified attribute/operator couple.\n * - if the operator is not provided either, then all the numeric filter on this attribute\n * will be removed.\n *\n * This method resets the current page to 0.\n * @param {string} attribute the attribute on which the numeric filter applies\n * @param {string} [operator] the operator of the filter\n * @param {number} [value] the value of the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeNumericRefinement = function(attribute, operator, value) {\n this._change(this.state.setPage(0).removeNumericRefinement(attribute, operator, value));\n return this;\n};\n\n/**\n * Removes a disjunctive filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeDisjunctiveFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).removeDisjunctiveFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeDisjunctiveFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.removeDisjunctiveRefine = function() {\n return this.removeDisjunctiveFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Removes the refinement set on a hierarchical facet.\n * @param {string} facet the facet name\n * @return {AlgoliaSearchHelper}\n * @throws Error if the facet is not defined or if the facet is not refined\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeHierarchicalFacetRefinement = function(facet) {\n this._change(this.state.setPage(0).removeHierarchicalFacetRefinement(facet));\n\n return this;\n};\n\n/**\n * Removes a filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).removeFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.removeRefine = function() {\n return this.removeFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Removes an exclusion filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeFacetExclusion = function(facet, value) {\n this._change(this.state.setPage(0).removeExcludeRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.removeExclude = function() {\n return this.removeFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Removes a tag filter with the `tag` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} tag tag to remove from the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeTag = function(tag) {\n this._change(this.state.setPage(0).removeTagRefinement(tag));\n return this;\n};\n\n/**\n * Adds or removes an exclusion filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleFacetExclusion = function(facet, value) {\n this._change(this.state.setPage(0).toggleExcludeFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.toggleExclude = function() {\n return this.toggleFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Adds or removes a filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method can be used for conjunctive, disjunctive and hierarchical filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @throws Error will throw an error if the facet is not declared in the settings of the helper\n * @fires change\n * @chainable\n * @deprecated since version 2.19.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.toggleRefinement = function(facet, value) {\n return this.toggleFacetRefinement(facet, value);\n};\n\n/**\n * Adds or removes a filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method can be used for conjunctive, disjunctive and hierarchical filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @throws Error will throw an error if the facet is not declared in the settings of the helper\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleFacetRefinement = function(facet, value) {\n this._change(this.state.setPage(0).toggleFacetRefinement(facet, value));\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.toggleRefine = function() {\n return this.toggleFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Adds or removes a tag filter with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method resets the current page to 0.\n * @param {string} tag tag to remove or add\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleTag = function(tag) {\n this._change(this.state.setPage(0).toggleTagRefinement(tag));\n return this;\n};\n\n/**\n * Increments the page number by one.\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * helper.setPage(0).nextPage().getPage();\n * // returns 1\n */\nAlgoliaSearchHelper.prototype.nextPage = function() {\n return this.setPage(this.state.page + 1);\n};\n\n/**\n * Decrements the page number by one.\n * @fires change\n * @return {AlgoliaSearchHelper}\n * @chainable\n * @example\n * helper.setPage(1).previousPage().getPage();\n * // returns 0\n */\nAlgoliaSearchHelper.prototype.previousPage = function() {\n return this.setPage(this.state.page - 1);\n};\n\n/**\n * @private\n */\nfunction setCurrentPage(page) {\n if (page < 0) throw new Error('Page requested below 0.');\n\n this._change(this.state.setPage(page));\n return this;\n}\n\n/**\n * Change the current page\n * @deprecated\n * @param {number} page The page number\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setCurrentPage = setCurrentPage;\n\n/**\n * Updates the current page.\n * @function\n * @param {number} page The page number\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setPage = setCurrentPage;\n\n/**\n * Updates the name of the index that will be targeted by the query.\n *\n * This method resets the current page to 0.\n * @param {string} name the index name\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setIndex = function(name) {\n this._change(this.state.setPage(0).setIndex(name));\n return this;\n};\n\n/**\n * Update a parameter of the search. This method reset the page\n *\n * The complete list of parameters is available on the\n * [Algolia website](https://www.algolia.com/doc/rest#query-an-index).\n * The most commonly used parameters have their own [shortcuts](#query-parameters-shortcuts)\n * or benefit from higher-level APIs (all the kind of filters and facets have their own API)\n *\n * This method resets the current page to 0.\n * @param {string} parameter name of the parameter to update\n * @param {any} value new value of the parameter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * helper.setQueryParameter('hitsPerPage', 20).search();\n */\nAlgoliaSearchHelper.prototype.setQueryParameter = function(parameter, value) {\n this._change(this.state.setPage(0).setQueryParameter(parameter, value));\n return this;\n};\n\n/**\n * Set the whole state (warning: will erase previous state)\n * @param {SearchParameters} newState the whole new state\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setState = function(newState) {\n this._change(SearchParameters.make(newState));\n return this;\n};\n\n/**\n * Get the current search state stored in the helper. This object is immutable.\n * @param {string[]} [filters] optional filters to retrieve only a subset of the state\n * @return {SearchParameters|object} if filters is specified a plain object is\n * returned containing only the requested fields, otherwise return the unfiltered\n * state\n * @example\n * // Get the complete state as stored in the helper\n * helper.getState();\n * @example\n * // Get a part of the state with all the refinements on attributes and the query\n * helper.getState(['query', 'attribute:category']);\n */\nAlgoliaSearchHelper.prototype.getState = function(filters) {\n if (filters === undefined) return this.state;\n return this.state.filter(filters);\n};\n\n/**\n * DEPRECATED Get part of the state as a query string. By default, the output keys will not\n * be prefixed and will only take the applied refinements and the query.\n * @deprecated\n * @param {object} [options] May contain the following parameters :\n *\n * **filters** : possible values are all the keys of the [SearchParameters](#searchparameters), `index` for\n * the index, all the refinements with `attribute:*` or for some specific attributes with\n * `attribute:theAttribute`\n *\n * **prefix** : prefix in front of the keys\n *\n * **moreAttributes** : more values to be added in the query string. Those values\n * won't be prefixed.\n * @return {string} the query string\n */\nAlgoliaSearchHelper.prototype.getStateAsQueryString = function getStateAsQueryString(options) {\n var filters = options && options.filters || ['query', 'attribute:*'];\n var partialState = this.getState(filters);\n\n return url.getQueryStringFromState(partialState, options);\n};\n\n/**\n * DEPRECATED Read a query string and return an object containing the state. Use\n * url module.\n * @deprecated\n * @static\n * @param {string} queryString the query string that will be decoded\n * @param {object} options accepted options :\n * - prefix : the prefix used for the saved attributes, you have to provide the\n * same that was used for serialization\n * @return {object} partial search parameters object (same properties than in the\n * SearchParameters but not exhaustive)\n * @see {@link url#getStateFromQueryString}\n */\nAlgoliaSearchHelper.getConfigurationFromQueryString = url.getStateFromQueryString;\n\n/**\n * DEPRECATED Retrieve an object of all the properties that are not understandable as helper\n * parameters. Use url module.\n * @deprecated\n * @static\n * @param {string} queryString the query string to read\n * @param {object} options the options\n * - prefixForParameters : prefix used for the helper configuration keys\n * @return {object} the object containing the parsed configuration that doesn't\n * to the helper\n */\nAlgoliaSearchHelper.getForeignConfigurationInQueryString = url.getUnrecognizedParametersInQueryString;\n\n/**\n * DEPRECATED Overrides part of the state with the properties stored in the provided query\n * string.\n * @deprecated\n * @param {string} queryString the query string containing the informations to url the state\n * @param {object} options optional parameters :\n * - prefix : prefix used for the algolia parameters\n * - triggerChange : if set to true the state update will trigger a change event\n */\nAlgoliaSearchHelper.prototype.setStateFromQueryString = function(queryString, options) {\n var triggerChange = options && options.triggerChange || false;\n var configuration = url.getStateFromQueryString(queryString, options);\n var updatedState = this.state.setQueryParameters(configuration);\n\n if (triggerChange) this.setState(updatedState);\n else this.overrideStateWithoutTriggeringChangeEvent(updatedState);\n};\n\n/**\n * Override the current state without triggering a change event.\n * Do not use this method unless you know what you are doing. (see the example\n * for a legit use case)\n * @param {SearchParameters} newState the whole new state\n * @return {AlgoliaSearchHelper}\n * @example\n * helper.on('change', function(state){\n * // In this function you might want to find a way to store the state in the url/history\n * updateYourURL(state)\n * })\n * window.onpopstate = function(event){\n * // This is naive though as you should check if the state is really defined etc.\n * helper.overrideStateWithoutTriggeringChangeEvent(event.state).search()\n * }\n * @chainable\n */\nAlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent = function(newState) {\n this.state = new SearchParameters(newState);\n return this;\n};\n\n/**\n * @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasRefinements}\n */\nAlgoliaSearchHelper.prototype.isRefined = function(facet, value) {\n if (this.state.isConjunctiveFacet(facet)) {\n return this.state.isFacetRefined(facet, value);\n } else if (this.state.isDisjunctiveFacet(facet)) {\n return this.state.isDisjunctiveFacetRefined(facet, value);\n }\n\n throw new Error(facet +\n ' is not properly defined in this helper configuration' +\n '(use the facets or disjunctiveFacets keys to configure it)');\n};\n\n/**\n * Check if an attribute has any numeric, conjunctive, disjunctive or hierarchical filters.\n * @param {string} attribute the name of the attribute\n * @return {boolean} true if the attribute is filtered by at least one value\n * @example\n * // hasRefinements works with numeric, conjunctive, disjunctive and hierarchical filters\n * helper.hasRefinements('price'); // false\n * helper.addNumericRefinement('price', '>', 100);\n * helper.hasRefinements('price'); // true\n *\n * helper.hasRefinements('color'); // false\n * helper.addFacetRefinement('color', 'blue');\n * helper.hasRefinements('color'); // true\n *\n * helper.hasRefinements('material'); // false\n * helper.addDisjunctiveFacetRefinement('material', 'plastic');\n * helper.hasRefinements('material'); // true\n *\n * helper.hasRefinements('categories'); // false\n * helper.toggleFacetRefinement('categories', 'kitchen > knife');\n * helper.hasRefinements('categories'); // true\n *\n */\nAlgoliaSearchHelper.prototype.hasRefinements = function(attribute) {\n if (!isEmpty(this.state.getNumericRefinements(attribute))) {\n return true;\n } else if (this.state.isConjunctiveFacet(attribute)) {\n return this.state.isFacetRefined(attribute);\n } else if (this.state.isDisjunctiveFacet(attribute)) {\n return this.state.isDisjunctiveFacetRefined(attribute);\n } else if (this.state.isHierarchicalFacet(attribute)) {\n return this.state.isHierarchicalFacetRefined(attribute);\n }\n\n // there's currently no way to know that the user did call `addNumericRefinement` at some point\n // thus we cannot distinguish if there once was a numeric refinement that was cleared\n // so we will return false in every other situations to be consistent\n // while what we should do here is throw because we did not find the attribute in any type\n // of refinement\n return false;\n};\n\n/**\n * Check if a value is excluded for a specific faceted attribute. If the value\n * is omitted then the function checks if there is any excluding refinements.\n *\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} [value] optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} true if refined\n * @example\n * helper.isExcludeRefined('color'); // false\n * helper.isExcludeRefined('color', 'blue') // false\n * helper.isExcludeRefined('color', 'red') // false\n *\n * helper.addFacetExclusion('color', 'red');\n *\n * helper.isExcludeRefined('color'); // true\n * helper.isExcludeRefined('color', 'blue') // false\n * helper.isExcludeRefined('color', 'red') // true\n */\nAlgoliaSearchHelper.prototype.isExcluded = function(facet, value) {\n return this.state.isExcludeRefined(facet, value);\n};\n\n/**\n * @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasRefinements}\n */\nAlgoliaSearchHelper.prototype.isDisjunctiveRefined = function(facet, value) {\n return this.state.isDisjunctiveFacetRefined(facet, value);\n};\n\n/**\n * Check if the string is a currently filtering tag.\n * @param {string} tag tag to check\n * @return {boolean}\n */\nAlgoliaSearchHelper.prototype.hasTag = function(tag) {\n return this.state.isTagRefined(tag);\n};\n\n/**\n * @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasTag}\n */\nAlgoliaSearchHelper.prototype.isTagRefined = function() {\n return this.hasTagRefinements.apply(this, arguments);\n};\n\n\n/**\n * Get the name of the currently used index.\n * @return {string}\n * @example\n * helper.setIndex('highestPrice_products').getIndex();\n * // returns 'highestPrice_products'\n */\nAlgoliaSearchHelper.prototype.getIndex = function() {\n return this.state.index;\n};\n\nfunction getCurrentPage() {\n return this.state.page;\n}\n\n/**\n * Get the currently selected page\n * @deprecated\n * @return {number} the current page\n */\nAlgoliaSearchHelper.prototype.getCurrentPage = getCurrentPage;\n/**\n * Get the currently selected page\n * @function\n * @return {number} the current page\n */\nAlgoliaSearchHelper.prototype.getPage = getCurrentPage;\n\n/**\n * Get all the tags currently set to filters the results.\n *\n * @return {string[]} The list of tags currently set.\n */\nAlgoliaSearchHelper.prototype.getTags = function() {\n return this.state.tagRefinements;\n};\n\n/**\n * Get a parameter of the search by its name. It is possible that a parameter is directly\n * defined in the index dashboard, but it will be undefined using this method.\n *\n * The complete list of parameters is\n * available on the\n * [Algolia website](https://www.algolia.com/doc/rest#query-an-index).\n * The most commonly used parameters have their own [shortcuts](#query-parameters-shortcuts)\n * or benefit from higher-level APIs (all the kind of filters have their own API)\n * @param {string} parameterName the parameter name\n * @return {any} the parameter value\n * @example\n * var hitsPerPage = helper.getQueryParameter('hitsPerPage');\n */\nAlgoliaSearchHelper.prototype.getQueryParameter = function(parameterName) {\n return this.state.getQueryParameter(parameterName);\n};\n\n/**\n * Get the list of refinements for a given attribute. This method works with\n * conjunctive, disjunctive, excluding and numerical filters.\n *\n * See also SearchResults#getRefinements\n *\n * @param {string} facetName attribute name used for faceting\n * @return {Array.} All Refinement are objects that contain a value, and\n * a type. Numeric also contains an operator.\n * @example\n * helper.addNumericRefinement('price', '>', 100);\n * helper.getRefinements('price');\n * // [\n * // {\n * // \"value\": [\n * // 100\n * // ],\n * // \"operator\": \">\",\n * // \"type\": \"numeric\"\n * // }\n * // ]\n * @example\n * helper.addFacetRefinement('color', 'blue');\n * helper.addFacetExclusion('color', 'red');\n * helper.getRefinements('color');\n * // [\n * // {\n * // \"value\": \"blue\",\n * // \"type\": \"conjunctive\"\n * // },\n * // {\n * // \"value\": \"red\",\n * // \"type\": \"exclude\"\n * // }\n * // ]\n * @example\n * helper.addDisjunctiveFacetRefinement('material', 'plastic');\n * // [\n * // {\n * // \"value\": \"plastic\",\n * // \"type\": \"disjunctive\"\n * // }\n * // ]\n */\nAlgoliaSearchHelper.prototype.getRefinements = function(facetName) {\n var refinements = [];\n\n if (this.state.isConjunctiveFacet(facetName)) {\n var conjRefinements = this.state.getConjunctiveRefinements(facetName);\n\n forEach(conjRefinements, function(r) {\n refinements.push({\n value: r,\n type: 'conjunctive'\n });\n });\n\n var excludeRefinements = this.state.getExcludeRefinements(facetName);\n\n forEach(excludeRefinements, function(r) {\n refinements.push({\n value: r,\n type: 'exclude'\n });\n });\n } else if (this.state.isDisjunctiveFacet(facetName)) {\n var disjRefinements = this.state.getDisjunctiveRefinements(facetName);\n\n forEach(disjRefinements, function(r) {\n refinements.push({\n value: r,\n type: 'disjunctive'\n });\n });\n }\n\n var numericRefinements = this.state.getNumericRefinements(facetName);\n\n forEach(numericRefinements, function(value, operator) {\n refinements.push({\n value: value,\n operator: operator,\n type: 'numeric'\n });\n });\n\n return refinements;\n};\n\n/**\n * Return the current refinement for the (attribute, operator)\n * @param {string} attribute attribute in the record\n * @param {string} operator operator applied on the refined values\n * @return {Array.} refined values\n */\nAlgoliaSearchHelper.prototype.getNumericRefinement = function(attribute, operator) {\n return this.state.getNumericRefinement(attribute, operator);\n};\n\n/**\n * Get the current breadcrumb for a hierarchical facet, as an array\n * @param {string} facetName Hierarchical facet name\n * @return {array.} the path as an array of string\n */\nAlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function(facetName) {\n return this.state.getHierarchicalFacetBreadcrumb(facetName);\n};\n\n// /////////// PRIVATE\n\n/**\n * Perform the underlying queries\n * @private\n * @return {undefined}\n * @fires search\n * @fires result\n * @fires error\n */\nAlgoliaSearchHelper.prototype._search = function() {\n var state = this.state;\n var mainQueries = requestBuilder._getQueries(state.index, state);\n\n var states = [{\n state: state,\n queriesCount: mainQueries.length,\n helper: this\n }];\n\n this.emit('search', state, this.lastResults);\n\n var derivedQueries = map(this.derivedHelpers, function(derivedHelper) {\n var derivedState = derivedHelper.getModifiedState(state);\n var queries = requestBuilder._getQueries(derivedState.index, derivedState);\n states.push({\n state: derivedState,\n queriesCount: queries.length,\n helper: derivedHelper\n });\n derivedHelper.emit('search', derivedState, derivedHelper.lastResults);\n return queries;\n });\n\n var queries = mainQueries.concat(flatten(derivedQueries));\n var queryId = this._queryId++;\n\n this._currentNbQueries++;\n\n try {\n this.client.search(queries)\n .then(this._dispatchAlgoliaResponse.bind(this, states, queryId))\n .catch(this._dispatchAlgoliaError.bind(this, queryId));\n } catch (err) {\n // If we reach this part, we're in an internal error state\n this.emit('error', err);\n }\n};\n\n/**\n * Transform the responses as sent by the server and transform them into a user\n * usable object that merge the results of all the batch requests. It will dispatch\n * over the different helper + derived helpers (when there are some).\n * @private\n * @param {array.<{SearchParameters, AlgoliaQueries, AlgoliaSearchHelper}>}\n * state state used for to generate the request\n * @param {number} queryId id of the current request\n * @param {object} content content of the response\n * @return {undefined}\n */\nAlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function(states, queryId, content) {\n // FIXME remove the number of outdated queries discarded instead of just one\n\n if (queryId < this._lastQueryIdReceived) {\n // Outdated answer\n return;\n }\n\n this._currentNbQueries -= (queryId - this._lastQueryIdReceived);\n this._lastQueryIdReceived = queryId;\n\n if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');\n\n var results = content.results.slice();\n forEach(states, function(s) {\n var state = s.state;\n var queriesCount = s.queriesCount;\n var helper = s.helper;\n var specificResults = results.splice(0, queriesCount);\n\n var formattedResponse = helper.lastResults = new SearchResults(state, specificResults);\n helper.emit('result', formattedResponse, state);\n });\n};\n\nAlgoliaSearchHelper.prototype._dispatchAlgoliaError = function(queryId, err) {\n if (queryId < this._lastQueryIdReceived) {\n // Outdated answer\n return;\n }\n\n this._currentNbQueries -= queryId - this._lastQueryIdReceived;\n this._lastQueryIdReceived = queryId;\n\n this.emit('error', err);\n\n if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');\n};\n\nAlgoliaSearchHelper.prototype.containsRefinement = function(query, facetFilters, numericFilters, tagFilters) {\n return query ||\n facetFilters.length !== 0 ||\n numericFilters.length !== 0 ||\n tagFilters.length !== 0;\n};\n\n/**\n * Test if there are some disjunctive refinements on the facet\n * @private\n * @param {string} facet the attribute to test\n * @return {boolean}\n */\nAlgoliaSearchHelper.prototype._hasDisjunctiveRefinements = function(facet) {\n return this.state.disjunctiveRefinements[facet] &&\n this.state.disjunctiveRefinements[facet].length > 0;\n};\n\nAlgoliaSearchHelper.prototype._change = function(newState) {\n if (newState !== this.state) {\n this.state = newState;\n this.emit('change', this.state, this.lastResults);\n }\n};\n\n/**\n * Clears the cache of the underlying Algolia client.\n * @return {AlgoliaSearchHelper}\n */\nAlgoliaSearchHelper.prototype.clearCache = function() {\n this.client.clearCache && this.client.clearCache();\n return this;\n};\n\n/**\n * Updates the internal client instance. If the reference of the clients\n * are equal then no update is actually done.\n * @param {AlgoliaSearch} newClient an AlgoliaSearch client\n * @return {AlgoliaSearchHelper}\n */\nAlgoliaSearchHelper.prototype.setClient = function(newClient) {\n if (this.client === newClient) return this;\n\n if (newClient.addAlgoliaAgent && !doesClientAgentContainsHelper(newClient)) {\n newClient.addAlgoliaAgent('JS Helper (' + version + ')');\n }\n this.client = newClient;\n\n return this;\n};\n\n/**\n * Gets the instance of the currently used client.\n * @return {AlgoliaSearch}\n */\nAlgoliaSearchHelper.prototype.getClient = function() {\n return this.client;\n};\n\n/**\n * Creates an derived instance of the Helper. A derived helper\n * is a way to request other indices synchronised with the lifecycle\n * of the main Helper. This mechanism uses the multiqueries feature\n * of Algolia to aggregate all the requests in a single network call.\n *\n * This method takes a function that is used to create a new SearchParameter\n * that will be used to create requests to Algolia. Those new requests\n * are created just before the `search` event. The signature of the function\n * is `SearchParameters -> SearchParameters`.\n *\n * This method returns a new DerivedHelper which is an EventEmitter\n * that fires the same `search`, `result` and `error` events. Those\n * events, however, will receive data specific to this DerivedHelper\n * and the SearchParameters that is returned by the call of the\n * parameter function.\n * @param {function} fn SearchParameters -> SearchParameters\n * @return {DerivedHelper}\n */\nAlgoliaSearchHelper.prototype.derive = function(fn) {\n var derivedHelper = new DerivedHelper(this, fn);\n this.derivedHelpers.push(derivedHelper);\n return derivedHelper;\n};\n\n/**\n * This method detaches a derived Helper from the main one. Prefer using the one from the\n * derived helper itself, to remove the event listeners too.\n * @private\n * @return {undefined}\n * @throws Error\n */\nAlgoliaSearchHelper.prototype.detachDerivedHelper = function(derivedHelper) {\n var pos = this.derivedHelpers.indexOf(derivedHelper);\n if (pos === -1) throw new Error('Derived helper already detached');\n this.derivedHelpers.splice(pos, 1);\n};\n\n/**\n * This method returns true if there is currently at least one on-going search.\n * @return {boolean} true if there is a search pending\n */\nAlgoliaSearchHelper.prototype.hasPendingRequests = function() {\n return this._currentNbQueries > 0;\n};\n\n/**\n * @typedef AlgoliaSearchHelper.NumericRefinement\n * @type {object}\n * @property {number[]} value the numbers that are used for filtering this attribute with\n * the operator specified.\n * @property {string} operator the faceting data: value, number of entries\n * @property {string} type will be 'numeric'\n */\n\n/**\n * @typedef AlgoliaSearchHelper.FacetRefinement\n * @type {object}\n * @property {string} value the string use to filter the attribute\n * @property {string} type the type of filter: 'conjunctive', 'disjunctive', 'exclude'\n */\n\n\n/*\n * This function tests if the _ua parameter of the client\n * already contains the JS Helper UA\n */\nfunction doesClientAgentContainsHelper(client) {\n // this relies on JS Client internal variable, this might break if implementation changes\n var currentAgent = client._ua;\n return !currentAgent ? false :\n currentAgent.indexOf('JS Helper') !== -1;\n}\n\nmodule.exports = AlgoliaSearchHelper;\n","'use strict';\n\nvar AlgoliaSearchHelper = require('./src/algoliasearch.helper');\n\nvar SearchParameters = require('./src/SearchParameters');\nvar SearchResults = require('./src/SearchResults');\n\n/**\n * The algoliasearchHelper module is the function that will let its\n * contains everything needed to use the Algoliasearch\n * Helper. It is a also a function that instanciate the helper.\n * To use the helper, you also need the Algolia JS client v3.\n * @example\n * //using the UMD build\n * var client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');\n * var helper = algoliasearchHelper(client, 'bestbuy', {\n * facets: ['shipping'],\n * disjunctiveFacets: ['category']\n * });\n * helper.on('result', function(result) {\n * console.log(result);\n * });\n * helper\n * .toggleFacetRefinement('category', 'Movies & TV Shows')\n * .toggleFacetRefinement('shipping', 'Free shipping')\n * .search();\n * @example\n * // The helper is an event emitter using the node API\n * helper.on('result', updateTheResults);\n * helper.once('result', updateTheResults);\n * helper.removeListener('result', updateTheResults);\n * helper.removeAllListeners('result');\n * @module algoliasearchHelper\n * @param {AlgoliaSearch} client an AlgoliaSearch client\n * @param {string} index the name of the index to query\n * @param {SearchParameters|object} opts an object defining the initial config of the search. It doesn't have to be a {SearchParameters}, just an object containing the properties you need from it.\n * @return {AlgoliaSearchHelper}\n */\nfunction algoliasearchHelper(client, index, opts) {\n return new AlgoliaSearchHelper(client, index, opts);\n}\n\n/**\n * The version currently used\n * @member module:algoliasearchHelper.version\n * @type {number}\n */\nalgoliasearchHelper.version = require('./src/version.js');\n\n/**\n * Constructor for the Helper.\n * @member module:algoliasearchHelper.AlgoliaSearchHelper\n * @type {AlgoliaSearchHelper}\n */\nalgoliasearchHelper.AlgoliaSearchHelper = AlgoliaSearchHelper;\n\n/**\n * Constructor for the object containing all the parameters of the search.\n * @member module:algoliasearchHelper.SearchParameters\n * @type {SearchParameters}\n */\nalgoliasearchHelper.SearchParameters = SearchParameters;\n\n/**\n * Constructor for the object containing the results of the search.\n * @member module:algoliasearchHelper.SearchResults\n * @type {SearchResults}\n */\nalgoliasearchHelper.SearchResults = SearchResults;\n\n/**\n * URL tools to generate query string and parse them from/into\n * SearchParameters\n * @member module:algoliasearchHelper.url\n * @type {object} {@link url}\n *\n */\nalgoliasearchHelper.url = require('./src/url');\n\nmodule.exports = algoliasearchHelper;\n","import isDomElement from './isDomElement';\n\n/**\n * Return the container. If it's a string, it is considered a\n * css selector and retrieves the first matching element. Otherwise\n * test if it validates that it's a correct DOMElement.\n *\n * @param {string|HTMLElement} selectorOrHTMLElement CSS Selector or container node.\n * @return {HTMLElement} Container node\n * @throws Error when the type is not correct\n */\nfunction getContainerNode(\n selectorOrHTMLElement: string | HTMLElement\n): HTMLElement {\n const isSelectorString = typeof selectorOrHTMLElement === 'string';\n const domElement = isSelectorString\n ? document.querySelector(selectorOrHTMLElement as string)\n : selectorOrHTMLElement;\n\n if (!isDomElement(domElement)) {\n let errorMessage = 'Container must be `string` or `HTMLElement`.';\n\n if (isSelectorString) {\n errorMessage += ` Unable to find ${selectorOrHTMLElement}`;\n }\n\n throw new Error(errorMessage);\n }\n\n return domElement;\n}\n\nexport default getContainerNode;\n","function isDomElement(object: any): object is HTMLElement {\n return (\n object instanceof HTMLElement || (Boolean(object) && object.nodeType > 0)\n );\n}\n\nexport default isDomElement;\n","function isSpecialClick(event: MouseEvent): boolean {\n const isMiddleClick = event.button === 1;\n\n return (\n isMiddleClick ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n );\n}\n\nexport default isSpecialClick;\n","function uniq(array: any[]): any[] {\n return array.filter((value, index, self) => self.indexOf(value) === index);\n}\n\nexport default uniq;\n","import uniq from './uniq';\n\nfunction prepareTemplates(defaultTemplates = {}, templates = {}) {\n const allKeys = uniq([\n ...Object.keys(defaultTemplates),\n ...Object.keys(templates),\n ]);\n\n return allKeys.reduce(\n (config, key) => {\n const defaultTemplate = defaultTemplates[key];\n const customTemplate = templates[key];\n const isCustomTemplate =\n customTemplate !== undefined && customTemplate !== defaultTemplate;\n\n config.templates[key] = isCustomTemplate\n ? customTemplate\n : defaultTemplate;\n config.useCustomCompileOptions[key] = isCustomTemplate;\n\n return config;\n },\n { templates: {}, useCustomCompileOptions: {} }\n );\n}\n\n/**\n * Prepares an object to be passed to the Template widget\n * @param {object} unknownBecauseES6 an object with the following attributes:\n * - defaultTemplate\n * - templates\n * - templatesConfig\n * @return {object} the configuration with the attributes:\n * - defaultTemplate\n * - templates\n * - useCustomCompileOptions\n */\nfunction prepareTemplateProps({\n defaultTemplates,\n templates,\n templatesConfig,\n}) {\n const preparedTemplates = prepareTemplates(defaultTemplates, templates);\n\n return {\n templatesConfig,\n ...preparedTemplates,\n };\n}\n\nexport default prepareTemplateProps;\n","/*\n * Copyright 2011 Twitter, Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n(function (Hogan) {\n // Setup regex assignments\n // remove whitespace according to Mustache spec\n var rIsWhitespace = /\\S/,\n rQuot = /\\\"/g,\n rNewline = /\\n/g,\n rCr = /\\r/g,\n rSlash = /\\\\/g,\n rLineSep = /\\u2028/,\n rParagraphSep = /\\u2029/;\n\n Hogan.tags = {\n '#': 1, '^': 2, '<': 3, '$': 4,\n '/': 5, '!': 6, '>': 7, '=': 8, '_v': 9,\n '{': 10, '&': 11, '_t': 12\n };\n\n Hogan.scan = function scan(text, delimiters) {\n var len = text.length,\n IN_TEXT = 0,\n IN_TAG_TYPE = 1,\n IN_TAG = 2,\n state = IN_TEXT,\n tagType = null,\n tag = null,\n buf = '',\n tokens = [],\n seenTag = false,\n i = 0,\n lineStart = 0,\n otag = '{{',\n ctag = '}}';\n\n function addBuf() {\n if (buf.length > 0) {\n tokens.push({tag: '_t', text: new String(buf)});\n buf = '';\n }\n }\n\n function lineIsWhitespace() {\n var isAllWhitespace = true;\n for (var j = lineStart; j < tokens.length; j++) {\n isAllWhitespace =\n (Hogan.tags[tokens[j].tag] < Hogan.tags['_v']) ||\n (tokens[j].tag == '_t' && tokens[j].text.match(rIsWhitespace) === null);\n if (!isAllWhitespace) {\n return false;\n }\n }\n\n return isAllWhitespace;\n }\n\n function filterLine(haveSeenTag, noNewLine) {\n addBuf();\n\n if (haveSeenTag && lineIsWhitespace()) {\n for (var j = lineStart, next; j < tokens.length; j++) {\n if (tokens[j].text) {\n if ((next = tokens[j+1]) && next.tag == '>') {\n // set indent to token value\n next.indent = tokens[j].text.toString()\n }\n tokens.splice(j, 1);\n }\n }\n } else if (!noNewLine) {\n tokens.push({tag:'\\n'});\n }\n\n seenTag = false;\n lineStart = tokens.length;\n }\n\n function changeDelimiters(text, index) {\n var close = '=' + ctag,\n closeIndex = text.indexOf(close, index),\n delimiters = trim(\n text.substring(text.indexOf('=', index) + 1, closeIndex)\n ).split(' ');\n\n otag = delimiters[0];\n ctag = delimiters[delimiters.length - 1];\n\n return closeIndex + close.length - 1;\n }\n\n if (delimiters) {\n delimiters = delimiters.split(' ');\n otag = delimiters[0];\n ctag = delimiters[1];\n }\n\n for (i = 0; i < len; i++) {\n if (state == IN_TEXT) {\n if (tagChange(otag, text, i)) {\n --i;\n addBuf();\n state = IN_TAG_TYPE;\n } else {\n if (text.charAt(i) == '\\n') {\n filterLine(seenTag);\n } else {\n buf += text.charAt(i);\n }\n }\n } else if (state == IN_TAG_TYPE) {\n i += otag.length - 1;\n tag = Hogan.tags[text.charAt(i + 1)];\n tagType = tag ? text.charAt(i + 1) : '_v';\n if (tagType == '=') {\n i = changeDelimiters(text, i);\n state = IN_TEXT;\n } else {\n if (tag) {\n i++;\n }\n state = IN_TAG;\n }\n seenTag = i;\n } else {\n if (tagChange(ctag, text, i)) {\n tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,\n i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});\n buf = '';\n i += ctag.length - 1;\n state = IN_TEXT;\n if (tagType == '{') {\n if (ctag == '}}') {\n i++;\n } else {\n cleanTripleStache(tokens[tokens.length - 1]);\n }\n }\n } else {\n buf += text.charAt(i);\n }\n }\n }\n\n filterLine(seenTag, true);\n\n return tokens;\n }\n\n function cleanTripleStache(token) {\n if (token.n.substr(token.n.length - 1) === '}') {\n token.n = token.n.substring(0, token.n.length - 1);\n }\n }\n\n function trim(s) {\n if (s.trim) {\n return s.trim();\n }\n\n return s.replace(/^\\s*|\\s*$/g, '');\n }\n\n function tagChange(tag, text, index) {\n if (text.charAt(index) != tag.charAt(0)) {\n return false;\n }\n\n for (var i = 1, l = tag.length; i < l; i++) {\n if (text.charAt(index + i) != tag.charAt(i)) {\n return false;\n }\n }\n\n return true;\n }\n\n // the tags allowed inside super templates\n var allowedInSuper = {'_t': true, '\\n': true, '$': true, '/': true};\n\n function buildTree(tokens, kind, stack, customTags) {\n var instructions = [],\n opener = null,\n tail = null,\n token = null;\n\n tail = stack[stack.length - 1];\n\n while (tokens.length > 0) {\n token = tokens.shift();\n\n if (tail && tail.tag == '<' && !(token.tag in allowedInSuper)) {\n throw new Error('Illegal content in < super tag.');\n }\n\n if (Hogan.tags[token.tag] <= Hogan.tags['$'] || isOpener(token, customTags)) {\n stack.push(token);\n token.nodes = buildTree(tokens, token.tag, stack, customTags);\n } else if (token.tag == '/') {\n if (stack.length === 0) {\n throw new Error('Closing tag without opener: /' + token.n);\n }\n opener = stack.pop();\n if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {\n throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);\n }\n opener.end = token.i;\n return instructions;\n } else if (token.tag == '\\n') {\n token.last = (tokens.length == 0) || (tokens[0].tag == '\\n');\n }\n\n instructions.push(token);\n }\n\n if (stack.length > 0) {\n throw new Error('missing closing tag: ' + stack.pop().n);\n }\n\n return instructions;\n }\n\n function isOpener(token, tags) {\n for (var i = 0, l = tags.length; i < l; i++) {\n if (tags[i].o == token.n) {\n token.tag = '#';\n return true;\n }\n }\n }\n\n function isCloser(close, open, tags) {\n for (var i = 0, l = tags.length; i < l; i++) {\n if (tags[i].c == close && tags[i].o == open) {\n return true;\n }\n }\n }\n\n function stringifySubstitutions(obj) {\n var items = [];\n for (var key in obj) {\n items.push('\"' + esc(key) + '\": function(c,p,t,i) {' + obj[key] + '}');\n }\n return \"{ \" + items.join(\",\") + \" }\";\n }\n\n function stringifyPartials(codeObj) {\n var partials = [];\n for (var key in codeObj.partials) {\n partials.push('\"' + esc(key) + '\":{name:\"' + esc(codeObj.partials[key].name) + '\", ' + stringifyPartials(codeObj.partials[key]) + \"}\");\n }\n return \"partials: {\" + partials.join(\",\") + \"}, subs: \" + stringifySubstitutions(codeObj.subs);\n }\n\n Hogan.stringify = function(codeObj, text, options) {\n return \"{code: function (c,p,i) { \" + Hogan.wrapMain(codeObj.code) + \" },\" + stringifyPartials(codeObj) + \"}\";\n }\n\n var serialNo = 0;\n Hogan.generate = function(tree, text, options) {\n serialNo = 0;\n var context = { code: '', subs: {}, partials: {} };\n Hogan.walk(tree, context);\n\n if (options.asString) {\n return this.stringify(context, text, options);\n }\n\n return this.makeTemplate(context, text, options);\n }\n\n Hogan.wrapMain = function(code) {\n return 'var t=this;t.b(i=i||\"\");' + code + 'return t.fl();';\n }\n\n Hogan.template = Hogan.Template;\n\n Hogan.makeTemplate = function(codeObj, text, options) {\n var template = this.makePartials(codeObj);\n template.code = new Function('c', 'p', 'i', this.wrapMain(codeObj.code));\n return new this.template(template, text, this, options);\n }\n\n Hogan.makePartials = function(codeObj) {\n var key, template = {subs: {}, partials: codeObj.partials, name: codeObj.name};\n for (key in template.partials) {\n template.partials[key] = this.makePartials(template.partials[key]);\n }\n for (key in codeObj.subs) {\n template.subs[key] = new Function('c', 'p', 't', 'i', codeObj.subs[key]);\n }\n return template;\n }\n\n function esc(s) {\n return s.replace(rSlash, '\\\\\\\\')\n .replace(rQuot, '\\\\\\\"')\n .replace(rNewline, '\\\\n')\n .replace(rCr, '\\\\r')\n .replace(rLineSep, '\\\\u2028')\n .replace(rParagraphSep, '\\\\u2029');\n }\n\n function chooseMethod(s) {\n return (~s.indexOf('.')) ? 'd' : 'f';\n }\n\n function createPartial(node, context) {\n var prefix = \"<\" + (context.prefix || \"\");\n var sym = prefix + node.n + serialNo++;\n context.partials[sym] = {name: node.n, partials: {}};\n context.code += 't.b(t.rp(\"' + esc(sym) + '\",c,p,\"' + (node.indent || '') + '\"));';\n return sym;\n }\n\n Hogan.codegen = {\n '#': function(node, context) {\n context.code += 'if(t.s(t.' + chooseMethod(node.n) + '(\"' + esc(node.n) + '\",c,p,1),' +\n 'c,p,0,' + node.i + ',' + node.end + ',\"' + node.otag + \" \" + node.ctag + '\")){' +\n 't.rs(c,p,' + 'function(c,p,t){';\n Hogan.walk(node.nodes, context);\n context.code += '});c.pop();}';\n },\n\n '^': function(node, context) {\n context.code += 'if(!t.s(t.' + chooseMethod(node.n) + '(\"' + esc(node.n) + '\",c,p,1),c,p,1,0,0,\"\")){';\n Hogan.walk(node.nodes, context);\n context.code += '};';\n },\n\n '>': createPartial,\n '<': function(node, context) {\n var ctx = {partials: {}, code: '', subs: {}, inPartial: true};\n Hogan.walk(node.nodes, ctx);\n var template = context.partials[createPartial(node, context)];\n template.subs = ctx.subs;\n template.partials = ctx.partials;\n },\n\n '$': function(node, context) {\n var ctx = {subs: {}, code: '', partials: context.partials, prefix: node.n};\n Hogan.walk(node.nodes, ctx);\n context.subs[node.n] = ctx.code;\n if (!context.inPartial) {\n context.code += 't.sub(\"' + esc(node.n) + '\",c,p,i);';\n }\n },\n\n '\\n': function(node, context) {\n context.code += write('\"\\\\n\"' + (node.last ? '' : ' + i'));\n },\n\n '_v': function(node, context) {\n context.code += 't.b(t.v(t.' + chooseMethod(node.n) + '(\"' + esc(node.n) + '\",c,p,0)));';\n },\n\n '_t': function(node, context) {\n context.code += write('\"' + esc(node.text) + '\"');\n },\n\n '{': tripleStache,\n\n '&': tripleStache\n }\n\n function tripleStache(node, context) {\n context.code += 't.b(t.t(t.' + chooseMethod(node.n) + '(\"' + esc(node.n) + '\",c,p,0)));';\n }\n\n function write(s) {\n return 't.b(' + s + ');';\n }\n\n Hogan.walk = function(nodelist, context) {\n var func;\n for (var i = 0, l = nodelist.length; i < l; i++) {\n func = Hogan.codegen[nodelist[i].tag];\n func && func(nodelist[i], context);\n }\n return context;\n }\n\n Hogan.parse = function(tokens, text, options) {\n options = options || {};\n return buildTree(tokens, '', [], options.sectionTags || []);\n }\n\n Hogan.cache = {};\n\n Hogan.cacheKey = function(text, options) {\n return [text, !!options.asString, !!options.disableLambda, options.delimiters, !!options.modelGet].join('||');\n }\n\n Hogan.compile = function(text, options) {\n options = options || {};\n var key = Hogan.cacheKey(text, options);\n var template = this.cache[key];\n\n if (template) {\n var partials = template.partials;\n for (var name in partials) {\n delete partials[name].instance;\n }\n return template;\n }\n\n template = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);\n return this.cache[key] = template;\n }\n})(typeof exports !== 'undefined' ? exports : Hogan);\n","/*\n * Copyright 2011 Twitter, Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvar Hogan = {};\n\n(function (Hogan) {\n Hogan.Template = function (codeObj, text, compiler, options) {\n codeObj = codeObj || {};\n this.r = codeObj.code || this.r;\n this.c = compiler;\n this.options = options || {};\n this.text = text || '';\n this.partials = codeObj.partials || {};\n this.subs = codeObj.subs || {};\n this.buf = '';\n }\n\n Hogan.Template.prototype = {\n // render: replaced by generated code.\n r: function (context, partials, indent) { return ''; },\n\n // variable escaping\n v: hoganEscape,\n\n // triple stache\n t: coerceToString,\n\n render: function render(context, partials, indent) {\n return this.ri([context], partials || {}, indent);\n },\n\n // render internal -- a hook for overrides that catches partials too\n ri: function (context, partials, indent) {\n return this.r(context, partials, indent);\n },\n\n // ensurePartial\n ep: function(symbol, partials) {\n var partial = this.partials[symbol];\n\n // check to see that if we've instantiated this partial before\n var template = partials[partial.name];\n if (partial.instance && partial.base == template) {\n return partial.instance;\n }\n\n if (typeof template == 'string') {\n if (!this.c) {\n throw new Error(\"No compiler available.\");\n }\n template = this.c.compile(template, this.options);\n }\n\n if (!template) {\n return null;\n }\n\n // We use this to check whether the partials dictionary has changed\n this.partials[symbol].base = template;\n\n if (partial.subs) {\n // Make sure we consider parent template now\n if (!partials.stackText) partials.stackText = {};\n for (key in partial.subs) {\n if (!partials.stackText[key]) {\n partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text;\n }\n }\n template = createSpecializedPartial(template, partial.subs, partial.partials,\n this.stackSubs, this.stackPartials, partials.stackText);\n }\n this.partials[symbol].instance = template;\n\n return template;\n },\n\n // tries to find a partial in the current scope and render it\n rp: function(symbol, context, partials, indent) {\n var partial = this.ep(symbol, partials);\n if (!partial) {\n return '';\n }\n\n return partial.ri(context, partials, indent);\n },\n\n // render a section\n rs: function(context, partials, section) {\n var tail = context[context.length - 1];\n\n if (!isArray(tail)) {\n section(context, partials, this);\n return;\n }\n\n for (var i = 0; i < tail.length; i++) {\n context.push(tail[i]);\n section(context, partials, this);\n context.pop();\n }\n },\n\n // maybe start a section\n s: function(val, ctx, partials, inverted, start, end, tags) {\n var pass;\n\n if (isArray(val) && val.length === 0) {\n return false;\n }\n\n if (typeof val == 'function') {\n val = this.ms(val, ctx, partials, inverted, start, end, tags);\n }\n\n pass = !!val;\n\n if (!inverted && pass && ctx) {\n ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);\n }\n\n return pass;\n },\n\n // find values with dotted names\n d: function(key, ctx, partials, returnFound) {\n var found,\n names = key.split('.'),\n val = this.f(names[0], ctx, partials, returnFound),\n doModelGet = this.options.modelGet,\n cx = null;\n\n if (key === '.' && isArray(ctx[ctx.length - 2])) {\n val = ctx[ctx.length - 1];\n } else {\n for (var i = 1; i < names.length; i++) {\n found = findInScope(names[i], val, doModelGet);\n if (found !== undefined) {\n cx = val;\n val = found;\n } else {\n val = '';\n }\n }\n }\n\n if (returnFound && !val) {\n return false;\n }\n\n if (!returnFound && typeof val == 'function') {\n ctx.push(cx);\n val = this.mv(val, ctx, partials);\n ctx.pop();\n }\n\n return val;\n },\n\n // find values with normal names\n f: function(key, ctx, partials, returnFound) {\n var val = false,\n v = null,\n found = false,\n doModelGet = this.options.modelGet;\n\n for (var i = ctx.length - 1; i >= 0; i--) {\n v = ctx[i];\n val = findInScope(key, v, doModelGet);\n if (val !== undefined) {\n found = true;\n break;\n }\n }\n\n if (!found) {\n return (returnFound) ? false : \"\";\n }\n\n if (!returnFound && typeof val == 'function') {\n val = this.mv(val, ctx, partials);\n }\n\n return val;\n },\n\n // higher order templates\n ls: function(func, cx, partials, text, tags) {\n var oldTags = this.options.delimiters;\n\n this.options.delimiters = tags;\n this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials));\n this.options.delimiters = oldTags;\n\n return false;\n },\n\n // compile text\n ct: function(text, cx, partials) {\n if (this.options.disableLambda) {\n throw new Error('Lambda features disabled.');\n }\n return this.c.compile(text, this.options).render(cx, partials);\n },\n\n // template result buffering\n b: function(s) { this.buf += s; },\n\n fl: function() { var r = this.buf; this.buf = ''; return r; },\n\n // method replace section\n ms: function(func, ctx, partials, inverted, start, end, tags) {\n var textSource,\n cx = ctx[ctx.length - 1],\n result = func.call(cx);\n\n if (typeof result == 'function') {\n if (inverted) {\n return true;\n } else {\n textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text;\n return this.ls(result, cx, partials, textSource.substring(start, end), tags);\n }\n }\n\n return result;\n },\n\n // method replace variable\n mv: function(func, ctx, partials) {\n var cx = ctx[ctx.length - 1];\n var result = func.call(cx);\n\n if (typeof result == 'function') {\n return this.ct(coerceToString(result.call(cx)), cx, partials);\n }\n\n return result;\n },\n\n sub: function(name, context, partials, indent) {\n var f = this.subs[name];\n if (f) {\n this.activeSub = name;\n f(context, partials, this, indent);\n this.activeSub = false;\n }\n }\n\n };\n\n //Find a key in an object\n function findInScope(key, scope, doModelGet) {\n var val;\n\n if (scope && typeof scope == 'object') {\n\n if (scope[key] !== undefined) {\n val = scope[key];\n\n // try lookup with get for backbone or similar model data\n } else if (doModelGet && scope.get && typeof scope.get == 'function') {\n val = scope.get(key);\n }\n }\n\n return val;\n }\n\n function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) {\n function PartialTemplate() {};\n PartialTemplate.prototype = instance;\n function Substitutions() {};\n Substitutions.prototype = instance.subs;\n var key;\n var partial = new PartialTemplate();\n partial.subs = new Substitutions();\n partial.subsText = {}; //hehe. substext.\n partial.buf = '';\n\n stackSubs = stackSubs || {};\n partial.stackSubs = stackSubs;\n partial.subsText = stackText;\n for (key in subs) {\n if (!stackSubs[key]) stackSubs[key] = subs[key];\n }\n for (key in stackSubs) {\n partial.subs[key] = stackSubs[key];\n }\n\n stackPartials = stackPartials || {};\n partial.stackPartials = stackPartials;\n for (key in partials) {\n if (!stackPartials[key]) stackPartials[key] = partials[key];\n }\n for (key in stackPartials) {\n partial.partials[key] = stackPartials[key];\n }\n\n return partial;\n }\n\n var rAmp = /&/g,\n rLt = //g,\n rApos = /\\'/g,\n rQuot = /\\\"/g,\n hChars = /[&<>\\\"\\']/;\n\n function coerceToString(val) {\n return String((val === null || val === undefined) ? '' : val);\n }\n\n function hoganEscape(str) {\n str = coerceToString(str);\n return hChars.test(str) ?\n str\n .replace(rAmp, '&')\n .replace(rLt, '<')\n .replace(rGt, '>')\n .replace(rApos, ''')\n .replace(rQuot, '"') :\n str;\n }\n\n var isArray = Array.isArray || function(a) {\n return Object.prototype.toString.call(a) === '[object Array]';\n };\n\n})(typeof exports !== 'undefined' ? exports : Hogan);\n","/*\n * Copyright 2011 Twitter, Inc.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is for use with Node.js. See dist/ for browser files.\n\nvar Hogan = require('./compiler');\nHogan.Template = require('./template').Template;\nHogan.template = Hogan.Template;\nmodule.exports = Hogan;\n","import hogan from 'hogan.js';\n\n// We add all our template helper methods to the template as lambdas. Note\n// that lambdas in Mustache are supposed to accept a second argument of\n// `render` to get the rendered value, not the literal `{{value}}`. But\n// this is currently broken (see https://github.com/twitter/hogan.js/issues/222).\nfunction transformHelpersToHogan(helpers = {}, compileOptions, data) {\n return Object.keys(helpers).reduce(\n (acc, helperKey) => ({\n ...acc,\n [helperKey]() {\n return text => {\n const render = value =>\n hogan.compile(value, compileOptions).render(this);\n\n return helpers[helperKey].call(data, text, render);\n };\n },\n }),\n {}\n );\n}\n\nfunction renderTemplate({\n templates,\n templateKey,\n compileOptions,\n helpers,\n data,\n}) {\n const template = templates[templateKey];\n const templateType = typeof template;\n const isTemplateString = templateType === 'string';\n const isTemplateFunction = templateType === 'function';\n\n if (!isTemplateString && !isTemplateFunction) {\n throw new Error(\n `Template must be 'string' or 'function', was '${templateType}' (key: ${templateKey})`\n );\n }\n\n if (isTemplateFunction) {\n return template(data);\n }\n\n const transformedHelpers = transformHelpersToHogan(\n helpers,\n compileOptions,\n data\n );\n\n return hogan\n .compile(template, compileOptions)\n .render({\n ...data,\n helpers: transformedHelpers,\n })\n .replace(/[ \\n\\r\\t\\f\\xA0]+/g, spaces =>\n spaces.replace(/(^|\\xA0+)[^\\xA0]+/g, '$1 ')\n )\n .trim();\n}\n\nexport default renderTemplate;\n","// We aren't using the native `Array.prototype.find` because the refactor away from Lodash is not\n// published as a major version.\n// Relying on the `find` polyfill on user-land, which before was only required for niche use-cases,\n// was decided as too risky.\n// @MAJOR Replace with the native `Array.prototype.find` method\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\nfunction find(\n items: TItem[],\n predicate: (value: TItem, index: number, obj: TItem[]) => boolean,\n thisArg?: any\n): TItem | undefined {\n if (!Array.prototype.find) {\n return items.filter(predicate, thisArg)[0];\n }\n\n return items.find(predicate, thisArg);\n}\n\nexport default find;\n","function unescapeRefinement(value: string | number): string {\n return String(value).replace(/^\\\\-/, '-');\n}\n\nexport default unescapeRefinement;\n","import { SearchParameters, SearchResults } from '../../types';\nimport find from './find';\nimport unescapeRefinement from './unescapeRefinement';\n\nexport interface FacetRefinement {\n type:\n | 'facet'\n | 'exclude'\n | 'disjunctive'\n | 'hierarchical'\n | 'numeric'\n | 'tag'\n | 'query';\n attributeName: string;\n name: string;\n count?: number;\n exhaustive?: boolean;\n}\n\nexport interface QueryRefinement\n extends Pick {\n type: 'query';\n query: string;\n}\n\nexport interface NumericRefinement extends FacetRefinement {\n type: 'numeric';\n numericValue: number;\n operator: '<' | '<=' | '=' | '!=' | '>=' | '>';\n}\n\nexport interface FacetExcludeRefinement extends FacetRefinement {\n type: 'exclude';\n exclude: boolean;\n}\n\nexport type Refinement =\n | FacetRefinement\n | QueryRefinement\n | NumericRefinement\n | FacetExcludeRefinement;\n\nfunction getRefinement(\n state: SearchParameters,\n type: Refinement['type'],\n attributeName: Refinement['attributeName'],\n name: Refinement['name'],\n resultsFacets: SearchResults['facets' | 'hierarchicalFacets'] = []\n): Refinement {\n const res: Refinement = { type, attributeName, name };\n let facet: any = find(\n resultsFacets as Array<{ name: string }>,\n resultsFacet => resultsFacet.name === attributeName\n );\n let count: number;\n\n if (type === 'hierarchical') {\n const facetDeclaration = state.getHierarchicalFacetByName(attributeName);\n const nameParts = name.split(facetDeclaration.separator);\n\n const getFacetRefinement = (\n facetData: any\n ): ((refinementKey: string) => any) => (refinementKey: string): any =>\n facetData[refinementKey];\n\n for (let i = 0; facet !== undefined && i < nameParts.length; ++i) {\n facet =\n facet &&\n facet.data &&\n find(\n Object.keys(facet.data).map(getFacetRefinement(facet.data)),\n refinement => refinement.name === nameParts[i]\n );\n }\n\n count = facet && facet.count;\n } else {\n count = facet && facet.data && facet.data[res.name];\n }\n\n const exhaustive = facet && facet.exhaustive;\n\n if (count !== undefined) {\n res.count = count;\n }\n\n if (exhaustive !== undefined) {\n res.exhaustive = exhaustive;\n }\n\n return res;\n}\n\nfunction getRefinements(\n results: SearchResults,\n state: SearchParameters,\n clearsQuery: boolean = false\n): Refinement[] {\n const res: Refinement[] = [];\n const {\n facetsRefinements = {},\n facetsExcludes = {},\n disjunctiveFacetsRefinements = {},\n hierarchicalFacetsRefinements = {},\n numericRefinements = {},\n tagRefinements = [],\n } = state;\n\n Object.keys(facetsRefinements).forEach(attributeName => {\n const refinements = facetsRefinements[attributeName];\n\n refinements.forEach(refinement => {\n res.push(\n getRefinement(state, 'facet', attributeName, refinement, results.facets)\n );\n });\n });\n\n Object.keys(facetsExcludes).forEach(attributeName => {\n const refinements = facetsExcludes[attributeName];\n\n refinements.forEach(refinement => {\n res.push({\n type: 'exclude',\n attributeName,\n name: refinement,\n exclude: true,\n });\n });\n });\n\n Object.keys(disjunctiveFacetsRefinements).forEach(attributeName => {\n const refinements = disjunctiveFacetsRefinements[attributeName];\n\n refinements.forEach(refinement => {\n res.push(\n getRefinement(\n state,\n 'disjunctive',\n attributeName,\n // We unescape any disjunctive refined values with `unescapeRefinement` because\n // they can be escaped on negative numeric values with `escapeRefinement`.\n unescapeRefinement(refinement),\n results.disjunctiveFacets\n )\n );\n });\n });\n\n Object.keys(hierarchicalFacetsRefinements).forEach(attributeName => {\n const refinements = hierarchicalFacetsRefinements[attributeName];\n\n refinements.forEach(refinement => {\n res.push(\n getRefinement(\n state,\n 'hierarchical',\n attributeName,\n refinement,\n results.hierarchicalFacets\n )\n );\n });\n });\n\n Object.keys(numericRefinements).forEach(attributeName => {\n const operators = numericRefinements[attributeName];\n\n Object.keys(operators).forEach(operator => {\n const valueOrValues = operators[operator];\n const refinements = Array.isArray(valueOrValues)\n ? valueOrValues\n : [valueOrValues];\n\n refinements.forEach(refinement => {\n res.push({\n type: 'numeric',\n attributeName,\n name: `${refinement}`,\n numericValue: refinement,\n operator: operator as NumericRefinement['operator'],\n });\n });\n });\n });\n\n tagRefinements.forEach(refinement => {\n res.push({ type: 'tag', attributeName: '_tags', name: refinement });\n });\n\n if (clearsQuery && state.query && state.query.trim()) {\n res.push({\n attributeName: 'query',\n type: 'query',\n name: state.query,\n query: state.query,\n });\n }\n\n return res;\n}\n\nexport default getRefinements;\n","/**\n * Clears the refinements of a SearchParameters object based on rules provided.\n * The included attributes list is applied before the excluded attributes list. If the list\n * is not provided, this list of all the currently refined attributes is used as included attributes.\n * @param {object} $0 parameters\n * @param {Helper} $0.helper instance of the Helper\n * @param {string[]} [$0.attributesToClear = []] list of parameters to clear\n * @returns {SearchParameters} search parameters with refinements cleared\n */\nfunction clearRefinements({ helper, attributesToClear = [] }) {\n let finalState = helper.state;\n\n attributesToClear.forEach(attribute => {\n if (attribute === '_tags') {\n finalState = finalState.clearTags();\n } else {\n finalState = finalState.clearRefinements(attribute);\n }\n });\n\n if (attributesToClear.indexOf('query') !== -1) {\n finalState = finalState.setQuery('');\n }\n\n return finalState;\n}\n\nexport default clearRefinements;\n","function escapeRefinement(value: string | number): string | number {\n if (typeof value === 'number' && value < 0) {\n value = String(value).replace(/^-/, '\\\\-');\n }\n\n return value;\n}\n\nexport default escapeRefinement;\n","import { Renderer } from '../../types/connector';\n\nfunction checkRendering(rendering: Renderer, usage: string): void {\n if (rendering === undefined || typeof rendering !== 'function') {\n throw new Error(`The render function is not valid (got type \"${typeof rendering}\").\n\n${usage}`);\n }\n}\n\nexport default checkRendering;\n","function getPropertyByPath(object: object, path: string): any {\n const parts = path.split('.');\n\n return parts.reduce((current, key) => current && current[key], object);\n}\n\nexport default getPropertyByPath;\n","function noop(..._args: any[]): void {}\n\nexport default noop;\n","// This is the `Number.isFinite()` polyfill recommended by MDN.\n// We do not provide any tests for this function.\n// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#Polyfill\nfunction isFiniteNumber(value: any): value is number {\n return typeof value === 'number' && isFinite(value);\n}\n\nexport default isFiniteNumber;\n","/**\n * This implementation is taken from Lodash implementation.\n * See: https://github.com/lodash/lodash/blob/master/isPlainObject.js\n */\n\nfunction getTag(value: any): string {\n if (value === null) {\n return value === undefined ? '[object Undefined]' : '[object Null]';\n }\n\n return Object.prototype.toString.call(value);\n}\n\nfunction isObjectLike(value: any): boolean {\n return typeof value === 'object' && value !== null;\n}\n\n/**\n * Checks if `value` is a plain object.\n *\n * A plain object is an object created by the `Object`\n * constructor or with a `[[Prototype]]` of `null`.\n */\nfunction isPlainObject(value: any): boolean {\n if (!isObjectLike(value) || getTag(value) !== '[object Object]') {\n return false;\n }\n\n if (Object.getPrototypeOf(value) === null) {\n return true;\n }\n\n let proto = value;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(value) === proto;\n}\n\nexport default isPlainObject;\n","type RangeOptions = {\n start?: number;\n end: number;\n step?: number;\n};\n\nfunction range({ start = 0, end, step = 1 }: RangeOptions): number[] {\n // We can't divide by 0 so we re-assign the step to 1 if it happens.\n const limitStep = step === 0 ? 1 : step;\n\n // In some cases the array to create has a decimal length.\n // We therefore need to round the value.\n // Example:\n // { start: 1, end: 5000, step: 500 }\n // => Array length = (5000 - 1) / 500 = 9.998\n const arrayLength = Math.round((end - start) / limitStep);\n\n return [...Array(arrayLength)].map(\n (_, current) => (start + current) * limitStep\n );\n}\n\nexport default range;\n","function isPrimitive(obj: any): boolean {\n return obj !== Object(obj);\n}\n\nfunction isEqual(first: any, second: any): boolean {\n if (first === second) {\n return true;\n }\n\n if (\n isPrimitive(first) ||\n isPrimitive(second) ||\n typeof first === 'function' ||\n typeof second === 'function'\n ) {\n return first === second;\n }\n\n if (Object.keys(first).length !== Object.keys(second).length) {\n return false;\n }\n\n for (const key of Object.keys(first)) {\n if (!(key in second)) {\n return false;\n }\n\n if (!isEqual(first[key], second[key])) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default isEqual;\n","/**\n * This implementation is taken from Lodash implementation.\n * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js\n */\n\n// Used to map characters to HTML entities.\nconst htmlEscapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n// Used to match HTML entities and HTML characters.\nconst regexUnescapedHtml = /[&<>\"']/g;\nconst regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);\n\n/**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `string` to their\n * corresponding HTML entities.\n */\nfunction escape(value: string): string {\n return value && regexHasUnescapedHtml.test(value)\n ? value.replace(regexUnescapedHtml, character => htmlEscapes[character])\n : value;\n}\n\nexport default escape;\n","type WidgetParam = {\n name: string;\n connector?: boolean;\n};\n\nexport const createDocumentationLink = ({\n name,\n connector = false,\n}: WidgetParam): string => {\n return [\n 'https://www.algolia.com/doc/api-reference/widgets/',\n name,\n '/js/',\n connector ? '#connector' : '',\n ].join('');\n};\n\ntype DocumentationMessageGenerator = (message?: string) => string;\n\nexport const createDocumentationMessageGenerator = (\n ...widgets: WidgetParam[]\n): DocumentationMessageGenerator => {\n const links = widgets\n .map(widget => createDocumentationLink(widget))\n .join(', ');\n\n return (message?: string) =>\n [message, `See documentation: ${links}`].filter(Boolean).join('\\n\\n');\n};\n","import noop from './noop';\n\nlet deprecate = noop;\nlet warn = noop;\n\n/**\n * Logs a warning if the condition is not met.\n * This is used to log issues in development environment only.\n *\n * @returns {undefined}\n */\nlet warning = noop;\n\nif (__DEV__) {\n warn = message => {\n // eslint-disable-next-line no-console\n console.warn(`[InstantSearch.js]: ${message.trim()}`);\n };\n\n deprecate = (fn, message) => {\n let hasAlreadyPrinted = false;\n\n return function(...args) {\n if (!hasAlreadyPrinted) {\n hasAlreadyPrinted = true;\n\n warn(message);\n }\n\n return fn(...args);\n };\n };\n\n warning = (condition, message) => {\n if (condition) {\n return;\n }\n\n const hasAlreadyPrinted = warning.cache[message];\n\n if (!hasAlreadyPrinted) {\n warning.cache[message] = true;\n\n warn(message);\n }\n };\n\n warning.cache = {};\n}\n\nexport { warn, deprecate, warning };\n","const latLngRegExp = /^(-?\\d+(?:\\.\\d+)?),\\s*(-?\\d+(?:\\.\\d+)?)$/;\n\nexport function aroundLatLngToPosition(value) {\n const pattern = value.match(latLngRegExp);\n\n // Since the value provided is the one send with the request, the API should\n // throw an error due to the wrong format. So throw an error should be safe.\n if (!pattern) {\n throw new Error(`Invalid value for \"aroundLatLng\" parameter: \"${value}\"`);\n }\n\n return {\n lat: parseFloat(pattern[1]),\n lng: parseFloat(pattern[2]),\n };\n}\n\nexport function insideBoundingBoxArrayToBoundingBox(value) {\n const [[neLat, neLng, swLat, swLng] = []] = value;\n\n // Since the value provided is the one send with the request, the API should\n // throw an error due to the wrong format. So throw an error should be safe.\n if (!neLat || !neLng || !swLat || !swLng) {\n throw new Error(\n `Invalid value for \"insideBoundingBox\" parameter: [${value}]`\n );\n }\n\n return {\n northEast: {\n lat: neLat,\n lng: neLng,\n },\n southWest: {\n lat: swLat,\n lng: swLng,\n },\n };\n}\n\nexport function insideBoundingBoxStringToBoundingBox(value) {\n const [neLat, neLng, swLat, swLng] = value.split(',').map(parseFloat);\n\n // Since the value provided is the one send with the request, the API should\n // throw an error due to the wrong format. So throw an error should be safe.\n if (!neLat || !neLng || !swLat || !swLng) {\n throw new Error(\n `Invalid value for \"insideBoundingBox\" parameter: \"${value}\"`\n );\n }\n\n return {\n northEast: {\n lat: neLat,\n lng: neLng,\n },\n southWest: {\n lat: swLat,\n lng: swLng,\n },\n };\n}\n\nexport function insideBoundingBoxToBoundingBox(value) {\n if (Array.isArray(value)) {\n return insideBoundingBoxArrayToBoundingBox(value);\n }\n\n return insideBoundingBoxStringToBoundingBox(value);\n}\n","import { Hits } from '../../types';\n\nexport const addAbsolutePosition = (\n hits: Hits,\n page: number,\n hitsPerPage: number\n): Hits => {\n return hits.map((hit, idx) => ({\n ...hit,\n __position: hitsPerPage * page + idx + 1,\n }));\n};\n","import { Hits } from '../../types';\n\nexport const addQueryID = (hits: Hits, queryID: string): Hits => {\n if (!queryID) {\n return hits;\n }\n return hits.map(hit => ({\n ...hit,\n __queryID: queryID,\n }));\n};\n","import algoliasearchHelper from 'algoliasearch-helper';\nimport { isEqual } from './utils';\nimport {\n InstantSearch,\n UiState,\n SearchParameters,\n Router,\n StateMapping,\n Widget,\n} from '../types';\n\ntype RoutingManagerProps = {\n instantSearchInstance: InstantSearch;\n router: Router;\n stateMapping: StateMapping;\n};\n\nclass RoutingManager implements Widget {\n private readonly instantSearchInstance: InstantSearch;\n private readonly router: Router;\n private readonly stateMapping: StateMapping;\n\n private isFirstRender: boolean = true;\n private currentUiState: UiState;\n private initState?: UiState;\n private renderURLFromState?: (searchParameters: SearchParameters) => void;\n\n public constructor({\n router,\n stateMapping,\n instantSearchInstance,\n }: RoutingManagerProps) {\n this.router = router;\n this.stateMapping = stateMapping;\n this.instantSearchInstance = instantSearchInstance;\n this.currentUiState = this.stateMapping.routeToState(this.router.read());\n }\n\n private getAllSearchParameters({\n currentSearchParameters,\n uiState,\n }): Partial {\n const widgets = this.instantSearchInstance.widgets;\n\n return widgets.reduce((parameters, widget) => {\n if (!widget.getWidgetSearchParameters) {\n return parameters;\n }\n\n return widget.getWidgetSearchParameters(parameters, {\n uiState,\n });\n }, currentSearchParameters);\n }\n\n private getAllUiStates({\n searchParameters,\n }: {\n searchParameters: SearchParameters;\n }): UiState {\n const widgets = this.instantSearchInstance.widgets;\n const helper = this.instantSearchInstance.helper!;\n\n return widgets.reduce((state, widget) => {\n if (!widget.getWidgetState) {\n return state;\n }\n\n return widget.getWidgetState(state, {\n helper,\n searchParameters,\n });\n }, {});\n }\n\n private setupRouting(state: SearchParameters): void {\n const helper = this.instantSearchInstance.helper!;\n\n this.router.onUpdate(route => {\n const nextUiState = this.stateMapping.routeToState(route);\n const widgetsUiState = this.getAllUiStates({\n searchParameters: helper.state,\n });\n\n if (isEqual(nextUiState, widgetsUiState)) {\n return;\n }\n\n this.currentUiState = nextUiState;\n\n const searchParameters = this.getAllSearchParameters({\n currentSearchParameters: state,\n uiState: this.currentUiState,\n });\n\n helper\n .overrideStateWithoutTriggeringChangeEvent(searchParameters)\n .search();\n });\n\n this.renderURLFromState = searchParameters => {\n this.currentUiState = this.getAllUiStates({\n searchParameters,\n });\n\n const route = this.stateMapping.stateToRoute(this.currentUiState);\n\n this.router.write(route);\n };\n\n helper.on('change', this.renderURLFromState);\n\n // Compare initial state and first render state to see if the query has been\n // changed by the `searchFunction`. It's required because the helper of the\n // `searchFunction` does not trigger change event (not the same instance).\n const firstRenderState = this.getAllUiStates({\n searchParameters: state,\n });\n\n if (!isEqual(this.initState, firstRenderState)) {\n // Force update the URL, if the state has changed since the initial read.\n // We do this in order to make the URL update when there is `searchFunction`\n // that prevents the search of the initial rendering.\n // See: https://github.com/algolia/instantsearch.js/issues/2523#issuecomment-339356157\n this.currentUiState = firstRenderState;\n\n const route = this.stateMapping.stateToRoute(this.currentUiState);\n\n this.router.write(route);\n }\n }\n\n public getConfiguration(\n currentConfiguration: Partial\n ): Partial {\n // We have to create a `SearchParameters` because `getAllSearchParameters`\n // expects an instance of `SearchParameters` and not a plain object.\n const currentSearchParameters = algoliasearchHelper.SearchParameters.make(\n currentConfiguration\n );\n\n return {\n ...this.getAllSearchParameters({\n uiState: this.currentUiState,\n currentSearchParameters,\n }),\n };\n }\n\n public init({ state }: { state: SearchParameters }): void {\n // Store the initial state from the storage to compare it with the state on next renders\n // in case the `searchFunction` has modified it.\n this.initState = this.getAllUiStates({\n searchParameters: state,\n });\n }\n\n public render({ state }: { state: SearchParameters }): void {\n if (this.isFirstRender) {\n this.isFirstRender = false;\n this.setupRouting(state);\n }\n }\n\n public dispose({ helper, state }): void {\n if (this.renderURLFromState) {\n this.instantSearchInstance.helper!.removeListener(\n 'change',\n this.renderURLFromState\n );\n }\n\n if (this.router.dispose) {\n this.router.dispose({ helper, state });\n }\n }\n\n public createURL(state: SearchParameters): string {\n const uiState = this.getAllUiStates({\n searchParameters: state,\n });\n const route = this.stateMapping.stateToRoute(uiState);\n\n return this.router.createURL(route);\n }\n\n public onHistoryChange(\n callback: (state: Partial) => void\n ): void {\n const helper = this.instantSearchInstance.helper!;\n\n this.router.onUpdate(route => {\n const nextUiState = this.stateMapping.routeToState(route);\n\n const widgetsUiState = this.getAllUiStates({\n searchParameters: helper.state,\n });\n\n if (isEqual(nextUiState, widgetsUiState)) {\n return;\n }\n\n this.currentUiState = nextUiState;\n\n const searchParameters = this.getAllSearchParameters({\n currentSearchParameters: helper.state,\n uiState: this.currentUiState,\n });\n\n callback({ ...searchParameters });\n });\n }\n}\n\nexport default RoutingManager;\n","import { UiState, RouteState, StateMapping } from '../../types';\n\nclass SimpleUIStateMapping implements StateMapping {\n public stateToRoute(uiState: UiState): RouteState {\n return uiState;\n }\n\n public routeToState(routeState: RouteState): UiState {\n return routeState;\n }\n}\n\nexport default function(): SimpleUIStateMapping {\n return new SimpleUIStateMapping();\n}\n","import qs from 'qs';\nimport { Router, RouteState } from '../../types';\n\ntype CreateURL = ({\n qsModule,\n routeState,\n location,\n}: {\n qsModule: typeof qs;\n routeState: RouteState;\n location: Location;\n}) => string;\n\ntype ParseURL = ({\n qsModule,\n location,\n}: {\n qsModule: typeof qs;\n location: Location;\n}) => RouteState;\n\ntype BrowserHistoryProps = {\n windowTitle?: (routeState: RouteState) => string;\n writeDelay: number;\n createURL: CreateURL;\n parseURL: ParseURL;\n};\n\nconst defaultCreateURL: CreateURL = ({ qsModule, routeState, location }) => {\n const { protocol, hostname, port = '', pathname, hash } = location;\n const queryString = qsModule.stringify(routeState);\n const portWithPrefix = port === '' ? '' : `:${port}`;\n\n // IE <= 11 has no proper `location.origin` so we cannot rely on it.\n if (!routeState || Object.keys(routeState).length === 0) {\n return `${protocol}//${hostname}${portWithPrefix}${pathname}${hash}`;\n }\n\n return `${protocol}//${hostname}${portWithPrefix}${pathname}?${queryString}${hash}`;\n};\n\nconst defaultParseURL: ParseURL = ({ qsModule, location }) => {\n // `qs` by default converts arrays with more than 20 items to an object.\n // We want to avoid this because the data structure manipulated can therefore vary.\n // Setting the limit to `100` seems a good number because the engine's default is 100\n // (it can go up to 1000 but it is very unlikely to select more than 100 items in the UI).\n //\n // Using an `arrayLimit` of `n` allows `n + 1` items.\n //\n // See:\n // - https://github.com/ljharb/qs#parsing-arrays\n // - https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/\n return qsModule.parse(location.search.slice(1), { arrayLimit: 99 });\n};\n\nconst setWindowTitle = (title?: string): void => {\n if (title) {\n window.document.title = title;\n }\n};\n\nclass BrowserHistory implements Router {\n /**\n * Transforms a UI state into a title for the page.\n */\n private readonly windowTitle?: BrowserHistoryProps['windowTitle'];\n /**\n * Time in milliseconds before performing a write in the history.\n * It prevents from adding too many entries in the history and\n * makes the back button more usable.\n *\n * @default 400\n */\n private readonly writeDelay: BrowserHistoryProps['writeDelay'];\n /**\n * Creates a full URL based on the route state.\n * The storage adaptor maps all syncable keys to the query string of the URL.\n */\n private readonly _createURL: BrowserHistoryProps['createURL'];\n /**\n * Parses the URL into a route state.\n * It should be symetrical to `createURL`.\n */\n private readonly parseURL: BrowserHistoryProps['parseURL'];\n\n private writeTimer?: number;\n private _onPopState?(event: PopStateEvent): void;\n\n /**\n * Initializes a new storage provider that syncs the search state to the URL\n * using web APIs (`window.location.pushState` and `onpopstate` event).\n */\n public constructor(\n {\n windowTitle,\n writeDelay = 400,\n createURL = defaultCreateURL,\n parseURL = defaultParseURL,\n }: BrowserHistoryProps = {} as BrowserHistoryProps\n ) {\n this.windowTitle = windowTitle;\n this.writeTimer = undefined;\n this.writeDelay = writeDelay;\n this._createURL = createURL;\n this.parseURL = parseURL;\n\n const title = this.windowTitle && this.windowTitle(this.read());\n\n setWindowTitle(title);\n }\n\n /**\n * Reads the URL and returns a syncable UI search state.\n */\n public read(): RouteState {\n return this.parseURL({ qsModule: qs, location: window.location });\n }\n\n /**\n * Pushes a search state into the URL.\n */\n public write(routeState: RouteState): void {\n const url = this.createURL(routeState);\n const title = this.windowTitle && this.windowTitle(routeState);\n\n if (this.writeTimer) {\n window.clearTimeout(this.writeTimer);\n }\n\n this.writeTimer = window.setTimeout(() => {\n setWindowTitle(title);\n\n window.history.pushState(routeState, title || '', url);\n this.writeTimer = undefined;\n }, this.writeDelay);\n }\n\n /**\n * Sets a callback on the `onpopstate` event of the history API of the current page.\n * It enables the URL sync to keep track of the changes.\n */\n public onUpdate(callback: (routeState: RouteState) => void): void {\n this._onPopState = event => {\n if (this.writeTimer) {\n window.clearTimeout(this.writeTimer);\n this.writeTimer = undefined;\n }\n\n const routeState = event.state;\n\n // At initial load, the state is read from the URL without update.\n // Therefore the state object is not available.\n // In this case, we fallback and read the URL.\n if (!routeState) {\n callback(this.read());\n } else {\n callback(routeState);\n }\n };\n\n window.addEventListener('popstate', this._onPopState);\n }\n\n /**\n * Creates a complete URL from a given syncable UI state.\n *\n * It always generates the full URL, not a relative one.\n * This allows to handle cases like using a .\n * See: https://github.com/algolia/instantsearch.js/issues/790\n */\n public createURL(routeState: RouteState): string {\n return this._createURL({\n qsModule: qs,\n routeState,\n location: window.location,\n });\n }\n\n /**\n * Removes the event listener and cleans up the URL.\n */\n public dispose(): void {\n if (this._onPopState) {\n window.removeEventListener('popstate', this._onPopState);\n }\n\n if (this.writeTimer) {\n window.clearTimeout(this.writeTimer);\n }\n\n this.write({});\n }\n}\n\nexport default function(...args: BrowserHistoryProps[]): BrowserHistory {\n return new BrowserHistory(...args);\n}\n","import { Hit, FacetHit } from '../types';\nimport { isPlainObject, escape } from '../lib/utils';\n\nexport const TAG_PLACEHOLDER = {\n highlightPreTag: '__ais-highlight__',\n highlightPostTag: '__/ais-highlight__',\n};\n\nexport const TAG_REPLACEMENT = {\n highlightPreTag: '',\n highlightPostTag: '',\n};\n\nfunction replaceTagsAndEscape(value: string): string {\n return escape(value)\n .replace(\n new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'),\n TAG_REPLACEMENT.highlightPreTag\n )\n .replace(\n new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'),\n TAG_REPLACEMENT.highlightPostTag\n );\n}\n\nfunction recursiveEscape(input: any): any {\n if (isPlainObject(input) && typeof input.value !== 'string') {\n return Object.keys(input).reduce(\n (acc, key) => ({\n ...acc,\n [key]: recursiveEscape(input[key]),\n }),\n {}\n );\n }\n\n if (Array.isArray(input)) {\n return input.map(recursiveEscape);\n }\n\n return {\n ...input,\n value: replaceTagsAndEscape(input.value),\n };\n}\n\nexport default function escapeHits(hits: Hit[]): Hit[] {\n if ((hits as any).__escaped === undefined) {\n hits = hits.map(hit => {\n if (hit._highlightResult) {\n hit._highlightResult = recursiveEscape(hit._highlightResult);\n }\n\n if (hit._snippetResult) {\n hit._snippetResult = recursiveEscape(hit._snippetResult);\n }\n\n return hit;\n });\n\n (hits as any).__escaped = true;\n }\n\n return hits;\n}\n\nexport function escapeFacets(facetHits: FacetHit[]): FacetHit[] {\n return facetHits.map(h => ({\n ...h,\n highlighted: replaceTagsAndEscape(h.highlighted),\n }));\n}\n","const NAMESPACE = 'ais';\n\ninterface SuitOptions {\n descendantName?: string;\n modifierName?: string;\n}\n\ntype SuitSelector = (names?: SuitOptions) => string;\n\nexport const component = (componentName: string): SuitSelector => ({\n descendantName,\n modifierName,\n}: SuitOptions = {}) => {\n const descendent = descendantName ? `-${descendantName}` : '';\n const modifier = modifierName ? `--${modifierName}` : '';\n\n return `${NAMESPACE}-${componentName}${descendent}${modifier}`;\n};\n","import { Hit } from '../types';\nimport { getPropertyByPath } from '../lib/utils';\nimport { TAG_REPLACEMENT } from '../lib/escape-highlight';\nimport { component } from '../lib/suit';\n\nexport type HighlightOptions = {\n attribute: string;\n highlightedTagName?: string;\n hit: Partial;\n};\n\nconst suit = component('Highlight');\n\nexport default function highlight({\n attribute,\n highlightedTagName = 'mark',\n hit,\n}: HighlightOptions): string {\n const attributeValue =\n (getPropertyByPath(hit, `_highlightResult.${attribute}.value`) as string) ||\n '';\n\n const className = suit({\n descendantName: 'highlighted',\n });\n\n return attributeValue\n .replace(\n new RegExp(TAG_REPLACEMENT.highlightPreTag, 'g'),\n `<${highlightedTagName} class=\"${className}\">`\n )\n .replace(\n new RegExp(TAG_REPLACEMENT.highlightPostTag, 'g'),\n ``\n );\n}\n","import { Hit } from '../types';\nimport { getPropertyByPath } from '../lib/utils';\nimport { TAG_REPLACEMENT } from '../lib/escape-highlight';\nimport { component } from '../lib/suit';\n\nexport type SnippetOptions = {\n attribute: string;\n highlightedTagName?: string;\n hit: Partial;\n};\n\nconst suit = component('Snippet');\n\nexport default function snippet({\n attribute,\n highlightedTagName = 'mark',\n hit,\n}: SnippetOptions): string {\n const attributeValue =\n (getPropertyByPath(hit, `_snippetResult.${attribute}.value`) as string) ||\n '';\n\n const className = suit({\n descendantName: 'highlighted',\n });\n\n return attributeValue\n .replace(\n new RegExp(TAG_REPLACEMENT.highlightPreTag, 'g'),\n `<${highlightedTagName} class=\"${className}\">`\n )\n .replace(\n new RegExp(TAG_REPLACEMENT.highlightPostTag, 'g'),\n ``\n );\n}\n","import algoliasearchHelper from 'algoliasearch-helper';\nimport EventEmitter from 'events';\nimport RoutingManager from './RoutingManager';\nimport simpleMapping from './stateMappings/simple';\nimport historyRouter from './routers/history';\nimport version from './version';\nimport createHelpers from './createHelpers';\nimport {\n createDocumentationMessageGenerator,\n noop,\n isPlainObject,\n mergeDeep,\n} from './utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'instantsearch',\n});\n\nconst ROUTING_DEFAULT_OPTIONS = {\n stateMapping: simpleMapping(),\n router: historyRouter(),\n};\n\nfunction defaultCreateURL() {\n return '#';\n}\n\n/**\n * Widgets are the building blocks of InstantSearch.js. Any\n * valid widget must have at least a `render` or a `init` function.\n * @typedef {Object} Widget\n * @property {function} [render] Called after each search response has been received\n * @property {function} [getConfiguration] Let the widget update the configuration\n * of the search with new parameters\n * @property {function} [init] Called once before the first search\n */\n\n/**\n * The actual implementation of the InstantSearch. This is\n * created using the `instantsearch` factory function.\n * @fires Instantsearch#render This event is triggered each time a render is done\n */\nclass InstantSearch extends EventEmitter {\n constructor(options) {\n super();\n\n const {\n indexName = null,\n numberLocale,\n searchParameters = {},\n routing = null,\n searchFunction,\n stalledSearchDelay = 200,\n searchClient = null,\n insightsClient = null,\n } = options;\n\n if (indexName === null) {\n throw new Error(withUsage('The `indexName` option is required.'));\n }\n\n if (searchClient === null) {\n throw new Error(withUsage('The `searchClient` option is required.'));\n }\n\n if (typeof options.urlSync !== 'undefined') {\n throw new Error(\n withUsage(\n 'The `urlSync` option was removed in InstantSearch.js 3. You may want to use the `routing` option.'\n )\n );\n }\n\n if (typeof searchClient.search !== 'function') {\n throw new Error(\n `The \\`searchClient\\` must implement a \\`search\\` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/`\n );\n }\n\n if (typeof searchClient.addAlgoliaAgent === 'function') {\n searchClient.addAlgoliaAgent(`instantsearch.js (${version})`);\n }\n\n if (insightsClient && typeof insightsClient !== 'function') {\n throw new Error('The provided `insightsClient` must be a function.');\n }\n\n this.client = searchClient;\n this.insightsClient = insightsClient;\n this.helper = null;\n this.indexName = indexName;\n this.searchParameters = { ...searchParameters, index: indexName };\n this.widgets = [];\n this.templatesConfig = {\n helpers: createHelpers({ numberLocale }),\n compileOptions: {},\n };\n this._stalledSearchDelay = stalledSearchDelay;\n\n if (searchFunction) {\n this._searchFunction = searchFunction;\n }\n\n if (routing === true) this.routing = ROUTING_DEFAULT_OPTIONS;\n else if (isPlainObject(routing))\n this.routing = {\n ...ROUTING_DEFAULT_OPTIONS,\n ...routing,\n };\n }\n\n /**\n * Adds a widget. This can be done before and after InstantSearch has been started. Adding a\n * widget after InstantSearch started is considered **EXPERIMENTAL** and therefore\n * it is possibly buggy, if you find anything please\n * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20hot%20addWidget).\n * @param {Widget} widget The widget to add to InstantSearch. Widgets are simple objects\n * that have methods that map the search life cycle in a UI perspective. Usually widgets are\n * created by [widget factories](widgets.html) like the one provided with InstantSearch.js.\n * @return {undefined} This method does not return anything\n */\n addWidget(widget) {\n this.addWidgets([widget]);\n }\n\n /**\n * Adds multiple widgets. This can be done before and after the InstantSearch has been started. This feature\n * is considered **EXPERIMENTAL** and therefore it is possibly buggy, if you find anything please\n * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20addWidgets).\n * @param {Widget[]} widgets The array of widgets to add to InstantSearch.\n * @return {undefined} This method does not return anything\n */\n addWidgets(widgets) {\n if (!Array.isArray(widgets)) {\n throw new Error(\n withUsage(\n 'The `addWidgets` method expects an array of widgets. Please use `addWidget`.'\n )\n );\n }\n\n // The routing manager widget is always added manually at the last position.\n // By removing it from the last position and adding it back after, we ensure\n // it keeps this position.\n // fixes #3148\n const lastWidget = this.widgets.pop();\n\n widgets.forEach(widget => {\n // Add the widget to the list of widget\n if (widget.render === undefined && widget.init === undefined) {\n throw new Error(`The widget definition expects a \\`render\\` and/or an \\`init\\` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/widgets/create-your-own-widgets/js/`);\n }\n\n this.widgets.push(widget);\n });\n\n // Second part of the fix for #3148\n if (lastWidget) this.widgets.push(lastWidget);\n\n // Init the widget directly if instantsearch has been already started\n if (this.started && Boolean(widgets.length)) {\n this.searchParameters = this.widgets.reduce(enhanceConfiguration, {\n ...this.helper.state,\n });\n\n this.helper.setState(this.searchParameters);\n\n widgets.forEach(widget => {\n if (widget.init) {\n widget.init({\n state: this.helper.state,\n helper: this.helper,\n templatesConfig: this.templatesConfig,\n createURL: this._createAbsoluteURL,\n onHistoryChange: this._onHistoryChange,\n instantSearchInstance: this,\n });\n }\n });\n\n this.helper.search();\n }\n }\n\n /**\n * Removes a widget. This can be done after the InstantSearch has been started. This feature\n * is considered **EXPERIMENTAL** and therefore it is possibly buggy, if you find anything please\n * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20removeWidget).\n * @param {Widget} widget The widget instance to remove from InstantSearch. This widget must implement a `dispose()` method in order to be gracefully removed.\n * @return {undefined} This method does not return anything\n */\n removeWidget(widget) {\n this.removeWidgets([widget]);\n }\n\n /**\n * Removes multiple widgets. This can be done only after the InstantSearch has been started. This feature\n * is considered **EXPERIMENTAL** and therefore it is possibly buggy, if you find anything please\n * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20addWidgets).\n * @param {Widget[]} widgets Array of widgets instances to remove from InstantSearch.\n * @return {undefined} This method does not return anything\n */\n removeWidgets(widgets) {\n if (!Array.isArray(widgets)) {\n throw new Error(\n withUsage(\n 'The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'\n )\n );\n }\n\n widgets.forEach(widget => {\n if (\n !this.widgets.includes(widget) ||\n typeof widget.dispose !== 'function'\n ) {\n throw new Error(\n `The \\`dispose\\` method is required to remove the widget.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/widgets/create-your-own-widgets/js/#the-widget-lifecycle-and-api`\n );\n }\n\n this.widgets = this.widgets.filter(w => w !== widget);\n\n const nextState = widget.dispose({\n helper: this.helper,\n state: this.helper.state,\n });\n\n // re-compute remaining widgets to the state\n // in a case two widgets were using the same configuration but we removed one\n if (nextState) {\n this.searchParameters = this.widgets.reduce(enhanceConfiguration, {\n ...nextState,\n });\n\n this.helper.setState(this.searchParameters);\n }\n });\n\n // If there's multiple call to `removeWidget()` let's wait until they are all made\n // and then check for widgets.length & make a search on next tick\n //\n // This solves an issue where you unmount a page and removing widget by widget\n setTimeout(() => {\n // no need to trigger a search if we don't have any widgets left\n if (this.widgets.length > 0) {\n this.helper.search();\n }\n }, 0);\n }\n\n /**\n * Clears the cached answers from Algolia and triggers a new search.\n *\n * @return {undefined} Does not return anything\n */\n refresh() {\n if (this.helper) {\n this.helper.clearCache().search();\n }\n }\n\n /**\n * Ends the initialization of InstantSearch.js and triggers the\n * first search. This method should be called after all widgets have been added\n * to the instance of InstantSearch.js. InstantSearch.js also supports adding and removing\n * widgets after the start as an **EXPERIMENTAL** feature.\n *\n * @return {undefined} Does not return anything\n */\n start() {\n if (this.started) {\n throw new Error(\n withUsage('The `start` method has already been called once.')\n );\n }\n\n if (this.routing) {\n const routingManager = new RoutingManager({\n ...this.routing,\n instantSearchInstance: this,\n });\n this._onHistoryChange = routingManager.onHistoryChange.bind(\n routingManager\n );\n this._createURL = routingManager.createURL.bind(routingManager);\n this._createAbsoluteURL = this._createURL;\n this.widgets.push(routingManager);\n } else {\n this._createURL = defaultCreateURL;\n this._createAbsoluteURL = defaultCreateURL;\n this._onHistoryChange = noop;\n }\n\n this.searchParameters = this.widgets.reduce(\n enhanceConfiguration,\n this.searchParameters\n );\n\n const helper = algoliasearchHelper(\n this.client,\n this.searchParameters.index || this.indexName,\n this.searchParameters\n );\n\n if (this._searchFunction) {\n this._mainHelperSearch = helper.search.bind(helper);\n helper.search = () => {\n const helperSearchFunction = algoliasearchHelper(\n {\n search: () => new Promise(noop),\n },\n helper.state.index,\n helper.state\n );\n helperSearchFunction.once('search', state => {\n helper.overrideStateWithoutTriggeringChangeEvent(state);\n this._mainHelperSearch();\n });\n this._searchFunction(helperSearchFunction);\n };\n }\n\n this.helper = helper;\n this._init(helper.state, this.helper);\n this.helper.on('result', this._render.bind(this, this.helper));\n this.helper.on('error', e => {\n this.emit('error', e);\n });\n\n this._searchStalledTimer = null;\n this._isSearchStalled = true;\n\n this.helper.search();\n\n this.helper.on('search', () => {\n if (!this._isSearchStalled && !this._searchStalledTimer) {\n this._searchStalledTimer = setTimeout(() => {\n this._isSearchStalled = true;\n this._render(\n this.helper,\n this.helper.lastResults,\n this.helper.lastResults._state\n );\n }, this._stalledSearchDelay);\n }\n });\n\n // track we started the search if we add more widgets,\n // to init them directly after add\n this.started = true;\n }\n\n /**\n * Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,\n * if you find an issue with it, please\n * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20dispose).\n * @return {undefined} This method does not return anything\n */\n dispose() {\n this.removeWidgets(this.widgets);\n // You can not start an instance two times, therefore a disposed instance needs to set started as false\n // otherwise this can not be restarted at a later point.\n this.started = false;\n\n // The helper needs to be reset to perform the next search from a fresh state.\n // If not reset, it would use the state stored before calling `dispose()`.\n this.helper.removeAllListeners();\n this.helper = null;\n }\n\n createURL(params) {\n if (!this._createURL) {\n throw new Error(\n 'The `start` method needs to be called before `createURL`.'\n );\n }\n return this._createURL(this.helper.state.setQueryParameters(params));\n }\n\n _render(helper, results, state) {\n if (!this.helper.hasPendingRequests()) {\n clearTimeout(this._searchStalledTimer);\n this._searchStalledTimer = null;\n this._isSearchStalled = false;\n }\n\n this.widgets.forEach(widget => {\n if (!widget.render) {\n return;\n }\n widget.render({\n templatesConfig: this.templatesConfig,\n results,\n state,\n helper,\n createURL: this._createAbsoluteURL,\n instantSearchInstance: this,\n searchMetadata: {\n isSearchStalled: this._isSearchStalled,\n },\n });\n });\n\n /**\n * Render is triggered when the rendering of the widgets has been completed\n * after a search.\n * @event InstantSearch#render\n */\n this.emit('render');\n }\n\n _init(state, helper) {\n this.widgets.forEach(widget => {\n if (widget.init) {\n widget.init({\n state,\n helper,\n templatesConfig: this.templatesConfig,\n createURL: this._createAbsoluteURL,\n onHistoryChange: this._onHistoryChange,\n instantSearchInstance: this,\n });\n }\n });\n }\n}\n\nexport function enhanceConfiguration(configuration, widgetDefinition) {\n if (!widgetDefinition.getConfiguration) {\n return configuration;\n }\n\n // Get the relevant partial configuration asked by the widget\n const partialConfiguration = widgetDefinition.getConfiguration(configuration);\n\n return mergeDeep(configuration, partialConfiguration);\n}\n\nexport default InstantSearch;\n","export default '3.5.4';\n","import {\n highlight,\n snippet,\n HighlightOptions,\n SnippetOptions,\n} from '../helpers';\n\ntype HoganRenderer = (value: any) => string;\n\ninterface HoganHelpers {\n formatNumber: (value: number, render: HoganRenderer) => string;\n highlight: (options: string, render: HoganRenderer) => string;\n snippet: (options: string, render: HoganRenderer) => string;\n}\n\nexport default function hoganHelpers({\n numberLocale,\n}: {\n numberLocale: string;\n}): HoganHelpers {\n return {\n formatNumber(value, render) {\n return Number(render(value)).toLocaleString(numberLocale);\n },\n highlight(options, render) {\n try {\n const highlightOptions: Omit = JSON.parse(\n options\n );\n\n return render(\n highlight({\n ...highlightOptions,\n hit: this,\n })\n );\n } catch (error) {\n throw new Error(`\nThe highlight helper expects a JSON object of the format:\n{ \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }`);\n }\n },\n snippet(options, render) {\n try {\n const snippetOptions: Omit = JSON.parse(options);\n\n return render(\n snippet({\n ...snippetOptions,\n hit: this,\n })\n );\n } catch (error) {\n throw new Error(`\nThe snippet helper expects a JSON object of the format:\n{ \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }`);\n }\n },\n };\n}\n","import uniq from './uniq';\nimport isPlainObject from './isPlainObject';\n\n/**\n * Deeply merges all the object values in a new object.\n *\n * - Primitive values are replaced\n * - Arrays a concatenated and their values are made unique\n */\nfunction mergeDeep(...values: object[]): object {\n return values.reduce((acc, source = {}) => {\n Object.keys(source).forEach(key => {\n const previousValue = acc[key];\n const nextValue = source[key];\n\n if (Array.isArray(previousValue) && Array.isArray(nextValue)) {\n acc[key] = uniq([...previousValue, ...nextValue]);\n } else if (isPlainObject(previousValue) && isPlainObject(nextValue)) {\n acc[key] = mergeDeep(previousValue, nextValue);\n } else {\n acc[key] = nextValue;\n }\n });\n\n return acc;\n }, {});\n}\n\nexport default mergeDeep;\n","import {\n checkRendering,\n clearRefinements,\n getRefinements,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'clear-refinements',\n connector: true,\n});\n\n/**\n * @typedef {Object} CustomClearRefinementsWidgetOptions\n * @property {string[]} [includedAttributes = []] The attributes to include in the refinements to clear (all by default). Cannot be used with `excludedAttributes`.\n * @property {string[]} [excludedAttributes = ['query']] The attributes to exclude from the refinements to clear. Cannot be used with `includedAttributes`.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} ClearRefinementsRenderingOptions\n * @property {function} refine Triggers the clear of all the currently refined values.\n * @property {boolean} hasRefinements Indicates if search state is refined.\n * @property {function} createURL Creates a url for the next state when refinements are cleared.\n * @property {Object} widgetParams All original `CustomClearRefinementsWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **ClearRefinements** connector provides the logic to build a custom widget that will give the user\n * the ability to reset the search state.\n *\n * This connector provides a `refine` function to remove the current refined facets.\n *\n * The behaviour of this function can be changed with widget options. If `clearsQuery`\n * is set to `true`, `refine` will also clear the query and `excludedAttributes` can\n * prevent certain attributes from being cleared.\n *\n * @type {Connector}\n * @param {function(ClearRefinementsRenderingOptions, boolean)} renderFn Rendering function for the custom **ClearRefinements** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomClearRefinementsWidgetOptions)} Re-usable widget factory for a custom **ClearRefinements** widget.\n * @example\n * // custom `renderFn` to render the custom ClearRefinements widget\n * function renderFn(ClearRefinementsRenderingOptions, isFirstRendering) {\n * var containerNode = ClearRefinementsRenderingOptions.widgetParams.containerNode;\n * if (isFirstRendering) {\n * var markup = $('');\n * containerNode.append(markup);\n *\n * markup.on('click', function(event) {\n * event.preventDefault();\n * ClearRefinementsRenderingOptions.refine();\n * })\n * }\n *\n * var clearRefinementsCTA = containerNode.find('#custom-clear-all');\n * clearRefinementsCTA.attr('disabled', !ClearRefinementsRenderingOptions.hasRefinements)\n * };\n *\n * // connect `renderFn` to ClearRefinements logic\n * var customClearRefinementsWidget = instantsearch.connectors.connectClearRefinements(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customClearRefinementsWidget({\n * containerNode: $('#custom-clear-all-container'),\n * })\n * );\n */\nexport default function connectClearRefinements(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n if (widgetParams.includedAttributes && widgetParams.excludedAttributes) {\n throw new Error(\n withUsage(\n 'The options `includedAttributes` and `excludedAttributes` cannot be used together.'\n )\n );\n }\n\n const {\n includedAttributes = [],\n excludedAttributes = ['query'],\n transformItems = items => items,\n } = widgetParams;\n\n return {\n init({ helper, instantSearchInstance, createURL }) {\n const attributesToClear = getAttributesToClear({\n helper,\n includedAttributes,\n excludedAttributes,\n transformItems,\n });\n const hasRefinements = attributesToClear.length > 0;\n\n this._refine = () => {\n helper\n .setState(\n clearRefinements({\n helper,\n attributesToClear: getAttributesToClear({\n helper,\n includedAttributes,\n excludedAttributes,\n transformItems,\n }),\n })\n )\n .search();\n };\n\n this._createURL = () =>\n createURL(\n clearRefinements({\n helper,\n attributesToClear: getAttributesToClear({\n helper,\n includedAttributes,\n excludedAttributes,\n transformItems,\n }),\n })\n );\n\n renderFn(\n {\n hasRefinements,\n refine: this._refine,\n createURL: this._createURL,\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ helper, instantSearchInstance }) {\n const attributesToClear = getAttributesToClear({\n helper,\n includedAttributes,\n excludedAttributes,\n transformItems,\n });\n const hasRefinements = attributesToClear.length > 0;\n\n renderFn(\n {\n hasRefinements,\n refine: this._refine,\n createURL: this._createURL,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n };\n };\n}\n\nfunction getAttributesToClear({\n helper,\n includedAttributes,\n excludedAttributes,\n transformItems,\n}) {\n const clearsQuery =\n includedAttributes.indexOf('query') !== -1 ||\n excludedAttributes.indexOf('query') === -1;\n\n return transformItems(\n getRefinements(helper.lastResults || {}, helper.state, clearsQuery)\n .map(refinement => refinement.attributeName)\n .filter(\n attribute =>\n // If the array is empty (default case), we keep all the attributes\n includedAttributes.length === 0 ||\n // Otherwise, only add the specified attributes\n includedAttributes.indexOf(attribute) !== -1\n )\n .filter(\n attribute =>\n // If the query is included, we ignore the default `excludedAttributes = ['query']`\n (attribute === 'query' && clearsQuery) ||\n // Otherwise, ignore the excluded attributes\n excludedAttributes.indexOf(attribute) === -1\n )\n );\n}\n","import {\n getRefinements,\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'current-refinements',\n connector: true,\n});\n\n/**\n * @typedef {Object} Refinement\n * @property {\"facet\"|\"exclude\"|\"disjunctive\"|\"hierarchical\"|\"numeric\"|\"query\"} type The type of the refinement\n * @property {string} attribute The attribute on which the refinement is applied\n * @property {string} label The label of the refinement to display\n * @property {string} value The raw value of the refinement\n * @property {string} [operator] The value of the operator, only if applicable\n * @property {boolean} [exhaustive] Whether the count is exhaustive, only if applicable\n * @property {number} [count] number of items found, if applicable\n */\n\n/**\n * @typedef {Object} RefinementItem\n * @property {string} attribute The attribute on which the refinement is applied\n * @property {function} refine The function to remove the refinement\n * @property {Refinement[]} refinements The current refinements\n */\n\n/**\n * @typedef {Object} CurrentRefinementsRenderingOptions\n * @property {function(item)} refine Clears a single refinement\n * @property {function(item): string} createURL Creates an individual URL where a single refinement is cleared\n * @property {RefinementItem[]} items All the refinement items\n * @property {Object} widgetParams All original `CustomCurrentRefinementsWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * @typedef {Object} CustomCurrentRefinementsWidgetOptions\n * @property {string[]} [includedAttributes] The attributes to include in the refinements (all by default). Cannot be used with `excludedAttributes`.\n * @property {string[]} [excludedAttributes = [\"query\"]] The attributes to exclude from the refinements. Cannot be used with `includedAttributes`.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * **CurrentRefinements** connector provides the logic to build a widget that will give\n * the user the ability to see all the currently applied filters and, remove some or all of\n * them.\n *\n * This provides a `refine(item)` function to remove a selected refinement.\n * Those functions can see their behaviour change based on the widget options used.\n * @type {Connector}\n * @param {function(CurrentRefinementsRenderingOptions)} renderFn Rendering function for the custom **CurrentRefinements** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomCurrentRefinementsWidgetOptions)} Re-usable widget factory for a custom **CurrentRefinements** widget.\n * @example\n * // custom `renderFn` to render the custom ClearRefinements widget\n * function renderFn(currentRefinementsRenderingOptions, isFirstRendering) {\n * var containerNode = currentRefinementsRenderingOptions.widgetParams.containerNode;\n * if (isFirstRendering) {\n * containerNode\n * .html('
    ');\n * }\n *\n * containerNode\n * .find('#cta-container > a')\n * .off('click');\n *\n * containerNode\n * .find('li > a')\n * .each(function() { $(this).off('click') });\n *\n * if (currentRefinementsRenderingOptions.items\n * && currentRefinementsRenderingOptions.items.length > 0) {\n * var list = currentRefinementsRenderingOptions.items.map(function(item) {\n * return '
  • ' + item.attribute +\n * ''\n * '
  • ';\n * });\n *\n * currentRefinementsRenderingOptions.find('ul').html(list);\n * } else {\n * containerNode.find('#cta-container').html('');\n * containerNode.find('ul').html('');\n * }\n * }\n *\n * // connect `renderFn` to CurrentRefinements logic\n * var customCurrentRefinements = instantsearch.connectors.connectCurrentRefinements(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customCurrentRefinements({\n * containerNode: $('#custom-crv-container'),\n * })\n * );\n */\nexport default function connectCurrentRefinements(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n if (widgetParams.includedAttributes && widgetParams.excludedAttributes) {\n throw new Error(\n withUsage(\n 'The options `includedAttributes` and `excludedAttributes` cannot be used together.'\n )\n );\n }\n\n const {\n includedAttributes,\n excludedAttributes = ['query'],\n transformItems = items => items,\n } = widgetParams;\n\n return {\n init({ helper, createURL, instantSearchInstance }) {\n const items = transformItems(\n getFilteredRefinements({\n results: {},\n state: helper.state,\n helper,\n includedAttributes,\n excludedAttributes,\n })\n );\n\n renderFn(\n {\n items,\n refine: refinement => clearRefinement(helper, refinement),\n createURL: refinement =>\n createURL(clearRefinementFromState(helper.state, refinement)),\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, helper, state, createURL, instantSearchInstance }) {\n const items = transformItems(\n getFilteredRefinements({\n results,\n state,\n helper,\n includedAttributes,\n excludedAttributes,\n })\n );\n\n renderFn(\n {\n items,\n refine: refinement => clearRefinement(helper, refinement),\n createURL: refinement =>\n createURL(clearRefinementFromState(helper.state, refinement)),\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n };\n };\n}\n\nfunction getFilteredRefinements({\n results,\n state,\n helper,\n includedAttributes,\n excludedAttributes,\n}) {\n const clearsQuery =\n (includedAttributes || []).indexOf('query') !== -1 ||\n (excludedAttributes || []).indexOf('query') === -1;\n\n const filterFunction = includedAttributes\n ? item => includedAttributes.indexOf(item.attributeName) !== -1\n : item => excludedAttributes.indexOf(item.attributeName) === -1;\n\n const items = getRefinements(results, state, clearsQuery)\n .filter(filterFunction)\n .map(normalizeRefinement);\n\n return groupItemsByRefinements(items, helper);\n}\n\nfunction clearRefinementFromState(state, refinement) {\n switch (refinement.type) {\n case 'facet':\n return state.removeFacetRefinement(\n refinement.attribute,\n refinement.value\n );\n case 'disjunctive':\n return state.removeDisjunctiveFacetRefinement(\n refinement.attribute,\n refinement.value\n );\n case 'hierarchical':\n return state.removeHierarchicalFacetRefinement(refinement.attribute);\n case 'exclude':\n return state.removeExcludeRefinement(\n refinement.attribute,\n refinement.value\n );\n case 'numeric':\n return state.removeNumericRefinement(\n refinement.attribute,\n refinement.operator,\n refinement.value\n );\n case 'tag':\n return state.removeTagRefinement(refinement.value);\n case 'query':\n return state.setQueryParameter('query', '');\n default:\n throw new Error(\n `clearRefinement: type ${refinement.type} is not handled`\n );\n }\n}\n\nfunction clearRefinement(helper, refinement) {\n helper.setState(clearRefinementFromState(helper.state, refinement)).search();\n}\n\nfunction getOperatorSymbol(operator) {\n switch (operator) {\n case '>=':\n return '≥';\n case '<=':\n return '≤';\n default:\n return operator;\n }\n}\n\nfunction normalizeRefinement(refinement) {\n const value =\n refinement.type === 'numeric' ? Number(refinement.name) : refinement.name;\n const label = refinement.operator\n ? `${getOperatorSymbol(refinement.operator)} ${refinement.name}`\n : refinement.name;\n\n const normalizedRefinement = {\n attribute: refinement.attributeName,\n type: refinement.type,\n value,\n label,\n };\n\n if (refinement.operator !== undefined) {\n normalizedRefinement.operator = refinement.operator;\n }\n if (refinement.count !== undefined) {\n normalizedRefinement.count = refinement.count;\n }\n if (refinement.exhaustive !== undefined) {\n normalizedRefinement.exhaustive = refinement.exhaustive;\n }\n return normalizedRefinement;\n}\n\nfunction groupItemsByRefinements(items, helper) {\n return items.reduce(\n (results, currentItem) => [\n ...results.filter(result => result.attribute !== currentItem.attribute),\n {\n attribute: currentItem.attribute,\n label: currentItem.attribute,\n refinements: items\n .filter(result => result.attribute === currentItem.attribute)\n // We want to keep the order of refinements except the numeric ones.\n .sort((a, b) => (a.type === 'numeric' ? a.value - b.value : 0)),\n refine: refinement => clearRefinement(helper, refinement),\n },\n ],\n []\n );\n}\n","import {\n checkRendering,\n warning,\n createDocumentationMessageGenerator,\n isEqual,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'hierarchical-menu',\n connector: true,\n});\n\n/**\n * @typedef {Object} HierarchicalMenuItem\n * @property {string} value Value of the menu item.\n * @property {string} label Human-readable value of the menu item.\n * @property {number} count Number of matched results after refinement is applied.\n * @property {isRefined} boolean Indicates if the refinement is applied.\n * @property {Object} [data = undefined] n+1 level of items, same structure HierarchicalMenuItem (default: `undefined`).\n */\n\n/**\n * @typedef {Object} CustomHierarchicalMenuWidgetOptions\n * @property {string[]} attributes Attributes to use to generate the hierarchy of the menu.\n * @property {string} [separator = '>'] Separator used in the attributes to separate level values.\n * @property {string} [rootPath = null] Prefix path to use if the first level is not the root level.\n * @property {boolean} [showParentLevel=false] Show the siblings of the selected parent levels of the current refined value. This\n * does not impact the root level.\n * @property {number} [limit = 10] Max number of values to display.\n * @property {boolean} [showMore = false] Whether to display the \"show more\" button.\n * @property {number} [showMoreLimit = 20] Max number of values to display when showing more.\n * @property {string[]|function} [sortBy = ['name:asc']] How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.\n *\n * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} HierarchicalMenuRenderingOptions\n * @property {function(item.value): string} createURL Creates an url for the next state for a clicked item.\n * @property {HierarchicalMenuItem[]} items Values to be rendered.\n * @property {function(item.value)} refine Sets the path of the hierarchical filter and triggers a new search.\n * @property {Object} widgetParams All original `CustomHierarchicalMenuWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **HierarchicalMenu** connector provides the logic to build a custom widget\n * that will give the user the ability to explore facets in a tree-like structure.\n *\n * This is commonly used for multi-level categorization of products on e-commerce\n * websites. From a UX point of view, we suggest not displaying more than two\n * levels deep.\n *\n * There's a complete example available on how to write a custom **HierarchicalMenu**:\n * [hierarchicalMenu.js](https://github.com/algolia/instantsearch.js/blob/develop/storybook/app/jquery/widgets/hierarchicalMenu.js)\n * @type {Connector}\n * @param {function(HierarchicalMenuRenderingOptions)} renderFn Rendering function for the custom **HierarchicalMenu** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomHierarchicalMenuWidgetOptions)} Re-usable widget factory for a custom **HierarchicalMenu** widget.\n */\nexport default function connectHierarchicalMenu(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const {\n attributes,\n separator = ' > ',\n rootPath = null,\n showParentLevel = true,\n limit = 10,\n showMore = false,\n showMoreLimit = 20,\n sortBy = ['name:asc'],\n transformItems = items => items,\n } = widgetParams;\n\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) {\n throw new Error(\n withUsage('The `attributes` option expects an array of strings.')\n );\n }\n\n if (showMore === true && showMoreLimit <= limit) {\n throw new Error(\n withUsage('The `showMoreLimit` option must be greater than `limit`.')\n );\n }\n\n // we need to provide a hierarchicalFacet name for the search state\n // so that we can always map $hierarchicalFacetName => real attributes\n // we use the first attribute name\n const [hierarchicalFacetName] = attributes;\n\n return {\n isShowingMore: false,\n\n // Provide the same function to the `renderFn` so that way the user\n // has to only bind it once when `isFirstRendering` for instance\n toggleShowMore() {},\n cachedToggleShowMore() {\n this.toggleShowMore();\n },\n\n createToggleShowMore(renderOptions) {\n return () => {\n this.isShowingMore = !this.isShowingMore;\n this.render(renderOptions);\n };\n },\n\n getLimit() {\n return this.isShowingMore ? showMoreLimit : limit;\n },\n\n getConfiguration(currentConfiguration) {\n if (currentConfiguration.hierarchicalFacets) {\n const isFacetSet = find(\n currentConfiguration.hierarchicalFacets,\n ({ name }) => name === hierarchicalFacetName\n );\n if (\n isFacetSet &&\n !(\n isEqual(isFacetSet.attributes, attributes) &&\n isFacetSet.separator === separator\n )\n ) {\n warning(\n isEqual(isFacetSet.attributes, attributes) &&\n isFacetSet.separator === separator,\n 'Using Breadcrumb and HierarchicalMenu on the same facet with different options overrides the configuration of the HierarchicalMenu.'\n );\n return {};\n }\n }\n\n const widgetConfiguration = {\n hierarchicalFacets: [\n {\n name: hierarchicalFacetName,\n attributes,\n separator,\n rootPath,\n showParentLevel,\n },\n ],\n };\n\n const currentMaxValuesPerFacet =\n currentConfiguration.maxValuesPerFacet || 0;\n\n widgetConfiguration.maxValuesPerFacet = Math.max(\n currentMaxValuesPerFacet,\n showMore ? showMoreLimit : limit\n );\n\n return widgetConfiguration;\n },\n\n init({ helper, createURL, instantSearchInstance }) {\n this.cachedToggleShowMore = this.cachedToggleShowMore.bind(this);\n this._refine = function(facetValue) {\n helper.toggleRefinement(hierarchicalFacetName, facetValue).search();\n };\n\n // Bind createURL to this specific attribute\n function _createURL(facetValue) {\n return createURL(\n helper.state.toggleRefinement(hierarchicalFacetName, facetValue)\n );\n }\n\n renderFn(\n {\n items: [],\n createURL: _createURL,\n refine: this._refine,\n instantSearchInstance,\n widgetParams,\n isShowingMore: false,\n toggleShowMore: this.cachedToggleShowMore,\n canToggleShowMore: false,\n },\n true\n );\n },\n\n _prepareFacetValues(facetValues, state) {\n return facetValues\n .slice(0, this.getLimit())\n .map(({ name: label, path: value, ...subValue }) => {\n if (Array.isArray(subValue.data)) {\n subValue.data = this._prepareFacetValues(subValue.data, state);\n }\n return { ...subValue, label, value };\n });\n },\n\n render(renderOptions) {\n const {\n results,\n state,\n createURL,\n instantSearchInstance,\n } = renderOptions;\n\n const facetValues =\n results.getFacetValues(hierarchicalFacetName, { sortBy }).data || [];\n const items = transformItems(\n this._prepareFacetValues(facetValues),\n state\n );\n\n // Bind createURL to this specific attribute\n function _createURL(facetValue) {\n return createURL(\n state.toggleRefinement(hierarchicalFacetName, facetValue)\n );\n }\n\n const maxValuesPerFacetConfig = state.getQueryParameter(\n 'maxValuesPerFacet'\n );\n const currentLimit = this.getLimit();\n // If the limit is the max number of facet retrieved it is impossible to know\n // if the facets are exhaustive. The only moment we are sure it is exhaustive\n // is when it is strictly under the number requested unless we know that another\n // widget has requested more values (maxValuesPerFacet > getLimit()).\n // Because this is used for making the search of facets unable or not, it is important\n // to be conservative here.\n const hasExhaustiveItems =\n maxValuesPerFacetConfig > currentLimit\n ? facetValues.length <= currentLimit\n : facetValues.length < currentLimit;\n\n this.toggleShowMore = this.createToggleShowMore(renderOptions);\n\n renderFn(\n {\n items,\n refine: this._refine,\n createURL: _createURL,\n instantSearchInstance,\n widgetParams,\n isShowingMore: this.isShowingMore,\n toggleShowMore: this.cachedToggleShowMore,\n canToggleShowMore:\n showMore && (this.isShowingMore || !hasExhaustiveItems),\n },\n false\n );\n },\n\n dispose({ state }) {\n // unmount widget from DOM\n unmountFn();\n\n // compute nextState for the search\n let nextState = state;\n\n if (state.isHierarchicalFacetRefined(hierarchicalFacetName)) {\n nextState = state.removeHierarchicalFacetRefinement(\n hierarchicalFacetName\n );\n }\n\n nextState = nextState.removeHierarchicalFacet(hierarchicalFacetName);\n\n if (nextState.maxValuesPerFacet === limit) {\n nextState.setQueryParameters('maxValuesPerFacet', undefined);\n }\n\n return nextState;\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const path = searchParameters.getHierarchicalFacetBreadcrumb(\n hierarchicalFacetName\n );\n if (!path || path.length === 0) return uiState;\n if (\n uiState.hierarchicalMenu &&\n isEqual(path, uiState.hierarchicalMenu[hierarchicalFacetName])\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n hierarchicalMenu: {\n ...uiState.hierarchicalMenu,\n [hierarchicalFacetName]: path,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n if (\n uiState.hierarchicalMenu &&\n uiState.hierarchicalMenu[hierarchicalFacetName]\n ) {\n return searchParameters\n .clearRefinements(hierarchicalFacetName)\n .toggleRefinement(\n hierarchicalFacetName,\n uiState.hierarchicalMenu[hierarchicalFacetName].join(separator)\n );\n } else {\n return searchParameters;\n }\n },\n };\n };\n}\n","import escapeHits, { TAG_PLACEHOLDER } from '../../lib/escape-highlight';\nimport {\n checkRendering,\n createDocumentationMessageGenerator,\n addAbsolutePosition,\n addQueryID,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'hits',\n connector: true,\n});\n\n/**\n * @typedef {Object} HitsRenderingOptions\n * @property {Object[]} hits The matched hits from Algolia API.\n * @property {Object} results The complete results response from Algolia API.\n * @property {Object} widgetParams All original widget options forwarded to the `renderFn`.\n */\n\n/**\n * @typedef {Object} CustomHitsWidgetOptions\n * @property {boolean} [escapeHTML = true] Whether to escape HTML tags from `hits[i]._highlightResult`.\n * @property {function(Object[]):Object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * **Hits** connector provides the logic to create custom widgets that will render the results retrieved from Algolia.\n * @type {Connector}\n * @param {function(HitsRenderingOptions, boolean)} renderFn Rendering function for the custom **Hits** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomHitsWidgetOptions)} Re-usable widget factory for a custom **Hits** widget.\n * @example\n * // custom `renderFn` to render the custom Hits widget\n * function renderFn(HitsRenderingOptions) {\n * HitsRenderingOptions.widgetParams.containerNode.html(\n * HitsRenderingOptions.hits.map(function(hit) {\n * return '
    ' + hit._highlightResult.name.value + '
    ';\n * })\n * );\n * }\n *\n * // connect `renderFn` to Hits logic\n * var customHits = instantsearch.connectors.connectHits(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customHits({\n * containerNode: $('#custom-hits-container'),\n * })\n * );\n */\nexport default function connectHits(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { escapeHTML = true, transformItems = items => items } = widgetParams;\n\n return {\n getConfiguration() {\n return escapeHTML ? TAG_PLACEHOLDER : undefined;\n },\n\n init({ instantSearchInstance }) {\n renderFn(\n {\n hits: [],\n results: undefined,\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, instantSearchInstance }) {\n if (escapeHTML && results.hits.length > 0) {\n results.hits = escapeHits(results.hits);\n }\n\n const initialEscaped = results.hits.__escaped;\n\n results.hits = addAbsolutePosition(\n results.hits,\n results.page,\n results.hitsPerPage\n );\n\n results.hits = addQueryID(results.hits, results.queryID);\n\n results.hits = transformItems(results.hits);\n\n // Make sure the escaped tag stays, even after mapping over the hits.\n // This prevents the hits from being double-escaped if there are multiple\n // hits widgets mounted on the page.\n results.hits.__escaped = initialEscaped;\n\n renderFn(\n {\n hits: results.hits,\n results,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n };\n };\n}\n","import { uniq, find } from '../utils';\nimport {\n Hits,\n InsightsClient,\n InsightsClientMethod,\n InsightsClientPayload,\n InsightsClientWrapper,\n Renderer,\n RenderOptions,\n Unmounter,\n WidgetFactory,\n SearchResults,\n} from '../../types';\n\nconst getSelectedHits = (hits: Hits, selectedObjectIDs: string[]): Hits => {\n return selectedObjectIDs.map(objectID => {\n const hit = find(hits, h => h.objectID === objectID);\n if (typeof hit === 'undefined') {\n throw new Error(\n `Could not find objectID \"${objectID}\" passed to \\`clickedObjectIDsAfterSearch\\` in the returned hits. This is necessary to infer the absolute position and the query ID.`\n );\n }\n return hit;\n });\n};\n\nconst getQueryID = (selectedHits: Hits): string => {\n const queryIDs = uniq(selectedHits.map(hit => hit.__queryID));\n if (queryIDs.length > 1) {\n throw new Error(\n 'Insights currently allows a single `queryID`. The `objectIDs` provided map to multiple `queryID`s.'\n );\n }\n const queryID = queryIDs[0];\n if (typeof queryID !== 'string') {\n throw new Error(\n 'Could not infer `queryID`. Ensure InstantSearch is configured with `clickAnalytics: true`'\n );\n }\n return queryID;\n};\n\nconst getPositions = (selectedHits: Hits): number[] =>\n selectedHits.map(hit => hit.__position);\n\nexport const inferPayload = ({\n method,\n results,\n hits,\n objectIDs,\n}: {\n method: InsightsClientMethod;\n results: SearchResults;\n hits: Hits;\n objectIDs: string[];\n}): Omit => {\n const { index } = results;\n const selectedHits = getSelectedHits(hits, objectIDs);\n const queryID = getQueryID(selectedHits);\n\n switch (method) {\n case 'clickedObjectIDsAfterSearch': {\n const positions = getPositions(selectedHits);\n return { index, queryID, objectIDs, positions };\n }\n\n case 'convertedObjectIDsAfterSearch':\n return { index, queryID, objectIDs };\n\n default:\n throw new Error(`Unsupported method passed to insights: \"${method}\".`);\n }\n};\n\nconst wrapInsightsClient = (\n aa: InsightsClient,\n results: SearchResults,\n hits: Hits\n): InsightsClientWrapper => (\n method: InsightsClientMethod,\n payload: Partial\n) => {\n if (!Array.isArray(payload.objectIDs)) {\n throw new TypeError('Expected `objectIDs` to be an array.');\n }\n const inferredPayload = inferPayload({\n method,\n results,\n hits,\n objectIDs: payload.objectIDs,\n });\n aa(method, { ...inferredPayload, ...payload } as any);\n};\n\ntype Connector = (\n renderFn: Renderer,\n unmountFn: Unmounter\n) => WidgetFactory;\n\nexport default function withInsights(\n connector: Connector\n): Connector {\n const wrapRenderFn = (\n renderFn: Renderer>\n ): Renderer> => (\n renderOptions: RenderOptions,\n isFirstRender: boolean\n ) => {\n const { results, hits, instantSearchInstance } = renderOptions;\n if (\n results &&\n hits &&\n instantSearchInstance &&\n instantSearchInstance.insightsClient /* providing the insightsClient is optional */\n ) {\n const insights = wrapInsightsClient(\n instantSearchInstance.insightsClient,\n results,\n hits\n );\n return renderFn({ ...renderOptions, insights }, isFirstRender);\n }\n return renderFn(renderOptions, isFirstRender);\n };\n\n return (renderFn: Renderer>, unmountFn: Unmounter) =>\n connector(wrapRenderFn(renderFn), unmountFn);\n}\n","/** @license React v16.8.6\n * react-is.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';Object.defineProperty(exports,\"__esModule\",{value:!0});\nvar b=\"function\"===typeof Symbol&&Symbol.for,c=b?Symbol.for(\"react.element\"):60103,d=b?Symbol.for(\"react.portal\"):60106,e=b?Symbol.for(\"react.fragment\"):60107,f=b?Symbol.for(\"react.strict_mode\"):60108,g=b?Symbol.for(\"react.profiler\"):60114,h=b?Symbol.for(\"react.provider\"):60109,k=b?Symbol.for(\"react.context\"):60110,l=b?Symbol.for(\"react.async_mode\"):60111,m=b?Symbol.for(\"react.concurrent_mode\"):60111,n=b?Symbol.for(\"react.forward_ref\"):60112,p=b?Symbol.for(\"react.suspense\"):60113,q=b?Symbol.for(\"react.memo\"):\n60115,r=b?Symbol.for(\"react.lazy\"):60116;function t(a){if(\"object\"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case r:case q:case d:return u}}}function v(a){return t(a)===m}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;\nexports.Fragment=e;exports.Lazy=r;exports.Memo=q;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isValidElementType=function(a){return\"string\"===typeof a||\"function\"===typeof a||a===e||a===m||a===g||a===f||a===p||\"object\"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||t(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return t(a)===k};\nexports.isContextProvider=function(a){return t(a)===h};exports.isElement=function(a){return\"object\"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===n};exports.isFragment=function(a){return t(a)===e};exports.isLazy=function(a){return t(a)===r};exports.isMemo=function(a){return t(a)===q};exports.isPortal=function(a){return t(a)===d};exports.isProfiler=function(a){return t(a)===g};exports.isStrictMode=function(a){return t(a)===f};\nexports.isSuspense=function(a){return t(a)===p};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-is.production.min.js');\n} else {\n module.exports = require('./cjs/react-is.development.js');\n}\n","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactIs = require('react-is');\nvar assign = require('object-assign');\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\nvar checkPropTypes = require('./checkPropTypes');\n\nvar has = Function.call.bind(Object.prototype.hasOwnProperty);\nvar printWarning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) {}\n };\n}\n\nfunction emptyFunctionThatReturnsNull() {\n return null;\n}\n\nmodule.exports = function(isValidElement, throwOnDirectAccess) {\n /* global Symbol */\n var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;\n var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.\n\n /**\n * Returns the iterator method function contained on the iterable object.\n *\n * Be sure to invoke the function with the iterable as context:\n *\n * var iteratorFn = getIteratorFn(myIterable);\n * if (iteratorFn) {\n * var iterator = iteratorFn.call(myIterable);\n * ...\n * }\n *\n * @param {?object} maybeIterable\n * @return {?function}\n */\n function getIteratorFn(maybeIterable) {\n var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);\n if (typeof iteratorFn === 'function') {\n return iteratorFn;\n }\n }\n\n /**\n * Collection of methods that allow declaration and validation of props that are\n * supplied to React components. Example usage:\n *\n * var Props = require('ReactPropTypes');\n * var MyArticle = React.createClass({\n * propTypes: {\n * // An optional string prop named \"description\".\n * description: Props.string,\n *\n * // A required enum prop named \"category\".\n * category: Props.oneOf(['News','Photos']).isRequired,\n *\n * // A prop named \"dialog\" that requires an instance of Dialog.\n * dialog: Props.instanceOf(Dialog).isRequired\n * },\n * render: function() { ... }\n * });\n *\n * A more formal specification of how these methods are used:\n *\n * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)\n * decl := ReactPropTypes.{type}(.isRequired)?\n *\n * Each and every declaration produces a function with the same signature. This\n * allows the creation of custom validation functions. For example:\n *\n * var MyLink = React.createClass({\n * propTypes: {\n * // An optional string or URI prop named \"href\".\n * href: function(props, propName, componentName) {\n * var propValue = props[propName];\n * if (propValue != null && typeof propValue !== 'string' &&\n * !(propValue instanceof URI)) {\n * return new Error(\n * 'Expected a string or an URI for ' + propName + ' in ' +\n * componentName\n * );\n * }\n * }\n * },\n * render: function() {...}\n * });\n *\n * @internal\n */\n\n var ANONYMOUS = '<>';\n\n // Important!\n // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.\n var ReactPropTypes = {\n array: createPrimitiveTypeChecker('array'),\n bool: createPrimitiveTypeChecker('boolean'),\n func: createPrimitiveTypeChecker('function'),\n number: createPrimitiveTypeChecker('number'),\n object: createPrimitiveTypeChecker('object'),\n string: createPrimitiveTypeChecker('string'),\n symbol: createPrimitiveTypeChecker('symbol'),\n\n any: createAnyTypeChecker(),\n arrayOf: createArrayOfTypeChecker,\n element: createElementTypeChecker(),\n elementType: createElementTypeTypeChecker(),\n instanceOf: createInstanceTypeChecker,\n node: createNodeChecker(),\n objectOf: createObjectOfTypeChecker,\n oneOf: createEnumTypeChecker,\n oneOfType: createUnionTypeChecker,\n shape: createShapeTypeChecker,\n exact: createStrictShapeTypeChecker,\n };\n\n /**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\n /*eslint-disable no-self-compare*/\n function is(x, y) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n return x !== 0 || 1 / x === 1 / y;\n } else {\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n }\n }\n /*eslint-enable no-self-compare*/\n\n /**\n * We use an Error-like object for backward compatibility as people may call\n * PropTypes directly and inspect their output. However, we don't use real\n * Errors anymore. We don't inspect their stack anyway, and creating them\n * is prohibitively expensive if they are created too often, such as what\n * happens in oneOfType() for any type before the one that matched.\n */\n function PropTypeError(message) {\n this.message = message;\n this.stack = '';\n }\n // Make `instanceof Error` still work for returned errors.\n PropTypeError.prototype = Error.prototype;\n\n function createChainableTypeChecker(validate) {\n if (process.env.NODE_ENV !== 'production') {\n var manualPropTypeCallCache = {};\n var manualPropTypeWarningCount = 0;\n }\n function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {\n componentName = componentName || ANONYMOUS;\n propFullName = propFullName || propName;\n\n if (secret !== ReactPropTypesSecret) {\n if (throwOnDirectAccess) {\n // New behavior only for users of `prop-types` package\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use `PropTypes.checkPropTypes()` to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {\n // Old behavior for people using React.PropTypes\n var cacheKey = componentName + ':' + propName;\n if (\n !manualPropTypeCallCache[cacheKey] &&\n // Avoid spamming the console because they are often not actionable except for lib authors\n manualPropTypeWarningCount < 3\n ) {\n printWarning(\n 'You are manually calling a React.PropTypes validation ' +\n 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +\n 'and will throw in the standalone `prop-types` package. ' +\n 'You may be seeing this warning due to a third-party PropTypes ' +\n 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'\n );\n manualPropTypeCallCache[cacheKey] = true;\n manualPropTypeWarningCount++;\n }\n }\n }\n if (props[propName] == null) {\n if (isRequired) {\n if (props[propName] === null) {\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));\n }\n return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));\n }\n return null;\n } else {\n return validate(props, propName, componentName, location, propFullName);\n }\n }\n\n var chainedCheckType = checkType.bind(null, false);\n chainedCheckType.isRequired = checkType.bind(null, true);\n\n return chainedCheckType;\n }\n\n function createPrimitiveTypeChecker(expectedType) {\n function validate(props, propName, componentName, location, propFullName, secret) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== expectedType) {\n // `propValue` being instance of, say, date/regexp, pass the 'object'\n // check, but we can offer a more precise error message here rather than\n // 'of type `object`'.\n var preciseType = getPreciseType(propValue);\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createAnyTypeChecker() {\n return createChainableTypeChecker(emptyFunctionThatReturnsNull);\n }\n\n function createArrayOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');\n }\n var propValue = props[propName];\n if (!Array.isArray(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));\n }\n for (var i = 0; i < propValue.length; i++) {\n var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!isValidElement(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createElementTypeTypeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n if (!ReactIs.isValidElementType(propValue)) {\n var propType = getPropType(propValue);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createInstanceTypeChecker(expectedClass) {\n function validate(props, propName, componentName, location, propFullName) {\n if (!(props[propName] instanceof expectedClass)) {\n var expectedClassName = expectedClass.name || ANONYMOUS;\n var actualClassName = getClassName(props[propName]);\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createEnumTypeChecker(expectedValues) {\n if (!Array.isArray(expectedValues)) {\n if (process.env.NODE_ENV !== 'production') {\n if (arguments.length > 1) {\n printWarning(\n 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +\n 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'\n );\n } else {\n printWarning('Invalid argument supplied to oneOf, expected an array.');\n }\n }\n return emptyFunctionThatReturnsNull;\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n for (var i = 0; i < expectedValues.length; i++) {\n if (is(propValue, expectedValues[i])) {\n return null;\n }\n }\n\n var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {\n var type = getPreciseType(value);\n if (type === 'symbol') {\n return String(value);\n }\n return value;\n });\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createObjectOfTypeChecker(typeChecker) {\n function validate(props, propName, componentName, location, propFullName) {\n if (typeof typeChecker !== 'function') {\n return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');\n }\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));\n }\n for (var key in propValue) {\n if (has(propValue, key)) {\n var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error instanceof Error) {\n return error;\n }\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createUnionTypeChecker(arrayOfTypeCheckers) {\n if (!Array.isArray(arrayOfTypeCheckers)) {\n process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n return emptyFunctionThatReturnsNull;\n }\n\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (typeof checker !== 'function') {\n printWarning(\n 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +\n 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'\n );\n return emptyFunctionThatReturnsNull;\n }\n }\n\n function validate(props, propName, componentName, location, propFullName) {\n for (var i = 0; i < arrayOfTypeCheckers.length; i++) {\n var checker = arrayOfTypeCheckers[i];\n if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {\n return null;\n }\n }\n\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));\n }\n return createChainableTypeChecker(validate);\n }\n\n function createNodeChecker() {\n function validate(props, propName, componentName, location, propFullName) {\n if (!isNode(props[propName])) {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n for (var key in shapeTypes) {\n var checker = shapeTypes[key];\n if (!checker) {\n continue;\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n return createChainableTypeChecker(validate);\n }\n\n function createStrictShapeTypeChecker(shapeTypes) {\n function validate(props, propName, componentName, location, propFullName) {\n var propValue = props[propName];\n var propType = getPropType(propValue);\n if (propType !== 'object') {\n return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));\n }\n // We need to check all keys in case some are required but missing from\n // props.\n var allKeys = assign({}, props[propName], shapeTypes);\n for (var key in allKeys) {\n var checker = shapeTypes[key];\n if (!checker) {\n return new PropTypeError(\n 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +\n '\\nBad object: ' + JSON.stringify(props[propName], null, ' ') +\n '\\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')\n );\n }\n var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);\n if (error) {\n return error;\n }\n }\n return null;\n }\n\n return createChainableTypeChecker(validate);\n }\n\n function isNode(propValue) {\n switch (typeof propValue) {\n case 'number':\n case 'string':\n case 'undefined':\n return true;\n case 'boolean':\n return !propValue;\n case 'object':\n if (Array.isArray(propValue)) {\n return propValue.every(isNode);\n }\n if (propValue === null || isValidElement(propValue)) {\n return true;\n }\n\n var iteratorFn = getIteratorFn(propValue);\n if (iteratorFn) {\n var iterator = iteratorFn.call(propValue);\n var step;\n if (iteratorFn !== propValue.entries) {\n while (!(step = iterator.next()).done) {\n if (!isNode(step.value)) {\n return false;\n }\n }\n } else {\n // Iterator will provide entry [k,v] tuples rather than values.\n while (!(step = iterator.next()).done) {\n var entry = step.value;\n if (entry) {\n if (!isNode(entry[1])) {\n return false;\n }\n }\n }\n }\n } else {\n return false;\n }\n\n return true;\n default:\n return false;\n }\n }\n\n function isSymbol(propType, propValue) {\n // Native Symbol.\n if (propType === 'symbol') {\n return true;\n }\n\n // falsy value can't be a Symbol\n if (!propValue) {\n return false;\n }\n\n // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'\n if (propValue['@@toStringTag'] === 'Symbol') {\n return true;\n }\n\n // Fallback for non-spec compliant Symbols which are polyfilled.\n if (typeof Symbol === 'function' && propValue instanceof Symbol) {\n return true;\n }\n\n return false;\n }\n\n // Equivalent of `typeof` but with special handling for array and regexp.\n function getPropType(propValue) {\n var propType = typeof propValue;\n if (Array.isArray(propValue)) {\n return 'array';\n }\n if (propValue instanceof RegExp) {\n // Old webkits (at least until Android 4.0) return 'function' rather than\n // 'object' for typeof a RegExp. We'll normalize this here so that /bla/\n // passes PropTypes.object.\n return 'object';\n }\n if (isSymbol(propType, propValue)) {\n return 'symbol';\n }\n return propType;\n }\n\n // This handles more types than `getPropType`. Only used for error messages.\n // See `createPrimitiveTypeChecker`.\n function getPreciseType(propValue) {\n if (typeof propValue === 'undefined' || propValue === null) {\n return '' + propValue;\n }\n var propType = getPropType(propValue);\n if (propType === 'object') {\n if (propValue instanceof Date) {\n return 'date';\n } else if (propValue instanceof RegExp) {\n return 'regexp';\n }\n }\n return propType;\n }\n\n // Returns a string that is postfixed to a warning about an invalid type.\n // For example, \"undefined\" or \"of type array\"\n function getPostfixForTypeWarning(value) {\n var type = getPreciseType(value);\n switch (type) {\n case 'array':\n case 'object':\n return 'an ' + type;\n case 'boolean':\n case 'date':\n case 'regexp':\n return 'a ' + type;\n default:\n return type;\n }\n }\n\n // Returns class name of the object, if any.\n function getClassName(propValue) {\n if (!propValue.constructor || !propValue.constructor.name) {\n return ANONYMOUS;\n }\n return propValue.constructor.name;\n }\n\n ReactPropTypes.checkPropTypes = checkPropTypes;\n ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\nfunction emptyFunctionWithReset() {}\nemptyFunctionWithReset.resetWarningCache = emptyFunction;\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n elementType: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim,\n\n checkPropTypes: emptyFunctionWithReset,\n resetWarningCache: emptyFunction\n };\n\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactIs = require('react-is');\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n","var VNode = function VNode() {};\n\nvar options = {};\n\nvar stack = [];\n\nvar EMPTY_CHILDREN = [];\n\nfunction h(nodeName, attributes) {\n\tvar children = EMPTY_CHILDREN,\n\t lastSimple,\n\t child,\n\t simple,\n\t i;\n\tfor (i = arguments.length; i-- > 2;) {\n\t\tstack.push(arguments[i]);\n\t}\n\tif (attributes && attributes.children != null) {\n\t\tif (!stack.length) stack.push(attributes.children);\n\t\tdelete attributes.children;\n\t}\n\twhile (stack.length) {\n\t\tif ((child = stack.pop()) && child.pop !== undefined) {\n\t\t\tfor (i = child.length; i--;) {\n\t\t\t\tstack.push(child[i]);\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof child === 'boolean') child = null;\n\n\t\t\tif (simple = typeof nodeName !== 'function') {\n\t\t\t\tif (child == null) child = '';else if (typeof child === 'number') child = String(child);else if (typeof child !== 'string') simple = false;\n\t\t\t}\n\n\t\t\tif (simple && lastSimple) {\n\t\t\t\tchildren[children.length - 1] += child;\n\t\t\t} else if (children === EMPTY_CHILDREN) {\n\t\t\t\tchildren = [child];\n\t\t\t} else {\n\t\t\t\tchildren.push(child);\n\t\t\t}\n\n\t\t\tlastSimple = simple;\n\t\t}\n\t}\n\n\tvar p = new VNode();\n\tp.nodeName = nodeName;\n\tp.children = children;\n\tp.attributes = attributes == null ? undefined : attributes;\n\tp.key = attributes == null ? undefined : attributes.key;\n\n\tif (options.vnode !== undefined) options.vnode(p);\n\n\treturn p;\n}\n\nfunction extend(obj, props) {\n for (var i in props) {\n obj[i] = props[i];\n }return obj;\n}\n\nfunction applyRef(ref, value) {\n if (ref != null) {\n if (typeof ref == 'function') ref(value);else ref.current = value;\n }\n}\n\nvar defer = typeof Promise == 'function' ? Promise.resolve().then.bind(Promise.resolve()) : setTimeout;\n\nfunction cloneElement(vnode, props) {\n return h(vnode.nodeName, extend(extend({}, vnode.attributes), props), arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children);\n}\n\nvar IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;\n\nvar items = [];\n\nfunction enqueueRender(component) {\n\tif (!component._dirty && (component._dirty = true) && items.push(component) == 1) {\n\t\t(options.debounceRendering || defer)(rerender);\n\t}\n}\n\nfunction rerender() {\n\tvar p;\n\twhile (p = items.pop()) {\n\t\tif (p._dirty) renderComponent(p);\n\t}\n}\n\nfunction isSameNodeType(node, vnode, hydrating) {\n\tif (typeof vnode === 'string' || typeof vnode === 'number') {\n\t\treturn node.splitText !== undefined;\n\t}\n\tif (typeof vnode.nodeName === 'string') {\n\t\treturn !node._componentConstructor && isNamedNode(node, vnode.nodeName);\n\t}\n\treturn hydrating || node._componentConstructor === vnode.nodeName;\n}\n\nfunction isNamedNode(node, nodeName) {\n\treturn node.normalizedNodeName === nodeName || node.nodeName.toLowerCase() === nodeName.toLowerCase();\n}\n\nfunction getNodeProps(vnode) {\n\tvar props = extend({}, vnode.attributes);\n\tprops.children = vnode.children;\n\n\tvar defaultProps = vnode.nodeName.defaultProps;\n\tif (defaultProps !== undefined) {\n\t\tfor (var i in defaultProps) {\n\t\t\tif (props[i] === undefined) {\n\t\t\t\tprops[i] = defaultProps[i];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn props;\n}\n\nfunction createNode(nodeName, isSvg) {\n\tvar node = isSvg ? document.createElementNS('http://www.w3.org/2000/svg', nodeName) : document.createElement(nodeName);\n\tnode.normalizedNodeName = nodeName;\n\treturn node;\n}\n\nfunction removeNode(node) {\n\tvar parentNode = node.parentNode;\n\tif (parentNode) parentNode.removeChild(node);\n}\n\nfunction setAccessor(node, name, old, value, isSvg) {\n\tif (name === 'className') name = 'class';\n\n\tif (name === 'key') {} else if (name === 'ref') {\n\t\tapplyRef(old, null);\n\t\tapplyRef(value, node);\n\t} else if (name === 'class' && !isSvg) {\n\t\tnode.className = value || '';\n\t} else if (name === 'style') {\n\t\tif (!value || typeof value === 'string' || typeof old === 'string') {\n\t\t\tnode.style.cssText = value || '';\n\t\t}\n\t\tif (value && typeof value === 'object') {\n\t\t\tif (typeof old !== 'string') {\n\t\t\t\tfor (var i in old) {\n\t\t\t\t\tif (!(i in value)) node.style[i] = '';\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var i in value) {\n\t\t\t\tnode.style[i] = typeof value[i] === 'number' && IS_NON_DIMENSIONAL.test(i) === false ? value[i] + 'px' : value[i];\n\t\t\t}\n\t\t}\n\t} else if (name === 'dangerouslySetInnerHTML') {\n\t\tif (value) node.innerHTML = value.__html || '';\n\t} else if (name[0] == 'o' && name[1] == 'n') {\n\t\tvar useCapture = name !== (name = name.replace(/Capture$/, ''));\n\t\tname = name.toLowerCase().substring(2);\n\t\tif (value) {\n\t\t\tif (!old) node.addEventListener(name, eventProxy, useCapture);\n\t\t} else {\n\t\t\tnode.removeEventListener(name, eventProxy, useCapture);\n\t\t}\n\t\t(node._listeners || (node._listeners = {}))[name] = value;\n\t} else if (name !== 'list' && name !== 'type' && !isSvg && name in node) {\n\t\ttry {\n\t\t\tnode[name] = value == null ? '' : value;\n\t\t} catch (e) {}\n\t\tif ((value == null || value === false) && name != 'spellcheck') node.removeAttribute(name);\n\t} else {\n\t\tvar ns = isSvg && name !== (name = name.replace(/^xlink:?/, ''));\n\n\t\tif (value == null || value === false) {\n\t\t\tif (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());else node.removeAttribute(name);\n\t\t} else if (typeof value !== 'function') {\n\t\t\tif (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase(), value);else node.setAttribute(name, value);\n\t\t}\n\t}\n}\n\nfunction eventProxy(e) {\n\treturn this._listeners[e.type](options.event && options.event(e) || e);\n}\n\nvar mounts = [];\n\nvar diffLevel = 0;\n\nvar isSvgMode = false;\n\nvar hydrating = false;\n\nfunction flushMounts() {\n\tvar c;\n\twhile (c = mounts.shift()) {\n\t\tif (options.afterMount) options.afterMount(c);\n\t\tif (c.componentDidMount) c.componentDidMount();\n\t}\n}\n\nfunction diff(dom, vnode, context, mountAll, parent, componentRoot) {\n\tif (!diffLevel++) {\n\t\tisSvgMode = parent != null && parent.ownerSVGElement !== undefined;\n\n\t\thydrating = dom != null && !('__preactattr_' in dom);\n\t}\n\n\tvar ret = idiff(dom, vnode, context, mountAll, componentRoot);\n\n\tif (parent && ret.parentNode !== parent) parent.appendChild(ret);\n\n\tif (! --diffLevel) {\n\t\thydrating = false;\n\n\t\tif (!componentRoot) flushMounts();\n\t}\n\n\treturn ret;\n}\n\nfunction idiff(dom, vnode, context, mountAll, componentRoot) {\n\tvar out = dom,\n\t prevSvgMode = isSvgMode;\n\n\tif (vnode == null || typeof vnode === 'boolean') vnode = '';\n\n\tif (typeof vnode === 'string' || typeof vnode === 'number') {\n\t\tif (dom && dom.splitText !== undefined && dom.parentNode && (!dom._component || componentRoot)) {\n\t\t\tif (dom.nodeValue != vnode) {\n\t\t\t\tdom.nodeValue = vnode;\n\t\t\t}\n\t\t} else {\n\t\t\tout = document.createTextNode(vnode);\n\t\t\tif (dom) {\n\t\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\n\t\t\t\trecollectNodeTree(dom, true);\n\t\t\t}\n\t\t}\n\n\t\tout['__preactattr_'] = true;\n\n\t\treturn out;\n\t}\n\n\tvar vnodeName = vnode.nodeName;\n\tif (typeof vnodeName === 'function') {\n\t\treturn buildComponentFromVNode(dom, vnode, context, mountAll);\n\t}\n\n\tisSvgMode = vnodeName === 'svg' ? true : vnodeName === 'foreignObject' ? false : isSvgMode;\n\n\tvnodeName = String(vnodeName);\n\tif (!dom || !isNamedNode(dom, vnodeName)) {\n\t\tout = createNode(vnodeName, isSvgMode);\n\n\t\tif (dom) {\n\t\t\twhile (dom.firstChild) {\n\t\t\t\tout.appendChild(dom.firstChild);\n\t\t\t}\n\t\t\tif (dom.parentNode) dom.parentNode.replaceChild(out, dom);\n\n\t\t\trecollectNodeTree(dom, true);\n\t\t}\n\t}\n\n\tvar fc = out.firstChild,\n\t props = out['__preactattr_'],\n\t vchildren = vnode.children;\n\n\tif (props == null) {\n\t\tprops = out['__preactattr_'] = {};\n\t\tfor (var a = out.attributes, i = a.length; i--;) {\n\t\t\tprops[a[i].name] = a[i].value;\n\t\t}\n\t}\n\n\tif (!hydrating && vchildren && vchildren.length === 1 && typeof vchildren[0] === 'string' && fc != null && fc.splitText !== undefined && fc.nextSibling == null) {\n\t\tif (fc.nodeValue != vchildren[0]) {\n\t\t\tfc.nodeValue = vchildren[0];\n\t\t}\n\t} else if (vchildren && vchildren.length || fc != null) {\n\t\t\tinnerDiffNode(out, vchildren, context, mountAll, hydrating || props.dangerouslySetInnerHTML != null);\n\t\t}\n\n\tdiffAttributes(out, vnode.attributes, props);\n\n\tisSvgMode = prevSvgMode;\n\n\treturn out;\n}\n\nfunction innerDiffNode(dom, vchildren, context, mountAll, isHydrating) {\n\tvar originalChildren = dom.childNodes,\n\t children = [],\n\t keyed = {},\n\t keyedLen = 0,\n\t min = 0,\n\t len = originalChildren.length,\n\t childrenLen = 0,\n\t vlen = vchildren ? vchildren.length : 0,\n\t j,\n\t c,\n\t f,\n\t vchild,\n\t child;\n\n\tif (len !== 0) {\n\t\tfor (var i = 0; i < len; i++) {\n\t\t\tvar _child = originalChildren[i],\n\t\t\t props = _child['__preactattr_'],\n\t\t\t key = vlen && props ? _child._component ? _child._component.__key : props.key : null;\n\t\t\tif (key != null) {\n\t\t\t\tkeyedLen++;\n\t\t\t\tkeyed[key] = _child;\n\t\t\t} else if (props || (_child.splitText !== undefined ? isHydrating ? _child.nodeValue.trim() : true : isHydrating)) {\n\t\t\t\tchildren[childrenLen++] = _child;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (vlen !== 0) {\n\t\tfor (var i = 0; i < vlen; i++) {\n\t\t\tvchild = vchildren[i];\n\t\t\tchild = null;\n\n\t\t\tvar key = vchild.key;\n\t\t\tif (key != null) {\n\t\t\t\tif (keyedLen && keyed[key] !== undefined) {\n\t\t\t\t\tchild = keyed[key];\n\t\t\t\t\tkeyed[key] = undefined;\n\t\t\t\t\tkeyedLen--;\n\t\t\t\t}\n\t\t\t} else if (min < childrenLen) {\n\t\t\t\t\tfor (j = min; j < childrenLen; j++) {\n\t\t\t\t\t\tif (children[j] !== undefined && isSameNodeType(c = children[j], vchild, isHydrating)) {\n\t\t\t\t\t\t\tchild = c;\n\t\t\t\t\t\t\tchildren[j] = undefined;\n\t\t\t\t\t\t\tif (j === childrenLen - 1) childrenLen--;\n\t\t\t\t\t\t\tif (j === min) min++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tchild = idiff(child, vchild, context, mountAll);\n\n\t\t\tf = originalChildren[i];\n\t\t\tif (child && child !== dom && child !== f) {\n\t\t\t\tif (f == null) {\n\t\t\t\t\tdom.appendChild(child);\n\t\t\t\t} else if (child === f.nextSibling) {\n\t\t\t\t\tremoveNode(f);\n\t\t\t\t} else {\n\t\t\t\t\tdom.insertBefore(child, f);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (keyedLen) {\n\t\tfor (var i in keyed) {\n\t\t\tif (keyed[i] !== undefined) recollectNodeTree(keyed[i], false);\n\t\t}\n\t}\n\n\twhile (min <= childrenLen) {\n\t\tif ((child = children[childrenLen--]) !== undefined) recollectNodeTree(child, false);\n\t}\n}\n\nfunction recollectNodeTree(node, unmountOnly) {\n\tvar component = node._component;\n\tif (component) {\n\t\tunmountComponent(component);\n\t} else {\n\t\tif (node['__preactattr_'] != null) applyRef(node['__preactattr_'].ref, null);\n\n\t\tif (unmountOnly === false || node['__preactattr_'] == null) {\n\t\t\tremoveNode(node);\n\t\t}\n\n\t\tremoveChildren(node);\n\t}\n}\n\nfunction removeChildren(node) {\n\tnode = node.lastChild;\n\twhile (node) {\n\t\tvar next = node.previousSibling;\n\t\trecollectNodeTree(node, true);\n\t\tnode = next;\n\t}\n}\n\nfunction diffAttributes(dom, attrs, old) {\n\tvar name;\n\n\tfor (name in old) {\n\t\tif (!(attrs && attrs[name] != null) && old[name] != null) {\n\t\t\tsetAccessor(dom, name, old[name], old[name] = undefined, isSvgMode);\n\t\t}\n\t}\n\n\tfor (name in attrs) {\n\t\tif (name !== 'children' && name !== 'innerHTML' && (!(name in old) || attrs[name] !== (name === 'value' || name === 'checked' ? dom[name] : old[name]))) {\n\t\t\tsetAccessor(dom, name, old[name], old[name] = attrs[name], isSvgMode);\n\t\t}\n\t}\n}\n\nvar recyclerComponents = [];\n\nfunction createComponent(Ctor, props, context) {\n\tvar inst,\n\t i = recyclerComponents.length;\n\n\tif (Ctor.prototype && Ctor.prototype.render) {\n\t\tinst = new Ctor(props, context);\n\t\tComponent.call(inst, props, context);\n\t} else {\n\t\tinst = new Component(props, context);\n\t\tinst.constructor = Ctor;\n\t\tinst.render = doRender;\n\t}\n\n\twhile (i--) {\n\t\tif (recyclerComponents[i].constructor === Ctor) {\n\t\t\tinst.nextBase = recyclerComponents[i].nextBase;\n\t\t\trecyclerComponents.splice(i, 1);\n\t\t\treturn inst;\n\t\t}\n\t}\n\n\treturn inst;\n}\n\nfunction doRender(props, state, context) {\n\treturn this.constructor(props, context);\n}\n\nfunction setComponentProps(component, props, renderMode, context, mountAll) {\n\tif (component._disable) return;\n\tcomponent._disable = true;\n\n\tcomponent.__ref = props.ref;\n\tcomponent.__key = props.key;\n\tdelete props.ref;\n\tdelete props.key;\n\n\tif (typeof component.constructor.getDerivedStateFromProps === 'undefined') {\n\t\tif (!component.base || mountAll) {\n\t\t\tif (component.componentWillMount) component.componentWillMount();\n\t\t} else if (component.componentWillReceiveProps) {\n\t\t\tcomponent.componentWillReceiveProps(props, context);\n\t\t}\n\t}\n\n\tif (context && context !== component.context) {\n\t\tif (!component.prevContext) component.prevContext = component.context;\n\t\tcomponent.context = context;\n\t}\n\n\tif (!component.prevProps) component.prevProps = component.props;\n\tcomponent.props = props;\n\n\tcomponent._disable = false;\n\n\tif (renderMode !== 0) {\n\t\tif (renderMode === 1 || options.syncComponentUpdates !== false || !component.base) {\n\t\t\trenderComponent(component, 1, mountAll);\n\t\t} else {\n\t\t\tenqueueRender(component);\n\t\t}\n\t}\n\n\tapplyRef(component.__ref, component);\n}\n\nfunction renderComponent(component, renderMode, mountAll, isChild) {\n\tif (component._disable) return;\n\n\tvar props = component.props,\n\t state = component.state,\n\t context = component.context,\n\t previousProps = component.prevProps || props,\n\t previousState = component.prevState || state,\n\t previousContext = component.prevContext || context,\n\t isUpdate = component.base,\n\t nextBase = component.nextBase,\n\t initialBase = isUpdate || nextBase,\n\t initialChildComponent = component._component,\n\t skip = false,\n\t snapshot = previousContext,\n\t rendered,\n\t inst,\n\t cbase;\n\n\tif (component.constructor.getDerivedStateFromProps) {\n\t\tstate = extend(extend({}, state), component.constructor.getDerivedStateFromProps(props, state));\n\t\tcomponent.state = state;\n\t}\n\n\tif (isUpdate) {\n\t\tcomponent.props = previousProps;\n\t\tcomponent.state = previousState;\n\t\tcomponent.context = previousContext;\n\t\tif (renderMode !== 2 && component.shouldComponentUpdate && component.shouldComponentUpdate(props, state, context) === false) {\n\t\t\tskip = true;\n\t\t} else if (component.componentWillUpdate) {\n\t\t\tcomponent.componentWillUpdate(props, state, context);\n\t\t}\n\t\tcomponent.props = props;\n\t\tcomponent.state = state;\n\t\tcomponent.context = context;\n\t}\n\n\tcomponent.prevProps = component.prevState = component.prevContext = component.nextBase = null;\n\tcomponent._dirty = false;\n\n\tif (!skip) {\n\t\trendered = component.render(props, state, context);\n\n\t\tif (component.getChildContext) {\n\t\t\tcontext = extend(extend({}, context), component.getChildContext());\n\t\t}\n\n\t\tif (isUpdate && component.getSnapshotBeforeUpdate) {\n\t\t\tsnapshot = component.getSnapshotBeforeUpdate(previousProps, previousState);\n\t\t}\n\n\t\tvar childComponent = rendered && rendered.nodeName,\n\t\t toUnmount,\n\t\t base;\n\n\t\tif (typeof childComponent === 'function') {\n\n\t\t\tvar childProps = getNodeProps(rendered);\n\t\t\tinst = initialChildComponent;\n\n\t\t\tif (inst && inst.constructor === childComponent && childProps.key == inst.__key) {\n\t\t\t\tsetComponentProps(inst, childProps, 1, context, false);\n\t\t\t} else {\n\t\t\t\ttoUnmount = inst;\n\n\t\t\t\tcomponent._component = inst = createComponent(childComponent, childProps, context);\n\t\t\t\tinst.nextBase = inst.nextBase || nextBase;\n\t\t\t\tinst._parentComponent = component;\n\t\t\t\tsetComponentProps(inst, childProps, 0, context, false);\n\t\t\t\trenderComponent(inst, 1, mountAll, true);\n\t\t\t}\n\n\t\t\tbase = inst.base;\n\t\t} else {\n\t\t\tcbase = initialBase;\n\n\t\t\ttoUnmount = initialChildComponent;\n\t\t\tif (toUnmount) {\n\t\t\t\tcbase = component._component = null;\n\t\t\t}\n\n\t\t\tif (initialBase || renderMode === 1) {\n\t\t\t\tif (cbase) cbase._component = null;\n\t\t\t\tbase = diff(cbase, rendered, context, mountAll || !isUpdate, initialBase && initialBase.parentNode, true);\n\t\t\t}\n\t\t}\n\n\t\tif (initialBase && base !== initialBase && inst !== initialChildComponent) {\n\t\t\tvar baseParent = initialBase.parentNode;\n\t\t\tif (baseParent && base !== baseParent) {\n\t\t\t\tbaseParent.replaceChild(base, initialBase);\n\n\t\t\t\tif (!toUnmount) {\n\t\t\t\t\tinitialBase._component = null;\n\t\t\t\t\trecollectNodeTree(initialBase, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (toUnmount) {\n\t\t\tunmountComponent(toUnmount);\n\t\t}\n\n\t\tcomponent.base = base;\n\t\tif (base && !isChild) {\n\t\t\tvar componentRef = component,\n\t\t\t t = component;\n\t\t\twhile (t = t._parentComponent) {\n\t\t\t\t(componentRef = t).base = base;\n\t\t\t}\n\t\t\tbase._component = componentRef;\n\t\t\tbase._componentConstructor = componentRef.constructor;\n\t\t}\n\t}\n\n\tif (!isUpdate || mountAll) {\n\t\tmounts.push(component);\n\t} else if (!skip) {\n\n\t\tif (component.componentDidUpdate) {\n\t\t\tcomponent.componentDidUpdate(previousProps, previousState, snapshot);\n\t\t}\n\t\tif (options.afterUpdate) options.afterUpdate(component);\n\t}\n\n\twhile (component._renderCallbacks.length) {\n\t\tcomponent._renderCallbacks.pop().call(component);\n\t}if (!diffLevel && !isChild) flushMounts();\n}\n\nfunction buildComponentFromVNode(dom, vnode, context, mountAll) {\n\tvar c = dom && dom._component,\n\t originalComponent = c,\n\t oldDom = dom,\n\t isDirectOwner = c && dom._componentConstructor === vnode.nodeName,\n\t isOwner = isDirectOwner,\n\t props = getNodeProps(vnode);\n\twhile (c && !isOwner && (c = c._parentComponent)) {\n\t\tisOwner = c.constructor === vnode.nodeName;\n\t}\n\n\tif (c && isOwner && (!mountAll || c._component)) {\n\t\tsetComponentProps(c, props, 3, context, mountAll);\n\t\tdom = c.base;\n\t} else {\n\t\tif (originalComponent && !isDirectOwner) {\n\t\t\tunmountComponent(originalComponent);\n\t\t\tdom = oldDom = null;\n\t\t}\n\n\t\tc = createComponent(vnode.nodeName, props, context);\n\t\tif (dom && !c.nextBase) {\n\t\t\tc.nextBase = dom;\n\n\t\t\toldDom = null;\n\t\t}\n\t\tsetComponentProps(c, props, 1, context, mountAll);\n\t\tdom = c.base;\n\n\t\tif (oldDom && dom !== oldDom) {\n\t\t\toldDom._component = null;\n\t\t\trecollectNodeTree(oldDom, false);\n\t\t}\n\t}\n\n\treturn dom;\n}\n\nfunction unmountComponent(component) {\n\tif (options.beforeUnmount) options.beforeUnmount(component);\n\n\tvar base = component.base;\n\n\tcomponent._disable = true;\n\n\tif (component.componentWillUnmount) component.componentWillUnmount();\n\n\tcomponent.base = null;\n\n\tvar inner = component._component;\n\tif (inner) {\n\t\tunmountComponent(inner);\n\t} else if (base) {\n\t\tif (base['__preactattr_'] != null) applyRef(base['__preactattr_'].ref, null);\n\n\t\tcomponent.nextBase = base;\n\n\t\tremoveNode(base);\n\t\trecyclerComponents.push(component);\n\n\t\tremoveChildren(base);\n\t}\n\n\tapplyRef(component.__ref, null);\n}\n\nfunction Component(props, context) {\n\tthis._dirty = true;\n\n\tthis.context = context;\n\n\tthis.props = props;\n\n\tthis.state = this.state || {};\n\n\tthis._renderCallbacks = [];\n}\n\nextend(Component.prototype, {\n\tsetState: function setState(state, callback) {\n\t\tif (!this.prevState) this.prevState = this.state;\n\t\tthis.state = extend(extend({}, this.state), typeof state === 'function' ? state(this.state, this.props) : state);\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\tenqueueRender(this);\n\t},\n\tforceUpdate: function forceUpdate(callback) {\n\t\tif (callback) this._renderCallbacks.push(callback);\n\t\trenderComponent(this, 2);\n\t},\n\trender: function render() {}\n});\n\nfunction render(vnode, parent, merge) {\n return diff(merge, vnode, {}, false, parent, false);\n}\n\nfunction createRef() {\n\treturn {};\n}\n\nvar preact = {\n\th: h,\n\tcreateElement: h,\n\tcloneElement: cloneElement,\n\tcreateRef: createRef,\n\tComponent: Component,\n\trender: render,\n\trerender: rerender,\n\toptions: options\n};\n\nexport default preact;\nexport { h, h as createElement, cloneElement, createRef, Component, render, rerender, options };\n//# sourceMappingURL=preact.mjs.map\n","import PropTypes from 'prop-types';\nexport { default as PropTypes } from 'prop-types';\nimport { render, cloneElement, createRef, h, Component, options } from 'preact';\nexport { createRef } from 'preact';\n\nvar version = '15.1.0'; // trick libraries to think we are react\n\nvar ELEMENTS = 'a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr circle clipPath defs ellipse g image line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan'.split(' ');\n\nvar REACT_ELEMENT_TYPE = (typeof Symbol!=='undefined' && Symbol.for && Symbol.for('react.element')) || 0xeac7;\n\nvar COMPONENT_WRAPPER_KEY = (typeof Symbol!=='undefined' && Symbol.for) ? Symbol.for('__preactCompatWrapper') : '__preactCompatWrapper';\n\n// don't autobind these methods since they already have guaranteed context.\nvar AUTOBIND_BLACKLIST = {\n\tconstructor: 1,\n\trender: 1,\n\tshouldComponentUpdate: 1,\n\tcomponentWillReceiveProps: 1,\n\tcomponentWillUpdate: 1,\n\tcomponentDidUpdate: 1,\n\tcomponentWillMount: 1,\n\tcomponentDidMount: 1,\n\tcomponentWillUnmount: 1,\n\tcomponentDidUnmount: 1\n};\n\n\nvar CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip|color|fill|flood|font|glyph|horiz|marker|overline|paint|stop|strikethrough|stroke|text|underline|unicode|units|v|vector|vert|word|writing|x)[A-Z]/;\n\n\nvar BYPASS_HOOK = {};\n\n/*global process*/\nvar DEV = false;\ntry {\n\tDEV = process.env.NODE_ENV!=='production';\n}\ncatch (e) {}\n\n// a component that renders nothing. Used to replace components for unmountComponentAtNode.\nfunction EmptyComponent() { return null; }\n\n\n\n// make react think we're react.\nvar VNode = h('a', null).constructor;\nVNode.prototype.$$typeof = REACT_ELEMENT_TYPE;\nVNode.prototype.preactCompatUpgraded = false;\nVNode.prototype.preactCompatNormalized = false;\n\nObject.defineProperty(VNode.prototype, 'type', {\n\tget: function() { return this.nodeName; },\n\tset: function(v) { this.nodeName = v; },\n\tconfigurable:true\n});\n\nObject.defineProperty(VNode.prototype, 'props', {\n\tget: function() { return this.attributes; },\n\tset: function(v) { this.attributes = v; },\n\tconfigurable:true\n});\n\n\n\nvar oldEventHook = options.event;\noptions.event = function (e) {\n\tif (oldEventHook) { e = oldEventHook(e); }\n\te.persist = Object;\n\te.nativeEvent = e;\n\treturn e;\n};\n\n\nvar oldVnodeHook = options.vnode;\noptions.vnode = function (vnode) {\n\tif (!vnode.preactCompatUpgraded) {\n\t\tvnode.preactCompatUpgraded = true;\n\n\t\tvar tag = vnode.nodeName,\n\t\t\tattrs = vnode.attributes = vnode.attributes==null ? {} : extend({}, vnode.attributes);\n\n\t\tif (typeof tag==='function') {\n\t\t\tif (tag[COMPONENT_WRAPPER_KEY]===true || (tag.prototype && 'isReactComponent' in tag.prototype)) {\n\t\t\t\tif (vnode.children && String(vnode.children)==='') { vnode.children = undefined; }\n\t\t\t\tif (vnode.children) { attrs.children = vnode.children; }\n\n\t\t\t\tif (!vnode.preactCompatNormalized) {\n\t\t\t\t\tnormalizeVNode(vnode);\n\t\t\t\t}\n\t\t\t\thandleComponentVNode(vnode);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (vnode.children && String(vnode.children)==='') { vnode.children = undefined; }\n\t\t\tif (vnode.children) { attrs.children = vnode.children; }\n\n\t\t\tif (attrs.defaultValue) {\n\t\t\t\tif (!attrs.value && attrs.value!==0) {\n\t\t\t\t\tattrs.value = attrs.defaultValue;\n\t\t\t\t}\n\t\t\t\tdelete attrs.defaultValue;\n\t\t\t}\n\n\t\t\thandleElementVNode(vnode, attrs);\n\t\t}\n\t}\n\n\tif (oldVnodeHook) { oldVnodeHook(vnode); }\n};\n\nfunction handleComponentVNode(vnode) {\n\tvar tag = vnode.nodeName,\n\t\ta = vnode.attributes;\n\n\tvnode.attributes = {};\n\tif (tag.defaultProps) { extend(vnode.attributes, tag.defaultProps); }\n\tif (a) { extend(vnode.attributes, a); }\n}\n\nfunction handleElementVNode(vnode, a) {\n\tvar shouldSanitize, attrs, i;\n\tif (a) {\n\t\tfor (i in a) { if ((shouldSanitize = CAMEL_PROPS.test(i))) { break; } }\n\t\tif (shouldSanitize) {\n\t\t\tattrs = vnode.attributes = {};\n\t\t\tfor (i in a) {\n\t\t\t\tif (a.hasOwnProperty(i)) {\n\t\t\t\t\tattrs[ CAMEL_PROPS.test(i) ? i.replace(/([A-Z0-9])/, '-$1').toLowerCase() : i ] = a[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\n// proxy render() since React returns a Component reference.\nfunction render$1(vnode, parent, callback) {\n\tvar prev = parent && parent._preactCompatRendered && parent._preactCompatRendered.base;\n\n\t// ignore impossible previous renders\n\tif (prev && prev.parentNode!==parent) { prev = null; }\n\n\t// default to first Element child\n\tif (!prev && parent) { prev = parent.firstElementChild; }\n\n\t// remove unaffected siblings\n\tfor (var i=parent.childNodes.length; i--; ) {\n\t\tif (parent.childNodes[i]!==prev) {\n\t\t\tparent.removeChild(parent.childNodes[i]);\n\t\t}\n\t}\n\n\tvar out = render(vnode, parent, prev);\n\tif (parent) { parent._preactCompatRendered = out && (out._component || { base: out }); }\n\tif (typeof callback==='function') { callback(); }\n\treturn out && out._component || out;\n}\n\n\nvar ContextProvider = function () {};\n\nContextProvider.prototype.getChildContext = function () {\n\treturn this.props.context;\n};\nContextProvider.prototype.render = function (props) {\n\treturn props.children[0];\n};\n\nfunction renderSubtreeIntoContainer(parentComponent, vnode, container, callback) {\n\tvar wrap = h(ContextProvider, { context: parentComponent.context }, vnode);\n\tvar renderContainer = render$1(wrap, container);\n\tvar component = renderContainer._component || renderContainer.base;\n\tif (callback) { callback.call(component, renderContainer); }\n\treturn component;\n}\n\nfunction Portal(props) {\n\trenderSubtreeIntoContainer(this, props.vnode, props.container);\n}\n\nfunction createPortal(vnode, container) {\n\treturn h(Portal, { vnode: vnode, container: container });\n}\n\n\nfunction unmountComponentAtNode(container) {\n\tvar existing = container._preactCompatRendered && container._preactCompatRendered.base;\n\tif (existing && existing.parentNode===container) {\n\t\trender(h(EmptyComponent), container, existing);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n\n\nvar ARR = [];\n\n// This API is completely unnecessary for Preact, so it's basically passthrough.\nvar Children = {\n\tmap: function(children, fn, ctx) {\n\t\tif (children == null) { return null; }\n\t\tchildren = Children.toArray(children);\n\t\tif (ctx && ctx!==children) { fn = fn.bind(ctx); }\n\t\treturn children.map(fn);\n\t},\n\tforEach: function(children, fn, ctx) {\n\t\tif (children == null) { return null; }\n\t\tchildren = Children.toArray(children);\n\t\tif (ctx && ctx!==children) { fn = fn.bind(ctx); }\n\t\tchildren.forEach(fn);\n\t},\n\tcount: function(children) {\n\t\treturn children && children.length || 0;\n\t},\n\tonly: function(children) {\n\t\tchildren = Children.toArray(children);\n\t\tif (children.length!==1) { throw new Error('Children.only() expects only one child.'); }\n\t\treturn children[0];\n\t},\n\ttoArray: function(children) {\n\t\tif (children == null) { return []; }\n\t\treturn ARR.concat(children);\n\t}\n};\n\n\n/** Track current render() component for ref assignment */\nvar currentComponent;\n\n\nfunction createFactory(type) {\n\treturn createElement.bind(null, type);\n}\n\n\nvar DOM = {};\nfor (var i=ELEMENTS.length; i--; ) {\n\tDOM[ELEMENTS[i]] = createFactory(ELEMENTS[i]);\n}\n\nfunction upgradeToVNodes(arr, offset) {\n\tfor (var i=offset || 0; i 0 ) children[ len ] = arguments[ len + 2 ];\n\n\tif (!isValidElement(element)) { return element; }\n\tvar elementProps = element.attributes || element.props;\n\tvar node = h(\n\t\telement.nodeName || element.type,\n\t\textend({}, elementProps),\n\t\telement.children || elementProps && elementProps.children\n\t);\n\t// Only provide the 3rd argument if needed.\n\t// Arguments 3+ overwrite element.children in preactCloneElement\n\tvar cloneArgs = [node, props];\n\tif (children && children.length) {\n\t\tcloneArgs.push(children);\n\t}\n\telse if (props && props.children) {\n\t\tcloneArgs.push(props.children);\n\t}\n\treturn normalizeVNode(cloneElement.apply(void 0, cloneArgs));\n}\n\n\nfunction isValidElement(element) {\n\treturn element && ((element instanceof VNode) || element.$$typeof===REACT_ELEMENT_TYPE);\n}\n\n\nfunction createStringRefProxy(name, component) {\n\treturn component._refProxies[name] || (component._refProxies[name] = function (resolved) {\n\t\tif (component && component.refs) {\n\t\t\tcomponent.refs[name] = resolved;\n\t\t\tif (resolved===null) {\n\t\t\t\tdelete component._refProxies[name];\n\t\t\t\tcomponent = null;\n\t\t\t}\n\t\t}\n\t});\n}\n\n\nfunction applyEventNormalization(ref) {\n\tvar nodeName = ref.nodeName;\n\tvar attributes = ref.attributes;\n\n\tif (!attributes || typeof nodeName!=='string') { return; }\n\tvar props = {};\n\tfor (var i in attributes) {\n\t\tprops[i.toLowerCase()] = i;\n\t}\n\tif (props.ondoubleclick) {\n\t\tattributes.ondblclick = attributes[props.ondoubleclick];\n\t\tdelete attributes[props.ondoubleclick];\n\t}\n\t// for *textual inputs* (incl textarea), normalize `onChange` -> `onInput`:\n\tif (props.onchange && (nodeName==='textarea' || (nodeName.toLowerCase()==='input' && !/^fil|che|rad/i.test(attributes.type)))) {\n\t\tvar normalized = props.oninput || 'oninput';\n\t\tif (!attributes[normalized]) {\n\t\t\tattributes[normalized] = multihook([attributes[normalized], attributes[props.onchange]]);\n\t\t\tdelete attributes[props.onchange];\n\t\t}\n\t}\n}\n\n\nfunction applyClassName(vnode) {\n\tvar a = vnode.attributes || (vnode.attributes = {});\n\tclassNameDescriptor.enumerable = 'className' in a;\n\tif (a.className) { a.class = a.className; }\n\tObject.defineProperty(a, 'className', classNameDescriptor);\n}\n\n\nvar classNameDescriptor = {\n\tconfigurable: true,\n\tget: function() { return this.class; },\n\tset: function(v) { this.class = v; }\n};\n\nfunction extend(base, props) {\n\tvar arguments$1 = arguments;\n\n\tfor (var i=1, obj = (void 0); i) => {\n function WithInsightsListener(\n props: WithInsightsListenerProps\n ): React.ReactNode {\n const handleClick = (event: React.MouseEvent): void => {\n if (!hasDataAttributes(event.target)) {\n return;\n }\n if (!props.insights) {\n throw new Error(\n 'The `insightsClient` option has not been provided to `instantsearch`.'\n );\n }\n const { method, payload } = readDataAttributes(event.target);\n props.insights(method, payload);\n };\n\n return (\n
    \n \n
    \n );\n }\n\n return WithInsightsListener;\n};\n","import { InsightsClientMethod, InsightsClientPayload } from '../types';\n\nexport function readDataAttributes(\n domElement: HTMLElement\n): {\n method: InsightsClientMethod;\n payload: Partial;\n} {\n const method = domElement.getAttribute(\n 'data-insights-method'\n ) as InsightsClientMethod;\n\n const serializedPayload = domElement.getAttribute('data-insights-payload');\n\n if (typeof serializedPayload !== 'string') {\n throw new Error(\n 'The insights helper expects `data-insights-payload` to be a base64-encoded JSON string.'\n );\n }\n\n try {\n const payload: Partial = JSON.parse(\n atob(serializedPayload)\n );\n return { method, payload };\n } catch (error) {\n throw new Error(\n 'The insights helper was unable to parse `data-insights-payload`.'\n );\n }\n}\n\nexport function hasDataAttributes(domElement: HTMLElement): boolean {\n return domElement.hasAttribute('data-insights-method');\n}\n\nexport function writeDataAttributes({\n method,\n payload,\n}: {\n method: InsightsClientMethod;\n payload: Partial;\n}): string {\n if (typeof payload !== 'object') {\n throw new Error(`The insights helper expects the payload to be an object.`);\n }\n\n let serializedPayload: string;\n\n try {\n serializedPayload = btoa(JSON.stringify(payload));\n } catch (error) {\n throw new Error(`Could not JSON serialize the payload object.`);\n }\n\n return `data-insights-method=\"${method}\" data-insights-payload=\"${serializedPayload}\"`;\n}\n\nexport default function insights(\n method: InsightsClientMethod,\n payload: Partial\n): string {\n return writeDataAttributes({ method, payload });\n}\n","import { withInsights } from '../../lib/insights';\nimport connectHits from './connectHits';\n\nconst connectHitsWithInsights = withInsights(connectHits);\n\nexport default connectHitsWithInsights;\n","import {\n checkRendering,\n warning,\n createDocumentationMessageGenerator,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'hits-per-page',\n connector: true,\n});\n\n/**\n * @typedef {Object} HitsPerPageRenderingOptionsItem\n * @property {number} value Number of hits to display per page.\n * @property {string} label Label to display in the option.\n * @property {boolean} isRefined Indicates if it's the current refined value.\n */\n\n/**\n * @typedef {Object} HitsPerPageWidgetOptionsItem\n * @property {number} value Number of hits to display per page.\n * @property {string} label Label to display in the option.\n * @property {boolean} default The default hits per page on first search.\n */\n\n/**\n * @typedef {Object} HitsPerPageRenderingOptions\n * @property {HitsPerPageRenderingOptionsItem[]} items Array of objects defining the different values and labels.\n * @property {function(item.value)} createURL Creates the URL for a single item name in the list.\n * @property {function(number)} refine Sets the number of hits per page and trigger a search.\n * @property {boolean} hasNoResults `true` if the last search contains no result.\n * @property {Object} widgetParams Original `HitsPerPageWidgetOptions` forwarded to `renderFn`.\n */\n\n/**\n * @typedef {Object} HitsPerPageWidgetOptions\n * @property {HitsPerPageWidgetOptionsItem[]} items Array of objects defining the different values and labels.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * **HitsPerPage** connector provides the logic to create custom widget that will\n * allow a user to choose to display more or less results from Algolia.\n *\n * This connector provides a `refine()` function to change the hits per page configuration and trigger a new search.\n * @type {Connector}\n * @param {function(HitsPerPageRenderingOptions, boolean)} renderFn Rendering function for the custom **HitsPerPage** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(HitsPerPageWidgetOptions)} Re-usable widget factory for a custom **HitsPerPage** widget.\n * @example\n * // custom `renderFn` to render the custom HitsPerPage widget\n * function renderFn(HitsPerPageRenderingOptions, isFirstRendering) {\n * var containerNode = HitsPerPageRenderingOptions.widgetParams.containerNode\n * var items = HitsPerPageRenderingOptions.items\n * var refine = HitsPerPageRenderingOptions.refine\n *\n * if (isFirstRendering) {\n * var markup = '';\n * containerNode.append(markup);\n * }\n *\n * const itemsHTML = items.map(({value, label, isRefined}) => `\n * \n * ${label}\n * \n * `);\n *\n * containerNode\n * .find('select')\n * .html(itemsHTML);\n *\n * containerNode\n * .find('select')\n * .off('change')\n * .on('change', e => { refine(e.target.value); });\n * }\n *\n * // connect `renderFn` to HitsPerPage logic\n * var customHitsPerPage = instantsearch.connectors.connectHitsPerPage(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customHitsPerPage({\n * containerNode: $('#custom-hits-per-page-container'),\n * items: [\n * {value: 6, label: '6 per page', default: true},\n * {value: 12, label: '12 per page'},\n * {value: 24, label: '24 per page'},\n * ],\n * })\n * );\n */\nexport default function connectHitsPerPage(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { items: userItems, transformItems = items => items } = widgetParams;\n let items = userItems;\n\n if (!Array.isArray(items)) {\n throw new Error(\n withUsage('The `items` option expects an array of objects.')\n );\n }\n\n const defaultValues = items.filter(item => item.default);\n if (defaultValues.length > 1) {\n throw new Error(\n withUsage('More than one default value is specified in `items`.')\n );\n }\n\n const defaultValue = find(userItems, item => item.default === true);\n\n return {\n getConfiguration() {\n return defaultValues.length > 0\n ? { hitsPerPage: defaultValues[0].value }\n : {};\n },\n\n init({ helper, createURL, state, instantSearchInstance }) {\n const isCurrentInOptions = items.some(\n item => Number(state.hitsPerPage) === Number(item.value)\n );\n\n if (!isCurrentInOptions) {\n warning(\n state.hitsPerPage !== undefined,\n `\n\\`hitsPerPage\\` is not defined.\nThe option \\`hitsPerPage\\` needs to be set using the \\`configure\\` widget.\n\nLearn more: https://community.algolia.com/instantsearch.js/v2/widgets/configure.html\n `\n );\n\n warning(\n false,\n `\nThe \\`items\\` option of \\`hitsPerPage\\` does not contain the \"hits per page\" value coming from the state: ${\n state.hitsPerPage\n }.\n\nYou may want to add another entry to the \\`items\\` option with this value.`\n );\n\n items = [{ value: '', label: '' }, ...items];\n }\n\n this.setHitsPerPage = value =>\n !value && value !== 0\n ? helper.setQueryParameter('hitsPerPage', undefined).search()\n : helper.setQueryParameter('hitsPerPage', value).search();\n\n this.createURL = helperState => value =>\n createURL(\n helperState.setQueryParameter(\n 'hitsPerPage',\n !value && value !== 0 ? undefined : value\n )\n );\n\n renderFn(\n {\n items: transformItems(this._normalizeItems(state)),\n refine: this.setHitsPerPage,\n createURL: this.createURL(helper.state),\n hasNoResults: true,\n widgetParams,\n instantSearchInstance,\n },\n true\n );\n },\n\n render({ state, results, instantSearchInstance }) {\n const hasNoResults = results.nbHits === 0;\n\n renderFn(\n {\n items: transformItems(this._normalizeItems(state)),\n refine: this.setHitsPerPage,\n createURL: this.createURL(state),\n hasNoResults,\n widgetParams,\n instantSearchInstance,\n },\n false\n );\n },\n\n _normalizeItems({ hitsPerPage }) {\n return items.map(item => ({\n ...item,\n isRefined: Number(item.value) === Number(hitsPerPage),\n }));\n },\n\n dispose() {\n unmountFn();\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const hitsPerPage = searchParameters.hitsPerPage;\n if (\n (defaultValue && hitsPerPage === defaultValue.value) ||\n hitsPerPage === undefined ||\n uiState.hitsPerPage === hitsPerPage\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n hitsPerPage,\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const hitsPerPage = uiState.hitsPerPage;\n if (hitsPerPage)\n return searchParameters.setQueryParameter(\n 'hitsPerPage',\n uiState.hitsPerPage\n );\n if (defaultValue) {\n return searchParameters.setQueryParameter(\n 'hitsPerPage',\n defaultValue.value\n );\n }\n return searchParameters.setQueryParameter('hitsPerPage', undefined);\n },\n };\n };\n}\n","import escapeHits, { TAG_PLACEHOLDER } from '../../lib/escape-highlight';\nimport {\n Renderer,\n RenderOptions,\n WidgetFactory,\n Hits,\n Unmounter,\n Helper,\n SearchParameters,\n} from '../../types';\nimport {\n checkRendering,\n createDocumentationMessageGenerator,\n isEqual,\n addAbsolutePosition,\n addQueryID,\n noop,\n} from '../../lib/utils';\nimport { InfiniteHitsRendererWidgetParams } from '../../widgets/infinite-hits/infinite-hits';\n\nexport type InfiniteHitsConnectorParams = Partial<\n InfiniteHitsRendererWidgetParams\n>;\n\nexport interface InfiniteHitsRenderOptions\n extends RenderOptions {\n showPrevious: () => void;\n showMore: () => void;\n isFirstPage: boolean;\n isLastPage: boolean;\n}\n\nexport type InfiniteHitsRenderer = Renderer<\n InfiniteHitsRenderOptions<\n InfiniteHitsConnectorParams & TInfiniteHitsWidgetParams\n >\n>;\n\nexport type InfiniteHitsWidgetFactory<\n TInfiniteHitsWidgetParams\n> = WidgetFactory;\n\nexport type InfiniteHitsConnector = (\n render: InfiniteHitsRenderer,\n unmount?: Unmounter\n) => InfiniteHitsWidgetFactory;\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'infinite-hits',\n connector: true,\n});\n\n/**\n * @typedef {Object} InfiniteHitsRenderingOptions\n * @property {Array} hits The aggregated matched hits from Algolia API of all pages.\n * @property {Object} results The complete results response from Algolia API.\n * @property {function} showMore Loads the next page of hits.\n * @property {boolean} isLastPage Indicates if the last page of hits has been reached.\n * @property {Object} widgetParams All original widget options forwarded to the `renderFn`.\n */\n\n/**\n * @typedef {Object} CustomInfiniteHitsWidgetOptions\n * @property {boolean} [escapeHTML = true] Whether to escape HTML tags from `hits[i]._highlightResult`.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * **InfiniteHits** connector provides the logic to create custom widgets that will render an continuous list of results retrieved from Algolia.\n *\n * This connector provides a `InfiniteHitsRenderingOptions.showMore()` function to load next page of matched results.\n * @type {Connector}\n * @param {function(InfiniteHitsRenderingOptions, boolean)} renderFn Rendering function for the custom **InfiniteHits** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomInfiniteHitsWidgetOptions)} Re-usable widget factory for a custom **InfiniteHits** widget.\n * @example\n * // custom `renderFn` to render the custom InfiniteHits widget\n * function renderFn(InfiniteHitsRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * InfiniteHitsRenderingOptions.widgetParams.containerNode\n * .html('
    ');\n *\n * InfiniteHitsRenderingOptions.widgetParams.containerNode\n * .find('#show-more')\n * .on('click', function(event) {\n * event.preventDefault();\n * InfiniteHitsRenderingOptions.showMore();\n * });\n * }\n *\n * InfiniteHitsRenderingOptions.widgetParams.containerNode.find('#hits').html(\n * InfiniteHitsRenderingOptions.hits.map(function(hit) {\n * return '
    ' + hit._highlightResult.name.value + '
    ';\n * })\n * );\n * };\n *\n * // connect `renderFn` to InfiniteHits logic\n * var customInfiniteHits = instantsearch.connectors.connectInfiniteHits(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customInfiniteHits({\n * containerNode: $('#custom-infinite-hits-container'),\n * })\n * );\n */\nconst connectInfiniteHits: InfiniteHitsConnector = (\n renderFn,\n unmountFn = noop\n) => {\n checkRendering(renderFn, withUsage());\n\n return widgetParams => {\n const {\n escapeHTML = true,\n transformItems = (items: any[]) => items,\n showPrevious: hasShowPrevious = false,\n } = widgetParams || {};\n let hitsCache: Hits = [];\n let firstReceivedPage = Infinity;\n let lastReceivedPage = -1;\n let prevState: Partial;\n let showPrevious: () => void;\n let showMore: () => void;\n\n const getShowPrevious = (helper: Helper): (() => void) => () => {\n // Using the helper's `overrideStateWithoutTriggeringChangeEvent` method\n // avoid updating the browser URL when the user displays the previous page.\n helper\n .overrideStateWithoutTriggeringChangeEvent({\n ...helper.state,\n page: firstReceivedPage - 1,\n })\n .search();\n };\n const getShowMore = (helper: Helper): (() => void) => () => {\n helper.setPage(lastReceivedPage + 1).search();\n };\n\n return {\n getConfiguration() {\n return escapeHTML ? TAG_PLACEHOLDER : {};\n },\n\n init({ instantSearchInstance, helper }) {\n showPrevious = getShowPrevious(helper);\n showMore = getShowMore(helper);\n firstReceivedPage = helper.state.page!;\n lastReceivedPage = helper.state.page!;\n\n renderFn(\n {\n hits: hitsCache,\n results: undefined,\n showPrevious,\n showMore,\n isFirstPage: firstReceivedPage === 0,\n isLastPage: true,\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, state, instantSearchInstance }) {\n // Reset cache and received pages if anything changes in the\n // search state, except for the page.\n //\n // We're doing this to \"reset\" the widget if a refinement or the\n // query changes between renders, but we want to keep it as is\n // if we only change pages.\n const { page, ...currentState } = state;\n if (!isEqual(currentState, prevState)) {\n hitsCache = [];\n firstReceivedPage = page!;\n lastReceivedPage = page!;\n prevState = currentState;\n }\n\n if (escapeHTML && results.hits.length > 0) {\n results.hits = escapeHits(results.hits);\n }\n const initialEscaped = (results.hits as any).__escaped;\n\n results.hits = addAbsolutePosition(\n results.hits,\n results.page,\n results.hitsPerPage\n );\n\n results.hits = addQueryID(results.hits, results.queryID);\n\n results.hits = transformItems(results.hits);\n\n // Make sure the escaped tag stays after mapping over the hits.\n // This prevents the hits from being double-escaped if there are multiple\n // hits widgets mounted on the page.\n (results.hits as any).__escaped = initialEscaped;\n\n if (lastReceivedPage < page! || !hitsCache.length) {\n hitsCache = [...hitsCache, ...results.hits];\n lastReceivedPage = page!;\n } else if (firstReceivedPage > page!) {\n hitsCache = [...results.hits, ...hitsCache];\n firstReceivedPage = page!;\n }\n\n const isFirstPage = firstReceivedPage === 0;\n const isLastPage = results.nbPages <= results.page + 1;\n\n renderFn(\n {\n hits: hitsCache,\n results,\n showPrevious,\n showMore,\n isFirstPage,\n isLastPage,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const page = searchParameters.page!;\n\n if (!hasShowPrevious || page === 0 || page + 1 === uiState.page) {\n return uiState;\n }\n\n return {\n ...uiState,\n page: page + 1,\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n if (!hasShowPrevious) {\n return searchParameters;\n }\n const uiPage = uiState.page;\n if (uiPage) {\n return searchParameters.setQueryParameter('page', uiPage - 1);\n }\n return searchParameters.setQueryParameter('page', 0);\n },\n };\n };\n};\n\nexport default connectInfiniteHits;\n","import { withInsights } from '../../lib/insights';\nimport connectInfiniteHits from './connectInfiniteHits';\n\nconst connectInfiniteHitsWithInsights = withInsights(connectInfiniteHits);\n\nexport default connectInfiniteHitsWithInsights;\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'menu',\n connector: true,\n});\n\n/**\n * @typedef {Object} MenuItem\n * @property {string} value The value of the menu item.\n * @property {string} label Human-readable value of the menu item.\n * @property {number} count Number of results matched after refinement is applied.\n * @property {boolean} isRefined Indicates if the refinement is applied.\n */\n\n/**\n * @typedef {Object} CustomMenuWidgetOptions\n * @property {string} attribute Name of the attribute for faceting (eg. \"free_shipping\").\n * @property {number} [limit = 10] How many facets values to retrieve.\n * @property {boolean} [showMore = false] Whether to display a button that expands the number of items.\n * @property {number} [showMoreLimit = 20] How many facets values to retrieve when `toggleShowMore` is called, this value is meant to be greater than `limit` option.\n * @property {string[]|function} [sortBy = ['isRefined', 'name:asc']] How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.\n *\n * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} MenuRenderingOptions\n * @property {MenuItem[]} items The elements that can be refined for the current search results.\n * @property {function(item.value): string} createURL Creates the URL for a single item name in the list.\n * @property {function(item.value)} refine Filter the search to item value.\n * @property {boolean} canRefine True if refinement can be applied.\n * @property {Object} widgetParams All original `CustomMenuWidgetOptions` forwarded to the `renderFn`.\n * @property {boolean} isShowingMore True if the menu is displaying all the menu items.\n * @property {function} toggleShowMore Toggles the number of values displayed between `limit` and `showMore.limit`.\n * @property {boolean} canToggleShowMore `true` if the toggleShowMore button can be activated (enough items to display more or\n * already displaying more than `limit` items)\n */\n\n/**\n * **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories.\n *\n * This connector provides a `toggleShowMore()` function to display more or less items and a `refine()`\n * function to select an item. While selecting a new element, the `refine` will also unselect the\n * one that is currently selected.\n *\n * **Requirement:** the attribute passed as `attribute` must be present in \"attributes for faceting\" on the Algolia dashboard or configured as attributesForFaceting via a set settings call to the Algolia API.\n * @type {Connector}\n * @param {function(MenuRenderingOptions, boolean)} renderFn Rendering function for the custom **Menu** widget. widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomMenuWidgetOptions)} Re-usable widget factory for a custom **Menu** widget.\n * @example\n * // custom `renderFn` to render the custom Menu widget\n * function renderFn(MenuRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * MenuRenderingOptions.widgetParams.containerNode\n * .html(' ' +\n * item.label + '';\n * });\n *\n * NumericMenuRenderingOptions.widgetParams.containerNode.find('ul').html(list);\n * NumericMenuRenderingOptions.widgetParams.containerNode\n * .find('li[data-refine-value]')\n * .each(function() {\n * $(this).on('click', function(event) {\n * event.preventDefault();\n * event.stopPropagation();\n * NumericMenuRenderingOptions.refine($(this).data('refine-value'));\n * });\n * });\n * }\n *\n * // connect `renderFn` to NumericMenu logic\n * var customNumericMenu = instantsearch.connectors.connectNumericMenu(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customNumericMenu({\n * containerNode: $('#custom-numeric-menu-container'),\n * attribute: 'price',\n * items: [\n * {name: 'All'},\n * {end: 4, name: 'less than 4'},\n * {start: 4, end: 4, name: '4'},\n * {start: 5, end: 10, name: 'between 5 and 10'},\n * {start: 10, name: 'more than 10'},\n * ],\n * })\n * );\n */\nexport default function connectNumericMenu(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { attribute, items, transformItems = x => x } = widgetParams;\n\n if (!attribute) {\n throw new Error(withUsage('The `attribute` option is required.'));\n }\n\n if (!items) {\n throw new Error(\n withUsage('The `items` option expects an array of objects.')\n );\n }\n\n return {\n init({ helper, createURL, instantSearchInstance }) {\n this._refine = facetValue => {\n const refinedState = refine(\n helper.state,\n attribute,\n items,\n facetValue\n );\n helper.setState(refinedState).search();\n };\n\n this._createURL = state => facetValue =>\n createURL(refine(state, attribute, items, facetValue));\n this._prepareItems = state =>\n items.map(({ start, end, label }) => ({\n label,\n value: window.encodeURI(JSON.stringify({ start, end })),\n isRefined: isRefined(state, attribute, { start, end }),\n }));\n\n renderFn(\n {\n createURL: this._createURL(helper.state),\n items: transformItems(this._prepareItems(helper.state)),\n hasNoResults: true,\n refine: this._refine,\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, state, instantSearchInstance }) {\n renderFn(\n {\n createURL: this._createURL(state),\n items: transformItems(this._prepareItems(state)),\n hasNoResults: results.nbHits === 0,\n refine: this._refine,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n return state.clearRefinements(attribute);\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const currentRefinements = searchParameters.getNumericRefinements(\n attribute\n );\n const equal = currentRefinements['='] && currentRefinements['='][0];\n if (equal || equal === 0) {\n return {\n ...uiState,\n numericMenu: {\n ...uiState.numericMenu,\n [attribute]: `${currentRefinements['=']}`,\n },\n };\n }\n\n const lowerBound =\n (currentRefinements['>='] && currentRefinements['>='][0]) || '';\n const upperBound =\n (currentRefinements['<='] && currentRefinements['<='][0]) || '';\n\n if (lowerBound !== '' || upperBound !== '') {\n if (\n uiState.numericMenu &&\n uiState.numericMenu[attribute] === `${lowerBound}:${upperBound}`\n )\n return uiState;\n return {\n ...uiState,\n numericMenu: {\n ...uiState.numericMenu,\n [attribute]: `${lowerBound}:${upperBound}`,\n },\n };\n }\n\n return uiState;\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n let clearedParams = searchParameters.clearRefinements(attribute);\n const value = uiState.numericMenu && uiState.numericMenu[attribute];\n\n if (!value) {\n return clearedParams;\n }\n\n const valueAsEqual = value.indexOf(':') === -1 && value;\n\n if (valueAsEqual) {\n return clearedParams.addNumericRefinement(\n attribute,\n '=',\n valueAsEqual\n );\n }\n\n const [lowerBound, upperBound] = value.split(':').map(parseFloat);\n\n if (isFiniteNumber(lowerBound)) {\n clearedParams = clearedParams.addNumericRefinement(\n attribute,\n '>=',\n lowerBound\n );\n }\n\n if (isFiniteNumber(upperBound)) {\n clearedParams = clearedParams.addNumericRefinement(\n attribute,\n '<=',\n upperBound\n );\n }\n\n return clearedParams;\n },\n };\n };\n}\n\nfunction isRefined(state, attribute, option) {\n const currentRefinements = state.getNumericRefinements(attribute);\n\n if (option.start !== undefined && option.end !== undefined) {\n if (option.start === option.end) {\n return hasNumericRefinement(currentRefinements, '=', option.start);\n }\n }\n\n if (option.start !== undefined) {\n return hasNumericRefinement(currentRefinements, '>=', option.start);\n }\n\n if (option.end !== undefined) {\n return hasNumericRefinement(currentRefinements, '<=', option.end);\n }\n\n if (option.start === undefined && option.end === undefined) {\n return Object.keys(currentRefinements).length === 0;\n }\n\n return undefined;\n}\n\nfunction refine(state, attribute, items, facetValue) {\n let resolvedState = state;\n\n const refinedOption = JSON.parse(window.decodeURI(facetValue));\n\n const currentRefinements = resolvedState.getNumericRefinements(attribute);\n\n if (refinedOption.start === undefined && refinedOption.end === undefined) {\n return resolvedState.clearRefinements(attribute);\n }\n\n if (!isRefined(resolvedState, attribute, refinedOption)) {\n resolvedState = resolvedState.clearRefinements(attribute);\n }\n\n if (refinedOption.start !== undefined && refinedOption.end !== undefined) {\n if (refinedOption.start > refinedOption.end) {\n throw new Error('option.start should be > to option.end');\n }\n\n if (refinedOption.start === refinedOption.end) {\n if (hasNumericRefinement(currentRefinements, '=', refinedOption.start)) {\n resolvedState = resolvedState.removeNumericRefinement(\n attribute,\n '=',\n refinedOption.start\n );\n } else {\n resolvedState = resolvedState.addNumericRefinement(\n attribute,\n '=',\n refinedOption.start\n );\n }\n return resolvedState;\n }\n }\n\n if (refinedOption.start !== undefined) {\n if (hasNumericRefinement(currentRefinements, '>=', refinedOption.start)) {\n resolvedState = resolvedState.removeNumericRefinement(\n attribute,\n '>=',\n refinedOption.start\n );\n } else {\n resolvedState = resolvedState.addNumericRefinement(\n attribute,\n '>=',\n refinedOption.start\n );\n }\n }\n\n if (refinedOption.end !== undefined) {\n if (hasNumericRefinement(currentRefinements, '<=', refinedOption.end)) {\n resolvedState = resolvedState.removeNumericRefinement(\n attribute,\n '<=',\n refinedOption.end\n );\n } else {\n resolvedState = resolvedState.addNumericRefinement(\n attribute,\n '<=',\n refinedOption.end\n );\n }\n }\n\n resolvedState.page = 0;\n\n return resolvedState;\n}\n\nfunction hasNumericRefinement(currentRefinements, operator, value) {\n const hasOperatorRefinements = currentRefinements[operator] !== undefined;\n\n return hasOperatorRefinements && currentRefinements[operator].includes(value);\n}\n","import { range } from '../../lib/utils';\n\nclass Paginator {\n constructor(params) {\n this.currentPage = params.currentPage;\n this.total = params.total;\n this.padding = params.padding;\n }\n\n pages() {\n const { total, currentPage, padding } = this;\n\n if (total === 0) return [0];\n\n const totalDisplayedPages = this.nbPagesDisplayed(padding, total);\n if (totalDisplayedPages === total) {\n return range({ end: total });\n }\n\n const paddingLeft = this.calculatePaddingLeft(\n currentPage,\n padding,\n total,\n totalDisplayedPages\n );\n const paddingRight = totalDisplayedPages - paddingLeft;\n\n const first = currentPage - paddingLeft;\n const last = currentPage + paddingRight;\n\n return range({ start: first, end: last });\n }\n\n nbPagesDisplayed(padding, total) {\n return Math.min(2 * padding + 1, total);\n }\n\n calculatePaddingLeft(current, padding, total, totalDisplayedPages) {\n if (current <= padding) {\n return current;\n }\n\n if (current >= total - padding) {\n return totalDisplayedPages - (total - current);\n }\n\n return padding;\n }\n\n isLastPage() {\n return this.currentPage === this.total - 1;\n }\n\n isFirstPage() {\n return this.currentPage === 0;\n }\n}\n\nexport default Paginator;\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\nimport Paginator from './Paginator';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'pagination',\n connector: true,\n});\n\n/**\n * @typedef {Object} CustomPaginationWidgetOptions\n * @property {number} [totalPages] The total number of pages to browse.\n * @property {number} [padding = 3] The padding of pages to show around the current page\n */\n\n/**\n * @typedef {Object} PaginationRenderingOptions\n * @property {function(page): string} createURL Creates URLs for the next state, the number is the page to generate the URL for.\n * @property {number} currentRefinement The number of the page currently displayed.\n * @property {number} nbHits The number of hits computed for the last query (can be approximated).\n * @property {number} nbPages The number of pages for the result set.\n * @property {number[]} pages The actual pages relevant to the current situation and padding\n * @property {boolean} isFirstPage true if the current page is also the first page\n * @property {boolean} isLastPage true if the current page is also the last page\n * @property {function(page)} refine Sets the current page and trigger a search.\n * @property {Object} widgetParams All original `CustomPaginationWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **Pagination** connector provides the logic to build a widget that will let the user\n * choose the current page of the results.\n *\n * When using the pagination with Algolia, you should be aware that the engine won't provide you pages\n * beyond the 1000th hits by default. You can find more information on the [Algolia documentation](https://www.algolia.com/doc/guides/searching/pagination/#pagination-limitations).\n *\n * @type {Connector}\n * @param {function(PaginationRenderingOptions, boolean)} renderFn Rendering function for the custom **Pagination** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomPaginationWidgetOptions)} Re-usable widget factory for a custom **Pagination** widget.\n * @example\n * // custom `renderFn` to render the custom Pagination widget\n * function renderFn(PaginationRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * PaginationRenderingOptions.widgetParams.containerNode.html('
      ');\n * }\n *\n * // remove event listeners before replacing markup\n * PaginationRenderingOptions.widgetParams.containerNode\n * .find('a[data-page]')\n * .each(function() { $(this).off('click'); });\n *\n * var pages = PaginationRenderingOptions.pages\n * .map(function(page) {\n * return '
    • ' +\n * '' +\n * (parseInt(page) + 1) + '
    • ';\n * });\n *\n * PaginationRenderingOptions.widgetParams.containerNode\n * .find('ul')\n * .html(pages);\n *\n * PaginationRenderingOptions.widgetParams.containerNode\n * .find('a[data-page]')\n * .each(function() {\n * $(this).on('click', function(event) {\n * event.preventDefault();\n * PaginationRenderingOptions.refine($(this).data('page'));\n * });\n * });\n * }\n *\n * // connect `renderFn` to Pagination logic\n * var customPagination = instantsearch.connectors.connectPagination(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customPagination({\n * containerNode: $('#custom-pagination-container'),\n * totalPages: 20,\n * padding: 4,\n * })\n * );\n */\nexport default function connectPagination(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { totalPages, padding = 3 } = widgetParams;\n\n const pager = new Paginator({\n currentPage: 0,\n total: 0,\n padding,\n });\n\n return {\n init({ helper, createURL, instantSearchInstance }) {\n this.refine = page => {\n helper.setPage(page);\n helper.search();\n };\n\n this.createURL = state => page => createURL(state.setPage(page));\n\n renderFn(\n {\n createURL: this.createURL(helper.state),\n currentRefinement: helper.getPage() || 0,\n nbHits: 0,\n nbPages: 0,\n pages: [],\n isFirstPage: true,\n isLastPage: true,\n refine: this.refine,\n widgetParams,\n instantSearchInstance,\n },\n true\n );\n },\n\n getMaxPage({ nbPages }) {\n return totalPages !== undefined\n ? Math.min(totalPages, nbPages)\n : nbPages;\n },\n\n render({ results, state, instantSearchInstance }) {\n const nbPages = this.getMaxPage(results);\n pager.currentPage = state.page;\n pager.total = nbPages;\n\n renderFn(\n {\n createURL: this.createURL(state),\n currentRefinement: state.page,\n refine: this.refine,\n nbHits: results.nbHits,\n nbPages,\n pages: pager.pages(),\n isFirstPage: pager.isFirstPage(),\n isLastPage: pager.isLastPage(),\n widgetParams,\n instantSearchInstance,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const page = searchParameters.page;\n if (page === 0 || page + 1 === uiState.page) return uiState;\n return {\n ...uiState,\n page: page + 1,\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const uiPage = uiState.page;\n if (uiPage)\n return searchParameters.setQueryParameter('page', uiState.page - 1);\n return searchParameters.setQueryParameter('page', 0);\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n isFiniteNumber,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator(\n { name: 'range-input', connector: true },\n { name: 'range-slider', connector: true }\n);\n\n/**\n * @typedef {Object} CustomRangeWidgetOptions\n * @property {string} attribute Name of the attribute for faceting.\n * @property {number} [min = undefined] Minimal range value, default to automatically computed from the result set.\n * @property {number} [max = undefined] Maximal range value, default to automatically computed from the result set.\n * @property {number} [precision = 2] Number of digits after decimal point to use.\n */\n\n/**\n * @typedef {Object} RangeRenderingOptions\n * @property {function(Array)} refine Sets a range to filter the results on. Both values\n * are optional, and will default to the higher and lower bounds. You can use `undefined` to remove a\n * previously set bound or to set an infinite bound.\n * @property {{min: number, max: number}} range Results bounds without the current range filter.\n * @property {Array} start Current numeric bounds of the search.\n * @property {{from: function, to: function}} formatter Transform for the rendering `from` and/or `to` values.\n * Both functions take a `number` as input and should output a `string`.\n * @property {Object} widgetParams All original `CustomRangeWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **Range** connector provides the logic to create custom widget that will let\n * the user refine results using a numeric range.\n *\n * This connectors provides a `refine()` function that accepts bounds. It will also provide\n * information about the min and max bounds for the current result set.\n * @type {Connector}\n * @param {function(RangeRenderingOptions, boolean)} renderFn Rendering function for the custom **Range** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomRangeWidgetOptions)} Re-usable widget factory for a custom **Range** widget.\n */\nexport default function connectRange(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const {\n attribute,\n min: minBound,\n max: maxBound,\n precision = 2, // @MAJOR: the `precision` default value should be 0\n } = widgetParams;\n\n if (!attribute) {\n throw new Error(withUsage('The `attribute` option is required.'));\n }\n\n const hasMinBound = isFiniteNumber(minBound);\n const hasMaxBound = isFiniteNumber(maxBound);\n\n const formatToNumber = v => Number(Number(v).toFixed(precision));\n\n const rangeFormatter = {\n from: v => v,\n to: v => formatToNumber(v).toLocaleString(),\n };\n\n return {\n _getCurrentRange(stats) {\n const pow = Math.pow(10, precision);\n\n let min;\n if (hasMinBound) {\n min = minBound;\n } else if (isFiniteNumber(stats.min)) {\n min = stats.min;\n } else {\n min = 0;\n }\n\n let max;\n if (hasMaxBound) {\n max = maxBound;\n } else if (isFiniteNumber(stats.max)) {\n max = stats.max;\n } else {\n max = 0;\n }\n\n return {\n min: Math.floor(min * pow) / pow,\n max: Math.ceil(max * pow) / pow,\n };\n },\n\n _getCurrentRefinement(helper) {\n const [minValue] = helper.getNumericRefinement(attribute, '>=') || [];\n\n const [maxValue] = helper.getNumericRefinement(attribute, '<=') || [];\n\n const min = isFiniteNumber(minValue) ? minValue : -Infinity;\n const max = isFiniteNumber(maxValue) ? maxValue : Infinity;\n\n return [min, max];\n },\n\n _refine(helper, currentRange) {\n // eslint-disable-next-line complexity\n return ([nextMin, nextMax] = []) => {\n const { min: currentRangeMin, max: currentRangeMax } = currentRange;\n\n const [min] = helper.getNumericRefinement(attribute, '>=') || [];\n const [max] = helper.getNumericRefinement(attribute, '<=') || [];\n\n const isResetMin = nextMin === undefined || nextMin === '';\n const isResetMax = nextMax === undefined || nextMax === '';\n\n const nextMinAsNumber = !isResetMin ? parseFloat(nextMin) : undefined;\n const nextMaxAsNumber = !isResetMax ? parseFloat(nextMax) : undefined;\n\n let newNextMin;\n if (!hasMinBound && currentRangeMin === nextMinAsNumber) {\n newNextMin = undefined;\n } else if (hasMinBound && isResetMin) {\n newNextMin = minBound;\n } else {\n newNextMin = nextMinAsNumber;\n }\n\n let newNextMax;\n if (!hasMaxBound && currentRangeMax === nextMaxAsNumber) {\n newNextMax = undefined;\n } else if (hasMaxBound && isResetMax) {\n newNextMax = maxBound;\n } else {\n newNextMax = nextMaxAsNumber;\n }\n\n const isResetNewNextMin = newNextMin === undefined;\n const isValidNewNextMin = isFiniteNumber(newNextMin);\n const isValidMinCurrentRange = isFiniteNumber(currentRangeMin);\n const isGreaterThanCurrentRange =\n isValidMinCurrentRange && currentRangeMin <= newNextMin;\n const isMinValid =\n isResetNewNextMin ||\n (isValidNewNextMin &&\n (!isValidMinCurrentRange || isGreaterThanCurrentRange));\n\n const isResetNewNextMax = newNextMax === undefined;\n const isValidNewNextMax = isFiniteNumber(newNextMax);\n const isValidMaxCurrentRange = isFiniteNumber(currentRangeMax);\n const isLowerThanRange =\n isValidMaxCurrentRange && currentRangeMax >= newNextMax;\n const isMaxValid =\n isResetNewNextMax ||\n (isValidNewNextMax &&\n (!isValidMaxCurrentRange || isLowerThanRange));\n\n const hasMinChange = min !== newNextMin;\n const hasMaxChange = max !== newNextMax;\n\n if ((hasMinChange || hasMaxChange) && (isMinValid && isMaxValid)) {\n helper.clearRefinements(attribute);\n\n if (isValidNewNextMin) {\n helper.addNumericRefinement(\n attribute,\n '>=',\n formatToNumber(newNextMin)\n );\n }\n\n if (isValidNewNextMax) {\n helper.addNumericRefinement(\n attribute,\n '<=',\n formatToNumber(newNextMax)\n );\n }\n\n helper.search();\n }\n };\n },\n\n getConfiguration(currentConfiguration) {\n const configuration = {\n disjunctiveFacets: [attribute],\n };\n\n const isBoundsDefined = hasMinBound || hasMaxBound;\n\n const boundsAlreadyDefined =\n currentConfiguration &&\n currentConfiguration.numericRefinements &&\n currentConfiguration.numericRefinements[attribute] !== undefined;\n\n const isMinBoundValid = isFiniteNumber(minBound);\n const isMaxBoundValid = isFiniteNumber(maxBound);\n const isAbleToRefine =\n isMinBoundValid && isMaxBoundValid\n ? minBound < maxBound\n : isMinBoundValid || isMaxBoundValid;\n\n if (isBoundsDefined && !boundsAlreadyDefined && isAbleToRefine) {\n configuration.numericRefinements = { [attribute]: {} };\n\n if (hasMinBound) {\n configuration.numericRefinements[attribute]['>='] = [minBound];\n }\n\n if (hasMaxBound) {\n configuration.numericRefinements[attribute]['<='] = [maxBound];\n }\n }\n\n return configuration;\n },\n\n init({ helper, instantSearchInstance }) {\n const stats = {};\n const currentRange = this._getCurrentRange(stats);\n const start = this._getCurrentRefinement(helper);\n\n renderFn(\n {\n // On first render pass an empty range\n // to be able to bypass the validation\n // related to it\n refine: this._refine(helper, {}),\n format: rangeFormatter,\n range: currentRange,\n widgetParams: {\n ...widgetParams,\n precision,\n },\n start,\n instantSearchInstance,\n },\n true\n );\n },\n\n render({ results, helper, instantSearchInstance }) {\n const facetsFromResults = results.disjunctiveFacets || [];\n const facet = find(\n facetsFromResults,\n facetResult => facetResult.name === attribute\n );\n const stats = (facet && facet.stats) || {};\n\n const currentRange = this._getCurrentRange(stats);\n const start = this._getCurrentRefinement(helper);\n\n renderFn(\n {\n refine: this._refine(helper, currentRange),\n format: rangeFormatter,\n range: currentRange,\n widgetParams: {\n ...widgetParams,\n precision,\n },\n start,\n instantSearchInstance,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n\n const nextState = state\n .removeNumericRefinement(attribute)\n .removeDisjunctiveFacet(attribute);\n\n return nextState;\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const {\n '>=': min = '',\n '<=': max = '',\n } = searchParameters.getNumericRefinements(attribute);\n\n if (\n (min === '' && max === '') ||\n (uiState &&\n uiState.range &&\n uiState.range[attribute] === `${min}:${max}`)\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n range: {\n ...uiState.range,\n [attribute]: `${min}:${max}`,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const value = uiState && uiState.range && uiState.range[attribute];\n\n if (!value || value.indexOf(':') === -1) {\n return searchParameters;\n }\n\n const {\n '>=': previousMin = [NaN],\n '<=': previousMax = [NaN],\n } = searchParameters.getNumericRefinements(attribute);\n let clearedParams = searchParameters.clearRefinements(attribute);\n const [lowerBound, upperBound] = value.split(':').map(parseFloat);\n\n if (\n previousMin.includes(lowerBound) &&\n previousMax.includes(upperBound)\n ) {\n return searchParameters;\n }\n\n if (isFiniteNumber(lowerBound)) {\n clearedParams = clearedParams.addNumericRefinement(\n attribute,\n '>=',\n lowerBound\n );\n }\n\n if (isFiniteNumber(upperBound)) {\n clearedParams = clearedParams.addNumericRefinement(\n attribute,\n '<=',\n upperBound\n );\n }\n\n return clearedParams;\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n isEqual,\n} from '../../lib/utils';\nimport {\n escapeFacets,\n TAG_PLACEHOLDER,\n TAG_REPLACEMENT,\n} from '../../lib/escape-highlight';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'refinement-list',\n connector: true,\n});\n\n/**\n * @typedef {Object} RefinementListItem\n * @property {string} value The value of the refinement list item.\n * @property {string} label Human-readable value of the refinement list item.\n * @property {number} count Number of matched results after refinement is applied.\n * @property {boolean} isRefined Indicates if the list item is refined.\n */\n\n/**\n * @typedef {Object} CustomRefinementListWidgetOptions\n * @property {string} attribute The name of the attribute in the records.\n * @property {\"and\"|\"or\"} [operator = 'or'] How the filters are combined together.\n * @property {number} [limit = 10] The max number of items to display when\n * `showMoreLimit` is not set or if the widget is showing less value.\n * @property {boolean} [showMore = false] Whether to display a button that expands the number of items.\n * @property {number} [showMoreLimit = 20] The max number of items to display if the widget\n * is showing more items.\n * @property {string[]|function} [sortBy = ['isRefined', 'count:desc', 'name:asc']] How to sort refinements. Possible values: `count|isRefined|name:asc|name:desc`.\n * @property {boolean} [escapeFacetValues = true] Escapes the content of the facet values.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} RefinementListRenderingOptions\n * @property {RefinementListItem[]} items The list of filtering values returned from Algolia API.\n * @property {function(item.value): string} createURL Creates the next state url for a selected refinement.\n * @property {function(item.value)} refine Action to apply selected refinements.\n * @property {function} searchForItems Searches for values inside the list.\n * @property {boolean} isFromSearch `true` if the values are from an index search.\n * @property {boolean} canRefine `true` if a refinement can be applied.\n * @property {boolean} canToggleShowMore `true` if the toggleShowMore button can be activated (enough items to display more or\n * already displaying more than `limit` items)\n * @property {Object} widgetParams All original `CustomRefinementListWidgetOptions` forwarded to the `renderFn`.\n * @property {boolean} isShowingMore True if the menu is displaying all the menu items.\n * @property {function} toggleShowMore Toggles the number of values displayed between `limit` and `showMoreLimit`.\n */\n\n/**\n * **RefinementList** connector provides the logic to build a custom widget that will let the\n * user filter the results based on the values of a specific facet.\n *\n * This connector provides a `toggleShowMore()` function to display more or less items and a `refine()`\n * function to select an item.\n * @type {Connector}\n * @param {function(RefinementListRenderingOptions, boolean)} renderFn Rendering function for the custom **RefinementList** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomRefinementListWidgetOptions)} Re-usable widget factory for a custom **RefinementList** widget.\n * @example\n * // custom `renderFn` to render the custom RefinementList widget\n * function renderFn(RefinementListRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * RefinementListRenderingOptions.widgetParams.containerNode\n * .html('
        ')\n * }\n *\n * RefinementListRenderingOptions.widgetParams.containerNode\n * .find('li[data-refine-value]')\n * .each(function() { $(this).off('click'); });\n *\n * if (RefinementListRenderingOptions.canRefine) {\n * var list = RefinementListRenderingOptions.items.map(function(item) {\n * return `\n *
      • \n * \n * \n * ${item.label} (${item.count})\n * \n *
      • \n * `;\n * });\n *\n * RefinementListRenderingOptions.widgetParams.containerNode.find('ul').html(list);\n * RefinementListRenderingOptions.widgetParams.containerNode\n * .find('li[data-refine-value]')\n * .each(function() {\n * $(this).on('click', function(event) {\n * event.stopPropagation();\n * event.preventDefault();\n *\n * RefinementListRenderingOptions.refine($(this).data('refine-value'));\n * });\n * });\n * } else {\n * RefinementListRenderingOptions.widgetParams.containerNode.find('ul').html('');\n * }\n * }\n *\n * // connect `renderFn` to RefinementList logic\n * var customRefinementList = instantsearch.connectors.connectRefinementList(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customRefinementList({\n * containerNode: $('#custom-refinement-list-container'),\n * attribute: 'categories',\n * limit: 10,\n * })\n * );\n */\nexport default function connectRefinementList(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const {\n attribute,\n operator = 'or',\n limit = 10,\n showMore = false,\n showMoreLimit = 20,\n sortBy = ['isRefined', 'count:desc', 'name:asc'],\n escapeFacetValues = true,\n transformItems = items => items,\n } = widgetParams;\n\n if (!attribute) {\n throw new Error(withUsage('The `attribute` option is required.'));\n }\n\n if (!/^(and|or)$/.test(operator)) {\n throw new Error(\n withUsage(\n `The \\`operator\\` must one of: \\`\"and\"\\`, \\`\"or\"\\` (got \"${operator}\").`\n )\n );\n }\n\n if (showMore === true && showMoreLimit <= limit) {\n throw new Error(\n withUsage('`showMoreLimit` should be greater than `limit`.')\n );\n }\n\n const formatItems = ({ name: label, ...item }) => ({\n ...item,\n label,\n value: label,\n highlighted: label,\n });\n\n const render = ({\n items,\n state,\n createURL,\n helperSpecializedSearchFacetValues,\n refine,\n isFromSearch,\n isFirstSearch,\n isShowingMore,\n toggleShowMore,\n hasExhaustiveItems,\n instantSearchInstance,\n }) => {\n // Compute a specific createURL method able to link to any facet value state change\n const _createURL = facetValue =>\n createURL(state.toggleRefinement(attribute, facetValue));\n\n // Do not mistake searchForFacetValues and searchFacetValues which is the actual search\n // function\n const searchFacetValues =\n helperSpecializedSearchFacetValues &&\n helperSpecializedSearchFacetValues(\n state,\n createURL,\n helperSpecializedSearchFacetValues,\n refine,\n instantSearchInstance\n );\n\n renderFn(\n {\n createURL: _createURL,\n items,\n refine,\n searchForItems: searchFacetValues,\n instantSearchInstance,\n isFromSearch,\n canRefine: isFromSearch || items.length > 0,\n widgetParams,\n isShowingMore,\n canToggleShowMore: showMore && (isShowingMore || !hasExhaustiveItems),\n toggleShowMore,\n hasExhaustiveItems,\n },\n isFirstSearch\n );\n };\n\n let lastResultsFromMainSearch;\n let searchForFacetValues;\n let refine;\n\n const createSearchForFacetValues = helper => (\n state,\n createURL,\n helperSpecializedSearchFacetValues,\n toggleRefinement,\n instantSearchInstance\n ) => query => {\n if (query === '' && lastResultsFromMainSearch) {\n // render with previous data from the helper.\n render({\n items: lastResultsFromMainSearch,\n state,\n createURL,\n helperSpecializedSearchFacetValues,\n refine: toggleRefinement,\n isFromSearch: false,\n isFirstSearch: false,\n instantSearchInstance,\n hasExhaustiveItems: false, // SFFV should not be used with show more\n });\n } else {\n const tags = {\n highlightPreTag: escapeFacetValues\n ? TAG_PLACEHOLDER.highlightPreTag\n : TAG_REPLACEMENT.highlightPreTag,\n highlightPostTag: escapeFacetValues\n ? TAG_PLACEHOLDER.highlightPostTag\n : TAG_REPLACEMENT.highlightPostTag,\n };\n\n helper\n .searchForFacetValues(attribute, query, limit, tags)\n .then(results => {\n const facetValues = escapeFacetValues\n ? escapeFacets(results.facetHits)\n : results.facetHits;\n\n const normalizedFacetValues = transformItems(\n facetValues.map(({ value, ...item }) => ({\n ...item,\n value,\n label: value,\n }))\n );\n\n render({\n items: normalizedFacetValues,\n state,\n createURL,\n helperSpecializedSearchFacetValues,\n refine: toggleRefinement,\n isFromSearch: true,\n isFirstSearch: false,\n instantSearchInstance,\n hasExhaustiveItems: false, // SFFV should not be used with show more\n });\n });\n }\n };\n\n return {\n isShowingMore: false,\n\n // Provide the same function to the `renderFn` so that way the user\n // has to only bind it once when `isFirstRendering` for instance\n toggleShowMore() {},\n cachedToggleShowMore() {\n this.toggleShowMore();\n },\n\n createToggleShowMore(renderOptions) {\n return () => {\n this.isShowingMore = !this.isShowingMore;\n this.render(renderOptions);\n };\n },\n\n getLimit() {\n return this.isShowingMore ? showMoreLimit : limit;\n },\n\n getConfiguration: (configuration = {}) => {\n const widgetConfiguration = {\n [operator === 'and' ? 'facets' : 'disjunctiveFacets']: [attribute],\n };\n\n const currentMaxValuesPerFacet = configuration.maxValuesPerFacet || 0;\n\n widgetConfiguration.maxValuesPerFacet = Math.max(\n currentMaxValuesPerFacet,\n showMore ? showMoreLimit : limit\n );\n\n return widgetConfiguration;\n },\n\n init({ helper, createURL, instantSearchInstance }) {\n this.cachedToggleShowMore = this.cachedToggleShowMore.bind(this);\n\n refine = facetValue =>\n helper.toggleRefinement(attribute, facetValue).search();\n\n searchForFacetValues = createSearchForFacetValues(helper);\n\n render({\n items: [],\n state: helper.state,\n createURL,\n helperSpecializedSearchFacetValues: searchForFacetValues,\n refine,\n isFromSearch: false,\n isFirstSearch: true,\n instantSearchInstance,\n isShowingMore: this.isShowingMore,\n toggleShowMore: this.cachedToggleShowMore,\n hasExhaustiveItems: true,\n });\n },\n\n render(renderOptions) {\n const {\n results,\n state,\n createURL,\n instantSearchInstance,\n } = renderOptions;\n\n const facetValues = results.getFacetValues(attribute, { sortBy });\n const items = transformItems(\n facetValues.slice(0, this.getLimit()).map(formatItems)\n );\n\n const maxValuesPerFacetConfig = state.getQueryParameter(\n 'maxValuesPerFacet'\n );\n const currentLimit = this.getLimit();\n // If the limit is the max number of facet retrieved it is impossible to know\n // if the facets are exhaustive. The only moment we are sure it is exhaustive\n // is when it is strictly under the number requested unless we know that another\n // widget has requested more values (maxValuesPerFacet > getLimit()).\n // Because this is used for making the search of facets unable or not, it is important\n // to be conservative here.\n const hasExhaustiveItems =\n maxValuesPerFacetConfig > currentLimit\n ? facetValues.length <= currentLimit\n : facetValues.length < currentLimit;\n\n lastResultsFromMainSearch = items;\n\n this.toggleShowMore = this.createToggleShowMore(renderOptions);\n\n render({\n items,\n state,\n createURL,\n helperSpecializedSearchFacetValues: searchForFacetValues,\n refine,\n isFromSearch: false,\n isFirstSearch: false,\n instantSearchInstance,\n isShowingMore: this.isShowingMore,\n toggleShowMore: this.cachedToggleShowMore,\n hasExhaustiveItems,\n });\n },\n\n dispose({ state }) {\n unmountFn();\n\n if (operator === 'and') {\n return state.removeFacetRefinement(attribute).removeFacet(attribute);\n } else {\n return state\n .removeDisjunctiveFacetRefinement(attribute)\n .removeDisjunctiveFacet(attribute);\n }\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const values =\n operator === 'or'\n ? searchParameters.getDisjunctiveRefinements(attribute)\n : searchParameters.getConjunctiveRefinements(attribute);\n\n if (\n values.length === 0 ||\n (uiState.refinementList &&\n isEqual(values, uiState.refinementList[attribute]))\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n refinementList: {\n ...uiState.refinementList,\n [attribute]: values,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const values =\n uiState.refinementList && uiState.refinementList[attribute];\n if (values === undefined) return searchParameters;\n return values.reduce(\n (sp, v) =>\n operator === 'or'\n ? sp.addDisjunctiveFacetRefinement(attribute, v)\n : sp.addFacetRefinement(attribute, v),\n searchParameters.clearRefinements(attribute)\n );\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'search-box',\n connector: true,\n});\n\n/**\n * @typedef {Object} CustomSearchBoxWidgetOptions\n * @property {function(string, function(string))} [queryHook = undefined] A function that will be called every time\n * a new value for the query is set. The first parameter is the query and the second is a\n * function to actually trigger the search. The function takes the query as the parameter.\n *\n * This queryHook can be used to debounce the number of searches done from the searchBox.\n */\n\n/**\n * @typedef {Object} SearchBoxRenderingOptions\n * @property {string} query The query from the last search.\n * @property {function(string)} refine Sets a new query and searches.\n * @property {function()} clear Remove the query and perform search.\n * @property {Object} widgetParams All original `CustomSearchBoxWidgetOptions` forwarded to the `renderFn`.\n * @property {boolean} isSearchStalled `true` if the search results takes more than a certain time to come back\n * from Algolia servers. This can be configured on the InstantSearch constructor with the attribute\n * `stalledSearchDelay` which is 200ms, by default.\n */\n\n/**\n * **SearchBox** connector provides the logic to build a widget that will let the user search for a query.\n *\n * The connector provides to the rendering: `refine()` to set the query. The behaviour of this function\n * may be impacted by the `queryHook` widget parameter.\n * @type {Connector}\n * @param {function(SearchBoxRenderingOptions, boolean)} renderFn Rendering function for the custom **SearchBox** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomSearchBoxWidgetOptions)} Re-usable widget factory for a custom **SearchBox** widget.\n * @example\n * // custom `renderFn` to render the custom SearchBox widget\n * function renderFn(SearchBoxRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * SearchBoxRenderingOptions.widgetParams.containerNode.html('');\n * SearchBoxRenderingOptions.widgetParams.containerNode\n * .find('input')\n * .on('keyup', function() {\n * SearchBoxRenderingOptions.refine($(this).val());\n * });\n * SearchBoxRenderingOptions.widgetParams.containerNode\n * .find('input')\n * .val(SearchBoxRenderingOptions.query);\n * }\n * }\n *\n * // connect `renderFn` to SearchBox logic\n * var customSearchBox = instantsearch.connectors.connectSearchBox(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customSearchBox({\n * containerNode: $('#custom-searchbox'),\n * })\n * );\n */\nexport default function connectSearchBox(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { queryHook } = widgetParams;\n\n function clear(helper) {\n return function() {\n helper.setQuery('');\n helper.search();\n };\n }\n\n return {\n _clear() {},\n _cachedClear() {\n this._clear();\n },\n\n init({ helper, instantSearchInstance }) {\n this._cachedClear = this._cachedClear.bind(this);\n this._clear = clear(helper);\n\n this._refine = (() => {\n let previousQuery;\n\n const setQueryAndSearch = (q, doSearch = true) => {\n if (q !== helper.state.query) {\n previousQuery = helper.state.query;\n helper.setQuery(q);\n }\n if (doSearch && previousQuery !== undefined && previousQuery !== q)\n helper.search();\n };\n\n return queryHook\n ? q => queryHook(q, setQueryAndSearch)\n : setQueryAndSearch;\n })();\n\n renderFn(\n {\n query: helper.state.query,\n refine: this._refine,\n clear: this._cachedClear,\n widgetParams,\n instantSearchInstance,\n },\n true\n );\n },\n\n render({ helper, instantSearchInstance, searchMetadata }) {\n this._clear = clear(helper);\n\n renderFn(\n {\n query: helper.state.query,\n refine: this._refine,\n clear: this._cachedClear,\n widgetParams,\n instantSearchInstance,\n isSearchStalled: searchMetadata.isSearchStalled,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n return state.setQuery('');\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const query = searchParameters.query;\n\n if (query === '' || (uiState && uiState.query === query)) {\n return uiState;\n }\n\n return {\n ...uiState,\n query,\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n return searchParameters.setQuery(uiState.query || '');\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n find,\n warning,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'sort-by',\n connector: true,\n});\n\n/**\n * @typedef {Object} SortByItem\n * @property {string} value The name of the index to target.\n * @property {string} label The label of the index to display.\n */\n\n/**\n * @typedef {Object} CustomSortByWidgetOptions\n * @property {SortByItem[]} items Array of objects defining the different indices to choose from.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} SortByRenderingOptions\n * @property {string} currentRefinement The currently selected index.\n * @property {SortByItem[]} options All the available indices\n * @property {function(string)} refine Switches indices and triggers a new search.\n * @property {boolean} hasNoResults `true` if the last search contains no result.\n * @property {Object} widgetParams All original `CustomSortByWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * The **SortBy** connector provides the logic to build a custom widget that will display a\n * list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows\n * a user to change how the hits are being sorted.\n *\n * This connector provides the `refine` function that allows to switch indices.\n * The connector provides to the rendering: `refine()` to switch the current index and\n * `options` that are the values that can be selected. `refine` should be used\n * with `options.value`.\n * @type {Connector}\n * @param {function(SortByRenderingOptions, boolean)} renderFn Rendering function for the custom **SortBy** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomSortByWidgetOptions)} Re-usable widget factory for a custom **SortBy** widget.\n * @example\n * // custom `renderFn` to render the custom SortBy widget\n * function renderFn(SortByRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * SortByRenderingOptions.widgetParams.containerNode.html('');\n * SortByRenderingOptions.widgetParams.containerNode\n * .find('select')\n * .on('change', function(event) {\n * SortByRenderingOptions.refine(event.target.value);\n * });\n * }\n *\n * var optionsHTML = SortByRenderingOptions.options.map(function(option) {\n * return `\n * \n * ${option.label}\n * \n * `;\n * });\n *\n * SortByRenderingOptions.widgetParams.containerNode\n * .find('select')\n * .html(optionsHTML);\n * }\n *\n * // connect `renderFn` to SortBy logic\n * var customSortBy = instantsearch.connectors.connectSortBy(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customSortBy({\n * containerNode: $('#custom-sort-by-container'),\n * items: [\n * { value: 'instant_search', label: 'Most relevant' },\n * { value: 'instant_search_price_asc', label: 'Lowest price' },\n * { value: 'instant_search_price_desc', label: 'Highest price' },\n * ],\n * })\n * );\n */\nexport default function connectSortBy(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { items, transformItems = x => x } = widgetParams;\n\n if (!Array.isArray(items)) {\n throw new Error(\n withUsage('The `items` option expects an array of objects.')\n );\n }\n\n return {\n init({ helper, instantSearchInstance }) {\n const initialIndex = helper.state.index;\n const isInitialIndexInItems = find(\n items,\n item => item.value === initialIndex\n );\n\n this.initialIndex = initialIndex;\n this.setIndex = indexName => {\n helper.setIndex(indexName).search();\n };\n\n warning(\n isInitialIndexInItems,\n `The index named \"${initialIndex}\" is not listed in the \\`items\\` of \\`sortBy\\`.`\n );\n\n renderFn(\n {\n currentRefinement: initialIndex,\n options: transformItems(items),\n refine: this.setIndex,\n hasNoResults: true,\n widgetParams,\n instantSearchInstance,\n },\n true\n );\n },\n\n render({ helper, results, instantSearchInstance }) {\n renderFn(\n {\n currentRefinement: helper.state.index,\n options: transformItems(items),\n refine: this.setIndex,\n hasNoResults: results.nbHits === 0,\n widgetParams,\n instantSearchInstance,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n\n return state.setIndex(this.initialIndex);\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const currentIndex = searchParameters.getQueryParameter('index');\n const isInitialIndex = currentIndex === this.initialIndex;\n\n if (isInitialIndex || (uiState && uiState.sortBy === currentIndex)) {\n return uiState;\n }\n\n return {\n ...uiState,\n sortBy: searchParameters.getQueryParameter('index'),\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n return searchParameters.setQueryParameter(\n 'index',\n uiState.sortBy || this.initialIndex\n );\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'rating-menu',\n connector: true,\n});\n\n/**\n * @typedef {Object} StarRatingItems\n * @property {string} name Name corresponding to the number of stars.\n * @property {string} value Number of stars as string.\n * @property {number} count Count of matched results corresponding to the number of stars.\n * @property {boolean[]} stars Array of length of maximum rating value with stars to display or not.\n * @property {boolean} isRefined Indicates if star rating refinement is applied.\n */\n\n/**\n * @typedef {Object} CustomStarRatingWidgetOptions\n * @property {string} attribute Name of the attribute for faceting (eg. \"free_shipping\").\n * @property {number} [max = 5] The maximum rating value.\n */\n\n/**\n * @typedef {Object} StarRatingRenderingOptions\n * @property {StarRatingItems[]} items Possible star ratings the user can apply.\n * @property {function(string): string} createURL Creates an URL for the next\n * state (takes the item value as parameter). Takes the value of an item as parameter.\n * @property {function(string)} refine Selects a rating to filter the results\n * (takes the filter value as parameter). Takes the value of an item as parameter.\n * @property {boolean} hasNoResults `true` if the last search contains no result.\n * @property {Object} widgetParams All original `CustomStarRatingWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **StarRating** connector provides the logic to build a custom widget that will let\n * the user refine search results based on ratings.\n *\n * The connector provides to the rendering: `refine()` to select a value and\n * `items` that are the values that can be selected. `refine` should be used\n * with `items.value`.\n * @type {Connector}\n * @param {function(StarRatingRenderingOptions, boolean)} renderFn Rendering function for the custom **StarRating** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomStarRatingWidgetOptions)} Re-usable widget factory for a custom **StarRating** widget.\n * @example\n * // custom `renderFn` to render the custom StarRating widget\n * function renderFn(StarRatingRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) {\n * StarRatingRenderingOptions.widgetParams.containerNode.html('
          ');\n * }\n *\n * StarRatingRenderingOptions.widgetParams.containerNode\n * .find('li[data-refine-value]')\n * .each(function() { $(this).off('click'); });\n *\n * var listHTML = StarRatingRenderingOptions.items.map(function(item) {\n * return '
        • ' +\n * '' +\n * item.stars.map(function(star) { return star === false ? '☆' : '★'; }).join(' ') +\n * '& up (' + item.count + ')' +\n * '
        • ';\n * });\n *\n * StarRatingRenderingOptions.widgetParams.containerNode\n * .find('ul')\n * .html(listHTML);\n *\n * StarRatingRenderingOptions.widgetParams.containerNode\n * .find('li[data-refine-value]')\n * .each(function() {\n * $(this).on('click', function(event) {\n * event.preventDefault();\n * event.stopPropagation();\n *\n * StarRatingRenderingOptions.refine($(this).data('refine-value'));\n * });\n * });\n * }\n *\n * // connect `renderFn` to StarRating logic\n * var customStarRating = instantsearch.connectors.connectRatingMenu(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customStarRating({\n * containerNode: $('#custom-rating-menu-container'),\n * attribute: 'rating',\n * max: 5,\n * })\n * );\n */\nexport default function connectRatingMenu(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { attribute, max = 5 } = widgetParams;\n\n if (!attribute) {\n throw new Error(withUsage('The `attribute` option is required.'));\n }\n\n return {\n getConfiguration() {\n return { disjunctiveFacets: [attribute] };\n },\n\n init({ helper, createURL, instantSearchInstance }) {\n this._toggleRefinement = this._toggleRefinement.bind(this, helper);\n this._createURL = state => facetValue =>\n createURL(state.toggleRefinement(attribute, facetValue));\n\n renderFn(\n {\n instantSearchInstance,\n items: [],\n hasNoResults: true,\n refine: this._toggleRefinement,\n createURL: this._createURL(helper.state),\n widgetParams,\n },\n true\n );\n },\n\n render({ helper, results, state, instantSearchInstance }) {\n const facetValues = [];\n const allValues = {};\n for (let v = max; v >= 0; --v) {\n allValues[v] = 0;\n }\n results.getFacetValues(attribute).forEach(facet => {\n const val = Math.round(facet.name);\n if (!val || val > max) {\n return;\n }\n for (let v = val; v >= 1; --v) {\n allValues[v] += facet.count;\n }\n });\n const refinedStar = this._getRefinedStar(helper.state);\n for (let star = max - 1; star >= 1; --star) {\n const count = allValues[star];\n if (refinedStar && star !== refinedStar && count === 0) {\n // skip count==0 when at least 1 refinement is enabled\n // eslint-disable-next-line no-continue\n continue;\n }\n const stars = [];\n for (let i = 1; i <= max; ++i) {\n stars.push(i <= star);\n }\n facetValues.push({\n stars,\n name: String(star),\n value: String(star),\n count,\n isRefined: refinedStar === star,\n });\n }\n\n renderFn(\n {\n instantSearchInstance,\n items: facetValues,\n hasNoResults: results.nbHits === 0,\n refine: this._toggleRefinement,\n createURL: this._createURL(state),\n widgetParams,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n\n const nextState = state\n .removeDisjunctiveFacetRefinement(attribute)\n .removeDisjunctiveFacet(attribute);\n\n return nextState;\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const refinedStar = this._getRefinedStar(searchParameters);\n if (\n refinedStar === undefined ||\n (uiState &&\n uiState.ratingMenu &&\n uiState.ratingMenu[attribute] === refinedStar)\n )\n return uiState;\n return {\n ...uiState,\n ratingMenu: {\n ...uiState.ratingMenu,\n [attribute]: refinedStar,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const starRatingFromURL =\n uiState.ratingMenu && uiState.ratingMenu[attribute];\n const refinedStar = this._getRefinedStar(searchParameters);\n\n if (starRatingFromURL === refinedStar) return searchParameters;\n\n let clearedSearchParam = searchParameters.clearRefinements(attribute);\n\n if (starRatingFromURL !== undefined) {\n for (let val = Number(starRatingFromURL); val <= max; ++val) {\n clearedSearchParam = clearedSearchParam.addDisjunctiveFacetRefinement(\n attribute,\n val\n );\n }\n }\n\n return clearedSearchParam;\n },\n\n _toggleRefinement(helper, facetValue) {\n const isRefined =\n this._getRefinedStar(helper.state) === Number(facetValue);\n helper.clearRefinements(attribute);\n if (!isRefined) {\n for (let val = Number(facetValue); val <= max; ++val) {\n helper.addDisjunctiveFacetRefinement(attribute, val);\n }\n }\n helper.search();\n },\n\n _getRefinedStar(searchParameters) {\n let refinedStar = undefined;\n const refinements = searchParameters.getDisjunctiveRefinements(\n attribute\n );\n refinements.forEach(r => {\n if (!refinedStar || Number(r) < refinedStar) {\n refinedStar = Number(r);\n }\n });\n return refinedStar;\n },\n };\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'stats',\n connector: true,\n});\n\n/**\n * @typedef {Object} StatsRenderingOptions\n * @property {number} hitsPerPage The maximum number of hits per page returned by Algolia.\n * @property {number} nbHits The number of hits in the result set.\n * @property {number} nbPages The number of pages computed for the result set.\n * @property {number} page The current page.\n * @property {number} processingTimeMS The time taken to compute the results inside the Algolia engine.\n * @property {string} query The query used for the current search.\n * @property {object} widgetParams All original `CustomStatsWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **Stats** connector provides the logic to build a custom widget that will displays\n * search statistics (hits number and processing time).\n *\n * @type {Connector}\n * @param {function(StatsRenderingOptions, boolean)} renderFn Rendering function for the custom **Stats** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function} Re-usable widget factory for a custom **Stats** widget.\n * @example\n * // custom `renderFn` to render the custom Stats widget\n * function renderFn(StatsRenderingOptions, isFirstRendering) {\n * if (isFirstRendering) return;\n *\n * StatsRenderingOptions.widgetParams.containerNode\n * .html(StatsRenderingOptions.nbHits + ' results found in ' + StatsRenderingOptions.processingTimeMS);\n * }\n *\n * // connect `renderFn` to Stats logic\n * var customStatsWidget = instantsearch.connectors.connectStats(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customStatsWidget({\n * containerNode: $('#custom-stats-container'),\n * })\n * );\n */\nexport default function connectStats(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => ({\n init({ helper, instantSearchInstance }) {\n renderFn(\n {\n instantSearchInstance,\n hitsPerPage: helper.state.hitsPerPage,\n nbHits: 0,\n nbPages: 0,\n page: helper.state.page,\n processingTimeMS: -1,\n query: helper.state.query,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, instantSearchInstance }) {\n renderFn(\n {\n instantSearchInstance,\n hitsPerPage: results.hitsPerPage,\n nbHits: results.nbHits,\n nbPages: results.nbPages,\n page: results.page,\n processingTimeMS: results.processingTimeMS,\n query: results.query,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n });\n}\n","import {\n checkRendering,\n escapeRefinement,\n unescapeRefinement,\n createDocumentationMessageGenerator,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'toggle-refinement',\n connector: true,\n});\n\n/**\n * @typedef {Object} ToggleValue\n * @property {boolean} isRefined `true` if the toggle is on.\n * @property {number} count Number of results matched after applying the toggle refinement.\n * @property {Object} onFacetValue Value of the toggle when it's on.\n * @property {Object} offFacetValue Value of the toggle when it's off.\n */\n\n/**\n * @typedef {Object} CustomToggleWidgetOptions\n * @property {string} attribute Name of the attribute for faceting (eg. \"free_shipping\").\n * @property {Object} [on = true] Value to filter on when toggled.\n * @property {Object} [off] Value to filter on when not toggled.\n */\n\n/**\n * @typedef {Object} ToggleRenderingOptions\n * @property {ToggleValue} value The current toggle value.\n * @property {function():string} createURL Creates an URL for the next state.\n * @property {function(value)} refine Updates to the next state by applying the toggle refinement.\n * @property {Object} widgetParams All original `CustomToggleWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **Toggle** connector provides the logic to build a custom widget that will provide\n * an on/off filtering feature based on an attribute value or values.\n *\n * Two modes are implemented in the custom widget:\n * - with or without the value filtered\n * - switch between two values.\n *\n * @type {Connector}\n * @param {function(ToggleRenderingOptions, boolean)} renderFn Rendering function for the custom **Toggle** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomToggleWidgetOptions)} Re-usable widget factory for a custom **Toggle** widget.\n * @example\n * // custom `renderFn` to render the custom ClearAll widget\n * function renderFn(ToggleRenderingOptions, isFirstRendering) {\n * ToggleRenderingOptions.widgetParams.containerNode\n * .find('a')\n * .off('click');\n *\n * var buttonHTML = `\n * \n * \n * ${ToggleRenderingOptions.value.name} (${ToggleRenderingOptions.value.count})\n * \n * `;\n *\n * ToggleRenderingOptions.widgetParams.containerNode.html(buttonHTML);\n * ToggleRenderingOptions.widgetParams.containerNode\n * .find('a')\n * .on('click', function(event) {\n * event.preventDefault();\n * event.stopPropagation();\n *\n * ToggleRenderingOptions.refine(ToggleRenderingOptions.value);\n * });\n * }\n *\n * // connect `renderFn` to Toggle logic\n * var customToggle = instantsearch.connectors.connectToggleRefinement(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customToggle({\n * containerNode: $('#custom-toggle-container'),\n * attribute: 'free_shipping',\n * })\n * );\n */\nexport default function connectToggleRefinement(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { attribute, on: userOn = true, off: userOff } = widgetParams;\n\n if (!attribute) {\n throw new Error(withUsage('The `attribute` option is required.'));\n }\n\n const hasAnOffValue = userOff !== undefined;\n const hasAnOnValue = userOn !== undefined;\n const on = hasAnOnValue ? escapeRefinement(userOn) : undefined;\n const off = hasAnOffValue ? escapeRefinement(userOff) : undefined;\n\n return {\n getConfiguration() {\n return {\n disjunctiveFacets: [attribute],\n };\n },\n\n _toggleRefinement(helper, { isRefined } = {}) {\n // Checking\n if (!isRefined) {\n if (hasAnOffValue) {\n helper.removeDisjunctiveFacetRefinement(attribute, off);\n }\n helper.addDisjunctiveFacetRefinement(attribute, on);\n } else {\n // Unchecking\n helper.removeDisjunctiveFacetRefinement(attribute, on);\n if (hasAnOffValue) {\n helper.addDisjunctiveFacetRefinement(attribute, off);\n }\n }\n\n helper.search();\n },\n\n init({ state, helper, createURL, instantSearchInstance }) {\n this._createURL = isCurrentlyRefined => () =>\n createURL(\n state\n .removeDisjunctiveFacetRefinement(\n attribute,\n isCurrentlyRefined ? on : off\n )\n .addDisjunctiveFacetRefinement(\n attribute,\n isCurrentlyRefined ? off : on\n )\n );\n\n this.toggleRefinement = opts => {\n this._toggleRefinement(helper, opts);\n };\n\n const isRefined = state.isDisjunctiveFacetRefined(attribute, on);\n\n // no need to refine anything at init if no custom off values\n if (hasAnOffValue) {\n // Add filtering on the 'off' value if set\n if (!isRefined) {\n const currentPage = helper.getPage();\n helper\n .addDisjunctiveFacetRefinement(attribute, off)\n .setPage(currentPage);\n }\n }\n\n const onFacetValue = {\n isRefined,\n count: 0,\n };\n\n const offFacetValue = {\n isRefined: hasAnOffValue && !isRefined,\n count: 0,\n };\n\n const value = {\n name: attribute,\n isRefined,\n count: null,\n onFacetValue,\n offFacetValue,\n };\n\n renderFn(\n {\n value,\n createURL: this._createURL(value.isRefined),\n refine: this.toggleRefinement,\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ helper, results, state, instantSearchInstance }) {\n const isRefined = helper.state.isDisjunctiveFacetRefined(attribute, on);\n const offValue = off === undefined ? false : off;\n const allFacetValues = results.getFacetValues(attribute);\n\n const onData = find(\n allFacetValues,\n ({ name }) => name === unescapeRefinement(on)\n );\n const onFacetValue = {\n isRefined: onData !== undefined ? onData.isRefined : false,\n count: onData === undefined ? null : onData.count,\n };\n\n const offData = hasAnOffValue\n ? find(\n allFacetValues,\n ({ name }) => name === unescapeRefinement(offValue)\n )\n : undefined;\n const offFacetValue = {\n isRefined: offData !== undefined ? offData.isRefined : false,\n count:\n offData === undefined\n ? allFacetValues.reduce((total, { count }) => total + count, 0)\n : offData.count,\n };\n\n // what will we show by default,\n // if checkbox is not checked, show: [ ] free shipping (countWhenChecked)\n // if checkbox is checked, show: [x] free shipping (countWhenNotChecked)\n const nextRefinement = isRefined ? offFacetValue : onFacetValue;\n\n const value = {\n name: attribute,\n isRefined,\n count: nextRefinement === undefined ? null : nextRefinement.count,\n onFacetValue,\n offFacetValue,\n };\n\n renderFn(\n {\n value,\n state,\n createURL: this._createURL(value.isRefined),\n refine: this.toggleRefinement,\n helper,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n\n const nextState = state\n .removeDisjunctiveFacetRefinement(attribute)\n .removeDisjunctiveFacet(attribute);\n\n return nextState;\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const isRefined = searchParameters.isDisjunctiveFacetRefined(\n attribute,\n on\n );\n\n if (\n !isRefined ||\n (uiState && uiState.toggle && uiState.toggle[attribute] === isRefined)\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n toggle: {\n ...uiState.toggle,\n [attribute]: isRefined,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n const isRefined = Boolean(uiState.toggle && uiState.toggle[attribute]);\n\n if (isRefined) {\n if (hasAnOffValue)\n return searchParameters\n .removeDisjunctiveFacetRefinement(attribute, off)\n .addDisjunctiveFacetRefinement(attribute, on);\n\n return searchParameters.addDisjunctiveFacetRefinement(attribute, on);\n }\n\n if (hasAnOffValue)\n return searchParameters\n .removeDisjunctiveFacetRefinement(attribute, on)\n .addDisjunctiveFacetRefinement(attribute, off);\n\n return searchParameters.removeDisjunctiveFacetRefinement(attribute, on);\n },\n };\n };\n}\n","import {\n checkRendering,\n warning,\n createDocumentationMessageGenerator,\n isEqual,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'breadcrumb',\n connector: true,\n});\n\n/**\n * @typedef {Object} BreadcrumbItem\n * @property {string} label Label of the category or subcategory.\n * @property {string} value Value of breadcrumb item.\n */\n\n/**\n * @typedef {Object} CustomBreadcrumbWidgetOptions\n * @property {string[]} attributes Attributes to use to generate the hierarchy of the breadcrumb.\n * @property {string} [rootPath = null] Prefix path to use if the first level is not the root level.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n *\n * You can also use a sort function that behaves like the standard Javascript [compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Syntax).\n */\n\n/**\n * @typedef {Object} BreadcrumbRenderingOptions\n * @property {function(item.value): string} createURL Creates an url for the next state for a clicked item. The special value `null` is used for the `Home` (or root) item of the breadcrumb and will return an empty array.\n * @property {BreadcrumbItem[]} items Values to be rendered.\n * @property {function(item.value)} refine Sets the path of the hierarchical filter and triggers a new search.\n * @property {Object} widgetParams All original `CustomBreadcrumbWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **Breadcrumb** connector provides the logic to build a custom widget\n * that will give the user the ability to see the current path in a hierarchical facet.\n *\n * This is commonly used in websites that have a large amount of content organized in a hierarchical manner (usually e-commerce websites).\n * @type {Connector}\n * @param {function(BreadcrumbRenderingOptions, boolean)} renderFn Rendering function for the custom **Breadcrumb* widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomBreadcrumbWidgetOptions)} Re-usable widget factory for a custom **Breadcrumb** widget.\n */\nexport default function connectBreadcrumb(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n return (widgetParams = {}) => {\n const {\n attributes,\n separator = ' > ',\n rootPath = null,\n transformItems = items => items,\n } = widgetParams;\n\n if (!attributes || !Array.isArray(attributes) || attributes.length === 0) {\n throw new Error(\n withUsage('The `attributes` option expects an array of strings.')\n );\n }\n\n const [hierarchicalFacetName] = attributes;\n\n return {\n getConfiguration: currentConfiguration => {\n if (currentConfiguration.hierarchicalFacets) {\n const isFacetSet = find(\n currentConfiguration.hierarchicalFacets,\n ({ name }) => name === hierarchicalFacetName\n );\n if (isFacetSet) {\n warning(\n isEqual(isFacetSet.attributes, attributes) &&\n isFacetSet.separator === separator,\n 'Using Breadcrumb and HierarchicalMenu on the same facet with different options overrides the configuration of the HierarchicalMenu.'\n );\n return {};\n }\n }\n\n return {\n hierarchicalFacets: [\n {\n attributes,\n name: hierarchicalFacetName,\n separator,\n rootPath,\n },\n ],\n };\n },\n\n init({ createURL, helper, instantSearchInstance }) {\n this._createURL = facetValue => {\n if (!facetValue) {\n const breadcrumb = helper.getHierarchicalFacetBreadcrumb(\n hierarchicalFacetName\n );\n if (breadcrumb.length > 0) {\n return createURL(\n helper.state.toggleRefinement(\n hierarchicalFacetName,\n breadcrumb[0]\n )\n );\n }\n }\n return createURL(\n helper.state.toggleRefinement(hierarchicalFacetName, facetValue)\n );\n };\n\n this._refine = function(facetValue) {\n if (!facetValue) {\n const breadcrumb = helper.getHierarchicalFacetBreadcrumb(\n hierarchicalFacetName\n );\n if (breadcrumb.length > 0) {\n helper\n .toggleRefinement(hierarchicalFacetName, breadcrumb[0])\n .search();\n }\n } else {\n helper.toggleRefinement(hierarchicalFacetName, facetValue).search();\n }\n };\n\n renderFn(\n {\n createURL: this._createURL,\n canRefine: false,\n instantSearchInstance,\n items: [],\n refine: this._refine,\n widgetParams,\n },\n true\n );\n },\n\n render({ instantSearchInstance, results, state }) {\n const [{ name: facetName }] = state.hierarchicalFacets;\n\n const facetValues = results.getFacetValues(facetName);\n const data = Array.isArray(facetValues.data) ? facetValues.data : [];\n const items = transformItems(shiftItemsValues(prepareItems(data)));\n\n renderFn(\n {\n canRefine: items.length > 0,\n createURL: this._createURL,\n instantSearchInstance,\n items,\n refine: this._refine,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n };\n };\n}\n\nfunction prepareItems(data) {\n return data.reduce((result, currentItem) => {\n if (currentItem.isRefined) {\n result.push({\n label: currentItem.name,\n value: currentItem.path,\n });\n if (Array.isArray(currentItem.data)) {\n result = result.concat(prepareItems(currentItem.data));\n }\n }\n return result;\n }, []);\n}\n\nfunction shiftItemsValues(array) {\n return array.map((x, idx) => ({\n label: x.label,\n value: idx + 1 === array.length ? null : array[idx + 1].value,\n }));\n}\n","import {\n checkRendering,\n warning,\n aroundLatLngToPosition,\n insideBoundingBoxToBoundingBox,\n createDocumentationMessageGenerator,\n noop,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'geo-search',\n connector: true,\n});\n\n/**\n * @typedef {Object} LatLng\n * @property {number} lat The latitude in degrees.\n * @property {number} lng The longitude in degrees.\n */\n\n/**\n * @typedef {Object} Bounds\n * @property {LatLng} northEast The top right corner of the map view.\n * @property {LatLng} southWest The bottom left corner of the map view.\n */\n\n/**\n * @typedef {Object} CustomGeoSearchWidgetOptions\n * @property {boolean} [enableRefineOnMapMove=true] If true, refine will be triggered as you move the map.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * @typedef {Object} GeoSearchRenderingOptions\n * @property {Object[]} items The matched hits from Algolia API.\n * @property {LatLng} position The current position of the search.\n * @property {Bounds} currentRefinement The current bounding box of the search.\n * @property {function(Bounds)} refine Sets a bounding box to filter the results from the given map bounds.\n * @property {function()} clearMapRefinement Reset the current bounding box refinement.\n * @property {function(): boolean} isRefinedWithMap Return true if the current refinement is set with the map bounds.\n * @property {function()} toggleRefineOnMapMove Toggle the fact that the user is able to refine on map move.\n * @property {function(): boolean} isRefineOnMapMove Return true if the user is able to refine on map move.\n * @property {function()} setMapMoveSinceLastRefine Set the fact that the map has moved since the last refinement, should be call on each map move. The call to the function triggers a new rendering only when the value change.\n * @property {function(): boolean} hasMapMoveSinceLastRefine Return true if the map has move since the last refinement.\n * @property {Object} widgetParams All original `CustomGeoSearchWidgetOptions` forwarded to the `renderFn`.\n * @property {LatLng} [position] The current position of the search.\n */\n\n/**\n * The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example).\n *\n * @requirements\n *\n * Note that the GeoSearch connector uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia. Your hits **must** have a `_geoloc` attribute in order to be passed to the rendering function.\n *\n * Currently, the feature is not compatible with multiple values in the _geoloc attribute.\n *\n * @type {Connector}\n * @param {function(GeoSearchRenderingOptions, boolean)} renderFn Rendering function for the custom **GeoSearch** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomGeoSearchWidgetOptions)} Re-usable widget factory for a custom **GeoSearch** widget.\n * @staticExample\n * // This example use Leaflet for the rendering, be sure to have the library correctly setup\n * // before trying the demo. You can find more details in their documentation (link below).\n * // We choose Leaflet for the example but you can use any libraries that you want.\n * // See: http://leafletjs.com/examples/quick-start\n *\n * let map = null;\n * let markers = [];\n *\n * // custom `renderFn` to render the custom GeoSearch widget\n * function renderFn(GeoSearchRenderingOptions, isFirstRendering) {\n * const { items, widgetParams } = GeoSearchRenderingOptions;\n *\n * if (isFirstRendering) {\n * map = L.map(widgetParams.container);\n *\n * L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n * attribution:\n * '© OpenStreetMap contributors',\n * }).addTo(map);\n * }\n *\n * markers.forEach(marker => marker.remove());\n *\n * markers = items.map(({ _geoloc }) =>\n * L.marker([_geoloc.lat, _geoloc.lng]).addTo(map)\n * );\n *\n * if (markers.length) {\n * map.fitBounds(L.featureGroup(markers).getBounds());\n * }\n * }\n *\n * // connect `renderFn` to GeoSearch logic\n * const customGeoSearch = instantsearch.connectors.connectGeoSearch(renderFn);\n *\n * // mount widget on the page\n * search.addWidget(\n * customGeoSearch({\n * container: document.getElementById('custom-geo-search'),\n * })\n * );\n */\nconst connectGeoSearch = (renderFn, unmountFn) => {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const {\n enableRefineOnMapMove = true,\n transformItems = items => items,\n } = widgetParams;\n\n // Always trigger this message because the default value was `true`. We can't\n // display the message only when the parameter is defined otherwise a user that was\n // relying on the default value won't have any information about the changes.\n warning(\n false,\n `\nThe option \\`enableGeolocationWithIP\\` has been removed from the GeoSearch widget.\nPlease consider using the \\`Configure\\` widget instead:\n\nsearch.addWidget(\n configure({\n aroundLatLngViaIP: ${widgetParams.enableGeolocationWithIP || 'true'},\n })\n);\n\nYou can find more information inside the migration guide:\nhttp://community.algolia.com/instantsearch.js/migration-guide\n `\n );\n\n warning(\n typeof widgetParams.position === 'undefined',\n `\nThe option \\`position\\` has been removed from the GeoSearch widget.\nPlease consider using the \\`Configure\\` widget instead:\n\nsearch.addWidget(\n configure({\n aroundLatLng: '${widgetParams.position &&\n widgetParams.position.lat}, ${widgetParams.position &&\n widgetParams.position.lng}',\n })\n);\n\nYou can find more information inside the migration guide:\nhttp://community.algolia.com/instantsearch.js/migration-guide\n `\n );\n\n warning(\n typeof widgetParams.radius === 'undefined',\n `\nThe option \\`radius\\` has been removed from the GeoSearch widget.\nPlease consider using the \\`Configure\\` widget instead:\n\nsearch.addWidget(\n configure({\n aroundRadius: ${widgetParams.radius},\n })\n);\n\nYou can find more information inside the migration guide:\n\nhttp://community.algolia.com/instantsearch.js/migration-guide\n `\n );\n\n warning(\n typeof widgetParams.precision === 'undefined',\n `\nThe option \\`precision\\` has been removed from the GeoSearch widget.\nPlease consider using the \\`Configure\\` widget instead:\n\nsearch.addWidget(\n configure({\n aroundPrecision: ${widgetParams.precision},\n })\n);\n\nYou can find more information inside the migration guide:\n\nhttp://community.algolia.com/instantsearch.js/migration-guide\n `\n );\n\n const widgetState = {\n isRefineOnMapMove: enableRefineOnMapMove,\n hasMapMoveSinceLastRefine: false,\n lastRefinePosition: '',\n lastRefineBoundingBox: '',\n internalToggleRefineOnMapMove: noop,\n internalSetMapMoveSinceLastRefine: noop,\n };\n\n const getPositionFromState = state =>\n state.aroundLatLng && aroundLatLngToPosition(state.aroundLatLng);\n\n const getCurrentRefinementFromState = state =>\n state.insideBoundingBox &&\n insideBoundingBoxToBoundingBox(state.insideBoundingBox);\n\n const refine = helper => ({ northEast: ne, southWest: sw }) => {\n const boundingBox = [ne.lat, ne.lng, sw.lat, sw.lng].join();\n\n helper.setQueryParameter('insideBoundingBox', boundingBox).search();\n\n widgetState.hasMapMoveSinceLastRefine = false;\n widgetState.lastRefineBoundingBox = boundingBox;\n };\n\n const clearMapRefinement = helper => () => {\n helper.setQueryParameter('insideBoundingBox').search();\n };\n\n const isRefinedWithMap = state => () => Boolean(state.insideBoundingBox);\n\n const toggleRefineOnMapMove = () =>\n widgetState.internalToggleRefineOnMapMove();\n const createInternalToggleRefinementOnMapMove = (render, args) => () => {\n widgetState.isRefineOnMapMove = !widgetState.isRefineOnMapMove;\n\n render(args);\n };\n\n const isRefineOnMapMove = () => widgetState.isRefineOnMapMove;\n\n const setMapMoveSinceLastRefine = () =>\n widgetState.internalSetMapMoveSinceLastRefine();\n const createInternalSetMapMoveSinceLastRefine = (render, args) => () => {\n const shouldTriggerRender =\n widgetState.hasMapMoveSinceLastRefine !== true;\n\n widgetState.hasMapMoveSinceLastRefine = true;\n\n if (shouldTriggerRender) {\n render(args);\n }\n };\n\n const hasMapMoveSinceLastRefine = () =>\n widgetState.hasMapMoveSinceLastRefine;\n\n const init = initArgs => {\n const { state, helper, instantSearchInstance } = initArgs;\n const isFirstRendering = true;\n\n widgetState.internalToggleRefineOnMapMove = createInternalToggleRefinementOnMapMove(\n noop,\n initArgs\n );\n\n widgetState.internalSetMapMoveSinceLastRefine = createInternalSetMapMoveSinceLastRefine(\n noop,\n initArgs\n );\n\n renderFn(\n {\n items: [],\n position: getPositionFromState(state),\n currentRefinement: getCurrentRefinementFromState(state),\n refine: refine(helper),\n clearMapRefinement: clearMapRefinement(helper),\n isRefinedWithMap: isRefinedWithMap(state),\n toggleRefineOnMapMove,\n isRefineOnMapMove,\n setMapMoveSinceLastRefine,\n hasMapMoveSinceLastRefine,\n widgetParams,\n instantSearchInstance,\n },\n isFirstRendering\n );\n };\n\n const render = renderArgs => {\n const { results, helper, instantSearchInstance } = renderArgs;\n const isFirstRendering = false;\n // We don't use the state provided by the render function because we need\n // to be sure that the state is the latest one for the following condition\n const state = helper.state;\n\n const positionChangedSinceLastRefine =\n Boolean(state.aroundLatLng) &&\n Boolean(widgetState.lastRefinePosition) &&\n state.aroundLatLng !== widgetState.lastRefinePosition;\n\n const boundingBoxChangedSinceLastRefine =\n !state.insideBoundingBox &&\n Boolean(widgetState.lastRefineBoundingBox) &&\n state.insideBoundingBox !== widgetState.lastRefineBoundingBox;\n\n if (positionChangedSinceLastRefine || boundingBoxChangedSinceLastRefine) {\n widgetState.hasMapMoveSinceLastRefine = false;\n }\n\n widgetState.lastRefinePosition = state.aroundLatLng || '';\n widgetState.lastRefineBoundingBox = state.insideBoundingBox || '';\n\n widgetState.internalToggleRefineOnMapMove = createInternalToggleRefinementOnMapMove(\n render,\n renderArgs\n );\n\n widgetState.internalSetMapMoveSinceLastRefine = createInternalSetMapMoveSinceLastRefine(\n render,\n renderArgs\n );\n\n const items = transformItems(results.hits.filter(hit => hit._geoloc));\n\n renderFn(\n {\n items,\n position: getPositionFromState(state),\n currentRefinement: getCurrentRefinementFromState(state),\n refine: refine(helper),\n clearMapRefinement: clearMapRefinement(helper),\n isRefinedWithMap: isRefinedWithMap(state),\n toggleRefineOnMapMove,\n isRefineOnMapMove,\n setMapMoveSinceLastRefine,\n hasMapMoveSinceLastRefine,\n widgetParams,\n instantSearchInstance,\n },\n isFirstRendering\n );\n };\n\n return {\n init,\n render,\n\n dispose({ state }) {\n unmountFn();\n\n return state.setQueryParameter('insideBoundingBox');\n },\n\n getWidgetState(uiState, { searchParameters }) {\n const boundingBox = searchParameters.insideBoundingBox;\n\n if (\n !boundingBox ||\n (uiState &&\n uiState.geoSearch &&\n uiState.geoSearch.boundingBox === boundingBox)\n ) {\n return uiState;\n }\n\n return {\n ...uiState,\n geoSearch: {\n boundingBox,\n },\n };\n },\n\n getWidgetSearchParameters(searchParameters, { uiState }) {\n if (!uiState || !uiState.geoSearch) {\n return searchParameters.setQueryParameter('insideBoundingBox');\n }\n\n return searchParameters.setQueryParameter(\n 'insideBoundingBox',\n uiState.geoSearch.boundingBox\n );\n },\n };\n };\n};\n\nexport default connectGeoSearch;\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'powered-by',\n connector: true,\n});\n\n/**\n * @typedef {Object} PoweredByWidgetOptions\n * @property {string} [theme] The theme of the logo (\"light\" or \"dark\").\n * @property {string} [url] The URL to redirect to.\n */\n\n/**\n * @typedef {Object} PoweredByRenderingOptions\n * @property {Object} widgetParams All original `PoweredByWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * **PoweredBy** connector provides the logic to build a custom widget that will displays\n * the logo to redirect to Algolia.\n *\n * @type {Connector}\n * @param {function(PoweredByRenderingOptions, boolean)} renderFn Rendering function for the custom **PoweredBy** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function} Re-usable widget factory for a custom **PoweredBy** widget.\n */\nexport default function connectPoweredBy(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n const defaultUrl =\n 'https://www.algolia.com/?' +\n 'utm_source=instantsearch.js&' +\n 'utm_medium=website&' +\n `utm_content=${\n typeof window !== 'undefined' && window.location\n ? window.location.hostname\n : ''\n }&` +\n 'utm_campaign=poweredby';\n\n return (widgetParams = {}) => {\n const { url = defaultUrl } = widgetParams;\n\n return {\n init() {\n renderFn(\n {\n url,\n widgetParams,\n },\n true\n );\n },\n\n render() {\n renderFn(\n {\n url,\n widgetParams,\n },\n false\n );\n },\n\n dispose() {\n unmountFn();\n },\n };\n };\n}\n","import {\n createDocumentationMessageGenerator,\n noop,\n isPlainObject,\n} from '../../lib/utils';\nimport { enhanceConfiguration } from '../../lib/InstantSearch';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'configure',\n connector: true,\n});\n\n/**\n * @typedef {Object} CustomConfigureWidgetOptions\n * @property {Object} searchParameters The Configure widget options are search parameters\n */\n\n/**\n * @typedef {Object} ConfigureRenderingOptions\n * @property {function(searchParameters: Object)} refine Sets new `searchParameters` and trigger a search.\n * @property {Object} widgetParams All original `CustomConfigureWidgetOptions` forwarded to the `renderFn`.\n */\n\n/**\n * The **Configure** connector provides the logic to build a custom widget\n * that will give you ability to override or force some search parameters sent to Algolia API.\n *\n * @type {Connector}\n * @param {function(ConfigureRenderingOptions)} renderFn Rendering function for the custom **Configure** Widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomConfigureWidgetOptions)} Re-usable widget factory for a custom **Configure** widget.\n */\nexport default function connectConfigure(renderFn = noop, unmountFn = noop) {\n return (widgetParams = {}) => {\n if (!isPlainObject(widgetParams.searchParameters)) {\n throw new Error(\n withUsage('The `searchParameters` option expects an object.')\n );\n }\n\n return {\n getConfiguration() {\n return widgetParams.searchParameters;\n },\n\n init({ helper }) {\n this._refine = this.refine(helper);\n\n renderFn(\n {\n refine: this._refine,\n widgetParams,\n },\n true\n );\n },\n\n refine(helper) {\n return searchParameters => {\n // merge new `searchParameters` with the ones set from other widgets\n const actualState = this.removeSearchParameters(helper.state);\n const nextSearchParameters = enhanceConfiguration(\n { ...actualState },\n {\n getConfiguration: () => searchParameters,\n }\n );\n\n // trigger a search with the new merged searchParameters\n helper.setState(nextSearchParameters).search();\n\n // update original `widgetParams.searchParameters` to the new refined one\n widgetParams.searchParameters = searchParameters;\n };\n },\n\n render() {\n renderFn(\n {\n refine: this._refine,\n widgetParams,\n },\n false\n );\n },\n\n dispose({ state }) {\n unmountFn();\n\n return this.removeSearchParameters(state);\n },\n\n removeSearchParameters(state) {\n // widgetParams are assumed 'controlled',\n // so they override whatever other widgets give the state\n return state.mutateMe(mutableState => {\n Object.keys(widgetParams.searchParameters).forEach(key => {\n delete mutableState[key];\n });\n });\n },\n };\n };\n}\n","import escapeHits, { TAG_PLACEHOLDER } from '../../lib/escape-highlight';\nimport {\n checkRendering,\n createDocumentationMessageGenerator,\n find,\n} from '../../lib/utils';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'autocomplete',\n connector: true,\n});\n\n/**\n * @typedef {Object} Index\n * @property {string} index Name of the index.\n * @property {string} label Label of the index (for display purpose).\n * @property {Object[]} hits The hits resolved from the index matching the query.\n * @property {Object} results The full results object from Algolia API.\n */\n\n/**\n * @typedef {Object} AutocompleteRenderingOptions\n * @property {Index[]} indices The indices you provided with their hits and results and the main index as first position.\n * @property {function(string)} refine Search into the indices with the query provided.\n * @property {string} currentRefinement The actual value of the query.\n * @property {Object} widgetParams All original widget options forwarded to the `renderFn`.\n */\n\n/**\n * @typedef {Object} CustomAutocompleteWidgetOptions\n * @property {{value: string, label: string}[]} [indices = []] Name of the others indices to search into.\n * @property {boolean} [escapeHTML = true] If true, escape HTML tags from `hits[i]._highlightResult`.\n */\n\n/**\n * **Autocomplete** connector provides the logic to build a widget that will give the user the ability to search into multiple indices.\n *\n * This connector provides a `refine()` function to search for a query and a `currentRefinement` as the current query used to search.\n * @type {Connector}\n * @param {function(AutocompleteRenderingOptions, boolean)} renderFn Rendering function for the custom **Autocomplete** widget.\n * @param {function} unmountFn Unmount function called when the widget is disposed.\n * @return {function(CustomAutocompleteWidgetOptions)} Re-usable widget factory for a custom **Autocomplete** widget.\n */\nexport default function connectAutocomplete(renderFn, unmountFn) {\n checkRendering(renderFn, withUsage());\n\n return (widgetParams = {}) => {\n const { escapeHTML = true, indices = [] } = widgetParams;\n\n // user passed a wrong `indices` option type\n if (!Array.isArray(indices)) {\n throw new Error(\n withUsage('The `indices` option expects an array of objects.')\n );\n }\n\n return {\n getConfiguration() {\n return escapeHTML ? TAG_PLACEHOLDER : undefined;\n },\n\n init({ instantSearchInstance, helper }) {\n this._refine = this.refine(helper);\n\n this.indices = [\n {\n helper,\n label: 'primary',\n index: helper.getIndex(),\n results: undefined,\n hits: [],\n },\n ];\n\n // add additionnal indices into `this.indices`\n indices.forEach(({ label, value }) => {\n const derivedHelper = helper.derive(searchParameters =>\n searchParameters.setIndex(value)\n );\n\n this.indices.push({\n label,\n index: value,\n helper: derivedHelper,\n results: undefined,\n hits: [],\n });\n\n // update results then trigger render after a search from any helper\n derivedHelper.on('result', results =>\n this.saveResults({ results, label })\n );\n });\n\n this.instantSearchInstance = instantSearchInstance;\n this.renderWithAllIndices({ isFirstRendering: true });\n },\n\n saveResults({ results, label }) {\n const derivedIndex = find(this.indices, i => i.label === label);\n\n if (escapeHTML && results && results.hits && results.hits.length > 0) {\n results.hits = escapeHits(results.hits);\n }\n\n derivedIndex.results = results;\n derivedIndex.hits =\n results && results.hits && Array.isArray(results.hits)\n ? results.hits\n : [];\n\n this.renderWithAllIndices();\n },\n\n refine(helper) {\n return query => helper.setQuery(query).search();\n },\n\n render({ results }) {\n this.saveResults({ results, label: this.indices[0].label });\n },\n\n renderWithAllIndices({ isFirstRendering = false } = {}) {\n const currentRefinement = this.indices[0].helper.state.query;\n\n renderFn(\n {\n widgetParams,\n currentRefinement,\n // we do not want to provide the `helper` to the end-user\n indices: this.indices.map(({ index, label, hits, results }) => ({\n index,\n label,\n hits,\n results,\n })),\n instantSearchInstance: this.instantSearchInstance,\n refine: this._refine,\n },\n isFirstRendering\n );\n },\n\n dispose() {\n // detach every derived indices from the main helper instance\n this.indices.slice(1).forEach(({ helper }) => helper.detach());\n\n unmountFn();\n },\n };\n };\n}\n","import {\n Renderer,\n RenderOptions,\n WidgetFactory,\n Helper,\n SearchParameters,\n} from '../../types';\nimport {\n checkRendering,\n createDocumentationMessageGenerator,\n warning,\n getRefinements,\n isEqual,\n noop,\n} from '../../lib/utils';\nimport {\n Refinement as InternalRefinement,\n NumericRefinement as InternalNumericRefinement,\n} from '../../lib/utils/getRefinements';\n\ntype TrackedFilterRefinement = string | number | boolean;\n\nexport type ParamTrackedFilters = {\n [facetName: string]: (\n facetValues: TrackedFilterRefinement[]\n ) => TrackedFilterRefinement[];\n};\nexport type ParamTransformRuleContexts = (ruleContexts: string[]) => string[];\ntype ParamTransformItems = (items: any[]) => any;\n\nexport type QueryRulesConnectorParams = {\n trackedFilters?: ParamTrackedFilters;\n transformRuleContexts?: ParamTransformRuleContexts;\n transformItems?: ParamTransformItems;\n};\n\nexport interface QueryRulesRenderOptions\n extends RenderOptions {\n items: any[];\n}\n\nexport type QueryRulesRenderer = Renderer<\n QueryRulesRenderOptions\n>;\n\nexport type QueryRulesWidgetFactory = WidgetFactory<\n QueryRulesConnectorParams & TQueryRulesWidgetParams\n>;\n\nexport type QueryRulesConnector = (\n render: QueryRulesRenderer,\n unmount?: () => void\n) => QueryRulesWidgetFactory;\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'query-rules',\n connector: true,\n});\n\nfunction hasStateRefinements(state: SearchParameters): boolean {\n return [\n state.disjunctiveFacetsRefinements,\n state.facetsRefinements,\n state.hierarchicalFacetsRefinements,\n state.numericRefinements,\n ].some(refinement =>\n Boolean(refinement && Object.keys(refinement).length > 0)\n );\n}\n\n// A context rule must consist only of alphanumeric characters, hyphens, and underscores.\n// See https://www.algolia.com/doc/guides/managing-results/refine-results/merchandising-and-promoting/in-depth/implementing-query-rules/#context\nfunction escapeRuleContext(ruleName: string): string {\n return ruleName.replace(/[^a-z0-9-_]+/gi, '_');\n}\n\nfunction getRuleContextsFromTrackedFilters({\n helper,\n sharedHelperState,\n trackedFilters,\n}: {\n helper: Helper;\n sharedHelperState: SearchParameters;\n trackedFilters: ParamTrackedFilters;\n}): string[] {\n const ruleContexts = Object.keys(trackedFilters).reduce(\n (facets, facetName) => {\n const facetRefinements: TrackedFilterRefinement[] = getRefinements(\n helper.lastResults || {},\n sharedHelperState\n )\n .filter(\n (refinement: InternalRefinement) =>\n refinement.attributeName === facetName\n )\n .map(\n (refinement: InternalRefinement) =>\n (refinement as InternalNumericRefinement).numericValue ||\n refinement.name\n );\n\n const getTrackedFacetValues = trackedFilters[facetName];\n const trackedFacetValues = getTrackedFacetValues(facetRefinements);\n\n return [\n ...facets,\n ...facetRefinements\n .filter(facetRefinement =>\n trackedFacetValues.includes(facetRefinement)\n )\n .map(facetValue =>\n escapeRuleContext(`ais-${facetName}-${facetValue}`)\n ),\n ];\n },\n []\n );\n\n return ruleContexts;\n}\n\nfunction applyRuleContexts(\n this: {\n helper: Helper;\n initialRuleContexts: string[];\n trackedFilters: ParamTrackedFilters;\n transformRuleContexts: ParamTransformRuleContexts;\n },\n sharedHelperState: SearchParameters\n): void {\n const {\n helper,\n initialRuleContexts,\n trackedFilters,\n transformRuleContexts,\n } = this;\n\n const previousRuleContexts: string[] = sharedHelperState.ruleContexts || [];\n const newRuleContexts = getRuleContextsFromTrackedFilters({\n helper,\n sharedHelperState,\n trackedFilters,\n });\n const nextRuleContexts = [...initialRuleContexts, ...newRuleContexts];\n\n warning(\n nextRuleContexts.length <= 10,\n `\nThe maximum number of \\`ruleContexts\\` is 10. They have been sliced to that limit.\nConsider using \\`transformRuleContexts\\` to minimize the number of rules sent to Algolia.\n`\n );\n\n const ruleContexts = transformRuleContexts(nextRuleContexts).slice(0, 10);\n\n if (!isEqual(previousRuleContexts, ruleContexts)) {\n helper.overrideStateWithoutTriggeringChangeEvent({\n ...sharedHelperState,\n ruleContexts,\n });\n }\n}\n\nconst connectQueryRules: QueryRulesConnector = (render, unmount = noop) => {\n checkRendering(render, withUsage());\n\n return widgetParams => {\n const {\n trackedFilters = {} as ParamTrackedFilters,\n transformRuleContexts = (rules => rules) as ParamTransformRuleContexts,\n transformItems = (items => items) as ParamTransformItems,\n } = widgetParams || {};\n\n Object.keys(trackedFilters).forEach(facetName => {\n if (typeof trackedFilters[facetName] !== 'function') {\n throw new Error(\n withUsage(\n `'The \"${facetName}\" filter value in the \\`trackedFilters\\` option expects a function.`\n )\n );\n }\n });\n\n const hasTrackedFilters = Object.keys(trackedFilters).length > 0;\n\n // We store the initial rule contexts applied before creating the widget\n // so that we do not override them with the rules created from `trackedFilters`.\n let initialRuleContexts: string[] = [];\n let onHelperChange: (state: SearchParameters) => void;\n\n return {\n init({ helper, state, instantSearchInstance }) {\n initialRuleContexts = state.ruleContexts || [];\n onHelperChange = applyRuleContexts.bind({\n helper,\n initialRuleContexts,\n trackedFilters,\n transformRuleContexts,\n });\n\n if (hasTrackedFilters) {\n // We need to apply the `ruleContexts` based on the `trackedFilters`\n // before the helper changes state in some cases:\n // - Some filters are applied on the first load (e.g. using `configure`)\n // - The `transformRuleContexts` option sets initial `ruleContexts`.\n if (\n hasStateRefinements(state) ||\n Boolean(widgetParams.transformRuleContexts)\n ) {\n onHelperChange(state);\n }\n\n // We track every change in the helper to override its state and add\n // any `ruleContexts` needed based on the `trackedFilters`.\n helper.on('change', onHelperChange);\n }\n\n render(\n {\n items: [],\n instantSearchInstance,\n widgetParams,\n },\n true\n );\n },\n\n render({ results, instantSearchInstance }) {\n const { userData = [] } = results;\n const items = transformItems(userData);\n\n render(\n {\n items,\n instantSearchInstance,\n widgetParams,\n },\n false\n );\n },\n\n dispose({ helper, state }) {\n unmount();\n\n if (hasTrackedFilters) {\n helper.removeListener('change', onHelperChange);\n\n return state.setQueryParameter('ruleContexts', initialRuleContexts);\n }\n\n return state;\n },\n };\n };\n};\n\nexport default connectQueryRules;\n","export type VoiceSearchHelperParams = {\n searchAsYouSpeak: boolean;\n onQueryChange: (query: string) => void;\n onStateChange: () => void;\n};\n\nexport type Status =\n | 'initial'\n | 'askingPermission'\n | 'waiting'\n | 'recognizing'\n | 'finished'\n | 'error';\n\nexport type VoiceListeningState = {\n status: Status;\n transcript: string;\n isSpeechFinal: boolean;\n errorCode?: SpeechRecognitionErrorCode;\n};\n\nexport type VoiceSearchHelper = {\n getState: () => VoiceListeningState;\n isBrowserSupported: () => boolean;\n isListening: () => boolean;\n toggleListening: () => void;\n dispose: () => void;\n};\n\nexport type ToggleListening = () => void;\n\nexport default function createVoiceSearchHelper({\n searchAsYouSpeak,\n onQueryChange,\n onStateChange,\n}: VoiceSearchHelperParams): VoiceSearchHelper {\n const SpeechRecognitionAPI: new () => SpeechRecognition =\n (window as any).webkitSpeechRecognition ||\n (window as any).SpeechRecognition;\n const getDefaultState = (status: Status): VoiceListeningState => ({\n status,\n transcript: '',\n isSpeechFinal: false,\n errorCode: undefined,\n });\n let state: VoiceListeningState = getDefaultState('initial');\n let recognition: SpeechRecognition | undefined;\n\n const isBrowserSupported = (): boolean => Boolean(SpeechRecognitionAPI);\n\n const isListening = (): boolean =>\n state.status === 'askingPermission' ||\n state.status === 'waiting' ||\n state.status === 'recognizing';\n\n const setState = (newState: Partial = {}): void => {\n state = { ...state, ...newState };\n onStateChange();\n };\n\n const getState = (): VoiceListeningState => state;\n\n const resetState = (status: Status = 'initial'): void => {\n setState(getDefaultState(status));\n };\n\n const onStart = (): void => {\n setState({\n status: 'waiting',\n });\n };\n\n const onError = (event: SpeechRecognitionError): void => {\n setState({ status: 'error', errorCode: event.error });\n };\n\n const onResult = (event: SpeechRecognitionEvent): void => {\n setState({\n status: 'recognizing',\n transcript:\n (event.results[0] &&\n event.results[0][0] &&\n event.results[0][0].transcript) ||\n '',\n isSpeechFinal: event.results[0] && event.results[0].isFinal,\n });\n if (searchAsYouSpeak && state.transcript) {\n onQueryChange(state.transcript);\n }\n };\n\n const onEnd = (): void => {\n if (!state.errorCode && state.transcript && !searchAsYouSpeak) {\n onQueryChange(state.transcript);\n }\n if (state.status !== 'error') {\n setState({ status: 'finished' });\n }\n };\n\n const start = (): void => {\n recognition = new SpeechRecognitionAPI();\n if (!recognition) {\n return;\n }\n resetState('askingPermission');\n recognition.interimResults = true;\n recognition.addEventListener('start', onStart);\n recognition.addEventListener('error', onError);\n recognition.addEventListener('result', onResult);\n recognition.addEventListener('end', onEnd);\n recognition.start();\n };\n\n const dispose = (): void => {\n if (!recognition) {\n return;\n }\n recognition.stop();\n recognition.removeEventListener('start', onStart);\n recognition.removeEventListener('error', onError);\n recognition.removeEventListener('result', onResult);\n recognition.removeEventListener('end', onEnd);\n recognition = undefined;\n };\n\n const stop = (): void => {\n dispose();\n // Because `dispose` removes event listeners, `end` listener is not called.\n // So we're setting the `status` as `finished` here.\n // If we don't do it, it will be still `waiting` or `recognizing`.\n resetState('finished');\n };\n\n const toggleListening = (): void => {\n if (!isBrowserSupported()) {\n return;\n }\n if (isListening()) {\n stop();\n } else {\n start();\n }\n };\n\n return {\n getState,\n isBrowserSupported,\n isListening,\n toggleListening,\n dispose,\n };\n}\n","import {\n checkRendering,\n createDocumentationMessageGenerator,\n noop,\n} from '../../lib/utils';\nimport { Renderer, RenderOptions, WidgetFactory } from '../../types';\nimport createVoiceSearchHelper, {\n VoiceListeningState,\n ToggleListening,\n} from '../../lib/voiceSearchHelper';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'voice-search',\n connector: true,\n});\n\nexport type VoiceSearchConnectorParams = {\n searchAsYouSpeak?: boolean;\n};\n\nexport interface VoiceSearchRenderOptions\n extends RenderOptions {\n isBrowserSupported: boolean;\n isListening: boolean;\n toggleListening: ToggleListening;\n voiceListeningState: VoiceListeningState;\n}\n\nexport type VoiceSearchRenderer = Renderer<\n VoiceSearchRenderOptions<\n VoiceSearchConnectorParams & TVoiceSearchWidgetParams\n >\n>;\n\nexport type VoiceSearchWidgetFactory = WidgetFactory<\n VoiceSearchConnectorParams & TVoiceSearchWidgetParams\n>;\n\nexport type VoiceSearchConnector = (\n renderFn: VoiceSearchRenderer,\n unmountFn?: () => void\n) => VoiceSearchWidgetFactory;\n\nconst connectVoiceSearch: VoiceSearchConnector = (\n renderFn,\n unmountFn = noop\n) => {\n checkRendering(renderFn, withUsage());\n\n return widgetParams => {\n const render = ({\n isFirstRendering,\n instantSearchInstance,\n voiceSearchHelper: {\n isBrowserSupported,\n isListening,\n toggleListening,\n getState,\n },\n }): void => {\n renderFn(\n {\n isBrowserSupported: isBrowserSupported(),\n isListening: isListening(),\n toggleListening,\n voiceListeningState: getState(),\n widgetParams,\n instantSearchInstance,\n },\n isFirstRendering\n );\n };\n\n const { searchAsYouSpeak = false } = widgetParams;\n\n return {\n init({ helper, instantSearchInstance }) {\n (this as any)._refine = (() => {\n let previousQuery: string | undefined;\n const setQueryAndSearch = (query: string): void => {\n if (query !== helper.state.query) {\n previousQuery = helper.state.query;\n helper.setQuery(query);\n }\n if (\n typeof previousQuery !== 'undefined' &&\n previousQuery !== query\n ) {\n helper.search();\n }\n };\n return setQueryAndSearch;\n })();\n (this as any)._voiceSearchHelper = createVoiceSearchHelper({\n searchAsYouSpeak,\n onQueryChange: query => (this as any)._refine(query),\n onStateChange: () => {\n render({\n isFirstRendering: false,\n instantSearchInstance,\n voiceSearchHelper: (this as any)._voiceSearchHelper,\n });\n },\n });\n render({\n isFirstRendering: true,\n instantSearchInstance,\n voiceSearchHelper: (this as any)._voiceSearchHelper,\n });\n },\n render({ instantSearchInstance }) {\n render({\n isFirstRendering: false,\n instantSearchInstance,\n voiceSearchHelper: (this as any)._voiceSearchHelper,\n });\n },\n dispose({ state }) {\n (this as any)._voiceSearchHelper.dispose();\n unmountFn();\n return state.setQuery('');\n },\n getWidgetState(uiState, { searchParameters }) {\n const query = searchParameters.query;\n\n if (query === '' || (uiState && uiState.query === query)) {\n return uiState;\n }\n\n return {\n ...uiState,\n query,\n };\n },\n getWidgetSearchParameters(searchParameters, { uiState }) {\n return searchParameters.setQuery(uiState.query || '');\n },\n };\n };\n};\n\nexport default connectVoiceSearch;\n","/*!\n Copyright (c) 2017 Jed Watson.\n Licensed under the MIT License (MIT), see\n http://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = [];\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (!arg) continue;\n\n\t\t\tvar argType = typeof arg;\n\n\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\tclasses.push(arg);\n\t\t\t} else if (Array.isArray(arg) && arg.length) {\n\t\t\t\tvar inner = classNames.apply(null, arg);\n\t\t\t\tif (inner) {\n\t\t\t\t\tclasses.push(inner);\n\t\t\t\t}\n\t\t\t} else if (argType === 'object') {\n\t\t\t\tfor (var key in arg) {\n\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classes.join(' ');\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import React, { Component } from 'preact-compat';\nimport PropTypes from 'prop-types';\nimport { renderTemplate, isEqual } from '../../lib/utils';\n\nclass Template extends Component {\n shouldComponentUpdate(nextProps) {\n return (\n !isEqual(this.props.data, nextProps.data) ||\n this.props.templateKey !== nextProps.templateKey ||\n !isEqual(this.props.rootProps, nextProps.rootProps)\n );\n }\n\n render() {\n const RootTagName = this.props.rootTagName;\n const useCustomCompileOptions = this.props.useCustomCompileOptions[\n this.props.templateKey\n ];\n const compileOptions = useCustomCompileOptions\n ? this.props.templatesConfig.compileOptions\n : {};\n\n const content = renderTemplate({\n templates: this.props.templates,\n templateKey: this.props.templateKey,\n compileOptions,\n helpers: this.props.templatesConfig.helpers,\n data: this.props.data,\n });\n\n if (content === null) {\n // Adds a noscript to the DOM but virtual DOM is null\n // See http://facebook.github.io/react/docs/component-specs.html#render\n return null;\n }\n\n return (\n \n );\n }\n}\n\nTemplate.propTypes = {\n data: PropTypes.object,\n rootProps: PropTypes.object,\n rootTagName: PropTypes.string,\n templateKey: PropTypes.string,\n templates: PropTypes.objectOf(\n PropTypes.oneOfType([PropTypes.string, PropTypes.func])\n ),\n templatesConfig: PropTypes.shape({\n helpers: PropTypes.objectOf(PropTypes.func),\n // https://github.com/twitter/hogan.js/#compilation-options\n compileOptions: PropTypes.shape({\n asString: PropTypes.bool,\n sectionTags: PropTypes.arrayOf(\n PropTypes.shape({\n o: PropTypes.string,\n c: PropTypes.string,\n })\n ),\n delimiters: PropTypes.string,\n disableLambda: PropTypes.bool,\n }),\n }),\n useCustomCompileOptions: PropTypes.objectOf(PropTypes.bool),\n};\n\nTemplate.defaultProps = {\n data: {},\n rootTagName: 'div',\n useCustomCompileOptions: {},\n templates: {},\n templatesConfig: {},\n};\n\nexport default Template;\n","import React from 'preact-compat';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Template from '../Template/Template';\n\nconst ClearRefinements = ({\n hasRefinements,\n refine,\n cssClasses,\n templateProps,\n}) => (\n
          \n \n
          \n);\n\nClearRefinements.propTypes = {\n refine: PropTypes.func.isRequired,\n cssClasses: PropTypes.shape({\n root: PropTypes.string.isRequired,\n button: PropTypes.string.isRequired,\n disabledButton: PropTypes.string.isRequired,\n }).isRequired,\n hasRefinements: PropTypes.bool.isRequired,\n templateProps: PropTypes.object.isRequired,\n};\n\nexport default ClearRefinements;\n","export default {\n resetLabel: 'Clear refinements',\n};\n","import React, { render, unmountComponentAtNode } from 'preact-compat';\nimport ClearRefinements from '../../components/ClearRefinements/ClearRefinements';\nimport cx from 'classnames';\nimport connectClearRefinements from '../../connectors/clear-refinements/connectClearRefinements';\nimport defaultTemplates from './defaultTemplates';\nimport {\n getContainerNode,\n prepareTemplateProps,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\nimport { component } from '../../lib/suit';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'clear-refinements',\n});\nconst suit = component('ClearRefinements');\n\nconst renderer = ({ containerNode, cssClasses, renderState, templates }) => (\n { refine, hasRefinements, instantSearchInstance },\n isFirstRendering\n) => {\n if (isFirstRendering) {\n renderState.templateProps = prepareTemplateProps({\n defaultTemplates,\n templatesConfig: instantSearchInstance.templatesConfig,\n templates,\n });\n return;\n }\n\n render(\n ,\n containerNode\n );\n};\n\n/**\n * @typedef {Object} ClearRefinementsCSSClasses\n * @property {string|string[]} [root] CSS class to add to the wrapper element.\n * @property {string|string[]} [button] CSS class to add to the button of the widget.\n * @property {string|string[]} [disabledButton] CSS class to add to the button when there are no refinements.\n */\n\n/**\n * @typedef {Object} ClearRefinementsTemplates\n * @property {string|string[]} [resetLabel] Template for the content of the button\n */\n\n/**\n * @typedef {Object} ClearRefinementsWidgetOptions\n * @property {string|HTMLElement} container CSS Selector or HTMLElement to insert the widget.\n * @property {string[]} [includedAttributes = []] The attributes to include in the refinements to clear (all by default). Cannot be used with `excludedAttributes`.\n * @property {string[]} [excludedAttributes = ['query']] The attributes to exclude from the refinements to clear. Cannot be used with `includedAttributes`.\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n * @property {ClearRefinementsTemplates} [templates] Templates to use for the widget.\n * @property {ClearRefinementsCSSClasses} [cssClasses] CSS classes to be added.\n */\n\n/**\n * The clear all widget gives the user the ability to clear all the refinements currently\n * applied on the results. It is equivalent to the reset button of a form.\n *\n * The current refined values widget can display a button that has the same behavior.\n * @type {WidgetFactory}\n * @devNovel ClearRefinements\n * @category clear-filter\n * @param {ClearRefinementsWidgetOptions} $0 The ClearRefinements widget options.\n * @returns {Widget} A new instance of the ClearRefinements widget.\n * @example\n * search.addWidget(\n * instantsearch.widgets.clearRefinements({\n * container: '#clear-all',\n * templates: {\n * resetLabel: 'Reset everything'\n * },\n * })\n * );\n */\nexport default function clearRefinements({\n container,\n templates = defaultTemplates,\n includedAttributes,\n excludedAttributes,\n transformItems,\n cssClasses: userCssClasses = {},\n}) {\n if (!container) {\n throw new Error(withUsage('The `container` option is required.'));\n }\n\n const containerNode = getContainerNode(container);\n\n const cssClasses = {\n root: cx(suit(), userCssClasses.root),\n button: cx(suit({ descendantName: 'button' }), userCssClasses.button),\n disabledButton: cx(\n suit({ descendantName: 'button', modifierName: 'disabled' }),\n userCssClasses.disabledButton\n ),\n };\n\n const specializedRenderer = renderer({\n containerNode,\n cssClasses,\n renderState: {},\n templates,\n });\n\n const makeWidget = connectClearRefinements(specializedRenderer, () =>\n unmountComponentAtNode(containerNode)\n );\n\n return makeWidget({\n includedAttributes,\n excludedAttributes,\n transformItems,\n });\n}\n","import React from 'preact-compat';\nimport PropTypes from 'prop-types';\nimport { isSpecialClick, capitalize } from '../../lib/utils';\n\nconst createItemKey = ({ attribute, value, type, operator }) =>\n [attribute, type, value, operator]\n .map(key => key)\n .filter(Boolean)\n .join(':');\n\nconst handleClick = callback => event => {\n if (isSpecialClick(event)) {\n return;\n }\n\n event.preventDefault();\n callback();\n};\n\nconst CurrentRefinements = ({ items, cssClasses }) => (\n
          \n
            \n {items.map((item, index) => (\n
          • \n {capitalize(item.label)}:\n\n {item.refinements.map(refinement => (\n \n \n {refinement.attribute === 'query' ? (\n {refinement.label}\n ) : (\n refinement.label\n )}\n \n\n \n ✕\n \n \n ))}\n
          • \n ))}\n
          \n
          \n);\n\nconst RefinementPropTypes = PropTypes.shape({\n attribute: PropTypes.string.isRequired,\n label: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n});\n\nconst ItemPropTypes = PropTypes.shape({\n attribute: PropTypes.string.isRequired,\n refine: PropTypes.func.isRequired,\n refinements: PropTypes.arrayOf(RefinementPropTypes).isRequired,\n});\n\nCurrentRefinements.propTypes = {\n cssClasses: PropTypes.shape({\n root: PropTypes.string.isRequired,\n list: PropTypes.string.isRequired,\n item: PropTypes.string.isRequired,\n label: PropTypes.string.isRequired,\n category: PropTypes.string.isRequired,\n categoryLabel: PropTypes.string.isRequired,\n delete: PropTypes.string.isRequired,\n }).isRequired,\n items: PropTypes.arrayOf(ItemPropTypes).isRequired,\n};\n\nexport default CurrentRefinements;\n","function capitalize(text: string): string {\n return (\n text\n .toString()\n .charAt(0)\n .toUpperCase() + text.toString().slice(1)\n );\n}\n\nexport default capitalize;\n","import React, { render, unmountComponentAtNode } from 'preact-compat';\nimport cx from 'classnames';\nimport CurrentRefinements from '../../components/CurrentRefinements/CurrentRefinements';\nimport connectCurrentRefinements from '../../connectors/current-refinements/connectCurrentRefinements';\nimport {\n getContainerNode,\n createDocumentationMessageGenerator,\n} from '../../lib/utils';\nimport { component } from '../../lib/suit';\n\nconst withUsage = createDocumentationMessageGenerator({\n name: 'current-refinements',\n});\nconst suit = component('CurrentRefinements');\n\nconst renderer = ({ containerNode, cssClasses }) => (\n { items },\n isFirstRendering\n) => {\n if (isFirstRendering) {\n return;\n }\n\n render(\n ,\n containerNode\n );\n};\n\n/**\n * @typedef {Object} CurrentRefinementsCSSClasses\n * @property {string} [root] CSS classes added to the root element.\n * @property {string} [list] CSS classes added to the list element.\n * @property {string} [item] CSS classes added to the item element.\n * @property {string} [label] CSS classes added to the label element.\n * @property {string} [category] CSS classes added to the category element.\n * @property {string} [categoryLabel] CSS classes added to the categoryLabel element.\n * @property {string} [delete] CSS classes added to the delete element.\n */\n\n/**\n * @typedef {Object} CurrentRefinementsWidgetOptions\n * @property {string|HTMLElement} container The CSS Selector or HTMLElement to insert the widget\n * @property {string[]} [includedAttributes] The attributes to include in the refinements (all by default)\n * @property {string[]} [excludedAttributes = ['query']] The attributes to exclude from the refinements\n * @property {CurrentRefinementsCSSClasses} [cssClasses] The CSS classes to be added\n * @property {function(object[]):object[]} [transformItems] Function to transform the items passed to the templates.\n */\n\n/**\n * The `currentRefinements` widget has two purposes give the user a synthetic view of the current filters\n * and the ability to remove a filter.\n *\n * This widget is usually in the top part of the search UI.\n * @type {WidgetFactory}\n * @devNovel CurrentRefinements\n * @category clear-filter\n * @param {CurrentRefinementsWidgetOptions} $0 The CurrentRefinements widget options.\n * @returns {Object} A new CurrentRefinements widget instance.\n * @example\n * search.addWidget(\n * instantsearch.widgets.currentRefinements({\n * container: '#current-refinements',\n * includedAttributes: [\n * 'free_shipping',\n * 'price',\n * 'brand',\n * 'category',\n * ],\n * })\n * );\n */\nexport default function currentRefinements({\n container,\n includedAttributes,\n excludedAttributes,\n cssClasses: userCssClasses = {},\n transformItems,\n}) {\n if (!container) {\n throw new Error(withUsage('The `container` option is required.'));\n }\n\n const containerNode = getContainerNode(container);\n const cssClasses = {\n root: cx(suit(), userCssClasses.root),\n list: cx(suit({ descendantName: 'list' }), userCssClasses.list),\n item: cx(suit({ descendantName: 'item' }), userCssClasses.item),\n label: cx(suit({ descendantName: 'label' }), userCssClasses.label),\n category: cx(suit({ descendantName: 'category' }), userCssClasses.category),\n categoryLabel: cx(\n suit({ descendantName: 'categoryLabel' }),\n userCssClasses.categoryLabel\n ),\n delete: cx(suit({ descendantName: 'delete' }), userCssClasses.delete),\n };\n\n const specializedRenderer = renderer({\n containerNode,\n cssClasses,\n });\n\n const makeWidget = connectCurrentRefinements(specializedRenderer, () =>\n unmountComponentAtNode(containerNode)\n );\n\n return makeWidget({\n includedAttributes,\n excludedAttributes,\n transformItems,\n });\n}\n","import React from 'preact-compat';\nimport PropTypes from 'prop-types';\n\nconst GeoSearchButton = ({ className, disabled, onClick, children }) => (\n \n);\n\nGeoSearchButton.propTypes = {\n className: PropTypes.string.isRequired,\n onClick: PropTypes.func.isRequired,\n children: PropTypes.node.isRequired,\n disabled: PropTypes.bool,\n};\n\nGeoSearchButton.defaultProps = {\n disabled: false,\n};\n\nexport default GeoSearchButton;\n","import React from 'preact-compat';\nimport PropTypes from 'prop-types';\n\nconst GeoSearchToggle = ({\n classNameLabel,\n classNameInput,\n checked,\n onToggle,\n children,\n}) => (\n \n);\n\nGeoSearchToggle.propTypes = {\n classNameLabel: PropTypes.string.isRequired,\n classNameInput: PropTypes.string.isRequired,\n checked: PropTypes.bool.isRequired,\n onToggle: PropTypes.func.isRequired,\n children: PropTypes.node.isRequired,\n};\n\nexport default GeoSearchToggle;\n","import React from 'preact-compat';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Template from '../Template/Template';\nimport GeoSearchButton from './GeoSearchButton';\nimport GeoSearchToggle from './GeoSearchToggle';\n\nconst GeoSearchControls = ({\n cssClasses,\n enableRefine,\n enableRefineControl,\n enableClearMapRefinement,\n isRefineOnMapMove,\n isRefinedWithMap,\n hasMapMoveSinceLastRefine,\n onRefineToggle,\n onRefineClick,\n onClearClick,\n templateProps,\n}) =>\n enableRefine && (\n
          \n {enableRefineControl && (\n
          \n {isRefineOnMapMove || !hasMapMoveSinceLastRefine ? (\n \n \n \n ) : (\n \n \n \n )}\n
          \n )}\n\n {!enableRefineControl && !isRefineOnMapMove && (\n
          \n \n \n \n
          \n )}\n\n {enableClearMapRefinement && isRefinedWithMap && (\n \n