{"version":3,"sources":["HiddenQuery.min__ff92a1d47dbcec2611e1.js","./src/ui/HiddenQuery/HiddenQuery.ts"],"names":["webpackJsonpCoveo__temporary","259","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","HiddenQuery","ID","ComponentOptions","initComponentOptions","bind","onRootElement","QueryEvents","buildingQuery","args","handleBuildingQuery","BreadcrumbEvents","populateBreadcrumb","handlePopulateBreadcrumb","clearBreadcrumb","setStateEmpty","_this","clear","hiddenDescriptionRemoved","getDescription","usageAnalytics","logSearchEvent","analyticsActionCauseList","contextRemove","contextName","queryController","executeQuery","queryStateModel","set","QUERY_STATE_ATTRIBUTES","HD","HQ","data","Assert","exists","hiddenQuery","get","Utils","isNonEmptyString","queryBuilder","advancedExpression","add","description","_","isEmpty","elem","document","createElement","$$","addClass","title","text","appendChild","className","escape","el","SVGIcons","icons","mainClear","on","breadcrumbs","push","QueryStateModel","attributesEnum","hd","hq","length","maximumDescriptionLength","slice","doExport","exportGlobally","buildNumberOption","min","defaultValue","buildLocalizedStringOption","localizedString","l","Component","Initialization","registerAutoCreateComponent","621"],"mappings":"AAAAA,8BAA8B,KAExBC,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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) {\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 Strings_1 = __webpack_require__(6);\nvar QueryEvents_1 = __webpack_require__(11);\nvar BreadcrumbEvents_1 = __webpack_require__(35);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar QueryStateModel_1 = __webpack_require__(13);\nvar Dom_1 = __webpack_require__(1);\nvar Utils_1 = __webpack_require__(4);\nvar Initialization_1 = __webpack_require__(2);\nvar Assert_1 = __webpack_require__(5);\nvar _ = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\n__webpack_require__(621);\nvar SVGIcons_1 = __webpack_require__(12);\n/**\n * The HiddenQuery component handles a \"hidden\" query parameter (`hq`) and its description (`hd`).\n *\n * Concretely, this means that if a HiddenQuery component is present in your page and you load your search interface\n * with `hq=foo&hd=bar` in the URL hash, the component adds `foo` as an expression to the query (`hq` is the hidden\n * query) and renders `bar` in the {@link Breadcrumb} (`hd` is the hidden query description).\n */\nvar HiddenQuery = /** @class */ (function (_super) {\n    __extends(HiddenQuery, _super);\n    /**\n     * Creates a new HiddenQuery component, which binds multiple events ({@link QueryEvents.buildingQuery},\n     * {@link BreadcrumbEvents.populateBreadcrumb} and {@link BreadcrumbEvents.clearBreadcrumb}).\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the HiddenQuery 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     */\n    function HiddenQuery(element, options, bindings) {\n        var _this = _super.call(this, element, HiddenQuery.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, HiddenQuery, options);\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.buildingQuery, function (args) { return _this.handleBuildingQuery(args); });\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 () { return _this.setStateEmpty(); });\n        return _this;\n    }\n    /**\n     * Clears any `hd` or `hq` set in the {@link QueryStateModel}.\n     * Also logs the `contextRemove` event in the usage analytics and triggers a new query.\n     */\n    HiddenQuery.prototype.clear = function () {\n        this.setStateEmpty();\n        var hiddenDescriptionRemoved = this.getDescription();\n        this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.contextRemove, {\n            contextName: hiddenDescriptionRemoved\n        });\n        this.queryController.executeQuery();\n    };\n    HiddenQuery.prototype.setStateEmpty = function () {\n        this.queryStateModel.set(QueryStateModel_1.QUERY_STATE_ATTRIBUTES.HD, '');\n        this.queryStateModel.set(QueryStateModel_1.QUERY_STATE_ATTRIBUTES.HQ, '');\n    };\n    HiddenQuery.prototype.handleBuildingQuery = function (data) {\n        Assert_1.Assert.exists(data);\n        var hiddenQuery = this.queryStateModel.get(QueryStateModel_1.QUERY_STATE_ATTRIBUTES.HQ);\n        if (Utils_1.Utils.isNonEmptyString(hiddenQuery)) {\n            data.queryBuilder.advancedExpression.add(hiddenQuery);\n        }\n    };\n    HiddenQuery.prototype.handlePopulateBreadcrumb = function (args) {\n        var _this = this;\n        var description = this.getDescription();\n        if (!_.isEmpty(description) && !_.isEmpty(this.queryStateModel.get(QueryStateModel_1.QUERY_STATE_ATTRIBUTES.HQ))) {\n            var elem = document.createElement('div');\n            Dom_1.$$(elem).addClass('coveo-hidden-query-breadcrumb');\n            var title = document.createElement('span');\n            Dom_1.$$(title).addClass('coveo-hidden-query-breadcrumb-title');\n            Dom_1.$$(title).text(this.options.title);\n            elem.appendChild(title);\n            var value = Dom_1.$$('span', { className: 'coveo-hidden-query-breadcrumb-value' }, _.escape(description)).el;\n            elem.appendChild(value);\n            var clear = Dom_1.$$('span', { className: 'coveo-hidden-query-breadcrumb-clear' }, SVGIcons_1.SVGIcons.icons.mainClear);\n            value.appendChild(clear.el);\n            Dom_1.$$(value).on('click', function () { return _this.clear(); });\n            args.breadcrumbs.push({\n                element: elem\n            });\n        }\n    };\n    HiddenQuery.prototype.getDescription = function () {\n        var description = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.hd);\n        if (_.isEmpty(description)) {\n            description = this.queryStateModel.get(QueryStateModel_1.QueryStateModel.attributesEnum.hq);\n        }\n        if (!_.isEmpty(description)) {\n            if (description.length > this.options.maximumDescriptionLength) {\n                description = description.slice(0, this.options.maximumDescriptionLength) + ' ...';\n            }\n        }\n        return description;\n    };\n    HiddenQuery.ID = 'HiddenQuery';\n    HiddenQuery.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            HiddenQuery: HiddenQuery\n        });\n    };\n    /**\n     * Possible options for the `HiddenQuery` component\n     * @componentOptions\n     */\n    HiddenQuery.options = {\n        /**\n         * Specifies the maximum number of characters from the hidden query description (`hd`) to display in the\n         * {@link Breadcrumb}.\n         *\n         * Beyond this length, the HiddenQuery component slices the rest of the description and replaces it by `...`.\n         *\n         * Default value is `100`. Minimum value is `0`.\n         */\n        maximumDescriptionLength: ComponentOptions_1.ComponentOptions.buildNumberOption({ min: 0, defaultValue: 100 }),\n        /**\n         * Specifies the title that should appear in the {@link Breadcrumb} when the HiddenQuery populates it.\n         *\n         * Default value is the localized string f\n         * or `\"Additional filters:\"`\n         */\n        title: ComponentOptions_1.ComponentOptions.buildLocalizedStringOption({\n            localizedString: function () { return Strings_1.l('AdditionalFilters') + ':'; }\n        })\n    };\n    return HiddenQuery;\n}(Component_1.Component));\nexports.HiddenQuery = HiddenQuery;\nInitialization_1.Initialization.registerAutoCreateComponent(HiddenQuery);\n\n\n/***/ }),\n\n/***/ 621:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// HiddenQuery.min__ff92a1d47dbcec2611e1.js","import { Component } from '../Base/Component';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { l } from '../../strings/Strings';\nimport { QueryEvents, IBuildingQueryEventArgs } from '../../events/QueryEvents';\nimport { BreadcrumbEvents, IPopulateBreadcrumbEventArgs } from '../../events/BreadcrumbEvents';\nimport { analyticsActionCauseList, IAnalyticsContextRemoveMeta } from '../Analytics/AnalyticsActionListMeta';\nimport { QUERY_STATE_ATTRIBUTES, QueryStateModel } from '../../models/QueryStateModel';\nimport { $$ } from '../../utils/Dom';\nimport { Utils } from '../../utils/Utils';\nimport { Initialization } from '../Base/Initialization';\nimport { Assert } from '../../misc/Assert';\nimport * as _ from 'underscore';\nimport { exportGlobally } from '../../GlobalExports';\nimport 'styling/_HiddenQuery';\nimport { SVGIcons } from '../../utils/SVGIcons';\n\nexport interface IHiddenQueryOptions {\n  maximumDescriptionLength: number;\n  title: string;\n}\n\n/**\n * The HiddenQuery component handles a \"hidden\" query parameter (`hq`) and its description (`hd`).\n *\n * Concretely, this means that if a HiddenQuery component is present in your page and you load your search interface\n * with `hq=foo&hd=bar` in the URL hash, the component adds `foo` as an expression to the query (`hq` is the hidden\n * query) and renders `bar` in the {@link Breadcrumb} (`hd` is the hidden query description).\n */\nexport class HiddenQuery extends Component {\n  static ID = 'HiddenQuery';\n\n  static doExport = () => {\n    exportGlobally({\n      HiddenQuery: HiddenQuery\n    });\n  };\n\n  /**\n   * Possible options for the `HiddenQuery` component\n   * @componentOptions\n   */\n  static options: IHiddenQueryOptions = {\n    /**\n     * Specifies the maximum number of characters from the hidden query description (`hd`) to display in the\n     * {@link Breadcrumb}.\n     *\n     * Beyond this length, the HiddenQuery component slices the rest of the description and replaces it by `...`.\n     *\n     * Default value is `100`. Minimum value is `0`.\n     */\n    maximumDescriptionLength: ComponentOptions.buildNumberOption({ min: 0, defaultValue: 100 }),\n\n    /**\n     * Specifies the title that should appear in the {@link Breadcrumb} when the HiddenQuery populates it.\n     *\n     * Default value is the localized string f\n     * or `\"Additional filters:\"`\n     */\n    title: ComponentOptions.buildLocalizedStringOption({\n      localizedString: () => l('AdditionalFilters') + ':'\n    })\n  };\n\n  /**\n   * Creates a new HiddenQuery component, which binds multiple events ({@link QueryEvents.buildingQuery},\n   * {@link BreadcrumbEvents.populateBreadcrumb} and {@link BreadcrumbEvents.clearBreadcrumb}).\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the HiddenQuery 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   */\n  constructor(public element: HTMLElement, public options?: IHiddenQueryOptions, bindings?: IComponentBindings) {\n    super(element, HiddenQuery.ID, bindings);\n    this.options = ComponentOptions.initComponentOptions(element, HiddenQuery, options);\n\n    this.bind.onRootElement(QueryEvents.buildingQuery, (args: IBuildingQueryEventArgs) => this.handleBuildingQuery(args));\n    this.bind.onRootElement(BreadcrumbEvents.populateBreadcrumb, (args: IPopulateBreadcrumbEventArgs) =>\n      this.handlePopulateBreadcrumb(args)\n    );\n    this.bind.onRootElement(BreadcrumbEvents.clearBreadcrumb, () => this.setStateEmpty());\n  }\n\n  /**\n   * Clears any `hd` or `hq` set in the {@link QueryStateModel}.\n   * Also logs the `contextRemove` event in the usage analytics and triggers a new query.\n   */\n  public clear() {\n    this.setStateEmpty();\n    const hiddenDescriptionRemoved = this.getDescription();\n    this.usageAnalytics.logSearchEvent<IAnalyticsContextRemoveMeta>(analyticsActionCauseList.contextRemove, {\n      contextName: hiddenDescriptionRemoved\n    });\n    this.queryController.executeQuery();\n  }\n\n  private setStateEmpty() {\n    this.queryStateModel.set(QUERY_STATE_ATTRIBUTES.HD, '');\n    this.queryStateModel.set(QUERY_STATE_ATTRIBUTES.HQ, '');\n  }\n\n  private handleBuildingQuery(data: IBuildingQueryEventArgs) {\n    Assert.exists(data);\n    const hiddenQuery = this.queryStateModel.get(QUERY_STATE_ATTRIBUTES.HQ);\n    if (Utils.isNonEmptyString(hiddenQuery)) {\n      data.queryBuilder.advancedExpression.add(hiddenQuery);\n    }\n  }\n\n  private handlePopulateBreadcrumb(args: IPopulateBreadcrumbEventArgs) {\n    const description = this.getDescription();\n    if (!_.isEmpty(description) && !_.isEmpty(this.queryStateModel.get(QUERY_STATE_ATTRIBUTES.HQ))) {\n      const elem = document.createElement('div');\n      $$(elem).addClass('coveo-hidden-query-breadcrumb');\n\n      const title = document.createElement('span');\n      $$(title).addClass('coveo-hidden-query-breadcrumb-title');\n      $$(title).text(this.options.title);\n      elem.appendChild(title);\n\n      const value = $$('span', { className: 'coveo-hidden-query-breadcrumb-value' }, _.escape(description)).el;\n      elem.appendChild(value);\n\n      const clear = $$('span', { className: 'coveo-hidden-query-breadcrumb-clear' }, SVGIcons.icons.mainClear);\n      value.appendChild(clear.el);\n\n      $$(value).on('click', () => this.clear());\n\n      args.breadcrumbs.push({\n        element: elem\n      });\n    }\n  }\n\n  private getDescription() {\n    let description = this.queryStateModel.get(QueryStateModel.attributesEnum.hd);\n    if (_.isEmpty(description)) {\n      description = this.queryStateModel.get(QueryStateModel.attributesEnum.hq);\n    }\n    if (!_.isEmpty(description)) {\n      if (description.length > this.options.maximumDescriptionLength) {\n        description = description.slice(0, this.options.maximumDescriptionLength) + ' ...';\n      }\n    }\n    return description;\n  }\n}\nInitialization.registerAutoCreateComponent(HiddenQuery);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/HiddenQuery/HiddenQuery.ts"],"sourceRoot":""}