\";\n return template;\n };\n DefaultRecommendationTemplate.prototype.instantiateToElement = function (object) {\n var _this = this;\n return new Promise(function (resolve, reject) {\n var div = document.createElement('div');\n div.innerHTML = _this.instantiateToString(object);\n resolve(div);\n });\n };\n return DefaultRecommendationTemplate;\n}(Template_1.Template));\nexports.DefaultRecommendationTemplate = DefaultRecommendationTemplate;\n\n\n/***/ }),\n\n/***/ 472:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Core_1 = __webpack_require__(20);\nvar ResultList_1 = __webpack_require__(92);\nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nvar Logger_1 = __webpack_require__(9);\nvar TemplateToHtml = /** @class */ (function () {\n function TemplateToHtml(args) {\n this.args = args;\n }\n TemplateToHtml.prototype.buildResults = function (results, layout, currentlyDisplayedResults) {\n return __awaiter(this, void 0, void 0, function () {\n var _this = this;\n var res, resultsPromises;\n return __generator(this, function (_a) {\n res = [];\n resultsPromises = underscore_1.map(results.results, function (result, index) {\n return _this.buildResult(result, layout, currentlyDisplayedResults).then(function (resultElement) {\n if (resultElement != null) {\n res.push({ elem: resultElement, idx: index });\n }\n ResultList_1.ResultList.resultCurrentlyBeingRendered = null;\n return resultElement;\n });\n });\n // We need to sort by the original index order, because in lazy loading mode, it's possible that results does not gets rendered\n // in the correct order returned by the index, depending on the time it takes to load all the results component for a given result template\n return [2 /*return*/, Promise.all(resultsPromises).then(function () {\n return underscore_1.pluck(underscore_1.sortBy(res, 'idx'), 'elem');\n })];\n });\n });\n };\n TemplateToHtml.prototype.buildResult = function (result, layout, currentlyDisplayedResults) {\n return __awaiter(this, void 0, void 0, function () {\n var resultElement;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n Core_1.Assert.exists(result);\n Core_1.QueryUtils.setStateObjectOnQueryResult(this.args.queryStateModel.get(), result);\n Core_1.QueryUtils.setSearchInterfaceObjectOnQueryResult(this.args.searchInterface, result);\n ResultList_1.ResultList.resultCurrentlyBeingRendered = result;\n return [4 /*yield*/, this.createHtmlElement(result, layout)];\n case 1:\n resultElement = _a.sent();\n if (resultElement != null) {\n Core_1.Component.bindResultToElement(resultElement, result);\n }\n currentlyDisplayedResults.push(result);\n return [4 /*yield*/, this.autoCreateComponentsInsideResult(resultElement, result).initResult];\n case 2:\n _a.sent();\n this.verifyChildren(resultElement);\n return [2 /*return*/, resultElement];\n }\n });\n });\n };\n TemplateToHtml.prototype.autoCreateComponentsInsideResult = function (element, result) {\n Core_1.Assert.exists(element);\n return Core_1.Initialization.automaticallyCreateComponentsInsideResult(element, result);\n };\n TemplateToHtml.prototype.createHtmlElement = function (result, layout) {\n return this.args.resultTemplate.instantiateToElement(result, {\n wrapInDiv: true,\n checkCondition: true,\n currentLayout: layout,\n responsiveComponents: this.args.searchInterface.responsiveComponents\n });\n };\n TemplateToHtml.prototype.verifyChildren = function (element) {\n var containsResultLink = !!Dom_1.$$(element).find('.CoveoResultLink');\n if (containsResultLink) {\n return;\n }\n var msg = \"Result does not contain a \\\"CoveoResultLink\\\" component, please verify the result template\";\n new Logger_1.Logger(element).warn(msg, this.args.resultTemplate);\n };\n return TemplateToHtml;\n}());\nexports.TemplateToHtml = TemplateToHtml;\n\n\n/***/ }),\n\n/***/ 473:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar TemplateHelpers_1 = __webpack_require__(121);\nvar HighlightUtils_1 = __webpack_require__(69);\nvar DateUtils_1 = __webpack_require__(33);\nvar CurrencyUtils_1 = __webpack_require__(134);\nvar HtmlUtils_1 = __webpack_require__(179);\nvar Utils_1 = __webpack_require__(4);\nvar StringUtils_1 = __webpack_require__(22);\nvar TimeSpanUtils_1 = __webpack_require__(73);\nvar EmailUtils_1 = __webpack_require__(178);\nvar QueryUtils_1 = __webpack_require__(21);\nvar DeviceUtils_1 = __webpack_require__(24);\nvar Dom_1 = __webpack_require__(1);\nvar SearchEndpoint_1 = __webpack_require__(53);\nvar StreamHighlightUtils_1 = __webpack_require__(119);\nvar FacetUtils_1 = __webpack_require__(40);\nvar Globalize = __webpack_require__(23);\nvar _ = __webpack_require__(0);\nvar Component_1 = __webpack_require__(7);\nvar TemplateCache_1 = __webpack_require__(68);\nvar CoreHelpers = /** @class */ (function () {\n function CoreHelpers() {\n }\n /**\n * For backward compatibility reason, the \"global\" template helper should be available under the\n * coveo namespace.\n * @param scope\n */\n CoreHelpers.exportAllHelpersGlobally = function (scope) {\n _.each(TemplateHelpers_1.TemplateHelpers.getHelpers(), function (helper, name) {\n if (scope[name] == undefined) {\n scope[name] = helper;\n }\n });\n };\n return CoreHelpers;\n}());\nexports.CoreHelpers = CoreHelpers;\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('javascriptEncode', function (value) {\n return Utils_1.Utils.exists(value) ? StringUtils_1.StringUtils.javascriptEncode(value) : undefined;\n});\nvar executeShorten = function (content, options) {\n var strAndHoles = HighlightUtils_1.StringAndHoles.shortenString(content, options.length, '...');\n if (Utils_1.Utils.exists(options.highlights)) {\n return HighlightUtils_1.HighlightUtils.highlightString(strAndHoles.value, options.highlights, strAndHoles.holes, options.cssClass || 'highlight');\n }\n else {\n return strAndHoles.value;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('shorten', function (content, length, highlights, cssClass) {\n return executeShorten(content, {\n length: length,\n highlights: highlights,\n cssClass: cssClass\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('shortenv2', function (content, options) {\n return executeShorten(content, options);\n});\nvar executeShortenPath = function (content, options) {\n var strAndHoles = HighlightUtils_1.StringAndHoles.shortenPath(content, options.length);\n if (Utils_1.Utils.exists(options.highlights)) {\n return HighlightUtils_1.HighlightUtils.highlightString(strAndHoles.value, options.highlights, strAndHoles.holes, options.cssClass || 'highlight');\n }\n else {\n return strAndHoles.value;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('shortenPath', function (content, length, highlights, cssClass) {\n return executeShortenPath(content, {\n length: length,\n highlights: highlights,\n cssClass: cssClass\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('shortenPathv2', function (content, options) {\n return executeShortenPath(content, options);\n});\nvar executeShortenUri = function (content, options) {\n var strAndHoles = HighlightUtils_1.StringAndHoles.shortenUri(content, options.length);\n if (Utils_1.Utils.exists(options.highlights)) {\n return HighlightUtils_1.HighlightUtils.highlightString(strAndHoles.value, options.highlights, strAndHoles.holes, options.cssClass || 'highlight');\n }\n else {\n return strAndHoles.value;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('shortenUri', function (content, length, highlights, cssClass) {\n return executeShortenUri(content, {\n length: length,\n highlights: highlights,\n cssClass: cssClass\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('shortenUriv2', function (content, options) {\n return executeShortenUri(content, options);\n});\nvar executeHighlight = function (content, options) {\n if (Utils_1.Utils.exists(content)) {\n if (Utils_1.Utils.exists(options.highlights)) {\n return HighlightUtils_1.HighlightUtils.highlightString(content, options.highlights, null, options.cssClass || 'highlight');\n }\n else {\n return content;\n }\n }\n else {\n return undefined;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlight', function (content, highlights, cssClass) {\n return executeHighlight(content, {\n highlights: highlights,\n cssClass: cssClass\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlightv2', function (content, options) {\n return executeHighlight(content, options);\n});\nvar executeHighlightStreamText = function (content, options) {\n if (Utils_1.Utils.exists(content) && Utils_1.Utils.exists(options.termsToHighlight) && Utils_1.Utils.exists(options.phrasesToHighlight)) {\n if (termsToHighlightAreDefined(options.termsToHighlight, options.phrasesToHighlight)) {\n return StreamHighlightUtils_1.StreamHighlightUtils.highlightStreamText(content, options.termsToHighlight, options.phrasesToHighlight, options.opts);\n }\n else {\n return content;\n }\n }\n else {\n return undefined;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlightStreamText', function (content, termsToHighlight, phrasesToHighlight, opts) {\n if (termsToHighlight === void 0) { termsToHighlight = resolveTermsToHighlight(); }\n if (phrasesToHighlight === void 0) { phrasesToHighlight = resolvePhrasesToHighlight(); }\n return executeHighlightStreamText(content, {\n termsToHighlight: termsToHighlight,\n phrasesToHighlight: phrasesToHighlight,\n opts: opts\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlightStreamTextv2', function (content, options) {\n var mergedOptions = __assign({ termsToHighlight: resolveTermsToHighlight(), phrasesToHighlight: resolvePhrasesToHighlight() }, options);\n return executeHighlightStreamText(content, mergedOptions);\n});\nvar executeHighlightStreamHTML = function (content, options) {\n if (Utils_1.Utils.exists(content) && Utils_1.Utils.exists(options.termsToHighlight) && Utils_1.Utils.exists(options.phrasesToHighlight)) {\n if (termsToHighlightAreDefined(options.termsToHighlight, options.phrasesToHighlight)) {\n return StreamHighlightUtils_1.StreamHighlightUtils.highlightStreamHTML(content, options.termsToHighlight, options.phrasesToHighlight, options.opts);\n }\n else {\n return content;\n }\n }\n else {\n return undefined;\n }\n};\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlightStreamHTML', function (content, termsToHighlight, phrasesToHighlight, opts) {\n if (termsToHighlight === void 0) { termsToHighlight = resolveTermsToHighlight(); }\n if (phrasesToHighlight === void 0) { phrasesToHighlight = resolvePhrasesToHighlight(); }\n return executeHighlightStreamHTML(content, {\n termsToHighlight: termsToHighlight,\n phrasesToHighlight: phrasesToHighlight,\n opts: opts\n });\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('highlightStreamHTMLv2', function (content, options) {\n var mergedOptions = __assign({ termsToHighlight: resolveTermsToHighlight(), phrasesToHighlight: resolvePhrasesToHighlight() }, options);\n return executeHighlightStreamHTML(content, mergedOptions);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('number', function (value, options) {\n if (!Utils_1.Utils.exists(value)) {\n return undefined;\n }\n var numberValue = Number(value);\n var format = _.isString(options) ? options : options && options.format;\n if (!format) {\n return StringUtils_1.StringUtils.htmlEncode(numberValue.toString());\n }\n return StringUtils_1.StringUtils.htmlEncode(Globalize.format(numberValue, format));\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('date', function (value, options) {\n return DateUtils_1.DateUtils.dateToString(DateUtils_1.DateUtils.convertFromJsonDateIfNeeded(value), options);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('time', function (value, options) {\n return DateUtils_1.DateUtils.timeToString(DateUtils_1.DateUtils.convertFromJsonDateIfNeeded(value), options);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('dateTime', function (value, options) {\n return DateUtils_1.DateUtils.dateTimeToString(DateUtils_1.DateUtils.convertFromJsonDateIfNeeded(value), options);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('emailDateTime', function (value, options) {\n var defaultOptions = {};\n defaultOptions.includeTimeIfThisWeek = true;\n var optionsToUse = _.extend(options, defaultOptions);\n return value ? DateUtils_1.DateUtils.dateTimeToString(DateUtils_1.DateUtils.convertFromJsonDateIfNeeded(value), optionsToUse) : undefined;\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('currency', function (value, options) {\n return CurrencyUtils_1.CurrencyUtils.currencyToString(value, options);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('timeSpan', function (value, options) {\n if (options === void 0) { options = { isMilliseconds: false }; }\n return new TimeSpanUtils_1.TimeSpan(value, options.isMilliseconds).getHHMMSS();\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('email', function (value) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n // support old arguments (value: any, companyDomain: string, me: string, lengthLimit = 2, truncateName = false)\n var companyDomain;\n var me;\n var lengthLimit;\n var truncateName;\n if (_.isObject(args[0])) {\n companyDomain = args[0]['companyDomain'];\n me = args[0]['me'];\n lengthLimit = args[0]['lengthLimit'];\n truncateName = args[0]['truncateName'];\n }\n else {\n companyDomain = args[0];\n me = args[1];\n lengthLimit = args[2];\n truncateName = args[3];\n }\n if (lengthLimit == undefined) {\n lengthLimit = 2;\n }\n if (truncateName == undefined) {\n truncateName = false;\n }\n if (_.isString(value)) {\n var listOfAddresses = EmailUtils_1.EmailUtils.splitSemicolonSeparatedListOfEmailAddresses(value);\n return EmailUtils_1.EmailUtils.emailAddressesToHyperlinks(listOfAddresses, companyDomain, me, lengthLimit, truncateName);\n }\n else if (_.isArray(value)) {\n return EmailUtils_1.EmailUtils.emailAddressesToHyperlinks(value, companyDomain, me, lengthLimit, truncateName);\n }\n else {\n return undefined;\n }\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('excessEmailToggle', function (target) {\n Dom_1.$$(target).removeClass('coveo-active');\n if (Dom_1.$$(target).hasClass('coveo-emails-excess-collapsed')) {\n _.each(Dom_1.$$(target).siblings('.coveo-emails-excess-expanded'), function (sibling) {\n Dom_1.$$(sibling).addClass('coveo-active');\n });\n }\n else if (Dom_1.$$(target).hasClass('coveo-hide-expanded')) {\n Dom_1.$$(target.parentElement).addClass('coveo-inactive');\n _.each(Dom_1.$$(target.parentElement).siblings('.coveo-emails-excess-collapsed'), function (sibling) {\n Dom_1.$$(sibling).addClass('coveo-active');\n });\n }\n return undefined;\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('anchor', function (href, options) {\n return HtmlUtils_1.AnchorUtils.buildAnchor(href, options);\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('image', function (src, options, result) {\n if (result === void 0) { result = resolveQueryResult(); }\n if (options && options.srcTemplate) {\n return HtmlUtils_1.ImageUtils.buildImage(StringUtils_1.StringUtils.buildStringTemplateFromResult(options.srcTemplate, result), {\n alt: options.alt,\n height: options.height,\n width: options.width\n });\n }\n return HtmlUtils_1.ImageUtils.buildImage(src, options);\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('thumbnail', function (result, endpoint, options) {\n if (result === void 0) { result = resolveQueryResult(); }\n if (endpoint === void 0) { endpoint = 'default'; }\n if (QueryUtils_1.QueryUtils.hasThumbnail(result)) {\n return HtmlUtils_1.ImageUtils.buildImageFromResult(result, SearchEndpoint_1.SearchEndpoint.endpoints[endpoint], options);\n }\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('fromFileTypeToIcon', function (result, options) {\n if (result === void 0) { result = resolveQueryResult(); }\n if (options === void 0) { options = {}; }\n var icon = Component_1.Component.getComponentRef('Icon');\n if (icon) {\n return icon.createIcon(result, options).outerHTML;\n }\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('attrEncode', function (value) {\n return ('' + value) /* Forces the conversion to string. */\n .replace(/&/g, '&') /* This MUST be the 1st replacement. */\n .replace(/'/g, ''') /* The 4 other predefined entities, required. */\n .replace(/'/g, '"')\n .replace(//g, '>');\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('loadTemplates', function (templatesToLoad, once) {\n if (once === void 0) { once = true; }\n var ret = '';\n var data = resolveQueryResult();\n var atLeastOneWasLoaded = false;\n var toLoad = templatesToLoad;\n var defaultTmpl;\n _.each(templatesToLoad, function (value, key, obj) {\n if (value == 'default') {\n defaultTmpl = key;\n }\n });\n if (defaultTmpl != undefined) {\n toLoad = _.omit(templatesToLoad, defaultTmpl);\n }\n _.each(toLoad, function (condition, id, obj) {\n if (!atLeastOneWasLoaded || !once) {\n atLeastOneWasLoaded = atLeastOneWasLoaded || condition;\n ret += TemplateHelpers_1.TemplateHelpers.getHelper('loadTemplate')(id, condition, data);\n }\n });\n if (!atLeastOneWasLoaded && defaultTmpl != undefined) {\n ret += TemplateHelpers_1.TemplateHelpers.getHelper('loadTemplate')(defaultTmpl, true, data);\n }\n return ret;\n});\nvar byteMeasure = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('size', function (value, options) {\n var size = parseInt(value, 10);\n var precision = options != null && options.precision != null ? options.precision : 2;\n var base = options != null && options.base != null ? options.base : 0;\n while (size > 1024 && base + 1 < byteMeasure.length) {\n size /= 1024;\n base++;\n }\n size = Math.floor(size * Math.pow(10, precision)) / Math.pow(10, precision);\n return size + ' ' + byteMeasure[base];\n});\nTemplateHelpers_1.TemplateHelpers.registerFieldHelper('translatedCaption', function (value) {\n return FacetUtils_1.FacetUtils.tryToGetTranslatedCaption('@filetype', value);\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('loadTemplate', function (id, condition, data) {\n if (condition === void 0) { condition = true; }\n if (Utils_1.Utils.isNullOrUndefined(data)) {\n data = resolveQueryResult();\n }\n if (condition) {\n return TemplateCache_1.TemplateCache.getTemplate(id).instantiateToString(data, {\n checkCondition: false\n });\n }\n return '';\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('encodeCarriageReturn', function (data) {\n if (Utils_1.Utils.isNullOrUndefined(data)) {\n return undefined;\n }\n else {\n return StringUtils_1.StringUtils.encodeCarriageReturn(data);\n }\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('isMobileDevice', function () {\n return DeviceUtils_1.DeviceUtils.isMobileDevice() ? DeviceUtils_1.DeviceUtils.getDeviceName() : null;\n});\nTemplateHelpers_1.TemplateHelpers.registerTemplateHelper('pluralHelper', function (count, options) {\n return count > 1 ? options.plural : options.singular;\n});\nfunction resolveQueryResult() {\n var found;\n var resultList = Component_1.Component.getComponentRef('ResultList');\n if (resultList) {\n found = resultList.resultCurrentlyBeingRendered;\n }\n if (!found) {\n var quickview = Component_1.Component.getComponentRef('Quickview');\n if (quickview) {\n found = quickview.resultCurrentlyBeingRendered;\n }\n }\n return found;\n}\nfunction resolveTermsToHighlight() {\n var currentQueryResult = resolveQueryResult();\n if (currentQueryResult) {\n return currentQueryResult.termsToHighlight;\n }\n}\nfunction resolvePhrasesToHighlight() {\n var currentQueryResult = resolveQueryResult();\n if (currentQueryResult) {\n return currentQueryResult.phrasesToHighlight;\n }\n}\nfunction termsToHighlightAreDefined(termsToHighlight, phrasesToHighlight) {\n return Utils_1.Utils.isNonEmptyArray(_.keys(termsToHighlight)) || Utils_1.Utils.isNonEmptyArray(_.keys(phrasesToHighlight));\n}\n\n\n/***/ }),\n\n/***/ 475:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * The possible values for the [allowedValuesPatternType]{@link IGroupByRequest.allowedValuesPatternType} property of the `IGroupByRequest` interface.\n */\nvar AllowedValuesPatternType;\n(function (AllowedValuesPatternType) {\n /**\n * Only supports trailing wildcards in the pattern.\n */\n AllowedValuesPatternType[\"Legacy\"] = \"legacy\";\n /**\n * Fully supports wildcards.\n */\n AllowedValuesPatternType[\"Wildcards\"] = \"wildcards\";\n /**\n * Supports regular expression as the pattern.\n */\n AllowedValuesPatternType[\"Regex\"] = \"regex\";\n /**\n *Applies the Edit Distance algorithm to match values that are close to the specified pattern.\n */\n AllowedValuesPatternType[\"EditDistance\"] = \"editdistance\";\n /**\n *Applies a phonetic algorithm to match values that are phonetically similar to the specified pattern.\n */\n AllowedValuesPatternType[\"Phonetic\"] = \"phonetic\";\n})(AllowedValuesPatternType = exports.AllowedValuesPatternType || (exports.AllowedValuesPatternType = {}));\n\n\n/***/ }),\n\n/***/ 476:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ValueElementRenderer_1 = __webpack_require__(477);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Dom_1 = __webpack_require__(1);\nvar KeyboardUtils_1 = __webpack_require__(25);\nvar ValueElement = /** @class */ (function () {\n function ValueElement(facet, facetValue, onSelect, onExclude) {\n this.facet = facet;\n this.facetValue = facetValue;\n this.onSelect = onSelect;\n this.onExclude = onExclude;\n }\n ValueElement.prototype.build = function () {\n this.renderer = new ValueElementRenderer_1.ValueElementRenderer(this.facet, this.facetValue).build();\n this.bindEvent({ displayNextTime: true, pinFacet: this.facet.options.preservePosition });\n return this;\n };\n ValueElement.prototype.bindEvent = function (eventBindings) {\n if (!Utils_1.Utils.isNullOrUndefined(eventBindings.omniboxObject)) {\n this.isOmnibox = true;\n }\n else {\n this.isOmnibox = false;\n }\n this.handleEventForCheckboxChange(eventBindings);\n if (this.facetValue.excluded) {\n this.handleEventForExcludedValueElement(eventBindings);\n }\n else {\n this.handleEventForValueElement(eventBindings);\n }\n };\n ValueElement.prototype.select = function () {\n this.facetValue.selected = true;\n this.facetValue.excluded = false;\n this.renderer.setCssClassOnListValueElement();\n };\n ValueElement.prototype.unselect = function () {\n this.facetValue.selected = false;\n this.facetValue.excluded = false;\n this.renderer.setCssClassOnListValueElement();\n };\n ValueElement.prototype.exclude = function () {\n this.facetValue.selected = false;\n this.facetValue.excluded = true;\n this.renderer.setCssClassOnListValueElement();\n };\n ValueElement.prototype.unexclude = function () {\n this.facetValue.selected = false;\n this.facetValue.excluded = false;\n this.renderer.setCssClassOnListValueElement();\n };\n ValueElement.prototype.toggleExcludeWithUA = function () {\n var _this = this;\n var actionCause;\n if (this.facetValue.excluded) {\n actionCause = this.isOmnibox ? AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxFacetUnexclude : AnalyticsActionListMeta_1.analyticsActionCauseList.facetUnexclude;\n }\n else {\n actionCause = this.isOmnibox ? AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxFacetExclude : AnalyticsActionListMeta_1.analyticsActionCauseList.facetExclude;\n }\n this.facet.toggleExcludeValue(this.facetValue);\n if (this.onExclude) {\n this.facet.triggerNewQuery(function () { return _this.onExclude(_this, actionCause); });\n }\n else {\n this.facet.triggerNewQuery(function () {\n return _this.facet.usageAnalytics.logSearchEvent(actionCause, _this.getAnalyticsFacetMeta());\n });\n }\n };\n ValueElement.prototype.handleSelectValue = function (eventBindings) {\n var _this = this;\n this.facet.keepDisplayedValuesNextTime = eventBindings.displayNextTime && !this.facet.options.useAnd;\n var actionCause;\n if (this.facetValue.excluded) {\n actionCause = this.isOmnibox ? AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxFacetUnexclude : AnalyticsActionListMeta_1.analyticsActionCauseList.facetUnexclude;\n this.facet.unexcludeValue(this.facetValue);\n }\n else {\n if (this.facetValue.selected) {\n actionCause = this.isOmnibox ? AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxFacetDeselect : AnalyticsActionListMeta_1.analyticsActionCauseList.facetDeselect;\n }\n else {\n actionCause = this.isOmnibox ? AnalyticsActionListMeta_1.analyticsActionCauseList.omniboxFacetSelect : AnalyticsActionListMeta_1.analyticsActionCauseList.facetSelect;\n }\n this.facet.toggleSelectValue(this.facetValue);\n }\n if (this.onSelect) {\n this.facet.triggerNewQuery(function () { return _this.onSelect(_this, actionCause); });\n }\n else {\n this.facet.triggerNewQuery(function () {\n return _this.facet.usageAnalytics.logSearchEvent(actionCause, _this.getAnalyticsFacetMeta());\n });\n }\n };\n ValueElement.prototype.handleExcludeClick = function (eventBindings) {\n this.facet.keepDisplayedValuesNextTime = eventBindings.displayNextTime && !this.facet.options.useAnd;\n this.toggleExcludeWithUA();\n };\n ValueElement.prototype.handleSelectEventForExcludedValueElement = function (eventBindings) {\n var _this = this;\n var clickEvent = function () {\n if (eventBindings.pinFacet) {\n _this.facet.pinFacetPosition();\n }\n if (eventBindings.omniboxObject) {\n _this.omniboxCloseEvent(eventBindings.omniboxObject);\n }\n _this.handleSelectValue(eventBindings);\n _this.tryDismissSearchResults();\n return false;\n };\n Dom_1.$$(this.renderer.label).on('click', function (e) {\n e.stopPropagation();\n clickEvent();\n });\n Dom_1.$$(this.renderer.stylishCheckbox).on('keydown', KeyboardUtils_1.KeyboardUtils.keypressAction([KeyboardUtils_1.KEYBOARD.SPACEBAR, KeyboardUtils_1.KEYBOARD.ENTER], clickEvent));\n };\n ValueElement.prototype.handleExcludeEventForValueElement = function (eventBindings) {\n var _this = this;\n var excludeAction = function (event) {\n if (eventBindings.omniboxObject) {\n _this.omniboxCloseEvent(eventBindings.omniboxObject);\n }\n _this.handleExcludeClick(eventBindings);\n _this.tryDismissSearchResults();\n event.stopPropagation();\n event.preventDefault();\n };\n Dom_1.$$(this.renderer.excludeIcon).on('click', excludeAction);\n Dom_1.$$(this.renderer.excludeIcon).on('keydown', KeyboardUtils_1.KeyboardUtils.keypressAction([KeyboardUtils_1.KEYBOARD.SPACEBAR, KeyboardUtils_1.KEYBOARD.ENTER], excludeAction));\n };\n ValueElement.prototype.handleSelectEventForValueElement = function (eventBindings) {\n var _this = this;\n var selectAction = function (event) {\n if (eventBindings.pinFacet) {\n _this.facet.pinFacetPosition();\n }\n _this.tryDismissSearchResults();\n Dom_1.$$(_this.renderer.checkbox).trigger('change');\n event.preventDefault();\n };\n Dom_1.$$(this.renderer.label).on('click', selectAction);\n Dom_1.$$(this.renderer.stylishCheckbox).on('keydown', KeyboardUtils_1.KeyboardUtils.keypressAction([KeyboardUtils_1.KEYBOARD.SPACEBAR, KeyboardUtils_1.KEYBOARD.ENTER], selectAction));\n };\n ValueElement.prototype.handleEventForExcludedValueElement = function (eventBindings) {\n this.handleSelectEventForExcludedValueElement(eventBindings);\n this.handleExcludeEventForValueElement(eventBindings);\n };\n ValueElement.prototype.handleEventForValueElement = function (eventBindings) {\n this.handleSelectEventForValueElement(eventBindings);\n this.handleExcludeEventForValueElement(eventBindings);\n };\n ValueElement.prototype.handleEventForCheckboxChange = function (eventBindings) {\n var _this = this;\n Dom_1.$$(this.renderer.checkbox).on('change', function () {\n if (eventBindings.omniboxObject) {\n _this.omniboxCloseEvent(eventBindings.omniboxObject);\n }\n _this.handleSelectValue(eventBindings);\n });\n };\n ValueElement.prototype.omniboxCloseEvent = function (eventArg) {\n eventArg.closeOmnibox();\n eventArg.clear();\n };\n ValueElement.prototype.tryDismissSearchResults = function () {\n if (this.facet && this.facet.facetSearch && this.facet.facetSearch.dismissSearchResults) {\n this.facet.facetSearch.dismissSearchResults();\n }\n };\n ValueElement.prototype.getAnalyticsFacetMeta = function () {\n return {\n facetId: this.facet.options.id,\n facetField: this.facet.options.field.toString(),\n facetValue: this.facetValue.value,\n facetTitle: this.facet.options.title\n };\n };\n return ValueElement;\n}());\nexports.ValueElement = ValueElement;\n\n\n/***/ }),\n\n/***/ 477:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar Utils_1 = __webpack_require__(4);\nvar Strings_1 = __webpack_require__(6);\nvar Component_1 = __webpack_require__(7);\nvar _ = __webpack_require__(0);\nvar SVGIcons_1 = __webpack_require__(12);\nvar SVGDom_1 = __webpack_require__(16);\nvar ValueElementRenderer = /** @class */ (function () {\n function ValueElementRenderer(facet, facetValue) {\n this.facet = facet;\n this.facetValue = facetValue;\n }\n ValueElementRenderer.prototype.withNo = function (element) {\n if (_.isArray(element)) {\n _.each(element, function (e) {\n if (e) {\n Dom_1.$$(e).detach();\n }\n });\n }\n else {\n if (element) {\n Dom_1.$$(element).detach();\n }\n }\n return this;\n };\n ValueElementRenderer.prototype.build = function () {\n this.buildListItem();\n this.initAndAppendLabel();\n this.initAndAppendExcludeIcon();\n this.setCssClassOnListValueElement();\n this.addAccessibilityAttributesToTargetElement();\n return this;\n };\n ValueElementRenderer.prototype.setCssClassOnListValueElement = function () {\n Dom_1.$$(this.listItem).toggleClass('coveo-selected', this.facetValue.selected);\n Dom_1.$$(this.listItem).toggleClass('coveo-excluded', this.facetValue.excluded);\n };\n Object.defineProperty(ValueElementRenderer.prototype, \"accessibleElement\", {\n get: function () {\n return this.stylishCheckbox;\n },\n enumerable: true,\n configurable: true\n });\n ValueElementRenderer.prototype.buildExcludeIcon = function () {\n var isExcluded = this.facetValue.excluded;\n var excludeIcon = Dom_1.$$('div', {\n ariaLabel: Strings_1.l('ExcludeValueWithResultCount', this.caption, Strings_1.l('ResultCount', this.count, parseInt(this.count, 10))),\n className: 'coveo-facet-value-exclude',\n tabindex: 0,\n role: 'button',\n ariaPressed: isExcluded.toString()\n }).el;\n this.addFocusAndBlurEventListeners(excludeIcon);\n excludeIcon.innerHTML = isExcluded ? SVGIcons_1.SVGIcons.icons.plus : SVGIcons_1.SVGIcons.icons.checkboxHookExclusionMore;\n SVGDom_1.SVGDom.addClassToSVGInContainer(excludeIcon, isExcluded ? 'coveo-facet-value-unexclude-svg' : 'coveo-facet-value-exclude-svg');\n SVGDom_1.SVGDom.addAttributesToSVGInContainer(excludeIcon, { 'aria-hidden': 'true' });\n return excludeIcon;\n };\n ValueElementRenderer.prototype.buildValueComputedField = function () {\n var computedField = this.facetValue.getFormattedComputedField(this.facet.options.computedFieldFormat);\n if (Utils_1.Utils.isNonEmptyString(computedField)) {\n var elem = Dom_1.$$('span', {\n className: 'coveo-facet-value-computed-field'\n }).el;\n Dom_1.$$(elem).text(computedField);\n return elem;\n }\n else {\n return undefined;\n }\n };\n ValueElementRenderer.prototype.buildValueCheckbox = function () {\n var checkbox = Dom_1.$$('input', {\n type: 'checkbox',\n ariaHidden: true,\n ariaLabel: this.ariaLabel\n }).el;\n this.facetValue.selected ? checkbox.setAttribute('checked', 'checked') : checkbox.removeAttribute('checked');\n this.facetValue.excluded ? checkbox.setAttribute('disabled', 'disabled') : checkbox.removeAttribute('disabled');\n Component_1.Component.pointElementsToDummyForm(checkbox);\n return checkbox;\n };\n ValueElementRenderer.prototype.buildValueStylishCheckbox = function () {\n var checkbox = Dom_1.$$('div', {\n className: 'coveo-facet-value-checkbox',\n tabindex: 0\n }).el;\n checkbox.innerHTML = SVGIcons_1.SVGIcons.icons.checkboxHookExclusionMore;\n SVGDom_1.SVGDom.addClassToSVGInContainer(checkbox, 'coveo-facet-value-checkbox-svg');\n this.addFocusAndBlurEventListeners(checkbox);\n return checkbox;\n };\n ValueElementRenderer.prototype.buildValueIcon = function () {\n var icon = this.getValueIcon();\n if (Utils_1.Utils.exists(icon)) {\n return Dom_1.$$('img', {\n className: 'coveo-facet-value-icon coveo-icon',\n src: this.getValueIcon()\n }).el;\n }\n else {\n return this.buildValueIconFromSprite();\n }\n };\n ValueElementRenderer.prototype.getValueIcon = function () {\n if (Utils_1.Utils.exists(this.facet.options.valueIcon)) {\n return this.facet.options.valueIcon(this.facetValue);\n }\n else {\n return undefined;\n }\n };\n ValueElementRenderer.prototype.buildValueIconFromSprite = function () {\n return Dom_1.$$('div', {\n className: 'coveo-facet-value-icon coveo-icon ' + this.facet.options.field.substr(1) + ' ' + this.facetValue.value\n }).el;\n };\n ValueElementRenderer.prototype.buildValueCaption = function () {\n var valueCaption = Dom_1.$$('span', {\n className: 'coveo-facet-value-caption',\n title: this.caption,\n 'data-original-value': this.facetValue.value\n }).el;\n Dom_1.$$(valueCaption).text(this.caption);\n return valueCaption;\n };\n ValueElementRenderer.prototype.buildValueCount = function () {\n if (Utils_1.Utils.isNonEmptyString(this.count)) {\n var countElement = Dom_1.$$('span', {\n className: 'coveo-facet-value-count'\n }).el;\n Dom_1.$$(countElement).text(this.count);\n return countElement;\n }\n else {\n return undefined;\n }\n };\n Object.defineProperty(ValueElementRenderer.prototype, \"caption\", {\n get: function () {\n return this.facet.getValueCaption(this.facetValue);\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(ValueElementRenderer.prototype, \"count\", {\n get: function () {\n return this.facetValue.getFormattedCount();\n },\n enumerable: true,\n configurable: true\n });\n ValueElementRenderer.prototype.addFocusAndBlurEventListeners = function (elem) {\n var _this = this;\n Dom_1.$$(elem).on('focus', function () { return Dom_1.$$(_this.listItem).addClass('coveo-focused'); });\n Dom_1.$$(elem).on('blur', function () { return Dom_1.$$(_this.listItem).removeClass('coveo-focused'); });\n };\n ValueElementRenderer.prototype.buildListItem = function () {\n this.listItem = Dom_1.$$('li', { className: 'coveo-facet-value coveo-facet-selectable', ariaLabel: this.ariaLabel }).el;\n if (!Dom_1.$$(this.listItem).canHandleEvent('touchstart')) {\n Dom_1.$$(this.listItem).addClass('coveo-with-hover');\n }\n this.listItem.setAttribute('data-value', this.facetValue.value);\n };\n ValueElementRenderer.prototype.initAndAppendLabel = function () {\n this.label = Dom_1.$$('label', { className: 'coveo-facet-value-label', role: 'group' }).el;\n this.tryToInitAndAppendComputedField();\n this.initAndAppendFacetValueLabelWrapper();\n this.listItem.appendChild(this.label);\n };\n ValueElementRenderer.prototype.initAndAppendExcludeIcon = function () {\n this.excludeIcon = this.buildExcludeIcon();\n this.attachExcludeIconEventHandlers();\n this.listItem.appendChild(this.excludeIcon);\n };\n ValueElementRenderer.prototype.attachExcludeIconEventHandlers = function () {\n var _this = this;\n Dom_1.$$(this.excludeIcon).on('mouseover', function () {\n Dom_1.$$(_this.listItem).addClass('coveo-facet-value-will-exclude');\n });\n Dom_1.$$(this.excludeIcon).on('mouseout', function () {\n Dom_1.$$(_this.listItem).removeClass('coveo-facet-value-will-exclude');\n });\n };\n ValueElementRenderer.prototype.tryToInitAndAppendComputedField = function () {\n if (!Utils_1.Utils.exists(this.facetValue.computedField)) {\n return;\n }\n this.computedField = this.buildValueComputedField();\n if (!this.computedField) {\n return;\n }\n this.label.appendChild(this.computedField);\n Dom_1.$$(this.label).addClass('coveo-with-computed-field');\n };\n ValueElementRenderer.prototype.initAndAppendFacetValueLabelWrapper = function () {\n this.facetValueLabelWrapper = Dom_1.$$('div', { className: 'coveo-facet-value-label-wrapper' }).el;\n this.initAndAppendCheckbox();\n this.initAndAppendStylishCheckbox();\n this.initAndAppendValueCaption();\n this.initAndAppendValueCount();\n this.label.appendChild(this.facetValueLabelWrapper);\n };\n ValueElementRenderer.prototype.initAndAppendCheckbox = function () {\n this.checkbox = this.buildValueCheckbox();\n this.facetValueLabelWrapper.appendChild(this.checkbox);\n };\n ValueElementRenderer.prototype.initAndAppendStylishCheckbox = function () {\n this.stylishCheckbox = this.buildValueStylishCheckbox();\n this.facetValueLabelWrapper.appendChild(this.stylishCheckbox);\n };\n ValueElementRenderer.prototype.initAndAppendValueCount = function () {\n this.valueCount = this.buildValueCount();\n if (!this.valueCount) {\n return;\n }\n this.facetValueLabelWrapper.appendChild(this.valueCount);\n };\n ValueElementRenderer.prototype.initAndAppendValueCaption = function () {\n this.valueCaption = this.buildValueCaption();\n this.facetValueLabelWrapper.appendChild(this.valueCaption);\n };\n ValueElementRenderer.prototype.addAccessibilityAttributesToTargetElement = function () {\n var el = this.accessibleElement;\n el.setAttribute('aria-label', this.ariaLabel);\n el.setAttribute('role', 'button');\n el.setAttribute('aria-pressed', this.ariaPressed);\n };\n Object.defineProperty(ValueElementRenderer.prototype, \"ariaLabel\", {\n get: function () {\n var resultCount = Strings_1.l('ResultCount', this.count, parseInt(this.count, 10));\n return \"\" + Strings_1.l('IncludeValueWithResultCount', this.caption, resultCount);\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(ValueElementRenderer.prototype, \"ariaPressed\", {\n get: function () {\n if (this.facetValue.excluded) {\n return 'mixed';\n }\n return this.facetValue.selected ? 'true' : 'false';\n },\n enumerable: true,\n configurable: true\n });\n return ValueElementRenderer;\n}());\nexports.ValueElementRenderer = ValueElementRenderer;\n\n\n/***/ }),\n\n/***/ 478:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar StringUtils_1 = __webpack_require__(22);\nvar _ = __webpack_require__(0);\nvar FacetValuesOrder = /** @class */ (function () {\n function FacetValuesOrder(facet, facetSort) {\n this.facet = facet;\n this.facetSort = facetSort;\n }\n FacetValuesOrder.prototype.reorderValues = function (facetValues) {\n if (this.facetSort && this.facetSort.activeSort) {\n if (this.usingCustomSort) {\n return this.reorderValuesWithCustomOrder(facetValues);\n }\n if (this.usingAlphabeticalSort) {\n return this.reorderValuesWithCustomCaption(facetValues);\n }\n }\n return facetValues;\n };\n FacetValuesOrder.prototype.reorderValuesIfUsingCustomSort = function (values) {\n return this.usingCustomSort ? this.reorderValuesWithCustomOrder(values) : values;\n };\n FacetValuesOrder.prototype.reorderValuesIfUsingAlphabeticalSort = function (values) {\n return this.usingAlphabeticalSort ? this.reorderValuesWithCustomCaption(values) : values;\n };\n Object.defineProperty(FacetValuesOrder.prototype, \"usingCustomSort\", {\n get: function () {\n return this.facetSort.activeSort.name == 'custom' && this.facet.options.customSort != undefined;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetValuesOrder.prototype, \"usingAlphabeticalSort\", {\n get: function () {\n return this.facetSort.activeSort.name.indexOf('alpha') != -1;\n },\n enumerable: true,\n configurable: true\n });\n FacetValuesOrder.prototype.reorderValuesWithCustomOrder = function (facetValues) {\n var customSortsLowercase = _.map(this.facet.options.customSort, function (customSort) { return customSort.toLowerCase(); });\n var valueIndexPair = _.map(facetValues, function (facetValue, i) {\n // Get the index of the current value in the custom sort array.\n // If it's not found, put it's index to it's original value + the length of customSort so that's always after the specified custom sort order.\n var index = _.findIndex(customSortsLowercase, function (customSort) {\n return (StringUtils_1.StringUtils.equalsCaseInsensitive(customSort, facetValue.value) ||\n (facetValue.lookupValue != null && StringUtils_1.StringUtils.equalsCaseInsensitive(customSort, facetValue.lookupValue)));\n });\n if (index == -1) {\n index = i + customSortsLowercase.length;\n }\n return { facetValue: facetValue, index: index };\n });\n var sorted = _.sortBy(valueIndexPair, 'index');\n sorted = this.facetSort.customSortDirection == 'ascending' ? sorted : sorted.reverse();\n return _.pluck(sorted, 'facetValue');\n };\n FacetValuesOrder.prototype.reorderValuesWithCustomCaption = function (facetValues) {\n var _this = this;\n var sorted = facetValues.sort(function (firstValue, secondValue) {\n return _this.facet.getValueCaption(firstValue).localeCompare(_this.facet.getValueCaption(secondValue), String['locale'], {\n sensitivity: 'base'\n });\n });\n if (this.facetSort.activeSort.name.indexOf('descending') != -1) {\n sorted = sorted.reverse();\n }\n return sorted;\n };\n return FacetValuesOrder;\n}());\nexports.FacetValuesOrder = FacetValuesOrder;\n\n\n/***/ }),\n\n/***/ 479:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar SVGIcons_1 = __webpack_require__(12);\nvar SVGDom_1 = __webpack_require__(16);\nvar Component_1 = __webpack_require__(7);\nvar Strings_1 = __webpack_require__(6);\nvar EventsUtils_1 = __webpack_require__(137);\nvar FacetSearchUserInputHandler_1 = __webpack_require__(544);\nvar underscore_1 = __webpack_require__(0);\nvar SearchDropdownNavigatorFactory_1 = __webpack_require__(545);\nvar KeyboardUtils_1 = __webpack_require__(25);\nvar FacetSearchElement = /** @class */ (function () {\n function FacetSearchElement(facetSearch) {\n this.facetSearch = facetSearch;\n this.searchBarIsAnimating = false;\n this.triggeredScroll = false;\n this.facetSearchId = underscore_1.uniqueId('coveo-facet-search-results');\n this.facetValueNotFoundId = underscore_1.uniqueId('coveo-facet-value-not-found');\n this.facetSearchUserInputHandler = new FacetSearchUserInputHandler_1.FacetSearchUserInputHandler(this.facetSearch);\n this.initSearchResults();\n }\n FacetSearchElement.prototype.build = function (handleFacetSearchClear) {\n var _this = this;\n this.search = document.createElement('div');\n Dom_1.$$(this.search).addClass('coveo-facet-search');\n this.magnifier = this.buildMagnifierIcon();\n this.search.appendChild(this.magnifier);\n this.wait = this.buildWaitIcon();\n this.search.appendChild(this.wait);\n this.hideFacetSearchWaitingAnimation();\n this.clear = Dom_1.$$('div', { className: 'coveo-facet-search-clear', title: Strings_1.l('Clear', Strings_1.l('Search')) }, SVGIcons_1.SVGIcons.icons.clear).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(this.clear, 'coveo-facet-search-clear-svg');\n this.clear.style.display = 'none';\n this.search.appendChild(this.clear);\n this.combobox = this.buildCombobox();\n this.search.appendChild(this.combobox);\n this.input = this.buildInputElement();\n Component_1.Component.pointElementsToDummyForm(this.input);\n this.combobox.appendChild(this.input);\n Dom_1.$$(this.input).on('keyup', function (e) {\n _this.facetSearchUserInputHandler.handleKeyboardEvent(e);\n });\n Dom_1.$$(this.clear).on('click', function (e) {\n handleFacetSearchClear && handleFacetSearchClear();\n });\n Dom_1.$$(this.input).on('focus', function (e) {\n _this.handleFacetSearchFocus();\n });\n Dom_1.$$(this.input).on('blur', function (e) { return _this.onInputBlur(e); });\n this.detectSearchBarAnimation();\n this.initSearchDropdownNavigator();\n return this.search;\n };\n FacetSearchElement.prototype.initSearchResults = function () {\n var _this = this;\n this.searchResults = Dom_1.$$('ul', { id: this.facetSearchId, className: 'coveo-facet-search-results', role: 'listbox' }).el;\n Dom_1.$$(this.searchResults).on('scroll', function () { return _this.handleScrollEvent(); });\n Dom_1.$$(this.searchResults).on('keyup', function (e) {\n if (e.which === KeyboardUtils_1.KEYBOARD.ESCAPE) {\n _this.facetSearch.dismissSearchResults();\n }\n });\n Dom_1.$$(this.searchResults).on('focusout', function (event) { return _this.onSearchResultsFocusOut(event); });\n Dom_1.$$(this.searchResults).hide();\n };\n FacetSearchElement.prototype.onInputBlur = function (e) {\n var target = e.relatedTarget;\n var isUsingKeyboard = !!target;\n var focusedOnSearchResult = this.searchResults.contains(target);\n if (isUsingKeyboard && !focusedOnSearchResult) {\n this.facetSearch.dismissSearchResults();\n }\n };\n FacetSearchElement.prototype.onSearchResultsFocusOut = function (e) {\n var target = e.relatedTarget;\n var isUsingKeyboard = !!target;\n var focusedOnInput = this.input.contains(target);\n var focusedOnSearchResult = this.searchResults.contains(target);\n if (isUsingKeyboard && !focusedOnInput && !focusedOnSearchResult) {\n this.facetSearch.dismissSearchResults();\n }\n };\n FacetSearchElement.prototype.initSearchDropdownNavigator = function () {\n var _this = this;\n var config = {\n input: this.input,\n searchResults: this.searchResults,\n setScrollTrigger: function (val) { return (_this.triggeredScroll = val); }\n };\n this.searchDropdownNavigator = SearchDropdownNavigatorFactory_1.SearchDropdownNavigatorFactory(this.facetSearch, config);\n };\n FacetSearchElement.prototype.buildCombobox = function () {\n return Dom_1.$$('div', {\n className: 'coveo-facet-search-middle',\n ariaHaspopup: 'listbox',\n ariaExpanded: 'true'\n }).el;\n };\n FacetSearchElement.prototype.showFacetSearchWaitingAnimation = function () {\n this.magnifier && Dom_1.$$(this.magnifier).hide();\n Dom_1.$$(this.wait).show();\n };\n FacetSearchElement.prototype.getValueInInputForFacetSearch = function () {\n return this.input.value.trim();\n };\n FacetSearchElement.prototype.hideFacetSearchWaitingAnimation = function () {\n Dom_1.$$(this.magnifier).show();\n Dom_1.$$(this.wait).hide();\n };\n FacetSearchElement.prototype.detectSearchBarAnimation = function () {\n var _this = this;\n EventsUtils_1.EventsUtils.addPrefixedEvent(this.search, 'AnimationStart', function (event) {\n if (event.animationName == 'grow') {\n _this.searchBarIsAnimating = true;\n }\n });\n EventsUtils_1.EventsUtils.addPrefixedEvent(this.search, 'AnimationEnd', function (event) {\n if (event.animationName == 'grow') {\n _this.searchBarIsAnimating = false;\n }\n });\n };\n FacetSearchElement.prototype.positionSearchResults = function () {\n var _this = this;\n if (this.searchResults != null) {\n Dom_1.$$(this.searchResults).insertAfter(this.search);\n Dom_1.$$(this.searchResults).show();\n if (Dom_1.$$(this.searchResults).css('display') == 'none') {\n this.searchResults.style.display = '';\n }\n var searchBar = Dom_1.$$(this.search);\n if (searchBar.css('display') == 'none' || this.searchBarIsAnimating) {\n if (Dom_1.$$(this.searchResults).css('display') == 'none') {\n this.searchResults.style.display = '';\n }\n EventsUtils_1.EventsUtils.addPrefixedEvent(this.search, 'AnimationEnd', function () {\n EventsUtils_1.EventsUtils.removePrefixedEvent(_this.search, 'AnimationEnd', _this);\n });\n }\n }\n this.addAriaAttributes();\n };\n FacetSearchElement.prototype.setAsCurrentResult = function (toSet) {\n this.searchDropdownNavigator.setAsCurrentResult(toSet);\n };\n Object.defineProperty(FacetSearchElement.prototype, \"currentResult\", {\n get: function () {\n return this.searchDropdownNavigator.currentResult;\n },\n enumerable: true,\n configurable: true\n });\n FacetSearchElement.prototype.moveCurrentResultDown = function () {\n this.searchDropdownNavigator.focusNextElement();\n };\n FacetSearchElement.prototype.moveCurrentResultUp = function () {\n this.searchDropdownNavigator.focusPreviousElement();\n };\n FacetSearchElement.prototype.highlightCurrentQueryInSearchResults = function (regex) {\n var captions = this.facetSearch.getCaptions();\n captions.forEach(function (caption) {\n caption.innerHTML = Dom_1.$$(caption).text().replace(regex, '$1');\n });\n };\n FacetSearchElement.prototype.appendToSearchResults = function (el) {\n this.searchResults.appendChild(el);\n this.setupFacetSearchResultsEvents(el);\n };\n FacetSearchElement.prototype.emptyAndShowNoResults = function () {\n Dom_1.$$(this.searchResults).empty();\n this.searchResults.appendChild(Dom_1.$$('li', { id: this.facetValueNotFoundId, className: 'coveo-facet-value-not-found', role: 'option', ariaSelected: 'true', tabindex: 0 }, Strings_1.l('NoValuesFound')).el);\n this.input.setAttribute('aria-activedescendant', this.facetValueNotFoundId);\n };\n FacetSearchElement.prototype.updateAriaLiveWithResults = function (inputValue, numberOfResults, moreValuesToFetch) {\n var ariaLiveText = inputValue === ''\n ? Strings_1.l('ShowingResults', numberOfResults, inputValue, numberOfResults)\n : Strings_1.l('ShowingResultsWithQuery', numberOfResults, inputValue, numberOfResults);\n if (moreValuesToFetch) {\n ariaLiveText = ariaLiveText + \" (\" + Strings_1.l('MoreValuesAvailable') + \")\";\n }\n this.facetSearch.updateAriaLive(ariaLiveText);\n };\n FacetSearchElement.prototype.focus = function () {\n this.input.focus();\n this.handleFacetSearchFocus();\n };\n FacetSearchElement.prototype.handleFacetSearchFocus = function () {\n if (this.facetSearch.currentlyDisplayedResults == null) {\n this.facetSearch.displayNewValues();\n this.addAriaAttributes();\n }\n };\n FacetSearchElement.prototype.setupFacetSearchResultsEvents = function (el) {\n var _this = this;\n Dom_1.$$(el).on('mousemove', function () {\n _this.setAsCurrentResult(Dom_1.$$(el));\n });\n // Prevent closing the search results on the end of a touch drag\n var touchDragging = false;\n var mouseDragging = false;\n Dom_1.$$(el).on('mousedown', function () { return (mouseDragging = false); });\n Dom_1.$$(el).on('mousemove', function () { return (mouseDragging = true); });\n Dom_1.$$(el).on('touchmove', function () { return (touchDragging = true); });\n Dom_1.$$(el).on('mouseup touchend', function () {\n if (!touchDragging && !mouseDragging) {\n setTimeout(function () {\n _this.facetSearch.dismissSearchResults();\n }, 0); // setTimeout is to give time to trigger the click event before hiding the search menu.\n }\n touchDragging = false;\n mouseDragging = false;\n });\n };\n FacetSearchElement.prototype.hideSearchResultsElement = function () {\n this.removeAriaAttributes();\n Dom_1.$$(this.searchResults).hide();\n Dom_1.$$(this.searchResults).remove();\n };\n FacetSearchElement.prototype.clearSearchInput = function () {\n if (this.input) {\n this.input.value = '';\n }\n };\n FacetSearchElement.prototype.buildMagnifierIcon = function () {\n var magnifier = document.createElement('div');\n magnifier.innerHTML = SVGIcons_1.SVGIcons.icons.search;\n Dom_1.$$(magnifier).addClass('coveo-facet-search-magnifier');\n SVGDom_1.SVGDom.addClassToSVGInContainer(magnifier, 'coveo-facet-search-magnifier-svg');\n this.search.appendChild(magnifier);\n return magnifier;\n };\n FacetSearchElement.prototype.buildWaitIcon = function () {\n var wait = document.createElement('div');\n wait.innerHTML = SVGIcons_1.SVGIcons.icons.loading;\n Dom_1.$$(wait).addClass('coveo-facet-search-wait-animation');\n SVGDom_1.SVGDom.addClassToSVGInContainer(wait, 'coveo-facet-search-wait-animation-svg');\n return wait;\n };\n FacetSearchElement.prototype.buildInputElement = function () {\n return Dom_1.$$('input', {\n className: 'coveo-facet-search-input',\n type: 'text',\n autocapitalize: 'off',\n autocorrect: 'off',\n ariaLabel: Strings_1.l('SearchFacetResults', this.facetSearch.facetTitle),\n ariaHaspopup: 'true',\n ariaAutocomplete: 'list'\n }).el;\n };\n FacetSearchElement.prototype.handleScrollEvent = function () {\n if (this.triggeredScroll) {\n this.triggeredScroll = false;\n }\n else {\n this.facetSearchUserInputHandler.handleFacetSearchResultsScroll();\n }\n };\n FacetSearchElement.prototype.addAriaAttributes = function () {\n if (!this.input || !this.combobox) {\n return;\n }\n this.combobox.setAttribute('role', 'combobox');\n this.combobox.setAttribute('aria-owns', this.facetSearchId);\n this.input.setAttribute('aria-controls', this.facetSearchId);\n this.input.setAttribute('aria-expanded', 'true');\n this.facetSearch.setExpandedFacetSearchAccessibilityAttributes(this.searchResults);\n };\n FacetSearchElement.prototype.removeAriaAttributes = function () {\n if (!this.input || !this.combobox) {\n return;\n }\n this.combobox.removeAttribute('role');\n this.combobox.removeAttribute('aria-owns');\n this.input.removeAttribute('aria-controls');\n this.input.removeAttribute('aria-activedescendant');\n this.input.setAttribute('aria-expanded', 'false');\n this.facetSearch.setCollapsedFacetSearchAccessibilityAttributes();\n };\n return FacetSearchElement;\n}());\nexports.FacetSearchElement = FacetSearchElement;\n\n\n/***/ }),\n\n/***/ 480:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nvar DefaultSearchDropdownNavigator = /** @class */ (function () {\n function DefaultSearchDropdownNavigator(config) {\n this.config = config;\n }\n DefaultSearchDropdownNavigator.prototype.setAsCurrentResult = function (toSet) {\n this.currentResult && this.currentResult.removeClass('coveo-facet-search-current-result');\n this.currentResult = toSet;\n toSet.addClass('coveo-facet-search-current-result');\n this.updateSelectedOption(toSet);\n };\n DefaultSearchDropdownNavigator.prototype.focusNextElement = function () {\n this.moveCurrentResultDown();\n };\n DefaultSearchDropdownNavigator.prototype.focusPreviousElement = function () {\n this.moveCurrentResultUp();\n };\n DefaultSearchDropdownNavigator.prototype.moveCurrentResultDown = function () {\n var nextResult = this.currentResult.el.nextElementSibling;\n if (!nextResult) {\n nextResult = underscore_1.first(this.searchResults.children);\n }\n this.setAsCurrentResult(Dom_1.$$(nextResult));\n this.highlightAndShowCurrentResultWithKeyboard();\n };\n DefaultSearchDropdownNavigator.prototype.moveCurrentResultUp = function () {\n var previousResult = this.currentResult.el.previousElementSibling;\n if (!previousResult) {\n previousResult = underscore_1.last(this.searchResults.children);\n }\n this.setAsCurrentResult(Dom_1.$$(previousResult));\n this.highlightAndShowCurrentResultWithKeyboard();\n };\n DefaultSearchDropdownNavigator.prototype.highlightAndShowCurrentResultWithKeyboard = function () {\n this.currentResult.addClass('coveo-facet-search-current-result');\n this.config.setScrollTrigger(true);\n this.searchResults.scrollTop = this.currentResult.el.offsetTop;\n };\n Object.defineProperty(DefaultSearchDropdownNavigator.prototype, \"searchResults\", {\n get: function () {\n return this.config.searchResults;\n },\n enumerable: true,\n configurable: true\n });\n DefaultSearchDropdownNavigator.prototype.updateSelectedOption = function (option) {\n this.config.input.setAttribute('aria-activedescendant', option.getAttribute('id'));\n var previouslySelectedOption = Dom_1.$$(this.searchResults).find('[aria-selected^=\"true\"]');\n previouslySelectedOption && previouslySelectedOption.setAttribute('aria-selected', 'false');\n option.setAttribute('aria-selected', 'true');\n };\n return DefaultSearchDropdownNavigator;\n}());\nexports.DefaultSearchDropdownNavigator = DefaultSearchDropdownNavigator;\n\n\n/***/ }),\n\n/***/ 481:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar CategoryValue_1 = __webpack_require__(549);\nvar underscore_1 = __webpack_require__(0);\nvar CategoryChildrenValueRenderer = /** @class */ (function () {\n function CategoryChildrenValueRenderer(element, categoryFacetTemplates, categoryValue, categoryFacet) {\n this.element = element;\n this.categoryFacetTemplates = categoryFacetTemplates;\n this.categoryValue = categoryValue;\n this.categoryFacet = categoryFacet;\n this.children = [];\n }\n CategoryChildrenValueRenderer.prototype.clearChildren = function () {\n this.element.removeClass('coveo-active-category-facet-parent');\n this.children.forEach(function (child) {\n child.clear();\n });\n this.children = [];\n };\n CategoryChildrenValueRenderer.prototype.renderChildren = function (values) {\n var _this = this;\n underscore_1.each(values, function (value) {\n _this.renderValue(value, true).makeSelectable();\n });\n };\n CategoryChildrenValueRenderer.prototype.renderAsParent = function (value) {\n var categoryValue = this.renderValue(value, false);\n return categoryValue;\n };\n CategoryChildrenValueRenderer.prototype.renderValue = function (value, isChild) {\n var path = this.categoryValue.path.concat([value.value]);\n var categoryValueDescriptor = {\n value: value.value,\n count: value.numberOfResults,\n path: path\n };\n var categoryValue = new CategoryValue_1.CategoryValue(this.categoryValue.listRoot, categoryValueDescriptor, this.categoryFacetTemplates, this.categoryFacet);\n categoryValue.render(isChild);\n this.children.push(categoryValue);\n return categoryValue;\n };\n return CategoryChildrenValueRenderer;\n}());\nexports.CategoryChildrenValueRenderer = CategoryChildrenValueRenderer;\n\n\n/***/ }),\n\n/***/ 482:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar popper_js_1 = __webpack_require__(97);\n__webpack_require__(558);\nvar underscore_1 = __webpack_require__(0);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Strings_1 = __webpack_require__(6);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Dom_1 = __webpack_require__(1);\nvar KeyboardUtils_1 = __webpack_require__(25);\nvar LocalStorageUtils_1 = __webpack_require__(41);\nvar SVGDom_1 = __webpack_require__(16);\nvar SVGIcons_1 = __webpack_require__(12);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar FacetSort_1 = __webpack_require__(483);\n/**\n * Handle the rendering of the {@link Facet} settings menu (typically the ... in the facet header).\n */\nvar FacetSettings = /** @class */ (function (_super) {\n __extends(FacetSettings, _super);\n function FacetSettings(sorts, facet) {\n var _this = _super.call(this, sorts, facet) || this;\n _this.sorts = sorts;\n _this.facet = facet;\n _this.customSortDirectionChange = false;\n _this.onDocumentClick = function () { return _this.close(); };\n _this.enabledSortsIgnoreRenderBecauseOfPairs = [];\n _this.filterDuplicateForRendering();\n return _this;\n }\n Object.defineProperty(FacetSettings.prototype, \"isExpanded\", {\n get: function () {\n return this.settingsButton && this.settingsButton.getAttribute('aria-expanded') === \"\" + true;\n },\n set: function (expanded) {\n this.settingsButton.setAttribute('aria-expanded', \"\" + expanded);\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSettings.prototype, \"firstFocusablePopupElement\", {\n get: function () {\n return underscore_1.find(Dom_1.$$(this.settingsPopup).findAll('[tabindex]'), function (element) { return element.tabIndex >= 0; });\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Build the menu, hook click events.\n * @returns {HTMLElement}\n */\n FacetSettings.prototype.build = function () {\n var _this = this;\n this.buildSettingsButton();\n this.buildSettingsPopup();\n if (Utils_1.Utils.isNonEmptyArray(this.enabledSorts)) {\n this.sortSection = this.buildSortSection();\n if (this.enabledSortsAllowDirection()) {\n this.directionSection = this.buildDirectionSection();\n }\n }\n if (this.facet.options.enableSettingsFacetState) {\n this.saveStateSection = this.buildSaveStateSection();\n this.clearStateSection = this.buildClearStateSection();\n }\n if (this.facet.options.enableCollapse) {\n this.hideSection = this.buildHideSection();\n this.showSection = this.buildShowSection();\n }\n var appendCommon = function () {\n _this.appendIfNotUndefined(_this.saveStateSection);\n _this.appendIfNotUndefined(_this.clearStateSection);\n _this.appendIfNotUndefined(_this.hideSection);\n _this.appendIfNotUndefined(_this.showSection);\n };\n this.addOnDocumentClickHandler();\n this.addOnNukeHandler();\n if (Utils_1.Utils.isNonEmptyArray(this.enabledSorts)) {\n this.settingsPopup.appendChild(this.sortSection.element);\n underscore_1.each(this.directionSection, function (d) {\n _this.appendIfNotUndefined(d);\n });\n appendCommon();\n }\n else {\n appendCommon();\n }\n return this.settingsButton;\n };\n /**\n * Restore the facet state from local storage, and apply it in the query state model.\n */\n FacetSettings.prototype.loadSavedState = function () {\n if (this.facetStateLocalStorage) {\n // set the state from the settings only if there is nothing\n // in the query state model for the current facet\n var state = this.facetStateLocalStorage.load();\n var currentStateIncluded = this.facet.queryStateModel.get(this.includedStateAttribute);\n var currentStateExcluded = this.facet.queryStateModel.get(this.excludedStateAttribute);\n var currentStateOperator = this.facet.queryStateModel.get(this.operatorStateAttribute);\n if (!Utils_1.Utils.isNullOrUndefined(state) &&\n Utils_1.Utils.isEmptyArray(currentStateIncluded) &&\n Utils_1.Utils.isEmptyArray(currentStateExcluded) &&\n !Utils_1.Utils.isNonEmptyString(currentStateOperator)) {\n var toSet = {};\n toSet[this.includedStateAttribute] = state.included;\n toSet[this.excludedStateAttribute] = state.excluded;\n toSet[this.operatorStateAttribute] = state.operator;\n this.facet.queryStateModel.setMultiple(toSet);\n this.loadedFromSettings = toSet;\n }\n }\n else {\n this.facet.logger.info('Facet state local storage not enabled : See Facet.options.enableSettingsFacetState');\n }\n };\n /**\n * Take the current state of the facet and save it in the local storage.\n */\n FacetSettings.prototype.saveState = function () {\n if (this.facetStateLocalStorage) {\n this.facetStateLocalStorage.save({\n included: this.facet.queryStateModel.get(this.includedStateAttribute),\n excluded: this.facet.queryStateModel.get(this.excludedStateAttribute),\n operator: this.facet.queryStateModel.get(this.operatorStateAttribute)\n });\n }\n else {\n this.facet.logger.info('Facet state local storage not enabled : See Facet.options.enableSettingsFacetState');\n }\n };\n /**\n * Close the settings menu\n */\n FacetSettings.prototype.close = function () {\n if (!this.isExpanded) {\n return;\n }\n this.isExpanded = false;\n Dom_1.$$(this.settingsPopup).detach();\n };\n /**\n * Open the settings menu\n */\n FacetSettings.prototype.open = function () {\n var _this = this;\n Dom_1.$$(this.settingsPopup).insertAfter(this.settingsButton);\n new popper_js_1.default(this.settingsButton, this.settingsPopup);\n this.isExpanded = true;\n if (this.hideSection && this.showSection) {\n Dom_1.$$(this.hideSection).toggle(!Dom_1.$$(this.facet.element).hasClass('coveo-facet-collapsed'));\n Dom_1.$$(this.showSection).toggle(Dom_1.$$(this.facet.element).hasClass('coveo-facet-collapsed'));\n }\n if (this.facet.options.enableSettingsFacetState) {\n Dom_1.$$(this.clearStateSection).toggle(!Utils_1.Utils.isNullOrUndefined(this.facetStateLocalStorage.load()));\n }\n underscore_1.each(this.enabledSorts, function (criteria, i) {\n if (_this.activeSort.name == criteria.name.toLowerCase()) {\n _this.selectItem(_this.getSortItem(criteria.name));\n }\n else {\n _this.unselectItem(_this.getSortItem(criteria.name));\n }\n });\n var elementToFocus = this.firstFocusablePopupElement;\n if (elementToFocus) {\n elementToFocus.focus();\n }\n };\n FacetSettings.prototype.getSortItem = function (sortName) {\n return underscore_1.find(this.sortSection.sortItems, function (sortItem) {\n return Dom_1.$$(sortItem).getAttribute('data-sort-name').toLowerCase() == sortName.replace('ascending|descending', '').toLowerCase();\n });\n };\n Object.defineProperty(FacetSettings.prototype, \"button\", {\n get: function () {\n return this.settingsButton;\n },\n enumerable: true,\n configurable: true\n });\n FacetSettings.prototype.buildSettingsButton = function () {\n var _this = this;\n this.settingsButton = Dom_1.$$('div', { className: 'coveo-facet-header-settings', 'aria-haspopup': 'true' }).el;\n this.settingsButton.innerHTML = SVGIcons_1.SVGIcons.icons.more;\n SVGDom_1.SVGDom.addClassToSVGInContainer(this.settingsButton, 'coveo-facet-settings-more-svg');\n this.hideElementOnMouseEnterLeave(this.settingsButton);\n this.isExpanded = false;\n new AccessibleButton_1.AccessibleButton()\n .withElement(this.settingsButton)\n .withLabel(Strings_1.l('Settings'))\n .withClickAction(function (e) { return _this.handleSettingsButtonClick(e); })\n .withEnterKeyboardAction(function (e) { return _this.handleSettingsButtonClick(e); })\n .build();\n };\n FacetSettings.prototype.hideElementOnMouseEnterLeave = function (el) {\n var _this = this;\n var mouseLeave = function () { return (_this.closeTimeout = window.setTimeout(function () { return _this.close(); }, 300)); };\n var mouseEnter = function () { return clearTimeout(_this.closeTimeout); };\n Dom_1.$$(el).on('mouseleave', mouseLeave);\n Dom_1.$$(el).on('mouseenter', mouseEnter);\n Dom_1.$$(el).on('keyup', KeyboardUtils_1.KeyboardUtils.keypressAction(KeyboardUtils_1.KEYBOARD.ESCAPE, function () { return _this.handleKeyboardClose(); }));\n };\n FacetSettings.prototype.handleKeyboardClose = function () {\n this.close();\n this.settingsButton.focus();\n };\n FacetSettings.prototype.buildSettingsPopup = function () {\n var _this = this;\n this.settingsPopup = Dom_1.$$('div', { className: 'coveo-facet-settings-popup' }).el;\n this.hideElementOnMouseEnterLeave(this.settingsPopup);\n Dom_1.$$(this.settingsPopup).on('focusout', function (e) {\n if (e.relatedTarget && _this.settingsPopup.contains(e.relatedTarget)) {\n return;\n }\n _this.close();\n });\n };\n FacetSettings.prototype.buildSortSection = function () {\n var sortSection = this.buildSection('coveo-facet-settings-section-sort');\n var sortSectionIcon = this.buildIcon('coveo-facet-settings-section-sort-svg', SVGIcons_1.SVGIcons.icons.sort);\n var sortSectionItems = this.buildItems();\n var sortTitle = document.createElement('div');\n Dom_1.$$(sortTitle).addClass('coveo-facet-settings-section-sort-title');\n Dom_1.$$(sortTitle).text(Strings_1.l('SortBy') + ' :');\n sortSectionItems.appendChild(sortTitle);\n var sortItems = this.buildSortSectionItems();\n underscore_1.each(sortItems, function (s) {\n sortSectionItems.appendChild(s);\n });\n sortSection.appendChild(sortSectionIcon);\n sortSection.appendChild(sortSectionItems);\n return { element: sortSection, sortItems: sortItems };\n };\n FacetSettings.prototype.buildSortSectionItems = function () {\n var _this = this;\n var elems = underscore_1.map(this.enabledSorts, function (enabledSort) {\n if (underscore_1.contains(_this.enabledSortsIgnoreRenderBecauseOfPairs, enabledSort)) {\n return undefined;\n }\n else {\n var elem = _this.buildItem(Strings_1.l(enabledSort.label), enabledSort.description);\n Dom_1.$$(elem).setAttribute('data-sort-name', enabledSort.name.toLowerCase().replace('ascending|descending', ''));\n new AccessibleButton_1.AccessibleButton()\n .withElement(elem)\n .withSelectAction(function (e) { return _this.handleClickSortButton(e, enabledSort); })\n .withLabel(enabledSort.label)\n .build();\n return elem;\n }\n });\n elems = underscore_1.compact(elems);\n return elems;\n };\n FacetSettings.prototype.closePopupAndUpdateSort = function () {\n this.close();\n if (this.activeSort.name != 'custom') {\n this.facet.updateSort(this.activeSort.name);\n }\n else {\n this.facet.updateSort('nosort');\n if (this.customSortDirectionChange) {\n this.customSortDirectionChange = false;\n this.facet.queryController.executeQuery();\n }\n }\n };\n FacetSettings.prototype.enabledSortsAllowDirection = function () {\n var _this = this;\n var allEnabledSortsWithPossibleDirectionToggle = underscore_1.filter(this.enabledSorts, function (facetSortDescription) {\n return facetSortDescription.directionToggle;\n });\n var allowToggle = underscore_1.filter(allEnabledSortsWithPossibleDirectionToggle, function (possibleDirectionToggle) {\n return underscore_1.findWhere(_this.enabledSorts, { name: possibleDirectionToggle.relatedSort }) != undefined;\n });\n return allowToggle.length > 0;\n };\n FacetSettings.prototype.buildDirectionSection = function () {\n var _this = this;\n var directionAscendingSection = this.buildAscendingOrDescendingSection('Ascending');\n var iconAscending = this.buildIcon('coveo-facet-settings-section-direction-ascending-svg', SVGIcons_1.SVGIcons.icons.ascending);\n var iconDescending = this.buildIcon('coveo-facet-settings-section-direction-descending-svg', SVGIcons_1.SVGIcons.icons.descending);\n var directionItemsAscending = this.buildItems();\n var ascending = this.buildAscendingOrDescending('Ascending');\n directionItemsAscending.appendChild(ascending);\n directionAscendingSection.appendChild(iconAscending);\n directionAscendingSection.appendChild(directionItemsAscending);\n new AccessibleButton_1.AccessibleButton()\n .withElement(ascending)\n .withoutLabelOrTitle()\n .withSelectAction(function () { return _this.handleDirectionClick(ascending, 'ascending'); })\n .build();\n this.unselectSection(directionAscendingSection);\n var directionDescendingSection = this.buildAscendingOrDescendingSection('Descending');\n var directionItemsDescending = this.buildItems();\n var descending = this.buildAscendingOrDescending('Descending');\n directionItemsDescending.appendChild(descending);\n directionDescendingSection.appendChild(iconDescending);\n directionDescendingSection.appendChild(directionItemsDescending);\n new AccessibleButton_1.AccessibleButton()\n .withElement(descending)\n .withoutLabelOrTitle()\n .withSelectAction(function () { return _this.handleDirectionClick(descending, 'descending'); })\n .build();\n this.unselectSection(directionDescendingSection);\n if (!this.activeSort.directionToggle) {\n Dom_1.$$(directionAscendingSection).addClass('coveo-facet-settings-disabled');\n Dom_1.$$(directionDescendingSection).addClass('coveo-facet-settings-disabled');\n }\n else {\n this.selectItem(this.getItems(directionAscendingSection)[0]);\n }\n return [directionAscendingSection, directionDescendingSection];\n };\n FacetSettings.prototype.buildSaveStateSection = function () {\n var _this = this;\n var saveStateSection = this.buildSection('coveo-facet-settings-section-save-state');\n var icon = this.buildIcon('coveo-facet-settings-section-save-state-svg', SVGIcons_1.SVGIcons.icons.dropdownMore);\n var saveStateItems = this.buildItems();\n this.facetStateLocalStorage = new LocalStorageUtils_1.LocalStorageUtils('facet-state-' + this.facet.options.id);\n this.includedStateAttribute = QueryStateModel_1.QueryStateModel.getFacetId(this.facet.options.id);\n this.excludedStateAttribute = QueryStateModel_1.QueryStateModel.getFacetId(this.facet.options.id, false);\n this.operatorStateAttribute = QueryStateModel_1.QueryStateModel.getFacetOperator(this.facet.options.id);\n var saveStateItem = document.createElement('div');\n Dom_1.$$(saveStateItem).addClass('coveo-facet-settings-item');\n saveStateItem.setAttribute('title', Strings_1.l('SaveFacetState'));\n Dom_1.$$(saveStateItem).text(Strings_1.l('SaveFacetState'));\n saveStateItems.appendChild(saveStateItem);\n saveStateSection.appendChild(icon);\n saveStateSection.appendChild(saveStateItems);\n new AccessibleButton_1.AccessibleButton()\n .withElement(saveStateSection)\n .withSelectAction(function () { return _this.handleSaveStateClick(); })\n .withoutLabelOrTitle()\n .build();\n return saveStateSection;\n };\n FacetSettings.prototype.buildClearStateSection = function () {\n var _this = this;\n var clearStateSection = this.buildSection('coveo-facet-settings-section-clear-state');\n var icon = this.buildIcon('coveo-facet-settings-section-clear-state-svg', SVGIcons_1.SVGIcons.icons.dropdownLess);\n var clearStateItems = this.buildItems();\n var clearStateItem = this.buildItem(Strings_1.l('ClearFacetState'));\n clearStateItems.appendChild(clearStateItem);\n clearStateSection.appendChild(icon);\n clearStateSection.appendChild(clearStateItems);\n new AccessibleButton_1.AccessibleButton()\n .withElement(clearStateSection)\n .withSelectAction(function () { return _this.handleClearStateClick(); })\n .withoutLabelOrTitle()\n .build();\n return clearStateSection;\n };\n FacetSettings.prototype.buildHideSection = function () {\n var _this = this;\n var hideSection = this.buildSection('coveo-facet-settings-section-hide');\n var icon = this.buildIcon('coveo-facet-settings-section-hide-svg', SVGIcons_1.SVGIcons.icons.facetCollapse);\n var hideItems = this.buildItems();\n var hideItem = this.buildItem(Strings_1.l('Collapse'));\n hideItems.appendChild(hideItem);\n hideSection.appendChild(icon);\n hideSection.appendChild(hideItems);\n new AccessibleButton_1.AccessibleButton()\n .withElement(hideSection)\n .withSelectAction(function () {\n _this.facet.facetHeader.collapseFacet();\n _this.close();\n })\n .withLabel(Strings_1.l('CollapseFacet', this.facet.options.title))\n .build();\n return hideSection;\n };\n FacetSettings.prototype.buildShowSection = function () {\n var _this = this;\n var showSection = this.buildSection('coveo-facet-settings-section-show');\n var icon = this.buildIcon('coveo-facet-settings-section-show-svg', SVGIcons_1.SVGIcons.icons.facetExpand);\n var showItems = this.buildItems();\n var showItem = this.buildItem(Strings_1.l('Expand'));\n showItems.appendChild(showItem);\n showSection.appendChild(icon);\n showSection.appendChild(showItems);\n new AccessibleButton_1.AccessibleButton()\n .withElement(showSection)\n .withSelectAction(function () {\n _this.facet.facetHeader.expandFacet();\n _this.close();\n })\n .withLabel(Strings_1.l('ExpandFacet', this.facet.options.title))\n .build();\n return showSection;\n };\n FacetSettings.prototype.buildIcon = function (iconClass, svgIcon) {\n if (iconClass && svgIcon) {\n var icon = Dom_1.$$('div', { className: 'coveo-icon-container' }, svgIcon);\n SVGDom_1.SVGDom.addClassToSVGInContainer(icon.el, iconClass);\n return icon.el;\n }\n else {\n return Dom_1.$$('div', { className: 'coveo-icon' }).el;\n }\n };\n FacetSettings.prototype.buildAscendingOrDescending = function (direction) {\n var elem = this.buildItem(Strings_1.l(direction));\n elem.setAttribute('aria-disabled', 'true');\n elem.setAttribute('data-direction', direction.toLowerCase());\n return elem;\n };\n FacetSettings.prototype.buildAscendingOrDescendingSection = function (direction) {\n return this.buildSection('coveo-facet-settings-section-direction-' + direction.toLowerCase());\n };\n FacetSettings.prototype.buildItem = function (label, title) {\n if (title === void 0) { title = label; }\n return Dom_1.$$('div', {\n className: 'coveo-facet-settings-item',\n title: title\n }, underscore_1.escape(label)).el;\n };\n FacetSettings.prototype.buildItems = function () {\n var elem = document.createElement('div');\n Dom_1.$$(elem).addClass('coveo-facet-settings-items');\n return elem;\n };\n FacetSettings.prototype.buildSection = function (className) {\n var section = document.createElement('div');\n Dom_1.$$(section).addClass(['coveo-facet-settings-section', className]);\n return section;\n };\n FacetSettings.prototype.handleSettingsButtonClick = function (event) {\n event.stopPropagation();\n var settingsPopupIsOpen = !Utils_1.Utils.isNullOrUndefined(this.settingsPopup.parentElement);\n settingsPopupIsOpen ? this.close() : this.open();\n };\n FacetSettings.prototype.handleClickSortButton = function (e, enabledSort) {\n if (this.activeSort != enabledSort && this.activeSort.relatedSort != enabledSort.name) {\n this.activeSort = enabledSort;\n if (enabledSort.directionToggle && underscore_1.contains(this.enabledSorts, FacetSettings.availableSorts[this.activeSort.relatedSort])) {\n this.activateDirectionSection();\n }\n else {\n this.disableDirectionSection();\n }\n this.unselectSection(this.sortSection.element);\n this.selectItem(e.target);\n this.closePopupAndUpdateSort();\n }\n };\n FacetSettings.prototype.handleDirectionClick = function (item, direction) {\n var _this = this;\n if (item.getAttribute('aria-disabled') === 'false' && this.activeSort.name.indexOf(direction) === -1) {\n this.activeSort = FacetSettings.availableSorts[this.activeSort.relatedSort];\n underscore_1.each(this.directionSection, function (d) {\n _this.unselectSection(d);\n });\n this.selectItem(item);\n if (this.activeSort.name == 'custom' && this.customSortDirection != direction) {\n this.customSortDirection = direction;\n this.customSortDirectionChange = true;\n }\n this.closePopupAndUpdateSort();\n }\n };\n FacetSettings.prototype.handleSaveStateClick = function () {\n this.saveState();\n this.close();\n };\n FacetSettings.prototype.handleClearStateClick = function () {\n var _this = this;\n this.facetStateLocalStorage.remove();\n this.facet.reset();\n this.close();\n this.facet.triggerNewQuery(function () {\n return _this.facet.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetClearAll, {\n facetId: _this.facet.options.id,\n facetField: _this.facet.options.field.toString(),\n facetTitle: _this.facet.options.title\n });\n });\n };\n FacetSettings.prototype.addOnNukeHandler = function () {\n var _this = this;\n Dom_1.$$(this.facet.root).on(InitializationEvents_1.InitializationEvents.nuke, function () { return _this.handleNuke(); });\n };\n FacetSettings.prototype.addOnDocumentClickHandler = function () {\n var _this = this;\n document.addEventListener('click', function () { return _this.onDocumentClick(); });\n };\n FacetSettings.prototype.getCurrentDirectionItem = function (directionSection) {\n var _this = this;\n if (directionSection === void 0) { directionSection = this.directionSection; }\n var found;\n underscore_1.each(directionSection, function (direction) {\n if (!found) {\n found = underscore_1.find(_this.getItems(direction), function (direction) {\n return _this.activeSort.name.indexOf(direction.getAttribute('data-direction')) != -1;\n });\n }\n });\n if (!found) {\n found = directionSection[0];\n }\n return found;\n };\n FacetSettings.prototype.activateDirectionSection = function () {\n var _this = this;\n underscore_1.each(this.directionSection, function (direction) {\n Dom_1.$$(direction).removeClass('coveo-facet-settings-disabled');\n Dom_1.$$(direction).find('.coveo-facet-settings-item').setAttribute('aria-disabled', 'false');\n _this.unselectSection(direction);\n });\n this.selectItem(this.getCurrentDirectionItem());\n };\n FacetSettings.prototype.disableDirectionSection = function () {\n var _this = this;\n underscore_1.each(this.directionSection, function (direction) {\n Dom_1.$$(direction).addClass('coveo-facet-settings-disabled');\n Dom_1.$$(direction).find('.coveo-facet-settings-item').setAttribute('aria-disabled', 'true');\n _this.unselectSection(direction);\n });\n };\n FacetSettings.prototype.getItems = function (section) {\n return Dom_1.$$(section).findAll('.coveo-facet-settings-item');\n };\n FacetSettings.prototype.unselectSection = function (section) {\n var _this = this;\n underscore_1.each(this.getItems(section), function (i) { return _this.unselectItem(i); });\n };\n FacetSettings.prototype.selectItem = function (item) {\n if (item) {\n Dom_1.$$(item).addClass('coveo-selected');\n item.setAttribute('aria-pressed', 'true');\n }\n };\n FacetSettings.prototype.unselectItem = function (item) {\n if (item) {\n Dom_1.$$(item).removeClass('coveo-selected');\n item.setAttribute('aria-pressed', 'false');\n }\n };\n FacetSettings.prototype.filterDuplicateForRendering = function () {\n var _this = this;\n underscore_1.each(this.enabledSorts, function (enabledSort, i) {\n if (enabledSort.relatedSort != null) {\n for (var j = i + 1; j < _this.enabledSorts.length; j++) {\n if (_this.enabledSorts[j].name == enabledSort.relatedSort) {\n _this.enabledSortsIgnoreRenderBecauseOfPairs.push(_this.enabledSorts[j]);\n break;\n }\n }\n }\n });\n };\n FacetSettings.prototype.appendIfNotUndefined = function (toAppend) {\n if (!Utils_1.Utils.isNullOrUndefined(toAppend)) {\n this.settingsPopup.appendChild(toAppend);\n }\n };\n FacetSettings.prototype.handleNuke = function () {\n document.removeEventListener('click', this.onDocumentClick);\n };\n return FacetSettings;\n}(FacetSort_1.FacetSort));\nexports.FacetSettings = FacetSettings;\n\n\n/***/ }),\n\n/***/ 483:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Strings_1 = __webpack_require__(6);\nvar FacetSettings_1 = __webpack_require__(482);\nvar Utils_1 = __webpack_require__(4);\nvar _ = __webpack_require__(0);\nvar FacetSort = /** @class */ (function () {\n function FacetSort(sorts, facet) {\n var _this = this;\n this.facet = facet;\n this.enabledSorts = [];\n this.customSortDirection = 'ascending';\n _.each(sorts, function (sortToActivate) {\n var newSortToEnable = FacetSettings_1.FacetSettings.availableSorts[sortToActivate.toLowerCase()];\n if (newSortToEnable != undefined) {\n _this.enabledSorts.push(newSortToEnable);\n }\n });\n this.removeEnabledSortsBasedOnFacetType();\n if (Utils_1.Utils.isNonEmptyArray(this.enabledSorts)) {\n if (this.facet.options.sortCriteria != undefined) {\n this.activeSort = _.find(this.enabledSorts, function (enabledSort) {\n return enabledSort.name == _this.facet.options.sortCriteria;\n });\n }\n if (!this.activeSort) {\n this.activeSort = this.enabledSorts[0];\n }\n }\n }\n FacetSort.prototype.removeEnabledSortsBasedOnFacetType = function () {\n if (Coveo.FacetRange && this.facet instanceof Coveo.FacetRange) {\n var facetRange = this.facet;\n if (facetRange.options['slider']) {\n this.enabledSorts = [];\n }\n }\n };\n FacetSort.availableSorts = {\n score: {\n label: Strings_1.l('Score'),\n directionToggle: false,\n description: Strings_1.l('ScoreDescription'),\n name: 'score'\n },\n occurrences: {\n label: Strings_1.l('Occurrences'),\n directionToggle: false,\n description: Strings_1.l('OccurrencesDescription'),\n name: 'occurrences'\n },\n alphaascending: {\n label: Strings_1.l('Label'),\n directionToggle: true,\n description: Strings_1.l('LabelDescription'),\n name: 'alphaascending',\n relatedSort: 'alphadescending'\n },\n alphadescending: {\n label: Strings_1.l('Label'),\n directionToggle: true,\n description: Strings_1.l('LabelDescription'),\n name: 'alphadescending',\n relatedSort: 'alphaascending'\n },\n computedfieldascending: {\n label: Strings_1.l('Value'),\n directionToggle: true,\n description: Strings_1.l('ValueDescription'),\n name: 'computedfieldascending',\n relatedSort: 'computedfielddescending'\n },\n computedfielddescending: {\n label: Strings_1.l('Value'),\n directionToggle: true,\n description: Strings_1.l('ValueDescription'),\n name: 'computedfielddescending',\n relatedSort: 'computedfieldascending'\n },\n chisquare: {\n label: Strings_1.l('RelativeFrequency'),\n directionToggle: false,\n description: Strings_1.l('RelativeFrequencyDescription'),\n name: 'chisquare'\n },\n nosort: {\n label: Strings_1.l('Nosort'),\n directionToggle: false,\n description: Strings_1.l('NosortDescription'),\n name: 'nosort'\n },\n custom: {\n label: Strings_1.l('Custom'),\n directionToggle: true,\n description: Strings_1.l('CustomDescription'),\n name: 'custom',\n relatedSort: 'custom'\n }\n };\n return FacetSort;\n}());\nexports.FacetSort = FacetSort;\n\n\n/***/ }),\n\n/***/ 484:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar Strings_1 = __webpack_require__(6);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\n__webpack_require__(538);\nvar SVGIcons_1 = __webpack_require__(12);\nvar SVGDom_1 = __webpack_require__(16);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar FacetHeader = /** @class */ (function () {\n function FacetHeader(options) {\n this.options = options;\n this.element = document.createElement('div');\n Dom_1.$$(this.element).addClass('coveo-facet-header');\n }\n FacetHeader.prototype.build = function () {\n var titleSection = Dom_1.$$('div', {\n className: 'coveo-facet-header-title-section'\n });\n if (this.options.icon != undefined) {\n this.iconElement = this.buildIcon();\n titleSection.append(this.iconElement);\n }\n titleSection.append(this.buildTitle());\n this.waitElement = this.buildWaitAnimation();\n titleSection.append(this.waitElement);\n this.element.appendChild(titleSection.el);\n var settingsSection = Dom_1.$$('div', {\n className: 'coveo-facet-header-settings-section'\n });\n this.eraserElement = this.buildEraser();\n settingsSection.append(this.eraserElement);\n if (this.options.facet) {\n this.operatorElement = this.buildOperatorToggle();\n settingsSection.append(this.operatorElement);\n Dom_1.$$(this.operatorElement).toggle(this.options.facet.options.enableTogglingOperator);\n }\n if (this.options.settingsKlass) {\n this.sort = this.settings = new this.options.settingsKlass(this.options.availableSorts, this.options.facet);\n settingsSection.append(this.settings.build());\n }\n else if (this.options.sortKlass) {\n this.sort = new this.options.sortKlass(this.options.availableSorts, this.options.facet);\n }\n this.element.appendChild(settingsSection.el);\n return this.element;\n };\n FacetHeader.prototype.switchToAnd = function () {\n if (this.options.facet) {\n this.options.facet.options.useAnd = true;\n this.rebuildOperatorToggle();\n this.updateOperatorQueryStateModel();\n }\n };\n FacetHeader.prototype.switchToOr = function () {\n if (this.options.facet) {\n this.options.facet.options.useAnd = false;\n this.rebuildOperatorToggle();\n this.updateOperatorQueryStateModel();\n }\n };\n FacetHeader.prototype.collapseFacet = function () {\n if (this.collapseElement && this.expandElement) {\n Dom_1.$$(this.collapseElement).hide();\n Dom_1.$$(this.expandElement).show();\n }\n Dom_1.$$(this.options.facetElement).addClass('coveo-facet-collapsed');\n };\n FacetHeader.prototype.expandFacet = function () {\n if (this.collapseElement && this.expandElement) {\n Dom_1.$$(this.expandElement).hide();\n Dom_1.$$(this.collapseElement).show();\n }\n Dom_1.$$(this.options.facetElement).removeClass('coveo-facet-collapsed');\n };\n FacetHeader.prototype.updateOperatorQueryStateModel = function () {\n if (this.options.facet && this.options.facet.options.enableTogglingOperator) {\n var valueToSet = '';\n if (this.options.facet.getSelectedValues().length != 0 || this.options.facet.getExcludedValues().length != 0) {\n valueToSet = this.options.facet.options.useAnd ? 'and' : 'or';\n }\n this.options.facet.queryStateModel.set(this.options.facet.operatorAttributeId, valueToSet);\n }\n };\n FacetHeader.prototype.rebuildOperatorToggle = function () {\n var newElement = this.buildOperatorToggle();\n if (this.operatorElement) {\n Dom_1.$$(this.operatorElement).replaceWith(newElement);\n }\n this.operatorElement = newElement;\n };\n FacetHeader.prototype.buildIcon = function () {\n var cssClassForIcon;\n if (this.options.icon) {\n cssClassForIcon = 'coveo-icon-custom ' + this.options.icon;\n }\n else {\n cssClassForIcon = 'coveo-icon ' + this.options.field.substr(1);\n }\n this.iconElement = document.createElement('div');\n Dom_1.$$(this.iconElement).addClass(cssClassForIcon);\n return this.iconElement;\n };\n FacetHeader.prototype.buildWaitAnimation = function () {\n this.waitElement = Dom_1.$$('div', { className: 'coveo-facet-header-wait-animation' }, SVGIcons_1.SVGIcons.icons.loading).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(this.waitElement, 'coveo-facet-header-wait-animation-svg');\n this.waitElement.style.visibility = 'hidden';\n return this.waitElement;\n };\n FacetHeader.prototype.buildOperatorToggle = function () {\n var _this = this;\n var label = Strings_1.l('SwitchTo', this.options.facet.options.useAnd ? Strings_1.l('Or') : Strings_1.l('And'));\n var icon = Dom_1.$$('span', { className: 'coveo-' + (this.options.facet.options.useAnd ? 'and' : 'or') }, SVGIcons_1.SVGIcons.icons.orAnd);\n SVGDom_1.SVGDom.addClassToSVGInContainer(icon.el, 'coveo-or-and-svg');\n var toggle = Dom_1.$$('div', {\n className: 'coveo-facet-header-operator',\n title: label\n });\n toggle.append(icon.el);\n new AccessibleButton_1.AccessibleButton()\n .withElement(toggle)\n .withLabel(label)\n .withSelectAction(function () { return _this.handleOperatorClick(); })\n .build();\n return toggle.el;\n };\n FacetHeader.prototype.handleOperatorClick = function () {\n var _this = this;\n if (this.options.facet.options.useAnd) {\n this.options.facet.switchToOr();\n }\n else {\n this.options.facet.switchToAnd();\n }\n if (this.options.facet.getSelectedValues().length != 0) {\n var operatorNow_1 = this.options.facet.options.useAnd ? 'AND' : 'OR';\n var operatorBefore_1 = this.options.facet.options.useAnd ? 'OR' : 'AND';\n this.options.facet.triggerNewQuery(function () {\n return _this.options.facet.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetToggle, {\n facetId: _this.options.facet.options.id,\n facetField: _this.options.field.toString(),\n facetOperatorBefore: operatorBefore_1,\n facetOperatorAfter: operatorNow_1,\n facetTitle: _this.options.title\n });\n });\n }\n };\n FacetHeader.prototype.buildTitle = function () {\n var title = Dom_1.$$('div', { className: 'coveo-facet-header-title' });\n title.text(this.options.title);\n title.setAttribute('role', 'heading');\n title.setAttribute('aria-level', '2');\n title.setAttribute('aria-label', Strings_1.l('FacetTitle', this.options.title) + \".\");\n return title.el;\n };\n FacetHeader.prototype.buildEraser = function () {\n var _this = this;\n var eraser = Dom_1.$$('div', { className: 'coveo-facet-header-eraser' }, SVGIcons_1.SVGIcons.icons.mainClear);\n SVGDom_1.SVGDom.addClassToSVGInContainer(eraser.el, 'coveo-facet-header-eraser-svg');\n new AccessibleButton_1.AccessibleButton()\n .withElement(eraser.el)\n .withLabel(Strings_1.l('Clear', this.options.title))\n .withClickAction(function () { return _this.onEraserClick(); })\n .withEnterKeyboardAction(function () { return _this.onEraserClick(); })\n .build();\n return eraser.el;\n };\n FacetHeader.prototype.onEraserClick = function () {\n var cmp = this.options.facet || this.options.facetSlider;\n cmp.reset();\n cmp.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetClearAll, {\n facetId: cmp.options.id,\n facetField: cmp.options.field.toString(),\n facetTitle: cmp.options.title\n });\n cmp.queryController.executeQuery();\n };\n return FacetHeader;\n}());\nexports.FacetHeader = FacetHeader;\n\n\n/***/ }),\n\n/***/ 485:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/// \nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(542);\nvar underscore_1 = __webpack_require__(0);\nvar Assert_1 = __webpack_require__(5);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Dom_1 = __webpack_require__(1);\nvar SVGIcons_1 = __webpack_require__(12);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Strings_1 = __webpack_require__(6);\nvar BreadcrumbValueElement = /** @class */ (function () {\n function BreadcrumbValueElement(facet, facetValue) {\n this.facet = facet;\n this.facetValue = facetValue;\n }\n BreadcrumbValueElement.prototype.build = function () {\n Assert_1.Assert.exists(this.facetValue);\n var _a = this.buildElements(), container = _a.container, caption = _a.caption, clear = _a.clear, listContainer = _a.listContainer;\n container.append(caption.el);\n container.append(clear.el);\n listContainer.append(container.el);\n return listContainer;\n };\n BreadcrumbValueElement.prototype.getBreadcrumbTooltip = function () {\n var tooltipParts = [\n this.facet.getValueCaption(this.facetValue),\n this.facetValue.getFormattedCount(),\n this.facetValue.getFormattedComputedField(this.facet.options.computedFieldFormat)\n ];\n return underscore_1.compact(tooltipParts).join(' ');\n };\n BreadcrumbValueElement.prototype.buildElements = function () {\n return {\n container: this.buildContainer(),\n clear: this.buildClear(),\n caption: this.buildCaption(),\n listContainer: this.buildListContainer()\n };\n };\n BreadcrumbValueElement.prototype.buildContainer = function () {\n var _this = this;\n var container = Dom_1.$$('div', {\n className: 'coveo-facet-breadcrumb-value'\n });\n container.toggleClass('coveo-selected', this.facetValue.selected);\n container.toggleClass('coveo-excluded', this.facetValue.excluded);\n var labelString = this.facetValue.excluded ? 'Unexclude' : 'RemoveFilterOn';\n var label = Strings_1.l(labelString, this.facet.getValueCaption(this.facetValue));\n new AccessibleButton_1.AccessibleButton()\n .withElement(container)\n .withLabel(label)\n .withSelectAction(function () { return _this.selectAction(); })\n .build();\n return container;\n };\n BreadcrumbValueElement.prototype.buildListContainer = function () {\n return Dom_1.$$('li', {\n className: 'coveo-facet-breadcrumb-value-list-item'\n });\n };\n BreadcrumbValueElement.prototype.buildClear = function () {\n var clear = Dom_1.$$('span', {\n className: 'coveo-facet-breadcrumb-clear'\n }, SVGIcons_1.SVGIcons.icons.mainClear);\n return clear;\n };\n BreadcrumbValueElement.prototype.buildCaption = function () {\n var caption = Dom_1.$$('span', {\n className: 'coveo-facet-breadcrumb-caption'\n });\n caption.text(this.facet.getValueCaption(this.facetValue));\n return caption;\n };\n BreadcrumbValueElement.prototype.selectAction = function () {\n var _this = this;\n if (this.facetValue.excluded) {\n this.facet.unexcludeValue(this.facetValue.value);\n }\n else {\n this.facet.deselectValue(this.facetValue.value);\n }\n this.facet.triggerNewQuery(function () {\n return _this.facet.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.breadcrumbFacet, {\n facetId: _this.facet.options.id,\n facetField: _this.facet.options.field.toString(),\n facetValue: _this.facetValue.value,\n facetTitle: _this.facet.options.title\n });\n });\n this.focusOnContainer();\n };\n BreadcrumbValueElement.prototype.focusOnContainer = function () {\n var breadcrumb = underscore_1.first(this.facet.searchInterface.getComponents('Breadcrumb'));\n breadcrumb ? breadcrumb.element.focus() : null;\n };\n return BreadcrumbValueElement;\n}());\nexports.BreadcrumbValueElement = BreadcrumbValueElement;\n\n\n/***/ }),\n\n/***/ 486:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Globalize = __webpack_require__(23);\nvar underscore_1 = __webpack_require__(0);\nvar Assert_1 = __webpack_require__(5);\nvar Strings_1 = __webpack_require__(6);\nvar Dom_1 = __webpack_require__(1);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar AccessibilityUtils_1 = __webpack_require__(48);\nvar BreadcrumbValueList = /** @class */ (function () {\n function BreadcrumbValueList(facet, facetValues, breadcrumbValueElementKlass, options) {\n this.facet = facet;\n this.facetValues = facetValues;\n this.breadcrumbValueElementKlass = breadcrumbValueElementKlass;\n this.options = options;\n this.setExpandedAndCollapsed();\n this.elem = Dom_1.$$('div', {\n className: 'coveo-facet-breadcrumb'\n }).el;\n var title = Dom_1.$$(AccessibilityUtils_1.getHeadingTag(this.options && this.options.headingLevel, 'span'));\n title.addClass('coveo-facet-breadcrumb-title');\n title.text(this.facet.options.title + ':');\n this.elem.appendChild(title.el);\n this.valueContainer = Dom_1.$$('ul', {\n className: 'coveo-facet-breadcrumb-values'\n }).el;\n this.elem.appendChild(this.valueContainer);\n }\n BreadcrumbValueList.prototype.build = function () {\n this.buildExpanded();\n if (this.collapsed.length != 0) {\n this.buildCollapsed();\n }\n return this.elem;\n };\n BreadcrumbValueList.prototype.buildAsString = function () {\n this.build();\n if (this.elem) {\n return (this.facet.options.title + \": \" +\n Dom_1.$$(this.elem)\n .findAll('.coveo-facet-breadcrumb-value')\n .map(function (value) {\n return Dom_1.$$(value).text();\n })\n .join(', '));\n }\n return '';\n };\n BreadcrumbValueList.prototype.buildExpanded = function () {\n var _this = this;\n this.expanded.forEach(function (value) {\n var elementBreadcrumb = new _this.breadcrumbValueElementKlass(_this.facet, value).build();\n _this.valueContainer.appendChild(elementBreadcrumb.el);\n });\n };\n BreadcrumbValueList.prototype.buildCollapsed = function () {\n var _this = this;\n var numberOfSelected = underscore_1.filter(this.collapsed, function (value) { return value.selected; }).length;\n var numberOfExcluded = underscore_1.filter(this.collapsed, function (value) { return value.excluded; }).length;\n Assert_1.Assert.check(numberOfSelected + numberOfExcluded == this.collapsed.length);\n var nMoreElement = Dom_1.$$('div', {\n className: 'coveo-facet-breadcrumb-value'\n }, Dom_1.$$('span', {\n className: 'coveo-facet-breadcrumb-multi-count'\n }, Strings_1.l('NMore', Globalize.format(numberOfSelected + numberOfExcluded, 'n0'))));\n var nMoreContainer = Dom_1.$$('li', {\n className: 'coveo-facet-breadcrumb-value-list-item'\n }, nMoreElement);\n var collapsedBreadcrumbs = this.collapsed.map(function (value) { return new _this.breadcrumbValueElementKlass(_this.facet, value); });\n var toolTip = collapsedBreadcrumbs.map(function (element) { return element.getBreadcrumbTooltip(); }).join('\\n');\n new AccessibleButton_1.AccessibleButton()\n .withElement(nMoreElement)\n .withTitle(toolTip)\n .withSelectAction(function () {\n nMoreElement.remove();\n collapsedBreadcrumbs.forEach(function (breadcrumb) {\n _this.valueContainer.appendChild(breadcrumb.build().el);\n });\n })\n .build();\n this.valueContainer.appendChild(nMoreContainer.el);\n };\n BreadcrumbValueList.prototype.setExpandedAndCollapsed = function () {\n if (this.facetValues.length > this.facet.options.numberOfValuesInBreadcrumb) {\n this.collapsed = underscore_1.rest(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb);\n this.expanded = underscore_1.first(this.facetValues, this.facet.options.numberOfValuesInBreadcrumb);\n }\n else {\n this.collapsed = [];\n this.expanded = this.facetValues;\n }\n };\n return BreadcrumbValueList;\n}());\nexports.BreadcrumbValueList = BreadcrumbValueList;\n\n\n/***/ }),\n\n/***/ 487:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/// \nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Facet_1 = __webpack_require__(70);\nvar Dom_1 = __webpack_require__(1);\nvar Utils_1 = __webpack_require__(4);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar FacetSearchParameters_1 = __webpack_require__(173);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Strings_1 = __webpack_require__(6);\nvar Assert_1 = __webpack_require__(5);\nvar FacetValue_1 = __webpack_require__(118);\nvar StringUtils_1 = __webpack_require__(22);\nvar FacetValueElement_1 = __webpack_require__(131);\nvar ExternalModulesShim_1 = __webpack_require__(26);\nvar SearchInterface_1 = __webpack_require__(19);\nvar ResponsiveComponentsUtils_1 = __webpack_require__(130);\nvar FacetValuesOrder_1 = __webpack_require__(478);\n__webpack_require__(543);\nvar underscore_1 = __webpack_require__(0);\nvar FacetSearchElement_1 = __webpack_require__(479);\n/**\n * Used by the {@link Facet} component to render and handle the facet search part of each facet.\n */\nvar FacetSearch = /** @class */ (function () {\n function FacetSearch(facet, facetSearchValuesListKlass, root) {\n var _this = this;\n this.facet = facet;\n this.facetSearchValuesListKlass = facetSearchValuesListKlass;\n this.root = root;\n this.moreValuesToFetch = true;\n this.lastSearchWasEmpty = true;\n this.facetSearchElement = new FacetSearchElement_1.FacetSearchElement(this);\n this.onResize = underscore_1.debounce(function () {\n // Mitigate issues in UT where the window in phantom js might get resized in the scope of another test.\n // These would point to random instance of a test karma object, and not a real search interface.\n if (_this.facet instanceof Facet_1.Facet && _this.facet.searchInterface instanceof SearchInterface_1.SearchInterface) {\n if (_this.shouldPositionSearchResults()) {\n _this.positionSearchResults();\n }\n }\n }, 250);\n this.onDocumentClick = function (e) {\n _this.handleClickElsewhere(e);\n };\n window.addEventListener('resize', this.onResize);\n document.addEventListener('click', function (e) { return _this.onDocumentClick(e); });\n Dom_1.$$(facet.root).on(InitializationEvents_1.InitializationEvents.nuke, function () { return _this.handleNuke(); });\n }\n Object.defineProperty(FacetSearch.prototype, \"facetType\", {\n get: function () {\n return Facet_1.Facet.ID;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSearch.prototype, \"facetTitle\", {\n get: function () {\n return this.facet.options.title || this.facet.options.field.toString();\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Build the search component and return an `HTMLElement` which can be appended to the {@link Facet}.\n * @returns {HTMLElement}\n */\n FacetSearch.prototype.build = function () {\n return this.buildBaseSearch();\n };\n /**\n * Position the search results at the footer of the facet.\n */\n FacetSearch.prototype.positionSearchResults = function () {\n this.facetSearchElement.positionSearchResults();\n };\n FacetSearch.prototype.fetchMoreValues = function () {\n this.triggerNewFacetSearch(this.buildParamsForFetchingMore());\n };\n /**\n * Dismiss the search results\n */\n FacetSearch.prototype.dismissSearchResults = function () {\n this.cancelAnyPendingSearchOperation();\n this.facet.unfadeInactiveValuesInMainList();\n Dom_1.$$(this.searchResults).empty();\n this.moreValuesToFetch = true;\n Dom_1.$$(this.search).removeClass('coveo-facet-search-no-results');\n Dom_1.$$(this.facet.element).removeClass('coveo-facet-searching');\n this.facetSearchElement.hideSearchResultsElement();\n this.input.value = '';\n Dom_1.$$(this.clear).hide();\n this.currentlyDisplayedResults = undefined;\n };\n /**\n * Trigger a new facet search, and display the results.\n * @param params\n */\n FacetSearch.prototype.triggerNewFacetSearch = function (params) {\n var _this = this;\n this.cancelAnyPendingSearchOperation();\n this.facetSearchElement.showFacetSearchWaitingAnimation();\n this.facet.logger.info('Triggering new facet search');\n this.facetSearchPromise = this.facet.facetQueryController.search(params);\n if (this.facetSearchPromise) {\n this.facetSearchPromise\n .then(function (fieldValues) {\n _this.facet.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetSearch, {\n facetId: _this.facet.options.id,\n facetField: _this.facet.options.field.toString(),\n facetTitle: _this.facet.options.title\n }, _this.facet.root);\n _this.facet.logger.debug('Received field values', fieldValues);\n _this.processNewFacetSearchResults(fieldValues, params);\n _this.facetSearchElement.hideFacetSearchWaitingAnimation();\n _this.facetSearchPromise = undefined;\n })\n .catch(function (error) {\n // The request might be normally cancelled if another search is triggered.\n // In this case we do not hide the animation to prevent flicking.\n if (Utils_1.Utils.exists(error)) {\n _this.facet.logger.error('Error while retrieving facet values', error);\n _this.facetSearchElement.hideFacetSearchWaitingAnimation();\n }\n _this.facetSearchPromise = undefined;\n return null;\n });\n }\n };\n /**\n * Trigger the event associated with the focus of the search input.\n */\n FacetSearch.prototype.focus = function () {\n this.facetSearchElement.focus();\n };\n Object.defineProperty(FacetSearch.prototype, \"searchResults\", {\n get: function () {\n return this.facetSearchElement.searchResults;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSearch.prototype, \"searchBarIsAnimating\", {\n get: function () {\n return this.facetSearchElement.searchBarIsAnimating;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSearch.prototype, \"search\", {\n get: function () {\n return this.facetSearchElement.search;\n },\n enumerable: true,\n configurable: true\n });\n FacetSearch.prototype.setExpandedFacetSearchAccessibilityAttributes = function (searchResultsElement) {\n this.facet.setExpandedFacetSearchAccessibilityAttributes(searchResultsElement);\n };\n FacetSearch.prototype.setCollapsedFacetSearchAccessibilityAttributes = function () {\n this.facet.setCollapsedFacetSearchAccessibilityAttributes();\n };\n FacetSearch.prototype.keyboardEventDefaultHandler = function () {\n this.moreValuesToFetch = true;\n this.highlightCurrentQueryWithinSearchResults();\n if (!this.inputIsEmpty()) {\n this.lastSearchWasEmpty = false;\n this.displayNewValues(this.buildParamsForNormalSearch());\n }\n else if (!this.lastSearchWasEmpty) {\n // This normally happen if a user delete the search box content to go back to \"empty\" state.\n this.currentlyDisplayedResults = undefined;\n Dom_1.$$(this.searchResults).empty();\n this.lastSearchWasEmpty = true;\n this.displayNewValues(this.buildParamsForFetchingMore());\n }\n };\n FacetSearch.prototype.keyboardNavigationEnterPressed = function (event) {\n if (event.shiftKey) {\n this.triggerNewFacetSearch(this.buildParamsForNormalSearch());\n }\n else {\n if (this.searchResults.style.display != 'none') {\n this.performActionOnCurrentSearchResult();\n this.dismissSearchResults();\n }\n else if (Dom_1.$$(this.search).is('.coveo-facet-search-no-results')) {\n this.selectAllValuesMatchingSearch();\n }\n }\n };\n FacetSearch.prototype.keyboardNavigationDeletePressed = function (event) {\n if (event.shiftKey) {\n this.performExcludeActionOnCurrentSearchResult();\n this.dismissSearchResults();\n this.input.value = '';\n }\n };\n FacetSearch.prototype.displayNewValues = function (params) {\n var _this = this;\n if (params === void 0) { params = this.buildParamsForExcludingCurrentlyDisplayedValues(); }\n this.cancelAnyPendingSearchOperation();\n this.facetSearchTimeout = window.setTimeout(function () {\n _this.triggerNewFacetSearch(params);\n }, this.facet.options.facetSearchDelay);\n };\n FacetSearch.prototype.getCaptions = function () {\n return Dom_1.$$(this.searchResults).findAll('.coveo-facet-value-caption');\n };\n FacetSearch.prototype.getValueInInputForFacetSearch = function () {\n return this.facetSearchElement.getValueInInputForFacetSearch();\n };\n FacetSearch.prototype.updateAriaLive = function (text) {\n this.facet.searchInterface.ariaLive.updateText(text);\n };\n Object.defineProperty(FacetSearch.prototype, \"input\", {\n get: function () {\n return this.facetSearchElement.input;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSearch.prototype, \"clear\", {\n get: function () {\n return this.facetSearchElement.clear;\n },\n enumerable: true,\n configurable: true\n });\n FacetSearch.prototype.shouldPositionSearchResults = function () {\n return !ResponsiveComponentsUtils_1.ResponsiveComponentsUtils.isSmallFacetActivated(Dom_1.$$(this.root)) && Dom_1.$$(this.facet.element).hasClass('coveo-facet-searching');\n };\n FacetSearch.prototype.buildBaseSearch = function () {\n var _this = this;\n this.facetSearchElement.build(function () { return _this.handleFacetSearchClear(); });\n Dom_1.$$(this.facetSearchElement.input).on('keyup', function () { return _this.showOrHideClearElement(); });\n return this.search;\n };\n FacetSearch.prototype.handleNuke = function () {\n window.removeEventListener('resize', this.onResize);\n document.removeEventListener('click', this.onDocumentClick);\n };\n FacetSearch.prototype.handleClickElsewhere = function (event) {\n if (this.currentlyDisplayedResults && this.search != event.target && this.searchResults != event.target && this.input != event.target) {\n this.dismissSearchResults();\n }\n };\n FacetSearch.prototype.handleFacetSearchClear = function () {\n this.input.value = '';\n Dom_1.$$(this.clear).hide();\n this.dismissSearchResults();\n };\n FacetSearch.prototype.showOrHideClearElement = function () {\n if (!this.inputIsEmpty()) {\n Dom_1.$$(this.clear).show();\n }\n else {\n Dom_1.$$(this.clear).hide();\n Dom_1.$$(this.search).removeClass('coveo-facet-search-no-results');\n }\n };\n FacetSearch.prototype.cancelAnyPendingSearchOperation = function () {\n if (Utils_1.Utils.exists(this.facetSearchTimeout)) {\n clearTimeout(this.facetSearchTimeout);\n this.facetSearchTimeout = undefined;\n }\n if (Utils_1.Utils.exists(this.facetSearchPromise)) {\n Promise.reject(this.facetSearchPromise).catch(function () { });\n this.facetSearchPromise = undefined;\n }\n this.facetSearchElement.hideFacetSearchWaitingAnimation();\n };\n FacetSearch.prototype.inputIsEmpty = function () {\n return this.input.value.trim() == '';\n };\n FacetSearch.prototype.processNewFacetSearchResults = function (fieldValues, facetSearchParameters) {\n Assert_1.Assert.exists(fieldValues);\n fieldValues = new FacetValuesOrder_1.FacetValuesOrder(this.facet, this.facet.facetSort).reorderValues(fieldValues);\n if (fieldValues.length > 0) {\n Dom_1.$$(this.search).removeClass('coveo-facet-search-no-results');\n this.facet.fadeInactiveValuesInMainList(this.facet.options.facetSearchDelay);\n this.rebuildSearchResults(fieldValues, facetSearchParameters);\n if (!facetSearchParameters.fetchMore) {\n this.showSearchResultsElement();\n }\n this.highlightCurrentQueryWithinSearchResults();\n this.makeFirstSearchResultTheCurrentOne();\n this.facetSearchElement.updateAriaLiveWithResults(this.input.value, this.currentlyDisplayedResults.length, this.moreValuesToFetch);\n }\n else {\n if (facetSearchParameters.fetchMore) {\n this.moreValuesToFetch = false;\n }\n else {\n Dom_1.$$(this.search).addClass('coveo-facet-search-no-results');\n this.showSearchResultsElement();\n this.facetSearchElement.emptyAndShowNoResults();\n }\n }\n };\n FacetSearch.prototype.rebuildSearchResults = function (fieldValues, facetSearchParameters) {\n var _this = this;\n Assert_1.Assert.exists(fieldValues);\n if (!facetSearchParameters.fetchMore) {\n Dom_1.$$(this.searchResults).empty();\n }\n var facetSearchHasQuery = Utils_1.Utils.isNonEmptyString(facetSearchParameters.valueToSearch);\n if (facetSearchHasQuery) {\n this.appendSelectAllResultsButton();\n }\n var facetValues = underscore_1.map(fieldValues, function (fieldValue) {\n return FacetValue_1.FacetValue.create(fieldValue);\n });\n underscore_1.each(new this.facetSearchValuesListKlass(this.facet, FacetValueElement_1.FacetValueElement).build(facetValues), function (listElement) {\n _this.facetSearchElement.appendToSearchResults(listElement);\n });\n if (this.currentlyDisplayedResults) {\n this.currentlyDisplayedResults = this.currentlyDisplayedResults.concat(underscore_1.pluck(facetValues, 'value'));\n }\n else {\n this.currentlyDisplayedResults = underscore_1.pluck(facetValues, 'value');\n }\n underscore_1.each(Dom_1.$$(this.searchResults).findAll('.coveo-facet-selectable'), function (elem, index) {\n Dom_1.$$(elem).setAttribute('id', \"coveo-facet-search-\" + _this.facet.options.id + \"-suggestion-\" + index);\n Dom_1.$$(elem).setAttribute('role', 'option');\n Dom_1.$$(elem).setAttribute('aria-selected', 'false');\n Dom_1.$$(elem).addClass('coveo-facet-search-selectable');\n });\n };\n FacetSearch.prototype.appendSelectAllResultsButton = function () {\n var _this = this;\n var selectAll = document.createElement('li');\n Dom_1.$$(selectAll).addClass(['coveo-facet-selectable', 'coveo-facet-search-selectable', 'coveo-facet-search-select-all']);\n Dom_1.$$(selectAll).text(Strings_1.l('SelectAll'));\n Dom_1.$$(selectAll).on('click', function () { return _this.selectAllValuesMatchingSearch(); });\n this.facetSearchElement.appendToSearchResults(selectAll);\n };\n FacetSearch.prototype.buildParamsForNormalSearch = function () {\n var params = new FacetSearchParameters_1.FacetSearchParameters(this.facet);\n params.setValueToSearch(this.getValueInInputForFacetSearch());\n params.fetchMore = false;\n return params;\n };\n FacetSearch.prototype.buildParamsForFetchingMore = function () {\n var params = this.buildParamsForExcludingCurrentlyDisplayedValues();\n params.fetchMore = true;\n return params;\n };\n FacetSearch.prototype.buildParamsForExcludingCurrentlyDisplayedValues = function () {\n var params = new FacetSearchParameters_1.FacetSearchParameters(this.facet);\n params.excludeCurrentlyDisplayedValuesInSearch(this.searchResults);\n params.setValueToSearch(this.getValueInInputForFacetSearch());\n return params;\n };\n FacetSearch.prototype.showSearchResultsElement = function () {\n this.positionSearchResults();\n };\n FacetSearch.prototype.highlightCurrentQueryWithinSearchResults = function () {\n var search = this.getValueInInputForFacetSearch();\n var regex = new RegExp('(' + StringUtils_1.StringUtils.wildcardsToRegex(search, this.facet.options.facetSearchIgnoreAccents) + ')', 'ig');\n this.facetSearchElement.highlightCurrentQueryInSearchResults(regex);\n };\n FacetSearch.prototype.makeFirstSearchResultTheCurrentOne = function () {\n this.facetSearchElement.setAsCurrentResult(Dom_1.$$(this.getSelectables()[0]));\n };\n FacetSearch.prototype.getSelectables = function (target) {\n if (target === void 0) { target = this.searchResults; }\n return Dom_1.$$(target).findAll('.coveo-facet-selectable');\n };\n FacetSearch.prototype.performActionOnCurrentSearchResult = function () {\n var current = Dom_1.$$(this.searchResults).find('.coveo-facet-search-current-result');\n Assert_1.Assert.check(current != undefined);\n var shouldExclude = Dom_1.$$(current).hasClass('coveo-facet-value-will-exclude');\n if (shouldExclude) {\n var excludeIcon = Dom_1.$$(current).find('.coveo-facet-value-exclude');\n excludeIcon.click();\n return;\n }\n var checkbox = Dom_1.$$(current).find('input[type=\"checkbox\"]');\n if (checkbox) {\n checkbox.checked = true;\n Dom_1.$$(checkbox).trigger('change');\n }\n else {\n current.click();\n }\n };\n FacetSearch.prototype.performExcludeActionOnCurrentSearchResult = function () {\n var current = Dom_1.$$(this.searchResults).find('.coveo-facet-search-current-result');\n Assert_1.Assert.check(current != null);\n var valueCaption = Dom_1.$$(current).find('.coveo-facet-value-caption');\n var valueElement = this.facet.facetValuesList.get(Dom_1.$$(valueCaption).text());\n valueElement.toggleExcludeWithUA();\n };\n FacetSearch.prototype.selectAllValuesMatchingSearch = function () {\n var _this = this;\n this.facet.showWaitingAnimation();\n var searchParameters = new FacetSearchParameters_1.FacetSearchParameters(this.facet);\n searchParameters.nbResults = 1000;\n searchParameters.setValueToSearch(this.getValueInInputForFacetSearch());\n this.facet.facetQueryController.search(searchParameters).then(function (fieldValues) {\n _this.dismissSearchResults();\n ExternalModulesShim_1.ModalBox.close(true);\n var facetValues = underscore_1.map(fieldValues, function (fieldValue) {\n var facetValue = _this.facet.values.get(fieldValue.value);\n if (!Utils_1.Utils.exists(facetValue)) {\n facetValue = FacetValue_1.FacetValue.create(fieldValue);\n }\n facetValue.selected = true;\n facetValue.excluded = false;\n return facetValue;\n });\n _this.facet.processFacetSearchAllResultsSelected(facetValues);\n });\n this.dismissSearchResults();\n };\n return FacetSearch;\n}());\nexports.FacetSearch = FacetSearch;\n\n\n/***/ }),\n\n/***/ 488:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar _ = __webpack_require__(0);\nvar FacetSearchValuesList = /** @class */ (function () {\n function FacetSearchValuesList(facet, facetValueElementKlass) {\n this.facet = facet;\n this.facetValueElementKlass = facetValueElementKlass;\n }\n FacetSearchValuesList.prototype.build = function (facetValues) {\n var _this = this;\n var valuesToBuildWith = _.map(facetValues, function (facetValue) {\n return (_.find(_this.facet.values.getAll(), function (valueAlreadyInFacet) {\n return valueAlreadyInFacet.value == facetValue.value;\n }) || facetValue);\n });\n return _.map(valuesToBuildWith, function (facetValue) {\n var valueElement = new _this.facetValueElementKlass(_this.facet, facetValue, _this.facet.keepDisplayedValuesNextTime).build();\n valueElement.renderer.excludeIcon.setAttribute('aria-hidden', 'true');\n valueElement.renderer.label.setAttribute('aria-hidden', 'true');\n return valueElement.renderer.listItem;\n });\n };\n return FacetSearchValuesList;\n}());\nexports.FacetSearchValuesList = FacetSearchValuesList;\n\n\n/***/ }),\n\n/***/ 489:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/// \nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar FacetValueElement_1 = __webpack_require__(131);\nvar Dom_1 = __webpack_require__(1);\nvar FacetValue_1 = __webpack_require__(118);\nvar Utils_1 = __webpack_require__(4);\nvar FacetUtils_1 = __webpack_require__(40);\nvar _ = __webpack_require__(0);\nvar FacetValuesList = /** @class */ (function () {\n function FacetValuesList(facet, facetValueElementKlass) {\n this.facet = facet;\n this.facetValueElementKlass = facetValueElementKlass;\n // Dictionary of values. The key is always in lowercase.\n this.valueList = {};\n this.currentlyDisplayed = [];\n }\n FacetValuesList.prototype.build = function () {\n this.valueContainer = document.createElement('ul');\n Dom_1.$$(this.valueContainer).addClass('coveo-facet-values');\n return this.valueContainer;\n };\n FacetValuesList.prototype.getAllCurrentlyDisplayed = function () {\n return this.currentlyDisplayed;\n };\n FacetValuesList.prototype.getAll = function () {\n return _.toArray(this.valueList);\n };\n FacetValuesList.prototype.getAllFacetValue = function () {\n return _.map(this.getAll(), function (v) {\n return v.facetValue;\n });\n };\n FacetValuesList.prototype.get = function (value) {\n var getter;\n if (value instanceof FacetValue_1.FacetValue) {\n getter = value.value;\n }\n else {\n value = Utils_1.Utils.anyTypeToString(value);\n getter = value;\n }\n this.ensureFacetValueIsInList(value);\n return this.valueList[getter.toLowerCase()];\n };\n FacetValuesList.prototype.select = function (value) {\n var valueElement = this.get(value);\n valueElement.select();\n return valueElement;\n };\n FacetValuesList.prototype.unselect = function (value) {\n var valueElement = this.get(value);\n valueElement.unselect();\n return valueElement;\n };\n FacetValuesList.prototype.exclude = function (value) {\n var valueElement = this.get(value);\n valueElement.exclude();\n return valueElement;\n };\n FacetValuesList.prototype.unExclude = function (value) {\n var valueElement = this.get(value);\n valueElement.unexclude();\n return valueElement;\n };\n FacetValuesList.prototype.toggleSelect = function (value) {\n var valueElement = this.get(value);\n if (valueElement.facetValue.selected) {\n valueElement.unselect();\n }\n else {\n valueElement.select();\n }\n return valueElement;\n };\n FacetValuesList.prototype.toggleExclude = function (value) {\n var valueElement = this.get(value);\n if (valueElement.facetValue.excluded) {\n valueElement.unexclude();\n }\n else {\n valueElement.exclude();\n }\n return valueElement;\n };\n FacetValuesList.prototype.rebuild = function (numberOfValues) {\n var _this = this;\n Dom_1.$$(this.valueContainer).empty();\n this.currentlyDisplayed = [];\n var allValues = this.getValuesToBuildWith();\n var toCompare = numberOfValues;\n var docFragment = document.createDocumentFragment();\n _.each(allValues, function (facetValue, index, list) {\n if (_this.facetValueShouldBeRemoved(facetValue)) {\n _this.facet.values.remove(facetValue.value);\n toCompare += 1;\n }\n else if (index < toCompare) {\n var valueElement = new _this.facetValueElementKlass(_this.facet, facetValue, true);\n _this.valueList[facetValue.value.toLowerCase()] = valueElement;\n var valueListElement = valueElement.build().renderer.listItem;\n docFragment.appendChild(valueListElement);\n _this.currentlyDisplayed.push(valueElement);\n }\n });\n this.valueContainer.appendChild(docFragment);\n FacetUtils_1.FacetUtils.addNoStateCssClassToFacetValues(this.facet, this.valueContainer);\n };\n FacetValuesList.prototype.getValuesToBuildWith = function () {\n return this.facet.values.getAll();\n };\n FacetValuesList.prototype.facetValueShouldBeRemoved = function (facetValue) {\n return (facetValue.occurrences == 0 &&\n (facetValue.delta == 0 || facetValue.delta == undefined) &&\n !facetValue.selected &&\n !facetValue.excluded &&\n !this.facet.keepDisplayedValuesNextTime);\n };\n FacetValuesList.prototype.ensureFacetValueIsInList = function (value) {\n var facetValue;\n if (value instanceof FacetValue_1.FacetValue) {\n facetValue = this.facet.values.get(value.value);\n if (facetValue == null) {\n this.facet.values.add(value);\n facetValue = value;\n }\n }\n else {\n facetValue = this.facet.values.get(value);\n if (facetValue == null) {\n facetValue = FacetValue_1.FacetValue.createFromValue(value);\n this.facet.values.add(facetValue);\n }\n }\n var key = facetValue.value.toLowerCase();\n var found = this.valueList[key];\n if (found == undefined) {\n found = this.valueList[key] = new FacetValueElement_1.FacetValueElement(this.facet, facetValue, true);\n found.build();\n }\n else {\n found.facetValue = facetValue;\n }\n };\n return FacetValuesList;\n}());\nexports.FacetValuesList = FacetValuesList;\n\n\n/***/ }),\n\n/***/ 490:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n/// \nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ValueElement_1 = __webpack_require__(476);\nvar OmniboxValueElement = /** @class */ (function (_super) {\n __extends(OmniboxValueElement, _super);\n function OmniboxValueElement(facet, facetValue, eventArg, onSelect, onExclude) {\n var _this = _super.call(this, facet, facetValue, onSelect, onExclude) || this;\n _this.facet = facet;\n _this.facetValue = facetValue;\n _this.eventArg = eventArg;\n return _this;\n }\n OmniboxValueElement.prototype.bindEvent = function () {\n _super.prototype.bindEvent.call(this, { displayNextTime: false, pinFacet: false, omniboxObject: this.eventArg });\n };\n return OmniboxValueElement;\n}(ValueElement_1.ValueElement));\nexports.OmniboxValueElement = OmniboxValueElement;\n\n\n/***/ }),\n\n/***/ 491:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/// \nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nvar Utils_1 = __webpack_require__(4);\nvar FacetUtils_1 = __webpack_require__(40);\nvar OmniboxValuesList = /** @class */ (function () {\n function OmniboxValuesList(facet, facetValues, omniboxObject, omniboxValueElementKlass) {\n this.facet = facet;\n this.facetValues = facetValues;\n this.omniboxObject = omniboxObject;\n this.omniboxValueElementKlass = omniboxValueElementKlass;\n }\n OmniboxValuesList.prototype.build = function () {\n var _this = this;\n var rows = [];\n underscore_1.each(this.facetValues, function (facetValue) {\n rows.push(_this.buildOmniboxForOneRow(facetValue, _this.omniboxObject));\n });\n return this.buildFinalOmniboxElement(rows);\n };\n OmniboxValuesList.prototype.buildOmniboxForOneRow = function (facetValue, omniboxObject) {\n var _this = this;\n var selectCallback = function (elem, cause) { return _this.logAnalyticsEvent(elem, cause); };\n var excludeCallback = function (elem, cause) { return _this.logAnalyticsEvent(elem, cause); };\n var omniboxValueElement = new this.omniboxValueElementKlass(this.facet, facetValue, omniboxObject, selectCallback, excludeCallback);\n var omniboxRowContent = omniboxValueElement.build().renderer.listItem;\n var regex = omniboxObject.completeQueryExpression.regex;\n var valueToSearch = omniboxObject.completeQueryExpression.word;\n var caption = Dom_1.$$(omniboxRowContent).find('.coveo-facet-value-caption');\n caption.innerHTML = this.highlightOmniboxMatch(this.facet.getValueCaption(facetValue), regex, valueToSearch);\n var omniboxRow = Dom_1.$$('ul', {\n className: 'coveo-omnibox-selectable coveo-facet-value coveo-omnibox-facet-value'\n }).el;\n omniboxRow.appendChild(omniboxRowContent);\n Dom_1.$$(omniboxRow).on('keyboardSelect', function () {\n var input = Dom_1.$$(omniboxRowContent).find('input[type=checkbox]');\n Dom_1.$$(input).trigger('change');\n });\n omniboxRow['no-text-suggestion'] = true;\n return omniboxRow;\n };\n OmniboxValuesList.prototype.buildFinalOmniboxElement = function (rows) {\n var header = this.buildOmniboxHeader();\n if (Utils_1.Utils.isEmptyArray(rows)) {\n return undefined;\n }\n else {\n var ret_1 = Dom_1.$$('div', {\n className: 'coveo-omnibox-facet-value'\n }).el;\n ret_1.appendChild(header);\n underscore_1.each(rows, function (r) {\n ret_1.appendChild(r);\n });\n FacetUtils_1.FacetUtils.addNoStateCssClassToFacetValues(this.facet, ret_1);\n return ret_1;\n }\n };\n OmniboxValuesList.prototype.buildOmniboxHeader = function () {\n var title = this.facet.options.title;\n var header = Dom_1.$$('div', {\n className: 'coveo-omnibox-facet-header'\n }).el;\n Dom_1.$$(header).text(title);\n return header;\n };\n OmniboxValuesList.prototype.highlightOmniboxMatch = function (orignalStr, regex, valueToSearch) {\n var firstChar = orignalStr.search(regex);\n var lastChar = firstChar + valueToSearch.length;\n return (orignalStr.slice(0, firstChar) +\n '' +\n orignalStr.slice(firstChar, lastChar) +\n '' +\n orignalStr.slice(lastChar));\n };\n OmniboxValuesList.prototype.logAnalyticsEvent = function (elem, cause) {\n var strippedFacetValues = underscore_1.pluck(this.facetValues, 'value');\n elem.facet.usageAnalytics.logSearchEvent(cause, {\n query: this.omniboxObject.completeQueryExpression.word,\n facetId: elem.facet.options.id,\n facetField: elem.facet.options.field.toString(),\n facetTitle: elem.facet.options.title,\n facetValue: elem.facetValue.value,\n suggestions: strippedFacetValues.join(';'),\n suggestionRanking: underscore_1.indexOf(strippedFacetValues, elem.facetValue.value)\n });\n };\n return OmniboxValuesList;\n}());\nexports.OmniboxValuesList = OmniboxValuesList;\n\n\n/***/ }),\n\n/***/ 527:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 528:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 529:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 530:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ResponsiveComponentsManager_1 = __webpack_require__(62);\nvar SearchInterface_1 = __webpack_require__(19);\nvar ResultList_1 = __webpack_require__(92);\nvar Dom_1 = __webpack_require__(1);\nvar Component_1 = __webpack_require__(7);\nvar Logger_1 = __webpack_require__(9);\nvar ResponsiveDefaultResultTemplate = /** @class */ (function () {\n function ResponsiveDefaultResultTemplate(coveoRoot, ID, options, responsiveDropdown) {\n this.coveoRoot = coveoRoot;\n this.ID = ID;\n this.searchInterface = Component_1.Component.get(this.coveoRoot.el, SearchInterface_1.SearchInterface, false);\n this.currentMode = 'large';\n }\n ResponsiveDefaultResultTemplate.init = function (root, component, options) {\n if (!Dom_1.$$(root).find(\".\" + Component_1.Component.computeCssClassName(ResultList_1.ResultList))) {\n var logger = new Logger_1.Logger('ResponsiveDefaultResultTemplate');\n logger.trace('No ResultLayout component found : Cannot instantiate ResponsiveResultLayout');\n return;\n }\n ResponsiveComponentsManager_1.ResponsiveComponentsManager.register(ResponsiveDefaultResultTemplate, Dom_1.$$(root), ResultList_1.ResultList.ID, component, options);\n };\n ResponsiveDefaultResultTemplate.prototype.registerComponent = function (accept) {\n if (accept instanceof ResultList_1.ResultList) {\n this.resultList = accept;\n return true;\n }\n return false;\n };\n ResponsiveDefaultResultTemplate.prototype.handleResizeEvent = function () {\n var _this = this;\n var lastResults = this.resultList.queryController.getLastResults();\n if (this.needSmallMode()) {\n Dom_1.$$(this.resultList.options.resultsContainer).addClass('coveo-card-layout-container');\n Dom_1.$$(this.resultList.options.resultsContainer).removeClass(\"coveo-list-layout-container\");\n if (this.currentMode != 'small') {\n if (lastResults) {\n this.resultList.buildResults(lastResults).then(function (elements) {\n _this.resultList.renderResults(elements);\n });\n }\n this.currentMode = 'small';\n }\n }\n else {\n Dom_1.$$(this.resultList.options.resultsContainer).removeClass('coveo-card-layout-container');\n Dom_1.$$(this.resultList.options.resultsContainer).addClass(\"coveo-list-layout-container\");\n if (this.currentMode != 'large') {\n if (lastResults) {\n this.resultList.buildResults(lastResults).then(function (elements) {\n _this.resultList.renderResults(elements);\n });\n }\n this.currentMode = 'large';\n }\n }\n };\n ResponsiveDefaultResultTemplate.prototype.needSmallMode = function () {\n return this.coveoRoot.width() <= this.searchInterface.responsiveComponents.getSmallScreenWidth();\n };\n return ResponsiveDefaultResultTemplate;\n}());\nexports.ResponsiveDefaultResultTemplate = ResponsiveDefaultResultTemplate;\n\n\n/***/ }),\n\n/***/ 531:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar ResultContainer = /** @class */ (function () {\n function ResultContainer(resultContainer, searchInterface) {\n this.searchInterface = searchInterface;\n this.resultContainerElement = Dom_1.$$(resultContainer);\n }\n ResultContainer.prototype.empty = function () {\n this.searchInterface.detachComponentsInside(this.resultContainerElement.el);\n Dom_1.$$(this.resultContainerElement).empty();\n };\n ResultContainer.prototype.addClass = function (classToAdd) {\n this.resultContainerElement.addClass(classToAdd);\n };\n ResultContainer.prototype.isEmpty = function () {\n return this.resultContainerElement.isEmpty();\n };\n ResultContainer.prototype.hideChildren = function () {\n this.resultContainerElement.children().forEach(function (child) { return Dom_1.$$(child).hide(); });\n };\n ResultContainer.prototype.getResultElements = function () {\n return this.resultContainerElement.findAll('.CoveoResult');\n };\n Object.defineProperty(ResultContainer.prototype, \"el\", {\n get: function () {\n return this.resultContainerElement.el;\n },\n enumerable: true,\n configurable: true\n });\n ResultContainer.resultCurrentlyBeingRendered = null;\n return ResultContainer;\n}());\nexports.ResultContainer = ResultContainer;\n\n\n/***/ }),\n\n/***/ 532:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ResultListRenderer_1 = __webpack_require__(215);\nvar Dom_1 = __webpack_require__(1);\nvar _ = __webpack_require__(0);\nvar ResultListCardRenderer = /** @class */ (function (_super) {\n __extends(ResultListCardRenderer, _super);\n function ResultListCardRenderer() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n ResultListCardRenderer.prototype.getEndFragment = function (resultElements) {\n var _this = this;\n return new Promise(function (resolve) {\n if (!_.isEmpty(resultElements)) {\n // with infinite scrolling, we want the additional results to append at the end of the previous query.\n // For this, we need to remove the padding.\n if (_this.resultListOptions.enableInfiniteScroll) {\n var needToBeRemoved = Dom_1.$$(_this.resultListOptions.resultsContainer).findAll('.coveo-card-layout-padding');\n _.each(needToBeRemoved, function (toRemove) { return Dom_1.$$(toRemove).remove(); });\n }\n // Used to prevent last card from spanning the grid's whole width\n var emptyCards_1 = document.createDocumentFragment();\n _.times(3, function () { return emptyCards_1.appendChild(Dom_1.$$('div', { className: 'coveo-card-layout coveo-card-layout-padding' }).el); });\n resolve(emptyCards_1);\n }\n resolve(null);\n });\n };\n return ResultListCardRenderer;\n}(ResultListRenderer_1.ResultListRenderer));\nexports.ResultListCardRenderer = ResultListCardRenderer;\n\n\n/***/ }),\n\n/***/ 533:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ResultListRenderer_1 = __webpack_require__(215);\nvar TableTemplate_1 = __webpack_require__(469);\nvar Dom_1 = __webpack_require__(1);\nvar _ = __webpack_require__(0);\nvar ResultListTableRenderer = /** @class */ (function (_super) {\n __extends(ResultListTableRenderer, _super);\n function ResultListTableRenderer(resultListOptions, autoCreateComponentsFn) {\n var _this = _super.call(this, resultListOptions, autoCreateComponentsFn) || this;\n _this.resultListOptions = resultListOptions;\n _this.autoCreateComponentsFn = autoCreateComponentsFn;\n _this.shouldDisplayHeader = true;\n _this.shouldDisplayFooter = false;\n if (_this.resultListOptions.resultTemplate instanceof TableTemplate_1.TableTemplate) {\n if (_this.resultListOptions.resultTemplate.hasTemplateWithRole('table-footer')) {\n _this.shouldDisplayFooter = true;\n }\n // If custom templates are defined but no header template, do not display it.\n if (_this.resultListOptions.resultTemplate.templates.length !== 0 &&\n !_this.resultListOptions.resultTemplate.hasTemplateWithRole('table-header')) {\n _this.shouldDisplayHeader = false;\n }\n }\n return _this;\n }\n ResultListTableRenderer.prototype.getStartFragment = function (resultElements, append) {\n if (!append && !_.isEmpty(resultElements) && this.shouldDisplayHeader) {\n return this.renderRoledTemplate('table-header');\n }\n };\n ResultListTableRenderer.prototype.getEndFragment = function (resultElements, append) {\n if (!append && !_.isEmpty(resultElements) && this.shouldDisplayFooter) {\n return this.renderRoledTemplate('table-footer');\n }\n };\n ResultListTableRenderer.prototype.renderRoledTemplate = function (role) {\n return __awaiter(this, void 0, void 0, function () {\n var elem, frag;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.resultListOptions.resultTemplate.instantiateRoleToElement(role)];\n case 1:\n elem = _a.sent();\n Dom_1.$$(elem).addClass(\"coveo-result-list-\" + role);\n this.autoCreateComponentsFn(elem, undefined);\n frag = document.createDocumentFragment();\n frag.appendChild(elem);\n return [2 /*return*/, frag];\n }\n });\n });\n };\n return ResultListTableRenderer;\n}(ResultListRenderer_1.ResultListRenderer));\nexports.ResultListTableRenderer = ResultListTableRenderer;\n\n\n/***/ }),\n\n/***/ 535:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 536:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ResponsiveDropdownContent_1 = __webpack_require__(93);\nvar Core_1 = __webpack_require__(20);\nvar SVGIcons_1 = __webpack_require__(12);\nvar FocusTrap_1 = __webpack_require__(470);\nvar ResponsiveDropdownModalContent = /** @class */ (function () {\n function ResponsiveDropdownModalContent(componentName, element, closeButtonLabel, close) {\n this.componentName = componentName;\n this.element = element;\n this.closeButtonLabel = closeButtonLabel;\n this.close = close;\n this.className = \"coveo-\" + this.componentName + \"-dropdown-modal-content\";\n }\n Object.defineProperty(ResponsiveDropdownModalContent.prototype, \"hidden\", {\n set: function (shouldHide) {\n this.element.toggleClass('coveo-hidden', shouldHide);\n },\n enumerable: true,\n configurable: true\n });\n ResponsiveDropdownModalContent.prototype.positionDropdown = function () {\n this.element.el.classList.add(this.className, ResponsiveDropdownContent_1.ResponsiveDropdownContent.DEFAULT_CSS_CLASS_NAME);\n this.element.setAttribute('role', 'group');\n this.element.setAttribute('aria-label', Core_1.l('FiltersDropdown'));\n this.hidden = false;\n this.ensureCloseButton();\n this.ensureFocusTrap();\n };\n ResponsiveDropdownModalContent.prototype.hideDropdown = function () {\n this.element.el.classList.remove(this.className, ResponsiveDropdownContent_1.ResponsiveDropdownContent.DEFAULT_CSS_CLASS_NAME);\n this.element.setAttribute('role', null);\n this.element.setAttribute('aria-label', null);\n this.hidden = true;\n this.removeCloseButton();\n this.removeFocusTrap();\n };\n ResponsiveDropdownModalContent.prototype.cleanUp = function () {\n this.hidden = false;\n };\n ResponsiveDropdownModalContent.prototype.ensureCloseButton = function () {\n var _this = this;\n if (!this.closeButton) {\n this.closeButton = Core_1.$$('button', {\n className: 'coveo-facet-modal-close-button',\n type: 'button',\n ariaLabel: this.closeButtonLabel\n }, SVGIcons_1.SVGIcons.icons.mainClear);\n this.closeButton.on('click', function () { return _this.close(); });\n this.element.prepend(this.closeButton.el);\n }\n };\n Object.defineProperty(ResponsiveDropdownModalContent.prototype, \"focusableSelector\", {\n get: function () {\n var facetElements = '[data-field]:not(.coveo-facet-empty) [tabindex]';\n var dynamicFacetsElements = '[data-field]:not(.coveo-hidden) button';\n var modalButton = '.coveo-facet-modal-close-button';\n return [facetElements, dynamicFacetsElements, modalButton].join(' , ');\n },\n enumerable: true,\n configurable: true\n });\n ResponsiveDropdownModalContent.prototype.ensureFocusTrap = function () {\n if (!this.focusTrap) {\n this.focusTrap = new FocusTrap_1.FocusTrap(this.element.el, { focusableSelector: this.focusableSelector });\n }\n };\n ResponsiveDropdownModalContent.prototype.removeCloseButton = function () {\n if (this.closeButton) {\n this.closeButton.remove();\n this.closeButton = null;\n }\n };\n ResponsiveDropdownModalContent.prototype.removeFocusTrap = function () {\n if (this.focusTrap) {\n this.focusTrap.disable();\n this.focusTrap = null;\n }\n };\n return ResponsiveDropdownModalContent;\n}());\nexports.ResponsiveDropdownModalContent = ResponsiveDropdownModalContent;\n\n\n/***/ }),\n\n/***/ 537:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * The names of the events that can be triggered by the [FacetsMobileMode]{@link FacetsMobileMode} component.\n */\nvar FacetsMobileModeEvents = /** @class */ (function () {\n function FacetsMobileModeEvents() {\n }\n /**\n * The name of the event that gets triggered when the facets pop-up (or modal) is opened in mobile mode.\n */\n FacetsMobileModeEvents.popupOpened = 'popupOpened';\n /**\n * The name of the event that gets triggered when the facets pop-up (or modal) is closed in mobile mode.\n */\n FacetsMobileModeEvents.popupClosed = 'popupClosed';\n return FacetsMobileModeEvents;\n}());\nexports.FacetsMobileModeEvents = FacetsMobileModeEvents;\n\n\n/***/ }),\n\n/***/ 538:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 540:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 541:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 542:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 543:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 544:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar KeyboardUtils_1 = __webpack_require__(25);\nvar FacetSearchUserInputHandler = /** @class */ (function () {\n function FacetSearchUserInputHandler(facetSearch) {\n this.facetSearch = facetSearch;\n }\n FacetSearchUserInputHandler.prototype.handleKeyboardEvent = function (event) {\n switch (event.which) {\n case KeyboardUtils_1.KEYBOARD.ENTER:\n this.facetSearch.keyboardNavigationEnterPressed(event);\n break;\n case KeyboardUtils_1.KEYBOARD.DELETE:\n this.facetSearch.keyboardNavigationDeletePressed && this.facetSearch.keyboardNavigationDeletePressed(event);\n break;\n case KeyboardUtils_1.KEYBOARD.ESCAPE:\n this.facetSearch.dismissSearchResults();\n break;\n case KeyboardUtils_1.KEYBOARD.DOWN_ARROW:\n this.facetSearch.facetSearchElement.moveCurrentResultDown();\n break;\n case KeyboardUtils_1.KEYBOARD.UP_ARROW:\n this.facetSearch.facetSearchElement.moveCurrentResultUp();\n break;\n default:\n this.facetSearch.keyboardEventDefaultHandler();\n }\n };\n FacetSearchUserInputHandler.prototype.handleFacetSearchResultsScroll = function () {\n if (this.facetSearch.facetSearchPromise ||\n this.facetSearch.facetSearchElement.getValueInInputForFacetSearch() != '' ||\n !this.facetSearch.moreValuesToFetch) {\n return;\n }\n var elementHeight = this.facetSearch.facetSearchElement.searchResults.clientHeight;\n var scrollHeight = this.facetSearch.facetSearchElement.searchResults.scrollHeight;\n var bottomPosition = this.facetSearch.facetSearchElement.searchResults.scrollTop + elementHeight;\n if (scrollHeight - bottomPosition < elementHeight / 2) {\n this.facetSearch.fetchMoreValues();\n }\n };\n return FacetSearchUserInputHandler;\n}());\nexports.FacetSearchUserInputHandler = FacetSearchUserInputHandler;\n\n\n/***/ }),\n\n/***/ 545:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar DefaultSearchDropdownNavigator_1 = __webpack_require__(480);\nvar FacetSearchDropdownNavigator_1 = __webpack_require__(546);\nvar CategoryFacet_1 = __webpack_require__(94);\nvar Facet_1 = __webpack_require__(70);\nfunction SearchDropdownNavigatorFactory(facetSearch, config) {\n switch (facetSearch.facetType) {\n case Facet_1.Facet.ID:\n return new FacetSearchDropdownNavigator_1.FacetSearchDropdownNavigator(__assign({}, config, { facetSearch: facetSearch }));\n case CategoryFacet_1.CategoryFacet.ID:\n default:\n return new DefaultSearchDropdownNavigator_1.DefaultSearchDropdownNavigator(config);\n }\n}\nexports.SearchDropdownNavigatorFactory = SearchDropdownNavigatorFactory;\n\n\n/***/ }),\n\n/***/ 546:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar DefaultSearchDropdownNavigator_1 = __webpack_require__(480);\nvar Dom_1 = __webpack_require__(1);\nvar FacetSearchDropdownNavigator = /** @class */ (function () {\n function FacetSearchDropdownNavigator(config) {\n this.config = config;\n this.defaultDropdownNavigator = new DefaultSearchDropdownNavigator_1.DefaultSearchDropdownNavigator(config);\n }\n FacetSearchDropdownNavigator.prototype.setAsCurrentResult = function (dom) {\n this.defaultDropdownNavigator.setAsCurrentResult(dom);\n };\n Object.defineProperty(FacetSearchDropdownNavigator.prototype, \"currentResult\", {\n get: function () {\n return this.defaultDropdownNavigator.currentResult;\n },\n enumerable: true,\n configurable: true\n });\n FacetSearchDropdownNavigator.prototype.focusNextElement = function () {\n this.toggleCanExcludeCurrentResult();\n if (this.willExcludeCurrentResult) {\n this.announceCurrentResultCanBeExcluded();\n return;\n }\n this.defaultDropdownNavigator.moveCurrentResultDown();\n };\n FacetSearchDropdownNavigator.prototype.focusPreviousElement = function () {\n if (this.willExcludeCurrentResult) {\n this.toggleCanExcludeCurrentResult();\n return;\n }\n this.moveResultUp();\n this.toggleCanExcludeCurrentResult();\n };\n FacetSearchDropdownNavigator.prototype.moveResultUp = function () {\n if (this.willExcludeCurrentResult) {\n this.toggleCanExcludeCurrentResult();\n return;\n }\n this.defaultDropdownNavigator.moveCurrentResultUp();\n this.toggleCanExcludeCurrentResult();\n };\n Object.defineProperty(FacetSearchDropdownNavigator.prototype, \"isCurrentResultNotAFacetValue\", {\n get: function () {\n return this.currentResult.hasClass('coveo-facet-search-select-all') || this.currentResult.hasClass('coveo-facet-value-not-found');\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(FacetSearchDropdownNavigator.prototype, \"willExcludeCurrentResult\", {\n get: function () {\n return this.currentResult.hasClass('coveo-facet-value-will-exclude');\n },\n enumerable: true,\n configurable: true\n });\n FacetSearchDropdownNavigator.prototype.toggleCanExcludeCurrentResult = function () {\n if (this.isCurrentResultNotAFacetValue) {\n return;\n }\n this.currentResult.toggleClass('coveo-facet-value-will-exclude', !this.willExcludeCurrentResult);\n };\n FacetSearchDropdownNavigator.prototype.announceCurrentResultCanBeExcluded = function () {\n if (this.isCurrentResultNotAFacetValue) {\n return;\n }\n var excludeIcon = Dom_1.$$(this.currentResult).find('.coveo-facet-value-exclude');\n this.config.facetSearch.updateAriaLive(excludeIcon.getAttribute('aria-label'));\n };\n return FacetSearchDropdownNavigator;\n}());\nexports.FacetSearchDropdownNavigator = FacetSearchDropdownNavigator;\n\n\n/***/ }),\n\n/***/ 547:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar SVGIcons_1 = __webpack_require__(12);\nvar SVGDom_1 = __webpack_require__(16);\nvar underscore_1 = __webpack_require__(0);\nvar Strings_1 = __webpack_require__(6);\nvar Globalize = __webpack_require__(23);\nvar CategoryFacetTemplates = /** @class */ (function () {\n function CategoryFacetTemplates() {\n this.listRoot = Dom_1.$$('ul', { className: 'coveo-category-facet-values' });\n this.collapseArrow = Dom_1.$$('span', { className: 'coveo-category-facet-collapse-children' }, SVGIcons_1.SVGIcons.icons.arrowDown);\n SVGDom_1.SVGDom.addClassToSVGInContainer(this.collapseArrow.el, 'coveo-category-facet-collapse-children-svg');\n }\n CategoryFacetTemplates.prototype.buildListRoot = function () {\n return this.listRoot.clone(true);\n };\n CategoryFacetTemplates.prototype.buildListElement = function (data) {\n var div = Dom_1.$$('div', {}, this.createListElement(data));\n return Dom_1.$$(div.el.firstChild);\n };\n CategoryFacetTemplates.prototype.buildAllCategoriesButton = function () {\n var allCategoriesCaption = Dom_1.$$('span', { className: 'coveo-category-facet-all-categories-caption' }, Strings_1.l('AllCategories'));\n var allCategories = Dom_1.$$('li', { className: 'coveo-category-facet-value coveo-category-facet-all-categories' }, this.buildCollapseArrow(), allCategoriesCaption);\n return allCategories;\n };\n CategoryFacetTemplates.prototype.buildEllipsis = function () {\n var ellipsisCaption = Dom_1.$$('span', { className: 'coveo-category-facet-ellipsis-caption' }, '[ ... ]');\n var ellipsis = Dom_1.$$('li', { className: 'coveo-category-facet-ellipsis' }, ellipsisCaption);\n return ellipsis;\n };\n CategoryFacetTemplates.prototype.buildCollapseArrow = function () {\n return this.collapseArrow.clone(true);\n };\n CategoryFacetTemplates.prototype.getFormattedCount = function (count) {\n return Globalize.format(count, 'n0');\n };\n CategoryFacetTemplates.prototype.createListElement = function (data) {\n return \"
\\n \\n
\";\n };\n return CategoryFacetTemplates;\n}());\nexports.CategoryFacetTemplates = CategoryFacetTemplates;\n\n\n/***/ }),\n\n/***/ 548:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar CategoryValueChildrenRenderer_1 = __webpack_require__(481);\nvar CategoryValueRoot = /** @class */ (function () {\n function CategoryValueRoot(element, categoryFacetTemplates, categoryFacet) {\n this.element = element;\n this.path = [];\n this.categoryChildrenValueRenderer = new CategoryValueChildrenRenderer_1.CategoryChildrenValueRenderer(element, categoryFacetTemplates, this, categoryFacet);\n this.listRoot = categoryFacetTemplates.buildListRoot();\n this.appendListRoot();\n }\n CategoryValueRoot.prototype.renderChildren = function (values) {\n this.appendListRoot();\n this.categoryChildrenValueRenderer.renderChildren(values);\n };\n CategoryValueRoot.prototype.renderAsParent = function (value) {\n this.appendListRoot();\n return this.categoryChildrenValueRenderer.renderAsParent(value);\n };\n Object.defineProperty(CategoryValueRoot.prototype, \"children\", {\n get: function () {\n return this.categoryChildrenValueRenderer.children;\n },\n enumerable: true,\n configurable: true\n });\n CategoryValueRoot.prototype.clear = function () {\n this.listRoot.detach();\n this.listRoot.empty();\n this.categoryChildrenValueRenderer.clearChildren();\n };\n CategoryValueRoot.prototype.appendListRoot = function () {\n this.element.append(this.listRoot.el);\n };\n return CategoryValueRoot;\n}());\nexports.CategoryValueRoot = CategoryValueRoot;\n\n\n/***/ }),\n\n/***/ 549:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar CategoryValueChildrenRenderer_1 = __webpack_require__(481);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Strings_1 = __webpack_require__(6);\nvar CategoryValue = /** @class */ (function () {\n function CategoryValue(listRoot, categoryValueDescriptor, categoryFacetTemplates, categoryFacet) {\n this.listRoot = listRoot;\n this.categoryValueDescriptor = categoryValueDescriptor;\n this.categoryFacetTemplates = categoryFacetTemplates;\n this.categoryFacet = categoryFacet;\n this.isActive = false;\n this.element = this.categoryFacetTemplates.buildListElement({\n value: this.captionedValueDescriptorValue,\n count: this.categoryValueDescriptor.count\n });\n this.collapseArrow = this.categoryFacetTemplates.buildCollapseArrow();\n this.categoryChildrenValueRenderer = new CategoryValueChildrenRenderer_1.CategoryChildrenValueRenderer(this.element, categoryFacetTemplates, this, this.categoryFacet);\n this.path = this.categoryValueDescriptor.path;\n }\n CategoryValue.prototype.render = function (isChild) {\n if (this.pastMaximumDepth()) {\n this.element.addClass('coveo-category-facet-last-value');\n }\n if (isChild) {\n this.element.addClass('coveo-category-facet-child-value');\n }\n else {\n this.element.addClass('coveo-category-facet-parent-value');\n }\n this.listRoot.append(this.element.el);\n };\n CategoryValue.prototype.getDescriptor = function () {\n return {\n value: this.categoryValueDescriptor.value,\n count: this.categoryValueDescriptor.count,\n path: this.path\n };\n };\n CategoryValue.prototype.clear = function () {\n this.element.detach();\n this.categoryChildrenValueRenderer.clearChildren();\n };\n CategoryValue.prototype.renderChildren = function (values) {\n this.isActive = true;\n this.element.addClass('coveo-active-category-facet-parent');\n this.categoryChildrenValueRenderer.renderChildren(values);\n };\n CategoryValue.prototype.renderAsParent = function (value) {\n return this.categoryChildrenValueRenderer.renderAsParent(value);\n };\n Object.defineProperty(CategoryValue.prototype, \"children\", {\n get: function () {\n return this.categoryChildrenValueRenderer.children;\n },\n enumerable: true,\n configurable: true\n });\n CategoryValue.prototype.makeSelectable = function () {\n var _this = this;\n var element = Dom_1.$$(this.element.find('.coveo-category-facet-value-label'));\n element.addClass('coveo-selectable');\n var count = this.categoryValueDescriptor.count;\n var countLabel = Strings_1.l('ResultCount', count.toString(), count);\n var label = Strings_1.l('IncludeValueWithResultCount', this.captionedValueDescriptorValue, countLabel);\n new AccessibleButton_1.AccessibleButton()\n .withElement(element)\n .withSelectAction(function () { return _this.onSelect(); })\n .withLabel(label)\n .build();\n return this;\n };\n CategoryValue.prototype.showCollapseArrow = function () {\n if (!this.collapseArrow.el.parentElement) {\n var label = this.element.find('label');\n Dom_1.$$(label).prepend(this.collapseArrow.el);\n }\n return this;\n };\n Object.defineProperty(CategoryValue.prototype, \"captionedValueDescriptorValue\", {\n get: function () {\n var value = this.categoryValueDescriptor.value;\n return this.categoryFacet.getCaption(value);\n },\n enumerable: true,\n configurable: true\n });\n CategoryValue.prototype.onSelect = function () {\n if (!this.pastMaximumDepth()) {\n this.categoryFacet.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSelect, this.path);\n this.categoryFacet.scrollToTop();\n this.categoryFacet.changeActivePath(this.path);\n this.categoryFacet.executeQuery();\n }\n };\n CategoryValue.prototype.pastMaximumDepth = function () {\n return this.path.length - this.categoryFacet.options.basePath.length >= this.categoryFacet.options.maximumDepth;\n };\n return CategoryValue;\n}());\nexports.CategoryValue = CategoryValue;\n\n\n/***/ }),\n\n/***/ 550:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar AllowedValuesPatternType_1 = __webpack_require__(475);\nvar Utils_1 = __webpack_require__(4);\nvar CategoryFacetQueryController = /** @class */ (function () {\n function CategoryFacetQueryController(categoryFacet) {\n this.categoryFacet = categoryFacet;\n }\n CategoryFacetQueryController.prototype.putCategoryFacetInQueryBuilder = function (queryBuilder, path, maximumNumberOfValues) {\n var positionInQuery = queryBuilder.categoryFacets.length;\n this.addQueryFilter(queryBuilder, path);\n this.addCategoryFacetRequest(queryBuilder, path, maximumNumberOfValues);\n return positionInQuery;\n };\n CategoryFacetQueryController.prototype.searchFacetValues = function (value, numberOfValues) {\n return __awaiter(this, void 0, void 0, function () {\n var lastQuery, groupByRequest, results, sortByNumberOfResultsThenPathLength;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n lastQuery = __assign({}, this.categoryFacet.queryController.getLastQuery());\n groupByRequest = {\n allowedValues: [this.getAllowedValuesPattern(value)],\n allowedValuesPatternType: AllowedValuesPatternType_1.AllowedValuesPatternType.Wildcards,\n maximumNumberOfValues: numberOfValues,\n field: this.categoryFacet.options.field,\n sortCriteria: 'occurrences',\n injectionDepth: this.categoryFacet.options.injectionDepth\n };\n lastQuery.groupBy = [groupByRequest];\n lastQuery.categoryFacets.splice(this.categoryFacet.positionInQuery, 1);\n return [4 /*yield*/, this.categoryFacet.queryController.getEndpoint().search(lastQuery)];\n case 1:\n results = _a.sent();\n sortByNumberOfResultsThenPathLength = function (firstGroupByValue, secondGroupByValue) {\n if (firstGroupByValue.numberOfResults == secondGroupByValue.numberOfResults) {\n return firstGroupByValue.value.length - secondGroupByValue.value.length;\n }\n return secondGroupByValue.numberOfResults - firstGroupByValue.numberOfResults;\n };\n return [2 /*return*/, results.groupByResults[0].values.sort(sortByNumberOfResultsThenPathLength)];\n }\n });\n });\n };\n CategoryFacetQueryController.prototype.addDebugGroupBy = function (queryBuilder, value) {\n queryBuilder.groupByRequests.push({\n field: this.categoryFacet.options.field,\n allowedValues: [\".*\" + Utils_1.Utils.escapeRegexCharacter(value) + \".*\"],\n allowedValuesPatternType: AllowedValuesPatternType_1.AllowedValuesPatternType.Regex\n });\n };\n CategoryFacetQueryController.prototype.shouldAddFilterToQuery = function (path) {\n return path.length != 0 && !Utils_1.Utils.arrayEqual(path, this.categoryFacet.options.basePath);\n };\n CategoryFacetQueryController.prototype.addQueryFilter = function (queryBuilder, path) {\n if (this.shouldAddFilterToQuery(path)) {\n queryBuilder.advancedExpression.addFieldExpression(this.categoryFacet.options.field, '==', [\n path.join(this.categoryFacet.options.delimitingCharacter)\n ]);\n }\n };\n CategoryFacetQueryController.prototype.addCategoryFacetRequest = function (queryBuilder, path, maximumNumberOfValues) {\n var categoryFacetsRequest = {\n field: this.categoryFacet.options.field,\n path: path,\n injectionDepth: this.categoryFacet.options.injectionDepth,\n maximumNumberOfValues: maximumNumberOfValues,\n delimitingCharacter: this.categoryFacet.options.delimitingCharacter\n };\n queryBuilder.categoryFacets.push(categoryFacetsRequest);\n };\n CategoryFacetQueryController.prototype.getAllowedValuesPattern = function (value) {\n var basePath = this.categoryFacet.options.basePath;\n var delimiter = this.categoryFacet.options.delimitingCharacter;\n if (Utils_1.Utils.isNonEmptyArray(basePath)) {\n return \"\" + basePath.join(delimiter) + delimiter + \"*\" + value + \"*\";\n }\n return \"*\" + value + \"*\";\n };\n return CategoryFacetQueryController;\n}());\nexports.CategoryFacetQueryController = CategoryFacetQueryController;\n\n\n/***/ }),\n\n/***/ 551:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 552:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar CategoryFacet_1 = __webpack_require__(94);\nvar FacetSearchElement_1 = __webpack_require__(479);\nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nvar SVGDom_1 = __webpack_require__(16);\nvar SVGIcons_1 = __webpack_require__(12);\nvar Strings_1 = __webpack_require__(6);\n__webpack_require__(553);\nvar StringUtils_1 = __webpack_require__(22);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Globalize = __webpack_require__(23);\nvar CategoryFacetSearch = /** @class */ (function () {\n function CategoryFacetSearch(categoryFacet, displayButton) {\n if (displayButton === void 0) { displayButton = true; }\n var _this = this;\n this.categoryFacet = categoryFacet;\n this.displayButton = displayButton;\n this.moreValuesToFetch = true;\n this.facetSearchElement = new FacetSearchElement_1.FacetSearchElement(this);\n this.displayNewValues = underscore_1.debounce(this.getDisplayNewValuesFunction(), this.categoryFacet.options.facetSearchDelay);\n this.categoryFacet.root.addEventListener('click', function (e) { return _this.handleClickElsewhere(e); });\n this.numberOfValuesToFetch = this.categoryFacet.options.numberOfResultsInFacetSearch;\n }\n Object.defineProperty(CategoryFacetSearch.prototype, \"facetType\", {\n get: function () {\n return CategoryFacet_1.CategoryFacet.ID;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(CategoryFacetSearch.prototype, \"facetTitle\", {\n get: function () {\n return this.categoryFacet.options.title || this.categoryFacet.options.field.toString();\n },\n enumerable: true,\n configurable: true\n });\n CategoryFacetSearch.prototype.setExpandedFacetSearchAccessibilityAttributes = function (searchResultsElements) {\n this.container.setAttribute('aria-expanded', 'true');\n };\n CategoryFacetSearch.prototype.setCollapsedFacetSearchAccessibilityAttributes = function () {\n this.container.setAttribute('aria-expanded', 'false');\n };\n CategoryFacetSearch.prototype.build = function () {\n this.container = Dom_1.$$('div', {\n className: 'coveo-category-facet-search-container',\n role: 'button'\n });\n this.container.toggleClass('coveo-category-facet-search-without-button', !this.displayButton);\n this.displayButton && this.buildButton();\n this.container.append(this.facetSearchElement.build());\n Dom_1.$$(this.facetSearchElement.search).toggleClass('without-animation', !this.displayButton);\n return this.container;\n };\n CategoryFacetSearch.prototype.buildButton = function () {\n var _this = this;\n new AccessibleButton_1.AccessibleButton()\n .withElement(this.container)\n .withSelectAction(function () {\n Dom_1.$$(_this.categoryFacet.element).addClass('coveo-category-facet-searching');\n _this.focus();\n })\n .withLabel(Strings_1.l('SearchFacetResults', this.facetTitle))\n .build();\n this.buildfacetSearchPlaceholder();\n };\n CategoryFacetSearch.prototype.focus = function () {\n this.facetSearchElement.focus();\n };\n CategoryFacetSearch.prototype.clear = function () {\n this.dismissSearchResults();\n this.container && this.container.detach();\n };\n CategoryFacetSearch.prototype.dismissSearchResults = function () {\n this.removeNoResultsCssClasses();\n Dom_1.$$(this.categoryFacet.element).removeClass('coveo-category-facet-searching');\n Dom_1.$$(this.facetSearchElement.searchResults).empty();\n this.facetSearchElement.clearSearchInput();\n this.facetSearchElement.hideSearchResultsElement();\n this.currentlyDisplayedResults = null;\n this.numberOfValuesToFetch = this.categoryFacet.options.numberOfResultsInFacetSearch;\n this.moreValuesToFetch = true;\n };\n CategoryFacetSearch.prototype.keyboardEventDefaultHandler = function () {\n this.moreValuesToFetch = true;\n this.displayNewValues();\n };\n CategoryFacetSearch.prototype.keyboardNavigationEnterPressed = function () {\n this.selectCurrentResult();\n };\n CategoryFacetSearch.prototype.fetchMoreValues = function () {\n this.numberOfValuesToFetch += this.categoryFacet.options.numberOfResultsInFacetSearch;\n this.displayNewValues();\n };\n CategoryFacetSearch.prototype.getCaptions = function () {\n var searchResults = Dom_1.$$(this.facetSearchElement.searchResults);\n var captions = searchResults\n .findAll('.coveo-category-facet-search-value-caption')\n .concat(searchResults.findAll('.coveo-category-facet-search-path-parents'))\n .concat(searchResults.findAll('.coveo-category-facet-search-path-last-value'));\n return captions;\n };\n CategoryFacetSearch.prototype.updateAriaLive = function (text) {\n this.categoryFacet.searchInterface.ariaLive.updateText(text);\n };\n CategoryFacetSearch.prototype.selectCurrentResult = function () {\n if (this.facetSearchElement.currentResult) {\n var currentResultPathData = this.facetSearchElement.currentResult.el.dataset.path;\n var delimiter = this.categoryFacet.options.delimitingCharacter;\n var path = currentResultPathData.split(delimiter);\n this.categoryFacet.changeActivePath(path);\n this.categoryFacet.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSelect, path);\n this.categoryFacet.executeQuery();\n this.categoryFacet.scrollToTop();\n }\n };\n CategoryFacetSearch.prototype.handleClickElsewhere = function (e) {\n var closestContainer = Dom_1.$$(e.target).closest('.coveo-category-facet-search-container');\n var isSelfContainer = this.container && closestContainer === this.container.el;\n if (!closestContainer || !isSelfContainer) {\n this.dismissSearchResults();\n }\n };\n CategoryFacetSearch.prototype.buildfacetSearchPlaceholder = function () {\n var placeholder = Dom_1.$$('div', { className: 'coveo-category-facet-search-placeholder' });\n var icon = Dom_1.$$('div', { className: 'coveo-category-facet-search-icon' }, SVGIcons_1.SVGIcons.icons.checkboxHookExclusionMore);\n SVGDom_1.SVGDom.addClassToSVGInContainer(icon.el, 'coveo-category-facet-search-icon-svg');\n var label = Dom_1.$$('span', { className: 'coveo-category-facet-search-label' }, Strings_1.l('Search'));\n placeholder.append(icon.el);\n placeholder.append(label.el);\n this.container.append(placeholder.el);\n };\n CategoryFacetSearch.prototype.getDisplayNewValuesFunction = function () {\n var _this = this;\n return function () { return __awaiter(_this, void 0, void 0, function () {\n var categoryFacetValues;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.facetSearchElement.showFacetSearchWaitingAnimation();\n this.categoryFacet.logger.info('Triggering new Category Facet search');\n return [4 /*yield*/, this.categoryFacet.categoryFacetQueryController.searchFacetValues(this.facetSearchElement.input.value, this.numberOfValuesToFetch)];\n case 1:\n categoryFacetValues = _a.sent();\n this.logAnalyticsEvent();\n if (categoryFacetValues.length < this.numberOfValuesToFetch) {\n this.moreValuesToFetch = false;\n }\n if (categoryFacetValues.length == 0) {\n this.noFacetSearchResults();\n return [2 /*return*/];\n }\n this.removeNoResultsCssClasses();\n this.setFacetSearchResults(categoryFacetValues);\n if (this.shouldPositionSearchResults) {\n this.facetSearchElement.positionSearchResults();\n }\n this.facetSearchElement.hideFacetSearchWaitingAnimation();\n return [2 /*return*/];\n }\n });\n }); };\n };\n CategoryFacetSearch.prototype.setFacetSearchResults = function (categoryFacetValues) {\n Dom_1.$$(this.facetSearchElement.searchResults).empty();\n this.currentlyDisplayedResults = underscore_1.pluck(categoryFacetValues, 'value');\n for (var i = 0; i < categoryFacetValues.length; i++) {\n var searchResult = this.buildFacetSearchValue(categoryFacetValues[i], i);\n if (i == 0) {\n this.facetSearchElement.setAsCurrentResult(searchResult);\n }\n this.facetSearchElement.appendToSearchResults(searchResult.el);\n }\n this.highlightCurrentQueryWithinSearchResults();\n this.facetSearchElement.updateAriaLiveWithResults(this.facetSearchElement.input.value, this.currentlyDisplayedResults.length, this.moreValuesToFetch);\n };\n CategoryFacetSearch.prototype.getFormattedCount = function (count) {\n return Globalize.format(count, 'n0');\n };\n CategoryFacetSearch.prototype.buildFacetSearchValue = function (categoryFacetValue, index) {\n var _this = this;\n var path = categoryFacetValue.value.split(this.categoryFacet.options.delimitingCharacter);\n var pathParents = path.slice(0, -1).length != 0 ? path.slice(0, -1).join('/') + \"/\" : '';\n var value = Dom_1.$$('span', { className: 'coveo-category-facet-search-value-caption' }, underscore_1.last(path));\n var number = Dom_1.$$('span', { className: 'coveo-category-facet-search-value-number' }, this.getFormattedCount(categoryFacetValue.numberOfResults));\n var pathParentsCaption = Dom_1.$$('span', { className: 'coveo-category-facet-search-path-parents' }, pathParents);\n var pathToValueCaption = Dom_1.$$('span', { className: 'coveo-category-facet-search-path' }, pathParentsCaption);\n var firstRow = Dom_1.$$('div', { className: 'coveo-category-facet-search-first-row' }, value, number);\n var secondRow = Dom_1.$$('div', { className: 'coveo-category-facet-search-second-row' }, pathToValueCaption);\n var item = Dom_1.$$('li', {\n id: \"coveo-category-facet-search-suggestion-\" + index,\n role: 'option',\n ariaSelected: 'false',\n className: 'coveo-category-facet-search-value',\n title: path\n }, firstRow, secondRow);\n item.el.dataset.path = categoryFacetValue.value;\n var countLabel = Strings_1.l('ResultCount', this.getFormattedCount(categoryFacetValue.numberOfResults), categoryFacetValue.numberOfResults);\n var label = Strings_1.l('IncludeValueWithResultCount', underscore_1.last(path), countLabel);\n new AccessibleButton_1.AccessibleButton()\n .withElement(item)\n .withSelectAction(function () {\n _this.categoryFacet.changeActivePath(path);\n _this.categoryFacet.scrollToTop();\n _this.categoryFacet.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSelect, path);\n _this.categoryFacet.executeQuery();\n })\n .withLabel(label)\n .build();\n return item;\n };\n CategoryFacetSearch.prototype.noFacetSearchResults = function () {\n this.facetSearchElement.hideFacetSearchWaitingAnimation();\n this.facetSearchElement.emptyAndShowNoResults();\n Dom_1.$$(this.facetSearchElement.search).addClass('coveo-facet-search-no-results');\n Dom_1.$$(this.categoryFacet.element).addClass('coveo-no-results');\n };\n CategoryFacetSearch.prototype.removeNoResultsCssClasses = function () {\n this.facetSearchElement.search && Dom_1.$$(this.facetSearchElement.search).removeClass('coveo-facet-search-no-results');\n Dom_1.$$(this.categoryFacet.element).removeClass('coveo-no-results');\n };\n CategoryFacetSearch.prototype.highlightCurrentQueryWithinSearchResults = function () {\n var regex = new RegExp(\"(\" + StringUtils_1.StringUtils.stringToRegex(this.facetSearchElement.input.value, true) + \")\", 'ig');\n this.facetSearchElement.highlightCurrentQueryInSearchResults(regex);\n };\n CategoryFacetSearch.prototype.logAnalyticsEvent = function () {\n this.categoryFacet.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSearch, {\n categoryFacetId: this.categoryFacet.options.id,\n categoryFacetField: this.categoryFacet.options.field.toString(),\n categoryFacetTitle: this.categoryFacet.options.title\n }, this.categoryFacet.root);\n };\n Object.defineProperty(CategoryFacetSearch.prototype, \"shouldPositionSearchResults\", {\n get: function () {\n var searchResults = this.facetSearchElement.searchResults;\n return searchResults && !searchResults.parentElement;\n },\n enumerable: true,\n configurable: true\n });\n return CategoryFacetSearch;\n}());\nexports.CategoryFacetSearch = CategoryFacetSearch;\n\n\n/***/ }),\n\n/***/ 553:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 554:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Dom_1 = __webpack_require__(1);\nvar SVGIcons_1 = __webpack_require__(12);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Strings_1 = __webpack_require__(6);\nvar underscore_1 = __webpack_require__(0);\nvar AccessibilityUtils_1 = __webpack_require__(48);\nvar CategoryFacetBreadcrumb = /** @class */ (function () {\n function CategoryFacetBreadcrumb(categoryFacet, onClickHandler, categoryValueDescriptor, options) {\n this.categoryFacet = categoryFacet;\n this.onClickHandler = onClickHandler;\n this.categoryValueDescriptor = categoryValueDescriptor;\n this.options = options;\n }\n CategoryFacetBreadcrumb.prototype.build = function () {\n var _this = this;\n var clear = Dom_1.$$('span', {\n className: 'coveo-facet-breadcrumb-clear'\n }, SVGIcons_1.SVGIcons.icons.mainClear);\n var pathToRender = underscore_1.without.apply(void 0, [this.categoryValueDescriptor.path].concat(this.categoryFacet.options.basePath));\n var captionLabel = pathToRender.map(function (pathPart) { return _this.categoryFacet.getCaption(pathPart); }).join('/');\n var breadcrumbTitle = Dom_1.$$(AccessibilityUtils_1.getHeadingTag(this.options && this.options.headingLevel, 'span'), { className: 'coveo-category-facet-breadcrumb-title' }, this.categoryFacet.options.title + \":\");\n var valuesContainer = Dom_1.$$('span', { className: 'coveo-category-facet-breadcrumb-values' }, captionLabel, clear);\n new AccessibleButton_1.AccessibleButton()\n .withElement(valuesContainer)\n .withLabel(Strings_1.l('RemoveFilterOn', captionLabel))\n .withSelectAction(this.onClickHandler)\n .build();\n var breadcrumb = Dom_1.$$('span', { className: 'coveo-category-facet-breadcrumb' }, breadcrumbTitle, valuesContainer);\n return breadcrumb.el;\n };\n return CategoryFacetBreadcrumb;\n}());\nexports.CategoryFacetBreadcrumb = CategoryFacetBreadcrumb;\n\n\n/***/ }),\n\n/***/ 555:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar CategoryFacet_1 = __webpack_require__(94);\nvar QueryEvents_1 = __webpack_require__(11);\nvar underscore_1 = __webpack_require__(0);\nvar Logger_1 = __webpack_require__(9);\nvar PathMap = /** @class */ (function () {\n function PathMap() {\n }\n return PathMap;\n}());\nvar CategoryFacetDebug = /** @class */ (function () {\n function CategoryFacetDebug(categoryFacet) {\n var _this = this;\n this.categoryFacet = categoryFacet;\n this.categoryFacet.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); });\n this.categoryFacet.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (args) {\n _this.handleQuerySuccess(args);\n });\n }\n CategoryFacetDebug.prototype.handleBuildingQuery = function (args) {\n var firstPositionInQuery = args.queryBuilder.groupByRequests.length;\n if (this.categoryFacet.activePath.length == 0) {\n this.positionInQuery = { start: firstPositionInQuery, end: firstPositionInQuery + 1 };\n this.addGroupByForEmptyPath(args.queryBuilder);\n }\n else {\n var path = this.categoryFacet.activePath;\n this.positionInQuery = { start: firstPositionInQuery, end: firstPositionInQuery + path.length };\n this.addGroupByForEachPathElement(args.queryBuilder, path);\n }\n };\n CategoryFacetDebug.prototype.handleQuerySuccess = function (args) {\n var _this = this;\n args.results.groupByResults\n .slice(this.positionInQuery.start, this.positionInQuery.end)\n .forEach(function (groupByResult) { return CategoryFacetDebug.analyzeResults(groupByResult, _this.categoryFacet.options.delimitingCharacter); });\n };\n CategoryFacetDebug.prototype.addGroupByForEmptyPath = function (queryBuilder) {\n queryBuilder.groupByRequests.push({\n field: this.categoryFacet.options.field,\n injectionDepth: this.categoryFacet.options.injectionDepth\n });\n };\n CategoryFacetDebug.prototype.addGroupByForEachPathElement = function (queryBuilder, path) {\n var _this = this;\n path.forEach(function (pathElement) {\n _this.categoryFacet.categoryFacetQueryController.addDebugGroupBy(queryBuilder, pathElement);\n });\n };\n CategoryFacetDebug.analyzeResults = function (groupByResults, delimiter) {\n var _this = this;\n var treeRoot = new Map();\n var orphans = [];\n var paths = this.buildPathsFromGroupByValues(groupByResults.values, delimiter);\n paths = underscore_1.sortBy(paths, function (value) { return value.length; });\n paths.forEach(function (path) {\n if (path.length == 1) {\n _this.addFirstNodeToTree(treeRoot, path);\n }\n else {\n var pathIsValid = true;\n var parentsOnly = path.slice(0, -1);\n var currentNode = treeRoot;\n for (var _i = 0, parentsOnly_1 = parentsOnly; _i < parentsOnly_1.length; _i++) {\n var parent_1 = parentsOnly_1[_i];\n currentNode = currentNode.get(parent_1);\n if (!currentNode) {\n _this.processOrphan(orphans, path, delimiter);\n pathIsValid = false;\n break;\n }\n }\n if (pathIsValid) {\n _this.addValidNodeToTree(currentNode, path);\n }\n }\n });\n return orphans;\n };\n CategoryFacetDebug.buildPathsFromGroupByValues = function (values, delimiter) {\n return underscore_1.chain(values)\n .pluck('value')\n .map(function (value) { return value.split(delimiter); })\n .sortBy(function (value) { return value.length; })\n .value();\n };\n CategoryFacetDebug.addFirstNodeToTree = function (treeRoot, path) {\n treeRoot.set(path[0], new Map());\n };\n CategoryFacetDebug.addValidNodeToTree = function (node, path) {\n node.set(path.slice(-1)[0], new Map());\n };\n CategoryFacetDebug.processOrphan = function (orphans, path, delimiter) {\n var formattedOrphan = path.join(delimiter);\n orphans.push(formattedOrphan);\n this.logger.error(\"Value \" + formattedOrphan + \" has no parent.\");\n };\n CategoryFacetDebug.logger = new Logger_1.Logger(CategoryFacet_1.CategoryFacet);\n return CategoryFacetDebug;\n}());\nexports.CategoryFacetDebug = CategoryFacetDebug;\n\n\n/***/ }),\n\n/***/ 556:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar CategoryFacet_1 = __webpack_require__(94);\nvar Dom_1 = __webpack_require__(1);\nvar Strings_1 = __webpack_require__(6);\nvar SVGIcons_1 = __webpack_require__(12);\nvar SVGDom_1 = __webpack_require__(16);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar CategoryFacetHeader = /** @class */ (function () {\n function CategoryFacetHeader(options) {\n this.options = options;\n this.element = document.createElement('div');\n Dom_1.$$(this.element).addClass('coveo-facet-header');\n }\n CategoryFacetHeader.prototype.build = function () {\n var waitElement = this.buildWaitAnimation();\n var titleSection = Dom_1.$$('div', {\n className: 'coveo-category-facet-title',\n role: 'heading',\n 'aria-level': '2',\n 'aria-label': Strings_1.l('FacetTitle', this.options.title) + \".\"\n }, this.options.title);\n this.element = Dom_1.$$('div', { className: 'coveo-category-facet-header' }, titleSection).el;\n Dom_1.$$(this.element).append(waitElement);\n var eraserElement = this.buildEraser();\n Dom_1.$$(this.element).append(eraserElement);\n return this.element;\n };\n CategoryFacetHeader.prototype.buildWaitAnimation = function () {\n var waitElement = Dom_1.$$('div', { className: CategoryFacet_1.CategoryFacet.WAIT_ELEMENT_CLASS }, SVGIcons_1.SVGIcons.icons.loading).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(waitElement, 'coveo-category-facet-header-wait-animation-svg');\n waitElement.style.visibility = 'hidden';\n return waitElement;\n };\n CategoryFacetHeader.prototype.buildEraser = function () {\n var _this = this;\n var eraserElement = Dom_1.$$('div', { className: 'coveo-category-facet-header-eraser coveo-facet-header-eraser' }, SVGIcons_1.SVGIcons.icons.mainClear)\n .el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(eraserElement, 'coveo-facet-header-eraser-svg');\n var onClearClick = function () {\n _this.options.categoryFacet.reset();\n _this.options.categoryFacet.scrollToTop();\n };\n new AccessibleButton_1.AccessibleButton()\n .withElement(eraserElement)\n .withLabel(Strings_1.l('Clear', this.options.title))\n .withClickAction(onClearClick)\n .withEnterKeyboardAction(onClearClick)\n .build();\n return eraserElement;\n };\n return CategoryFacetHeader;\n}());\nexports.CategoryFacetHeader = CategoryFacetHeader;\n\n\n/***/ }),\n\n/***/ 557:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar underscore_1 = __webpack_require__(0);\nvar CategoryFacetValuesTree = /** @class */ (function () {\n function CategoryFacetValuesTree() {\n this.seenValues = [];\n }\n CategoryFacetValuesTree.prototype.getValueForLastPartInPath = function (path) {\n var nullCategoryFacetValue = { value: '', numberOfResults: 0 };\n var currentNode;\n for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {\n var part = path_1[_i];\n var nodesToSearch = currentNode ? currentNode.children : this.seenValues;\n var node = this.findNodeWithValue(nodesToSearch, part);\n if (!node) {\n return nullCategoryFacetValue;\n }\n currentNode = node;\n }\n return currentNode ? currentNode.result : nullCategoryFacetValue;\n };\n CategoryFacetValuesTree.prototype.storeNewValues = function (categoryFacetResult) {\n var _this = this;\n var currentNodes = this.seenValues;\n for (var _i = 0, _a = categoryFacetResult.parentValues; _i < _a.length; _i++) {\n var parent_1 = _a[_i];\n var node = this.findNodeWithValue(currentNodes, parent_1.value);\n if (!node) {\n var newNode = { result: parent_1, children: [] };\n currentNodes.push(newNode);\n }\n currentNodes = this.findNodeWithValue(currentNodes, parent_1.value).children;\n }\n categoryFacetResult.values\n .filter(function (result) { return !_this.findNodeWithValue(currentNodes, result.value); })\n .forEach(function (result) { return currentNodes.push({ result: result, children: [] }); });\n };\n CategoryFacetValuesTree.prototype.findNodeWithValue = function (nodes, value) {\n return underscore_1.find(nodes, function (node) { return node.result.value === value; });\n };\n return CategoryFacetValuesTree;\n}());\nexports.CategoryFacetValuesTree = CategoryFacetValuesTree;\n\n\n/***/ }),\n\n/***/ 558:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 559:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Assert_1 = __webpack_require__(5);\nvar Utils_1 = __webpack_require__(4);\nvar FacetValue_1 = __webpack_require__(118);\nvar _ = __webpack_require__(0);\nvar FacetValues = /** @class */ (function () {\n function FacetValues(groupByResult) {\n if (Utils_1.Utils.exists(groupByResult)) {\n this.values = _.map(groupByResult.values, function (groupByValue) { return FacetValue_1.FacetValue.createFromGroupByValue(groupByValue); });\n }\n else {\n this.values = [];\n }\n }\n FacetValues.prototype.add = function (facetValue) {\n Assert_1.Assert.exists(facetValue);\n Assert_1.Assert.check(!this.contains(facetValue.value));\n this.values.push(facetValue);\n };\n FacetValues.prototype.remove = function (value) {\n Assert_1.Assert.isNonEmptyString(value);\n value = value;\n this.values = _.filter(this.values, function (elem) { return elem.value != value; });\n };\n FacetValues.prototype.size = function () {\n return this.values.length;\n };\n FacetValues.prototype.isEmpty = function () {\n return this.values.length == 0;\n };\n FacetValues.prototype.at = function (index) {\n Assert_1.Assert.isLargerOrEqualsThan(0, index);\n Assert_1.Assert.isSmallerThan(this.values.length, index);\n return this.values[index];\n };\n FacetValues.prototype.get = function (value) {\n return _.find(this.values, function (elem) { return elem.value.toLowerCase() == value.toLowerCase(); });\n };\n FacetValues.prototype.contains = function (value) {\n return Utils_1.Utils.exists(this.get(value));\n };\n FacetValues.prototype.getAll = function () {\n return this.values;\n };\n FacetValues.prototype.getSelected = function () {\n return _.filter(this.values, function (value) { return value.selected; });\n };\n FacetValues.prototype.getExcluded = function () {\n return _.filter(this.values, function (value) { return value.excluded; });\n };\n FacetValues.prototype.hasSelectedOrExcludedValues = function () {\n return this.getSelected().length != 0 || this.getExcluded().length != 0;\n };\n FacetValues.prototype.hasSelectedAndExcludedValues = function () {\n return this.getSelected().length != 0 && this.getExcluded().length != 0;\n };\n FacetValues.prototype.hasOnlyExcludedValues = function () {\n return this.getSelected().length == 0 && this.getExcluded().length != 0;\n };\n FacetValues.prototype.hasOnlySelectedValues = function () {\n return this.getSelected().length != 0 && this.getExcluded().length == 0;\n };\n FacetValues.prototype.reset = function () {\n _.each(this.values, function (elem) { return elem.reset(); });\n };\n FacetValues.prototype.importActiveValuesFromOtherList = function (other) {\n var _this = this;\n Assert_1.Assert.exists(other);\n _.each(other.getSelected(), function (otherValue) {\n var myValue = _this.get(otherValue.value);\n if (Utils_1.Utils.exists(myValue)) {\n myValue.selected = true;\n }\n else {\n _this.values.push(otherValue.cloneWithZeroOccurrences());\n }\n });\n _.each(other.getExcluded(), function (otherValue) {\n var myValue = _this.get(otherValue.value);\n if (Utils_1.Utils.exists(myValue)) {\n myValue.excluded = true;\n }\n else if (otherValue.occurrences != 0) {\n var occurrences = otherValue.occurrences;\n var clone = otherValue.cloneWithZeroOccurrences();\n clone.occurrences = occurrences;\n _this.values.push(clone);\n }\n else {\n _this.values.push(otherValue.cloneWithZeroOccurrences());\n }\n });\n };\n FacetValues.prototype.updateCountsFromNewValues = function (newValues) {\n Assert_1.Assert.exists(newValues);\n this.values = _.map(this.values, function (myValue) {\n var newValue = newValues.get(myValue.value);\n if (Utils_1.Utils.exists(newValue)) {\n myValue.updateCountsFromNewValue(newValue);\n return myValue;\n }\n else if (myValue.occurrences == null) {\n return myValue.cloneWithZeroOccurrences();\n }\n return myValue;\n });\n };\n FacetValues.prototype.updateDeltaWithFilteredFacetValues = function (filtered, isMultiValueField) {\n var _this = this;\n Assert_1.Assert.exists(filtered);\n _.each(this.values, function (unfilteredValue) {\n var filteredValue = filtered.get(unfilteredValue.value);\n unfilteredValue.waitingForDelta = false;\n if (Utils_1.Utils.exists(filteredValue)) {\n if (unfilteredValue.occurrences - filteredValue.occurrences > 0) {\n // When there are only exclusion in the facet, there should be no \"delta\"\n // The number of value for each facet will be what is selected, no addition.\n if (_this.hasOnlyExcludedValues()) {\n unfilteredValue.delta = null;\n unfilteredValue.occurrences = filteredValue.occurrences;\n }\n else {\n unfilteredValue.delta = unfilteredValue.occurrences - filteredValue.occurrences;\n }\n }\n else {\n unfilteredValue.delta = null;\n }\n }\n else if (!unfilteredValue.selected && !unfilteredValue.excluded) {\n if (isMultiValueField && filtered.values.length == 0) {\n unfilteredValue.delta = null;\n unfilteredValue.occurrences = 0;\n }\n else {\n unfilteredValue.delta = unfilteredValue.occurrences;\n }\n }\n });\n };\n FacetValues.prototype.mergeWithUnfilteredFacetValues = function (unfiltered) {\n var _this = this;\n Assert_1.Assert.exists(unfiltered);\n var values = [];\n _.each(unfiltered.values, function (unfilteredValue) {\n var filteredValue = _this.get(unfilteredValue.value);\n if (Utils_1.Utils.exists(filteredValue)) {\n if (filteredValue.occurrences == unfilteredValue.occurrences) {\n values.push(filteredValue);\n }\n else {\n values.push(unfilteredValue.cloneWithDelta(unfilteredValue.occurrences, unfilteredValue.occurrences - filteredValue.occurrences));\n }\n }\n else {\n values.push(unfilteredValue.cloneWithDelta(unfilteredValue.occurrences, unfilteredValue.occurrences));\n }\n });\n var index = 0;\n _.each(this.values, function (value) {\n var unfilteredValue = unfiltered.get(value.value);\n if (!Utils_1.Utils.exists(unfilteredValue)) {\n if (value.selected || value.excluded) {\n values.splice(index, 0, value);\n index++;\n }\n }\n else {\n for (var i = 0; i < values.length; i++) {\n if (values[i].value == value.value) {\n index = i + 1;\n break;\n }\n }\n }\n });\n this.values = values;\n };\n FacetValues.prototype.sort = function (options) {\n var facetValuesOrder = options.facetValuesOrder, numberOfValues = options.numberOfValues;\n this.values = facetValuesOrder.reorderValuesIfUsingAlphabeticalSort(this.values);\n this.sortValuesDependingOnStatus(numberOfValues);\n this.values = facetValuesOrder.reorderValuesIfUsingCustomSort(this.values);\n };\n FacetValues.prototype.sortValuesDependingOnStatus = function (numOfDisplayedValues) {\n this.values = _.sortBy(this.values, function (value) {\n if (value.selected) {\n return 1;\n }\n else if (value.excluded) {\n return 3;\n }\n else {\n return 2;\n }\n });\n this.ensureExcludedValuesAreDisplayed(numOfDisplayedValues);\n };\n FacetValues.prototype.ensureExcludedValuesAreDisplayed = function (numOfDisplayedValues) {\n if (numOfDisplayedValues != null && numOfDisplayedValues < this.values.length) {\n var nbExclude = this.getExcluded().length;\n var excludedValues = this.values.splice(this.values.length - nbExclude, nbExclude);\n (_a = this.values).splice.apply(_a, [numOfDisplayedValues - nbExclude, 0].concat(excludedValues));\n }\n var _a;\n };\n return FacetValues;\n}());\nexports.FacetValues = FacetValues;\n\n\n/***/ }),\n\n/***/ 70:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(540);\n__webpack_require__(541);\nvar _ = __webpack_require__(0);\nvar FacetQueryController_1 = __webpack_require__(217);\nvar BreadcrumbEvents_1 = __webpack_require__(35);\nvar OmniboxEvents_1 = __webpack_require__(34);\nvar QueryEvents_1 = __webpack_require__(11);\nvar SearchAlertEvents_1 = __webpack_require__(87);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Assert_1 = __webpack_require__(5);\nvar Defer_1 = __webpack_require__(31);\nvar Model_1 = __webpack_require__(18);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Strings_1 = __webpack_require__(6);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar ComponentsTypes_1 = __webpack_require__(47);\nvar DependsOnManager_1 = __webpack_require__(174);\nvar DeviceUtils_1 = __webpack_require__(24);\nvar Dom_1 = __webpack_require__(1);\nvar SVGDom_1 = __webpack_require__(16);\nvar SVGIcons_1 = __webpack_require__(12);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\nvar ResponsiveFacetOptions_1 = __webpack_require__(85);\nvar ResponsiveFacets_1 = __webpack_require__(175);\nvar BreadcrumbValueElement_1 = __webpack_require__(485);\nvar BreadcrumbValuesList_1 = __webpack_require__(486);\nvar FacetHeader_1 = __webpack_require__(484);\nvar FacetSearch_1 = __webpack_require__(487);\nvar FacetSearchParameters_1 = __webpack_require__(173);\nvar FacetSearchValuesList_1 = __webpack_require__(488);\nvar FacetSettings_1 = __webpack_require__(482);\nvar FacetSort_1 = __webpack_require__(483);\nvar FacetUtils_1 = __webpack_require__(40);\nvar FacetValueElement_1 = __webpack_require__(131);\nvar FacetValue_1 = __webpack_require__(118);\nvar FacetValues_1 = __webpack_require__(559);\nvar FacetValuesList_1 = __webpack_require__(489);\nvar FacetValuesOrder_1 = __webpack_require__(478);\nvar OmniboxValueElement_1 = __webpack_require__(490);\nvar OmniboxValuesList_1 = __webpack_require__(491);\nvar ValueElementRenderer_1 = __webpack_require__(477);\n/**\n * The `Facet` component displays a *facet* of the results for the current query. A facet is a list of values for a\n * certain field occurring in the results, ordered using a configurable criteria (e.g., number of occurrences).\n *\n * The list of values is obtained using a [`GroupByRequest`]{@link IGroupByRequest} operation performed at the same time\n * as the main query.\n *\n * The `Facet` component allows the end user to drill down inside a result set by restricting the result to certain\n * field values. It also allows filtering out values from the facet itself, and can provide a search box to look for\n * specific values inside larger sets.\n *\n * This is probably the most complex component in the Coveo JavaScript Search Framework and as such, it allows for many\n * configuration options.\n *\n * See also the [`FacetRange`]{@link FacetRange} and [`TimespanFacet`]{@link TimespanFacet} components (which\n * extend this component), and the [`FacetSlider`]{@link FacetSlider} and [`CategoryFacet`]{@link CategoryFacet} components (which do not extend this\n * component, but are very similar).\n */\nvar Facet = /** @class */ (function (_super) {\n __extends(Facet, _super);\n /**\n * Creates a new `Facet` component. Binds multiple query events as well.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `Facet` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param facetClassId The ID to use for this facet (as `Facet` inherited from by other component\n * (e.g., [`FacetRange`]{@link FacetRange}). Default value is `Facet`.\n */\n function Facet(element, options, bindings, facetClassId) {\n if (facetClassId === void 0) { facetClassId = Facet.ID; }\n var _this = _super.call(this, element, facetClassId, bindings) || this;\n _this.element = element;\n _this.options = options;\n _this.keepDisplayedValuesNextTime = false;\n _this.values = new FacetValues_1.FacetValues();\n _this.currentPage = 0;\n _this.firstQuery = true;\n _this.isFieldValueCompatible = true;\n _this.isFieldValueHierarchical = false;\n _this.canFetchMore = true;\n _this.showingWaitAnimation = false;\n _this.listenToQueryStateChange = true;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, Facet, options);\n if (_this.options.valueCaption != null) {\n _this.options.availableSorts = _.filter(_this.options.availableSorts, function (sort) { return !/^alpha.*$/.test(sort); });\n _this.logger.warn(\"Because the \" + _this.options.field + \" facet is using value captions, alphabetical sorts are disabled.\");\n }\n ResponsiveFacets_1.ResponsiveFacets.init(_this.root, _this, _this.options);\n // Serves as a way to render facet in the omnibox in the order in which they are instantiated\n _this.omniboxZIndex = Facet.omniboxIndex;\n Facet.omniboxIndex--;\n _this.checkForComputedFieldAndSort();\n _this.checkForValueCaptionType();\n _this.checkForCustomSort();\n _this.initDependsOnManager();\n _this.initFacetQueryController();\n _this.initQueryEvents();\n _this.initQueryStateEvents();\n _this.initComponentStateEvents();\n _this.initOmniboxEvents();\n _this.initBreadCrumbEvents();\n _this.initSearchAlertEvents();\n _this.updateNumberOfValues();\n _this.bind.oneRootElement(QueryEvents_1.QueryEvents.querySuccess, function () {\n _this.firstQuery = false;\n });\n return _this;\n }\n Facet.prototype.setExpandedFacetSearchAccessibilityAttributes = function (searchResultsElement) {\n if (!this.searchContainer) {\n return;\n }\n Assert_1.Assert.exists(searchResultsElement);\n var accessibleElement = this.searchContainer.accessibleElement;\n accessibleElement.setAttribute('aria-expanded', true.toString());\n };\n Facet.prototype.setCollapsedFacetSearchAccessibilityAttributes = function () {\n if (!this.searchContainer) {\n return;\n }\n this.searchContainer.accessibleElement.setAttribute('aria-expanded', false.toString());\n };\n Facet.prototype.isCurrentlyDisplayed = function () {\n if (!Dom_1.$$(this.element).isVisible()) {\n return false;\n }\n if (Dom_1.$$(this.element).hasClass('coveo-active')) {\n return true;\n }\n if (Dom_1.$$(this.element).hasClass('coveo-facet-empty')) {\n return false;\n }\n return true;\n };\n Facet.prototype.createDom = function () {\n var _this = this;\n this.initBottomAndTopSpacer();\n this.buildFacetContent();\n this.updateAppearanceDependingOnState();\n // After the facet has been created (and before the first query is applied)\n // Try to load a state from the setting, if it's available\n // Execute only _.once (only the first query, or the first time the user switch to a tab that contains a newly set of active facet)\n if (this.facetSettings && this.options.enableSettingsFacetState) {\n var loadOnce = _.once(function () {\n _this.facetSettings.loadSavedState.apply(_this.facetSettings);\n });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.newQuery, loadOnce);\n }\n };\n /**\n * Selects a single value.\n *\n * Does not trigger a query automatically.\n *\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string (e.g., `selectValue('foobar')` or\n * `selectValue(new FacetValue('foobar'))`).\n */\n Facet.prototype.selectValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Selecting facet value', this.facetValuesList.select(value));\n this.facetValueHasChanged();\n };\n /**\n * Selects multiple values.\n *\n * Does not trigger a query automatically.\n *\n * @param values Can be an array of [`FacetValue`]{@link FacetValue} or an array of strings.\n */\n Facet.prototype.selectMultipleValues = function (values) {\n var _this = this;\n Assert_1.Assert.exists(values);\n this.ensureDom();\n _.each(values, function (value) {\n _this.logger.info('Selecting facet value', _this.facetValuesList.select(value));\n });\n this.facetValueHasChanged();\n };\n /**\n * Deselects a single value.\n *\n * Does not trigger a query automatically.\n *\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string (e.g., `deselectValue('foobar')` or\n * `deselectValue(new FacetValue('foobar'))`).\n */\n Facet.prototype.deselectValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Deselecting facet value', this.facetValuesList.unselect(value));\n this.facetValueHasChanged();\n };\n /**\n * Deselects multiple values.\n *\n * Does not trigger a query automatically.\n *\n * @param values Can be an array of [`FacetValue`]{@link FacetValue} or an array of strings.\n */\n Facet.prototype.deselectMultipleValues = function (values) {\n var _this = this;\n Assert_1.Assert.exists(values);\n this.ensureDom();\n _.each(values, function (value) {\n _this.logger.info('Deselecting facet value', _this.facetValuesList.unselect(value));\n });\n this.facetValueHasChanged();\n };\n /**\n * Excludes a single value.\n *\n * Does not trigger a query automatically.\n *\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string (e.g., `excludeValue('foobar')` or\n * `excludeValue(new FacetValue('foobar'))`).\n */\n Facet.prototype.excludeValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Excluding facet value', this.facetValuesList.exclude(value));\n this.facetValueHasChanged();\n };\n /**\n * Excludes multiple values.\n *\n * Does not trigger a query automatically.\n *\n * @param values Can be an array of [`FacetValue`]{@link FacetValue} or an array of strings.\n */\n Facet.prototype.excludeMultipleValues = function (values) {\n var _this = this;\n Assert_1.Assert.exists(values);\n this.ensureDom();\n _.each(values, function (value) {\n _this.logger.info('Excluding facet value', _this.facetValuesList.exclude(value));\n });\n this.facetValueHasChanged();\n };\n /**\n * Unexcludes a single value.\n *\n * Does not trigger a query automatically.\n *\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string.\n */\n Facet.prototype.unexcludeValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Unexcluding facet value', this.facetValuesList.unExclude(value));\n this.facetValueHasChanged();\n };\n /**\n * Unexcludes multiple values.\n *\n * Does not trigger a query automatically.\n *\n * @param values Can be an array of [`FacetValue`]{@link FacetValue} or an array of strings.\n */\n Facet.prototype.unexcludeMultipleValues = function (values) {\n var _this = this;\n Assert_1.Assert.exists(values);\n this.ensureDom();\n _.each(values, function (value) {\n _this.logger.info('Unexcluding facet value', _this.facetValuesList.unExclude(value));\n });\n this.facetValueHasChanged();\n };\n /**\n * Toggles the selection state of a single value (selects the value if it is not already selected; un-selects the\n * value if it is already selected).\n *\n * Does not trigger a query automatically.\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string.\n */\n Facet.prototype.toggleSelectValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Toggle select facet value', this.facetValuesList.toggleSelect(value));\n this.facetValueHasChanged();\n };\n /**\n * Toggles the exclusion state of a single value (excludes the value if it is not already excluded; un-excludes the\n * value if it is already excluded).\n *\n * Does not trigger a query automatically.\n *\n * @param value Can be a [`FacetValue`]{@link FacetValue} or a string.\n */\n Facet.prototype.toggleExcludeValue = function (value) {\n Assert_1.Assert.exists(value);\n this.ensureDom();\n this.logger.info('Toggle exclude facet value', this.facetValuesList.toggleExclude(value));\n this.facetValueHasChanged();\n };\n /**\n * Returns the currently displayed values as an array of strings.\n *\n * @returns {any[]} The currently displayed values.\n */\n Facet.prototype.getDisplayedValues = function () {\n return _.pluck(this.getDisplayedFacetValues(), 'value');\n };\n /**\n * Returns the currently displayed values as an array of [`FacetValue`]{@link FacetValue}.\n *\n * @returns {T[]} The currently displayed values.\n */\n Facet.prototype.getDisplayedFacetValues = function () {\n this.ensureDom();\n var displayed = this.facetValuesList.getAllCurrentlyDisplayed();\n return _.map(displayed, function (value) {\n return value.facetValue;\n });\n };\n /**\n * Returns the currently selected values as an array of strings.\n * @returns {string[]} The currently selected values.\n */\n Facet.prototype.getSelectedValues = function () {\n this.ensureDom();\n return _.map(this.values.getSelected(), function (value) { return value.value; });\n };\n /**\n * Determines whether the specified value is selected in the facet.\n * @param value The name of the facet value to verify.\n */\n Facet.prototype.hasSelectedValue = function (value) {\n var facetValue = this.values.get(value);\n return facetValue && facetValue.selected;\n };\n /**\n * Returns the currently excluded values as an array of strings.\n * @returns {string[]} The currently excluded values.\n */\n Facet.prototype.getExcludedValues = function () {\n this.ensureDom();\n return _.map(this.values.getExcluded(), function (value) { return value.value; });\n };\n /**\n * Resets the facet by un-selecting all values, un-excluding all values, and redrawing the facet.\n */\n Facet.prototype.reset = function () {\n this.ensureDom();\n this.values.reset();\n this.rebuildValueElements();\n this.updateAppearanceDependingOnState();\n this.updateQueryStateModel();\n };\n /**\n * Switches the facet to `AND` mode.\n *\n * See the [`useAnd`]{@link Facet.options.useAnd}, and\n * [`enableTogglingOperator`]{@link Facet.options.enableTogglingOperator} options.\n */\n Facet.prototype.switchToAnd = function () {\n this.ensureDom();\n this.logger.info('Switching to AND');\n this.facetHeader.switchToAnd();\n };\n /**\n * Switches the facet to `OR` mode.\n *\n * See the [`useAnd`]{@link Facet.options.useAnd}, and\n * [`enableTogglingOperator`]{@link Facet.options.enableTogglingOperator} options.\n */\n Facet.prototype.switchToOr = function () {\n this.ensureDom();\n this.logger.info('Switching to OR');\n this.facetHeader.switchToOr();\n };\n /**\n * Returns the endpoint for the facet.\n * @returns {ISearchEndpoint} The endpoint for the facet.\n */\n Facet.prototype.getEndpoint = function () {\n return this.queryController.getEndpoint();\n };\n /**\n * Changes the sort parameter for the facet.\n *\n * See {@link Facet.options.availableSorts} for the list of possible values.\n *\n * Also triggers a new query.\n *\n * @param criteria The new sort parameter for the facet.\n */\n Facet.prototype.updateSort = function (criteria) {\n this.ensureDom();\n if (this.options.sortCriteria != criteria) {\n this.options.sortCriteria = criteria;\n this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetUpdateSort, {\n criteria: criteria,\n facetId: this.options.id,\n facetField: this.options.field.toString(),\n facetTitle: this.options.title\n }, this.element);\n this.triggerNewQuery();\n }\n };\n Facet.prototype.unfadeInactiveValuesInMainList = function () {\n Dom_1.$$(this.element).removeClass('coveo-facet-fade');\n };\n Facet.prototype.fadeInactiveValuesInMainList = function (delay) {\n Dom_1.$$(this.element).addClass('coveo-facet-fade');\n };\n /**\n * Shows a waiting animation in the facet header (a spinner).\n */\n Facet.prototype.showWaitingAnimation = function () {\n this.ensureDom();\n if (!this.showingWaitAnimation) {\n Dom_1.$$(this.headerElement).find('.coveo-facet-header-wait-animation').style.visibility = 'visible';\n this.showingWaitAnimation = true;\n }\n };\n /**\n * Hides the waiting animation in the facet header.\n */\n Facet.prototype.hideWaitingAnimation = function () {\n this.ensureDom();\n if (this.showingWaitAnimation) {\n Dom_1.$$(this.headerElement).find('.coveo-facet-header-wait-animation').style.visibility = 'hidden';\n this.showingWaitAnimation = false;\n }\n };\n Facet.prototype.processFacetSearchAllResultsSelected = function (facetValues) {\n var _this = this;\n var valuesForAnalytics = [];\n _.each(facetValues, function (facetValue) {\n _this.ensureFacetValueIsInList(facetValue);\n valuesForAnalytics.push(facetValue.value);\n });\n // Calculate the correct number of values from the current selected/excluded values (those will stay no matter what next rendering)\n // add the new one that will be selected (and are not already selected in the facet)\n // The minimum number of values is the number of values set in the option\n var valuesThatStays = this.values.getSelected().concat(this.values.getExcluded());\n this.numberOfValues = valuesThatStays.length + _.difference(valuesThatStays, facetValues).length;\n this.numberOfValues = Math.max(this.numberOfValues, this.options.numberOfValues);\n this.updateQueryStateModel();\n this.triggerNewQuery(function () {\n return _this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.facetSelectAll, {\n facetId: _this.options.id,\n facetField: _this.options.field.toString(),\n facetTitle: _this.options.title\n });\n });\n };\n Facet.prototype.pinFacetPosition = function () {\n if (this.options.preservePosition) {\n this.pinnedViewportPosition = this.element.getBoundingClientRect().top;\n }\n };\n /**\n * Returns the configured caption for the given [`FacetValue`]{@link FacetValue}.\n *\n * @param facetValue The `FacetValue` whose caption the method should return.\n */\n Facet.prototype.getValueCaption = function (facetValue) {\n Assert_1.Assert.exists(facetValue);\n var lookupValue = typeof facetValue === 'string' ? facetValue : facetValue.lookupValue || facetValue.value;\n var ret = FacetUtils_1.FacetUtils.tryToGetTranslatedCaption(this.options.field, lookupValue);\n if (Utils_1.Utils.exists(this.options.valueCaption)) {\n if (typeof this.options.valueCaption == 'object') {\n ret = this.options.valueCaption[lookupValue] || ret;\n }\n if (typeof this.options.valueCaption == 'function') {\n var fv = facetValue instanceof FacetValue_1.FacetValue ? facetValue : FacetValue_1.FacetValue.create(facetValue);\n var valueFromList = this.facetValuesList.get(fv).facetValue;\n ret = this.options.valueCaption.call(this, valueFromList);\n }\n }\n return ret;\n };\n /**\n * Returns the configured caption for a desired facet value.\n *\n * @param value The string facet value whose caption the method should return.\n */\n Facet.prototype.getCaptionForStringValue = function (value) {\n Assert_1.Assert.exists(value);\n return this.getValueCaption(value);\n };\n /**\n * Shows the next page of results in the facet.\n *\n * See the [`enableMoreLess`]{@link Facet.options.enableMoreLess}, and [`pageSize`]{@link Facet.options.pageSize}\n * options.\n *\n * Triggers a query if needed, or displays the already available values.\n */\n Facet.prototype.showMore = function () {\n this.currentPage = Math.floor((this.numberOfValues - this.options.numberOfValues) / this.options.pageSize) + 1;\n this.updateNumberOfValues();\n if (this.nbAvailableValues >= this.numberOfValues || !this.canFetchMore) {\n this.rebuildValueElements();\n }\n else {\n this.triggerMoreQuery();\n }\n };\n /**\n * Shows less elements in the Facet (up to the original number of values).\n *\n * See the [`enableMoreLess`]{@link Facet.options.enableMoreLess}, and\n * [`numberOfValues`]{@link Facet.options.numberOfValues} options.\n */\n Facet.prototype.showLess = function () {\n Dom_1.$$(this.lessElement).removeClass('coveo-active');\n this.currentPage = 0;\n this.updateNumberOfValues();\n Dom_1.$$(this.moreElement).addClass('coveo-active');\n this.values.sortValuesDependingOnStatus(this.numberOfValues);\n this.rebuildValueElements();\n this.logAnalyticsFacetShowMoreLess(AnalyticsActionListMeta_1.analyticsActionCauseList.facetShowLess);\n };\n /**\n * Collapses the facet.\n */\n Facet.prototype.collapse = function () {\n this.ensureDom();\n if (this.facetHeader) {\n this.facetHeader.collapseFacet();\n }\n };\n /**\n * Expands the facet.\n */\n Facet.prototype.expand = function () {\n this.ensureDom();\n if (this.facetHeader) {\n this.facetHeader.expandFacet();\n }\n };\n Facet.prototype.triggerNewQuery = function (beforeExecuteQuery) {\n if (!beforeExecuteQuery) {\n this.queryController.executeQuery({ ignoreWarningSearchEvent: true });\n }\n else {\n this.queryController.executeQuery({ beforeExecuteQuery: beforeExecuteQuery });\n }\n this.showWaitingAnimation();\n };\n Facet.prototype.handleDeferredQuerySuccess = function (data) {\n Assert_1.Assert.exists(data);\n this.unfadeInactiveValuesInMainList();\n this.hideWaitingAnimation();\n var groupByResult = data.results.groupByResults[this.facetQueryController.lastGroupByRequestIndex];\n this.facetQueryController.lastGroupByResult = groupByResult;\n // Two corner case to handle regarding the \"sticky\" aspect of facets :\n // 1) The group by is empty (so there is nothing to \"sticky\")\n // 2) There is only one value displayed currently, so there is nothing to \"sticky\" either\n if (!groupByResult) {\n this.keepDisplayedValuesNextTime = false;\n }\n if (this.values.getAll().length == 1) {\n this.keepDisplayedValuesNextTime = false;\n }\n this.processNewGroupByResults(groupByResult);\n };\n Facet.prototype.handleQueryError = function () {\n this.updateValues(new FacetValues_1.FacetValues());\n this.updateAppearanceDependingOnState();\n this.hideWaitingAnimation();\n };\n Facet.prototype.handlePopulateBreadcrumb = function (args) {\n Assert_1.Assert.exists(args);\n if (this.values.hasSelectedOrExcludedValues()) {\n var element = new BreadcrumbValuesList_1.BreadcrumbValueList(this, this.values.getSelected().concat(this.values.getExcluded()), BreadcrumbValueElement_1.BreadcrumbValueElement, {\n headingLevel: args.headingLevel\n }).build();\n args.breadcrumbs.push({ element: element });\n }\n };\n Facet.prototype.handlePopulateSearchAlerts = function (args) {\n if (this.values.hasSelectedOrExcludedValues()) {\n var excludedValues = this.values.getExcluded();\n var selectedValues = this.values.getSelected();\n if (!_.isEmpty(excludedValues)) {\n args.text.push({\n value: new BreadcrumbValuesList_1.BreadcrumbValueList(this, excludedValues, BreadcrumbValueElement_1.BreadcrumbValueElement).buildAsString(),\n lineThrough: true\n });\n }\n if (!_.isEmpty(selectedValues)) {\n args.text.push({\n value: new BreadcrumbValuesList_1.BreadcrumbValueList(this, selectedValues, BreadcrumbValueElement_1.BreadcrumbValueElement).buildAsString(),\n lineThrough: false\n });\n }\n }\n };\n Facet.prototype.initFacetQueryController = function () {\n this.facetQueryController = new FacetQueryController_1.FacetQueryController(this);\n };\n Facet.prototype.initFacetValuesList = function () {\n this.facetValuesList = new FacetValuesList_1.FacetValuesList(this, FacetValueElement_1.FacetValueElement);\n this.element.appendChild(this.facetValuesList.build());\n };\n Facet.prototype.initFacetSearch = function () {\n this.facetSearch = new FacetSearch_1.FacetSearch(this, FacetSearchValuesList_1.FacetSearchValuesList, this.root);\n this.element.appendChild(this.facetSearch.build());\n };\n Facet.prototype.facetValueHasChanged = function () {\n var _this = this;\n this.updateQueryStateModel();\n this.rebuildValueElements();\n Defer_1.Defer.defer(function () {\n _this.updateAppearanceDependingOnState();\n });\n };\n Facet.prototype.updateAppearanceDependingOnState = function () {\n Dom_1.$$(this.element).toggleClass('coveo-active', this.values.hasSelectedOrExcludedValues());\n Dom_1.$$(this.element).toggleClass('coveo-facet-empty', !this.isAnyValueCurrentlyDisplayed());\n Dom_1.$$(this.facetHeader.eraserElement).toggleClass('coveo-facet-header-eraser-visible', this.values.hasSelectedOrExcludedValues());\n };\n Facet.prototype.initQueryEvents = function () {\n var _this = this;\n this.bind.onRootElement(QueryEvents_1.QueryEvents.duringQuery, function () { return _this.handleDuringQuery(); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.doneBuildingQuery, function (args) { return _this.handleDoneBuildingQuery(args); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.deferredQuerySuccess, function (args) { return _this.handleDeferredQuerySuccess(args); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function () { return _this.handleQueryError(); });\n };\n Facet.prototype.initQueryStateEvents = function () {\n var _this = this;\n this.includedAttributeId = QueryStateModel_1.QueryStateModel.getFacetId(this.options.id);\n this.excludedAttributeId = QueryStateModel_1.QueryStateModel.getFacetId(this.options.id, false);\n this.operatorAttributeId = QueryStateModel_1.QueryStateModel.getFacetOperator(this.options.id);\n this.lookupValueAttributeId = QueryStateModel_1.QueryStateModel.getFacetLookupValue(this.options.id);\n this.queryStateModel.registerNewAttribute(this.includedAttributeId, []);\n this.queryStateModel.registerNewAttribute(this.excludedAttributeId, []);\n this.queryStateModel.registerNewAttribute(this.operatorAttributeId, '');\n this.queryStateModel.registerNewAttribute(this.lookupValueAttributeId, {});\n this.bind.onQueryState(Model_1.MODEL_EVENTS.CHANGE, undefined, function (args) { return _this.handleQueryStateChanged(args); });\n };\n Facet.prototype.initComponentStateEvents = function () {\n this.componentStateId = QueryStateModel_1.QueryStateModel.getFacetId(this.options.id);\n this.componentStateModel.registerComponent(this.componentStateId, this);\n };\n Facet.prototype.initOmniboxEvents = function () {\n var _this = this;\n if (this.options.includeInOmnibox) {\n this.bind.onRootElement(OmniboxEvents_1.OmniboxEvents.populateOmnibox, function (args) { return _this.handlePopulateOmnibox(args); });\n }\n };\n Facet.prototype.initBreadCrumbEvents = function () {\n var _this = this;\n if (this.options.includeInBreadcrumb) {\n this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.populateBreadcrumb, function (args) {\n return _this.handlePopulateBreadcrumb(args);\n });\n this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.clearBreadcrumb, function (args) { return _this.handleClearBreadcrumb(); });\n }\n };\n Facet.prototype.initSearchAlertEvents = function () {\n var _this = this;\n this.bind.onRootElement(SearchAlertEvents_1.SearchAlertsEvents.searchAlertsPopulateMessage, function (args) {\n return _this.handlePopulateSearchAlerts(args);\n });\n };\n Facet.prototype.handleOmniboxWithStaticValue = function (eventArg) {\n var _this = this;\n var regex = new RegExp('^' + eventArg.completeQueryExpression.regex.source, 'i');\n var match = _.first(_.filter(this.getDisplayedValues(), function (displayedValue) {\n var value = _this.getValueCaption(_this.facetValuesList.get(displayedValue).facetValue);\n return regex.test(value);\n }), this.options.numberOfValuesInOmnibox);\n var facetValues = _.map(match, function (gotAMatch) {\n return _this.facetValuesList.get(gotAMatch).facetValue;\n });\n var element = new OmniboxValuesList_1.OmniboxValuesList(this, facetValues, eventArg, OmniboxValueElement_1.OmniboxValueElement).build();\n eventArg.rows.push({ element: element, zIndex: this.omniboxZIndex });\n };\n Facet.prototype.processNewGroupByResults = function (groupByResult) {\n this.logger.trace('Displaying group by results', groupByResult);\n if (groupByResult != undefined && groupByResult.values != undefined) {\n this.nbAvailableValues = groupByResult.values.length;\n }\n var newFacetValues = new FacetValues_1.FacetValues(groupByResult);\n this.updateValues(newFacetValues);\n this.canFetchMore = this.numberOfValues < this.nbAvailableValues;\n if (this.values.hasSelectedOrExcludedValues() && !this.options.useAnd && this.options.isMultiValueField) {\n this.triggerUpdateDeltaQuery(_.filter(this.values.getAll(), function (facetValue) {\n return !facetValue.selected && !facetValue.excluded;\n }));\n }\n else if (this.values.getSelected().length > 0 && !this.options.useAnd) {\n this.values.updateDeltaWithFilteredFacetValues(new FacetValues_1.FacetValues(), this.options.isMultiValueField);\n }\n if (!this.values.hasSelectedOrExcludedValues() || this.options.useAnd || !this.options.isMultiValueField) {\n this.rebuildValueElements();\n this.updateAppearanceDependingOnState();\n this.ensurePinnedFacetHasntMoved();\n }\n this.keepDisplayedValuesNextTime = false;\n };\n Facet.prototype.updateQueryStateModel = function () {\n this.listenToQueryStateChange = false;\n this.updateExcludedQueryStateModel();\n this.updateIncludedQueryStateModel();\n this.facetHeader.updateOperatorQueryStateModel();\n this.updateLookupValueQueryStateModel();\n this.listenToQueryStateChange = true;\n };\n Facet.prototype.rebuildValueElements = function () {\n this.updateNumberOfValues();\n this.facetValuesList.rebuild(this.numberOfValues);\n if (this.shouldRenderMoreLess()) {\n this.updateMoreLess();\n if (this.shouldRenderFacetSearch()) {\n this.updateSearchElement(this.nbAvailableValues > this.numberOfValues);\n }\n }\n else if (this.shouldRenderFacetSearch()) {\n this.updateSearchElement();\n }\n };\n Facet.prototype.updateSearchElement = function (moreValuesAvailable) {\n var _this = this;\n if (moreValuesAvailable === void 0) { moreValuesAvailable = true; }\n if (!moreValuesAvailable) {\n return;\n }\n var renderer = new ValueElementRenderer_1.ValueElementRenderer(this, FacetValue_1.FacetValue.create(Strings_1.l('Search')));\n this.searchContainer = renderer.build().withNo([renderer.excludeIcon, renderer.icon]);\n Dom_1.$$(this.searchContainer.listItem).addClass('coveo-facet-search-button');\n new AccessibleButton_1.AccessibleButton()\n .withElement(this.searchContainer.accessibleElement)\n .withLabel(Strings_1.l('SearchFacetResults', this.options.title))\n .withEnterKeyboardAction(function (e) { return _this.toggleSearchMenu(e); })\n .build();\n this.setCollapsedFacetSearchAccessibilityAttributes();\n // Mobile do not like label. Use click event\n if (DeviceUtils_1.DeviceUtils.isMobileDevice()) {\n Dom_1.$$(this.searchContainer.label).on('click', function (e) { return _this.toggleSearchMenu(e); });\n }\n Dom_1.$$(this.searchContainer.checkbox).on('change', function () {\n Dom_1.$$(_this.element).addClass('coveo-facet-searching');\n _this.facetSearch.focus();\n });\n this.facetValuesList.valueContainer.appendChild(this.searchContainer.listItem);\n };\n Facet.prototype.updateMoreLess = function (lessElementIsShown, moreValuesAvailable) {\n if (lessElementIsShown === void 0) { lessElementIsShown = this.getMinimumNumberOfValuesToDisplay() < this.numberOfValues; }\n if (moreValuesAvailable === void 0) { moreValuesAvailable = this.nbAvailableValues > this.numberOfValues; }\n if (lessElementIsShown) {\n Dom_1.$$(this.lessElement).addClass('coveo-active');\n }\n else {\n Dom_1.$$(this.lessElement).removeClass('coveo-active');\n }\n if (moreValuesAvailable) {\n Dom_1.$$(this.moreElement).addClass('coveo-active');\n }\n else {\n Dom_1.$$(this.moreElement).removeClass('coveo-active');\n }\n if (lessElementIsShown || moreValuesAvailable) {\n Dom_1.$$(this.footerElement).removeClass('coveo-facet-empty');\n }\n else {\n Dom_1.$$(this.footerElement).addClass('coveo-facet-empty');\n }\n };\n Facet.prototype.handleClickMore = function () {\n this.showMore();\n };\n Facet.prototype.handleClickLess = function () {\n this.showLess();\n };\n Facet.prototype.toggleSearchMenu = function (e) {\n var searchButton = this.searchContainer;\n if (searchButton.checkbox.getAttribute('checked')) {\n searchButton.checkbox.removeAttribute('checked');\n }\n else {\n searchButton.checkbox.setAttribute('checked', 'checked');\n }\n Dom_1.$$(searchButton.checkbox).trigger('change');\n e.stopPropagation();\n e.preventDefault();\n };\n Facet.prototype.checkForComputedFieldAndSort = function () {\n if (this.options.sortCriteria.toLowerCase().indexOf('computedfield') != -1 && Utils_1.Utils.isNullOrUndefined(this.options.computedField)) {\n this.logger.warn('Sort criteria is specified as ComputedField, but the facet uses no computed field. Facet will always be empty !', this);\n }\n };\n Facet.prototype.checkForValueCaptionType = function () {\n if (this.options.valueCaption && typeof this.options.valueCaption == 'function') {\n this.options.enableFacetSearch = false;\n this.options.includeInOmnibox = false;\n this.logger.warn('Using a function as valueCaption is now deprecated. Use a json key value pair instead. Facet search and omnibox has been disabled for this facet', this);\n }\n };\n Facet.prototype.checkForCustomSort = function () {\n if (this.options.customSort != undefined && !_.contains(this.options.availableSorts, 'custom')) {\n this.options.availableSorts.unshift('custom');\n }\n if (this.options.availableSorts[0] == 'custom') {\n this.options.sortCriteria = 'nosort';\n }\n };\n Facet.prototype.initDependsOnManager = function () {\n var _this = this;\n var facetInfo = {\n reset: function () { return _this.reset(); },\n ref: this\n };\n this.dependsOnManager = new DependsOnManager_1.DependsOnManager(facetInfo);\n };\n Facet.prototype.dependsOnUpdateParentDisplayValue = function () {\n var _this = this;\n if (!this.options.dependsOn) {\n return;\n }\n var masterFacetComponent = ComponentsTypes_1.ComponentsTypes.getAllFacetInstancesFromElement(this.root).filter(function (cmp) {\n var idFacet = cmp instanceof Facet;\n return idFacet && cmp.options.id === _this.options.dependsOn;\n });\n if (!masterFacetComponent.length) {\n this.logger.warn(\"Unable to find a Facet with the id or field \\\"\" + this.options.dependsOn + \"\\\".\", \"The master facet values can't be updated.\");\n return;\n }\n if (masterFacetComponent.length > 1) {\n this.logger.warn(\"Multiple facets with id \\\"\" + this.options.dependsOn + \"\\\" found.\", \"A given facet may only depend on a single other facet.\", \"Ensure that each facet in your search interface has a unique id.\", \"The master facet cannot be updated.\", masterFacetComponent);\n return;\n }\n var masterFacet = masterFacetComponent[0];\n masterFacet.keepDisplayedValuesNextTime = false;\n };\n Facet.prototype.initBottomAndTopSpacer = function () {\n var _this = this;\n var bottomSpace = Dom_1.$$(this.options.paddingContainer).find('.coveo-bottomSpace');\n var topSpace = Dom_1.$$(this.options.paddingContainer).find('.coveo-topSpace');\n if (this.options.preservePosition) {\n Dom_1.$$(this.options.paddingContainer).on('mouseleave', function () { return _this.unpinFacetPosition(); });\n this.pinnedTopSpace = topSpace;\n this.pinnedBottomSpace = bottomSpace;\n if (!this.pinnedTopSpace) {\n this.pinnedTopSpace = document.createElement('div');\n Dom_1.$$(this.pinnedTopSpace).addClass('coveo-topSpace');\n Dom_1.$$(this.pinnedTopSpace).insertBefore(this.options.paddingContainer.firstChild);\n }\n if (!this.pinnedBottomSpace) {\n this.pinnedBottomSpace = document.createElement('div');\n Dom_1.$$(this.pinnedBottomSpace).addClass('coveo-bottomSpace');\n this.options.paddingContainer.appendChild(this.pinnedBottomSpace);\n }\n }\n };\n Facet.prototype.updateIncludedQueryStateModel = function () {\n var selectedValues = { included: this.getSelectedValues(), title: this.includedAttributeId };\n this.queryStateModel.set(this.includedAttributeId, selectedValues.included);\n };\n Facet.prototype.updateExcludedQueryStateModel = function () {\n var excludedValues = { title: this.excludedAttributeId, excluded: this.getExcludedValues() };\n this.queryStateModel.set(this.excludedAttributeId, excludedValues.excluded);\n };\n Facet.prototype.updateLookupValueQueryStateModel = function () {\n if (this.options.lookupField) {\n var valueToSet_1 = {};\n _.each(this.values.getSelected().concat(this.values.getExcluded()), function (value) {\n valueToSet_1[value.value] = value.lookupValue;\n });\n this.queryStateModel.set(this.lookupValueAttributeId, valueToSet_1);\n }\n };\n Facet.prototype.handleQueryStateChangedOperator = function (operator) {\n if (operator == 'and') {\n this.switchToAnd();\n }\n else if (operator == 'or') {\n this.switchToOr();\n }\n };\n Facet.prototype.handleQueryStateChangedIncluded = function (includedChanged) {\n var toUnSelect = _.difference(this.getSelectedValues(), includedChanged);\n if (Utils_1.Utils.isNonEmptyArray(toUnSelect)) {\n this.deselectMultipleValues(toUnSelect);\n }\n if (!Utils_1.Utils.arrayEqual(this.getSelectedValues(), includedChanged, false)) {\n this.selectMultipleValues(includedChanged);\n }\n };\n Facet.prototype.handleQueryStateChangedExcluded = function (excludedChanged) {\n var toUnExclude = _.difference(this.getExcludedValues(), excludedChanged);\n if (Utils_1.Utils.isNonEmptyArray(toUnExclude)) {\n this.unexcludeMultipleValues(toUnExclude);\n }\n if (!Utils_1.Utils.arrayEqual(this.getExcludedValues(), excludedChanged, false)) {\n this.excludeMultipleValues(excludedChanged);\n }\n };\n Facet.prototype.handleLookupvalueChanged = function (lookupFieldChanged) {\n var _this = this;\n _.each(lookupFieldChanged, function (lookupvalue, value) {\n _this.facetValuesList.get(decodeURIComponent(value)).facetValue.lookupValue = decodeURIComponent(lookupvalue);\n });\n };\n Facet.prototype.handleQueryStateChanged = function (data) {\n Assert_1.Assert.exists(data);\n this.ensureDom();\n this.dependsOnUpdateParentDisplayValue();\n var trimValuesFromModel = function (values) {\n if (values) {\n values = _.map(values, function (value) { return value.trim(); });\n }\n return values;\n };\n var queryStateAttributes = data.attributes;\n var includedChanged = trimValuesFromModel(queryStateAttributes[this.includedAttributeId]);\n var excludedChanged = trimValuesFromModel(queryStateAttributes[this.excludedAttributeId]);\n var operator = queryStateAttributes[this.operatorAttributeId];\n var lookupValueChanged = queryStateAttributes[this.lookupValueAttributeId];\n if (this.listenToQueryStateChange) {\n if (!Utils_1.Utils.isNullOrEmptyString(operator)) {\n this.handleQueryStateChangedOperator(operator);\n }\n if (!Utils_1.Utils.isNullOrUndefined(includedChanged)) {\n this.handleQueryStateChangedIncluded(includedChanged);\n }\n if (!Utils_1.Utils.isNullOrUndefined(excludedChanged)) {\n this.handleQueryStateChangedExcluded(excludedChanged);\n }\n if (!Utils_1.Utils.isNullOrUndefined(lookupValueChanged)) {\n this.handleLookupvalueChanged(lookupValueChanged);\n }\n }\n };\n Facet.prototype.handlePopulateOmnibox = function (data) {\n Assert_1.Assert.exists(data);\n Assert_1.Assert.exists(data.completeQueryExpression);\n // The omnibox calls can come in before a first query was executed (atypical, but\n // if no query is auto-triggered on initialization). To ensure that we've got the\n // proper filters, we ensure that at least a dumbshow query builder run occured\n // before proceeding.\n this.queryController.ensureCreatedQueryBuilder();\n if (this.canFetchMore) {\n this.handleOmniboxWithSearchInFacet(data);\n }\n else {\n this.handleOmniboxWithStaticValue(data);\n }\n };\n Facet.prototype.handleOmniboxWithSearchInFacet = function (eventArg) {\n var _this = this;\n var regex = new RegExp('^' + eventArg.completeQueryExpression.regex.source, 'i');\n var promise = new Promise(function (resolve, reject) {\n var searchParameters = new FacetSearchParameters_1.FacetSearchParameters(_this);\n searchParameters.setValueToSearch(eventArg.completeQueryExpression.word);\n searchParameters.nbResults = _this.options.numberOfValuesInOmnibox;\n _this.facetQueryController\n .search(searchParameters)\n .then(function (fieldValues) {\n var facetValues = _.map(_.filter(fieldValues, function (fieldValue) {\n return regex.test(fieldValue.lookupValue);\n }), function (fieldValue) {\n return _this.values.get(fieldValue.lookupValue) || FacetValue_1.FacetValue.create(fieldValue);\n });\n var element = new OmniboxValuesList_1.OmniboxValuesList(_this, facetValues, eventArg, OmniboxValueElement_1.OmniboxValueElement).build();\n resolve({ element: element, zIndex: _this.omniboxZIndex });\n })\n .catch(function () {\n resolve({ element: undefined });\n });\n });\n eventArg.rows.push({ deferred: promise });\n };\n Facet.prototype.handleDuringQuery = function () {\n this.ensureDom();\n if (!this.keepDisplayedValuesNextTime) {\n this.fadeInactiveValuesInMainList(this.options.facetSearchDelay);\n }\n };\n Facet.prototype.handleBuildingQuery = function (data) {\n Assert_1.Assert.exists(data);\n Assert_1.Assert.exists(data.queryBuilder);\n this.facetQueryController.prepareForNewQuery();\n if (this.values.hasSelectedOrExcludedValues()) {\n var expression = this.facetQueryController.computeOurFilterExpression();\n this.logger.trace('Putting filter in query', expression);\n data.queryBuilder.advancedExpression.add(expression);\n }\n };\n Facet.prototype.handleDoneBuildingQuery = function (data) {\n Assert_1.Assert.exists(data);\n Assert_1.Assert.exists(data.queryBuilder);\n var queryBuilder = data.queryBuilder;\n this.facetQueryController.putGroupByIntoQueryBuilder(queryBuilder);\n };\n Facet.prototype.handleClearBreadcrumb = function () {\n this.reset();\n };\n Facet.prototype.updateValues = function (facetValues) {\n Assert_1.Assert.exists(facetValues);\n if (this.keepDisplayedValuesNextTime) {\n this.values.updateCountsFromNewValues(facetValues);\n }\n else {\n this.values = this.consolidateAndSortNewFacetValues(facetValues);\n }\n this.updateNumberOfValues();\n };\n Facet.prototype.consolidateAndSortNewFacetValues = function (newValues) {\n newValues.importActiveValuesFromOtherList(this.values);\n newValues.sort(this.optionsToSortFacetValues);\n return newValues;\n };\n Object.defineProperty(Facet.prototype, \"optionsToSortFacetValues\", {\n get: function () {\n return {\n facetValuesOrder: this.facetValuesOrder,\n numberOfValues: this.numberOfValues\n };\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(Facet.prototype, \"facetValuesOrder\", {\n get: function () {\n return new FacetValuesOrder_1.FacetValuesOrder(this, this.facetSort);\n },\n enumerable: true,\n configurable: true\n });\n Facet.prototype.ensureFacetValueIsInList = function (facetValue) {\n Assert_1.Assert.exists(facetValue);\n if (!this.values.contains(facetValue.value)) {\n this.values.add(facetValue);\n }\n };\n Facet.prototype.isAnyValueCurrentlyDisplayed = function () {\n return !this.values.isEmpty();\n };\n Facet.prototype.buildFacetContent = function () {\n this.headerElement = this.buildHeader();\n this.element.appendChild(this.headerElement);\n this.initFacetValuesList();\n if (this.shouldRenderFacetSearch()) {\n this.initFacetSearch();\n }\n if (this.shouldRenderMoreLess()) {\n this.moreElement = this.buildMore();\n this.lessElement = this.buildLess();\n }\n this.footerElement = this.buildFooter();\n this.element.appendChild(this.footerElement);\n if (this.lessElement && this.moreElement) {\n this.footerElement.appendChild(this.lessElement);\n this.footerElement.appendChild(this.moreElement);\n }\n };\n Facet.prototype.buildHeader = function () {\n var icon = this.options.headerIcon;\n if (this.options.headerIcon == this.options.field) {\n icon = undefined;\n }\n this.facetHeader = new FacetHeader_1.FacetHeader({\n facetElement: this.element,\n title: this.options.title,\n icon: icon,\n field: this.options.field,\n enableClearElement: true,\n enableCollapseElement: this.options.enableCollapse,\n facet: this,\n settingsKlass: this.options.enableSettings ? FacetSettings_1.FacetSettings : undefined,\n sortKlass: FacetSort_1.FacetSort,\n availableSorts: this.options.availableSorts\n });\n var built = this.facetHeader.build();\n this.facetSettings = this.facetHeader.settings;\n this.facetSort = this.facetHeader.sort;\n return built;\n };\n Facet.prototype.unpinFacetPosition = function () {\n if (this.shouldFacetUnpin() && this.options.preservePosition) {\n Dom_1.$$(this.pinnedTopSpace).addClass('coveo-with-animation');\n Dom_1.$$(this.pinnedBottomSpace).addClass('coveo-with-animation');\n this.pinnedTopSpace.style.height = '0px';\n this.pinnedBottomSpace.style.height = '0px';\n }\n this.unpinnedViewportPosition = undefined;\n this.pinnedViewportPosition = undefined;\n };\n Facet.prototype.isFacetPinned = function () {\n return Utils_1.Utils.exists(this.pinnedViewportPosition);\n };\n Facet.prototype.shouldFacetUnpin = function () {\n return Utils_1.Utils.exists(this.unpinnedViewportPosition);\n };\n Facet.prototype.ensurePinnedFacetHasntMoved = function () {\n if (this.isFacetPinned()) {\n Assert_1.Assert.exists(this.pinnedViewportPosition);\n Dom_1.$$(this.pinnedTopSpace).removeClass('coveo-with-animation');\n Dom_1.$$(this.pinnedBottomSpace).removeClass('coveo-with-animation');\n this.pinnedTopSpace.style.height = '0px';\n this.pinnedBottomSpace.style.height = '0px';\n // Under firefox scrolling the body doesn't work, but window does\n // on all browser, so we substitute those here when needed.\n var elementToScroll_1 = this.options.scrollContainer == document.body ? window : this.options.scrollContainer;\n var currentViewportPosition = this.element.getBoundingClientRect().top;\n var offset_1 = currentViewportPosition - this.pinnedViewportPosition;\n var scrollToOffset = function () {\n if (elementToScroll_1 instanceof Window) {\n window.scrollTo(0, new Dom_1.Win(elementToScroll_1).scrollY() + offset_1);\n }\n else {\n elementToScroll_1.scrollTop = elementToScroll_1.scrollTop + offset_1;\n }\n };\n // First try to adjust position by scrolling the page\n scrollToOffset();\n currentViewportPosition = this.element.getBoundingClientRect().top;\n offset_1 = currentViewportPosition - this.pinnedViewportPosition;\n // If scrolling has worked (offset == 0), we're good to go, nothing to do anymore.\n if (offset_1 < 0) {\n // This means the facet element is scrolled up in the viewport,\n // scroll it down by adding space in the top container\n this.pinnedTopSpace.style.height = offset_1 * -1 + 'px';\n }\n this.unpinnedViewportPosition = this.pinnedViewportPosition;\n this.pinnedViewportPosition = null;\n }\n };\n Facet.prototype.buildFooter = function () {\n return Dom_1.$$('div', { className: 'coveo-facet-footer' }).el;\n };\n Facet.prototype.buildMore = function () {\n var _this = this;\n var svgContainer = Dom_1.$$('span', { className: 'coveo-facet-more-icon' }, SVGIcons_1.SVGIcons.icons.arrowDown).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(svgContainer, 'coveo-facet-more-icon-svg');\n var more = Dom_1.$$('div', { className: 'coveo-facet-more', tabindex: 0 }, svgContainer).el;\n new AccessibleButton_1.AccessibleButton()\n .withElement(more)\n .withLabel(Strings_1.l('ShowMoreFacetResults', this.options.title))\n .withSelectAction(function () { return _this.handleClickMore(); })\n .build();\n return more;\n };\n Facet.prototype.buildLess = function () {\n var _this = this;\n var svgContainer = Dom_1.$$('span', { className: 'coveo-facet-less-icon' }, SVGIcons_1.SVGIcons.icons.arrowUp).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(svgContainer, 'coveo-facet-less-icon-svg');\n var less = Dom_1.$$('div', { className: 'coveo-facet-less', tabindex: 0 }, svgContainer).el;\n new AccessibleButton_1.AccessibleButton()\n .withElement(less)\n .withLabel(Strings_1.l('ShowLessFacetResults', this.options.title))\n .withSelectAction(function () { return _this.handleClickLess(); })\n .build();\n return less;\n };\n Facet.prototype.triggerMoreQuery = function () {\n var _this = this;\n this.logger.info('Triggering new facet more query');\n this.showWaitingAnimation();\n // fetch 1 more value than we need, so we can see if there is more value to fetch still or if we have reached\n // the end of the availables values\n this.facetQueryController\n .fetchMore(this.numberOfValues + 1)\n .then(function (queryResults) {\n _this.logAnalyticsFacetShowMoreLess(AnalyticsActionListMeta_1.analyticsActionCauseList.facetShowMore);\n var facetValues = new FacetValues_1.FacetValues(queryResults.groupByResults[0]);\n _this.values = _this.consolidateAndSortNewFacetValues(facetValues);\n _this.nbAvailableValues = _this.values.size();\n _this.updateNumberOfValues();\n _this.canFetchMore = _this.numberOfValues < _this.nbAvailableValues;\n if (_this.values.hasSelectedOrExcludedValues() && !_this.options.useAnd && _this.options.isMultiValueField) {\n _this.triggerUpdateDeltaQuery(_.filter(_this.values.getAll(), function (facetValue) { return !facetValue.selected && !facetValue.excluded; }));\n }\n else if (_this.values.hasSelectedOrExcludedValues() && !_this.options.useAnd) {\n _this.values.updateDeltaWithFilteredFacetValues(new FacetValues_1.FacetValues(), _this.options.isMultiValueField);\n _this.hideWaitingAnimation();\n }\n else {\n _this.hideWaitingAnimation();\n }\n _this.rebuildValueElements();\n })\n .catch(function () { return _this.hideWaitingAnimation(); });\n };\n Facet.prototype.triggerUpdateDeltaQuery = function (facetValues) {\n var _this = this;\n this.showWaitingAnimation();\n this.facetQueryController.searchInFacetToUpdateDelta(facetValues).then(function (queryResults) {\n var values = new FacetValues_1.FacetValues();\n _.each(queryResults.groupByResults, function (groupByResult) {\n _.each(groupByResult.values, function (groupByValue) {\n if (!values.contains(groupByValue.value)) {\n values.add(FacetValue_1.FacetValue.createFromGroupByValue(groupByValue));\n }\n });\n });\n _this.values.updateDeltaWithFilteredFacetValues(values, _this.options.isMultiValueField);\n _this.cleanupDeltaValuesForMultiValueField();\n _this.rebuildValueElements();\n _this.hideWaitingAnimation();\n });\n };\n Facet.prototype.updateNumberOfValues = function () {\n if (this.keepDisplayedValuesNextTime) {\n return;\n }\n if (this.currentPage <= 0) {\n // We're on the first page, let's reset the number of values to a minimum.\n this.currentPage = 0;\n this.numberOfValues = 0;\n }\n else {\n // Calculate the number of value with the current page.\n this.numberOfValues = this.options.numberOfValues + this.currentPage * this.options.pageSize;\n }\n // Make sure we have at least the absolute minimum of value to display.\n this.numberOfValues = Math.max(this.numberOfValues, this.getMinimumNumberOfValuesToDisplay());\n };\n Facet.prototype.getMinimumNumberOfValuesToDisplay = function () {\n // The min value is the number of used values.\n var minValue = this.values.getExcluded().length + this.values.getSelected().length;\n // When using a custom sort, we have to show all values between the selected ones.\n // Thus, we must find the last selected value after a reorder and use that value as the number of value.\n if (this.options.customSort != null && this.facetSort != null && this.options.customSort.length > 0) {\n var lastSelectedValueIndex_1 = -1;\n new FacetValuesOrder_1.FacetValuesOrder(this, this.facetSort).reorderValues(this.values.getAll()).forEach(function (facetValue, index) {\n if (facetValue.selected) {\n lastSelectedValueIndex_1 = index;\n }\n });\n minValue = lastSelectedValueIndex_1 + 1;\n }\n return Math.max(minValue, this.options.numberOfValues);\n };\n Facet.prototype.cleanupDeltaValuesForMultiValueField = function () {\n var _this = this;\n // On a multi value field, it's possible to end up in a scenario where many of the current values are empty\n // Crop those out, and adjust the nbAvailable values for the \"search\" and \"show more\";\n if (this.options.isMultiValueField) {\n _.each(this.values.getAll(), function (v) {\n if (v.occurrences == 0 && !v.selected && !v.excluded) {\n _this.values.remove(v.value);\n }\n });\n this.nbAvailableValues = this.values.getAll().length;\n }\n };\n Facet.prototype.shouldRenderFacetSearch = function () {\n return this.options.enableFacetSearch;\n };\n Facet.prototype.shouldRenderMoreLess = function () {\n return this.options.enableMoreLess;\n };\n Facet.prototype.debugInfo = function () {\n var info = {};\n info[this['constructor']['ID']] = {\n component: this,\n groupByRequest: this.facetQueryController.lastGroupByRequest,\n groupByResult: this.facetQueryController.lastGroupByResult\n };\n return info;\n };\n Facet.prototype.logAnalyticsFacetShowMoreLess = function (cause) {\n this.usageAnalytics.logCustomEvent(cause, {\n facetId: this.options.id,\n facetField: this.options.field.toString(),\n facetTitle: this.options.title\n }, this.element);\n };\n Facet.ID = 'Facet';\n Facet.omniboxIndex = 50;\n Facet.doExport = function () {\n GlobalExports_1.exportGlobally({\n Facet: Facet,\n FacetHeader: FacetHeader_1.FacetHeader,\n FacetSearchValuesList: FacetSearchValuesList_1.FacetSearchValuesList,\n FacetSettings: FacetSettings_1.FacetSettings,\n FacetSort: FacetSort_1.FacetSort,\n FacetUtils: FacetUtils_1.FacetUtils,\n FacetValueElement: FacetValueElement_1.FacetValueElement,\n FacetValue: FacetValue_1.FacetValue\n });\n };\n /**\n * The possible options for a facet\n * @componentOptions\n */\n Facet.options = __assign({ \n /**\n * Specifies the title to display at the top of the facet.\n *\n * Default value is the localized string for `NoTitle`.\n */\n title: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({\n localizedString: function () { return Strings_1.l('NoTitle'); },\n section: 'CommonOptions',\n priority: 10\n }), \n /**\n * Specifies the index field whose values the facet should use.\n *\n * The field must of the `string` type.\n *\n * This requires the given field to be configured correctly in the index as a *Facet field* (see\n * [Add or Edit Fields](https://docs.coveo.com/en/1982/)).\n *\n * Specifying a value for this option is required for the `Facet` component to work.\n */\n field: ComponentOptions_1.ComponentOptions.buildFieldOption({ required: true, groupByField: true, section: 'CommonOptions' }), headerIcon: ComponentOptions_1.ComponentOptions.buildStringOption({\n deprecated: 'This option is exposed for legacy reasons, and the recommendation is to not use this option.'\n }), \n /**\n * Specifies a unique identifier for the facet. Among other things, this identifier serves the purpose of saving\n * the facet state in the URL hash.\n *\n * If you have two facets with the same field on the same page, you should specify an `id` value for at least one of\n * those two facets. This `id` must be unique among the facets.\n *\n * Non-word characters except - @ $ _ . + ! * ' ( ) , , ( `^a-zA-Z0-9-@$_.+!*'(),,]+` ) are automatically removed from the `id` value.\n *\n * Default value is the [`field`]{@link Facet.options.field} option value.\n */\n id: ComponentOptions_1.ComponentOptions.buildStringOption({\n postProcessing: function (value, options) {\n if (value) {\n // All non-word characters, except @ (the default character that specifies a field in the index)\n // and characters that do no need to be encoded in the URL : - @ $ _ . + ! * ' ( ) , ,\n var modified = value.replace(/[^a-zA-Z0-9-@$_.+!*'(),,]+/g, '');\n if (Utils_1.Utils.isNullOrEmptyString(modified)) {\n return options.field;\n }\n return modified;\n }\n return options.field;\n }\n }), \n /**\n * Specifies whether the facet [`field`]{@link Facet.options.field} is configured in the index as a multi-value\n * field (semicolon separated values such as `abc;def;ghi`).\n *\n * Default value is `false`.\n */\n isMultiValueField: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false, section: 'CommonOptions' }), \n /**\n * Specifies the field whose values the Facet should display.\n *\n * @deprecated This option is exposed for legacy reasons. It is not recommended to use this option.\n */\n lookupField: ComponentOptions_1.ComponentOptions.buildFieldOption({\n deprecated: 'This option is exposed for legacy reasons. It is not recommended to use this option.'\n }), \n /**\n * Specifies whether to display the facet **Settings** menu.\n *\n * See also the [`enableSettingsFacetState`]{@link Facet.options.enableSettingsFacetState},\n * [`availableSorts`]{@link Facet.options.availableSorts}, and\n * [`enableCollapse`]{@link Facet.options.enableCollapse} options.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `true`.\n */\n enableSettings: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true, section: 'Sorting', priority: 9 }), \n /**\n * If the [`enableSettings`]{@link Facet.options.enableSettings} option is `true`, specifies whether the\n * **Save state** menu option is available in the facet **Settings** menu.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `false`.\n */\n enableSettingsFacetState: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false, depend: 'enableSettings' }), \n /**\n * If the [`enableSettings`]{@link Facet.options.enableSettings} option is `true`, specifies the sort criteria\n * options to display in the facet **Settings** menu.\n *\n * Possible values are:\n * - `\"occurrences\"`\n * - `\"score\"`\n * - `\"alphaascending\"`\n * - `\"alphadescending\"`\n * - `\"computedfieldascending\"`\n * - `\"computedfielddescending\"`\n * - `\"custom\"`\n *\n * See {@link IGroupByRequest.sortCriteria} for a description of each possible value.\n *\n * **Notes:**\n * > * The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * > * Using value captions will disable alphabetical sorts (see the [valueCaption]{@link Facet.options.valueCaption} option).\n *\n * Default value is `occurrences,score,alphaascending,alphadescending`.\n */\n availableSorts: ComponentOptions_1.ComponentOptions.buildListOption({\n defaultValue: ['occurrences', 'score', 'alphaascending', 'alphadescending'],\n section: 'Sorting',\n depend: 'enableSettings',\n values: [\n 'occurrences',\n 'score',\n 'alphaascending',\n 'alphadescending',\n 'computedfieldascending',\n 'computedfielddescending',\n 'chisquare',\n 'nosort'\n ]\n }), \n /**\n * Specifies the criteria to use to sort the facet values.\n *\n * See {@link IGroupByRequest.sortCriteria} for the list and description of possible values.\n *\n * Default value is the first sort criteria specified in the [`availableSorts`]{@link Facet.options.availableSorts}\n * option, or `occurrences` if no sort criteria is specified.\n */\n sortCriteria: ComponentOptions_1.ComponentOptions.buildStringOption({\n postProcessing: function (value, options) {\n return value || (options.availableSorts.length > 0 ? options.availableSorts[0] : 'occurrences');\n },\n section: 'Sorting'\n }), \n /**\n * Specifies a custom order by which to sort the facet values.\n *\n * **Example:**\n *\n * You could use this option to specify a logical order for support tickets, such as:\n * ```html\n * \n * ```\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n */\n customSort: ComponentOptions_1.ComponentOptions.buildListOption({ section: 'Sorting' }), \n /**\n * Specifies the maximum number of field values to display by default in the facet before the user\n * clicks the arrow to show more.\n *\n * See also the [`enableMoreLess`]{@link Facet.options.enableMoreLess} option.\n */\n numberOfValues: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 5, min: 0, section: 'CommonOptions' }), \n /**\n * Specifies the *injection depth* to use for the [`GroupByRequest`]{@link IGroupByRequest} operation.\n *\n * The injection depth determines how many results to scan in the index to ensure that the facet lists all potential\n * facet values. Increasing this value enhances the accuracy of the listed values at the cost of performance.\n *\n * Default value is `1000`. Minimum value is `1000`.\n * @notSupportedIn salesforcefree\n *\n * @examples 1500\n */\n injectionDepth: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 1000, min: 1000 }), showIcon: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n defaultValue: false,\n deprecated: 'This option is exposed for legacy reasons. It is not recommended to use this option.'\n }), \n /**\n * Specifies whether to use the `AND` operator in the resulting filter when multiple values are selected in the\n * facet.\n *\n * Setting this option to `true` means that items must have all of the selected values to match the resulting\n * query.\n *\n * Default value is `false`, which means that the filter uses the `OR` operator. Thus, by default, items must\n * have at least one of the selected values to match the query.\n */\n useAnd: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false, section: 'Filtering' }), \n /**\n * Specifies whether to allow the user to toggle between the `OR` and `AND` modes in the facet.\n *\n * Setting this option to `true` displays an icon in the top right corner of the facet. The user can click this icon\n * to toggle between between the two modes.\n *\n * Default value is `false`.\n */\n enableTogglingOperator: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n defaultValue: false,\n alias: 'allowTogglingOperator'\n }), \n /**\n * Specifies whether to display a search box at the bottom of the facet for searching among the available facet\n * [`field`]{@link Facet.options.field} values.\n *\n * See also the [`facetSearchDelay`]{@link Facet.options.facetSearchDelay},\n * [`facetSearchIgnoreAccents`]{@link Facet.options.facetSearchIgnoreAccents}, and\n * [`numberOfValuesInFacetSearch`]{@link Facet.options.numberOfValuesInFacetSearch} options.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `true`.\n */\n enableFacetSearch: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true, section: 'FacetSearch', priority: 8 }), \n /**\n * If the [`enableFacetSearch`]{@link Facet.options.enableFacetSearch} option is `true`, specifies the delay (in\n * milliseconds) before sending a search request to the server when the user starts typing in the facet search box.\n *\n * Specifying a smaller value makes results appear faster. However, chances of having to cancel many requests\n * sent to the server increase as the user keeps on typing new characters.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `100`. Minimum value is `0`.\n */\n facetSearchDelay: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 100, min: 0, depend: 'enableFacetSearch' }), \n /**\n * If the [`enableFacetSearch`]{@link Facet.options.enableFacetSearch} option is `true`, specifies whether to ignore\n * accents in the facet search box.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `false`.\n */\n facetSearchIgnoreAccents: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false, depend: 'enableFacetSearch' }), \n /**\n * If the [`enableFacetSearch`]{@link Facet.options.enableFacetSearch} option is `true`, specifies the number of v\n * alues to display in the facet search results popup.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `15`. Minimum value is `1`.\n */\n numberOfValuesInFacetSearch: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 15, min: 1, section: 'FacetSearch' }), \n /**\n * Specifies whether [wildcards]{@link AllowedValuesPatternType.wildcards} are used as the [allowedValuesPatternType]{@link IGroupByRequest.allowedValuesPatternType}\n * in the [groupBy]{@link IGroupByRequest} for the facet search.\n *\n * Enabling this option returns results that end with the entered value. For example, searching for `veo` would match with `Coveo`.\n *\n * **Note:**\n * > If you are experiencing slow facet search and/or timeouts when this option is set to `true`, consider enabling the **Use cache for nested queries**\n * > option on your facet [field]{@link Facet.options.field} in the Coveo Cloud Admninistration Console (see [Add or Edit Fields]{@link https://docs.coveo.com/en/1982/}).\n */\n useWildcardsInFacetSearch: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false, section: 'FacetSearch' }), \n /**\n * Specifies whether the facet should push data to the [`Breadcrumb`]{@link Breadcrumb} component.\n *\n * See also the [`numberOfValuesInBreadcrumb`]{@link Facet.options.numberOfValuesInBreadcrumb} option.\n *\n * Default value is `true`.\n */\n includeInBreadcrumb: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }), \n /**\n * If the [`includeInBreadcrumb`]{@link Facet.options.includeInBreadcrumb} option is `true`, specifies the maximum\n * number of values that the facet should display in the [`Breadcrumb`]{@link Breadcrumb} before outputting a\n * **more...** button.\n *\n * Default value is `5` on a desktop computer and `3` on a mobile device. Minimum value is `0`.\n */\n numberOfValuesInBreadcrumb: ComponentOptions_1.ComponentOptions.buildNumberOption({\n defaultFunction: function () { return (DeviceUtils_1.DeviceUtils.isMobileDevice() ? 3 : 5); },\n min: 0,\n depend: 'includeInBreadcrumb'\n }), \n /**\n * Specifies whether the Facet should push data to the {@link Omnibox} component.\n *\n * See also {@link Facet.options.numberOfValuesInOmnibox}.\n *\n * Default value is `false`.\n *\n * @deprecated This option is exposed for legacy reasons. It is not recommended to use this option.\n */\n includeInOmnibox: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n defaultValue: false,\n deprecated: 'This option is exposed for legacy reasons. It is not recommended to use this option.'\n }), \n /**\n * When {@link Facet.options.includeInOmnibox} is `true`, specifies the number of values to populate the\n * {@link Breadcrumb} with.\n *\n * Default value is `5` on desktop computer and `3` on a mobile device. Minimum value is `0`.\n *\n * @deprecated This option is exposed for legacy reasons. It is not recommended to use this option.\n */\n numberOfValuesInOmnibox: ComponentOptions_1.ComponentOptions.buildNumberOption({\n defaultFunction: function () { return (DeviceUtils_1.DeviceUtils.isMobileDevice() ? 3 : 5); },\n min: 0,\n depend: 'includeInOmnibox',\n deprecated: 'This option is exposed for legacy reasons. It is not recommended to use this option.'\n }), \n /**\n * Specifies the name of a field on which to execute an aggregate operation for all distinct values of the facet\n * [`field`]{@link Facet.options.field}.\n *\n * The facet displays the result of the operation along with the number of occurrences for each value.\n *\n * You can use this option to compute the sum of a field (like a money amount) for each listed facet value.\n *\n * Works in conjunction with the [`computedFieldOperation`]{@link Facet.options.computedFieldOperation},\n * [`computedFieldFormat`]{@link Facet.options.computedFieldFormat}, and\n * [`computedFieldCaption`]{@link Facet.options.computedFieldCaption} options.\n * @notSupportedIn salesforcefree\n */\n computedField: ComponentOptions_1.ComponentOptions.buildFieldOption({ priority: 7 }), \n /**\n * Specifies the type of aggregate operation to perform on the [`computedField`]{@link Facet.options.computedField}.\n *\n * The possible values are:\n * - `sum` - Computes the sum of the computed field values.\n * - `average` - Computes the average of the computed field values.\n * - `minimum` - Finds the minimum value of the computed field values.\n * - `maximum` - Finds the maximum value of the computed field values.\n *\n * Default value is `sum`.\n * @notSupportedIn salesforcefree\n */\n computedFieldOperation: ComponentOptions_1.ComponentOptions.buildStringOption({\n defaultValue: 'sum',\n section: 'ComputedField'\n }), \n /**\n * Specifies how to format the values resulting from a\n * [`computedFieldOperation`]{@link Facet.options.computedFieldOperation}.\n *\n * The Globalize library defines all available formats (see\n * [Globalize](https://github.com/klaaspieter/jquery-global#globalizeformat-value-format-culture-)).\n *\n * The most commonly used formats are:\n * - `c0` - Formats the value as a currency.\n * - `n0` - Formats the value as an integer.\n * - `n2` - Formats the value as a floating point with 2 decimal digits.\n *\n * Default value is `\"c0\"`.\n * @notSupportedIn salesforcefree\n */\n computedFieldFormat: ComponentOptions_1.ComponentOptions.buildStringOption({\n defaultValue: 'c0',\n section: 'ComputedField'\n }), \n /**\n * Specifies what the caption of the [`computedField`]{@link Facet.options.computedField} should be in the facet\n * **Settings** menu for sorting.\n *\n * For example, setting this option to `\"Money\"` will display `\"Money Ascending\"` for computed field ascending.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is the localized string for `ComputedField`.\n * @notSupportedIn salesforcefree\n */\n computedFieldCaption: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({\n localizedString: function () { return Strings_1.l('ComputedField'); },\n section: 'ComputedField'\n }), \n /**\n * Specifies whether the facet should remain stable in its current position in the viewport while the mouse cursor\n * is over it.\n *\n * Whenever the value selection changes in a facet, the search interface automatically performs a query. This new\n * query might cause other elements in the page to resize themselves (typically, other facets above or below the\n * one the user is interacting with).\n *\n * This option is responsible for adding the `
` and\n * `
` around the Facet container. The Facet adjusts the scroll amount of the page to\n * ensure that it does not move relatively to the mouse when the results are updated.\n *\n * In some cases, the facet also adds margins to the `scrollContainer`, if scrolling alone is not enough to\n * preserve position.\n *\n * See also the [`paddingContainer`]{@link Facet.options.paddingContainer}, and\n * [`scrollContainer`]{@link Facet.options.scrollContainer} options.\n *\n * Default value is `true`.\n */\n preservePosition: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }), \n /**\n * Specifies the parent container of the facets.\n *\n * Used by the [`preservePosition`]{@link Facet.options.preservePosition} option.\n *\n * Default value is `element.parentElement`.\n */\n paddingContainer: ComponentOptions_1.ComponentOptions.buildSelectorOption({\n defaultFunction: function (element) {\n var standardColumn = Dom_1.$$(element).parent('coveo-facet-column');\n if (standardColumn != null) {\n return standardColumn;\n }\n return element.parentElement;\n }\n }), \n /**\n * Specifies the HTML element (through a CSS selector) whose scroll amount the facet should adjust to preserve its\n * position when results are updated.\n *\n * Used by the [`preservePosition`]{@link Facet.options.preservePosition} option.\n *\n * Default value is `document.body`.\n */\n scrollContainer: ComponentOptions_1.ComponentOptions.buildSelectorOption({ defaultFunction: function (element) { return document.body; } }), \n /**\n * Specifies whether to enable the **More** and **Less** buttons in the Facet.\n *\n * See also the [`pageSize`]{@link Facet.options.pageSize} option.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `true`.\n */\n enableMoreLess: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }), \n /**\n * If the [`enableMoreLess`]{@link Facet.options.enableMoreLess} option is `true`, specifies the number of\n * additional results to fetch when clicking the **More** button.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `10`. Minimum value is `1`.\n */\n pageSize: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 10, min: 1, depend: 'enableMoreLess' }), \n /**\n * If the [`enableSettings`]{@link Facet.options.enableSettings} option is `true`, specifies whether the\n * **Collapse \\ Expand** menu option is available in the facet **Settings** menu.\n *\n * **Note:**\n * > The [`FacetRange`]{@link FacetRange} component does not support this option.\n *\n * Default value is `true`.\n */\n enableCollapse: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true, depend: 'enableSettings' }), \n /**\n * Specifies an explicit list of [`allowedValues`]{@link IGroupByRequest.allowedValues} in the\n * [`GroupByRequest`]{@link IGroupByRequest}.\n *\n * If you specify a list of values for this option, the facet uses only these values (if they are available in\n * the current result set).\n *\n * **Example:**\n *\n * The following facet only uses the `Contact`, `Account`, and `File` values of the `@objecttype` field. Even if the\n * current result set contains other `@objecttype` values, such as `Message`, or `Product`, the facet does not use\n * those other values.\n *\n * ```html\n *\n * \n * ```\n *\n * Default value is `undefined`, and the facet uses all available values for its\n * [`field`]{@link Facet.options.field} in the current result set.\n */\n allowedValues: ComponentOptions_1.ComponentOptions.buildListOption(), \n /**\n * Specifies an additional query expression (query override) to add to each\n * [`GroupByRequest`]{@link IGroupByRequest} that this facet performs.\n *\n * Example: `@date>=2014/01/01`\n * @notSupportedIn salesforcefree\n */\n additionalFilter: ComponentOptions_1.ComponentOptions.buildQueryExpressionOption(), \n /**\n * Specifies whether this facet only appears when a value is selected in its \"parent\" facet.\n *\n * To specify the parent facet, use its [`id`]{@link Facet.options.id}.\n *\n * Remember that by default, a facet `id` value is the same as its [`field`]{@link Facet.options.field} option\n * value.\n *\n * **Examples:**\n *\n * First case: the \"parent\" facet has no custom `id`:\n * ```html\n * \n * \n *\n * \n * \n * ```\n *\n * Second case: the \"parent\" facet has a custom `id`:\n * ```html\n * \n * \n *\n * \n * \n * ```\n *\n * Default value is `undefined`\n */\n dependsOn: ComponentOptions_1.ComponentOptions.buildStringOption(), \n /**\n * A function that verifies whether the current state of the `dependsOn` facet allows the dependent facet to be displayed.\n *\n * If specified, the function receives a reference to the resolved `dependsOn` facet component instance as an argument, and must return a boolean.\n * The function's argument should typically be treated as read-only.\n *\n * By default, the dependent facet is displayed whenever one or more values are selected in its `dependsOn` facet.\n *\n * @externaldocs [Defining Dependent Facets](https://docs.coveo.com/3210/)\n */\n dependsOnCondition: ComponentOptions_1.ComponentOptions.buildCustomOption(function () {\n return null;\n }, { depend: 'dependsOn', section: 'CommonOptions' }), \n /**\n * Specifies a JSON object describing a mapping of facet values to their desired captions. See\n * [Normalizing Facet Value Captions](https://docs.coveo.com/en/368/).\n *\n * **Examples:**\n *\n * You can set the option in the ['init']{@link init} call:\n * ```javascript\n * var myValueCaptions = {\n * \"txt\" : \"Text files\",\n * \"html\" : \"Web page\",\n * [ ... ]\n * };\n *\n * Coveo.init(document.querySelector(\"#search\"), {\n * Facet : {\n * valueCaption : myValueCaptions\n * }\n * });\n * ```\n *\n * Or before the `init` call, using the ['options']{@link options} top-level function:\n * ```javascript\n * Coveo.options(document.querySelector(\"#search\"), {\n * Facet : {\n * valueCaption : myValueCaptions\n * }\n * });\n * ```\n *\n * Or directly in the markup:\n * ```html\n * \n * \n * ```\n *\n * **Note:**\n * > Using value captions will disable alphabetical sorts (see the [availableSorts]{@link Facet.options.availableSorts} option).\n */\n valueCaption: ComponentOptions_1.ComponentOptions.buildJsonOption() }, ResponsiveFacetOptions_1.ResponsiveFacetOptions);\n return Facet;\n}(Component_1.Component));\nexports.Facet = Facet;\nInitialization_1.Initialization.registerAutoCreateComponent(Facet);\nFacet.doExport();\n\n\n/***/ }),\n\n/***/ 85:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar ComponentOptions_1 = __webpack_require__(8);\n/**\n * ResponsiveFacets options\n */\nexports.ResponsiveFacetOptions = {\n /**\n * Specifies whether to enable *responsive mode* for facets. Setting this options to `false` on any `Facet`, or\n * [`FacetSlider`]{@link FacetSlider} component in a search interface disables responsive mode for all other facets\n * in the search interface.\n *\n * Responsive mode displays all facets under a single dropdown button whenever the width of the HTML element which\n * the search interface is bound to reaches or falls behind a certain threshold (see\n * {@link SearchInterface.responsiveComponents}).\n *\n * See also the [`dropdownHeaderLabel`]{@link Facet.options.dropdownHeaderLabel} option.\n *\n * Default value is `true`.\n */\n enableResponsiveMode: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true, section: 'ResponsiveOptions' }),\n responsiveBreakpoint: ComponentOptions_1.ComponentOptions.buildNumberOption({\n deprecated: 'This option is exposed for legacy reasons. It is not recommended to use this option. Instead, use `SearchInterface.options.responsiveMediumBreakpoint` options exposed on the `SearchInterface`.'\n }),\n /**\n * If the [`enableResponsiveMode`]{@link Facet.options.enableResponsiveMode} option is `true` for all facets and\n * {@link FacetSlider.options.enableResponsiveMode} is also `true` for all sliders, specifies the label of the\n * dropdown button that allows to display the facets when in responsive mode.\n *\n * If more than one `Facet` or {@link FacetSlider} component in the search interface specifies a value for this\n * option, the framework uses the first occurrence of the option.\n *\n * Default value is `Filters`.\n */\n dropdownHeaderLabel: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({ section: 'ResponsiveOptions' })\n};\n\n\n/***/ }),\n\n/***/ 86:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Core_1 = __webpack_require__(20);\nvar Initialization_1 = __webpack_require__(2);\n/**\n * This component lets you customize the mobile responsive behavior of facets in your search interface.\n *\n * **Notes:**\n * - You can include this component anywhere under the root element of your search interface.\n * - You should only include this component once in your search interface.\n */\nvar FacetsMobileMode = /** @class */ (function (_super) {\n __extends(FacetsMobileMode, _super);\n function FacetsMobileMode(element, options, bindings) {\n var _this = _super.call(this, element, FacetsMobileMode.ID, bindings) || this;\n _this.element = element;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, FacetsMobileMode, options);\n if (_this.options.preventScrolling) {\n var scrollContainer = _this.options.scrollContainer || _this.searchInterface.element;\n _this.options.scrollContainer = ComponentOptions_1.ComponentOptions.findParentScrollLockable(scrollContainer);\n }\n return _this;\n }\n FacetsMobileMode.ID = 'FacetsMobileMode';\n /**\n * @componentOptions\n */\n FacetsMobileMode.options = {\n /**\n * The screen width (in number of pixels) at which facets should enter mobile responsive mode and be collapsed under a single button.\n *\n * **Default:** `800`\n */\n breakpoint: ComponentOptions_1.ComponentOptions.buildNumberOption(),\n /**\n * Whether to display the facets in a modal instead of a pop-up when the end user expands them in mobile responsive mode.\n * Set this option to `false` in order to keep the old behaviour.\n */\n isModal: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }),\n /**\n * Whether to display an overlay behind the facets when the end user expands them in mobile responsive mode.\n *\n * By default, the following behavior applies:\n * - `true` when [isModal]{@link FacetsMobileMode.options.isModal} is `false`\n * - `false` when [isModal]{@link FacetsMobileMode.options.isModal} is `true`\n */\n displayOverlayWhileOpen: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n postProcessing: function (value, options) { return (Core_1.Utils.isNullOrUndefined(value) ? !options.isModal : value); }\n }),\n /**\n * Whether to disable vertical scrolling on the specified or resolved [`scrollContainer`]{@link FacetsMobileMode.options.scrollContainer} while facets are expanded in mobile responsive mode.\n *\n * By default, the following behavior applies:\n * - `true` when [isModal]{@link FacetsMobileMode.options.isModal} is `true`\n * - `false` when [isModal]{@link FacetsMobileMode.options.isModal} is `false`\n */\n preventScrolling: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n postProcessing: function (value, options) { return (Core_1.Utils.isNullOrUndefined(value) ? options.isModal : value); }\n }),\n /**\n * The HTML element whose vertical scrolling should be locked while facets are expanded in mobile responsive mode.\n *\n * By default, the component tries to detect and use the first ancestor element whose CSS `overflow-y` attribute is set to `scroll`, starting from the `FacetsMobileMode`'s element itself. If no such element is found, the `document.body` element is used.\n *\n * Since this heuristic is not perfect, we strongly recommend that you manually set this option by explicitly specifying the desired CSS selector.\n *\n * **Example:** `data-scroll-container-selector='#someCssSelector'`\n */\n scrollContainer: ComponentOptions_1.ComponentOptions.buildChildHtmlElementOption({ depend: 'preventScrolling' })\n };\n FacetsMobileMode.doExport = function () {\n GlobalExports_1.exportGlobally({\n FacetsMobileMode: FacetsMobileMode\n });\n };\n return FacetsMobileMode;\n}(Component_1.Component));\nexports.FacetsMobileMode = FacetsMobileMode;\nInitialization_1.Initialization.registerAutoCreateComponent(FacetsMobileMode);\n\n\n/***/ }),\n\n/***/ 92:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(527);\n__webpack_require__(528);\n__webpack_require__(529);\nvar underscore_1 = __webpack_require__(0);\nvar QueryEvents_1 = __webpack_require__(11);\nvar ResultLayoutEvents_1 = __webpack_require__(133);\nvar ResultListEvents_1 = __webpack_require__(29);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Assert_1 = __webpack_require__(5);\nvar Defer_1 = __webpack_require__(31);\nvar Model_1 = __webpack_require__(18);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar DeviceUtils_1 = __webpack_require__(24);\nvar Dom_1 = __webpack_require__(1);\nvar DomUtils_1 = __webpack_require__(96);\nvar Utils_1 = __webpack_require__(4);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\nvar InitializationPlaceholder_1 = __webpack_require__(177);\nvar TemplateComponentOptions_1 = __webpack_require__(63);\nvar ResponsiveDefaultResultTemplate_1 = __webpack_require__(530);\nvar CoreHelpers_1 = __webpack_require__(473);\nvar DefaultRecommendationTemplate_1 = __webpack_require__(471);\nvar DefaultResultTemplate_1 = __webpack_require__(122);\nvar TableTemplate_1 = __webpack_require__(469);\nvar TemplateCache_1 = __webpack_require__(68);\nvar TemplateList_1 = __webpack_require__(95);\nvar ResultContainer_1 = __webpack_require__(531);\nvar ResultListCardRenderer_1 = __webpack_require__(532);\nvar ResultListRenderer_1 = __webpack_require__(215);\nvar ResultListTableRenderer_1 = __webpack_require__(533);\nvar ResultListUtils_1 = __webpack_require__(117);\nvar TemplateToHtml_1 = __webpack_require__(472);\nCoreHelpers_1.CoreHelpers.exportAllHelpersGlobally(window['Coveo']);\n/**\n * The `ResultList` component is responsible for displaying query results by applying one or several result templates\n * (see [Result Templates](https://docs.coveo.com/en/413/)).\n *\n * It is possible to include multiple `ResultList` components along with a single `ResultLayout`\n * component in a search page to provide different result layouts (see\n * [Result Layouts](https://docs.coveo.com/en/360/)).\n *\n * This component supports infinite scrolling (see the\n * [`enableInfiniteScroll`]{@link ResultList.options.enableInfiniteScroll} option).\n */\nvar ResultList = /** @class */ (function (_super) {\n __extends(ResultList, _super);\n /**\n * Creates a new `ResultList` component. Binds various event related to queries (e.g., on querySuccess ->\n * renderResults). Binds scroll event if the [`enableInfiniteScroll`]{@link ResultList.options.enableInfiniteScroll}\n * option is `true`.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `ResultList` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param elementClassId The class that this component should instantiate. Components that extend the base ResultList\n * use this. Default value is `CoveoResultList`.\n */\n function ResultList(element, options, bindings, elementClassId) {\n if (elementClassId === void 0) { elementClassId = ResultList.ID; }\n var _this = _super.call(this, element, elementClassId, bindings) || this;\n _this.element = element;\n _this.options = options;\n _this.bindings = bindings;\n _this.currentlyDisplayedResults = [];\n _this.reachedTheEndOfResults = false;\n _this.disableLayoutChange = false;\n // This variable serves to block some setup where the framework fails to correctly identify the \"real\" scrolling container.\n // Since it's not technically feasible to correctly identify the scrolling container in every possible scenario without some very complex logic, we instead try to add some kind of mechanism to\n // block runaway requests where UI will keep asking more results in the index, eventually bringing the browser to it's knee.\n // Those successive request are needed in \"displayMoreResults\" to ensure we fill the scrolling container correctly.\n // Since the container is not identified correctly, it is never \"full\", so we keep asking for more.\n // It is reset every time the user actually scroll the container manually.\n _this.successiveScrollCount = 0;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, ResultList, options);\n Assert_1.Assert.exists(element);\n Assert_1.Assert.exists(_this.options);\n Assert_1.Assert.exists(_this.options.resultTemplate);\n Assert_1.Assert.exists(_this.options.infiniteScrollContainer);\n _this.showOrHideElementsDependingOnState(false, false);\n _this.addListeners();\n _this.resultContainer = _this.initResultContainer();\n Assert_1.Assert.exists(_this.options.resultsContainer);\n _this.initWaitAnimationContainer();\n Assert_1.Assert.exists(_this.options.waitAnimationContainer);\n _this.setupTemplatesVersusLayouts();\n Dom_1.$$(_this.root).on(ResultLayoutEvents_1.ResultLayoutEvents.populateResultLayout, function (e, args) {\n return args.layouts.push(_this.options.layout);\n });\n _this.setupRenderer();\n _this.makeElementFocusable();\n _this.ensureHasId();\n return _this;\n }\n ResultList.getDefaultTemplate = function (e) {\n var template = ResultList.loadTemplatesFromCache();\n if (template != null) {\n return template;\n }\n var component = Component_1.Component.get(e);\n if (Coveo['Recommendation'] && component.searchInterface instanceof Coveo['Recommendation']) {\n return new DefaultRecommendationTemplate_1.DefaultRecommendationTemplate();\n }\n return new DefaultResultTemplate_1.DefaultResultTemplate();\n };\n ResultList.loadTemplatesFromCache = function () {\n var pageTemplateNames = TemplateCache_1.TemplateCache.getResultListTemplateNames();\n if (pageTemplateNames.length > 0) {\n return new TemplateList_1.TemplateList(underscore_1.compact(underscore_1.map(pageTemplateNames, function (templateName) { return TemplateCache_1.TemplateCache.getTemplate(templateName); })));\n }\n return null;\n };\n ResultList.prototype.addListeners = function () {\n var _this = this;\n this.bind.onRootElement(QueryEvents_1.QueryEvents.newQuery, function (args) { return _this.handleNewQuery(); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) {\n return _this.handleBuildingQuery(args);\n });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (args) {\n return _this.handleQuerySuccess(args);\n });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.duringQuery, function (args) { return _this.handleDuringQuery(); });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function (args) { return _this.handleQueryError(); });\n Dom_1.$$(this.root).on(ResultListEvents_1.ResultListEvents.changeLayout, function (e, args) { return _this.handleChangeLayout(args); });\n if (this.options.enableInfiniteScroll) {\n this.addInfiniteScrollListeners();\n }\n else {\n this.addPagerListeners();\n }\n };\n ResultList.prototype.addInfiniteScrollListeners = function () {\n var _this = this;\n this.bind.on(this.options.infiniteScrollContainer, 'scroll', function () {\n _this.successiveScrollCount = 0;\n _this.handleScrollOfResultList();\n });\n this.bind.onRootElement(QueryEvents_1.QueryEvents.deferredQuerySuccess, function () {\n setTimeout(function () {\n _this.scrollToTopIfEnabled();\n }, 0);\n });\n };\n ResultList.prototype.addPagerListeners = function () {\n var _this = this;\n this.bind.onQueryState(Model_1.MODEL_EVENTS.CHANGE_ONE, QueryStateModel_1.QUERY_STATE_ATTRIBUTES.FIRST, function () {\n _this.bind.oneRootElement(QueryEvents_1.QueryEvents.deferredQuerySuccess, function () {\n setTimeout(function () {\n _this.scrollToTopIfEnabled();\n }, 0);\n });\n });\n };\n /**\n * Get the fields needed to be automatically included in the query for this result list.\n * @returns {string[]}\n */\n ResultList.prototype.getAutoSelectedFieldsToInclude = function () {\n return underscore_1.chain(this.options.resultTemplate.getFields()).concat(this.getMinimalFieldsToInclude()).compact().unique().value();\n };\n ResultList.prototype.setupTemplatesVersusLayouts = function () {\n var _this = this;\n var layoutClassToAdd = \"coveo-\" + this.options.layout + \"-layout-container\";\n this.resultContainer.addClass(layoutClassToAdd);\n if (this.options.layout === 'table') {\n this.options.resultTemplate = new TableTemplate_1.TableTemplate(this.options.resultTemplate.templates || []);\n }\n // A TemplateList is the scenario where the result template are directly embedded inside the ResultList\n // This is the typical scenario when a page gets created by the interface editor, for example.\n // In that case, we try to stick closely that what is actually configured inside the page, and do no \"special magic\".\n // Stick to the \"hardcoded\" configuration present in the page.\n // We only add the correct layout options if it has not been set manually.\n if (this.options.resultTemplate instanceof TemplateList_1.TemplateList) {\n underscore_1.each(this.options.resultTemplate.templates, function (tmpl) {\n if (!tmpl.layout) {\n tmpl.layout = _this.options.layout;\n }\n });\n }\n else if (this.options.resultTemplate instanceof DefaultResultTemplate_1.DefaultResultTemplate && this.options.layout == 'list') {\n ResponsiveDefaultResultTemplate_1.ResponsiveDefaultResultTemplate.init(this.root, this, {});\n }\n };\n /**\n * Empties the current result list content and appends the given array of HTMLElement.\n *\n * Can append to existing elements in the result list, or replace them.\n *\n * Triggers the `newResultsDisplayed` and `newResultDisplayed` events.\n * @param resultsElement\n * @param append\n */\n ResultList.prototype.renderResults = function (resultElements, append) {\n var _this = this;\n if (append === void 0) { append = false; }\n if (!append) {\n this.resultContainer.empty();\n }\n return this.renderer\n .renderResults(resultElements, append, this.triggerNewResultDisplayed.bind(this))\n .then(function () { return _this.triggerNewResultsDisplayed(); });\n };\n /**\n * Builds and returns an array of HTMLElement with the given result set.\n * @param results the result set to build an array of HTMLElement from.\n */\n ResultList.prototype.buildResults = function (results) {\n var layout = this.options.layout;\n return this.templateToHtml.buildResults(results, layout, this.currentlyDisplayedResults);\n };\n /**\n * Builds and returns an HTMLElement for the given result.\n * @param result the result to build an HTMLElement from.\n * @returns {HTMLElement}\n */\n ResultList.prototype.buildResult = function (result) {\n var layout = this.options.layout;\n return this.templateToHtml.buildResult(result, layout, this.currentlyDisplayedResults);\n };\n /**\n * Executes a query to fetch new results. After the query returns, renders the new results.\n *\n * Asserts that there are more results to display by verifying whether the last query has returned as many results as\n * requested.\n *\n * Asserts that the `ResultList` is not currently fetching results.\n * @param count The number of results to fetch and display.\n */\n ResultList.prototype.displayMoreResults = function (count) {\n Assert_1.Assert.isLargerOrEqualsThan(1, count);\n if (this.isCurrentlyFetchingMoreResults()) {\n this.logger.warn(\"Ignoring request to display more results since we're already doing so\");\n return;\n }\n if (!this.hasPotentiallyMoreResultsToDisplay()) {\n this.logger.warn(\"Ignoring request to display more results since we know there aren't more to display\");\n return;\n }\n if (this.options.enableInfiniteScrollWaitingAnimation) {\n this.showWaitingAnimationForInfiniteScrolling();\n }\n return this.fetchAndRenderMoreResults(count);\n };\n Object.defineProperty(ResultList.prototype, \"templateToHtml\", {\n get: function () {\n var templateToHtmlArgs = {\n resultTemplate: this.options.resultTemplate,\n searchInterface: this.searchInterface,\n queryStateModel: this.queryStateModel\n };\n return new TemplateToHtml_1.TemplateToHtml(templateToHtmlArgs);\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Gets the list of currently displayed result.\n * @returns {IQueryResult[]}\n */\n ResultList.prototype.getDisplayedResults = function () {\n return this.currentlyDisplayedResults;\n };\n /**\n * Gets the list of currently displayed result HTMLElement.\n * @returns {HTMLElement[]}\n */\n ResultList.prototype.getDisplayedResultsElements = function () {\n return this.resultContainer.getResultElements();\n };\n ResultList.prototype.enable = function () {\n this.disableLayoutChange = false;\n if (this.resultLayoutSelectors.length > 0) {\n this.enableBasedOnActiveLayouts();\n }\n else {\n _super.prototype.enable.call(this);\n Dom_1.$$(this.element).removeClass('coveo-hidden');\n }\n };\n ResultList.prototype.disable = function () {\n var _this = this;\n _super.prototype.disable.call(this);\n var otherLayoutsStillActive = underscore_1.map(this.otherResultLists, function (otherResultList) { return otherResultList.options.layout; });\n if (!underscore_1.contains(otherLayoutsStillActive, this.options.layout) && !this.disableLayoutChange) {\n underscore_1.each(this.resultLayoutSelectors, function (resultLayoutSelector) {\n resultLayoutSelector.disableLayouts([_this.options.layout]);\n });\n }\n this.disableLayoutChange = false;\n Dom_1.$$(this.element).addClass('coveo-hidden');\n };\n ResultList.prototype.autoCreateComponentsInsideResult = function (element, result) {\n return this.templateToHtml.autoCreateComponentsInsideResult(element, result);\n };\n ResultList.prototype.triggerNewResultDisplayed = function (result, resultElement) {\n var args = {\n result: result,\n item: resultElement\n };\n Dom_1.$$(this.element).trigger(ResultListEvents_1.ResultListEvents.newResultDisplayed, args);\n };\n ResultList.prototype.triggerNewResultsDisplayed = function () {\n var args = {\n isInfiniteScrollEnabled: this.options.enableInfiniteScroll\n };\n Dom_1.$$(this.element).trigger(ResultListEvents_1.ResultListEvents.newResultsDisplayed, args);\n };\n ResultList.prototype.fetchAndRenderMoreResults = function (count) {\n return __awaiter(this, void 0, void 0, function () {\n var data, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.fetchingMoreResults = this.queryController.fetchMore(count);\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.fetchingMoreResults];\n case 2:\n data = _a.sent();\n Assert_1.Assert.exists(data);\n this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.pagerScrolling, {}, this.element);\n this.reachedTheEndOfResults = count > data.results.length;\n this.renderNewResults(data);\n this.resetStateAfterFetchingMoreResults();\n return [2 /*return*/, data];\n case 3:\n e_1 = _a.sent();\n this.resetStateAfterFetchingMoreResults();\n return [2 /*return*/, Promise.reject(e_1)];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n ResultList.prototype.renderNewResults = function (data) {\n return __awaiter(this, void 0, void 0, function () {\n var elements, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0: return [4 /*yield*/, this.buildResults(data)];\n case 1:\n elements = _b.sent();\n this.renderResults(elements, true);\n (_a = this.currentlyDisplayedResults).push.apply(_a, data.results);\n this.triggerNewResultsDisplayed();\n return [2 /*return*/];\n }\n });\n });\n };\n ResultList.prototype.resetStateAfterFetchingMoreResults = function () {\n var _this = this;\n this.hideWaitingAnimationForInfiniteScrolling();\n this.fetchingMoreResults = undefined;\n Defer_1.Defer.defer(function () {\n _this.successiveScrollCount++;\n if (_this.successiveScrollCount <= ResultList.MAX_AMOUNT_OF_SUCESSIVE_REQUESTS) {\n _this.handleScrollOfResultList();\n }\n else {\n _this.logger.info(\"Result list has triggered 5 consecutive queries to try and fill up the scrolling container, but it is still unable to do so.\\n Try explicitly setting the 'data-infinite-scroll-container-selector' option on the result list. See: https://coveo.github.io/search-ui/components/resultlist.html#options.infinitescrollcontainer\");\n }\n });\n };\n ResultList.prototype.handleDuringQuery = function () {\n this.logger.trace('Emptying the result container');\n this.cancelFetchingMoreResultsIfNeeded();\n this.showWaitingAnimation();\n this.showOrHideElementsDependingOnState(false, false);\n };\n ResultList.prototype.handleQueryError = function () {\n this.hideWaitingAnimation();\n this.resultContainer.empty();\n this.currentlyDisplayedResults = [];\n this.reachedTheEndOfResults = true;\n };\n ResultList.prototype.handleQuerySuccess = function (data) {\n var _this = this;\n Assert_1.Assert.exists(data);\n Assert_1.Assert.exists(data.results);\n var results = data.results;\n this.logger.trace('Received query results from new query', results);\n this.hideWaitingAnimation();\n ResultList.resultCurrentlyBeingRendered = undefined;\n this.reachedTheEndOfResults = data.query.numberOfResults > data.results.results.length;\n this.currentlyDisplayedResults = [];\n this.buildResults(data.results).then(function (elements) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.renderResults(elements)];\n case 1:\n _a.sent();\n this.showOrHideElementsDependingOnState(true, this.currentlyDisplayedResults.length != 0);\n if (DeviceUtils_1.DeviceUtils.isMobileDevice() && this.options.mobileScrollContainer != undefined) {\n this.options.mobileScrollContainer.scrollTop = 0;\n }\n if (this.options.enableInfiniteScroll && results.results.length == data.queryBuilder.numberOfResults) {\n // This will check right away if we need to add more results to make the scroll container full & scrolling.\n this.scrollToTopIfEnabled();\n this.handleScrollOfResultList();\n }\n return [2 /*return*/];\n }\n });\n }); });\n };\n ResultList.prototype.handleScrollOfResultList = function () {\n if (this.isCurrentlyFetchingMoreResults() || !this.options.enableInfiniteScroll) {\n return;\n }\n if (this.isScrollingOfResultListAlmostAtTheBottom() && this.hasPotentiallyMoreResultsToDisplay()) {\n this.displayMoreResults(this.options.infiniteScrollPageSize);\n }\n };\n ResultList.prototype.scrollToTopIfEnabled = function () {\n if (!this.options.enableScrollToTop) {\n return;\n }\n ResultListUtils_1.ResultListUtils.scrollToTop(this.root);\n };\n ResultList.prototype.handleNewQuery = function () {\n Dom_1.$$(this.element).removeClass('coveo-hidden');\n ResultList.resultCurrentlyBeingRendered = undefined;\n };\n Object.defineProperty(ResultList.prototype, \"otherResultLists\", {\n get: function () {\n var allResultLists = this.searchInterface.getComponents(ResultList.ID);\n return underscore_1.without(allResultLists, this);\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(ResultList.prototype, \"resultLayoutSelectors\", {\n get: function () {\n return this.searchInterface.getComponents('ResultLayoutSelector');\n },\n enumerable: true,\n configurable: true\n });\n ResultList.prototype.handleBuildingQuery = function (args) {\n if (this.options.fieldsToInclude != null) {\n // remove the @\n args.queryBuilder.addFieldsToInclude(underscore_1.map(this.options.fieldsToInclude, function (field) { return field.substr(1); }));\n }\n if (this.options.autoSelectFieldsToInclude) {\n var otherFields = underscore_1.flatten(underscore_1.map(this.otherResultLists, function (otherResultList) {\n return otherResultList.getAutoSelectedFieldsToInclude();\n }));\n args.queryBuilder.addRequiredFields(underscore_1.unique(otherFields.concat(this.getAutoSelectedFieldsToInclude())));\n args.queryBuilder.includeRequiredFields = true;\n }\n };\n ResultList.prototype.handleChangeLayout = function (args) {\n var _this = this;\n if (args.layout === this.options.layout) {\n this.disableLayoutChange = false;\n this.enable();\n this.options.resultTemplate.layout = this.options.layout;\n if (args.results) {\n // Prevent flickering when switching to a new layout that is empty\n // add a temporary placeholder, the same that is used on initialization\n if (this.resultContainer.isEmpty()) {\n new InitializationPlaceholder_1.InitializationPlaceholder(this.root).withVisibleRootElement().withPlaceholderForResultList();\n }\n Defer_1.Defer.defer(function () { return __awaiter(_this, void 0, void 0, function () {\n var elements;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.buildResults(args.results)];\n case 1:\n elements = _a.sent();\n this.renderResults(elements);\n this.showOrHideElementsDependingOnState(true, this.currentlyDisplayedResults.length !== 0);\n return [2 /*return*/];\n }\n });\n }); });\n }\n }\n else {\n this.disableLayoutChange = true;\n this.disable();\n this.resultContainer.empty();\n }\n };\n ResultList.prototype.isCurrentlyFetchingMoreResults = function () {\n return Utils_1.Utils.exists(this.fetchingMoreResults);\n };\n ResultList.prototype.getMinimalFieldsToInclude = function () {\n // these fields are needed for analytics click event\n return ['author', 'language', 'urihash', 'objecttype', 'collection', 'source', 'language', 'permanentid'];\n };\n ResultList.prototype.isScrollingOfResultListAlmostAtTheBottom = function () {\n // this is in a try catch because the unit test fail otherwise (Window does not exist for phantom js in the console)\n var isWindow;\n try {\n isWindow = this.options.infiniteScrollContainer instanceof Window;\n }\n catch (e) {\n isWindow = false;\n }\n return isWindow ? this.isScrollAtBottomForWindowElement() : this.isScrollAtBottomForHtmlElement();\n };\n ResultList.prototype.isScrollAtBottomForWindowElement = function () {\n var win = new Dom_1.Win(window);\n var windowHeight = win.height();\n var scrollTop = win.scrollY();\n var bodyHeight = new Dom_1.Doc(document).height();\n return bodyHeight - (windowHeight + scrollTop) < windowHeight / 2;\n };\n ResultList.prototype.isScrollAtBottomForHtmlElement = function () {\n var el = this.options.infiniteScrollContainer;\n var elementHeight = el.clientHeight;\n var scrollHeight = el.scrollHeight;\n var bottomPosition = el.scrollTop + elementHeight;\n return scrollHeight - bottomPosition < elementHeight / 2;\n };\n ResultList.prototype.hasPotentiallyMoreResultsToDisplay = function () {\n return this.currentlyDisplayedResults.length > 0 && !this.reachedTheEndOfResults;\n };\n ResultList.prototype.cancelFetchingMoreResultsIfNeeded = function () {\n if (this.isCurrentlyFetchingMoreResults()) {\n this.logger.trace('Cancelling fetching more results');\n Promise.reject(this.fetchingMoreResults);\n this.fetchingMoreResults = undefined;\n }\n };\n ResultList.prototype.showOrHideElementsDependingOnState = function (hasQuery, hasResults) {\n var showIfQuery = Dom_1.$$(this.element).findAll('.coveo-show-if-query');\n var showIfNoQuery = Dom_1.$$(this.element).findAll('.coveo-show-if-no-query');\n var showIfResults = Dom_1.$$(this.element).findAll('.coveo-show-if-results');\n var showIfNoResults = Dom_1.$$(this.element).findAll('.coveo-show-if-no-results');\n underscore_1.each(showIfQuery, function (s) {\n Dom_1.$$(s).toggle(hasQuery);\n });\n underscore_1.each(showIfNoQuery, function (s) {\n Dom_1.$$(s).toggle(!hasQuery);\n });\n underscore_1.each(showIfResults, function (s) {\n Dom_1.$$(s).toggle(hasQuery && hasResults);\n });\n underscore_1.each(showIfNoResults, function (s) {\n Dom_1.$$(s).toggle(hasQuery && !hasResults);\n });\n };\n Object.defineProperty(ResultList.prototype, \"waitAnimation\", {\n get: function () {\n return this.options.waitAnimation.toLowerCase();\n },\n enumerable: true,\n configurable: true\n });\n ResultList.prototype.showWaitingAnimation = function () {\n switch (this.waitAnimation) {\n case 'fade':\n Dom_1.$$(this.options.waitAnimationContainer).addClass('coveo-fade-out');\n break;\n case 'spinner':\n this.resultContainer.hideChildren();\n if (Dom_1.$$(this.options.waitAnimationContainer).find('.coveo-wait-animation') == undefined) {\n this.options.waitAnimationContainer.appendChild(DomUtils_1.DomUtils.getBasicLoadingAnimation());\n }\n break;\n }\n };\n ResultList.prototype.hideWaitingAnimation = function () {\n switch (this.waitAnimation) {\n case 'fade':\n Dom_1.$$(this.options.waitAnimationContainer).removeClass('coveo-fade-out');\n break;\n case 'spinner':\n var spinner = Dom_1.$$(this.options.waitAnimationContainer).find('.coveo-loading-spinner');\n if (spinner) {\n Dom_1.$$(spinner).detach();\n }\n break;\n }\n };\n ResultList.prototype.showWaitingAnimationForInfiniteScrolling = function () {\n var spinner = DomUtils_1.DomUtils.getLoadingSpinner();\n if (this.options.layout == 'card' && this.options.enableInfiniteScroll) {\n var previousSpinnerContainer = Dom_1.$$(this.options.waitAnimationContainer).findAll('.coveo-loading-spinner-container');\n underscore_1.each(previousSpinnerContainer, function (previousSpinner) { return Dom_1.$$(previousSpinner).remove(); });\n var spinnerContainer = Dom_1.$$('div', {\n className: 'coveo-loading-spinner-container'\n });\n spinnerContainer.append(spinner);\n this.options.waitAnimationContainer.appendChild(spinnerContainer.el);\n }\n else {\n this.options.waitAnimationContainer.appendChild(DomUtils_1.DomUtils.getLoadingSpinner());\n }\n };\n ResultList.prototype.hideWaitingAnimationForInfiniteScrolling = function () {\n var spinners = Dom_1.$$(this.options.waitAnimationContainer).findAll('.coveo-loading-spinner');\n var containers = Dom_1.$$(this.options.waitAnimationContainer).findAll('.coveo-loading-spinner-container');\n underscore_1.each(spinners, function (spinner) { return Dom_1.$$(spinner).remove(); });\n underscore_1.each(containers, function (container) { return Dom_1.$$(container).remove(); });\n };\n ResultList.prototype.initResultContainer = function () {\n if (!this.options.resultsContainer) {\n var elemType = this.options.layout === 'table' ? 'table' : 'div';\n this.options.resultsContainer = Dom_1.$$(elemType, { className: 'coveo-result-list-container' }).el;\n this.initResultContainerAddToDom();\n }\n return new ResultContainer_1.ResultContainer(this.options.resultsContainer, this.searchInterface);\n };\n ResultList.prototype.initResultContainerAddToDom = function () {\n this.element.appendChild(this.options.resultsContainer);\n };\n ResultList.prototype.initWaitAnimationContainer = function () {\n if (!this.options.waitAnimationContainer) {\n this.options.waitAnimationContainer = this.resultContainer.el;\n }\n };\n ResultList.prototype.setupRenderer = function () {\n var initParameters = {\n options: this.searchInterface.options.originalOptionsObject,\n bindings: this.bindings\n };\n var autoCreateComponentsFn = function (elem) { return Initialization_1.Initialization.automaticallyCreateComponentsInside(elem, initParameters); };\n switch (this.options.layout) {\n case 'card':\n this.renderer = new ResultListCardRenderer_1.ResultListCardRenderer(this.options, autoCreateComponentsFn);\n break;\n case 'table':\n this.renderer = new ResultListTableRenderer_1.ResultListTableRenderer(this.options, autoCreateComponentsFn);\n break;\n case 'list':\n default:\n this.renderer = new ResultListRenderer_1.ResultListRenderer(this.options, autoCreateComponentsFn);\n break;\n }\n };\n ResultList.prototype.makeElementFocusable = function () {\n Dom_1.$$(this.element).setAttribute('tabindex', '-1');\n };\n ResultList.prototype.ensureHasId = function () {\n var currentId = this.element.id;\n if (currentId === '') {\n this.element.id = underscore_1.uniqueId('coveo-result-list');\n }\n };\n ResultList.prototype.enableBasedOnActiveLayouts = function () {\n var _this = this;\n // We should try to enable a result list only when the result layout selector currently allow that result list layout to be displayed.\n underscore_1.each(this.resultLayoutSelectors, function (resultLayoutSelector) {\n var found = underscore_1.find(resultLayoutSelector.activeLayouts, function (activeLayout, activeLayoutKey) { return activeLayoutKey == _this.options.layout; });\n if (found) {\n _super.prototype.enable.call(_this);\n resultLayoutSelector.enableLayouts([_this.options.layout]);\n Dom_1.$$(_this.element).removeClass('coveo-hidden');\n }\n });\n };\n ResultList.ID = 'ResultList';\n ResultList.doExport = function () {\n GlobalExports_1.exportGlobally({\n ResultList: ResultList\n });\n };\n /**\n * The options for the ResultList\n * @componentOptions\n */\n ResultList.options = {\n /**\n * The element inside which to insert the rendered result templates.\n *\n * Performing a new query clears the content of this element.\n *\n * You can change the container by specifying its selector (e.g.,\n * `data-result-container-selector='#someCssSelector'`).\n *\n * If you specify no value for this option, a `div` element will be dynamically created and appended to the result\n * list. This element will then be used as a result container.\n */\n resultsContainer: ComponentOptions_1.ComponentOptions.buildChildHtmlElementOption({ alias: 'resultContainerSelector' }),\n resultTemplate: TemplateComponentOptions_1.TemplateComponentOptions.buildTemplateOption({ defaultFunction: ResultList.getDefaultTemplate }),\n /**\n * The type of animation to display while waiting for a query to return.\n *\n * The possible values are:\n * - `fade`: Fades out the current list of results while the query is executing.\n * - `spinner`: Shows a spinning animation while the query is executing.\n * - `none`: Use no animation during queries.\n *\n * See also the [`waitAnimationContainer`]{@link ResultList.options.waitAnimationContainer} option.\n *\n * @examples spinner\n */\n waitAnimation: ComponentOptions_1.ComponentOptions.buildStringOption({ defaultValue: 'none' }),\n /**\n * The element inside which to display the [`waitAnimation`]{@link ResultList.options.waitAnimation}.\n *\n * You can change this by specifying a CSS selector (e.g.,\n * `data-wait-animation-container-selector='#someCssSelector'`).\n *\n * Defaults to the value of the [`resultsContainer`]{@link ResultList.options.resultsContainer} option.\n */\n waitAnimationContainer: ComponentOptions_1.ComponentOptions.buildChildHtmlElementOption({\n postProcessing: function (value, options) { return value || options.resultsContainer; }\n }),\n /**\n * Whether to automatically retrieve an additional page of results and append it to the\n * results that the `ResultList` is currently displaying when the user scrolls down to the bottom of the\n * [`infiniteScrollContainer`]{@link ResultList.options.infiniteScrollContainer}.\n *\n * See also the [`infiniteScrollPageSize`]{@link ResultList.options.infiniteScrollPageSize} and\n * [`enableInfiniteScrollWaitingAnimation`]{@link ResultList.options.enableInfiniteScrollWaitingAnimation} options.\n *\n * It is important to specify the `infiniteScrollContainer` option manually if you want the scrolling element to be\n * something else than the default `window` element. Otherwise, you might find yourself in a strange state where the\n * framework rapidly triggers multiple successive query.\n */\n enableInfiniteScroll: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * The number of additional results to fetch when the user scrolls down to the bottom of the\n * [`infiniteScrollContainer`]{@link ResultList.options.infiniteScrollContainer}.\n *\n * @examples 5\n */\n infiniteScrollPageSize: ComponentOptions_1.ComponentOptions.buildNumberOption({\n defaultValue: 10,\n min: 1,\n depend: 'enableInfiniteScroll'\n }),\n /**\n * The element that triggers fetching additional results when the end user scrolls down to its bottom.\n *\n * You can change the container by specifying its selector (e.g.,\n * `data-infinite-scroll-container-selector='#someCssSelector'`).\n *\n * By default, the framework uses the first vertically scrollable parent element it finds, starting from the\n * `ResultList` element itself. A vertically scrollable element is an element whose CSS `overflow-y` attribute is\n * `scroll`.\n *\n * This implies that if the framework can find no scrollable parent, it uses the `window` itself as a scrollable\n * container.\n *\n * This heuristic is not perfect, for technical reasons. There are always some corner case CSS combination which the\n * framework will not be able to correctly detect as 'scrollable'.\n *\n * It is highly recommended that you manually set this option if you wish something else than the `window` to be the\n * scrollable element.\n */\n infiniteScrollContainer: ComponentOptions_1.ComponentOptions.buildChildHtmlElementOption({\n depend: 'enableInfiniteScroll',\n defaultFunction: function (element) { return ComponentOptions_1.ComponentOptions.findParentScrolling(element); }\n }),\n /**\n * Whether to display the [`waitingAnimation`]{@link ResultList.options.waitAnimation} while fetching additional\n * results.\n */\n enableInfiniteScrollWaitingAnimation: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n depend: 'enableInfiniteScroll',\n defaultValue: true\n }),\n mobileScrollContainer: ComponentOptions_1.ComponentOptions.buildSelectorOption({\n defaultFunction: function () { return document.querySelector('.coveo-results-column'); }\n }),\n /**\n * Whether the `ResultList` should scan its result templates to discover which fields it must request to\n * be able to render all results.\n *\n * Setting this option to `true` ensures that the Coveo Search API does not return fields that are unnecessary for\n * the UI to function.\n *\n * If you set this option to `true`, the fields referenced in your result folding templates won't be automatically resolved.\n * In such a case, you must manually specify those fields using the [`fieldsToInclude`]{@link ResultList.options.fieldsToInclude} option.\n *\n * **Notes:**\n *\n * - Many interfaces created with the JavaScript Search Interface Editor explicitly set this option to `true`.\n * - You cannot set this option to `true` in the Coveo for Sitecore integration.\n */\n autoSelectFieldsToInclude: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * A list of fields to include in the query results.\n *\n * If you set the [`autoSelectFieldsToInclude`]{@link ResultList.options.autoSelectFieldsToInclude} option to\n * `true`, the Coveo Search API returns the fields you specify for this option (if those fields are available) in\n * addition to the fields which the `ResultList` automatically requests. Note that the `autoSelectFieldsToInclude`\n * option doesn't automatically request fields for folding templates; in such a case, you must manually specify\n * fields using this option to avoid empty results.\n *\n * If you set the [`autoSelectFieldsToInclude`]{@link ResultList.options.autoSelectFieldsToInclude} option to\n * `false`, the Coveo Search API only returns the fields you specify for this option (if those fields are\n * available).\n *\n * If you set the [`autoSelectFieldsToInclude`]{@link ResultList.options.autoSelectFieldsToInclude} option to\n * `false` and leave this option undefined, the Coveo Search API returns all available fields.\n */\n fieldsToInclude: ComponentOptions_1.ComponentOptions.buildFieldsOption({ includeInResults: true }),\n /**\n * Specifies the layout to use when displaying results in this `ResultList` (see\n * [Result Layouts](https://docs.coveo.com/en/360/)). Specifying a value for this option automatically\n * populates a [`ResultLayout`]{@link ResultLayout} component with a switcher for the layout.\n *\n * For example, if there are two `ResultList` components in the page, one with its `layout` set to `list` and the\n * other with the same option set to `card`, then the `ResultLayout` component will render two buttons respectively\n * entitled **List** and **Card**.\n *\n * See the [`ValidLayout`]{@link ValidLayout} type for the list of possible values.\n *\n * @examples card\n */\n layout: ComponentOptions_1.ComponentOptions.buildStringOption({\n defaultValue: 'list',\n required: true\n }),\n /**\n * Whether to scroll back to the top of the page when the end-user:\n * - interacts with a facet when [`infiniteScrollContainer`]{@link ResultList.options.infiniteScrollContainer} is set to `true`\n * - interacts with the [`Pager`]{@link Pager} component when [`infiniteScrollContainer`]{@link ResultList.options.infiniteScrollContainer} is set to `false`\n *\n * **Note:** Setting this option to `false` has no effect on dynamic facets. To disable this behavior on a `DynamicFacet` component, you must set its own [`enableScrollToTop`]{@link DynamicFacet.options.enableScrollToTop} option to `false`.\n *\n * @availablesince [July 2019 Release (v2.6459)](https://docs.coveo.com/en/2938/)\n */\n enableScrollToTop: ComponentOptions_1.ComponentOptions.buildBooleanOption({\n defaultValue: true\n })\n };\n ResultList.resultCurrentlyBeingRendered = null;\n ResultList.MAX_AMOUNT_OF_SUCESSIVE_REQUESTS = 5;\n return ResultList;\n}(Component_1.Component));\nexports.ResultList = ResultList;\nInitialization_1.Initialization.registerAutoCreateComponent(ResultList);\n\n\n/***/ }),\n\n/***/ 94:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Component_1 = __webpack_require__(7);\nvar Strings_1 = __webpack_require__(6);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Dom_1 = __webpack_require__(1);\nvar Initialization_1 = __webpack_require__(2);\nvar GlobalExports_1 = __webpack_require__(3);\nvar CategoryFacetTemplates_1 = __webpack_require__(547);\nvar CategoryValueRoot_1 = __webpack_require__(548);\nvar CategoryFacetQueryController_1 = __webpack_require__(550);\nvar SVGDom_1 = __webpack_require__(16);\nvar SVGIcons_1 = __webpack_require__(12);\nvar QueryStateModel_1 = __webpack_require__(13);\n__webpack_require__(551);\nvar Model_1 = __webpack_require__(18);\nvar Utils_1 = __webpack_require__(4);\nvar underscore_1 = __webpack_require__(0);\nvar Assert_1 = __webpack_require__(5);\nvar QueryEvents_1 = __webpack_require__(11);\nvar CategoryFacetSearch_1 = __webpack_require__(552);\nvar BreadcrumbEvents_1 = __webpack_require__(35);\nvar CategoryFacetBreadcrumb_1 = __webpack_require__(554);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar CategoryFacetDebug_1 = __webpack_require__(555);\nvar QueryBuilder_1 = __webpack_require__(49);\nvar ResponsiveFacets_1 = __webpack_require__(175);\nvar ResponsiveFacetOptions_1 = __webpack_require__(85);\nvar CategoryFacetHeader_1 = __webpack_require__(556);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar DependsOnManager_1 = __webpack_require__(174);\nvar ResultListUtils_1 = __webpack_require__(117);\nvar CategoryFacetValuesTree_1 = __webpack_require__(557);\n/**\n * The `CategoryFacet` component is a facet that renders values in a hierarchical fashion. It determines the filter to apply depending on the\n * current selected path of values.\n *\n * The path is a sequence of values that leads to a specific value in the hierarchy.\n * It is an array listing all the parents of a file (e.g., `['c', 'folder1']` for the `c:\\folder1\\text1.txt` file).\n *\n * This facet requires a [`field`]{@link CategoryFacet.options.field} with a special format to work correctly (see [Using the Category Facet Component](https://docs.coveo.com/en/2667)).\n *\n * @notSupportedIn salesforcefree\n * @availablesince [January 2019 Release (v2.5395.12)](https://docs.coveo.com/en/3277/#january-2019-release-v2539512)\n */\nvar CategoryFacet = /** @class */ (function (_super) {\n __extends(CategoryFacet, _super);\n function CategoryFacet(element, options, bindings) {\n var _this = _super.call(this, element, 'CategoryFacet', bindings) || this;\n _this.element = element;\n _this.options = options;\n _this.listenToQueryStateChange = true;\n _this.isFieldValueCompatible = false;\n _this.moreValuesToFetch = true;\n _this.showingWaitAnimation = false;\n _this.numberOfChildValuesCurrentlyDisplayed = 0;\n _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, CategoryFacet, options);\n _this.categoryFacetQueryController = new CategoryFacetQueryController_1.CategoryFacetQueryController(_this);\n _this.categoryFacetTemplates = new CategoryFacetTemplates_1.CategoryFacetTemplates();\n _this.categoryValueRoot = new CategoryValueRoot_1.CategoryValueRoot(Dom_1.$$(_this.element), _this.categoryFacetTemplates, _this);\n _this.categoryValueRoot.path = _this.activePath;\n _this.currentPage = 0;\n _this.numberOfValues = _this.options.numberOfValues;\n _this.categoryFacetValuesTree = new CategoryFacetValuesTree_1.CategoryFacetValuesTree();\n _this.tryToInitFacetSearch();\n if (_this.options.debug) {\n new CategoryFacetDebug_1.CategoryFacetDebug(_this);\n }\n ResponsiveFacets_1.ResponsiveFacets.init(_this.root, _this, _this.options);\n _this.initDependsOnManager();\n _this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); });\n _this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (args) { return _this.handleQuerySuccess(args); });\n _this.bind.onRootElement(QueryEvents_1.QueryEvents.duringQuery, function () { return _this.addFading(); });\n _this.bind.onRootElement(QueryEvents_1.QueryEvents.deferredQuerySuccess, function () { return _this.handleDeferredQuerySuccess(); });\n _this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.populateBreadcrumb, function (args) { return _this.handlePopulateBreadCrumb(args); });\n _this.bind.onRootElement(BreadcrumbEvents_1.BreadcrumbEvents.clearBreadcrumb, function () { return _this.handleClearBreadcrumb(); });\n _this.buildFacetHeader();\n _this.initQueryStateEvents();\n return _this;\n }\n CategoryFacet.prototype.isCurrentlyDisplayed = function () {\n return Dom_1.$$(this.element).isVisible();\n };\n Object.defineProperty(CategoryFacet.prototype, \"activePath\", {\n get: function () {\n return this.queryStateModel.get(this.queryStateAttribute) || this.options.basePath;\n },\n set: function (newPath) {\n this.listenToQueryStateChange = false;\n this.queryStateModel.set(this.queryStateAttribute, newPath);\n this.listenToQueryStateChange = true;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(CategoryFacet.prototype, \"queryStateAttribute\", {\n get: function () {\n return QueryStateModel_1.QueryStateModel.getFacetId(this.options.id);\n },\n enumerable: true,\n configurable: true\n });\n CategoryFacet.prototype.handleBuildingQuery = function (args) {\n this.positionInQuery = this.categoryFacetQueryController.putCategoryFacetInQueryBuilder(args.queryBuilder, this.activePath, this.numberOfValues + 1);\n };\n CategoryFacet.prototype.scrollToTop = function () {\n ResultListUtils_1.ResultListUtils.scrollToTop(this.root);\n };\n CategoryFacet.prototype.tryToInitFacetSearch = function () {\n if (!this.isFacetSearchAvailable) {\n return this.logDisabledFacetSearchWarning();\n }\n this.categoryFacetSearch = new CategoryFacetSearch_1.CategoryFacetSearch(this, this.options.displaySearchButton);\n };\n CategoryFacet.prototype.logDisabledFacetSearchWarning = function () {\n if (this.isEnableFacetSearchFalsy) {\n return;\n }\n var valueCaptionAttributeName = this.getOptionAttributeName('valueCaption');\n var enableFacetSearchAttributeName = this.getOptionAttributeName('enableFacetSearch');\n var field = this.options.field;\n this.logger.warn(\"The search box is disabled on the \" + field + \" CategoryFacet. To hide this warning,\\n either remove the \" + valueCaptionAttributeName + \" option or set the \" + enableFacetSearchAttributeName + \" option to \\\"false\\\".\");\n };\n CategoryFacet.prototype.getOptionAttributeName = function (optionName) {\n return ComponentOptions_1.ComponentOptions.attrNameFromName(optionName);\n };\n Object.defineProperty(CategoryFacet.prototype, \"isFacetSearchAvailable\", {\n get: function () {\n if (this.areValueCaptionsSpecified) {\n return false;\n }\n if (this.isEnableFacetSearchFalsy) {\n return false;\n }\n return true;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(CategoryFacet.prototype, \"areValueCaptionsSpecified\", {\n get: function () {\n var valueCaptions = this.options.valueCaption;\n return underscore_1.keys(valueCaptions).length !== 0;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(CategoryFacet.prototype, \"isEnableFacetSearchFalsy\", {\n get: function () {\n return !this.options.enableFacetSearch;\n },\n enumerable: true,\n configurable: true\n });\n Object.defineProperty(CategoryFacet.prototype, \"isCategoryEmpty\", {\n get: function () {\n return !this.categoryValueRoot.children.length;\n },\n enumerable: true,\n configurable: true\n });\n CategoryFacet.prototype.updateAppearance = function () {\n if (this.disabled || this.isCategoryEmpty) {\n return this.hide();\n }\n this.show();\n };\n CategoryFacet.prototype.handleQuerySuccess = function (args) {\n if (Utils_1.Utils.isNullOrUndefined(args.results.categoryFacets)) {\n return this.notImplementedError();\n }\n if (Utils_1.Utils.isNullOrUndefined(args.results.categoryFacets[this.positionInQuery])) {\n return;\n }\n var numberOfRequestedValues = args.query.categoryFacets[this.positionInQuery].maximumNumberOfValues;\n var categoryFacetResult = args.results.categoryFacets[this.positionInQuery];\n this.moreValuesToFetch = numberOfRequestedValues == categoryFacetResult.values.length;\n this.clear();\n if (categoryFacetResult.notImplemented) {\n return this.notImplementedError();\n }\n if (!categoryFacetResult.values.length && !categoryFacetResult.parentValues.length) {\n return;\n }\n this.renderValues(categoryFacetResult, numberOfRequestedValues);\n if (this.isFacetSearchAvailable) {\n var facetSearch = this.categoryFacetSearch.build();\n this.options.displaySearchOnTop\n ? Dom_1.$$(facetSearch).insertBefore(this.categoryValueRoot.listRoot.el)\n : Dom_1.$$(facetSearch).insertAfter(this.categoryValueRoot.listRoot.el);\n }\n this.moreLessContainer = Dom_1.$$('div', { className: 'coveo-category-facet-more-less-container' });\n Dom_1.$$(this.element).append(this.moreLessContainer.el);\n if (this.options.enableMoreLess) {\n this.renderMoreLess();\n }\n if (!this.isPristine()) {\n Dom_1.$$(this.element).addClass('coveo-category-facet-non-empty-path');\n }\n };\n /**\n * Changes the active path.\n *\n */\n CategoryFacet.prototype.changeActivePath = function (path) {\n this.activePath = path;\n };\n CategoryFacet.prototype.executeQuery = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.showWaitingAnimation();\n _a.label = 1;\n case 1:\n _a.trys.push([1, , 3, 4]);\n return [4 /*yield*/, this.queryController.executeQuery()];\n case 2:\n _a.sent();\n return [3 /*break*/, 4];\n case 3:\n this.hideWaitingAnimation();\n return [7 /*endfinally*/];\n case 4: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Reloads the facet with the same path.\n */\n CategoryFacet.prototype.reload = function () {\n this.changeActivePath(this.activePath);\n this.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetReload);\n this.executeQuery();\n };\n /**\n * Returns all the visible parent values.\n * @returns simple object with three fields: `value`, `count` and `path`.\n */\n CategoryFacet.prototype.getVisibleParentValues = function () {\n return this.getVisibleParentCategoryValues().map(function (categoryValue) { return categoryValue.getDescriptor(); });\n };\n CategoryFacet.prototype.getVisibleParentCategoryValues = function () {\n if (this.categoryValueRoot.children.length == 0 || this.categoryValueRoot.children[0].children.length == 0) {\n return [];\n }\n var currentParentvalue = this.categoryValueRoot.children[0];\n var parentValues = [currentParentvalue];\n while (currentParentvalue.children.length != 0 && !Utils_1.Utils.arrayEqual(currentParentvalue.path, this.activePath)) {\n currentParentvalue = currentParentvalue.children[0];\n parentValues.push(currentParentvalue);\n }\n return parentValues;\n };\n /**\n * Shows more values according to {@link CategoryFacet.options.pageSize}.\n *\n * See the [`enableMoreLess`]{@link CategoryFacet.options.enableMoreLess}, and\n * [`numberOfValues`]{@link CategoryFacet.options.numberOfValues} options.\n */\n CategoryFacet.prototype.showMore = function () {\n if (this.moreValuesToFetch) {\n this.currentPage++;\n this.numberOfValues = this.options.numberOfValues + this.currentPage * this.options.pageSize;\n this.reload();\n this.logAnalyticsFacetShowMoreLess(AnalyticsActionListMeta_1.analyticsActionCauseList.facetShowMore);\n }\n };\n /**\n * Shows less values, up to the original number of values.\n *\n * See the [`enableMoreLess`]{@link CategoryFacet.options.enableMoreLess}, and\n * [`numberOfValues`]{@link CategoryFacet.options.numberOfValues} options.\n */\n CategoryFacet.prototype.showLess = function () {\n if (this.currentPage > 0) {\n this.currentPage--;\n this.numberOfValues = this.options.numberOfValues + this.currentPage * this.options.pageSize;\n this.reload();\n this.logAnalyticsFacetShowMoreLess(AnalyticsActionListMeta_1.analyticsActionCauseList.facetShowLess);\n }\n };\n /**\n * Returns the values at the bottom of the hierarchy. These are the values that are not yet applied to the query.\n * @returns simple object with three fields: `value`, `count` and `path`.\n */\n CategoryFacet.prototype.getAvailableValues = function () {\n if (!this.activeCategoryValue) {\n return [];\n }\n return this.activeCategoryValue.children.map(function (categoryValue) {\n return {\n value: categoryValue.categoryValueDescriptor.value,\n count: categoryValue.categoryValueDescriptor.count,\n path: categoryValue.path\n };\n });\n };\n /**\n * Selects a value from the currently available values.\n * If the given value to select is not in the available values, it will throw an error.\n */\n CategoryFacet.prototype.selectValue = function (value) {\n Assert_1.Assert.check(underscore_1.contains(underscore_1.pluck(this.getAvailableValues(), 'value'), value), 'Failed while trying to select a value that is not available.');\n var newPath = this.activePath.slice(0);\n newPath.push(value);\n this.changeActivePath(newPath);\n this.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSelect);\n this.executeQuery();\n };\n /**\n * Deselects the last value in the hierarchy that is applied to the query. When at the top of the hierarchy, this method does nothing.\n */\n CategoryFacet.prototype.deselectCurrentValue = function () {\n if (this.activePath.length == 0) {\n return;\n }\n var newPath = this.activePath.slice(0);\n newPath.pop();\n this.changeActivePath(newPath);\n this.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetSelect);\n this.executeQuery();\n };\n CategoryFacet.prototype.resetPath = function () {\n this.changeActivePath(this.options.basePath);\n };\n /**\n * Resets the facet to its initial state.\n */\n CategoryFacet.prototype.reset = function () {\n this.resetPath();\n this.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.categoryFacetClear);\n this.executeQuery();\n };\n /**\n * Hides the component.\n */\n CategoryFacet.prototype.hide = function () {\n Dom_1.$$(this.element).addClass('coveo-hidden');\n };\n /**\n * Shows the component.\n */\n CategoryFacet.prototype.show = function () {\n Dom_1.$$(this.element).removeClass('coveo-hidden');\n };\n CategoryFacet.prototype.enable = function () {\n _super.prototype.enable.call(this);\n this.updateAppearance();\n };\n CategoryFacet.prototype.disable = function () {\n _super.prototype.disable.call(this);\n this.updateAppearance();\n };\n /**\n * Goes through any value that contains the value parameter, and verifies whether there are missing parents.\n * Issues are then logged in the console.\n * If you do not want to specify a value, you can simply enable {@link CategoryFacet.options.debug} and do an empty query.\n */\n CategoryFacet.prototype.debugValue = function (value) {\n return __awaiter(this, void 0, void 0, function () {\n var queryBuilder, queryResults;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n queryBuilder = new QueryBuilder_1.QueryBuilder();\n this.categoryFacetQueryController.addDebugGroupBy(queryBuilder, value);\n return [4 /*yield*/, this.queryController.getEndpoint().search(queryBuilder.build())];\n case 1:\n queryResults = _a.sent();\n CategoryFacetDebug_1.CategoryFacetDebug.analyzeResults(queryResults.groupByResults[0], this.options.delimitingCharacter);\n return [2 /*return*/];\n }\n });\n });\n };\n /**\n *\n * @param value The string to find a caption for.\n * Returns the caption for a value or the value itself if no caption is available.\n */\n CategoryFacet.prototype.getCaption = function (value) {\n var valueCaptions = this.options.valueCaption;\n var caption = valueCaptions[value];\n return caption ? caption : value;\n };\n CategoryFacet.prototype.showWaitingAnimation = function () {\n this.ensureDom();\n if (!this.showingWaitAnimation) {\n Dom_1.$$(this.headerElement).find('.coveo-category-facet-header-wait-animation').style.visibility = 'visible';\n this.showingWaitAnimation = true;\n }\n };\n CategoryFacet.prototype.hideWaitingAnimation = function () {\n this.ensureDom();\n if (this.showingWaitAnimation) {\n Dom_1.$$(this.headerElement).find('.coveo-category-facet-header-wait-animation').style.visibility = 'hidden';\n this.showingWaitAnimation = false;\n }\n };\n CategoryFacet.prototype.logAnalyticsEvent = function (eventName, path) {\n if (path === void 0) { path = this.activePath; }\n this.usageAnalytics.logSearchEvent(eventName, {\n categoryFacetId: this.options.id,\n categoryFacetField: this.options.field.toString(),\n categoryFacetPath: path,\n categoryFacetTitle: this.options.title\n });\n };\n CategoryFacet.prototype.getEndpoint = function () {\n return this.queryController.getEndpoint();\n };\n Object.defineProperty(CategoryFacet.prototype, \"children\", {\n get: function () {\n return this.categoryValueRoot.children;\n },\n enumerable: true,\n configurable: true\n });\n CategoryFacet.prototype.renderValues = function (categoryFacetResult, numberOfRequestedValues) {\n this.categoryFacetValuesTree.storeNewValues(categoryFacetResult);\n var sortedParentValues = this.sortParentValues(categoryFacetResult.parentValues);\n var currentParentValue = this.categoryValueRoot;\n var needToTruncate = false;\n var pathOfLastTruncatedParentValue;\n var numberOfItemsInFirstSlice = Math.floor(CategoryFacet.NUMBER_OF_VALUES_TO_KEEP_AFTER_TRUNCATING / 2);\n var numberOfItemsInSecondSlice = Math.ceil(CategoryFacet.NUMBER_OF_VALUES_TO_KEEP_AFTER_TRUNCATING / 2);\n sortedParentValues = this.hideBasePathInParentValues(sortedParentValues);\n if (this.shouldTruncate(sortedParentValues)) {\n pathOfLastTruncatedParentValue = this.findPathOfLastTruncatedParentValue(sortedParentValues, numberOfItemsInSecondSlice);\n needToTruncate = true;\n sortedParentValues = underscore_1.first(sortedParentValues, numberOfItemsInFirstSlice).concat(underscore_1.last(sortedParentValues, numberOfItemsInSecondSlice));\n }\n if (!this.isPristine()) {\n this.addAllCategoriesButton();\n }\n for (var i = 0; i < sortedParentValues.length; i++) {\n currentParentValue = currentParentValue.renderAsParent(sortedParentValues[i]);\n // We do not want to make the \"last\" parent selectable, as clicking it would be a noop (re-selecting the same filter)\n var isLastParent = i == sortedParentValues.length - 1;\n if (!isLastParent) {\n currentParentValue.makeSelectable().showCollapseArrow();\n }\n if (needToTruncate) {\n if (i == numberOfItemsInFirstSlice - 1) {\n this.addEllipsis();\n }\n if (i == numberOfItemsInFirstSlice) {\n currentParentValue.path = pathOfLastTruncatedParentValue.concat([sortedParentValues[i].value]);\n }\n }\n }\n var childrenValuesToRender = this.moreValuesToFetch\n ? categoryFacetResult.values.slice(0, numberOfRequestedValues - 1)\n : categoryFacetResult.values.slice(0, numberOfRequestedValues);\n this.numberOfChildValuesCurrentlyDisplayed = childrenValuesToRender.length;\n currentParentValue.renderChildren(childrenValuesToRender);\n this.activeCategoryValue = currentParentValue;\n };\n CategoryFacet.prototype.hideBasePathInParentValues = function (parentValues) {\n if (Utils_1.Utils.arrayEqual(underscore_1.first(this.activePath, this.options.basePath.length), this.options.basePath)) {\n parentValues = underscore_1.last(parentValues, parentValues.length - this.options.basePath.length);\n }\n return parentValues;\n };\n CategoryFacet.prototype.shouldTruncate = function (parentValues) {\n return parentValues.length > CategoryFacet.MAXIMUM_NUMBER_OF_VALUES_BEFORE_TRUNCATING;\n };\n CategoryFacet.prototype.addEllipsis = function () {\n this.categoryValueRoot.listRoot.append(this.categoryFacetTemplates.buildEllipsis().el);\n };\n CategoryFacet.prototype.findPathOfLastTruncatedParentValue = function (sortedParentValues, numberOfItemsInSecondSlice) {\n var indexOfLastTruncatedParentValue = sortedParentValues.length - numberOfItemsInSecondSlice - 1;\n return underscore_1.reduce(underscore_1.first(sortedParentValues, indexOfLastTruncatedParentValue + 1), function (path, parentValue) { return path.concat([parentValue.value]); }, []);\n };\n CategoryFacet.prototype.addAllCategoriesButton = function () {\n var _this = this;\n var allCategories = this.categoryFacetTemplates.buildAllCategoriesButton();\n new AccessibleButton_1.AccessibleButton()\n .withLabel(Strings_1.l('AllCategories'))\n .withElement(allCategories)\n .withSelectAction(function () {\n _this.reset();\n _this.scrollToTop();\n })\n .build();\n this.categoryValueRoot.listRoot.append(allCategories.el);\n };\n CategoryFacet.prototype.isPristine = function () {\n return Utils_1.Utils.arrayEqual(this.activePath, this.options.basePath);\n };\n CategoryFacet.prototype.buildFacetHeader = function () {\n var facetHeader = new CategoryFacetHeader_1.CategoryFacetHeader({ categoryFacet: this, title: this.options.title });\n this.headerElement = facetHeader.build();\n Dom_1.$$(this.element).prepend(this.headerElement);\n };\n CategoryFacet.prototype.handleQueryStateChanged = function (data) {\n if (this.listenToQueryStateChange) {\n var path = data.attributes[this.queryStateAttribute];\n if (!Utils_1.Utils.isNullOrUndefined(path) && underscore_1.isArray(path) && path.length != 0) {\n this.activePath = path;\n }\n }\n };\n CategoryFacet.prototype.initQueryStateEvents = function () {\n var _this = this;\n this.queryStateModel.registerNewAttribute(this.queryStateAttribute, this.options.basePath);\n this.bind.onQueryState(Model_1.MODEL_EVENTS.CHANGE, undefined, function (data) { return _this.handleQueryStateChanged(data); });\n };\n CategoryFacet.prototype.initDependsOnManager = function () {\n var _this = this;\n var facetInfo = {\n reset: function () { return _this.dependsOnReset(); },\n ref: this\n };\n this.dependsOnManager = new DependsOnManager_1.DependsOnManager(facetInfo);\n };\n CategoryFacet.prototype.dependsOnReset = function () {\n this.changeActivePath(this.options.basePath);\n this.clear();\n };\n CategoryFacet.prototype.addFading = function () {\n Dom_1.$$(this.element).addClass('coveo-category-facet-values-fade');\n };\n CategoryFacet.prototype.handleDeferredQuerySuccess = function () {\n this.updateAppearance();\n this.removeFading();\n };\n CategoryFacet.prototype.removeFading = function () {\n Dom_1.$$(this.element).removeClass('coveo-category-facet-values-fade');\n };\n CategoryFacet.prototype.notImplementedError = function () {\n var errorMessage = 'Category Facets are not supported by your current search endpoint. Disabling this component.';\n this.logger.error(errorMessage);\n this.disable();\n };\n CategoryFacet.prototype.sortParentValues = function (parentValues) {\n if (this.activePath.length != parentValues.length) {\n this.logger.warn('Inconsistent CategoryFacet results: Number of parent values results does not equal length of active path');\n return parentValues;\n }\n var sortedParentvalues = [];\n var _loop_1 = function (pathElement) {\n var currentParentValue = underscore_1.find(parentValues, function (parentValue) { return parentValue.value.toLowerCase() == pathElement.toLowerCase(); });\n if (!currentParentValue) {\n this_1.logger.warn('Inconsistent CategoryFacet results: path not consistent with parent values results');\n return { value: parentValues };\n }\n sortedParentvalues.push(currentParentValue);\n };\n var this_1 = this;\n for (var _i = 0, _a = this.activePath; _i < _a.length; _i++) {\n var pathElement = _a[_i];\n var state_1 = _loop_1(pathElement);\n if (typeof state_1 === \"object\")\n return state_1.value;\n }\n return sortedParentvalues;\n };\n CategoryFacet.prototype.renderMoreLess = function () {\n if (this.numberOfChildValuesCurrentlyDisplayed > this.options.numberOfValues) {\n this.moreLessContainer.append(this.buildLessButton());\n }\n if (this.moreValuesToFetch) {\n this.moreLessContainer.append(this.buildMoreButton());\n }\n };\n CategoryFacet.prototype.clear = function () {\n this.categoryValueRoot.clear();\n if (this.isFacetSearchAvailable) {\n this.categoryFacetSearch.clear();\n }\n this.moreLessContainer && this.moreLessContainer.detach();\n Dom_1.$$(this.element).removeClass('coveo-category-facet-non-empty-path');\n };\n CategoryFacet.prototype.buildMoreButton = function () {\n var _this = this;\n var svgContainer = Dom_1.$$('span', { className: 'coveo-facet-more-icon' }, SVGIcons_1.SVGIcons.icons.arrowDown).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(svgContainer, 'coveo-facet-more-icon-svg');\n var more = Dom_1.$$('div', { className: 'coveo-category-facet-more' }, svgContainer);\n new AccessibleButton_1.AccessibleButton()\n .withElement(more)\n .withSelectAction(function () { return _this.showMore(); })\n .withLabel(Strings_1.l('ShowMoreFacetResults', this.options.title))\n .build();\n return more.el;\n };\n CategoryFacet.prototype.buildLessButton = function () {\n var _this = this;\n var svgContainer = Dom_1.$$('span', { className: 'coveo-facet-less-icon' }, SVGIcons_1.SVGIcons.icons.arrowUp).el;\n SVGDom_1.SVGDom.addClassToSVGInContainer(svgContainer, 'coveo-facet-less-icon-svg');\n var less = Dom_1.$$('div', { className: 'coveo-category-facet-less' }, svgContainer);\n new AccessibleButton_1.AccessibleButton()\n .withElement(less)\n .withSelectAction(function () { return _this.showLess(); })\n .withLabel(Strings_1.l('ShowLessFacetResults', this.options.title))\n .build();\n return less.el;\n };\n CategoryFacet.prototype.handlePopulateBreadCrumb = function (args) {\n var _this = this;\n if (this.isPristine()) {\n return;\n }\n var lastParentValue = this.categoryFacetValuesTree.getValueForLastPartInPath(this.activePath);\n var descriptor = {\n path: this.activePath,\n count: lastParentValue.numberOfResults,\n value: lastParentValue.value\n };\n var resetFacet = function () {\n _this.logAnalyticsEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.breadcrumbFacet);\n _this.reset();\n };\n var categoryFacetBreadcrumbBuilder = new CategoryFacetBreadcrumb_1.CategoryFacetBreadcrumb(this, resetFacet, descriptor, { headingLevel: args.headingLevel });\n args.breadcrumbs.push({ element: categoryFacetBreadcrumbBuilder.build() });\n };\n CategoryFacet.prototype.handleClearBreadcrumb = function () {\n this.changeActivePath(this.options.basePath);\n };\n CategoryFacet.prototype.logAnalyticsFacetShowMoreLess = function (cause) {\n this.usageAnalytics.logCustomEvent(cause, {\n facetId: this.options.id,\n facetField: this.options.field.toString(),\n facetTitle: this.options.title\n }, this.element);\n };\n CategoryFacet.doExport = function () {\n GlobalExports_1.exportGlobally({\n CategoryFacet: CategoryFacet\n });\n };\n CategoryFacet.ID = 'CategoryFacet';\n /**\n * The options for the component\n * @componentOptions\n */\n CategoryFacet.options = __assign({ \n /**\n * The index field whose values the facet should use. The field values should have the form:\n * `the; the|path; the|path|to; the|path|to|given; the|path|to|given|item;`\n * where the delimiting character is `|`. This default delimiting character can be changed using the [delimitingCharacter]{@link CategoryFacet.options.delimitingCharacter} option.\n *\n * To help you verify whether your fields are setup correctly, see the {@link CategoryFacet.options.debug} option\n * and the {@link CategoryFacet.debugValue} method.\n *\n * See [Using the Category Facet Component](https://docs.coveo.com/en/2667).\n */\n field: ComponentOptions_1.ComponentOptions.buildFieldOption({ required: true }), \n /**\n * The title to display at the top of the facet.\n *\n * Default value is the localized string for `NoTitle`.\n */\n title: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({\n localizedString: function () { return Strings_1.l('NoTitle'); }\n }), \n /**\n * The maximum number of field values to display by default in the facet before the user\n * clicks the arrow to show more.\n *\n * See also the [`enableMoreLess`]{@link CategoryFacet.options.enableMoreLess} option.\n */\n numberOfValues: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 5, min: 0, section: 'CommonOptions' }), \n /**\n * Whether to display a search box at the bottom of the facet for searching among the available facet\n * [`field`]{@link CategoryFacet.options.field} values.\n *\n * See also the [`facetSearchDelay`]{@link CategoryFacet.options.facetSearchDelay}, and\n * [`numberOfResultsInFacetSearch`]{@link CategoryFacet.options.numberOfResultsInFacetSearch} options.\n *\n *\n * Default value is `true`.\n */\n enableFacetSearch: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }), \n /**\n * A unique identifier for the facet. Among other things, this identifier serves the purpose of saving\n * the facet state in the URL hash.\n *\n * If you have two facets with the same field on the same page, you should specify an `id` value for at least one of\n * those two facets. This `id` must be unique among the facets.\n *\n * Default value is the [`field`]{@link CategoryFacet.options.field} option value.\n */\n id: ComponentOptions_1.ComponentOptions.buildStringOption({\n postProcessing: function (value, options) { return value || options.field; }\n }), \n /**\n * The *injection depth* to use.\n *\n * The injection depth determines how many results to scan in the index to ensure that the category facet lists all potential\n * facet values. Increasing this value enhances the accuracy of the listed values at the cost of performance.\n *\n * Default value is `1000`. Minimum value is `1000`.\n * @notSupportedIn salesforcefree\n *\n * @examples 1500\n */\n injectionDepth: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 1000, min: 1000 }), \n /**\n * If the [`enableFacetSearch`]{@link CategoryFacet.options.enableFacetSearch} option is `true`, specifies the number of\n * values to display in the facet search results popup.\n *\n * Default value is `15`. Minimum value is `1`.\n */\n numberOfResultsInFacetSearch: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 15, min: 1 }), \n /**\n * If the [`enableFacetSearch`]{@link CategoryFacet.options.enableFacetSearch} option is `true`, specifies the delay (in\n * milliseconds) before sending a search request to the server when the user starts typing in the category facet search box.\n *\n * Specifying a smaller value makes results appear faster. However, chances of having to cancel many requests\n * sent to the server increase as the user keeps on typing new characters.\n *\n * Default value is `100`. Minimum value is `0`.\n */\n facetSearchDelay: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 100, min: 0 }), \n /**\n * Whether to enable the **More** and **Less** buttons in the Facet.\n *\n * See also the [`pageSize`]{@link CategoryFacet.options.pageSize} option.\n *\n * Default value is `true`.\n */\n enableMoreLess: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }), \n /**\n * If the [`enableMoreLess`]{@link CategoryFacet.options.enableMoreLess} option is `true`, specifies the number of\n * additional results to fetch when clicking the **More** button.\n *\n * Default value is `10`. Minimum value is `1`.\n */\n pageSize: ComponentOptions_1.ComponentOptions.buildNumberOption({ defaultValue: 10, min: 1, depend: 'enableMoreLess' }), \n /**\n * The character that specifies the hierarchical dependency.\n *\n * **Example:**\n *\n * If your field has the following values:\n *\n * `@field: c; c>folder2; c>folder2>folder3;`\n *\n * The delimiting character is `>`.\n *\n * Default value is `|`.\n */\n delimitingCharacter: ComponentOptions_1.ComponentOptions.buildStringOption({ defaultValue: '|' }), \n /**\n * The path to use as the path prefix for every query.\n *\n * **Example:**\n *\n * You have the following files indexed on a file system:\n * ```\n * c:\\\n * folder1\\\n * text1.txt\n * folder2\\\n * folder3\\\n * text2.txt\n * ```\n * Setting the `basePath` to `c` would display `folder1` and `folder2` in the `CategoryFacet`, but omit `c`.\n *\n * This options accepts an array of values. To specify a \"deeper\" starting path in your tree, you need to use comma-separated values.\n *\n * For example, setting `data-base-path=\"c,folder1\"` on the component markup would display `folder3` in the `CategoryFacet`, but omit `c` and `folder1`.\n *\n */\n basePath: ComponentOptions_1.ComponentOptions.buildListOption({ defaultValue: [] }), \n /**\n * The maximum number of levels to traverse in the hierarchy.\n * This option does not count the length of the base path. The depth depends on what is shown in the interface.\n *\n * Default value is `Number.MAX_VALUE`.\n */\n maximumDepth: ComponentOptions_1.ComponentOptions.buildNumberOption({ min: 1, defaultValue: Number.MAX_VALUE }), \n /**\n * Whether to activate field format debugging.\n * This options logs messages in the console for any potential encountered issues.\n * This option can have negative effects on performance, and should only be activated when debugging.\n */\n debug: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }), \n /**\n * Specifies a JSON object describing a mapping of facet values to their desired captions. See\n * [Normalizing Facet Value Captions](https://developers.coveo.com/x/jBsvAg).\n *\n * **Note:**\n * If this option is specified, the facet search box will be unavailable.\n *\n * **Examples:**\n *\n * You can set the option in the ['init']{@link init} call:\n * ```javascript\n * var myValueCaptions = {\n * \"txt\" : \"Text files\",\n * \"html\" : \"Web page\",\n * [ ... ]\n * };\n *\n * Coveo.init(document.querySelector(\"#search\"), {\n * Facet : {\n * valueCaption : myValueCaptions\n * }\n * });\n * ```\n *\n * Or before the `init` call, using the ['options']{@link options} top-level function:\n * ```javascript\n * Coveo.options(document.querySelector(\"#search\"), {\n * Facet : {\n * valueCaption : myValueCaptions\n * }\n * });\n * ```\n *\n * Or directly in the markup:\n * ```html\n * \n * \n * ```\n */\n valueCaption: ComponentOptions_1.ComponentOptions.buildJsonOption({ defaultValue: {} }), \n /**\n * The [id](@link Facet.options.id) of another facet in which at least one value must be selected in order\n * for the dependent category facet to be visible.\n *\n * **Default:** `undefined` and the category facet does not depend on any other facet to be displayed.\n *\n * @availablesince [September 2019 Release (v2.7023)](https://docs.coveo.com/en/2990/)\n */\n dependsOn: ComponentOptions_1.ComponentOptions.buildStringOption(), \n /**\n * A function that verifies whether the current state of the `dependsOn` facet allows the dependent facet to be displayed.\n *\n * If specified, the function receives a reference to the resolved `dependsOn` facet component instance as an argument, and must return a boolean.\n * The function's argument should typically be treated as read-only.\n *\n * By default, the dependent facet is displayed whenever one or more values are selected in its `dependsOn` facet.\n *\n * @externaldocs [Defining Dependent Facets](https://docs.coveo.com/3210/)\n */\n dependsOnCondition: ComponentOptions_1.ComponentOptions.buildCustomOption(function () {\n return null;\n }, { depend: 'dependsOn', section: 'CommonOptions' }), \n /**\n * Whether to display the facet search widget above the facet values instead of below them.\n *\n * @availablesince [July 2020 Release (v2.9373)](https://docs.coveo.com/3293/)\n */\n displaySearchOnTop: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }), \n /**\n * Whether to display the facet search widget as a button instead of a search bar.\n *\n * @availablesince [July 2020 Release (v2.9373)](https://docs.coveo.com/3293/)\n */\n displaySearchButton: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true }) }, ResponsiveFacetOptions_1.ResponsiveFacetOptions);\n CategoryFacet.MAXIMUM_NUMBER_OF_VALUES_BEFORE_TRUNCATING = 15;\n CategoryFacet.NUMBER_OF_VALUES_TO_KEEP_AFTER_TRUNCATING = 10;\n CategoryFacet.WAIT_ELEMENT_CLASS = 'coveo-category-facet-header-wait-animation';\n return CategoryFacet;\n}(Component_1.Component));\nexports.CategoryFacet = CategoryFacet;\nInitialization_1.Initialization.registerAutoCreateComponent(CategoryFacet);\nCategoryFacet.doExport();\n\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// CategoryFacet.min__ff92a1d47dbcec2611e1.js","import { Component } from '../ui/Base/Component';\nimport { ResultList } from '../ui/ResultList/ResultList';\nimport { $$ } from './Dom';\nimport { find } from 'underscore';\nimport { Logger } from '../misc/Logger';\n\nexport class ResultListUtils {\n public static hideIfInfiniteScrollEnabled(cmp: Component) {\n const infiniteScrollEnabled = ResultListUtils.isInfiniteScrollEnabled(cmp.searchInterface.element);\n\n if (infiniteScrollEnabled) {\n cmp.disable();\n $$(cmp.element).hide();\n ResultListUtils.warnIfComponentNotNeeded(cmp);\n } else {\n cmp.enable();\n $$(cmp.element).unhide();\n }\n }\n\n public static isInfiniteScrollEnabled(root: HTMLElement) {\n const resultList = ResultListUtils.getMainResultList(root);\n return resultList ? !!resultList.options.enableInfiniteScroll : false;\n }\n\n public static scrollToTop(root: HTMLElement) {\n const resultList = ResultListUtils.getMainResultList(root);\n if (!resultList) {\n new Logger(this).warn('No active ResultList, scrolling to the top of the Window');\n return window.scrollTo(0, 0);\n }\n\n const searchInterfacePosition = resultList.searchInterface.element.getBoundingClientRect().top;\n if (searchInterfacePosition > 0) {\n return;\n }\n\n window.scrollTo(0, window.pageYOffset + searchInterfacePosition);\n }\n\n private static getMainResultList(root: HTMLElement) {\n const resultLists = ResultListUtils.getResultLists(root);\n return find(resultLists, resultList => {\n const isRecInterface = resultList.searchInterface.element.classList.contains('CoveoRecommendation');\n return !resultList.disabled && !isRecInterface;\n });\n }\n\n private static getResultLists(root: HTMLElement) {\n return $$(root)\n .findAll(`.${ResultListUtils.cssClass()}`)\n .map(el => Component.get(el, ResultList));\n }\n\n private static cssClass() {\n return Component.computeCssClassName(ResultList);\n }\n\n private static warnIfComponentNotNeeded(cmp: Component) {\n const root = cmp.searchInterface.root;\n const allListsUseInfiniteScroll = ResultListUtils.allResultListsUseInfiniteScroll(root);\n\n allListsUseInfiniteScroll && ResultListUtils.notNeededComponentWarning(cmp);\n }\n\n private static allResultListsUseInfiniteScroll(root: HTMLElement) {\n const listsWithInfiniteScrollDisabled = ResultListUtils.getResultLists(root).filter(\n resultList => !resultList.options.enableInfiniteScroll\n );\n\n return listsWithInfiniteScrollDisabled.length === 0;\n }\n\n private static notNeededComponentWarning(cmp: Component) {\n const cmpCssClass = Component.computeCssClassNameForType(cmp.type);\n const message = `The ${cmpCssClass} component is not needed because all ${ResultListUtils.cssClass()} components have enableInfiniteScroll set to 'true'.\n For the best performance, remove the ${cmpCssClass} component from your search page.`;\n\n new Logger(cmp).warn(message);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/ResultListUtils.ts","import { Assert } from '../../misc/Assert';\nimport { Utils } from '../../utils/Utils';\nimport { IGroupByValue } from '../../rest/GroupByValue';\nimport { IIndexFieldValue } from '../../rest/FieldValue';\nimport * as Globalize from 'globalize';\nimport { isString, isObject } from 'underscore';\n\n/**\n * A class which holds information and operation available on a single facet value returned by a {@link IGroupByRequest}. \n * This class is used extensively in the {@link Facet} component.\n */\nexport class FacetValue {\n value: string;\n lookupValue: string;\n occurrences: number;\n computedField: number;\n delta: number;\n score: number;\n selected: boolean = false;\n excluded: boolean = false;\n waitingForDelta: boolean = false;\n\n reset() {\n this.selected = false;\n this.excluded = false;\n }\n\n updateCountsFromNewValue(newValue: FacetValue) {\n Assert.exists(newValue);\n this.occurrences = newValue.occurrences;\n this.delta = newValue.delta;\n this.computedField = newValue.computedField;\n }\n\n clone(): FacetValue {\n this.computedField = undefined;\n this.delta = undefined;\n return this;\n }\n\n cloneWithZeroOccurrences(): FacetValue {\n this.occurrences = 0;\n return this.clone();\n }\n\n cloneWithDelta(count: number, delta: number): FacetValue {\n Assert.isLargerOrEqualsThan(0, count);\n var clone = this.cloneWithZeroOccurrences();\n clone.delta = delta;\n clone.occurrences = count;\n return clone;\n }\n\n getFormattedCount() {\n var count: string = undefined;\n if (Utils.exists(this.delta) && this.delta > 0) {\n count = '+' + Globalize.format(this.delta, 'n0');\n } else {\n if (this.occurrences > 0) {\n count = Globalize.format(this.occurrences, 'n0');\n }\n }\n return count;\n }\n\n getFormattedComputedField(format: string) {\n if (this.computedField != 0) {\n return Globalize.format(this.computedField, format);\n } else {\n return undefined;\n }\n }\n\n static create(value: any): FacetValue {\n if (isString(value)) {\n return FacetValue.createFromValue(value);\n } else if (isObject(value)) {\n if ('computedFieldResults' in value) {\n return FacetValue.createFromGroupByValue(value);\n } else {\n return FacetValue.createFromFieldValue(value);\n }\n } else {\n throw new Error(\"Can't create value from \" + value);\n }\n }\n\n static createFromValue(value: string): FacetValue {\n Assert.isNonEmptyString(value);\n\n var facetValue = new FacetValue();\n facetValue.value = value;\n facetValue.lookupValue = value;\n\n return facetValue;\n }\n\n static createFromGroupByValue(groupByValue: IGroupByValue): FacetValue {\n Assert.exists(groupByValue);\n\n Assert.exists(groupByValue);\n\n var facetValue = new FacetValue();\n facetValue.value = groupByValue.value;\n facetValue.lookupValue = Utils.exists(groupByValue.lookupValue) ? groupByValue.lookupValue : groupByValue.value;\n facetValue.occurrences = groupByValue.numberOfResults;\n facetValue.computedField = Utils.isNonEmptyArray(groupByValue.computedFieldResults) ? groupByValue.computedFieldResults[0] : undefined;\n facetValue.score = groupByValue.score;\n\n return facetValue;\n }\n\n static createFromFieldValue(fieldValue: IIndexFieldValue): FacetValue {\n Assert.exists(fieldValue);\n\n var facetValue = new FacetValue();\n facetValue.value = fieldValue.value;\n facetValue.lookupValue = fieldValue.lookupValue;\n facetValue.occurrences = fieldValue.numberOfResults;\n\n return facetValue;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Facet/FacetValue.ts","import { Dom } from '../../utils/Dom';\nimport { ResponsiveDropdownContent } from './ResponsiveDropdown/ResponsiveDropdownContent';\n\nexport class ResponsiveComponentsUtils {\n private static smallTabsClassName: string = 'coveo-small-tabs';\n private static smallFacetClassName: string = 'coveo-small-facets';\n private static smallRecommendationClassName: string = 'coveo-small-recommendation';\n\n static shouldDrawFacetSlider(root: Dom, facetSliderElement: Dom): boolean {\n return ResponsiveDropdownContent.isTargetInsideOpenedDropdown(facetSliderElement) || !this.isSmallFacetActivated(root);\n }\n\n static isSmallTabsActivated(root: Dom): boolean {\n return root.hasClass(this.smallTabsClassName);\n }\n\n static isSmallFacetActivated(root: Dom): boolean {\n return root.hasClass(this.smallFacetClassName);\n }\n\n static isSmallRecommendationActivated(root: Dom): boolean {\n return root.hasClass(this.smallRecommendationClassName);\n }\n\n static activateSmallTabs(root: Dom): void {\n root.addClass(this.smallTabsClassName);\n }\n\n static deactivateSmallTabs(root: Dom): void {\n root.removeClass(this.smallTabsClassName);\n }\n\n static activateSmallFacet(root: Dom): void {\n root.addClass(this.smallFacetClassName);\n }\n\n static deactivateSmallFacet(root: Dom): void {\n root.removeClass(this.smallFacetClassName);\n }\n\n static activateSmallRecommendation(root: Dom): void {\n root.addClass(this.smallRecommendationClassName);\n }\n\n static deactivateSmallRecommendation(root: Dom): void {\n root.removeClass(this.smallRecommendationClassName);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResponsiveComponents/ResponsiveComponentsUtils.ts","/// \n\nimport { Facet } from './Facet';\nimport { FacetValue } from './FacetValue';\nimport { ValueElement } from './ValueElement';\n\nexport interface IFacetValueElementKlass {\n new (facet: Facet, facetValue: FacetValue, displayNextTime?: boolean): FacetValueElement;\n}\n\nexport class FacetValueElement extends ValueElement {\n constructor(public facet: Facet, public facetValue: FacetValue, public keepDisplayedValueNextTime: boolean) {\n super(facet, facetValue);\n }\n\n public bindEvent() {\n super.bindEvent({\n displayNextTime: this.keepDisplayedValueNextTime,\n pinFacet: this.facet.options.preservePosition\n });\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Facet/FacetValueElement.ts","/// \n\nimport { Facet } from './Facet';\nimport { Utils } from '../../utils/Utils';\nimport { FacetUtils } from './FacetUtils';\nimport { IGroupByRequest } from '../../rest/GroupByRequest';\nimport { IQuery } from '../../rest/Query';\nimport { QueryBuilder } from '../Base/QueryBuilder';\nimport { $$ } from '../../utils/Dom';\nimport * as _ from 'underscore';\nimport { AllowedValuesPatternType } from '../../rest/AllowedValuesPatternType';\n\nexport class FacetSearchParameters {\n public nbResults: number;\n public ignoreAccents: boolean;\n public valueToSearch: string = '';\n public alwaysInclude: string[] = [];\n public alwaysExclude: string[] = [];\n public sortCriteria = 'occurrences';\n public fetchMore = false;\n public completeFacetWithStandardValues = true;\n\n constructor(public facet: Facet) {\n this.nbResults = facet.options.numberOfValuesInFacetSearch;\n this.ignoreAccents = facet.options.facetSearchIgnoreAccents;\n }\n\n public setValueToSearch(value: string) {\n this.valueToSearch = value;\n if (Utils.isNonEmptyString(value)) {\n this.valueToSearch = this.valueToSearch.trim();\n this.alwaysInclude = this.alwaysInclude.concat(FacetUtils.getValuesToUseForSearchInFacet(this.valueToSearch, this.facet));\n }\n return this;\n }\n\n public excludeCurrentlyDisplayedValuesInSearch(searchResults: HTMLElement) {\n _.each(this.getCurrentlyShowedValueInSearch(searchResults), v => {\n const expandedValues = FacetUtils.getValuesToUseForSearchInFacet(v, this.facet);\n _.each(expandedValues, expanded => {\n this.alwaysExclude.push(expanded);\n });\n });\n _.each(this.facet.getDisplayedFacetValues(), v => {\n this.alwaysExclude.push(v.value);\n });\n }\n\n public getGroupByRequest(): IGroupByRequest {\n this.lowerCaseAll();\n let nbResults = this.nbResults;\n nbResults += this.alwaysExclude.length;\n\n let typedByUser = [];\n if (this.valueToSearch) {\n typedByUser = ['*' + this.valueToSearch + '*'];\n }\n\n let allowedValues;\n if (this.valueToSearch) {\n allowedValues = typedByUser.concat(this.alwaysInclude).concat(this.alwaysExclude);\n } else {\n allowedValues = _.compact(typedByUser.concat(this.alwaysInclude).concat(this.facet.options.allowedValues));\n }\n\n let completeFacetWithStandardValues = this.completeFacetWithStandardValues;\n if (this.facet.options.lookupField != null) {\n completeFacetWithStandardValues = false;\n }\n\n const request: IGroupByRequest = {\n allowedValues,\n allowedValuesPatternType: this.facet.options.useWildcardsInFacetSearch\n ? AllowedValuesPatternType.Wildcards\n : AllowedValuesPatternType.Legacy,\n maximumNumberOfValues: nbResults,\n completeFacetWithStandardValues: completeFacetWithStandardValues,\n field: this.facet.options.field,\n sortCriteria: this.facet.options.sortCriteria || this.sortCriteria,\n injectionDepth: this.facet.options.injectionDepth\n };\n\n if (this.facet.options.lookupField) {\n request.lookupField = this.facet.options.lookupField;\n }\n\n if (this.facet.options.computedField) {\n request.computedFields = [\n {\n field: this.facet.options.computedField,\n operation: this.facet.options.computedFieldOperation\n }\n ];\n }\n return request;\n }\n\n public getQuery(): IQuery {\n let lastQuery = _.clone(this.facet.queryController.getLastQuery());\n if (!lastQuery) {\n // There should normally always be a last query available\n // If not, just create an empty one.\n lastQuery = new QueryBuilder().build();\n }\n // We want to always force query syntax to true for a facet search,\n // but arrange for the basic expression to adapt itself with no syntax block\n if (lastQuery.enableQuerySyntax) {\n lastQuery.q = this.facet.facetQueryController.basicExpressionToUseForFacetSearch;\n } else if (Utils.isNonEmptyString(this.facet.facetQueryController.basicExpressionToUseForFacetSearch)) {\n lastQuery.q = `<@- ${this.facet.facetQueryController.basicExpressionToUseForFacetSearch} -@>`;\n } else {\n lastQuery.q = '';\n }\n\n lastQuery.enableQuerySyntax = true;\n lastQuery.cq = this.facet.facetQueryController.constantExpressionToUseForFacetSearch;\n lastQuery.aq = this.facet.facetQueryController.advancedExpressionToUseForFacetSearch;\n lastQuery.enableDidYouMean = false;\n lastQuery.firstResult = 0;\n lastQuery.numberOfResults = 0;\n lastQuery.fieldsToInclude = [];\n lastQuery.groupBy = [this.getGroupByRequest()];\n return lastQuery;\n }\n\n private getCurrentlyShowedValueInSearch(searchResults: HTMLElement) {\n return _.map($$(searchResults).findAll('.coveo-facet-value-caption'), val => {\n return $$(val).getAttribute('data-original-value') || $$(val).text();\n });\n }\n\n private lowerCaseAll() {\n this.alwaysExclude = _.chain(this.alwaysExclude)\n .map(v => {\n return v.toLowerCase();\n })\n .uniq()\n .value();\n\n this.alwaysInclude = _.chain(this.alwaysInclude)\n .map(v => {\n return v.toLowerCase();\n })\n .uniq()\n .value();\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Facet/FacetSearchParameters.ts","import { isFunction } from 'underscore';\nimport { QueryStateModel, QueryEvents, Component } from '../Core';\nimport { ComponentsTypes } from './ComponentsTypes';\nimport { $$ } from './Dom';\nimport { InitializationEvents } from '../events/InitializationEvents';\n\nexport interface IDependsOnCompatibleFacetOptions {\n id?: string;\n dependsOn?: string;\n dependsOnCondition?: IDependentFacetCondition;\n}\n\nexport interface IDependsOnCompatibleFacet extends Component {\n options: IDependsOnCompatibleFacetOptions;\n}\n\nexport interface IDependentFacet {\n reset: () => void;\n ref: IDependsOnCompatibleFacet;\n}\n\nexport interface IDependentFacetCondition {\n (facet: IDependsOnCompatibleFacet): boolean;\n}\n\nexport class DependsOnManager {\n private parentFacetRef: IDependsOnCompatibleFacet;\n\n constructor(private facet: IDependentFacet) {\n $$(this.facet.ref.searchInterface.element).on(QueryEvents.buildingQuery, () => this.handleBuildingQuery());\n\n if (this.getDependsOn(this.facet.ref)) {\n this.facet.ref.bind.onRootElement(InitializationEvents.afterComponentsInitialization, () => this.setupDependentFacet());\n }\n }\n\n private setupDependentFacet() {\n $$(this.facet.ref.element).addClass('coveo-hidden-dependant-facet');\n this.parentFacetRef = this.getParentFacet(this.facet.ref);\n\n if (this.parentFacetRef) {\n $$(this.facet.ref.root).on('state:change', () => this.resetIfConditionUnfullfiled());\n }\n }\n\n private resetIfConditionUnfullfiled() {\n const condition = this.getDependsOnCondition(this.facet.ref);\n\n if (!condition(this.parentFacetRef)) {\n this.facet.reset();\n }\n }\n\n private getId(component: IDependsOnCompatibleFacet) {\n const id = component.options.id;\n return id ? `${id}` : null;\n }\n\n private getDependsOn(component: IDependsOnCompatibleFacet) {\n const dependsOn = component.options.dependsOn;\n return dependsOn ? `${dependsOn}` : null;\n }\n\n private getDependsOnCondition(component: IDependsOnCompatibleFacet): IDependentFacetCondition {\n const conditionOption = component.options.dependsOnCondition;\n return conditionOption && isFunction(conditionOption)\n ? conditionOption\n : () => this.parentHasSelectedValues(component) && this.parentIsEnabled(component);\n }\n\n private parentHasSelectedValues(component: IDependsOnCompatibleFacet) {\n const parent = this.getParentFacet(component);\n return parent && this.valuesExistForFacetWithId(this.getId(parent));\n }\n\n private parentIsEnabled(component: IDependsOnCompatibleFacet) {\n const parent = this.getParentFacet(component);\n return parent && !parent.disabled;\n }\n\n private valuesExistForFacetWithId(facetId: string) {\n const values = this.facet.ref.queryStateModel.get(QueryStateModel.getFacetId(facetId));\n return !!values && !!values.length;\n }\n\n private get allFacetsInInterface() {\n return ComponentsTypes.getAllFacetsFromSearchInterface(this.facet.ref.searchInterface) as IDependsOnCompatibleFacet[];\n }\n\n private getParentFacet(component: IDependsOnCompatibleFacet) {\n const parent = this.allFacetsInInterface.filter(\n potentialParentFacet => this.getId(potentialParentFacet) === this.getDependsOn(component)\n );\n\n if (!parent.length) {\n component.logger.warn('DependsOn reference does not exist', this.getDependsOn(this.facet.ref));\n return null;\n }\n\n return parent[0];\n }\n\n private get dependentFacets() {\n return this.allFacetsInInterface.filter(\n potentialDependentFacet => this.getId(this.facet.ref) === this.getDependsOn(potentialDependentFacet)\n );\n }\n\n private handleBuildingQuery() {\n this.dependentFacets.forEach(dependentFacet => {\n const condition = this.getDependsOnCondition(dependentFacet);\n if (condition(this.facet.ref)) {\n $$(dependentFacet.element).removeClass('coveo-hidden-dependant-facet');\n return dependentFacet.enable();\n }\n\n dependentFacet.disable();\n $$(dependentFacet.element).addClass('coveo-hidden-dependant-facet');\n });\n }\n\n public get hasDependentFacets() {\n return !!this.dependentFacets.length;\n }\n\n public get dependentFacetsHaveSelectedValues() {\n return this.dependentFacets.some(dependentFacet => this.valuesExistForFacetWithId(this.getId(dependentFacet)));\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/DependsOnManager.ts","import { ResponsiveFacetColumn } from './ResponsiveFacetColumn';\nimport { IResponsiveComponentOptions } from './ResponsiveComponentsManager';\nimport { Facet } from '../Facet/Facet';\n\nexport class ResponsiveFacets extends ResponsiveFacetColumn {\n public static init(root: HTMLElement, component, options: IResponsiveComponentOptions) {\n ResponsiveFacetColumn.init(ResponsiveFacets, root, component, options, Facet.ID);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResponsiveComponents/ResponsiveFacets.ts","import { IQueryResult } from '../../rest/QueryResult';\nimport { Component } from '../Base/Component';\nimport { IResultListOptions } from './ResultListOptions';\nimport _ = require('underscore');\n\nexport class ResultListRenderer {\n constructor(protected resultListOptions: IResultListOptions, protected autoCreateComponentsFn: Function) {}\n\n renderResults(\n resultElements: HTMLElement[],\n append = false,\n resultDisplayedCallback: (result: IQueryResult, resultElem: HTMLElement) => any\n ) {\n return Promise.all([this.getStartFragment(resultElements, append), this.getEndFragment(resultElements, append)]).then(\n ([startFrag, endFrag]) => {\n const resultsFragment = document.createDocumentFragment();\n if (startFrag) {\n resultsFragment.appendChild(startFrag);\n }\n _.each(resultElements, resultElement => {\n resultsFragment.appendChild(resultElement);\n resultDisplayedCallback(Component.getResult(resultElement), resultElement);\n });\n if (endFrag) {\n resultsFragment.appendChild(endFrag);\n }\n this.resultListOptions.resultsContainer.appendChild(resultsFragment);\n }\n );\n }\n\n protected getStartFragment(resultElements: HTMLElement[], append: boolean): Promise {\n return Promise.resolve(document.createDocumentFragment());\n }\n\n protected getEndFragment(resultElements: HTMLElement[], append: boolean): Promise {\n return Promise.resolve(document.createDocumentFragment());\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResultList/ResultListRenderer.ts","import 'styling/_ResponsiveFacets';\nimport { IQuerySuccessEventArgs, QueryEvents } from '../../events/QueryEvents';\nimport { Logger } from '../../misc/Logger';\nimport { l } from '../../strings/Strings';\nimport { $$, Dom } from '../../utils/Dom';\nimport { Utils } from '../../utils/Utils';\nimport { Component } from '../Base/Component';\nimport { SearchInterface } from '../SearchInterface/SearchInterface';\nimport { ResponsiveComponents } from './ResponsiveComponents';\nimport { IResponsiveComponent, IResponsiveComponentOptions, ResponsiveComponentsManager } from './ResponsiveComponentsManager';\nimport { ResponsiveComponentsUtils } from './ResponsiveComponentsUtils';\nimport { ResponsiveDropdown } from './ResponsiveDropdown/ResponsiveDropdown';\nimport { ResponsiveDropdownContent, IResponsiveDropdownContent } from './ResponsiveDropdown/ResponsiveDropdownContent';\nimport { ResponsiveDropdownHeader } from './ResponsiveDropdown/ResponsiveDropdownHeader';\nimport { each, debounce } from 'underscore';\nimport { ComponentsTypes } from '../../utils/ComponentsTypes';\nimport { ResponsiveDropdownModalContent } from './ResponsiveDropdown/ResponsiveDropdownModalContent';\nimport { FacetsMobileMode, IFacetsMobileModeOptions } from '../FacetsMobileMode/FacetsMobileMode';\nimport { FacetsMobileModeEvents } from '../../events/FacetsMobileModeEvents';\n\nexport class ResponsiveFacetColumn implements IResponsiveComponent {\n public static DEBOUNCE_SCROLL_WAIT = 250;\n\n private static logger = new Logger('ResponsiveFacets');\n private static DROPDOWN_MIN_WIDTH: number = 280;\n private static DROPDOWN_WIDTH_RATIO: number = 0.35; // Used to set the width relative to the coveo root.\n private static DROPDOWN_HEADER_LABEL_DEFAULT_VALUE = 'Filters';\n\n private searchInterface: SearchInterface;\n private componentsInFacetColumn: any[] = [];\n private preservePositionOriginalValues: boolean[] = [];\n private breakpoint: number;\n protected dropdown: ResponsiveDropdown;\n private dropdownHeaderLabel: string;\n\n public static init(responsiveComponentConstructor, root: HTMLElement, component, options: IResponsiveComponentOptions, ID: string) {\n const column = this.findColumn(root);\n if (!column) {\n return;\n }\n\n ResponsiveComponentsManager.register(ResponsiveFacetColumn, $$(root), 'ResponsiveFacetColumn', component, options);\n ResponsiveComponentsManager.register(responsiveComponentConstructor, $$(root), ID, component, options);\n }\n\n private static findColumn(root: HTMLElement) {\n const column = $$(root).find('.coveo-facet-column');\n if (!column) {\n this.logger.info('No element with class coveo-facet-column. Responsive facets cannot be enabled');\n }\n return column;\n }\n\n constructor(public coveoRoot: Dom, public ID: string, options: IResponsiveComponentOptions, responsiveDropdown?: ResponsiveDropdown) {\n this.searchInterface = Component.get(this.coveoRoot.el, SearchInterface, false);\n this.dropdownHeaderLabel = this.getDropdownHeaderLabel();\n this.dropdown = this.buildDropdown(responsiveDropdown);\n this.bindDropdownContentEvents();\n this.bindFacetsMobileModeEvents();\n this.registerOnCloseHandler();\n this.registerQueryEvents();\n this.initializeBreakpoint(options.responsiveBreakpoint);\n }\n\n private get facetsMobileModeComponent() {\n return this.searchInterface ? this.searchInterface.getComponents(FacetsMobileMode.ID)[0] : null;\n }\n\n private get facetsMobileModeOptions(): IFacetsMobileModeOptions {\n const facetsMobileModeComponent = this.facetsMobileModeComponent;\n if (!facetsMobileModeComponent) {\n ResponsiveFacetColumn.logger.warn('The \"FacetsMobileMode\" component did not load properly, disabling the ResponsiveFacets modal.');\n return {\n isModal: false,\n preventScrolling: false,\n displayOverlayWhileOpen: true\n };\n }\n\n return facetsMobileModeComponent.options;\n }\n\n public registerComponent(accept: Component) {\n this.componentsInFacetColumn.push(accept);\n this.preservePositionOriginalValues.push(accept.options.preservePosition);\n return true;\n }\n\n public needDropdownWrapper() {\n return this.needSmallMode();\n }\n\n public handleResizeEvent() {\n if (this.needSmallMode() && !ResponsiveComponentsUtils.isSmallFacetActivated(this.coveoRoot)) {\n this.changeToSmallMode();\n } else if (!this.needSmallMode() && ResponsiveComponentsUtils.isSmallFacetActivated(this.coveoRoot)) {\n this.changeToLargeMode();\n }\n if (this.dropdown.isOpened) {\n this.dropdown.dropdownContent.positionDropdown();\n }\n }\n\n public dismissFacetSearches() {\n each(this.componentsInFacetColumn, component => {\n if (component.facetSearch && component.facetSearch.currentlyDisplayedResults) {\n component.facetSearch.dismissSearchResults();\n }\n });\n }\n\n private needSmallMode(): boolean {\n if (!this.searchInterface) {\n return (\n this.coveoRoot.width() <=\n (Utils.isNullOrUndefined(this.breakpoint) ? new ResponsiveComponents().getMediumScreenWidth() : this.breakpoint)\n );\n }\n switch (this.searchInterface.responsiveComponents.getResponsiveMode()) {\n case 'small':\n case 'medium':\n return true;\n case 'auto':\n return (\n this.coveoRoot.width() <=\n (Utils.isNullOrUndefined(this.breakpoint) ? this.searchInterface.responsiveComponents.getMediumScreenWidth() : this.breakpoint)\n );\n default:\n return false;\n }\n }\n\n private changeToSmallMode() {\n this.dropdown.close();\n this.disableFacetPreservePosition();\n $$(this.coveoRoot.find(`.${ResponsiveComponentsManager.DROPDOWN_HEADER_WRAPPER_CSS_CLASS}`)).append(\n this.dropdown.dropdownHeader.element.el\n );\n ResponsiveComponentsUtils.activateSmallFacet(this.coveoRoot);\n }\n\n private changeToLargeMode() {\n this.restoreFacetPreservePositionValue();\n this.dropdown.cleanUp();\n ResponsiveComponentsUtils.deactivateSmallFacet(this.coveoRoot);\n }\n\n private buildDropdown(responsiveDropdown?: ResponsiveDropdown) {\n let dropdownContent = this.buildDropdownContent();\n let dropdownHeader = this.buildDropdownHeader();\n let dropdown = responsiveDropdown ? responsiveDropdown : new ResponsiveDropdown(dropdownContent, dropdownHeader, this.coveoRoot);\n if (!this.facetsMobileModeOptions.displayOverlayWhileOpen) {\n dropdown.disablePopupBackground();\n }\n if (this.facetsMobileModeOptions.preventScrolling) {\n dropdown.enableScrollLocking(this.facetsMobileModeOptions.scrollContainer);\n }\n return dropdown;\n }\n\n private buildDropdownContent(): IResponsiveDropdownContent {\n let dropdownContentElement = $$(this.coveoRoot.find('.coveo-facet-column'));\n let filterByContainer = $$('div', { className: 'coveo-facet-header-filter-by-container', style: 'display: none' });\n let filterBy = $$('div', { className: 'coveo-facet-header-filter-by' });\n filterBy.text(l('Filter by:'));\n filterByContainer.append(filterBy.el);\n dropdownContentElement.prepend(filterByContainer.el);\n if (this.facetsMobileModeOptions.isModal) {\n return new ResponsiveDropdownModalContent('facet', dropdownContentElement, l('CloseFiltersDropdown'), () => this.dropdown.close());\n }\n return new ResponsiveDropdownContent(\n 'facet',\n dropdownContentElement,\n this.coveoRoot,\n ResponsiveFacetColumn.DROPDOWN_MIN_WIDTH,\n ResponsiveFacetColumn.DROPDOWN_WIDTH_RATIO\n );\n }\n\n private buildDropdownHeader() {\n let dropdownHeaderElement = $$('a');\n let content = $$('p');\n content.text(this.dropdownHeaderLabel);\n dropdownHeaderElement.el.appendChild(content.el);\n let dropdownHeader = new ResponsiveDropdownHeader('facet', dropdownHeaderElement);\n return dropdownHeader;\n }\n\n private initializeBreakpoint(defaultBreakpoint: number) {\n const facetsMobileModeBreakpoint = this.facetsMobileModeOptions.breakpoint;\n this.breakpoint = Utils.isNullOrUndefined(facetsMobileModeBreakpoint) ? defaultBreakpoint : facetsMobileModeBreakpoint;\n }\n\n private registerOnCloseHandler() {\n this.dropdown.registerOnCloseHandler(this.dismissFacetSearches, this);\n }\n\n private registerQueryEvents() {\n this.coveoRoot.on(QueryEvents.noResults, () => this.handleNoResults());\n this.coveoRoot.on(QueryEvents.querySuccess, (e: Event, data: IQuerySuccessEventArgs) => this.handleQuerySuccess(data));\n this.coveoRoot.on(QueryEvents.queryError, () => this.handleQueryError());\n }\n\n private bindDropdownContentEvents() {\n this.dropdown.dropdownContent.element.on(\n 'scroll',\n debounce(() => {\n each(this.componentsInFacetColumn, component => {\n let facetSearch = component.facetSearch;\n if (facetSearch && facetSearch.currentlyDisplayedResults && !this.isFacetSearchScrolledIntoView(facetSearch.search)) {\n component.facetSearch.positionSearchResults(this.dropdown.dropdownContent.element.el);\n } else if (facetSearch && component.facetSearch.currentlyDisplayedResults) {\n component.facetSearch.positionSearchResults();\n }\n });\n }, ResponsiveFacetColumn.DEBOUNCE_SCROLL_WAIT)\n );\n }\n\n private bindFacetsMobileModeEvents() {\n const facetsMobileModeComponent = this.facetsMobileModeComponent;\n if (facetsMobileModeComponent) {\n this.dropdown.registerOnOpenHandler(\n () => $$(facetsMobileModeComponent.element).trigger(FacetsMobileModeEvents.popupOpened),\n facetsMobileModeComponent\n );\n this.dropdown.registerOnCloseHandler(\n () => $$(facetsMobileModeComponent.element).trigger(FacetsMobileModeEvents.popupClosed),\n facetsMobileModeComponent\n );\n }\n }\n\n private restoreFacetPreservePositionValue() {\n each(this.componentsInFacetColumn, (component, index) => {\n if (component.options) {\n component.options.preservePosition = this.preservePositionOriginalValues[index];\n }\n });\n }\n\n private disableFacetPreservePosition() {\n each(this.componentsInFacetColumn, component => {\n if (component.options) {\n component.options.preservePosition = false;\n }\n });\n }\n\n private isFacetSearchScrolledIntoView(facetSearchElement: HTMLElement) {\n let facetTop = facetSearchElement.getBoundingClientRect().top;\n let facetBottom = facetSearchElement.getBoundingClientRect().bottom;\n let dropdownTop = this.dropdown.dropdownContent.element.el.getBoundingClientRect().top;\n let dropdownBottom = this.dropdown.dropdownContent.element.el.getBoundingClientRect().bottom;\n\n dropdownTop = dropdownTop >= 0 ? dropdownTop : 0;\n\n return facetTop >= dropdownTop && facetBottom <= dropdownBottom;\n }\n\n private getDropdownHeaderLabel() {\n let dropdownHeaderLabel: string;\n ComponentsTypes.getAllFacetInstancesFromElement(this.coveoRoot.find('.coveo-facet-column')).forEach(facet => {\n const options = facet.options as IResponsiveComponentOptions;\n\n if (!dropdownHeaderLabel && options.dropdownHeaderLabel) {\n dropdownHeaderLabel = options.dropdownHeaderLabel;\n }\n });\n\n if (!dropdownHeaderLabel) {\n dropdownHeaderLabel = l(ResponsiveFacetColumn.DROPDOWN_HEADER_LABEL_DEFAULT_VALUE);\n }\n\n return dropdownHeaderLabel;\n }\n\n private handleNoResults() {\n this.dropdown.dropdownHeader.hide();\n }\n\n private handleQueryError() {\n this.dropdown.dropdownHeader.hide();\n }\n\n private handleQuerySuccess(data: IQuerySuccessEventArgs) {\n if (data.results.totalCount === 0) {\n this.dropdown.dropdownHeader.hide();\n } else {\n this.dropdown.dropdownHeader.show();\n }\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResponsiveComponents/ResponsiveFacetColumn.ts","/// \n\nimport { Facet } from '../ui/Facet/Facet';\nimport { IGroupByRequest } from '../rest/GroupByRequest';\nimport { IGroupByResult } from '../rest/GroupByResult';\nimport { ExpressionBuilder } from '../ui/Base/ExpressionBuilder';\nimport { FacetValue } from '../ui/Facet/FacetValue';\nimport { Utils } from '../utils/Utils';\nimport { QueryBuilder } from '../ui/Base/QueryBuilder';\nimport { FacetSearchParameters } from '../ui/Facet/FacetSearchParameters';\nimport { Assert } from '../misc/Assert';\nimport { IIndexFieldValue } from '../rest/FieldValue';\nimport { FacetUtils } from '../ui/Facet/FacetUtils';\nimport { IQueryResults } from '../rest/QueryResults';\nimport { IGroupByValue } from '../rest/GroupByValue';\nimport { IEndpointError } from '../rest/EndpointError';\nimport * as _ from 'underscore';\nimport { QueryBuilderExpression } from '../ui/Base/QueryBuilderExpression';\n\nexport class FacetQueryController {\n public expressionToUseForFacetSearch: string;\n public basicExpressionToUseForFacetSearch: string;\n public advancedExpressionToUseForFacetSearch: string;\n public constantExpressionToUseForFacetSearch: string;\n public lastGroupByRequestIndex: number;\n public lastGroupByRequest: IGroupByRequest;\n public lastGroupByResult: IGroupByResult;\n\n private currentSearchPromise: Promise;\n\n constructor(public facet: Facet) {}\n\n /**\n * Reset the expression for the facet search, used when a new query is triggered\n */\n public prepareForNewQuery() {\n this.lastGroupByRequestIndex = undefined;\n this.expressionToUseForFacetSearch = undefined;\n this.constantExpressionToUseForFacetSearch = undefined;\n }\n\n /**\n * Compute the filter expression that the facet needs to output for the query\n * @returns {string}\n */\n public computeOurFilterExpression(): string {\n const builder = new ExpressionBuilder();\n const selected = this.facet.values.getSelected();\n if (selected.length > 0) {\n if (this.facet.options.useAnd) {\n _.each(selected, (value: FacetValue) => {\n builder.addFieldExpression(this.facet.options.field, '==', [value.value], true);\n });\n } else {\n builder.addFieldExpression(\n this.facet.options.field,\n '==',\n _.map(selected, (value: FacetValue) => value.value),\n true\n );\n }\n }\n const excluded = this.facet.values.getExcluded();\n if (excluded.length > 0) {\n builder.addFieldNotEqualExpression(\n this.facet.options.field,\n _.map(excluded, (value: FacetValue) => value.value),\n true\n );\n }\n if (Utils.isNonEmptyString(this.facet.options.additionalFilter)) {\n builder.add(this.facet.options.additionalFilter);\n }\n return builder.build();\n }\n\n /**\n * Build the group by request for the facet, and insert it in the query builder\n * @param queryBuilder\n */\n public putGroupByIntoQueryBuilder(queryBuilder: QueryBuilder) {\n Assert.exists(queryBuilder);\n\n const allowedValues = this.createGroupByAllowedValues();\n const groupByRequest = this.createBasicGroupByRequest(allowedValues);\n\n const queryOverrideObject = this.createGroupByQueryOverride(queryBuilder);\n if (!Utils.isNullOrUndefined(queryOverrideObject) || !QueryBuilderExpression.isEmpty(queryOverrideObject)) {\n groupByRequest.queryOverride = queryOverrideObject.basic;\n groupByRequest.advancedQueryOverride = queryOverrideObject.advanced;\n groupByRequest.constantQueryOverride = queryOverrideObject.constant;\n this.expressionToUseForFacetSearch = queryOverrideObject.withoutConstant;\n this.basicExpressionToUseForFacetSearch = queryOverrideObject.basic;\n this.advancedExpressionToUseForFacetSearch = queryOverrideObject.advanced;\n this.constantExpressionToUseForFacetSearch = queryOverrideObject.constant;\n } else {\n const parts = queryBuilder.computeCompleteExpressionParts();\n this.expressionToUseForFacetSearch = parts.withoutConstant == null ? '' : parts.withoutConstant;\n this.basicExpressionToUseForFacetSearch = parts.basic == null ? '' : parts.basic;\n this.advancedExpressionToUseForFacetSearch = parts.advanced;\n this.constantExpressionToUseForFacetSearch = parts.constant;\n }\n this.lastGroupByRequestIndex = queryBuilder.groupByRequests.length;\n this.lastGroupByRequest = groupByRequest;\n queryBuilder.groupByRequests.push(groupByRequest);\n }\n\n /**\n * Search inside the facet, using a group by request\n * @param params\n * @param oldLength Optional params, used by the search method to call itself recursively to fetch all required values\n * @returns {Promise|Promise}\n */\n public search(params: FacetSearchParameters, oldLength = params.nbResults): Promise {\n // For search, we want to retrieve the exact values we requested, and not additional ones\n params.completeFacetWithStandardValues = false;\n return new Promise((resolve, reject) => {\n const onResult = (fieldValues?: IIndexFieldValue[]) => {\n const newLength = fieldValues.length;\n fieldValues = this.checkForFacetSearchValuesToRemove(fieldValues, params.valueToSearch);\n if (FacetUtils.needAnotherFacetSearch(fieldValues.length, newLength, oldLength, 5)) {\n // This means that we removed enough values from the returned one that we need to perform a new search with more values requested.\n params.nbResults += 5;\n return this.search(params, fieldValues.length);\n } else {\n resolve(fieldValues);\n }\n };\n\n const searchPromise = this.facet.getEndpoint().search(params.getQuery());\n this.currentSearchPromise = searchPromise;\n\n searchPromise\n .then((queryResults: IQueryResults) => {\n if (this.currentSearchPromise == searchPromise) {\n // params.getQuery() will generate a query for all excluded values + some new values\n // there is no clean way to do a group by and remove some values\n // so instead we request more values than we need, and crop all the one we don't want\n const valuesCropped: IGroupByValue[] = [];\n if (queryResults.groupByResults && queryResults.groupByResults[0]) {\n _.each(queryResults.groupByResults[0].values, (v: IGroupByValue) => {\n if (v.lookupValue) {\n if (!_.contains(params.alwaysExclude, v.lookupValue.toLowerCase())) {\n valuesCropped.push(v);\n }\n } else {\n if (!_.contains(params.alwaysExclude, v.value.toLowerCase())) {\n valuesCropped.push(v);\n }\n }\n });\n }\n onResult(_.first(valuesCropped, params.nbResults));\n } else {\n reject();\n }\n })\n .catch((error: IEndpointError) => {\n reject(error);\n });\n });\n }\n\n public fetchMore(numberOfValuesToFetch: number): Promise {\n const params = new FacetSearchParameters(this.facet);\n params.alwaysInclude = this.facet.options.allowedValues || _.pluck(this.facet.values.getAll(), 'value');\n params.nbResults = numberOfValuesToFetch;\n return this.facet\n .getEndpoint()\n .search(params.getQuery())\n .then((results: IQueryResults) => {\n if (this.facet.options.allowedValues && results && results.groupByResults && results.groupByResults[0]) {\n results.groupByResults[0].values = this.filterByAllowedValueOption(results.groupByResults[0].values);\n }\n return results;\n });\n }\n\n public searchInFacetToUpdateDelta(facetValues: FacetValue[]): Promise {\n const params = new FacetSearchParameters(this.facet);\n const query = params.getQuery();\n query.aq = `${query.aq ? query.aq : ''} ${this.computeOurFilterExpression()}`;\n _.each(facetValues, (facetValue: FacetValue) => {\n facetValue.waitingForDelta = true;\n });\n query.groupBy = [this.createBasicGroupByRequest(_.map(facetValues, (facetValue: FacetValue) => facetValue.value))];\n query.groupBy[0].completeFacetWithStandardValues = false;\n return this.facet.getEndpoint().search(query);\n }\n\n protected createGroupByAllowedValues() {\n // if you want to keep displayed values next time, take all current values as allowed values\n // otherwise take only the selected value\n if (this.facet.options.allowedValues != undefined) {\n return this.facet.options.allowedValues;\n } else if (this.facet.options.customSort != undefined) {\n // If there is a custom sort, we still need to add selectedValues to the group by\n // Filter out duplicates with a lower case comparison on the value\n return this.getUnionWithCustomSortLowercase(this.facet.options.customSort, this.getAllowedValuesFromSelected());\n } else {\n return _.map(this.getAllowedValuesFromSelected(), (facetValue: FacetValue) => facetValue.value);\n }\n }\n\n protected createBasicGroupByRequest(allowedValues?: string[], addComputedField: boolean = true): IGroupByRequest {\n let nbOfRequestedValues = this.facet.numberOfValues;\n if (this.facet.options.customSort != null) {\n // If we have a custom sort, we need to make sure that we always request at least enough values to always receive them\n const usedValues = this.getUnionWithCustomSortLowercase(\n this.facet.options.customSort,\n this.facet.values.getSelected().concat(this.facet.values.getExcluded())\n );\n nbOfRequestedValues = Math.max(nbOfRequestedValues, usedValues.length);\n }\n const groupByRequest: IGroupByRequest = {\n field: this.facet.options.field,\n maximumNumberOfValues: nbOfRequestedValues + (this.facet.options.enableMoreLess ? 1 : 0),\n sortCriteria: this.facet.options.sortCriteria,\n injectionDepth: this.facet.options.injectionDepth,\n completeFacetWithStandardValues: this.facet.options.allowedValues == undefined ? true : false\n };\n if (this.facet.options.lookupField) {\n groupByRequest.lookupField = this.facet.options.lookupField;\n }\n if (allowedValues != null) {\n groupByRequest.allowedValues = allowedValues;\n }\n\n if (addComputedField && Utils.isNonEmptyString(this.facet.options.computedField)) {\n groupByRequest.computedFields = [\n {\n field: this.facet.options.computedField,\n operation: this.facet.options.computedFieldOperation\n }\n ];\n }\n return groupByRequest;\n }\n\n protected getAllowedValuesFromSelected() {\n let facetValues: FacetValue[] = [];\n if (this.facet.options.useAnd || !this.facet.keepDisplayedValuesNextTime) {\n const selected = this.facet.values.getSelected();\n if (selected.length == 0) {\n return undefined;\n }\n facetValues = this.facet.values.getSelected();\n } else {\n facetValues = this.facet.values.getAll();\n }\n return facetValues;\n }\n\n private get additionalFilter() {\n return this.facet.options.additionalFilter ? this.facet.options.additionalFilter : '';\n }\n\n private getUnionWithCustomSortLowercase(customSort: string[], facetValues: FacetValue[]) {\n // This will take the custom sort, compare it against the passed in facetValues\n // The comparison is lowercase.\n // The union of the 2 arrays with duplicated filtered out is returned.\n\n const toCompare = _.map(customSort, (val: string) => {\n return val.toLowerCase();\n });\n const filtered = _.chain(facetValues)\n .filter((facetValue: FacetValue) => {\n return !_.contains(toCompare, facetValue.value.toLowerCase());\n })\n .map((facetValue: FacetValue) => {\n return facetValue.value;\n })\n .value();\n return _.compact(customSort.concat(filtered));\n }\n\n private createGroupByQueryOverride(queryBuilder: QueryBuilder): QueryBuilderExpression {\n let queryBuilderExpression = queryBuilder.computeCompleteExpressionParts();\n\n if (this.queryOverrideIsNeededForMultiSelection()) {\n queryBuilderExpression = this.processQueryOverrideForMultiSelection(queryBuilder, queryBuilderExpression);\n } else {\n queryBuilderExpression.reset();\n }\n if (this.queryOverrideIsNeededForAdditionalFilter()) {\n queryBuilderExpression = this.processQueryOverrideForAdditionalFilter(queryBuilder, queryBuilderExpression);\n }\n\n queryBuilderExpression = this.processQueryOverrideForEmptyValues(queryBuilder, queryBuilderExpression);\n if (QueryBuilderExpression.isEmpty(queryBuilderExpression)) {\n return null;\n }\n return queryBuilderExpression;\n }\n\n private queryOverrideIsNeededForMultiSelection() {\n if (this.facet.options.useAnd) {\n return false;\n }\n if (this.facet.values.hasSelectedOrExcludedValues()) {\n return true;\n }\n return false;\n }\n\n private queryOverrideIsNeededForAdditionalFilter() {\n return Utils.isNonEmptyString(this.additionalFilter);\n }\n\n private processQueryOverrideForMultiSelection(queryBuilder: QueryBuilder, mergeWith: QueryBuilderExpression) {\n if (this.facet.values.hasSelectedOrExcludedValues()) {\n const ourExpression = this.computeOurFilterExpression();\n mergeWith = queryBuilder.computeCompleteExpressionPartsExcept(ourExpression);\n if (QueryBuilderExpression.isEmpty(mergeWith)) {\n mergeWith.advanced = '@uri';\n }\n }\n\n return mergeWith;\n }\n\n private processQueryOverrideForAdditionalFilter(queryBuilder: QueryBuilder, mergeWith: QueryBuilderExpression) {\n if (Utils.isEmptyString(mergeWith.basic)) {\n mergeWith.basic = queryBuilder.expression.build();\n }\n if (Utils.isEmptyString(mergeWith.constant)) {\n const addExistingConstantExpressionIfNotEmpty = queryBuilder.constantExpression.isEmpty()\n ? ''\n : queryBuilder.constantExpression.build() + ' ';\n mergeWith.constant = `${addExistingConstantExpressionIfNotEmpty}${this.additionalFilter}`;\n } else {\n mergeWith.constant = `${mergeWith.constant} ${this.additionalFilter}`;\n }\n\n if (!mergeWith.advanced) {\n mergeWith.advanced = this.getFilterExpressionWithoutOurFilterExpression(queryBuilder);\n }\n\n return mergeWith;\n }\n\n private getFilterExpressionWithoutOurFilterExpression(queryBuilder: QueryBuilder) {\n const expression = new ExpressionBuilder();\n const advancedExpressionParts = queryBuilder.advancedExpression.getParts();\n\n advancedExpressionParts.forEach(part => expression.add(part));\n\n const currentFacetAdvancedExpression = this.computeOurFilterExpression();\n expression.remove(currentFacetAdvancedExpression);\n\n return expression.build();\n }\n\n private processQueryOverrideForEmptyValues(queryBuilder: QueryBuilder, mergeWith: QueryBuilderExpression) {\n const withoutEmptyValues = _.chain(mergeWith)\n .keys()\n .each((key: string) => {\n if (Utils.isEmptyString(mergeWith[key]) || Utils.isNullOrUndefined(mergeWith[key])) {\n delete mergeWith[key];\n }\n })\n .value();\n\n if (_.keys(withoutEmptyValues).length == 0) {\n mergeWith = undefined;\n }\n\n return mergeWith;\n }\n\n private checkForFacetSearchValuesToRemove(fieldValues: IIndexFieldValue[], valueToCheckAgainst: string) {\n const regex = FacetUtils.getRegexToUseForFacetSearch(valueToCheckAgainst, this.facet.options.facetSearchIgnoreAccents);\n\n return _.filter(fieldValues, fieldValue => {\n const isAllowed = _.isEmpty(this.facet.options.allowedValues) || this.isValueAllowedByAllowedValueOption(fieldValue.value);\n const value = this.facet.getValueCaption(fieldValue);\n return isAllowed && regex.test(value);\n });\n }\n\n private filterByAllowedValueOption(values: IGroupByValue[]): IGroupByValue[] {\n return _.filter(values, (value: IGroupByValue) => this.isValueAllowedByAllowedValueOption(value.value));\n }\n\n private isValueAllowedByAllowedValueOption(value: string): boolean {\n return _.some(this.facet.options.allowedValues, allowedValue => {\n const regexContent = this.replaceWildcardsWithRegexEquivalent(this.escapeMostRegexCharacters(allowedValue));\n const regex = new RegExp(`^${regexContent}$`, 'gi');\n return regex.test(value);\n });\n }\n\n private escapeMostRegexCharacters(text: String) {\n // Regex taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n // `*` and `?` were removed because they are used for wildcards\n return text.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n private replaceWildcardsWithRegexEquivalent(text: String) {\n // Allowed value option on the facet should support * (wildcard searches)\n // We need to filter values client side the index will completeWithStandardValues\n // Replace the wildcard (*) for a regex match (.*)\n // Also replace the (?) with \"any character once\" since it is also supported by the index\n return text.replace(/\\*/g, '.*').replace(/\\?/g, '.');\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/controllers/FacetQueryController.ts","/// \nimport { StringUtils } from '../../utils/StringUtils';\nimport { QueryUtils } from '../../utils/QueryUtils';\nimport { FileTypes } from '../Misc/FileTypes';\nimport { DateUtils } from '../../utils/DateUtils';\nimport { Utils } from '../../utils/Utils';\nimport { $$ } from '../../utils/Dom';\nimport * as _ from 'underscore';\nimport FacetModuleDefinition = require('./Facet');\nimport { l } from '../../strings/Strings';\n\nexport class FacetUtils {\n static getRegexToUseForFacetSearch(value: string, ignoreAccent: boolean) {\n return new RegExp(StringUtils.stringToRegex(value, ignoreAccent), 'i');\n }\n\n static getDisplayValueFromValueCaption(value: string, field: string, valueCaption: Record) {\n const returnValue = this.tryToGetTranslatedCaption(field, value, false);\n return valueCaption[value] || returnValue;\n }\n\n static getValuesToUseForSearchInFacet(original: string, facet: FacetModuleDefinition.Facet): string[] {\n let ret = [original];\n let regex = this.getRegexToUseForFacetSearch(original, facet.options.facetSearchIgnoreAccents);\n if (facet.options.valueCaption) {\n _.chain(facet.options.valueCaption)\n .pairs()\n .filter(pair => {\n return regex.test(pair[1]);\n })\n .each(match => {\n ret.push(match[0]);\n });\n if (\n QueryUtils.isStratusAgnosticField(facet.options.field, '@objecttype') ||\n QueryUtils.isStratusAgnosticField(facet.options.field, '@filetype')\n ) {\n _.each(FileTypes.getFileTypeCaptions(), (value: string, key: string) => {\n if (!(key in facet.options.valueCaption) && regex.test(value)) {\n ret.push(key);\n }\n });\n }\n } else if (\n QueryUtils.isStratusAgnosticField(facet.options.field, '@objecttype') ||\n QueryUtils.isStratusAgnosticField(facet.options.field, '@filetype')\n ) {\n _.each(\n _.filter(_.pairs(FileTypes.getFileTypeCaptions()), pair => {\n return regex.test(pair[1]);\n }),\n match => {\n ret.push(match[0]);\n }\n );\n } else if (QueryUtils.isStratusAgnosticField(facet.options.field, '@month')) {\n _.each(_.range(1, 13), month => {\n if (regex.test(DateUtils.monthToString(month - 1))) {\n ret.push(('0' + month.toString()).substr(-2));\n }\n });\n }\n return ret;\n }\n\n static buildFacetSearchPattern(values: string[]) {\n values = _.map(values, value => {\n return Utils.escapeRegexCharacter(value);\n });\n values[0] = '.*' + values[0] + '.*';\n return values.join('|');\n }\n\n static needAnotherFacetSearch(\n currentSearchLength: number,\n newSearchLength: number,\n oldSearchLength: number,\n desiredSearchLength: number\n ) {\n // Something was removed (currentSearch < newSearch)\n // && we might want to display more facet search result(currentSearch < desiredSearch)\n // && the new query returned more stuff than the old one so there's still more results(currentSearchLength > oldLength)\n return currentSearchLength < newSearchLength && currentSearchLength < desiredSearchLength && currentSearchLength > oldSearchLength;\n }\n\n static addNoStateCssClassToFacetValues(facet: FacetModuleDefinition.Facet, container: HTMLElement) {\n // This takes care of adding the correct css class on each facet value checkbox (empty white box) if at least one value is selected in that facet\n if (facet.values.getSelected().length != 0) {\n let noStates = $$(container).findAll('li:not(.coveo-selected)');\n _.each(noStates, noState => {\n $$(noState).addClass('coveo-no-state');\n });\n }\n }\n\n static tryToGetTranslatedCaption(field: string, value: string, fallbackOnLocalization = true) {\n let found: string;\n\n if (QueryUtils.isStratusAgnosticField(field.toLowerCase(), '@filetype')) {\n found = FileTypes.getFileType(value, fallbackOnLocalization).caption;\n } else if (QueryUtils.isStratusAgnosticField(field.toLowerCase(), '@objecttype')) {\n found = FileTypes.getObjectType(value, fallbackOnLocalization).caption;\n } else if (FacetUtils.isMonthFieldValue(field, value)) {\n const month = parseInt(value, 10);\n found = DateUtils.monthToString(month - 1);\n } else if (fallbackOnLocalization) {\n found = l(value);\n }\n return found != undefined && Utils.isNonEmptyString(found) ? found : value;\n }\n\n static isMonthFieldValue(field: string, value: string) {\n if (!QueryUtils.isStratusAgnosticField(field.toLowerCase(), '@month')) {\n return false;\n }\n\n const asInt = parseInt(value, 10);\n\n if (isNaN(asInt)) {\n return false;\n }\n\n if (asInt < 1 || asInt > 12) {\n return false;\n }\n\n return true;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Facet/FacetUtils.ts","import { Template, TemplateRole } from './Template';\nimport { TemplateList } from './TemplateList';\nimport _ = require('underscore');\n\nexport class TableTemplate extends TemplateList {\n instantiateRoleToString(role: TemplateRole) {\n const roledTemplate = _.find(this.templates, t => t.role === role);\n if (roledTemplate) {\n return roledTemplate.instantiateToString(undefined, {});\n } else {\n return this.defaultRoledTemplates[role];\n }\n }\n instantiateRoleToElement(role: TemplateRole) {\n const roledTemplate = _.find(this.templates, t => t.role === role);\n if (roledTemplate) {\n return roledTemplate.instantiateToElement(undefined, {});\n } else {\n const tmpl = new Template(() => this.defaultRoledTemplates[role]);\n tmpl.layout = 'table';\n return tmpl.instantiateToElement(undefined);\n }\n }\n\n private defaultTemplate = `