{"version":3,"sources":["ResultLink.min__ff92a1d47dbcec2611e1.js","./src/ui/ResultLink/ResultLinkCommon.ts","./src/ui/ResultLink/ResultLink.ts"],"names":["webpackJsonpCoveo__temporary","474","module","exports","__webpack_require__","element","logAnalytics","executeOnlyOnce","once","$$","on","longPressTimer","window","setTimeout","clearTimeout","Object","defineProperty","value","534","71","__extends","this","extendStatics","setPrototypeOf","__proto__","Array","d","b","p","hasOwnProperty","__","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","options","bindings","result","os","ResultLink","ID","debounce","queryController","saveLastQuery","documentURL","getAttribute","undefined","escapedClickUri","logDocumentOpen","Defer","flush","globalOptions","searchInterface","originalOptionsObject","initialOptions","ComponentOptions","initComponentOptions","resultLinkOptions","componentOptionsModel","get","ComponentOptionsModel","attributesEnum","resultLink","extend","resolveResult","openQuickview","raw","DeviceUtils","isMobileDevice","hasAttribute","setAttribute","Assert","exists","quickviewShouldBeOpened","bindAnalyticsToLink","renderUri","bindEventToOpen","_this","test","innerHTML","title","getDisplayedTitle","titleAsText","getDisplayedTitleAsText","openLink","location","href","getResultUri","openLinkInNewWindow","open","openLinkInOutlook","hasOutlookField","openLinkAsConfigured","toExecuteOnOpen","bindOnClickIfNotUndefined","bindOpenQuickviewIfNotUndefined","setHrefIfNotAlready","openLinkThatIsNotAnAnchor","titleTemplate","newTitle","StringUtils","buildStringTemplateFromResult","StreamHighlightUtils","highlightStreamText","termsToHighlight","phrasesToHighlight","HighlightUtils","highlightString","titleHighlights","container","setHtml","text","escape","clickUri","enumerable","configurable","onClick","e","AccessibleButton","withElement","withLabel","withSelectAction","build","resultElement","trigger","ResultListEvents","preventDefault","elementIsAnAnchor","alwaysOpenInNewWindow","openInOutlook","Utils","isNonEmptyString","usageAnalytics","logClickEvent","analyticsActionCauseList","documentOpen","documentTitle","author","getFieldValue","root","filterProtocol","uri","isAbsolute","isRelative","hrefTemplate","field","setField","tagName","OSUtils","OS_NAME","MACOSX","WINDOWS","isUriThatMustBeOpenedInQuickview","toLowerCase","indexOf","QueryUtils","hasHTMLVersion","doExport","exportGlobally","buildFieldOption","buildBooleanOption","defaultValue","buildStringOption","buildCustomOption","Component","Initialization","registerAutoCreateComponent"],"mappings":"AAAAA,8BAA8B,KAExBC,IACA,SAAUC,EAAQC,EAASC,GAEjC,YCFA,YAAoCC,EAAsBC,GACxD,GAAMC,GAAkB,EAAAC,KAAK,WAAM,MAAAF,MAEnC,GAAAG,GAAGJ,GAASK,IAAI,cAAe,QAAS,YAAa,WAAYH,EACjE,IAAII,EACJ,GAAAF,GAAGJ,GAASK,GAAG,aAAc,WAC3BC,EAAiBC,OAAOC,WAAWN,EAAiB,OAEtD,EAAAE,GAAGJ,GAASK,GAAG,WAAY,WACrBC,GACFG,aAAaH,KDNnBI,OAAOC,eAAeb,EAAS,cAAgBc,OAAO,GCPtD,YACA,MAEA,0BDyBMC,IACA,SAAUhB,EAAQC,KAMlBgB,GACA,SAAUjB,EAAQC,EAASC,GAEjC,YAEA,IAAIgB,GAAaC,MAAQA,KAAKD,WAAc,WACxC,GAAIE,GAAgBP,OAAOQ,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,KAAOT,KAAKU,YAAcL,EADnCJ,EAAcI,EAAGC,GAEjBD,EAAEM,UAAkB,OAANL,EAAaZ,OAAOkB,OAAON,IAAMG,EAAGE,UAAYL,EAAEK,UAAW,GAAIF,QAGnFI,EAAYb,MAAQA,KAAKa,UAAanB,OAAOoB,QAAU,SAASC,GAChE,IAAK,GAAIC,GAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAAK,CACjDD,EAAIG,UAAUF,EACd,KAAK,GAAIV,KAAKS,GAAOtB,OAAOiB,UAAUH,eAAea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AKsB,QAAQ8G,MAAQ,gBAIjB,YAAAtD,gBAAR,WACE,GAAIrD,GAAK,EAAA4F,MAAM1D,OAAO3D,KAAKyB,IAAMzB,KAAKyB,GAAK,EAAA8G,QAAQzF,KACnD,OAAIrB,IAAM,EAAA+G,QAAQC,YAAiDxG,IAAvCjC,KAAKwB,OAAO6B,IAAsB,kBAEnD5B,GAAM,EAAA+G,QAAQE,aAA4CzG,IAAjCjC,KAAKwB,OAAO6B,IAAgB,YAM1D,YAAAsF,iCAAR,WACE,MAAgE,IAAzD3I,KAAKkC,gBAAgB0G,cAAcC,QAAQ,YAG5C,YAAAjF,wBAAR,WACE,OAAQ5D,KAAKsB,QAAQ8B,eAAiBpD,KAAK2I,qCAAuC,EAAAG,WAAWC,eAAe/I,KAAKwB,SAnhB5G,EAAAG,GAAK,aAEL,EAAAqH,SAAW,WAChB,EAAAC,gBACEvH,WAAYA,KAQT,EAAAJ,SA8BL8G,MAAO,EAAA1F,iBAAiBwG,mBAaxB9B,cAAe,EAAA1E,iBAAiByG,oBAAqBC,cAAc,IAQnEhG,cAAe,EAAAV,iBAAiByG,oBAAqBC,cAAc,IAmBnEjC,sBAAuB,EAAAzE,iBAAiByG,oBAAqBC,cAAc,IA2B3EjB,aAAc,EAAAzF,iBAAiB2G,oBAyC/BhE,cAAe,EAAA3C,iBAAiB2G,oBA0ChC9C,QAAS,EAAA7D,iBAAiB4G,kBAA2D,WACnF,MAAO,QA2BTrK,aAAc,EAAAyD,iBAAiB4G,kBAA0C,WAAM,eAyTnF,GAthBgC,EAAAC,UAAnB,GAAA7H,aAwhBb,EAAA8H,eAAeC,4BAA4B/H","file":"ResultLink.min__ff92a1d47dbcec2611e1.js","sourcesContent":["webpackJsonpCoveo__temporary([42],{\n\n/***/ 474:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar underscore_1 = __webpack_require__(0);\nvar Dom_1 = __webpack_require__(1);\nfunction bindAnalyticsToLink(element, logAnalytics) {\n var executeOnlyOnce = underscore_1.once(function () { return logAnalytics(); });\n Dom_1.$$(element).on(['contextmenu', 'click', 'mousedown', 'mouseup'], executeOnlyOnce);\n var longPressTimer;\n Dom_1.$$(element).on('touchstart', function () {\n longPressTimer = window.setTimeout(executeOnlyOnce, 1000);\n });\n Dom_1.$$(element).on('touchend', function () {\n if (longPressTimer) {\n clearTimeout(longPressTimer);\n }\n });\n}\nexports.bindAnalyticsToLink = bindAnalyticsToLink;\n\n\n/***/ }),\n\n/***/ 534:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 71:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar Component_1 = __webpack_require__(7);\nvar ComponentOptions_1 = __webpack_require__(8);\nvar ComponentOptionsModel_1 = __webpack_require__(28);\nvar AnalyticsActionListMeta_1 = __webpack_require__(10);\nvar ResultListEvents_1 = __webpack_require__(29);\nvar HighlightUtils_1 = __webpack_require__(69);\nvar DeviceUtils_1 = __webpack_require__(24);\nvar OSUtils_1 = __webpack_require__(181);\nvar Initialization_1 = __webpack_require__(2);\nvar QueryUtils_1 = __webpack_require__(21);\nvar Assert_1 = __webpack_require__(5);\nvar Utils_1 = __webpack_require__(4);\nvar Defer_1 = __webpack_require__(31);\nvar Dom_1 = __webpack_require__(1);\nvar StreamHighlightUtils_1 = __webpack_require__(119);\nvar StringUtils_1 = __webpack_require__(22);\nvar underscore_1 = __webpack_require__(0);\nvar GlobalExports_1 = __webpack_require__(3);\n__webpack_require__(534);\nvar AccessibleButton_1 = __webpack_require__(15);\nvar ResultLinkCommon_1 = __webpack_require__(474);\n/**\n * The `ResultLink` component automatically transform a search result title into a clickable link pointing to the\n * original item.\n *\n * This component is a result template component (see [Result Templates](https://docs.coveo.com/en/413/)).\n */\nvar ResultLink = /** @class */ (function (_super) {\n __extends(ResultLink, _super);\n /**\n * Creates a new `ResultLink` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `ResultLink` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param result The result to associate the component with.\n * @param os\n */\n function ResultLink(element, options, bindings, result, os) {\n var _this = _super.call(this, element, ResultLink.ID, bindings) || this;\n _this.element = element;\n _this.options = options;\n _this.bindings = bindings;\n _this.result = result;\n _this.os = os;\n _this.logAnalytics = underscore_1.debounce(function () {\n _this.queryController.saveLastQuery();\n var documentURL = Dom_1.$$(_this.element).getAttribute('href');\n if (documentURL == undefined || documentURL == '') {\n documentURL = _this.escapedClickUri;\n }\n if (_this.options.logAnalytics) {\n _this.options.logAnalytics(documentURL);\n }\n else {\n _this.logDocumentOpen(documentURL);\n }\n Defer_1.Defer.flush();\n }, 1500, true);\n var globalOptions = _this.searchInterface.options.originalOptionsObject[ResultLink.ID] || {};\n var initialOptions = ComponentOptions_1.ComponentOptions.initComponentOptions(element, ResultLink, __assign({}, globalOptions, options));\n var resultLinkOptions = _this.componentOptionsModel.get(ComponentOptionsModel_1.ComponentOptionsModel.attributesEnum.resultLink);\n _this.options = underscore_1.extend({}, initialOptions, resultLinkOptions);\n _this.result = result || _this.resolveResult();\n if (_this.options.openQuickview == null) {\n _this.options.openQuickview = result.raw['connectortype'] == 'ExchangeCrawler' && DeviceUtils_1.DeviceUtils.isMobileDevice();\n }\n if (!_this.element.hasAttribute('tabindex')) {\n _this.element.setAttribute('tabindex', '0');\n }\n Assert_1.Assert.exists(_this.componentOptionsModel);\n Assert_1.Assert.exists(_this.result);\n if (!_this.quickviewShouldBeOpened()) {\n // Bind on multiple \"click\" or \"mouse\" events.\n // Create a function that will be executed only once, so as not to log multiple events\n // Once a result link has been opened, and that we log at least one analytics event,\n // it should not matter if the end user open the same link multiple times with different methods.\n // It's still only one \"click\" event as far as UA is concerned.\n // Also need to handle \"longpress\" on mobile (the contextual menu), which we assume to be 1 s long.\n ResultLinkCommon_1.bindAnalyticsToLink(element, function () { return _this.logAnalytics(); });\n }\n _this.renderUri(element, result);\n _this.bindEventToOpen();\n return _this;\n }\n ResultLink.prototype.renderUri = function (element, result) {\n if (/^\\s*$/.test(this.element.innerHTML)) {\n var title = this.getDisplayedTitle();\n this.element.innerHTML = title;\n var titleAsText = this.getDisplayedTitleAsText();\n if (!this.element.hasAttribute('aria-label')) {\n this.element.setAttribute('aria-label', titleAsText);\n }\n if (!this.element.title) {\n this.element.title = titleAsText;\n }\n }\n };\n /**\n * Opens the result in the same window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLink = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.location.href = this.getResultUri();\n };\n /**\n * Opens the result in a new window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkInNewWindow = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.open(this.getResultUri(), '_blank');\n };\n /**\n * Tries to open the result in Microsoft Outlook if the result has an `outlookformacuri` or `outlookuri` field.\n *\n * Normally, this implies the result should be a link to an email.\n *\n * If the needed fields are not present, this method does nothing.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkInOutlook = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (this.hasOutlookField()) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.openLink();\n }\n };\n /**\n * Opens the link in the same manner the end user would.\n *\n * This essentially simulates a click on the result link.\n *\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n ResultLink.prototype.openLinkAsConfigured = function (logAnalytics) {\n if (logAnalytics === void 0) { logAnalytics = true; }\n if (this.toExecuteOnOpen) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.toExecuteOnOpen();\n }\n };\n ResultLink.prototype.bindEventToOpen = function () {\n return (this.bindOnClickIfNotUndefined() ||\n this.bindOpenQuickviewIfNotUndefined() ||\n this.setHrefIfNotAlready() ||\n this.openLinkThatIsNotAnAnchor());\n };\n ResultLink.prototype.getDisplayedTitle = function () {\n if (!this.options.titleTemplate) {\n return this.result.title\n ? HighlightUtils_1.HighlightUtils.highlightString(this.result.title, this.result.titleHighlights, null, 'coveo-highlight')\n : this.escapedClickUri;\n }\n else {\n var newTitle = StringUtils_1.StringUtils.buildStringTemplateFromResult(this.options.titleTemplate, this.result);\n return newTitle\n ? StreamHighlightUtils_1.StreamHighlightUtils.highlightStreamText(newTitle, this.result.termsToHighlight, this.result.phrasesToHighlight)\n : this.escapedClickUri;\n }\n };\n ResultLink.prototype.getDisplayedTitleAsText = function () {\n var container = Dom_1.$$('div');\n container.setHtml(this.getDisplayedTitle());\n return container.text();\n };\n Object.defineProperty(ResultLink.prototype, \"escapedClickUri\", {\n get: function () {\n return underscore_1.escape(this.result.clickUri);\n },\n enumerable: true,\n configurable: true\n });\n ResultLink.prototype.bindOnClickIfNotUndefined = function () {\n var _this = this;\n if (this.options.onClick != undefined) {\n this.toExecuteOnOpen = function (e) {\n _this.options.onClick.call(_this, e, _this.result);\n };\n new AccessibleButton_1.AccessibleButton()\n .withElement(this.element)\n .withLabel(this.result.title)\n .withSelectAction(function (e) { return _this.toExecuteOnOpen(e); })\n .build();\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.bindOpenQuickviewIfNotUndefined = function () {\n var _this = this;\n if (this.quickviewShouldBeOpened()) {\n this.toExecuteOnOpen = function () {\n Dom_1.$$(_this.bindings.resultElement).trigger(ResultListEvents_1.ResultListEvents.openQuickview);\n };\n Dom_1.$$(this.element).on('click', function (e) {\n e.preventDefault();\n _this.toExecuteOnOpen();\n });\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.openLinkThatIsNotAnAnchor = function () {\n var _this = this;\n if (!this.elementIsAnAnchor()) {\n this.toExecuteOnOpen = function () {\n if (_this.options.alwaysOpenInNewWindow) {\n if (_this.options.openInOutlook) {\n _this.openLinkInOutlook();\n }\n else {\n _this.openLinkInNewWindow();\n }\n }\n else {\n _this.openLink();\n }\n };\n Dom_1.$$(this.element).on('click', function () {\n _this.toExecuteOnOpen();\n });\n return true;\n }\n return false;\n };\n ResultLink.prototype.setHrefIfNotAlready = function () {\n // Do not erase any value put in href by the template, etc. Allows\n // using custom click urls while still keeping analytics recording\n // and other behavior brought by the component.\n if (this.elementIsAnAnchor() && !Utils_1.Utils.isNonEmptyString(Dom_1.$$(this.element).getAttribute('href'))) {\n Dom_1.$$(this.element).setAttribute('href', this.getResultUri());\n if (this.options.alwaysOpenInNewWindow && !(this.options.openInOutlook && this.hasOutlookField())) {\n Dom_1.$$(this.element).setAttribute('target', '_blank');\n }\n return true;\n }\n else {\n return false;\n }\n };\n ResultLink.prototype.logDocumentOpen = function (href) {\n this.usageAnalytics.logClickEvent(AnalyticsActionListMeta_1.analyticsActionCauseList.documentOpen, {\n documentURL: href,\n documentTitle: this.result.title,\n author: Utils_1.Utils.getFieldValue(this.result, 'author')\n }, this.result, this.root);\n };\n ResultLink.prototype.filterProtocol = function (uri) {\n var isAbsolute = /^(https?|ftp|file|mailto|tel|sip):/i.test(uri);\n var isRelative = /^(\\/|\\.\\/|\\.\\.\\/)/.test(uri);\n return isAbsolute || isRelative ? uri : '';\n };\n ResultLink.prototype.getResultUri = function () {\n if (this.options.hrefTemplate) {\n var uri = StringUtils_1.StringUtils.buildStringTemplateFromResult(this.options.hrefTemplate, this.result);\n return this.filterProtocol(uri);\n }\n if (this.options.field == undefined && this.options.openInOutlook) {\n this.setField();\n }\n if (this.options.field != undefined) {\n return this.filterProtocol(Utils_1.Utils.getFieldValue(this.result, this.options.field));\n }\n return this.filterProtocol(this.result.clickUri);\n };\n ResultLink.prototype.elementIsAnAnchor = function () {\n return this.element.tagName == 'A';\n };\n ResultLink.prototype.setField = function () {\n var os = Utils_1.Utils.exists(this.os) ? this.os : OSUtils_1.OSUtils.get();\n if (os == OSUtils_1.OS_NAME.MACOSX && this.hasOutlookField()) {\n this.options.field = '@outlookformacuri';\n }\n else if (os == OSUtils_1.OS_NAME.WINDOWS && this.hasOutlookField()) {\n this.options.field = '@outlookuri';\n }\n };\n ResultLink.prototype.hasOutlookField = function () {\n var os = Utils_1.Utils.exists(this.os) ? this.os : OSUtils_1.OSUtils.get();\n if (os == OSUtils_1.OS_NAME.MACOSX && this.result.raw['outlookformacuri'] != undefined) {\n return true;\n }\n else if (os == OSUtils_1.OS_NAME.WINDOWS && this.result.raw['outlookuri'] != undefined) {\n return true;\n }\n return false;\n };\n ResultLink.prototype.isUriThatMustBeOpenedInQuickview = function () {\n return this.escapedClickUri.toLowerCase().indexOf('ldap://') == 0;\n };\n ResultLink.prototype.quickviewShouldBeOpened = function () {\n return (this.options.openQuickview || this.isUriThatMustBeOpenedInQuickview()) && QueryUtils_1.QueryUtils.hasHTMLVersion(this.result);\n };\n ResultLink.ID = 'ResultLink';\n ResultLink.doExport = function () {\n GlobalExports_1.exportGlobally({\n ResultLink: ResultLink\n });\n };\n /**\n * The options for the ResultLink\n * @componentOptions\n */\n ResultLink.options = {\n /**\n * Specifies the field to use to output the component `href` attribute value.\n *\n * **Tip:**\n * > Instead of specifying a value for the `field` option, you can directly add an `href` attribute to the\n * > `ResultLink` HTML element. Then, you can use a custom script to generate the `href` value.\n *\n * **Examples:**\n * - With the following markup, the `ResultLink` outputs its `href` value using the `@uri` field (rather than the\n * default field):\n *\n * ```html\n * \n * ```\n *\n * - In the following result template, the custom `getMyKBUri()` function provides the `href` value:\n *\n * ```html\n * \n * ```\n *\n * See also [`hrefTemplate`]{@link ResultLink.options.hrefTemplate}, which can override this option.\n *\n * By default, the component uses the `@clickUri` field of the item to output the value of its `href` attribute.\n */\n field: ComponentOptions_1.ComponentOptions.buildFieldOption(),\n /**\n * Specifies whether the component should try to open its link in Microsoft Outlook.\n *\n * Setting this option to `true` is normally useful for `ResultLink` instances related to Microsoft Exchange emails.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInOutlook`]{@link ResultLink.openLinkInOutlook} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * Default value is `false`.\n */\n openInOutlook: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies whether the component should open its link in the [`Quickview`]{@link Quickview} component rather than\n * loading through the original URL.\n *\n * Default value is `false`.\n */\n openQuickview: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies whether the component should open its link in a new window instead of opening it in the current\n * context.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInNewWindow`]{@link ResultLink.openLinkInNewWindow} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * **Note:**\n * > If a search page contains a [`ResultPreferences`]{@link ResultsPreferences} component whose\n * > [`enableOpenInNewWindow`]{@link ResultsPreferences.options.enableOpenInNewWindow} option is `true`, and the end\n * > user checks the Always open results in new window box, `ResultLink` components in this page will always\n * > open their links in a new window when the end user clicks them, no matter what the value of their\n * > `alwaysOpenInNewWindow` option is.\n *\n * Default value is `false`.\n */\n alwaysOpenInNewWindow: ComponentOptions_1.ComponentOptions.buildBooleanOption({ defaultValue: false }),\n /**\n * Specifies a template literal from which to generate the `ResultLink` `href` attribute value (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the [`field`]{@link ResultLink.options.field} option value.\n *\n * The template literal can reference any number of fields from the parent result. It can also reference global\n * scope properties.\n *\n * **Examples:**\n *\n * - The following markup generates an `href` value such as `http://uri.com?id=itemTitle`:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates an `href` value such as `localhost/fooBar`:\n *\n * ```html\n * \n * ```\n *\n * Default value is `undefined`.\n */\n hrefTemplate: ComponentOptions_1.ComponentOptions.buildStringOption(),\n /**\n * Specifies a template literal from which to generate the `ResultLink` display title (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the default `ResultLink` display title behavior.\n *\n * The template literal can reference any number of fields from the parent result. However, if the template literal\n * references a key whose value is undefined in the parent result fields, the `ResultLink` title displays the\n * name of this key instead.\n *\n * This option is ignored if the `ResultLink` innerHTML contains any value.\n *\n * **Examples:**\n *\n * - The following markup generates a `ResultLink` display title such as `Case number: 123456` if both the\n * `raw.objecttype` and `raw.objectnumber` keys are defined in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `${myField}` as a `ResultLink` display title if the `myField` key is undefined\n * in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `Foobar` as a `ResultLink` display title, because the `ResultLink` innterHTML is\n * not empty:\n *\n * ```html\n * Foobar\n * ```\n *\n * Default value is `undefined`.\n *\n * @availablesince [January 2017 Release (v1.1865.9)](https://docs.coveo.com/en/396/#january-2017-release-v118659)\n */\n titleTemplate: ComponentOptions_1.ComponentOptions.buildStringOption(),\n /**\n * Specifies an event handler function to execute when the user clicks the `ResultLink` component.\n *\n * The handler function takes a JavaScript [`Event`](https://developer.mozilla.org/en/docs/Web/API/Event) object and\n * an [`IQueryResult`]{@link IQueryResult} as its parameters.\n *\n * Overriding the default behavior of the `onClick` event can allow you to execute specific code instead.\n *\n * **Note:**\n * > You cannot set this option directly in the component markup as an HTML attribute. You must either set it in the\n * > [`init`]{@link init} call of your search interface (see\n * > [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)),\n * > or before the `init` call, using the `options` top-level function (see\n * > [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n * ```javascript\n * // You can set the option in the 'init' call:\n * Coveo.init(document.querySelector(\"#search\"), {\n * ResultLink : {\n * onClick : function(e, result) {\n * e.preventDefault();\n * // Custom code to execute with the item URI and title.\n * openUriInASpecialTab(result.clickUri, result.title);\n * }\n * }\n * });\n *\n * // Or before the 'init' call, using the 'options' top-level function:\n * // Coveo.options(document.querySelector('#search'), {\n * // ResultLink : {\n * // onClick : function(e, result) {\n * // e.preventDefault();\n * // // Custom code to execute with the item URI and title.\n * // openUriInASpecialTab(result.clickUri, result.title);\n * // }\n * // }\n * // });\n * ```\n */\n onClick: ComponentOptions_1.ComponentOptions.buildCustomOption(function () {\n return null;\n }),\n /**\n * Specify this option to log additional analytics when this result link is pressed.\n *\n * **Example:**\n * ```javascript\n * const resultLink = new Coveo.ResultLink(\n * linkElement,\n * {\n * logAnalytics: (href) => Coveo.logCustomEvent(\n * Coveo.analyticsActionCauseList.openSmartSnippetSource,\n * {\n * searchQueryUid: searchInterface.queryController.lastSearchUid,\n * documentTitle: result.title,\n * author: Utils.getFieldValue(result, 'author'),\n * documentURL: href\n * },\n * element\n * )\n * },\n * searchInterface.getBindings(),\n * result\n * )\n * ```\n */\n logAnalytics: ComponentOptions_1.ComponentOptions.buildCustomOption(function () { return null; })\n };\n return ResultLink;\n}(Component_1.Component));\nexports.ResultLink = ResultLink;\nInitialization_1.Initialization.registerAutoCreateComponent(ResultLink);\n\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// ResultLink.min__ff92a1d47dbcec2611e1.js","import { once } from 'underscore';\nimport { $$ } from '../../utils/Dom';\n\nexport function bindAnalyticsToLink(element: HTMLElement, logAnalytics: () => void) {\n const executeOnlyOnce = once(() => logAnalytics());\n\n $$(element).on(['contextmenu', 'click', 'mousedown', 'mouseup'], executeOnlyOnce);\n let longPressTimer: number;\n $$(element).on('touchstart', () => {\n longPressTimer = window.setTimeout(executeOnlyOnce, 1000);\n });\n $$(element).on('touchend', () => {\n if (longPressTimer) {\n clearTimeout(longPressTimer);\n }\n });\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResultLink/ResultLinkCommon.ts","import { Component } from '../Base/Component';\nimport { ComponentOptions } from '../Base/ComponentOptions';\nimport { ComponentOptionsModel } from '../../models/ComponentOptionsModel';\nimport { IResultsComponentBindings } from '../Base/ResultsComponentBindings';\nimport { analyticsActionCauseList } from '../Analytics/AnalyticsActionListMeta';\nimport { IResultLinkOptions } from './ResultLinkOptions';\nimport { ResultListEvents } from '../../events/ResultListEvents';\nimport { HighlightUtils } from '../../utils/HighlightUtils';\nimport { IQueryResult } from '../../rest/QueryResult';\nimport { DeviceUtils } from '../../utils/DeviceUtils';\nimport { OS_NAME, OSUtils } from '../../utils/OSUtils';\nimport { Initialization } from '../Base/Initialization';\nimport { QueryUtils } from '../../utils/QueryUtils';\nimport { Assert } from '../../misc/Assert';\nimport { Utils } from '../../utils/Utils';\nimport { Defer } from '../../misc/Defer';\nimport { $$ } from '../../utils/Dom';\nimport { StreamHighlightUtils } from '../../utils/StreamHighlightUtils';\nimport { StringUtils } from '../../utils/StringUtils';\nimport { debounce, extend, escape } from 'underscore';\nimport { exportGlobally } from '../../GlobalExports';\n\nimport 'styling/_ResultLink';\nimport { AccessibleButton } from '../../utils/AccessibleButton';\nimport { bindAnalyticsToLink } from './ResultLinkCommon';\n\n/**\n * The `ResultLink` component automatically transform a search result title into a clickable link pointing to the\n * original item.\n *\n * This component is a result template component (see [Result Templates](https://docs.coveo.com/en/413/)).\n */\nexport class ResultLink extends Component {\n static ID = 'ResultLink';\n\n static doExport = () => {\n exportGlobally({\n ResultLink: ResultLink\n });\n };\n\n /**\n * The options for the ResultLink\n * @componentOptions\n */\n static options: IResultLinkOptions = {\n /**\n * Specifies the field to use to output the component `href` attribute value.\n *\n * **Tip:**\n * > Instead of specifying a value for the `field` option, you can directly add an `href` attribute to the\n * > `ResultLink` HTML element. Then, you can use a custom script to generate the `href` value.\n *\n * **Examples:**\n * - With the following markup, the `ResultLink` outputs its `href` value using the `@uri` field (rather than the\n * default field):\n *\n * ```html\n * \n * ```\n *\n * - In the following result template, the custom `getMyKBUri()` function provides the `href` value:\n *\n * ```html\n * \n * ```\n *\n * See also [`hrefTemplate`]{@link ResultLink.options.hrefTemplate}, which can override this option.\n *\n * By default, the component uses the `@clickUri` field of the item to output the value of its `href` attribute.\n */\n field: ComponentOptions.buildFieldOption(),\n\n /**\n * Specifies whether the component should try to open its link in Microsoft Outlook.\n *\n * Setting this option to `true` is normally useful for `ResultLink` instances related to Microsoft Exchange emails.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInOutlook`]{@link ResultLink.openLinkInOutlook} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * Default value is `false`.\n */\n openInOutlook: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies whether the component should open its link in the [`Quickview`]{@link Quickview} component rather than\n * loading through the original URL.\n *\n * Default value is `false`.\n */\n openQuickview: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies whether the component should open its link in a new window instead of opening it in the current\n * context.\n *\n * If this option is `true`, clicking the `ResultLink` calls the\n * [`openLinkInNewWindow`]{@link ResultLink.openLinkInNewWindow} method instead of the\n * [`openLink`]{@link ResultLink.openLink} method.\n *\n * **Note:**\n * > If a search page contains a [`ResultPreferences`]{@link ResultsPreferences} component whose\n * > [`enableOpenInNewWindow`]{@link ResultsPreferences.options.enableOpenInNewWindow} option is `true`, and the end\n * > user checks the Always open results in new window box, `ResultLink` components in this page will always\n * > open their links in a new window when the end user clicks them, no matter what the value of their\n * > `alwaysOpenInNewWindow` option is.\n *\n * Default value is `false`.\n */\n alwaysOpenInNewWindow: ComponentOptions.buildBooleanOption({ defaultValue: false }),\n\n /**\n * Specifies a template literal from which to generate the `ResultLink` `href` attribute value (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the [`field`]{@link ResultLink.options.field} option value.\n *\n * The template literal can reference any number of fields from the parent result. It can also reference global\n * scope properties.\n *\n * **Examples:**\n *\n * - The following markup generates an `href` value such as `http://uri.com?id=itemTitle`:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates an `href` value such as `localhost/fooBar`:\n *\n * ```html\n * \n * ```\n *\n * Default value is `undefined`.\n */\n hrefTemplate: ComponentOptions.buildStringOption(),\n\n /**\n * Specifies a template literal from which to generate the `ResultLink` display title (see\n * [Template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals)).\n *\n * This option overrides the default `ResultLink` display title behavior.\n *\n * The template literal can reference any number of fields from the parent result. However, if the template literal\n * references a key whose value is undefined in the parent result fields, the `ResultLink` title displays the\n * name of this key instead.\n *\n * This option is ignored if the `ResultLink` innerHTML contains any value.\n *\n * **Examples:**\n *\n * - The following markup generates a `ResultLink` display title such as `Case number: 123456` if both the\n * `raw.objecttype` and `raw.objectnumber` keys are defined in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `${myField}` as a `ResultLink` display title if the `myField` key is undefined\n * in the parent result fields:\n *\n * ```html\n * \n * ```\n *\n * - The following markup generates `Foobar` as a `ResultLink` display title, because the `ResultLink` innterHTML is\n * not empty:\n *\n * ```html\n * Foobar\n * ```\n *\n * Default value is `undefined`.\n *\n * @availablesince [January 2017 Release (v1.1865.9)](https://docs.coveo.com/en/396/#january-2017-release-v118659)\n */\n titleTemplate: ComponentOptions.buildStringOption(),\n\n /**\n * Specifies an event handler function to execute when the user clicks the `ResultLink` component.\n *\n * The handler function takes a JavaScript [`Event`](https://developer.mozilla.org/en/docs/Web/API/Event) object and\n * an [`IQueryResult`]{@link IQueryResult} as its parameters.\n *\n * Overriding the default behavior of the `onClick` event can allow you to execute specific code instead.\n *\n * **Note:**\n * > You cannot set this option directly in the component markup as an HTML attribute. You must either set it in the\n * > [`init`]{@link init} call of your search interface (see\n * > [Passing Component Options in the init Call](https://docs.coveo.com/en/346/#passing-component-options-in-the-init-call)),\n * > or before the `init` call, using the `options` top-level function (see\n * > [Passing Component Options Before the init Call](https://docs.coveo.com/en/346/#passing-component-options-before-the-init-call)).\n *\n * **Example:**\n * ```javascript\n * // You can set the option in the 'init' call:\n * Coveo.init(document.querySelector(\"#search\"), {\n * ResultLink : {\n * onClick : function(e, result) {\n * e.preventDefault();\n * // Custom code to execute with the item URI and title.\n * openUriInASpecialTab(result.clickUri, result.title);\n * }\n * }\n * });\n *\n * // Or before the 'init' call, using the 'options' top-level function:\n * // Coveo.options(document.querySelector('#search'), {\n * // ResultLink : {\n * // onClick : function(e, result) {\n * // e.preventDefault();\n * // // Custom code to execute with the item URI and title.\n * // openUriInASpecialTab(result.clickUri, result.title);\n * // }\n * // }\n * // });\n * ```\n */\n onClick: ComponentOptions.buildCustomOption<(e: Event, result: IQueryResult) => any>(() => {\n return null;\n }),\n\n /**\n * Specify this option to log additional analytics when this result link is pressed.\n *\n * **Example:**\n * ```javascript\n * const resultLink = new Coveo.ResultLink(\n * linkElement,\n * {\n * logAnalytics: (href) => Coveo.logCustomEvent(\n * Coveo.analyticsActionCauseList.openSmartSnippetSource,\n * {\n * searchQueryUid: searchInterface.queryController.lastSearchUid,\n * documentTitle: result.title,\n * author: Utils.getFieldValue(result, 'author'),\n * documentURL: href\n * },\n * element\n * )\n * },\n * searchInterface.getBindings(),\n * result\n * )\n * ```\n */\n logAnalytics: ComponentOptions.buildCustomOption<(href: string) => void>(() => null)\n };\n\n private toExecuteOnOpen: (e?: Event) => void;\n\n /**\n * Creates a new `ResultLink` component.\n * @param element The HTMLElement on which to instantiate the component.\n * @param options The options for the `ResultLink` component.\n * @param bindings The bindings that the component requires to function normally. If not set, these will be\n * automatically resolved (with a slower execution time).\n * @param result The result to associate the component with.\n * @param os\n */\n constructor(\n public element: HTMLElement,\n public options: IResultLinkOptions,\n public bindings?: IResultsComponentBindings,\n public result?: IQueryResult,\n public os?: OS_NAME\n ) {\n super(element, ResultLink.ID, bindings);\n\n const globalOptions = this.searchInterface.options.originalOptionsObject[ResultLink.ID] || {};\n const initialOptions = ComponentOptions.initComponentOptions(element, ResultLink, { ...globalOptions, ...options });\n const resultLinkOptions = this.componentOptionsModel.get(ComponentOptionsModel.attributesEnum.resultLink);\n this.options = extend({}, initialOptions, resultLinkOptions);\n\n this.result = result || this.resolveResult();\n\n if (this.options.openQuickview == null) {\n this.options.openQuickview = result.raw['connectortype'] == 'ExchangeCrawler' && DeviceUtils.isMobileDevice();\n }\n if (!this.element.hasAttribute('tabindex')) {\n this.element.setAttribute('tabindex', '0');\n }\n\n Assert.exists(this.componentOptionsModel);\n Assert.exists(this.result);\n\n if (!this.quickviewShouldBeOpened()) {\n // Bind on multiple \"click\" or \"mouse\" events.\n // Create a function that will be executed only once, so as not to log multiple events\n // Once a result link has been opened, and that we log at least one analytics event,\n // it should not matter if the end user open the same link multiple times with different methods.\n // It's still only one \"click\" event as far as UA is concerned.\n // Also need to handle \"longpress\" on mobile (the contextual menu), which we assume to be 1 s long.\n\n bindAnalyticsToLink(element, () => this.logAnalytics());\n }\n this.renderUri(element, result);\n this.bindEventToOpen();\n }\n public renderUri(element: HTMLElement, result?: IQueryResult) {\n if (/^\\s*$/.test(this.element.innerHTML)) {\n const title = this.getDisplayedTitle();\n this.element.innerHTML = title;\n\n const titleAsText = this.getDisplayedTitleAsText();\n if (!this.element.hasAttribute('aria-label')) {\n this.element.setAttribute('aria-label', titleAsText);\n }\n\n if (!this.element.title) {\n this.element.title = titleAsText;\n }\n }\n }\n /**\n * Opens the result in the same window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLink(logAnalytics = true) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.location.href = this.getResultUri();\n }\n\n /**\n * Opens the result in a new window, no matter how the actual component is configured for the end user.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkInNewWindow(logAnalytics = true) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n window.open(this.getResultUri(), '_blank');\n }\n\n /**\n * Tries to open the result in Microsoft Outlook if the result has an `outlookformacuri` or `outlookuri` field.\n *\n * Normally, this implies the result should be a link to an email.\n *\n * If the needed fields are not present, this method does nothing.\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkInOutlook(logAnalytics = true) {\n if (this.hasOutlookField()) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.openLink();\n }\n }\n\n /**\n * Opens the link in the same manner the end user would.\n *\n * This essentially simulates a click on the result link.\n *\n * @param logAnalytics Specifies whether the method should log an analytics event.\n */\n public openLinkAsConfigured(logAnalytics = true) {\n if (this.toExecuteOnOpen) {\n if (logAnalytics) {\n this.logAnalytics();\n }\n this.toExecuteOnOpen();\n }\n }\n\n protected bindEventToOpen(): boolean {\n return (\n this.bindOnClickIfNotUndefined() ||\n this.bindOpenQuickviewIfNotUndefined() ||\n this.setHrefIfNotAlready() ||\n this.openLinkThatIsNotAnAnchor()\n );\n }\n\n private getDisplayedTitle() {\n if (!this.options.titleTemplate) {\n return this.result.title\n ? HighlightUtils.highlightString(this.result.title, this.result.titleHighlights, null, 'coveo-highlight')\n : this.escapedClickUri;\n } else {\n let newTitle = StringUtils.buildStringTemplateFromResult(this.options.titleTemplate, this.result);\n return newTitle\n ? StreamHighlightUtils.highlightStreamText(newTitle, this.result.termsToHighlight, this.result.phrasesToHighlight)\n : this.escapedClickUri;\n }\n }\n\n private getDisplayedTitleAsText() {\n const container = $$('div');\n container.setHtml(this.getDisplayedTitle());\n return container.text();\n }\n\n private get escapedClickUri() {\n return escape(this.result.clickUri);\n }\n\n private bindOnClickIfNotUndefined() {\n if (this.options.onClick != undefined) {\n this.toExecuteOnOpen = (e: MouseEvent) => {\n this.options.onClick.call(this, e, this.result);\n };\n\n new AccessibleButton()\n .withElement(this.element)\n .withLabel(this.result.title)\n .withSelectAction((e: Event) => this.toExecuteOnOpen(e))\n .build();\n\n return true;\n } else {\n return false;\n }\n }\n\n private bindOpenQuickviewIfNotUndefined() {\n if (this.quickviewShouldBeOpened()) {\n this.toExecuteOnOpen = () => {\n $$(this.bindings.resultElement).trigger(ResultListEvents.openQuickview);\n };\n\n $$(this.element).on('click', (e: Event) => {\n e.preventDefault();\n this.toExecuteOnOpen();\n });\n\n return true;\n } else {\n return false;\n }\n }\n\n private openLinkThatIsNotAnAnchor() {\n if (!this.elementIsAnAnchor()) {\n this.toExecuteOnOpen = () => {\n if (this.options.alwaysOpenInNewWindow) {\n if (this.options.openInOutlook) {\n this.openLinkInOutlook();\n } else {\n this.openLinkInNewWindow();\n }\n } else {\n this.openLink();\n }\n };\n\n $$(this.element).on('click', () => {\n this.toExecuteOnOpen();\n });\n\n return true;\n }\n return false;\n }\n\n private setHrefIfNotAlready() {\n // Do not erase any value put in href by the template, etc. Allows\n // using custom click urls while still keeping analytics recording\n // and other behavior brought by the component.\n if (this.elementIsAnAnchor() && !Utils.isNonEmptyString($$(this.element).getAttribute('href'))) {\n $$(this.element).setAttribute('href', this.getResultUri());\n if (this.options.alwaysOpenInNewWindow && !(this.options.openInOutlook && this.hasOutlookField())) {\n $$(this.element).setAttribute('target', '_blank');\n }\n return true;\n } else {\n return false;\n }\n }\n\n private logDocumentOpen(href: string) {\n this.usageAnalytics.logClickEvent(\n analyticsActionCauseList.documentOpen,\n {\n documentURL: href,\n documentTitle: this.result.title,\n author: Utils.getFieldValue(this.result, 'author')\n },\n this.result,\n this.root\n );\n }\n\n private logAnalytics = debounce(\n () => {\n this.queryController.saveLastQuery();\n let documentURL = $$(this.element).getAttribute('href');\n if (documentURL == undefined || documentURL == '') {\n documentURL = this.escapedClickUri;\n }\n if (this.options.logAnalytics) {\n this.options.logAnalytics(documentURL);\n } else {\n this.logDocumentOpen(documentURL);\n }\n Defer.flush();\n },\n 1500,\n true\n );\n\n private filterProtocol(uri: string) {\n const isAbsolute = /^(https?|ftp|file|mailto|tel|sip):/i.test(uri);\n const isRelative = /^(\\/|\\.\\/|\\.\\.\\/)/.test(uri);\n\n return isAbsolute || isRelative ? uri : '';\n }\n\n private getResultUri(): string {\n if (this.options.hrefTemplate) {\n const uri = StringUtils.buildStringTemplateFromResult(this.options.hrefTemplate, this.result);\n return this.filterProtocol(uri);\n }\n\n if (this.options.field == undefined && this.options.openInOutlook) {\n this.setField();\n }\n\n if (this.options.field != undefined) {\n return this.filterProtocol(Utils.getFieldValue(this.result, this.options.field));\n }\n\n return this.filterProtocol(this.result.clickUri);\n }\n\n private elementIsAnAnchor() {\n return this.element.tagName == 'A';\n }\n\n private setField() {\n let os = Utils.exists(this.os) ? this.os : OSUtils.get();\n if (os == OS_NAME.MACOSX && this.hasOutlookField()) {\n this.options.field = '@outlookformacuri';\n } else if (os == OS_NAME.WINDOWS && this.hasOutlookField()) {\n this.options.field = '@outlookuri';\n }\n }\n\n private hasOutlookField() {\n let os = Utils.exists(this.os) ? this.os : OSUtils.get();\n if (os == OS_NAME.MACOSX && this.result.raw['outlookformacuri'] != undefined) {\n return true;\n } else if (os == OS_NAME.WINDOWS && this.result.raw['outlookuri'] != undefined) {\n return true;\n }\n return false;\n }\n\n private isUriThatMustBeOpenedInQuickview(): boolean {\n return this.escapedClickUri.toLowerCase().indexOf('ldap://') == 0;\n }\n\n private quickviewShouldBeOpened() {\n return (this.options.openQuickview || this.isUriThatMustBeOpenedInQuickview()) && QueryUtils.hasHTMLVersion(this.result);\n }\n}\n\nInitialization.registerAutoCreateComponent(ResultLink);\n\n\n\n// WEBPACK FOOTER //\n// ./src/ui/ResultLink/ResultLink.ts"],"sourceRoot":""}