{"version":3,"sources":["ErrorReport.min__7eadccde4abd055d0c1a.js","./src/ui/ErrorReport/ErrorReport.ts"],"names":["webpackJsonpCoveo__temporary","251","module","exports","__webpack_require__","__extends","this","extendStatics","Object","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","defineProperty","value","element","options","bindings","ErrorReport","ID","ComponentOptions","initComponentOptions","container","$$","className","appendChild","el","showDetailedError","message","append","helpSuggestion","hide","bind","onRootElement","QueryEvents","newQuery","handleNewQuery","queryError","data","handleQueryError","_this","back","usageAnalytics","logCustomEvent","analyticsActionCauseList","errorBack","root","logSearchEvent","history","reset","queryStateModel","errorClearQuery","queryController","executeQuery","retry","errorRetry","buildOrGetTitleElements","title","titleElement","find","prepend","firstHeading","secondHeading","h1","h2","setErrorTitle","errorName","errorTitle","l","text","buildPrevious","previous","AccessibleButton","withElement","withSelectAction","withLabel","build","buildReset","buildRetry","remove","closePopup","Assert","exists","error","endpoint","queryStringArguments","organizationId","isMissingAuthentication","name","buildEndpointErrorElements","undefined","buildOptionsElement","empty","on","buildErrorInfo","show","errorInfo","textArea","JSON","stringify","infoLabel","oldOptions","optionsElement","helpLink","link","href","setHtml","insertBefore","doExport","exportGlobally","buildBooleanOption","defaultValue","Component","Initialization","registerAutoCreateComponent","611"],"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,E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KAAK+B,eAAeD,OAAO2E,EAAK9E,IAChC3B,KAAKuB,UAAUI,GAAGiF,aAAa5G,KAAK+B,eAAeJ,GAAI3B,KAAK6B,QAAQF,KA/S/D,EAAAP,GAAK,cAEL,EAAAyF,SAAW,WAChB,EAAAC,gBACE3F,YAAaA,KAQV,EAAAF,SAMLW,kBAAmB,EAAAP,iBAAiB0F,oBAAqBC,cAAc,KA+R3E,GAlTiC,EAAAC,UAApB,GAAA9F,cAoTb,EAAA+F,eAAeC,4BAA4BhG,ID7CrCiG,IACA,SAAUxH,EAAQC","file":"ErrorReport.min__7eadccde4abd055d0c1a.js","sourcesContent":["webpackJsonpCoveo__temporary([73],{\n\n/***/ 251:\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__(611);\nvar QueryEvents_1 = __webpack_require__(11);\nvar GlobalExports_1 = __webpack_require__(3);\nvar Assert_1 = __webpack_require__(5);\nvar Strings_1 = __webpack_require__(6);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar Dom_1 = __webpack_require__(1);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar Initialization_1 = __webpack_require__(2);\n/**\n * The ErrorReport component takes care of handling fatal error when doing a query on the index / Search API.\n *\n * For example, the ErrorReport component displays a message when the service responds with a 401 or 503 error. This\n * component also renders a small text area with the JSON content of the error response, for debugging purposes.\n */\nvar ErrorReport = /** @class */ (function (_super) {\n    __extends(ErrorReport, _super);\n    /**\n     * Creates a new ErrorReport component.\n     * @param element The HTMLElement on which to instantiate the component.\n     * @param options The options for the ErrorReport 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 ErrorReport(element, options, bindings) {\n        var _this = _super.call(this, element, ErrorReport.ID, bindings) || this;\n        _this.element = element;\n        _this.options = options;\n        _this.options = ComponentOptions_1.ComponentOptions.initComponentOptions(element, ErrorReport, options);\n        _this.container = Dom_1.$$('div', { className: 'coveo-error-report-container' });\n        _this.element.appendChild(_this.container.el);\n        if (_this.options.showDetailedError) {\n            _this.message = Dom_1.$$('div', {\n                className: 'coveo-error-report-message'\n            });\n            _this.container.append(_this.message.el);\n        }\n        _this.helpSuggestion = Dom_1.$$('div', {\n            className: 'coveo-error-report-help-suggestion'\n        });\n        Dom_1.$$(_this.element).hide();\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.newQuery, function () { return _this.handleNewQuery(); });\n        _this.bind.onRootElement(QueryEvents_1.QueryEvents.queryError, function (data) { return _this.handleQueryError(data); });\n        return _this;\n    }\n    /**\n     * Performs the \"back\" action in the browser.\n     * Also logs an `errorBack` event in the usage analytics.\n     */\n    ErrorReport.prototype.back = function () {\n        this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorBack, {}, this.root);\n        this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorBack, {});\n        history.back();\n    };\n    /**\n     * Resets the current state of the query and triggers a new query.\n     * Also logs an `errorClearQuery` event in the usage analytics.\n     */\n    ErrorReport.prototype.reset = function () {\n        this.queryStateModel.reset();\n        this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorClearQuery, {});\n        this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorClearQuery, {}, this.root);\n        this.queryController.executeQuery();\n    };\n    /**\n     * Retries the same query, in case of a temporary service error.\n     * Also logs an `errorRetry` event in the usage analytics.\n     */\n    ErrorReport.prototype.retry = function () {\n        this.usageAnalytics.logSearchEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorRetry, {});\n        this.usageAnalytics.logCustomEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.errorRetry, {}, this.root);\n        this.queryController.executeQuery();\n    };\n    ErrorReport.prototype.buildOrGetTitleElements = function () {\n        var titleElement = Dom_1.$$(this.element).find('.coveo-error-report-title');\n        var title;\n        if (titleElement) {\n            title = Dom_1.$$(titleElement);\n        }\n        else {\n            title = Dom_1.$$('div', { className: 'coveo-error-report-title' });\n            this.container.prepend(title.el);\n        }\n        var firstHeading = title.find('h1');\n        if (!firstHeading) {\n            firstHeading = Dom_1.$$('h1').el;\n            title.append(firstHeading);\n        }\n        var secondHeading = title.find('h2');\n        if (!secondHeading) {\n            secondHeading = Dom_1.$$('h2').el;\n            title.append(secondHeading);\n        }\n        return {\n            title: title,\n            h1: Dom_1.$$(firstHeading),\n            h2: Dom_1.$$(secondHeading)\n        };\n    };\n    ErrorReport.prototype.setErrorTitle = function (errorName, helpSuggestion) {\n        var errorTitle = {\n            h1: errorName ? Strings_1.l(errorName) : Strings_1.l('OopsError'),\n            h2: helpSuggestion ? Strings_1.l(helpSuggestion) : Strings_1.l('ProblemPersists')\n        };\n        var _a = this.buildOrGetTitleElements(), h1 = _a.h1, h2 = _a.h2;\n        if (h1 && h2) {\n            Dom_1.$$(h1).text(errorTitle.h1);\n            Dom_1.$$(h2).text(errorTitle.h2);\n        }\n    };\n    ErrorReport.prototype.buildPrevious = function () {\n        var _this = this;\n        var previous = Dom_1.$$('span', {\n            className: 'coveo-error-report-previous'\n        }, Strings_1.l('GoBack'));\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(previous)\n            .withSelectAction(function () { return _this.back(); })\n            .withLabel(Strings_1.l('GoBack'))\n            .build();\n        return previous.el;\n    };\n    ErrorReport.prototype.buildReset = function () {\n        var _this = this;\n        var reset = Dom_1.$$('span', {\n            className: 'coveo-error-report-clear'\n        }, Strings_1.l('Reset'));\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(reset)\n            .withSelectAction(function () { return _this.reset(); })\n            .withLabel(Strings_1.l('Reset'))\n            .build();\n        return reset.el;\n    };\n    ErrorReport.prototype.buildRetry = function () {\n        var _this = this;\n        var retry = Dom_1.$$('span', {\n            className: 'coveo-error-report-retry'\n        }, Strings_1.l('Retry'));\n        new AccessibleButton_1.AccessibleButton()\n            .withElement(retry)\n            .withSelectAction(function () { return _this.retry(); })\n            .withLabel(Strings_1.l('Retry'))\n            .build();\n        return retry.el;\n    };\n    ErrorReport.prototype.handleNewQuery = function () {\n        Dom_1.$$(this.element).hide();\n        var _a = this.buildOrGetTitleElements(), h1 = _a.h1, h2 = _a.h2;\n        h1.remove();\n        h2.remove();\n        if (this.closePopup != null) {\n            this.closePopup();\n        }\n    };\n    ErrorReport.prototype.handleQueryError = function (data) {\n        var _this = this;\n        Assert_1.Assert.exists(data);\n        Assert_1.Assert.exists(data.error);\n        if (data.endpoint.options.queryStringArguments.organizationId) {\n            this.organizationId = data.endpoint.options.queryStringArguments.organizationId;\n        }\n        else {\n            this.organizationId = Strings_1.l('CoveoOrganization');\n        }\n        // Do not display the panel if the error is for missing authentication. The\n        // appropriate authentication provider should take care of redirecting.\n        if (data.error.isMissingAuthentication) {\n            return;\n        }\n        switch (data.error.name) {\n            case 'NoEndpointsException':\n                this.options.showDetailedError = false;\n                this.buildEndpointErrorElements('https://docs.coveo.com/en/331/');\n                this.setErrorTitle(Strings_1.l('NoEndpoints', this.organizationId), Strings_1.l('AddSources'));\n                break;\n            case 'InvalidTokenException':\n                this.options.showDetailedError = false;\n                this.buildEndpointErrorElements('https://docs.coveo.com/en/56/');\n                this.setErrorTitle(Strings_1.l('CannotAccess', this.organizationId), Strings_1.l('InvalidToken'));\n                break;\n            case 'GroupByAndFacetBothExistingException':\n                this.options.showDetailedError = false;\n                this.buildEndpointErrorElements('https://docs.coveo.com/en/2917');\n                this.setErrorTitle(undefined, Strings_1.l('GroupByAndFacetRequestsCannotCoexist'));\n                break;\n            case 'OrganizationIsPausedException':\n                this.options.showDetailedError = false;\n                this.buildEndpointErrorElements('https://docs.coveo.com/l6af0467');\n                this.setErrorTitle(Strings_1.l('OrganizationWillResume'), Strings_1.l('OrganizationIsPaused'));\n                break;\n            default:\n                this.buildOptionsElement();\n                this.setErrorTitle();\n        }\n        if (this.options.showDetailedError) {\n            this.message.empty();\n            var moreInfo_1 = Dom_1.$$('span', {\n                className: 'coveo-error-report-more-info'\n            }, Strings_1.l('MoreInfo'));\n            moreInfo_1.on('click', function () {\n                moreInfo_1.empty();\n                _this.message.el.appendChild(_this.buildErrorInfo(data.error));\n            });\n            this.message.el.appendChild(moreInfo_1.el);\n        }\n        Dom_1.$$(this.element).show();\n    };\n    ErrorReport.prototype.buildErrorInfo = function (data) {\n        var errorInfo = Dom_1.$$('div', {\n            className: 'coveo-error-info'\n        });\n        var textArea = Dom_1.$$('textarea', undefined, JSON.stringify(data, null, 2));\n        errorInfo.el.appendChild(textArea.el);\n        var infoLabel = Dom_1.$$('div', {\n            className: 'coveo-error-info-label'\n        }, Strings_1.l('CopyPasteToSupport'));\n        errorInfo.el.appendChild(infoLabel.el);\n        return errorInfo.el;\n    };\n    ErrorReport.prototype.buildOptionsElement = function () {\n        var oldOptions = this.container.find('.coveo-error-report-options');\n        if (oldOptions) {\n            Dom_1.$$(oldOptions).remove();\n        }\n        var optionsElement = Dom_1.$$('div', { className: 'coveo-error-report-options' });\n        optionsElement.el.appendChild(this.buildPrevious());\n        optionsElement.el.appendChild(this.buildReset());\n        optionsElement.el.appendChild(this.buildRetry());\n        this.container.append(optionsElement.el);\n    };\n    ErrorReport.prototype.buildEndpointErrorElements = function (helpLink) {\n        if (helpLink === void 0) { helpLink = 'https://docs.coveo.com/en/331/'; }\n        this.helpSuggestion.empty();\n        var link = Dom_1.$$('a', {\n            href: helpLink,\n            className: 'coveo-error-report-help-link'\n        });\n        link.setHtml(Strings_1.l('CoveoOnlineHelp'));\n        this.helpSuggestion.append(link.el);\n        this.container.el.insertBefore(this.helpSuggestion.el, this.message.el);\n    };\n    ErrorReport.ID = 'ErrorReport';\n    ErrorReport.doExport = function () {\n        GlobalExports_1.exportGlobally({\n            ErrorReport: ErrorReport\n        });\n    };\n    /**\n     * The options for the component\n     * @componentOptions\n     */\n    ErrorReport.options = {\n        /**\n         * Specifies whether to display a detailed error message as a JSON in a text content area.\n         *\n         * Default value is `true`.\n         */\n        showDetailedError: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: true })\n    };\n    return ErrorReport;\n}(Component_1.Component));\nexports.ErrorReport = ErrorReport;\nInitialization_1.Initialization.registerAutoCreateComponent(ErrorReport);\n\n\n/***/ }),\n\n/***/ 611:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// ErrorReport.min__7eadccde4abd055d0c1a.js","import 'styling/_ErrorReport';\nimport { IQueryErrorEventArgs, QueryEvents } from '../../events/QueryEvents';\nimport { exportGlobally } from '../../GlobalExports';\nimport { Assert } from '../../misc/Assert';\nimport { IEndpointError } from '../../rest/EndpointError';\nimport { MissingAuthenticationError } from '../../rest/MissingAuthenticationError';\nimport { l } from '../../strings/Strings';\nimport { AccessibleButton } from '../../utils/AccessibleButton';\nimport { $$, Dom } from '../../utils/Dom';\nimport { analyticsActionCauseList, IAnalyticsNoMeta } from '../Analytics/AnalyticsActionListMeta';\nimport { Component } from '../Base/Component';\nimport { IComponentBindings } from '../Base/ComponentBindings';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { Initialization } from '../Base/Initialization';\n\nexport interface IErrorReportOptions {\n  showDetailedError: boolean;\n}\n\n/**\n * The ErrorReport component takes care of handling fatal error when doing a query on the index / Search API.\n *\n * For example, the ErrorReport component displays a message when the service responds with a 401 or 503 error. This\n * component also renders a small text area with the JSON content of the error response, for debugging purposes.\n */\nexport class ErrorReport extends Component {\n  static ID = 'ErrorReport';\n\n  static doExport = () => {\n    exportGlobally({\n      ErrorReport: ErrorReport\n    });\n  };\n\n  /**\n   * The options for the component\n   * @componentOptions\n   */\n  static options: IErrorReportOptions = {\n    /**\n     * Specifies whether to display a detailed error message as a JSON in a text content area.\n     *\n     * Default value is `true`.\n     */\n    showDetailedError: ComponentOptions.buildBooleanOption({ defaultValue: true })\n  };\n  private organizationId;\n  private message: Dom;\n  private container: Dom;\n  private helpSuggestion: Dom;\n  private closePopup: () => void;\n\n  /**\n   * Creates a new ErrorReport component.\n   * @param element The HTMLElement on which to instantiate the component.\n   * @param options The options for the ErrorReport 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?: IErrorReportOptions, bindings?: IComponentBindings) {\n    super(element, ErrorReport.ID, bindings);\n    this.options = ComponentOptions.initComponentOptions(element, ErrorReport, options);\n    this.container = $$('div', { className: 'coveo-error-report-container' });\n    this.element.appendChild(this.container.el);\n\n    if (this.options.showDetailedError) {\n      this.message = $$('div', {\n        className: 'coveo-error-report-message'\n      });\n      this.container.append(this.message.el);\n    }\n    this.helpSuggestion = $$('div', {\n      className: 'coveo-error-report-help-suggestion'\n    });\n\n    $$(this.element).hide();\n\n    this.bind.onRootElement(QueryEvents.newQuery, () => this.handleNewQuery());\n    this.bind.onRootElement(QueryEvents.queryError, (data: IQueryErrorEventArgs) => this.handleQueryError(data));\n  }\n\n  /**\n   * Performs the \"back\" action in the browser.\n   * Also logs an `errorBack` event in the usage analytics.\n   */\n  public back(): void {\n    this.usageAnalytics.logCustomEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorBack, {}, this.root);\n    this.usageAnalytics.logSearchEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorBack, {});\n    history.back();\n  }\n\n  /**\n   * Resets the current state of the query and triggers a new query.\n   * Also logs an `errorClearQuery` event in the usage analytics.\n   */\n  public reset(): void {\n    this.queryStateModel.reset();\n    this.usageAnalytics.logSearchEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorClearQuery, {});\n    this.usageAnalytics.logCustomEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorClearQuery, {}, this.root);\n    this.queryController.executeQuery();\n  }\n\n  /**\n   * Retries the same query, in case of a temporary service error.\n   * Also logs an `errorRetry` event in the usage analytics.\n   */\n  public retry(): void {\n    this.usageAnalytics.logSearchEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorRetry, {});\n    this.usageAnalytics.logCustomEvent<IAnalyticsNoMeta>(analyticsActionCauseList.errorRetry, {}, this.root);\n    this.queryController.executeQuery();\n  }\n\n  private buildOrGetTitleElements() {\n    const titleElement = $$(this.element).find('.coveo-error-report-title');\n\n    let title: Dom;\n    if (titleElement) {\n      title = $$(titleElement);\n    } else {\n      title = $$('div', { className: 'coveo-error-report-title' });\n      this.container.prepend(title.el);\n    }\n\n    let firstHeading = title.find('h1');\n\n    if (!firstHeading) {\n      firstHeading = $$('h1').el;\n      title.append(firstHeading);\n    }\n\n    let secondHeading = title.find('h2');\n    if (!secondHeading) {\n      secondHeading = $$('h2').el;\n      title.append(secondHeading);\n    }\n\n    return {\n      title,\n      h1: $$(firstHeading),\n      h2: $$(secondHeading)\n    };\n  }\n\n  private setErrorTitle(errorName?: string, helpSuggestion?: string): void {\n    const errorTitle = {\n      h1: errorName ? l(errorName) : l('OopsError'),\n      h2: helpSuggestion ? l(helpSuggestion) : l('ProblemPersists')\n    };\n\n    const { h1, h2 } = this.buildOrGetTitleElements();\n    if (h1 && h2) {\n      $$(h1).text(errorTitle.h1);\n      $$(h2).text(errorTitle.h2);\n    }\n  }\n\n  private buildPrevious(): HTMLElement {\n    const previous = $$(\n      'span',\n      {\n        className: 'coveo-error-report-previous'\n      },\n      l('GoBack')\n    );\n\n    new AccessibleButton()\n      .withElement(previous)\n      .withSelectAction(() => this.back())\n      .withLabel(l('GoBack'))\n      .build();\n\n    return previous.el;\n  }\n\n  private buildReset(): HTMLElement {\n    const reset = $$(\n      'span',\n      {\n        className: 'coveo-error-report-clear'\n      },\n      l('Reset')\n    );\n\n    new AccessibleButton()\n      .withElement(reset)\n      .withSelectAction(() => this.reset())\n      .withLabel(l('Reset'))\n      .build();\n\n    return reset.el;\n  }\n\n  private buildRetry(): HTMLElement {\n    const retry = $$(\n      'span',\n      {\n        className: 'coveo-error-report-retry'\n      },\n      l('Retry')\n    );\n\n    new AccessibleButton()\n      .withElement(retry)\n      .withSelectAction(() => this.retry())\n      .withLabel(l('Retry'))\n      .build();\n\n    return retry.el;\n  }\n\n  private handleNewQuery(): void {\n    $$(this.element).hide();\n    const { h1, h2 } = this.buildOrGetTitleElements();\n    h1.remove();\n    h2.remove();\n    if (this.closePopup != null) {\n      this.closePopup();\n    }\n  }\n\n  private handleQueryError(data: IQueryErrorEventArgs): void {\n    Assert.exists(data);\n    Assert.exists(data.error);\n\n    if (data.endpoint.options.queryStringArguments.organizationId) {\n      this.organizationId = data.endpoint.options.queryStringArguments.organizationId;\n    } else {\n      this.organizationId = l('CoveoOrganization');\n    }\n\n    // Do not display the panel if the error is for missing authentication. The\n    // appropriate authentication provider should take care of redirecting.\n    if ((<MissingAuthenticationError>data.error).isMissingAuthentication) {\n      return;\n    }\n\n    switch (data.error.name) {\n      case 'NoEndpointsException':\n        this.options.showDetailedError = false;\n        this.buildEndpointErrorElements('https://docs.coveo.com/en/331/');\n        this.setErrorTitle(l('NoEndpoints', this.organizationId), l('AddSources'));\n        break;\n\n      case 'InvalidTokenException':\n        this.options.showDetailedError = false;\n        this.buildEndpointErrorElements('https://docs.coveo.com/en/56/');\n        this.setErrorTitle(l('CannotAccess', this.organizationId), l('InvalidToken'));\n        break;\n\n      case 'GroupByAndFacetBothExistingException':\n        this.options.showDetailedError = false;\n        this.buildEndpointErrorElements('https://docs.coveo.com/en/2917');\n        this.setErrorTitle(undefined, l('GroupByAndFacetRequestsCannotCoexist'));\n        break;\n\n      case 'OrganizationIsPausedException':\n        this.options.showDetailedError = false;\n        this.buildEndpointErrorElements('https://docs.coveo.com/l6af0467');\n        this.setErrorTitle(l('OrganizationWillResume'), l('OrganizationIsPaused'));\n        break;\n\n      default:\n        this.buildOptionsElement();\n        this.setErrorTitle();\n    }\n\n    if (this.options.showDetailedError) {\n      this.message.empty();\n      const moreInfo = $$(\n        'span',\n        {\n          className: 'coveo-error-report-more-info'\n        },\n        l('MoreInfo')\n      );\n\n      moreInfo.on('click', () => {\n        moreInfo.empty();\n        this.message.el.appendChild(this.buildErrorInfo(data.error));\n      });\n\n      this.message.el.appendChild(moreInfo.el);\n    }\n\n    $$(this.element).show();\n  }\n\n  private buildErrorInfo(data: IEndpointError): HTMLElement {\n    const errorInfo = $$('div', {\n      className: 'coveo-error-info'\n    });\n\n    let textArea = $$('textarea', undefined, JSON.stringify(data, null, 2));\n    errorInfo.el.appendChild(textArea.el);\n\n    const infoLabel = $$(\n      'div',\n      {\n        className: 'coveo-error-info-label'\n      },\n      l('CopyPasteToSupport')\n    );\n    errorInfo.el.appendChild(infoLabel.el);\n\n    return errorInfo.el;\n  }\n\n  private buildOptionsElement() {\n    const oldOptions = this.container.find('.coveo-error-report-options');\n    if (oldOptions) {\n      $$(oldOptions).remove();\n    }\n    const optionsElement = $$('div', { className: 'coveo-error-report-options' });\n    optionsElement.el.appendChild(this.buildPrevious());\n    optionsElement.el.appendChild(this.buildReset());\n    optionsElement.el.appendChild(this.buildRetry());\n    this.container.append(optionsElement.el);\n  }\n\n  private buildEndpointErrorElements(helpLink: string = 'https://docs.coveo.com/en/331/') {\n    this.helpSuggestion.empty();\n\n    const link = $$('a', {\n      href: helpLink,\n      className: 'coveo-error-report-help-link'\n    });\n\n    link.setHtml(l('CoveoOnlineHelp'));\n    this.helpSuggestion.append(link.el);\n    this.container.el.insertBefore(this.helpSuggestion.el, this.message.el);\n  }\n}\n\nInitialization.registerAutoCreateComponent(ErrorReport);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ErrorReport/ErrorReport.ts"],"sourceRoot":""}