{"version":3,"sources":["SortDropdown.min__00ecf0bd3e47c7b52b32.js","./src/ui/Sort/Sort.ts","./src/ui/SortDropdown/SortDropdown.ts","./src/ui/Sort/SortCriteria.ts","./src/ui/FormWidgets/Dropdown.ts"],"names":["webpackJsonpCoveo__temporary","192","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","Sort","ID","ComponentOptions","initComponentOptions","Assert","isLargerOrEqualsThan","sortCriteria","length","bind","onQueryState","MODEL_EVENTS","CHANGE_ONE","QUERY_STATE_ATTRIBUTES","SORT","handleQueryStateChanged","onRootElement","QueryEvents","querySuccess","args","handleQuerySuccess","buildingQuery","handleBuildingQuery","queryError","handleQueryError","ensureDom","_this","createDom","el","$$","on","selectAndExecuteQuery","innerText","text","empty","findOrCreateRadioGroup","createSortButton","isToggle","createDirectionButton","update","select","direction","currentCriteria","find","criteria","updateQueryStateModel","Utils","exists","selectNextCriteria","selectFirstCriteria","oldCriteria","executeSearchQuery","enable","removeClass","disable","addClass","getCurrentCriteria","match","sortId","any","toString","radioGroup","findRadioGroup","setAttribute","sortButton","caption","AccessibleButton","withElement","withEnterKeyboardAction","withArrowsAction","e","onArrowPressed","withLabel","getDirectionalLabel","initialDirection","getOmnidirectionalLabel","withRole","build","appendChild","directionButton","className","createIcons","withSelectAction","stopPropagation","selectNextCriteriaAndExecuteQuery","VALID_DIRECTION","DESCENDING","ASCENDING","selectNextRadioButton","ArrowDirection","RIGHT","DOWN","iconAscending","SVGIcons","icons","arrowUp","SVGDom","addClassToSVGInContainer","iconDescending","arrowDown","document","body","getAttribute","parentElement","indexToSelect","radioButtons","findAll","currentIndex","findIndex","radio","radioToSelect","focus","click","queryController","deferExecuteQuery","beforeExecuteQuery","logSortEvent","usageAnalytics","sort","indexOfCurrentCriteria","indexOf","queryStateModel","get","QueryStateModel","attributesEnum","isNonEmptyString","criteriaFromModel","SortCriteria","parse","equals","updateAppearance","updateAccessibilityProperties","enumerable","configurable","captionIsDefined","textContent","data","defaultAttributes","isSelected","putInQueryBuilder","queryBuilder","results","toggleClass","currentDirection","resultListsIds","directionIsInitial","searchInterface","getComponents","map","resultList","id","join","localizedCaption","l","displayedSortText","set","doExport","exportGlobally","buildCustomListOption","values","required","buildLocalizedStringOption","Component","Initialization","registerAutoCreateComponent","294","SortDropdown","sortComponents","removeTabSupport","oneRootElement","InitializationEvents","afterInitialization","handleAfterInitialization","buildDropdown","clearDropdown","dropdown","removeChild","getElement","getEnabledSortComponents","Dropdown","handleChange","getValuesForDropdown","getCaptionForValue","computeCssClassNameForType","sortElement","sortCmp","logger","warn","filter","disabled","executeQuery","sortIndex","getSortIndex","showElement","hideElement","selectedValue","getValue","itemValue","hide","show","498","VALID_SORT","SortCriterion","sortIsField","check","isValidSort","sortNeedsDirection","isValidDirection","chain","contains","charAt","sortsNeedingDirection","DATE","rawCriteriaString","split","forEach","criterion","push","first","575","62","onChange","listOfValues","getDisplayValue","label","optionsElement","buildContent","bindEvents","reset","setId","selectElement","index","executeOnChange","selectOption","setValue","_","each","option","selectOptions","buildOptions","opt","append","ret","buildOption","697"],"mappings":"AAAAA,8BAA8B,GAAG,GAAG,KAE9BC,IACA,SAAUC,EAAQC,EAASC,GAEjC,YAEA,IAAIC,GAAaC,MAAQA,KAAKD,WAAc,WACxC,GAAIE,GAAgBC,OAAOC,iBACpBC,uBAA2BC,QAAS,SAAUC,EAAGC,GAAKD,EAAEF,UAAYG,IACvE,SAAUD,EAAGC,GAAK,IAAK,GAAIC,KAAKD,GAAOA,EAAEE,eAAeD,KAAIF,EAAEE,GAAKD,EAAEC,IACzE,OAAO,UAAUF,EAAGC,GAEhB,QAASG,KAAOV,KAAKW,YAAcL,EADnCL,EAAcK,EAAGC,GAEjBD,EAAEM,UAAkB,OAANL,EAAaL,OAAOW,OAAON,IAAMG,EAAGE,UAAYL,EAAEK,UAAW,GAAIF,OAGvFR,QAAOY,eAAejB,EAAS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,UAAW,mBACVpD,GAEC9C,KAAKkP,OACPlP,KAAKwP,cAAcvK,aAAa,aAAc,EAAA0F,EAAE3K,KAAKkP,OAGvD,IAAMc,GAAgBhQ,KAAKiQ,cAC3BJ,GAAEC,KAAKE,EAAe,SAAAE,GACpB,EAAAnN,GAAG,EAAKyM,eAAeW,OAAOD,KAEhClQ,KAAKgB,QAAUhB,KAAKwP,eAGd,YAAAS,aAAR,sBACQG,IAIN,OAHAP,GAAEC,KAAK9P,KAAKgP,aAAc,SAACjO,GACzBqP,EAAIzB,KAAK,EAAK0B,YAAYtP,MAErBqP,GAGD,YAAAC,YAAR,SAAoBtP,GAClB,GAAMgP,GAAS,EAAAhN,GAAG,SAKlB,OAJAgN,GAAO9K,aAAa,aAAclE,GAClCgP,EAAO9K,aAAa,QAASlE,GAC7BgP,EAAO5M,KAAKnD,KAAKiP,gBAAgBlO,IACjCf,KAAKmP,eAAeR,KAAwBoB,EAAOjN,IAC5CiN,EAAOjN,IAGR,YAAAuM,WAAR,qBACE,GAAAtM,GAAG/C,KAAKwP,eAAexM,GAAG,SAAU,WAAM,SAAK+L,SAAS,MAE5D,IAnIa,GAAA1C,YJ20BPiE,IACA,SAAU1Q,EAAQC","file":"SortDropdown.min__00ecf0bd3e47c7b52b32.js","sourcesContent":["webpackJsonpCoveo__temporary([23,39,83],{\n\n/***/ 192:\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 });\n__webpack_require__(575);\nvar GlobalExports_1 = __webpack_require__(3);\nvar QueryEvents_1 = __webpack_require__(11);\nvar Assert_1 = __webpack_require__(5);\nvar Model_1 = __webpack_require__(18);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Dom_1 = __webpack_require__(1);\nvar SVGDom_1 = __webpack_require__(15);\nvar SVGIcons_1 = __webpack_require__(12);\nvar Utils_1 = __webpack_require__(4);\nvar SharedAnalyticsCalls_1 = __webpack_require__(119);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\nvar SortCriteria_1 = __webpack_require__(498);\nvar AccessibleButton_1 = __webpack_require__(16);\nvar Strings_1 = __webpack_require__(6);\nvar underscore_1 = __webpack_require__(0);\n/**\n * The `Sort` component renders a widget that the end user can interact with to select the criterion to use when sorting query results.\n *\n * To improve accessibility, it's recommended to group `Sort` components in a container with `role=\"radiogroup\"`.\n */\nvar Sort = /** @class */ (function (_super) {\n    __extends(Sort, _super);\n    /**\n     * Creates a new `Sort` component instance.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for this component instance.\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     */\n    function Sort(element, options, bindings) {\n        var _this = _super.call(this, element, Sort.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, Sort, options);\n        Assert_1.Assert.isLargerOrEqualsThan(1, _this.options.sortCriteria.length);\n        _this.bind.onQueryState(Model_1.MODEL_EVENTS.CHANGE_ONE, QueryStateModel_1.QUERY_STATE_ATTRIBUTES.SORT, function () { return _this.handleQueryStateChanged(); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (args) { return _this.handleQuerySuccess(args); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function (args) { return _this.handleQueryError(args); });\n        _this.ensureDom();\n        return _this;\n    }\n    Sort.prototype.createDom = function () {\n        var _this = this;\n        var el = Dom_1.$$(this.element);\n        el.on('click', function () { return _this.selectAndExecuteQuery(); });\n        var innerText = el.text();\n        el.empty();\n        this.findOrCreateRadioGroup();\n        this.createSortButton(innerText);\n        if (this.isToggle()) {\n            this.createDirectionButton();\n        }\n        this.update();\n    };\n    /**\n     * Selects this `Sort` component.\n     *\n     * Updates the state model if selecting this component toggles its current [`sortCriteria`]{@link Sort.options.sortCriteria}.\n     *\n     * @param direction The sort direction. Can be one of: `ascending`, `descending`.\n     */\n    Sort.prototype.select = function (direction) {\n        if (direction) {\n            this.currentCriteria = underscore_1.find(this.options.sortCriteria, function (criteria) {\n                return criteria.direction == direction;\n            });\n            this.updateQueryStateModel();\n        }\n        else if (Utils_1.Utils.exists(this.currentCriteria)) {\n            this.selectNextCriteria();\n        }\n        else {\n            this.selectFirstCriteria();\n        }\n    };\n    /**\n     * Selects this `Sort` component, then triggers a query if selecting this component toggles its current [`sortCriteria`]{@link Sort.options.sortCriteria}.\n     *\n     * Also logs an event in the usage analytics with the new current sort criteria.\n     */\n    Sort.prototype.selectAndExecuteQuery = function () {\n        var oldCriteria = this.currentCriteria;\n        this.select();\n        if (oldCriteria != this.currentCriteria) {\n            this.executeSearchQuery();\n        }\n    };\n    Sort.prototype.enable = function () {\n        Dom_1.$$(this.element).removeClass('coveo-tab-disabled');\n        this.update();\n        _super.prototype.enable.call(this);\n    };\n    Sort.prototype.disable = function () {\n        Dom_1.$$(this.element).addClass('coveo-tab-disabled');\n        _super.prototype.disable.call(this);\n    };\n    /**\n     * Gets the current [`sortCriteria`]{@link Sort.options.sortCriteria} of this `Sort` component.\n     * @returns {SortCriteria}\n     */\n    Sort.prototype.getCurrentCriteria = function () {\n        return this.currentCriteria;\n    };\n    /**\n     * Indicates whether the name of any of the available [`sortCriteria`]{@link Sort.options.sortCriteria} of this `Sort` component matches the argument.\n     * @param sortId The sort criteria name to look for (e.g., `date descending`).\n     */\n    Sort.prototype.match = function (sortId) {\n        return underscore_1.any(this.options.sortCriteria, function (sortCriteria) { return sortId == sortCriteria.toString(); });\n    };\n    Sort.prototype.findOrCreateRadioGroup = function () {\n        this.radioGroup = this.findRadioGroup();\n        if (!this.radioGroup) {\n            this.element.setAttribute('role', 'radiogroup');\n            this.radioGroup = this.element;\n        }\n    };\n    Sort.prototype.createSortButton = function (innerText) {\n        var _this = this;\n        this.sortButton = Dom_1.$$('span').el;\n        this.sortButton.innerText = this.options.caption || innerText;\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(this.sortButton)\n            .withEnterKeyboardAction(function () { return _this.selectAndExecuteQuery(); })\n            .withArrowsAction(function (direction, e) { return _this.onArrowPressed(direction, e); })\n            .withLabel(this.isToggle() ? this.getDirectionalLabel(this.initialDirection) : this.getOmnidirectionalLabel())\n            .withRole('radio')\n            .build();\n        this.element.appendChild(this.sortButton);\n    };\n    Sort.prototype.createDirectionButton = function () {\n        var _this = this;\n        this.directionButton = Dom_1.$$.apply(void 0, ['span', { className: 'coveo-icon' }].concat(this.createIcons())).el;\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(this.directionButton)\n            .withSelectAction(function (e) {\n            e.stopPropagation();\n            _this.selectNextCriteriaAndExecuteQuery();\n        })\n            .withArrowsAction(function (direction, e) { return _this.onArrowPressed(direction, e); })\n            .withLabel(this.getDirectionalLabel(this.initialDirection === SortCriteria_1.VALID_DIRECTION.DESCENDING ? SortCriteria_1.VALID_DIRECTION.ASCENDING : SortCriteria_1.VALID_DIRECTION.DESCENDING))\n            .withRole('radio')\n            .build();\n        this.element.appendChild(this.directionButton);\n    };\n    Sort.prototype.onArrowPressed = function (direction, e) {\n        this.selectNextRadioButton(direction === AccessibleButton_1.ArrowDirection.RIGHT || direction === AccessibleButton_1.ArrowDirection.DOWN ? 1 : -1);\n        e.stopPropagation();\n    };\n    Sort.prototype.createIcons = function () {\n        var iconAscending = Dom_1.$$('span', { className: 'coveo-sort-icon-ascending' }, SVGIcons_1.SVGIcons.icons.arrowUp);\n        SVGDom_1.SVGDom.addClassToSVGInContainer(iconAscending.el, 'coveo-sort-icon-ascending-svg');\n        var iconDescending = Dom_1.$$('span', { className: 'coveo-sort-icon-descending' }, SVGIcons_1.SVGIcons.icons.arrowDown);\n        SVGDom_1.SVGDom.addClassToSVGInContainer(iconDescending.el, 'coveo-sort-icon-descending-svg');\n        return [iconAscending, iconDescending];\n    };\n    Sort.prototype.findRadioGroup = function (element) {\n        if (element === void 0) { element = this.element; }\n        if (!element || element === document.body) {\n            return null;\n        }\n        if (element.getAttribute('role') === 'radiogroup') {\n            return element;\n        }\n        return this.findRadioGroup(element.parentElement);\n    };\n    Sort.prototype.selectNextRadioButton = function (direction) {\n        if (direction === void 0) { direction = 1; }\n        var radioButtons = Dom_1.$$(this.radioGroup).findAll('[role=\"radio\"]');\n        var currentIndex = underscore_1.findIndex(radioButtons, function (radio) { return radio.getAttribute('aria-checked') === 'true'; });\n        var indexToSelect;\n        var isAnythingSelected = currentIndex !== -1;\n        if (isAnythingSelected) {\n            indexToSelect = (currentIndex + direction + radioButtons.length) % radioButtons.length;\n        }\n        else {\n            if (direction >= 0) {\n                indexToSelect = 0;\n            }\n            else {\n                indexToSelect = radioButtons.length - 1;\n            }\n        }\n        var radioToSelect = radioButtons[indexToSelect];\n        radioToSelect.focus();\n        radioToSelect.click();\n    };\n    Sort.prototype.executeSearchQuery = function () {\n        var _this = this;\n        this.queryController.deferExecuteQuery({\n            beforeExecuteQuery: function () { return SharedAnalyticsCalls_1.logSortEvent(_this.usageAnalytics, _this.currentCriteria.sort + _this.currentCriteria.direction); }\n        });\n    };\n    Sort.prototype.selectFirstCriteria = function () {\n        this.currentCriteria = this.options.sortCriteria[0];\n        this.updateQueryStateModel();\n    };\n    Sort.prototype.selectNextCriteria = function () {\n        var indexOfCurrentCriteria = this.currentCriteria ? this.options.sortCriteria.indexOf(this.currentCriteria) : 0;\n        this.currentCriteria = this.options.sortCriteria[(indexOfCurrentCriteria + 1) % this.options.sortCriteria.length];\n        this.updateQueryStateModel();\n    };\n    Sort.prototype.selectNextCriteriaAndExecuteQuery = function () {\n        var oldCriteria = this.currentCriteria;\n        this.selectNextCriteria();\n        if (oldCriteria != this.currentCriteria) {\n            this.executeSearchQuery();\n        }\n    };\n    Sort.prototype.handleQueryStateChanged = function () {\n        this.update();\n    };\n    Sort.prototype.update = function () {\n        // Basically, if the criteria in the model fits with one of ours, it'll become our active criteria\n        var sortCriteria = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.sort);\n        if (Utils_1.Utils.isNonEmptyString(sortCriteria)) {\n            var criteriaFromModel = SortCriteria_1.SortCriteria.parse(sortCriteria);\n            this.currentCriteria = underscore_1.find(this.options.sortCriteria, function (criteria) { return criteriaFromModel.equals(criteria); });\n        }\n        else {\n            this.currentCriteria = null;\n        }\n        this.updateAppearance();\n        this.updateAccessibilityProperties();\n    };\n    Object.defineProperty(Sort.prototype, \"captionIsDefined\", {\n        get: function () {\n            return Utils_1.Utils.isNonEmptyString(this.options.caption);\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Sort.prototype, \"currentDirection\", {\n        get: function () {\n            return this.currentCriteria ? this.currentCriteria.direction : this.initialDirection;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Sort.prototype, \"initialDirection\", {\n        get: function () {\n            return this.options.sortCriteria[0].direction;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(Sort.prototype, \"displayedSortText\", {\n        get: function () {\n            return this.captionIsDefined ? this.options.caption : this.element.textContent;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Sort.prototype.handleBuildingQuery = function (data) {\n        Assert_1.Assert.exists(data);\n        var sort = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.sort);\n        if (sort == QueryStateModel_1.QueryStateModel.defaultAttributes.sort || this.isSelected()) {\n            if (this.currentCriteria) {\n                this.currentCriteria.putInQueryBuilder(data.queryBuilder);\n            }\n        }\n    };\n    Sort.prototype.handleQuerySuccess = function (data) {\n        if (data.results.results.length == 0) {\n            Dom_1.$$(this.element).addClass('coveo-sort-hidden');\n        }\n        else {\n            Dom_1.$$(this.element).removeClass('coveo-sort-hidden');\n        }\n    };\n    Sort.prototype.handleQueryError = function (data) {\n        Dom_1.$$(this.element).addClass('coveo-sort-hidden');\n    };\n    Sort.prototype.isToggle = function () {\n        return this.options.sortCriteria.length > 1;\n    };\n    Sort.prototype.isSelected = function () {\n        return Utils_1.Utils.exists(this.currentCriteria);\n    };\n    Sort.prototype.updateAppearance = function () {\n        Dom_1.$$(this.element).toggleClass('coveo-selected', this.isSelected());\n        if (this.isToggle()) {\n            Dom_1.$$(this.element).removeClass('coveo-ascending');\n            Dom_1.$$(this.element).removeClass('coveo-descending');\n            if (this.isSelected()) {\n                Dom_1.$$(this.element).addClass(this.currentDirection === 'ascending' ? 'coveo-ascending' : 'coveo-descending');\n            }\n        }\n    };\n    Sort.prototype.updateAccessibilityProperties = function () {\n        this.sortButton.setAttribute('aria-controls', this.resultListsIds);\n        var directionIsInitial = this.currentDirection === this.initialDirection;\n        this.sortButton.setAttribute('aria-checked', \"\" + (this.isSelected() && directionIsInitial));\n        if (this.isToggle()) {\n            this.directionButton.setAttribute('aria-controls', this.resultListsIds);\n            this.directionButton.setAttribute('aria-checked', \"\" + (this.isSelected() && !directionIsInitial));\n        }\n    };\n    Object.defineProperty(Sort.prototype, \"resultListsIds\", {\n        get: function () {\n            var resultLists = this.searchInterface.getComponents('ResultList');\n            return resultLists.map(function (resultList) { return resultList.element.id; }).join(' ');\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Sort.prototype.getDirectionalLabel = function (direction) {\n        var localizedCaption = Strings_1.l(this.displayedSortText);\n        return direction === SortCriteria_1.VALID_DIRECTION.DESCENDING\n            ? Strings_1.l('SortResultsByDescending', localizedCaption)\n            : Strings_1.l('SortResultsByAscending', localizedCaption);\n    };\n    Sort.prototype.getOmnidirectionalLabel = function () {\n        var localizedCaption = Strings_1.l(this.displayedSortText);\n        return Strings_1.l('SortResultsBy', localizedCaption);\n    };\n    Sort.prototype.updateQueryStateModel = function () {\n        this.queryStateModel.set(QueryStateModel_1.QueryStateModel.attributesEnum.sort, this.currentCriteria.toString());\n    };\n    Sort.ID = 'Sort';\n    Sort.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            Sort: Sort,\n            SortCriteria: SortCriteria_1.SortCriteria\n        });\n    };\n    /**\n     * Options for the component\n     * @componentOptions\n     */\n    Sort.options = {\n        /**\n         * The sort criterion/criteria the end user can select/toggle between when interacting with this component instance.\n         *\n         * The available sort criteria are:\n         * - `relevancy`\n         * - `date ascending`/`date descending`\n         * - `qre`\n         * - `@field ascending`/`@field descending`, where you must replace `field` with the name of a sortable field in your index (e.g., `data-sort-criteria=\"@size ascending\"`).\n         *\n         * You can specify a comma separated list of sort criteria to toggle between when interacting with this component instance (e.g., `data-sort-criteria=\"date descending,date ascending\"`).\n         *\n         * You can specify multiple sort criteria to be used in the same request by separating them with a semicolon (e.g., `data-sort-criteria=\"@size ascending;date ascending\"` ).\n         *\n         * Interacting with this component instance will cycle through those criteria in the order they are listed in.\n         * Typically, you should only specify a list of sort criteria when you want the end user to be able to to toggle the direction of a `date` or `@field` sort criteria.\n         * Otherwise, you should configure a distinct `Sort` component instance for each sort criterion you want to make available in your search page.\n         *\n         * You must specify a valid value for this option in order for this component instance to work correctly.\n         *\n         * Examples:\n         *\n         * - `data-sort-criteria=\"date ascending\"` createes a Sort component that allows to sort on `date ascending`, without being able to toggle the order.\n         * - `data-sort-criteria=\"date ascending, date descending\"` creates a Sort component that allows end users to toggle between `date ascending` and `date descending` on click.\n         * - `data-sort-criteria=\"@size ascending; date descending\"` creates a Sort component that only allows end users to sort on `@size ascending`. The index then applies a second sort on `date descending` when two items are of equal value.\n         * - `data-sort-criteria=\"@size ascending; date descending, @size descending; date descending\"` creates a Sort component that allows end users to toggle between `@size ascending` and `@size descending`. For each value, the index applies a second sort on `date descending` when two items are of equal value.\n         */\n        sortCriteria: ComponentOptions_1.ComponentOptions.buildCustomListOption(function (values) {\n            return values.map(function (criteria) {\n                // 'any' because Underscore won't accept the union type as an argument.\n                if (typeof criteria === 'string') {\n                    return new SortCriteria_1.SortCriteria(criteria);\n                }\n                else {\n                    return criteria;\n                }\n            });\n        }, { required: true }),\n        /**\n         * The caption to display on this component instance.\n         *\n         * By default, the component uses the text content of the element it is instanciated on.\n         */\n        caption: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({ required: true })\n    };\n    return Sort;\n}(Component_1.Component));\nexports.Sort = Sort;\nInitialization_1.Initialization.registerAutoCreateComponent(Sort);\n\n\n/***/ }),\n\n/***/ 294:\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 });\n__webpack_require__(697);\nvar underscore_1 = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\nvar QueryEvents_1 = __webpack_require__(11);\nvar Model_1 = __webpack_require__(18);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Dom_1 = __webpack_require__(1);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\nvar InitializationEvents_1 = __webpack_require__(17);\nvar Sort_1 = __webpack_require__(192);\nvar Dropdown_1 = __webpack_require__(62);\nvar Strings_1 = __webpack_require__(6);\n/**\n * The `SortDropdown` component renders a dropdown that the end user can interact with to select the criteria to use when sorting query results.\n *\n * It is meant to be a parent of regular [`Sort`]{@link Sort} components. Example:\n * ```\n * <div class=\"CoveoSortDropdown\">\n *   <span class=\"CoveoSort\" data-sort-criteria=\"relevancy\" data-caption=\"Relevance\"></span>\n *   <span class=\"CoveoSort\" data-sort-criteria=\"date descending\" data-caption=\"Newest\"></span>\n *   <span class=\"CoveoSort\" data-sort-criteria=\"date ascending\" data-caption=\"Oldest\"></span>\n * </div>\n * ```\n * Each one of the children `Sort` components should have only one sort criteria to prevent the regular toggle behaviour.\n *\n * @availablesince [March 2020 Release (v2.8521)](https://docs.coveo.com/en/3203/)\n */\nvar SortDropdown = /** @class */ (function (_super) {\n    __extends(SortDropdown, _super);\n    /**\n     * Creates a new `SortDropdown` component instance.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for this component instance.\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     */\n    function SortDropdown(element, options, bindings) {\n        var _this = _super.call(this, element, SortDropdown.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.sortComponents = [];\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, SortDropdown, options);\n        _this.removeTabSupport();\n        _this.bind.oneRootElement(InitializationEvents_1.InitializationEvents.afterInitialization, function () { return _this.handleAfterInitialization(); });\n        _this.bind.onQueryState(Model_1.MODEL_EVENTS.CHANGE_ONE, QueryStateModel_1.QUERY_STATE_ATTRIBUTES.SORT, function (args) {\n            return _this.handleQueryStateChanged(args);\n        });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.querySuccess, function (args) { return _this.handleQuerySuccess(args); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function (args) { return _this.handleQueryError(args); });\n        return _this;\n    }\n    SortDropdown.prototype.handleAfterInitialization = function () {\n        this.buildDropdown();\n    };\n    SortDropdown.prototype.clearDropdown = function () {\n        this.dropdown && this.element.removeChild(this.dropdown.getElement());\n        this.dropdown = null;\n    };\n    SortDropdown.prototype.buildDropdown = function () {\n        var _this = this;\n        this.sortComponents = this.getEnabledSortComponents();\n        this.clearDropdown();\n        if (!this.sortComponents.length) {\n            return;\n        }\n        this.dropdown = new Dropdown_1.Dropdown(function () { return _this.handleChange(); }, this.getValuesForDropdown(), function (value) { return _this.getCaptionForValue(value); }, Strings_1.l('SortBy'));\n        this.element.appendChild(this.dropdown.getElement());\n        this.update();\n    };\n    SortDropdown.prototype.getEnabledSortComponents = function () {\n        var _this = this;\n        var sortComponents = Dom_1.$$(this.element)\n            .findAll(\".\" + Component_1.Component.computeCssClassNameForType('Sort'))\n            .map(function (sortElement) {\n            var sortCmp = Component_1.Component.get(sortElement, Sort_1.Sort);\n            if (sortCmp.options.sortCriteria.length == 1) {\n                return sortCmp;\n            }\n            else {\n                _this.logger.warn(\"Each Sort component inside a SortDropdown should have only one sort criteria. Skipping \" + sortCmp.options.caption + \" in the SortDropdown.\");\n                return;\n            }\n        })\n            .filter(function (sortCmp) { return sortCmp && !sortCmp.disabled; });\n        return sortComponents;\n    };\n    SortDropdown.prototype.getValuesForDropdown = function () {\n        return this.sortComponents.map(function (sort) { return sort.options.sortCriteria.toString(); });\n    };\n    SortDropdown.prototype.handleQueryStateChanged = function (data) {\n        this.update();\n    };\n    SortDropdown.prototype.update = function () {\n        if (!this.dropdown) {\n            return;\n        }\n        var sortCriteria = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.sort);\n        this.select(sortCriteria);\n    };\n    /**\n     * Selects a sort criteria from the options.\n     * @param sortCriteria The sort criteria to select.\n     * @param executeQuery Whether to execute a query after changing the sort criteria\n     */\n    SortDropdown.prototype.select = function (sortCriteria, executeQuery) {\n        if (executeQuery === void 0) { executeQuery = false; }\n        var sortIndex = this.getSortIndex(sortCriteria);\n        sortIndex > -1 && this.dropdown.select(sortIndex, executeQuery);\n        Dom_1.$$(this.dropdown.getElement()).toggleClass('coveo-selected', sortIndex > -1);\n    };\n    SortDropdown.prototype.handleQuerySuccess = function (data) {\n        if (!data.results.results.length) {\n            return this.hideElement();\n        }\n        this.buildDropdown();\n        if (!this.sortComponents.length) {\n            return this.hideElement();\n        }\n        this.showElement();\n    };\n    SortDropdown.prototype.handleQueryError = function (data) {\n        this.hideElement();\n    };\n    SortDropdown.prototype.handleChange = function () {\n        var selectedValue = this.dropdown.getValue();\n        var sortIndex = this.getSortIndex(selectedValue);\n        sortIndex > -1 && this.sortComponents[sortIndex].selectAndExecuteQuery();\n    };\n    SortDropdown.prototype.getCaptionForValue = function (value) {\n        var sortIndex = this.getSortIndex(value);\n        return sortIndex > -1 ? this.sortComponents[sortIndex].options.caption : '';\n    };\n    SortDropdown.prototype.getSortIndex = function (itemValue) {\n        return underscore_1.findIndex(this.sortComponents, function (sort) { return sort.options.sortCriteria.toString() === itemValue; });\n    };\n    SortDropdown.prototype.hideElement = function () {\n        Dom_1.$$(this.element).hide();\n    };\n    SortDropdown.prototype.showElement = function () {\n        Dom_1.$$(this.element).show();\n    };\n    SortDropdown.ID = 'SortDropdown';\n    SortDropdown.options = {};\n    SortDropdown.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            SortDropdown: SortDropdown\n        });\n    };\n    return SortDropdown;\n}(Component_1.Component));\nexports.SortDropdown = SortDropdown;\nInitialization_1.Initialization.registerAutoCreateComponent(SortDropdown);\n\n\n/***/ }),\n\n/***/ 498:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar underscore_1 = __webpack_require__(0);\nvar Assert_1 = __webpack_require__(5);\nvar VALID_SORT;\n(function (VALID_SORT) {\n    VALID_SORT[\"RELEVANCY\"] = \"relevancy\";\n    VALID_SORT[\"DATE\"] = \"date\";\n    VALID_SORT[\"QRE\"] = \"qre\";\n})(VALID_SORT = exports.VALID_SORT || (exports.VALID_SORT = {}));\nvar VALID_DIRECTION;\n(function (VALID_DIRECTION) {\n    VALID_DIRECTION[\"ASCENDING\"] = \"ascending\";\n    VALID_DIRECTION[\"DESCENDING\"] = \"descending\";\n})(VALID_DIRECTION = exports.VALID_DIRECTION || (exports.VALID_DIRECTION = {}));\nvar SortCriterion = /** @class */ (function () {\n    /**\n     * Create a new SortCriteria\n     * @param sort The sort criteria (e.g.: relevancy, date)\n     * @param direction The direction by which to sort (e.g.: ascending, descending)\n     */\n    function SortCriterion(sort, direction) {\n        if (direction === void 0) { direction = ''; }\n        this.sort = sort;\n        this.direction = direction;\n        if (!SortCriterion.sortIsField(sort)) {\n            Assert_1.Assert.check(this.isValidSort(sort), sort + \" is not a valid sort criteria. Valid values are \" + underscore_1.values(VALID_SORT) + \" or a valid index sortable index field.\");\n        }\n        if (SortCriterion.sortNeedsDirection(sort)) {\n            Assert_1.Assert.check(this.isValidDirection(direction), direction + \" is not a valid sort criteria direction. Valid values are \" + underscore_1.values(VALID_DIRECTION));\n        }\n        else {\n            Assert_1.Assert.check(direction == '');\n        }\n    }\n    SortCriterion.prototype.isValidDirection = function (direction) {\n        return underscore_1.chain(VALID_DIRECTION)\n            .values()\n            .contains(direction)\n            .value();\n    };\n    SortCriterion.prototype.isValidSort = function (sort) {\n        return underscore_1.chain(VALID_SORT)\n            .values()\n            .contains(sort)\n            .value();\n    };\n    SortCriterion.sortIsField = function (criteria) {\n        return criteria.charAt(0) == '@';\n    };\n    SortCriterion.sortNeedsDirection = function (sort) {\n        return underscore_1.contains(SortCriterion.sortsNeedingDirection, sort) || SortCriterion.sortIsField(sort);\n    };\n    SortCriterion.sortsNeedingDirection = [VALID_SORT.DATE];\n    return SortCriterion;\n}());\nexports.SortCriterion = SortCriterion;\nvar SortCriteria = /** @class */ (function () {\n    function SortCriteria(rawCriteriaString) {\n        var _this = this;\n        this.criteria = [];\n        var criteria = rawCriteriaString.split(';');\n        criteria.forEach(function (criterion) {\n            var split = criterion.match(/\\S+/g);\n            _this.criteria.push(new SortCriterion(split[0], split[1]));\n        });\n    }\n    Object.defineProperty(SortCriteria.prototype, \"direction\", {\n        get: function () {\n            return underscore_1.first(this.criteria).direction;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    Object.defineProperty(SortCriteria.prototype, \"sort\", {\n        get: function () {\n            return underscore_1.first(this.criteria).sort;\n        },\n        enumerable: true,\n        configurable: true\n    });\n    /**\n     * Return a new SortCriteria from a string\n     * @param criteria The string from which to create the SortCriteria\n     */\n    SortCriteria.parse = function (criteria) {\n        return new SortCriteria(criteria);\n    };\n    /**\n     * Put the sort criteria in the passed queryBuilder\n     * @param queryBuilder The queryBuilder in which to put the sort criteria.\n     */\n    SortCriteria.prototype.putInQueryBuilder = function (queryBuilder) {\n        Assert_1.Assert.exists(queryBuilder);\n        queryBuilder.sortCriteria = this.toString()\n            .split(';')\n            .join(',');\n    };\n    /**\n     * Returns a string representation of the sort criteria (e.g.: 'date ascending').\n     */\n    SortCriteria.prototype.toString = function () {\n        return this.criteria\n            .map(function (criterion) {\n            return criterion.direction ? criterion.sort + \" \" + criterion.direction : \"\" + criterion.sort;\n        })\n            .join(';');\n    };\n    /**\n     * Checks if the SortCriteria is equal to another.\n     * @param criteria The SortCriteria to compare with\n     */\n    SortCriteria.prototype.equals = function (criteria) {\n        return criteria.toString() == this.toString();\n    };\n    return SortCriteria;\n}());\nexports.SortCriteria = SortCriteria;\n\n\n/***/ }),\n\n/***/ 575:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 62:\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 _ = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\n/**\n * A dropdown widget with standard styling.\n */\nvar Dropdown = /** @class */ (function () {\n    /**\n     * Creates a new `Dropdown`.\n     * @param onChange The function to call when the dropdown selected value changes. This function takes the current\n     * `Dropdown` instance as an argument.\n     * @param listOfValues The selectable values to display in the dropdown.\n     * @param getDisplayValue An optional function to modify the display values, rather than using the values as they\n     * appear in the `listOfValues`.\n     * @param label The label to use for the input for accessibility purposes.\n     */\n    function Dropdown(onChange, listOfValues, getDisplayValue, label) {\n        if (onChange === void 0) { onChange = function (dropdown) { }; }\n        if (getDisplayValue === void 0) { getDisplayValue = Strings_1.l; }\n        this.onChange = onChange;\n        this.listOfValues = listOfValues;\n        this.getDisplayValue = getDisplayValue;\n        this.label = label;\n        this.optionsElement = [];\n        this.buildContent();\n        this.select(0, false);\n        this.bindEvents();\n    }\n    Dropdown.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            Dropdown: Dropdown\n        });\n    };\n    /**\n     * Resets the dropdown.\n     */\n    Dropdown.prototype.reset = function () {\n        this.select(0, false);\n    };\n    Dropdown.prototype.setId = function (id) {\n        Dom_1.$$(this.element).setAttribute('id', id);\n    };\n    /**\n     * Gets the element on which the dropdown is bound.\n     * @returns {HTMLElement} The dropdown element.\n     */\n    Dropdown.prototype.getElement = function () {\n        return this.element;\n    };\n    /**\n     * Gets the currently selected dropdown value.\n     * @returns {string} The currently selected dropdown value.\n     */\n    Dropdown.prototype.getValue = function () {\n        return this.selectElement.value;\n    };\n    /**\n     * Selects a value from the dropdown [`listofValues`]{@link Dropdown.listOfValues}.\n     * @param index The 0-based index position of the value to select in the `listOfValues`.\n     * @param executeOnChange Indicates whether to execute the [`onChange`]{@link Dropdown.onChange} function when this\n     * method changes the dropdown selection.\n     */\n    Dropdown.prototype.select = function (index, executeOnChange) {\n        if (executeOnChange === void 0) { executeOnChange = true; }\n        this.selectOption(this.optionsElement[index], executeOnChange);\n    };\n    /**\n     * Gets the element on which the dropdown is bound.\n     * @returns {HTMLElement} The dropdown element.\n     */\n    Dropdown.prototype.build = function () {\n        return this.element;\n    };\n    /**\n     * Sets the dropdown value.\n     * @param value The value to set the dropdown to.\n     */\n    Dropdown.prototype.setValue = function (value) {\n        var _this = this;\n        _.each(this.optionsElement, function (option) {\n            if (Dom_1.$$(option).getAttribute('data-value') == value) {\n                _this.selectOption(option);\n            }\n        });\n    };\n    Dropdown.prototype.selectOption = function (option, executeOnChange) {\n        if (executeOnChange === void 0) { executeOnChange = true; }\n        this.selectElement.value = option.value;\n        if (executeOnChange) {\n            this.onChange(this);\n        }\n    };\n    Dropdown.prototype.buildContent = function () {\n        var _this = this;\n        this.selectElement = Dom_1.$$('select', {\n            className: 'coveo-dropdown'\n        }).el;\n        if (this.label) {\n            this.selectElement.setAttribute('aria-label', Strings_1.l(this.label));\n        }\n        var selectOptions = this.buildOptions();\n        _.each(selectOptions, function (opt) {\n            Dom_1.$$(_this.selectElement).append(opt);\n        });\n        this.element = this.selectElement;\n    };\n    Dropdown.prototype.buildOptions = function () {\n        var _this = this;\n        var ret = [];\n        _.each(this.listOfValues, function (value) {\n            ret.push(_this.buildOption(value));\n        });\n        return ret;\n    };\n    Dropdown.prototype.buildOption = function (value) {\n        var option = Dom_1.$$('option');\n        option.setAttribute('data-value', value);\n        option.setAttribute('value', value);\n        option.text(this.getDisplayValue(value));\n        this.optionsElement.push(option.el);\n        return option.el;\n    };\n    Dropdown.prototype.bindEvents = function () {\n        var _this = this;\n        Dom_1.$$(this.selectElement).on('change', function () { return _this.onChange(_this); });\n    };\n    return Dropdown;\n}());\nexports.Dropdown = Dropdown;\n\n\n/***/ }),\n\n/***/ 697:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// SortDropdown.min__00ecf0bd3e47c7b52b32.js","import 'styling/_Sort';\nimport { exportGlobally } from '../../GlobalExports';\nimport { IBuildingQueryEventArgs, IQueryErrorEventArgs, IQuerySuccessEventArgs, QueryEvents } from '../../events/QueryEvents';\nimport { Assert } from '../../misc/Assert';\nimport { MODEL_EVENTS } from '../../models/Model';\nimport { QUERY_STATE_ATTRIBUTES, QueryStateModel } from '../../models/QueryStateModel';\nimport { $$ } from '../../utils/Dom';\nimport { SVGDom } from '../../utils/SVGDom';\nimport { SVGIcons } from '../../utils/SVGIcons';\nimport { Utils } from '../../utils/Utils';\nimport { logSortEvent } from '../Analytics/SharedAnalyticsCalls';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { Initialization } from '../Base/Initialization';\nimport { SortCriteria, VALID_DIRECTION } from './SortCriteria';\nimport { AccessibleButton, ArrowDirection } from '../../utils/AccessibleButton';\nimport { l } from '../../strings/Strings';\nimport { findIndex, find, any } from 'underscore';\n\nexport interface ISortOptions {\n  sortCriteria?: SortCriteria[];\n  caption?: string;\n}\n/**\n * The `Sort` component renders a widget that the end user can interact with to select the criterion to use when sorting query results.\n *\n * To improve accessibility, it's recommended to group `Sort` components in a container with `role=\"radiogroup\"`.\n */\nexport class Sort extends Component {\n  static ID = 'Sort';\n\n  static doExport = () => {\n    exportGlobally({\n      Sort: Sort,\n      SortCriteria: SortCriteria\n    });\n  };\n\n  /**\n   * Options for the component\n   * @componentOptions\n   */\n  static options: ISortOptions = {\n    /**\n     * The sort criterion/criteria the end user can select/toggle between when interacting with this component instance.\n     *\n     * The available sort criteria are:\n     * - `relevancy`\n     * - `date ascending`/`date descending`\n     * - `qre`\n     * - `@field ascending`/`@field descending`, where you must replace `field` with the name of a sortable field in your index (e.g., `data-sort-criteria=\"@size ascending\"`).\n     *\n     * You can specify a comma separated list of sort criteria to toggle between when interacting with this component instance (e.g., `data-sort-criteria=\"date descending,date ascending\"`).\n     *\n     * You can specify multiple sort criteria to be used in the same request by separating them with a semicolon (e.g., `data-sort-criteria=\"@size ascending;date ascending\"` ).\n     *\n     * Interacting with this component instance will cycle through those criteria in the order they are listed in.\n     * Typically, you should only specify a list of sort criteria when you want the end user to be able to to toggle the direction of a `date` or `@field` sort criteria.\n     * Otherwise, you should configure a distinct `Sort` component instance for each sort criterion you want to make available in your search page.\n     *\n     * You must specify a valid value for this option in order for this component instance to work correctly.\n     *\n     * Examples:\n     *\n     * - `data-sort-criteria=\"date ascending\"` createes a Sort component that allows to sort on `date ascending`, without being able to toggle the order.\n     * - `data-sort-criteria=\"date ascending, date descending\"` creates a Sort component that allows end users to toggle between `date ascending` and `date descending` on click.\n     * - `data-sort-criteria=\"@size ascending; date descending\"` creates a Sort component that only allows end users to sort on `@size ascending`. The index then applies a second sort on `date descending` when two items are of equal value.\n     * - `data-sort-criteria=\"@size ascending; date descending, @size descending; date descending\"` creates a Sort component that allows end users to toggle between `@size ascending` and `@size descending`. For each value, the index applies a second sort on `date descending` when two items are of equal value.\n     */\n    sortCriteria: ComponentOptions.buildCustomListOption(\n      values => {\n        return values.map(criteria => {\n          // 'any' because Underscore won't accept the union type as an argument.\n          if (typeof criteria === 'string') {\n            return new SortCriteria(criteria);\n          } else {\n            return criteria as SortCriteria;\n          }\n        });\n      },\n      { required: true }\n    ),\n\n    /**\n     * The caption to display on this component instance.\n     *\n     * By default, the component uses the text content of the element it is instanciated on.\n     */\n    caption: ComponentOptions.buildLocalizedStringOption({ required: true })\n  };\n\n  private currentCriteria: SortCriteria;\n\n  private sortButton: HTMLElement;\n  private directionButton: HTMLElement;\n  private radioGroup: HTMLElement;\n\n  /**\n   * Creates a new `Sort` component instance.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for this component instance.\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   */\n  constructor(public element: HTMLElement, public options?: ISortOptions, bindings?: IComponentBindings) {\n    super(element, Sort.ID, bindings);\n\n    this.options = ComponentOptions.initComponentOptions(element, Sort, options);\n\n    Assert.isLargerOrEqualsThan(1, this.options.sortCriteria.length);\n\n    this.bind.onQueryState(MODEL_EVENTS.CHANGE_ONE, QUERY_STATE_ATTRIBUTES.SORT, () => this.handleQueryStateChanged());\n    this.bind.onRootElement(QueryEvents.querySuccess, (args: IQuerySuccessEventArgs) => this.handleQuerySuccess(args));\n    this.bind.onRootElement(QueryEvents.buildingQuery, (args: IBuildingQueryEventArgs) => this.handleBuildingQuery(args));\n    this.bind.onRootElement(QueryEvents.queryError, (args: IQueryErrorEventArgs) => this.handleQueryError(args));\n    this.ensureDom();\n  }\n\n  public createDom() {\n    const el = $$(this.element);\n    el.on('click', () => this.selectAndExecuteQuery());\n    const innerText = el.text();\n    el.empty();\n\n    this.findOrCreateRadioGroup();\n    this.createSortButton(innerText);\n    if (this.isToggle()) {\n      this.createDirectionButton();\n    }\n\n    this.update();\n  }\n\n  /**\n   * Selects this `Sort` component.\n   *\n   * Updates the state model if selecting this component toggles its current [`sortCriteria`]{@link Sort.options.sortCriteria}.\n   *\n   * @param direction The sort direction. Can be one of: `ascending`, `descending`.\n   */\n  public select(direction?: string) {\n    if (direction) {\n      this.currentCriteria = find(this.options.sortCriteria, (criteria: SortCriteria) => {\n        return criteria.direction == direction;\n      });\n      this.updateQueryStateModel();\n    } else if (Utils.exists(this.currentCriteria)) {\n      this.selectNextCriteria();\n    } else {\n      this.selectFirstCriteria();\n    }\n  }\n\n  /**\n   * Selects this `Sort` component, then triggers a query if selecting this component toggles its current [`sortCriteria`]{@link Sort.options.sortCriteria}.\n   *\n   * Also logs an event in the usage analytics with the new current sort criteria.\n   */\n\n  public selectAndExecuteQuery() {\n    var oldCriteria = this.currentCriteria;\n    this.select();\n    if (oldCriteria != this.currentCriteria) {\n      this.executeSearchQuery();\n    }\n  }\n\n  public enable() {\n    $$(this.element).removeClass('coveo-tab-disabled');\n    this.update();\n    super.enable();\n  }\n\n  public disable() {\n    $$(this.element).addClass('coveo-tab-disabled');\n    super.disable();\n  }\n\n  /**\n   * Gets the current [`sortCriteria`]{@link Sort.options.sortCriteria} of this `Sort` component.\n   * @returns {SortCriteria}\n   */\n  public getCurrentCriteria(): SortCriteria {\n    return this.currentCriteria;\n  }\n\n  /**\n   * Indicates whether the name of any of the available [`sortCriteria`]{@link Sort.options.sortCriteria} of this `Sort` component matches the argument.\n   * @param sortId The sort criteria name to look for (e.g., `date descending`).\n   */\n  public match(sortId: string) {\n    return any(this.options.sortCriteria, (sortCriteria: SortCriteria) => sortId == sortCriteria.toString());\n  }\n\n  private findOrCreateRadioGroup() {\n    this.radioGroup = this.findRadioGroup();\n    if (!this.radioGroup) {\n      this.element.setAttribute('role', 'radiogroup');\n      this.radioGroup = this.element;\n    }\n  }\n\n  private createSortButton(innerText?: string) {\n    this.sortButton = $$('span').el;\n    this.sortButton.innerText = this.options.caption || innerText;\n    new AccessibleButton()\n      .withElement(this.sortButton)\n      .withEnterKeyboardAction(() => this.selectAndExecuteQuery())\n      .withArrowsAction((direction, e) => this.onArrowPressed(direction, e))\n      .withLabel(this.isToggle() ? this.getDirectionalLabel(this.initialDirection as VALID_DIRECTION) : this.getOmnidirectionalLabel())\n      .withRole('radio')\n      .build();\n    this.element.appendChild(this.sortButton);\n  }\n\n  private createDirectionButton() {\n    this.directionButton = $$('span', { className: 'coveo-icon' }, ...this.createIcons()).el;\n    new AccessibleButton()\n      .withElement(this.directionButton)\n      .withSelectAction(e => {\n        e.stopPropagation();\n        this.selectNextCriteriaAndExecuteQuery();\n      })\n      .withArrowsAction((direction, e) => this.onArrowPressed(direction, e))\n      .withLabel(\n        this.getDirectionalLabel(\n          this.initialDirection === VALID_DIRECTION.DESCENDING ? VALID_DIRECTION.ASCENDING : VALID_DIRECTION.DESCENDING\n        )\n      )\n      .withRole('radio')\n      .build();\n    this.element.appendChild(this.directionButton);\n  }\n\n  private onArrowPressed(direction: ArrowDirection, e: Event) {\n    this.selectNextRadioButton(direction === ArrowDirection.RIGHT || direction === ArrowDirection.DOWN ? 1 : -1);\n    e.stopPropagation();\n  }\n\n  private createIcons() {\n    const iconAscending = $$('span', { className: 'coveo-sort-icon-ascending' }, SVGIcons.icons.arrowUp);\n    SVGDom.addClassToSVGInContainer(iconAscending.el, 'coveo-sort-icon-ascending-svg');\n    const iconDescending = $$('span', { className: 'coveo-sort-icon-descending' }, SVGIcons.icons.arrowDown);\n    SVGDom.addClassToSVGInContainer(iconDescending.el, 'coveo-sort-icon-descending-svg');\n    return [iconAscending, iconDescending];\n  }\n\n  private findRadioGroup(element = this.element) {\n    if (!element || element === document.body) {\n      return null;\n    }\n    if (element.getAttribute('role') === 'radiogroup') {\n      return element;\n    }\n    return this.findRadioGroup(element.parentElement);\n  }\n\n  private selectNextRadioButton(direction = 1) {\n    const radioButtons = $$(this.radioGroup).findAll('[role=\"radio\"]');\n    const currentIndex = findIndex(radioButtons, radio => radio.getAttribute('aria-checked') === 'true');\n    let indexToSelect: number;\n    const isAnythingSelected = currentIndex !== -1;\n    if (isAnythingSelected) {\n      indexToSelect = (currentIndex + direction + radioButtons.length) % radioButtons.length;\n    } else {\n      if (direction >= 0) {\n        indexToSelect = 0;\n      } else {\n        indexToSelect = radioButtons.length - 1;\n      }\n    }\n    const radioToSelect = radioButtons[indexToSelect];\n    radioToSelect.focus();\n    radioToSelect.click();\n  }\n\n  private executeSearchQuery() {\n    this.queryController.deferExecuteQuery({\n      beforeExecuteQuery: () => logSortEvent(this.usageAnalytics, this.currentCriteria.sort + this.currentCriteria.direction)\n    });\n  }\n\n  private selectFirstCriteria() {\n    this.currentCriteria = this.options.sortCriteria[0];\n    this.updateQueryStateModel();\n  }\n\n  private selectNextCriteria() {\n    const indexOfCurrentCriteria = this.currentCriteria ? this.options.sortCriteria.indexOf(this.currentCriteria) : 0;\n    this.currentCriteria = this.options.sortCriteria[(indexOfCurrentCriteria + 1) % this.options.sortCriteria.length];\n    this.updateQueryStateModel();\n  }\n\n  private selectNextCriteriaAndExecuteQuery() {\n    const oldCriteria = this.currentCriteria;\n    this.selectNextCriteria();\n    if (oldCriteria != this.currentCriteria) {\n      this.executeSearchQuery();\n    }\n  }\n\n  private handleQueryStateChanged() {\n    this.update();\n  }\n\n  private update() {\n    // Basically, if the criteria in the model fits with one of ours, it'll become our active criteria\n    var sortCriteria = <string>this.queryStateModel.get(QueryStateModel.attributesEnum.sort);\n    if (Utils.isNonEmptyString(sortCriteria)) {\n      var criteriaFromModel = SortCriteria.parse(sortCriteria);\n      this.currentCriteria = find(this.options.sortCriteria, (criteria: SortCriteria) => criteriaFromModel.equals(criteria));\n    } else {\n      this.currentCriteria = null;\n    }\n    this.updateAppearance();\n    this.updateAccessibilityProperties();\n  }\n\n  private get captionIsDefined() {\n    return Utils.isNonEmptyString(this.options.caption);\n  }\n\n  private get currentDirection() {\n    return this.currentCriteria ? this.currentCriteria.direction : this.initialDirection;\n  }\n\n  private get initialDirection() {\n    return this.options.sortCriteria[0].direction;\n  }\n\n  private get displayedSortText() {\n    return this.captionIsDefined ? this.options.caption : this.element.textContent;\n  }\n\n  private handleBuildingQuery(data: IBuildingQueryEventArgs) {\n    Assert.exists(data);\n\n    var sort = this.queryStateModel.get(QueryStateModel.attributesEnum.sort);\n    if (sort == QueryStateModel.defaultAttributes.sort || this.isSelected()) {\n      if (this.currentCriteria) {\n        this.currentCriteria.putInQueryBuilder(data.queryBuilder);\n      }\n    }\n  }\n\n  private handleQuerySuccess(data: IQuerySuccessEventArgs) {\n    if (data.results.results.length == 0) {\n      $$(this.element).addClass('coveo-sort-hidden');\n    } else {\n      $$(this.element).removeClass('coveo-sort-hidden');\n    }\n  }\n\n  private handleQueryError(data: IQueryErrorEventArgs) {\n    $$(this.element).addClass('coveo-sort-hidden');\n  }\n\n  private isToggle(): boolean {\n    return this.options.sortCriteria.length > 1;\n  }\n\n  private isSelected(): boolean {\n    return Utils.exists(this.currentCriteria);\n  }\n\n  private updateAppearance() {\n    $$(this.element).toggleClass('coveo-selected', this.isSelected());\n    if (this.isToggle()) {\n      $$(this.element).removeClass('coveo-ascending');\n      $$(this.element).removeClass('coveo-descending');\n      if (this.isSelected()) {\n        $$(this.element).addClass(this.currentDirection === 'ascending' ? 'coveo-ascending' : 'coveo-descending');\n      }\n    }\n  }\n\n  private updateAccessibilityProperties() {\n    this.sortButton.setAttribute('aria-controls', this.resultListsIds);\n    const directionIsInitial = this.currentDirection === this.initialDirection;\n    this.sortButton.setAttribute('aria-checked', `${this.isSelected() && directionIsInitial}`);\n    if (this.isToggle()) {\n      this.directionButton.setAttribute('aria-controls', this.resultListsIds);\n      this.directionButton.setAttribute('aria-checked', `${this.isSelected() && !directionIsInitial}`);\n    }\n  }\n\n  private get resultListsIds() {\n    const resultLists = this.searchInterface.getComponents('ResultList') as Component[];\n    return resultLists.map(resultList => resultList.element.id).join(' ');\n  }\n\n  private getDirectionalLabel(direction: VALID_DIRECTION) {\n    const localizedCaption = l(this.displayedSortText);\n    return direction === VALID_DIRECTION.DESCENDING\n      ? l('SortResultsByDescending', localizedCaption)\n      : l('SortResultsByAscending', localizedCaption);\n  }\n\n  private getOmnidirectionalLabel(): string {\n    const localizedCaption = l(this.displayedSortText);\n    return l('SortResultsBy', localizedCaption);\n  }\n\n  private updateQueryStateModel() {\n    this.queryStateModel.set(QueryStateModel.attributesEnum.sort, this.currentCriteria.toString());\n  }\n}\n\nInitialization.registerAutoCreateComponent(Sort);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Sort/Sort.ts","import 'styling/_SortDropdown';\nimport { findIndex } from 'underscore';\nimport { exportGlobally } from '../../GlobalExports';\nimport { IQuerySuccessEventArgs, IQueryErrorEventArgs, QueryEvents } from '../../events/QueryEvents';\nimport { IAttributeChangedEventArg, MODEL_EVENTS } from '../../models/Model';\nimport { QUERY_STATE_ATTRIBUTES, QueryStateModel } from '../../models/QueryStateModel';\nimport { $$ } from '../../utils/Dom';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { Initialization } from '../Base/Initialization';\nimport { InitializationEvents } from '../../events/InitializationEvents';\nimport { Sort } from '../Sort/Sort';\nimport { Dropdown } from '../FormWidgets/Dropdown';\nimport { l } from '../../strings/Strings';\n\n/**\n * The `SortDropdown` component renders a dropdown that the end user can interact with to select the criteria to use when sorting query results.\n *\n * It is meant to be a parent of regular [`Sort`]{@link Sort} components. Example:\n * ```\n * <div class=\"CoveoSortDropdown\">\n *   <span class=\"CoveoSort\" data-sort-criteria=\"relevancy\" data-caption=\"Relevance\"></span>\n *   <span class=\"CoveoSort\" data-sort-criteria=\"date descending\" data-caption=\"Newest\"></span>\n *   <span class=\"CoveoSort\" data-sort-criteria=\"date ascending\" data-caption=\"Oldest\"></span>\n * </div>\n * ```\n * Each one of the children `Sort` components should have only one sort criteria to prevent the regular toggle behaviour.\n *\n * @availablesince [March 2020 Release (v2.8521)](https://docs.coveo.com/en/3203/)\n */\nexport class SortDropdown extends Component {\n  static ID = 'SortDropdown';\n  static options: any = {};\n\n  static doExport = () => {\n    exportGlobally({\n      SortDropdown: SortDropdown\n    });\n  };\n\n  private dropdown: Dropdown;\n  private sortComponents: Sort[] = [];\n\n  /**\n   * Creates a new `SortDropdown` component instance.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for this component instance.\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   */\n  constructor(public element: HTMLElement, public options?: any, bindings?: IComponentBindings) {\n    super(element, SortDropdown.ID, bindings);\n\n    this.options = ComponentOptions.initComponentOptions(element, SortDropdown, options);\n    this.removeTabSupport();\n\n    this.bind.oneRootElement(InitializationEvents.afterInitialization, () => this.handleAfterInitialization());\n    this.bind.onQueryState(MODEL_EVENTS.CHANGE_ONE, QUERY_STATE_ATTRIBUTES.SORT, (args: IAttributeChangedEventArg) =>\n      this.handleQueryStateChanged(args)\n    );\n    this.bind.onRootElement(QueryEvents.querySuccess, (args: IQuerySuccessEventArgs) => this.handleQuerySuccess(args));\n    this.bind.onRootElement(QueryEvents.queryError, (args: IQueryErrorEventArgs) => this.handleQueryError(args));\n  }\n\n  private handleAfterInitialization() {\n    this.buildDropdown();\n  }\n\n  private clearDropdown() {\n    this.dropdown && this.element.removeChild(this.dropdown.getElement());\n    this.dropdown = null;\n  }\n\n  private buildDropdown() {\n    this.sortComponents = this.getEnabledSortComponents();\n    this.clearDropdown();\n\n    if (!this.sortComponents.length) {\n      return;\n    }\n\n    this.dropdown = new Dropdown(\n      () => this.handleChange(),\n      this.getValuesForDropdown(),\n      value => this.getCaptionForValue(value),\n      l('SortBy')\n    );\n    this.element.appendChild(this.dropdown.getElement());\n    this.update();\n  }\n\n  private getEnabledSortComponents() {\n    const sortComponents = $$(this.element)\n      .findAll(`.${Component.computeCssClassNameForType('Sort')}`)\n      .map(sortElement => {\n        const sortCmp = <Sort>Component.get(sortElement, Sort);\n        if (sortCmp.options.sortCriteria.length == 1) {\n          return sortCmp;\n        } else {\n          this.logger.warn(\n            `Each Sort component inside a SortDropdown should have only one sort criteria. Skipping ${\n              sortCmp.options.caption\n            } in the SortDropdown.`\n          );\n          return;\n        }\n      })\n      .filter(sortCmp => sortCmp && !sortCmp.disabled);\n\n    return sortComponents;\n  }\n\n  private getValuesForDropdown(): string[] {\n    return this.sortComponents.map(sort => sort.options.sortCriteria.toString());\n  }\n\n  private handleQueryStateChanged(data: IAttributeChangedEventArg) {\n    this.update();\n  }\n\n  private update() {\n    if (!this.dropdown) {\n      return;\n    }\n\n    const sortCriteria = <string>this.queryStateModel.get(QueryStateModel.attributesEnum.sort);\n    this.select(sortCriteria);\n  }\n\n  /**\n   * Selects a sort criteria from the options.\n   * @param sortCriteria The sort criteria to select.\n   * @param executeQuery Whether to execute a query after changing the sort criteria\n   */\n  public select(sortCriteria: string, executeQuery: boolean = false) {\n    const sortIndex = this.getSortIndex(sortCriteria);\n    sortIndex > -1 && this.dropdown.select(sortIndex, executeQuery);\n    $$(this.dropdown.getElement()).toggleClass('coveo-selected', sortIndex > -1);\n  }\n\n  private handleQuerySuccess(data: IQuerySuccessEventArgs) {\n    if (!data.results.results.length) {\n      return this.hideElement();\n    }\n\n    this.buildDropdown();\n\n    if (!this.sortComponents.length) {\n      return this.hideElement();\n    }\n\n    this.showElement();\n  }\n\n  private handleQueryError(data: IQueryErrorEventArgs) {\n    this.hideElement();\n  }\n\n  private handleChange() {\n    const selectedValue = this.dropdown.getValue();\n    const sortIndex = this.getSortIndex(selectedValue);\n    sortIndex > -1 && this.sortComponents[sortIndex].selectAndExecuteQuery();\n  }\n\n  private getCaptionForValue(value: string) {\n    const sortIndex = this.getSortIndex(value);\n    return sortIndex > -1 ? this.sortComponents[sortIndex].options.caption : '';\n  }\n\n  private getSortIndex(itemValue: string) {\n    return findIndex(this.sortComponents, sort => sort.options.sortCriteria.toString() === itemValue);\n  }\n\n  private hideElement() {\n    $$(this.element).hide();\n  }\n\n  private showElement() {\n    $$(this.element).show();\n  }\n}\n\nInitialization.registerAutoCreateComponent(SortDropdown);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/SortDropdown/SortDropdown.ts","import { chain, contains, first, values } from 'underscore';\nimport { Assert } from '../../misc/Assert';\nimport { QueryBuilder } from '../../ui/Base/QueryBuilder';\n\nexport enum VALID_SORT {\n  RELEVANCY = 'relevancy',\n  DATE = 'date',\n  QRE = 'qre'\n}\n\nexport enum VALID_DIRECTION {\n  ASCENDING = 'ascending',\n  DESCENDING = 'descending'\n}\n\nexport class SortCriterion {\n  private static sortsNeedingDirection = [VALID_SORT.DATE];\n\n  /**\n   * Create a new SortCriteria\n   * @param sort The sort criteria (e.g.: relevancy, date)\n   * @param direction The direction by which to sort (e.g.: ascending, descending)\n   */\n  constructor(public sort: VALID_SORT, public direction: VALID_DIRECTION | '' = '') {\n    if (!SortCriterion.sortIsField(sort)) {\n      Assert.check(\n        this.isValidSort(sort),\n        `${sort} is not a valid sort criteria. Valid values are ${values(VALID_SORT)} or a valid index sortable index field.`\n      );\n    }\n    if (SortCriterion.sortNeedsDirection(sort)) {\n      Assert.check(\n        this.isValidDirection(direction),\n        `${direction} is not a valid sort criteria direction. Valid values are ${values(VALID_DIRECTION)}`\n      );\n    } else {\n      Assert.check(direction == '');\n    }\n  }\n\n  private isValidDirection(direction: string): direction is VALID_DIRECTION {\n    return chain(VALID_DIRECTION)\n      .values()\n      .contains(direction as any)\n      .value();\n  }\n\n  private isValidSort(sort: string): sort is VALID_SORT {\n    return chain(VALID_SORT)\n      .values()\n      .contains(sort as any)\n      .value();\n  }\n\n  private static sortIsField(criteria: string) {\n    return criteria.charAt(0) == '@';\n  }\n\n  private static sortNeedsDirection(sort: string) {\n    return contains(SortCriterion.sortsNeedingDirection, sort) || SortCriterion.sortIsField(sort);\n  }\n}\n\nexport class SortCriteria {\n  private criteria: SortCriterion[] = [];\n\n  constructor(rawCriteriaString: string) {\n    const criteria = rawCriteriaString.split(';');\n    criteria.forEach(criterion => {\n      const split = criterion.match(/\\S+/g);\n      this.criteria.push(new SortCriterion(split[0] as VALID_SORT, split[1] as VALID_DIRECTION));\n    });\n  }\n\n  public get direction() {\n    return first(this.criteria).direction;\n  }\n\n  public get sort() {\n    return first(this.criteria).sort;\n  }\n\n  /**\n   * Return a new SortCriteria from a string\n   * @param criteria The string from which to create the SortCriteria\n   */\n  static parse(criteria: string): SortCriteria {\n    return new SortCriteria(criteria);\n  }\n\n  /**\n   * Put the sort criteria in the passed queryBuilder\n   * @param queryBuilder The queryBuilder in which to put the sort criteria.\n   */\n  public putInQueryBuilder(queryBuilder: QueryBuilder) {\n    Assert.exists(queryBuilder);\n    queryBuilder.sortCriteria = this.toString()\n      .split(';')\n      .join(',');\n  }\n\n  /**\n   * Returns a string representation of the sort criteria (e.g.: 'date ascending').\n   */\n  public toString(): string {\n    return this.criteria\n      .map(criterion => {\n        return criterion.direction ? `${criterion.sort} ${criterion.direction}` : `${criterion.sort}`;\n      })\n      .join(';');\n  }\n\n  /**\n   * Checks if the SortCriteria is equal to another.\n   * @param criteria The SortCriteria to compare with\n   */\n  public equals(criteria: SortCriteria): boolean {\n    return criteria.toString() == this.toString();\n  }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/Sort/SortCriteria.ts","import { $$ } from '../../utils/Dom';\nimport { l } from '../../strings/Strings';\nimport * as _ from 'underscore';\nimport { IFormWidget, IFormWidgetSettable } from './FormWidgets';\nimport { exportGlobally } from '../../GlobalExports';\n\n/**\n * A dropdown widget with standard styling.\n */\nexport class Dropdown implements IFormWidget, IFormWidgetSettable {\n  private element: HTMLElement;\n  private selectElement: HTMLSelectElement;\n  private optionsElement: HTMLOptionElement[] = [];\n\n  static doExport() {\n    exportGlobally({\n      Dropdown: Dropdown\n    });\n  }\n\n  /**\n   * Creates a new `Dropdown`.\n   * @param onChange The function to call when the dropdown selected value changes. This function takes the current\n   * `Dropdown` instance as an argument.\n   * @param listOfValues The selectable values to display in the dropdown.\n   * @param getDisplayValue An optional function to modify the display values, rather than using the values as they\n   * appear in the `listOfValues`.\n   * @param label The label to use for the input for accessibility purposes.\n   */\n  constructor(\n    public onChange: (dropdown: Dropdown) => void = (dropdown: Dropdown) => {},\n    protected listOfValues: string[],\n    private getDisplayValue: (string) => string = l,\n    private label?: string\n  ) {\n    this.buildContent();\n    this.select(0, false);\n    this.bindEvents();\n  }\n\n  /**\n   * Resets the dropdown.\n   */\n  public reset() {\n    this.select(0, false);\n  }\n\n  public setId(id: string) {\n    $$(this.element).setAttribute('id', id);\n  }\n\n  /**\n   * Gets the element on which the dropdown is bound.\n   * @returns {HTMLElement} The dropdown element.\n   */\n  public getElement(): HTMLElement {\n    return this.element;\n  }\n\n  /**\n   * Gets the currently selected dropdown value.\n   * @returns {string} The currently selected dropdown value.\n   */\n  public getValue(): string {\n    return this.selectElement.value;\n  }\n\n  /**\n   * Selects a value from the dropdown [`listofValues`]{@link Dropdown.listOfValues}.\n   * @param index The 0-based index position of the value to select in the `listOfValues`.\n   * @param executeOnChange Indicates whether to execute the [`onChange`]{@link Dropdown.onChange} function when this\n   * method changes the dropdown selection.\n   */\n  public select(index: number, executeOnChange = true) {\n    this.selectOption(this.optionsElement[index], executeOnChange);\n  }\n\n  /**\n   * Gets the element on which the dropdown is bound.\n   * @returns {HTMLElement} The dropdown element.\n   */\n  public build() {\n    return this.element;\n  }\n\n  /**\n   * Sets the dropdown value.\n   * @param value The value to set the dropdown to.\n   */\n  public setValue(value: string) {\n    _.each(this.optionsElement, option => {\n      if ($$(option).getAttribute('data-value') == value) {\n        this.selectOption(option);\n      }\n    });\n  }\n\n  private selectOption(option: HTMLOptionElement, executeOnChange = true) {\n    this.selectElement.value = option.value;\n    if (executeOnChange) {\n      this.onChange(this);\n    }\n  }\n\n  private buildContent() {\n    this.selectElement = <HTMLSelectElement>$$('select', {\n      className: 'coveo-dropdown'\n    }).el;\n\n    if (this.label) {\n      this.selectElement.setAttribute('aria-label', l(this.label));\n    }\n\n    const selectOptions = this.buildOptions();\n    _.each(selectOptions, opt => {\n      $$(this.selectElement).append(opt);\n    });\n    this.element = this.selectElement;\n  }\n\n  private buildOptions(): HTMLElement[] {\n    const ret: HTMLElement[] = [];\n    _.each(this.listOfValues, (value: string) => {\n      ret.push(this.buildOption(value));\n    });\n    return ret;\n  }\n\n  private buildOption(value: string): HTMLElement {\n    const option = $$('option');\n    option.setAttribute('data-value', value);\n    option.setAttribute('value', value);\n    option.text(this.getDisplayValue(value));\n    this.optionsElement.push(<HTMLOptionElement>option.el);\n    return option.el;\n  }\n\n  private bindEvents() {\n    $$(this.selectElement).on('change', () => this.onChange(this));\n  }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/FormWidgets/Dropdown.ts"],"sourceRoot":""}