PageSourceSearch

https://balticmaster.ru/bitrix/js/ui/entity-selector/dist/entity-selector.bundle.js?1674489273293459

js balticmaster.ru collected 2026-10-06 17:27:08 UTC 293,459 bytes, 9,356 lines download raw bytes

1this.BX = this.BX || {};
2this.BX.UI = this.BX.UI || {};
3(function (exports,main_popup,main_core_collections,main_core_events,main_core,main_loader) {
4	'use strict';
5
6	var ItemNodeComparator = /*#__PURE__*/function () {
7	  function ItemNodeComparator() {
8	    babelHelpers.classCallCheck(this, ItemNodeComparator);
9	  }
10
11	  babelHelpers.createClass(ItemNodeComparator, null, [{
12	    key: "makeMultipleComparator",
13	    value: function makeMultipleComparator(order) {
14	      var _this = this;
15
16	      var props = Object.keys(order).map(function (property) {
17	        return "get".concat(main_core.Text.capitalize(property));
18	      });
19	      /*
20	      asc *
21	      asc nulls last *
22	      asc nulls first
23	      	desc *
24	      desc nulls first *
25	      desc nulls last
26	      */
27
28	      var directions = [];
29	      Object.values(order).forEach(function (element) {
30	        var direction = element.toLowerCase().trim(); // Default sorting: 'asc' || 'asc nulls last'
31
32	        var ascOrdering = true;
33	        var nullsOrdering = true;
34
35	        if (direction === 'desc' || direction === 'desc nulls first') {
36	          ascOrdering = false;
37	        } else if (direction === 'asc nulls first') {
38	          nullsOrdering = false;
39	        } else if (direction === 'desc nulls last') {
40	          ascOrdering = false;
41	          nullsOrdering = false;
42	        }
43
44	        directions.push({
45	          ascOrdering: ascOrdering,
46	          nullsOrdering: nullsOrdering
47	        });
48	      });
49	      var numberOfProperties = props.length;
50	      return function (nodeA, nodeB) {
51	        var i = 0;
52	        var result = 0;
53
54	        while (result === 0 && i < numberOfProperties) {
55	          var propertyGetter = props[i];
56	          var direction = directions[i];
57	          result = _this.compareItemNodes(nodeA, nodeB, propertyGetter, direction.ascOrdering, direction.nullsOrdering);
58	          i += 1;
59	        }
60
61	        return result;
62	      };
63	    }
64	  }, {
65	    key: "compareItemNodes",
66	    value: function compareItemNodes(nodeA, nodeB, propertyGetter, ascOrdering, nullsOrdering) {
67	      var itemA = nodeA.getItem();
68	      var itemB = nodeB.getItem();
69	      itemA.getCustomData().get();
70	      var valueA = itemA[propertyGetter]();
71	      var valueB = itemB[propertyGetter]();
72	      var result = 0;
73
74	      if (valueA !== null && valueB === null) {
75	        result = nullsOrdering ? -1 : 1;
76	      } else if (valueA === null && valueB !== null) {
77	        result = nullsOrdering ? 1 : -1;
78	      } else if (valueA === null && valueB === null) {
79	        result = ascOrdering ? -1 : 1;
80	      } else {
81	        if (main_core.Type.isString(valueA)) {
82	          result = valueA.localeCompare(valueB);
83	        } else {
84	          result = valueA - valueB;
85	        }
86	      }
87
88	      var sortOrder = ascOrdering ? 1 : -1;
89	      return result * sortOrder;
90	    }
91	  }]);
92	  return ItemNodeComparator;
93	}();
94
95	var TextNodeType = /*#__PURE__*/function () {
96	  function TextNodeType() {
97	    babelHelpers.classCallCheck(this, TextNodeType);
98	  }
99
100	  babelHelpers.createClass(TextNodeType, null, [{
101	    key: "isValid",
102	    value: function isValid(type) {
103	      return main_core.Type.isString(type) && (type === this.HTML || type === this.TEXT);
104	    }
105	  }]);
106	  return TextNodeType;
107	}();
108
109	babelHelpers.defineProperty(TextNodeType, "TEXT", 'text');
110	babelHelpers.defineProperty(TextNodeType, "HTML", 'html');
111
112	var TextNode = /*#__PURE__*/function () {
113	  function TextNode(options) {
114	    babelHelpers.classCallCheck(this, TextNode);
115	    babelHelpers.defineProperty(this, "text", null);
116	    babelHelpers.defineProperty(this, "type", null);
117
118	    if (main_core.Type.isPlainObject(options)) {
119	      if (main_core.Type.isString(options.text)) {
120	        this.text = options.text;
121	      }
122
123	      if (TextNodeType.isValid(options.type)) {
124	        this.type = options.type;
125	      }
126	    } else if (main_core.Type.isString(options)) {
127	      this.text = options;
128	    }
129	  }
130
131	  babelHelpers.createClass(TextNode, [{
132	    key: "getText",
133	    value: function getText() {
134	      return this.text;
135	    }
136	  }, {
137	    key: "getType",
138	    value: function getType() {
139	      return this.type;
140	    }
141	  }, {
142	    key: "isNullable",
143	    value: function isNullable() {
144	      return this.getText() === null;
145	    }
146	  }, {
147	    key: "renderTo",
148	    value: function renderTo(element) {
149	      var text = this.getText();
150
151	      if (text === null) {
152	        return;
153	      }
154
155	      if (this.getType() === null || this.getType() === TextNodeType.TEXT) {
156	        element.textContent = text;
157	      } else if (this.getType() === TextNodeType.HTML) {
158	        element.innerHTML = text;
159	      }
160	    }
161	  }, {
162	    key: "toString",
163	    value: function toString() {
164	      var _this$getText;
165
166	      return (_this$getText = this.getText()) !== null && _this$getText !== void 0 ? _this$getText : '';
167	    }
168	  }, {
169	    key: "toJSON",
170	    value: function toJSON() {
171	      if (this.getType() === null) {
172	        return this.getText();
173	      } else {
174	        return {
175	          text: this.getText(),
176	          type: this.getType()
177	        };
178	      }
179	    }
180	  }]);
181	  return TextNode;
182	}();
183
184	var Highlighter = /*#__PURE__*/function () {
185	  function Highlighter() {
186	    babelHelpers.classCallCheck(this, Highlighter);
187	  }
188
189	  babelHelpers.createClass(Highlighter, null, [{
190	    key: "mark",
191	    value: function mark(text, matches) {
192	      var encode = true;
193
194	      if (text instanceof TextNode) {
195	        if (text.getType() === 'html') {
196	          encode = false;
197	        }
198
199	        text = text.getText();
200	      }
201
202	      if (!main_core.Type.isStringFilled(text) || !matches || matches.count() === 0) {
203	        return text;
204	      }
205
206	      var result = '';
207	      var offset = 0;
208	      var chunk = '';
209	      matches.forEach(function (match) {
210	        if (offset > match.getStartIndex()) {
211	          return;
212	        }
213
214	        chunk = text.substring(offset, match.getStartIndex());
215	        result += encode ? main_core.Text.encode(chunk) : chunk;
216	        result += '<span class="ui-selector-highlight-mark">';
217	        chunk = text.substring(match.getStartIndex(), match.getEndIndex());
218	        result += encode ? main_core.Text.encode(chunk) : chunk;
219	        result += '</span>';
220	        offset = match.getEndIndex();
221	      });
222	      chunk = text.substring(offset);
223	      result += encode ? main_core.Text.encode(chunk) : chunk;
224	      return result;
225	    }
226	  }]);
227	  return Highlighter;
228	}();
229
230	var ItemBadge = /*#__PURE__*/function () {
231	  function ItemBadge(badgeOptions) {
232	    babelHelpers.classCallCheck(this, ItemBadge);
233	    babelHelpers.defineProperty(this, "title", null);
234	    babelHelpers.defineProperty(this, "textColor", null);
235	    babelHelpers.defineProperty(this, "bgColor", null);
236	    babelHelpers.defineProperty(this, "containers", new WeakMap());
237	    var options = main_core.Type.isPlainObject(badgeOptions) ? badgeOptions : {};
238	    this.setTitle(options.title);
239	    this.setTextColor(options.textColor);
240	    this.setBgColor(options.bgColor);
241	  }
242
243	  babelHelpers.createClass(ItemBadge, [{
244	    key: "getTitle",
245	    value: function getTitle() {
246	      var titleNode = this.getTitleNode();
247	      return titleNode !== null && !titleNode.isNullable() ? titleNode.getText() : '';
248	    }
249	  }, {
250	    key: "getTitleNode",
251	    value: function getTitleNode() {
252	      return this.title;
253	    }
254	  }, {
255	    key: "setTitle",
256	    value: function setTitle(title) {
257	      if (main_core.Type.isStringFilled(title) || main_core.Type.isPlainObject(title) || title === null) {
258	        this.title = title === null ? null : new TextNode(title);
259	      }
260	    }
261	  }, {
262	    key: "getTextColor",
263	    value: function getTextColor() {
264	      return this.textColor;
265	    }
266	  }, {
267	    key: "setTextColor",
268	    value: function setTextColor(textColor) {
269	      if (main_core.Type.isString(textColor) || textColor === null) {
270	        this.textColor = textColor;
271	      }
272	    }
273	  }, {
274	    key: "getBgColor",
275	    value: function getBgColor() {
276	      return this.bgColor;
277	    }
278	  }, {
279	    key: "setBgColor",
280	    value: function setBgColor(bgColor) {
281	      if (main_core.Type.isString(bgColor) || bgColor === null) {
282	        this.bgColor = bgColor;
283	      }
284	    }
285	  }, {
286	    key: "getContainer",
287	    value: function getContainer(target) {
288	      var container = this.containers.get(target);
289
290	      if (!container) {
291	        container = document.createElement('span');
292	        container.className = 'ui-selector-item-badge';
293	        this.containers.set(target, container);
294	      }
295
296	      return container;
297	    }
298	  }, {
299	    key: "renderTo",
300	    value: function renderTo(target) {
301	      var container = this.getContainer(target);
302	      var titleNode = this.getTitleNode();
303
304	      if (titleNode) {
305	        this.getTitleNode().renderTo(container);
306	      } else {
307	        container.textContent = '';
308	      }
309
310	      main_core.Dom.style(container, 'color', this.getTextColor());
311	      main_core.Dom.style(container, 'background-color', this.getBgColor());
312	      main_core.Dom.append(container, target);
313	    }
314	  }, {
315	    key: "toJSON",
316	    value: function toJSON() {
317	      return {
318	        title: this.getTitleNode(),
319	        textColor: this.getTextColor(),
320	        bgColor: this.getBgColor()
321	      };
322	    }
323	  }]);
324	  return ItemBadge;
325	}();
326
327	var SearchField = /*#__PURE__*/function () {
328	  function SearchField(fieldOptions) {
329	    babelHelpers.classCallCheck(this, SearchField);
330	    babelHelpers.defineProperty(this, "name", null);
331	    babelHelpers.defineProperty(this, "type", 'string');
332	    babelHelpers.defineProperty(this, "searchable", true);
333	    babelHelpers.defineProperty(this, "system", false);
334	    babelHelpers.defineProperty(this, "sort", null);
335	    var options = main_core.Type.isPlainObject(fieldOptions) ? fieldOptions : {};
336
337	    if (!main_core.Type.isStringFilled(options.name)) {
338	      throw new Error('EntitySelector.SearchField: "name" parameter is required.');
339	    }
340
341	    this.name = options.name;
342	    this.setType(options.type);
343	    this.setSystem(options.system);
344	    this.setSort(options.sort);
345	    this.setSearchable(options.searchable);
346	  }
347
348	  babelHelpers.createClass(SearchField, [{
349	    key: "getName",
350	    value: function getName() {
351	      return this.name;
352	    }
353	  }, {
354	    key: "getType",
355	    value: function getType() {
356	      return this.type;
357	    }
358	  }, {
359	    key: "setType",
360	    value: function setType(type) {
361	      if (main_core.Type.isStringFilled(type)) {
362	        this.type = type;
363	      }
364	    }
365	  }, {
366	    key: "getSort",
367	    value: function getSort() {
368	      return this.sort;
369	    }
370	  }, {
371	    key: "setSort",
372	    value: function setSort(sort) {
373	      if (main_core.Type.isNumber(sort) || sort === null) {
374	        this.sort = sort;
375	      }
376	    }
377	  }, {
378	    key: "setSearchable",
379	    value: function setSearchable(flag) {
380	      if (main_core.Type.isBoolean(flag)) {
381	        this.searchable = flag;
382	      }
383	    }
384	  }, {
385	    key: "isSearchable",
386	    value: function isSearchable() {
387	      return this.searchable;
388	    }
389	  }, {
390	    key: "setSystem",
391	    value: function setSystem(flag) {
392	      if (main_core.Type.isBoolean(flag)) {
393	        this.system = flag;
394	      }
395	    }
396	  }, {
397	    key: "isCustom",
398	    value: function isCustom() {
399	      return !this.isSystem();
400	    }
401	  }, {
402	    key: "isSystem",
403	    value: function isSystem() {
404	      return this.system;
405	    }
406	  }]);
407	  return SearchField;
408	}();
409
410	var MatchIndex = /*#__PURE__*/function () {
411	  function MatchIndex(field, queryWord, startIndex) {
412	    babelHelpers.classCallCheck(this, MatchIndex);
413	    babelHelpers.defineProperty(this, "field", null);
414	    babelHelpers.defineProperty(this, "queryWord", null);
415	    babelHelpers.defineProperty(this, "startIndex", null);
416	    babelHelpers.defineProperty(this, "endIndex", null);
417	    this.field = field;
418	    this.queryWord = queryWord;
419	    this.startIndex = startIndex;
420	    this.endIndex = startIndex + queryWord.length;
421	  }
422
423	  babelHelpers.createClass(MatchIndex, [{
424	    key: "getField",
425	    value: function getField() {
426	      return this.field;
427	    }
428	  }, {
429	    key: "getQueryWord",
430	    value: function getQueryWord() {
431	      return this.queryWord;
432	    }
433	  }, {
434	    key: "getStartIndex",
435	    value: function getStartIndex() {
436	      return this.startIndex;
437	    }
438	  }, {
439	    key: "getEndIndex",
440	    value: function getEndIndex() {
441	      return this.endIndex;
442	    }
443	  }]);
444	  return MatchIndex;
445	}();
446
447	var comparator = function comparator(a, b) {
448	  if (a.getStartIndex() === b.getStartIndex()) {
449	    return a.getEndIndex() > b.getEndIndex() ? -1 : 1;
450	  } else {
451	    return a.getStartIndex() > b.getStartIndex() ? 1 : -1;
452	  }
453	};
454
455	var MatchField = /*#__PURE__*/function () {
456	  function MatchField(field) {
457	    var indexes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
458	    babelHelpers.classCallCheck(this, MatchField);
459	    babelHelpers.defineProperty(this, "field", null);
460	    babelHelpers.defineProperty(this, "matchIndexes", new main_core_collections.OrderedArray(comparator));
461	    this.field = field;
462	    this.addIndexes(indexes);
463	  }
464
465	  babelHelpers.createClass(MatchField, [{
466	    key: "getField",
467	    value: function getField() {
468	      return this.field;
469	    }
470	  }, {
471	    key: "getMatches",
472	    value: function getMatches() {
473	      return this.matchIndexes;
474	    }
475	  }, {
476	    key: "addIndex",
477	    value: function addIndex(matchIndex) {
478	      this.matchIndexes.add(matchIndex);
479	    }
480	  }, {
481	    key: "addIndexes",
482	    value: function addIndexes(matchIndexes) {
483	      var _this = this;
484
485	      if (main_core.Type.isArray(matchIndexes)) {
486	        matchIndexes.forEach(function (matchIndex) {
487	          _this.addIndex(matchIndex);
488	        });
489	      }
490	    }
491	  }]);
492	  return MatchField;
493	}();
494
495	var Animation = /*#__PURE__*/function () {
496	  function Animation() {
497	    babelHelpers.classCallCheck(this, Animation);
498	  }
499
500	  babelHelpers.createClass(Animation, null, [{
501	    key: "handleTransitionEnd",
502	    value: function handleTransitionEnd(element, propertyName) {
503	      var properties = main_core.Type.isArray(propertyName) ? new Set(propertyName) : new Set([propertyName]);
504	      return new Promise(function (resolve) {
505	        var handler = function handler(event) {
506	          if (event.target !== element || !properties.has(event.propertyName)) {
507	            return;
508	          }
509
510	          properties["delete"](event.propertyName);
511
512	          if (properties.size === 0) {
513	            resolve(event);
514	            main_core.Event.unbind(element, 'transitionend', handler);
515	          }
516	        };
517
518	        main_core.Event.bind(element, 'transitionend', handler);
519	      });
520	    }
521	  }, {
522	    key: "handleAnimationEnd",
523	    value: function handleAnimationEnd(element, animationName) {
524	      return new Promise(function (resolve) {
525	        var handler = function handler(event) {
526	          if (!animationName || event.animationName === animationName) {
527	            resolve(event);
528	            main_core.Event.unbind(element, 'animationend', handler);
529	          }
530	        };
531
532	        main_core.Event.bind(element, 'animationend', handler);
533	      });
534	    }
535	  }]);
536	  return Animation;
537	}();
538
539	var regexp = /^data:((?:\w+\/(?:(?!;).)+)?)((?:;[\w\W]*?[^;])*),(.+)$/;
540
541	var isDataUri = function isDataUri(str) {
542	  return typeof str === 'string' ? str.match(regexp) : false;
543	};
544
545	function encodeUrl(url) {
546	  if (isDataUri(url)) {
547	    return url;
548	  }
549
550	  return encodeURI(url);
551	}
552
553	function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
554
555	function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
556
557	function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
558
559	function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
560
561	function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
562	var RenderMode = function RenderMode() {
563	  babelHelpers.classCallCheck(this, RenderMode);
564	};
565	babelHelpers.defineProperty(RenderMode, "PARTIAL", 'partial');
566	babelHelpers.defineProperty(RenderMode, "OVERRIDE", 'override');
567
568	var _setHidden = /*#__PURE__*/new WeakSet();
569
570	var _makeEllipsisTitle = /*#__PURE__*/new WeakSet();
571
572	var ItemNode = /*#__PURE__*/function () {
573	  // for the fast access
574	  function ItemNode(item, nodeOptions) {
575	    babelHelpers.classCallCheck(this, ItemNode);
576
577	    _classPrivateMethodInitSpec(this, _makeEllipsisTitle);
578
579	    _classPrivateMethodInitSpec(this, _setHidden);
580
581	    babelHelpers.defineProperty(this, "item", null);
582	    babelHelpers.defineProperty(this, "tab", null);
583	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
584	    babelHelpers.defineProperty(this, "parentNode", null);
585	    babelHelpers.defineProperty(this, "children", null);
586	    babelHelpers.defineProperty(this, "childItems", new WeakMap());
587	    babelHelpers.defineProperty(this, "loaded", false);
588	    babelHelpers.defineProperty(this, "dynamic", false);
589	    babelHelpers.defineProperty(this, "dynamicPromise", null);
590	    babelHelpers.defineProperty(this, "loader", null);
591	    babelHelpers.defineProperty(this, "open", false);
592	    babelHelpers.defineProperty(this, "autoOpen", false);
593	    babelHelpers.defineProperty(this, "focused", false);
594	    babelHelpers.defineProperty(this, "renderMode", RenderMode.PARTIAL);
595	    babelHelpers.defineProperty(this, "title", null);
596	    babelHelpers.defineProperty(this, "subtitle", null);
597	    babelHelpers.defineProperty(this, "supertitle", null);
598	    babelHelpers.defineProperty(this, "caption", null);
599	    babelHelpers.defineProperty(this, "captionOptions", {});
600	    babelHelpers.defineProperty(this, "avatar", null);
601	    babelHelpers.defineProperty(this, "avatarOptions", null);
602	    babelHelpers.defineProperty(this, "link", null);
603	    babelHelpers.defineProperty(this, "linkTitle", null);
604	    babelHelpers.defineProperty(this, "textColor", null);
605	    babelHelpers.defineProperty(this, "badges", null);
606	    babelHelpers.defineProperty(this, "badgesOptions", {});
607	    babelHelpers.defineProperty(this, "hidden", false);
608	    babelHelpers.defineProperty(this, "highlights", []);
609	    babelHelpers.defineProperty(this, "renderWithDebounce", main_core.Runtime.debounce(this.render, 50, this));
610	    var options = main_core.Type.isPlainObject(nodeOptions) ? nodeOptions : {};
611
612	    if (main_core.Type.isObject(item)) {
613	      this.item = item;
614	    }
615
616	    var comparator = null;
617
618	    if (main_core.Type.isFunction(options.itemOrder)) {
619	      comparator = options.itemOrder;
620	    } else if (main_core.Type.isPlainObject(options.itemOrder)) {
621	      comparator = ItemNodeComparator.makeMultipleComparator(options.itemOrder);
622	    }
623
624	    this.children = new main_core_collections.OrderedArray(comparator);
625	    this.renderMode = options.renderMode === RenderMode.OVERRIDE ? RenderMode.OVERRIDE : RenderMode.PARTIAL;
626
627	    if (this.renderMode === RenderMode.OVERRIDE) {
628	      this.setTitle('');
629	      this.setSubtitle('');
630	      this.setSupertitle('');
631	      this.setCaption('');
632	      this.setLinkTitle('');
633	      this.avatar = '';
634	      this.avatarOptions = {
635	        bgSize: null,
636	        bgColor: null,
637	        bgImage: null
638	      };
639	      this.textColor = '';
640	      this.link = '';
641	      this.badges = [];
642	      this.captionOptions = {
643	        fitContent: null,
644	        maxWidth: null
645	      };
646	      this.badgesOptions = {
647	        fitContent: null,
648	        maxWidth: null
649	      };
650	    }
651
652	    this.setTitle(options.title);
653	    this.setSubtitle(options.subtitle);
654	    this.setSupertitle(options.supertitle);
655	    this.setCaption(options.caption);
656	    this.setCaptionOptions(options.captionOptions);
657	    this.setAvatar(options.avatar);
658	    this.setAvatarOptions(options.avatarOptions);
659	    this.setTextColor(options.textColor);
660	    this.setLink(options.link);
661	    this.setLinkTitle(options.linkTitle);
662	    this.setBadges(options.badges);
663	    this.setBadgesOptions(options.badgesOptions);
664	    this.setDynamic(options.dynamic);
665	    this.setOpen(options.open);
666	  }
667
668	  babelHelpers.createClass(ItemNode, [{
669	    key: "getItem",
670	    value: function getItem() {
671	      return this.item;
672	    }
673	  }, {
674	    key: "isRoot",
675	    value: function isRoot() {
676	      return this.getParentNode() === null;
677	    }
678	  }, {
679	    key: "getDialog",
680	    value: function getDialog() {
681	      return this.getTab().getDialog();
682	    }
683	  }, {
684	    key: "setTab",
685	    value: function setTab(tab) {
686	      this.tab = tab;
687	    }
688	  }, {
689	    key: "getTab",
690	    value: function getTab() {
691	      return this.tab;
692	    }
693	  }, {
694	    key: "getParentNode",
695	    value: function getParentNode() {
696	      return this.parentNode;
697	    }
698	  }, {
699	    key: "setParentNode",
700	    value: function setParentNode(parentNode) {
701	      this.parentNode = parentNode;
702	    }
703	  }, {
704	    key: "getNextSibling",
705	    value: function getNextSibling() {
706	      if (!this.getParentNode()) {
707	        return null;
708	      }
709
710	      var siblings = this.getParentNode().getChildren();
711	      var index = siblings.getIndex(this);
712	      return siblings.getByIndex(index + 1);
713	    }
714	  }, {
715	    key: "getPreviousSibling",
716	    value: function getPreviousSibling() {
717	      if (!this.getParentNode()) {
718	        return null;
719	      }
720
721	      var siblings = this.getParentNode().getChildren();
722	      var index = siblings.getIndex(this);
723	      return siblings.getByIndex(index - 1);
724	    }
725	  }, {
726	    key: "addChildren",
727	    value: function addChildren(children) {
728	      var _this = this;
729
730	      if (!main_core.Type.isArray(children)) {
731	        return;
732	      }
733
734	      children.forEach(function (childOptions) {
735	        delete childOptions.tabs;
736
737	        var childItem = _this.getDialog().addItem(childOptions);
738
739	        var childNode = _this.addItem(childItem, childOptions.nodeOptions);
740
741	        childNode.addChildren(childOptions.children);
742	      });
743	    }
744	  }, {
745	    key: "addChild",
746	    value: function addChild(child) {
747	      if (!(child instanceof ItemNode)) {
748	        throw new Error('EntitySelector.ItemNode: an item must be an instance of EntitySelector.ItemNode.');
749	      }
750
751	      if (this.isChildOf(child) || child === this) {
752	        throw new Error('EntitySelector.ItemNode: a child item cannot be a parent of current item.');
753	      }
754
755	      if (this.getChildren().has(child) || this.childItems.has(child.getItem())) {
756	        return null;
757	      }
758
759	      this.getChildren().add(child);
760	      this.childItems.set(child.getItem(), child);
761	      child.setTab(this.getTab());
762	      child.setParentNode(this);
763
764	      if (this.isRendered()) {
765	        this.renderWithDebounce();
766	      }
767
768	      return child;
769	    }
770	  }, {
771	    key: "getDepthLevel",
772	    value: function getDepthLevel() {
773	      return this.isRoot() ? 0 : this.getParentNode().getDepthLevel() + 1;
774	    }
775	  }, {
776	    key: "addItem",
777	    value: function addItem(item, nodeOptions) {
778	      var itemNode = this.childItems.get(item);
779
780	      if (!itemNode) {
781	        itemNode = item.createNode(nodeOptions);
782	        this.addChild(itemNode);
783	      }
784
785	      return itemNode;
786	    }
787	  }, {
788	    key: "addItems",
789	    value: function addItems(items) {
790	      var _this2 = this;
791
792	      if (main_core.Type.isArray(items)) {
793	        this.disableRender();
794	        items.forEach(function (item) {
795	          if (main_core.Type.isArray(item) && item.length === 2) {
796	            _this2.addItem(item[0], item[1]);
797	          } else if (item instanceof Item) {
798	            _this2.addItem(item);
799	          }
800	        });
801	        this.enableRender();
802
803	        if (this.isRendered()) {
804	          this.renderWithDebounce();
805	        }
806	      }
807	    }
808	  }, {
809	    key: "hasItem",
810	    value: function hasItem(item) {
811	      return this.childItems.has(item);
812	    }
813	  }, {
814	    key: "removeChild",
815	    value: function removeChild(child) {
816	      if (!this.getChildren().has(child)) {
817	        return false;
818	      }
819
820	      child.removeChildren();
821
822	      if (child.isFocused()) {
823	        child.unfocus();
824	      }
825
826	      child.setParentNode(null);
827	      child.getItem().removeNode(child);
828	      this.getChildren()["delete"](child);
829	      this.childItems["delete"](child.getItem());
830
831	      if (this.isRendered()) {
832	        main_core.Dom.remove(child.getOuterContainer());
833	      }
834
835	      return true;
836	    }
837	  }, {
838	    key: "removeChildren",
839	    value: function removeChildren() {
840	      if (!this.hasChildren()) {
841	        return;
842	      }
843
844	      this.getChildren().forEach(function (node) {
845	        node.removeChildren();
846
847	        if (node.isFocused()) {
848	          node.unfocus();
849	        }
850
851	        node.setParentNode(null);
852	        node.getItem().removeNode(node);
853	      });
854	      this.getChildren().clear();
855	      this.childItems = new WeakMap();
856
857	      if (this.isRendered()) {
858	        if (main_core.Browser.isIE()) {
859	          main_core.Dom.clean(this.getChildrenContainer());
860	        } else {
861	          this.getChildrenContainer().textContent = '';
862	        }
863	      }
864	    }
865	  }, {
866	    key: "hasChild",
867	    value: function hasChild(child) {
868	      return this.getChildren().has(child);
869	    }
870	  }, {
871	    key: "isChildOf",
872	    value: function isChildOf(parent) {
873	      var parentNode = this.getParentNode();
874
875	      while (parentNode !== null) {
876	        if (parentNode === parent) {
877	          return true;
878	        }
879
880	        parentNode = parentNode.getParentNode();
881	      }
882
883	      return false;
884	    }
885	  }, {
886	    key: "getFirstChild",
887	    value: function getFirstChild() {
888	      return this.children.getFirst();
889	    }
890	  }, {
891	    key: "getLastChild",
892	    value: function getLastChild() {
893	      return this.children.getLast();
894	    }
895	  }, {
896	    key: "getChildren",
897	    value: function getChildren() {
898	      return this.children;
899	    }
900	  }, {
901	    key: "hasChildren",
902	    value: function hasChildren() {
903	      return this.children.count() > 0;
904	    }
905	  }, {
906	    key: "loadChildren",
907	    value: function loadChildren() {
908	      var _this3 = this;
909
910	      if (!this.isDynamic()) {
911	        throw new Error('EntitySelector.ItemNode.loadChildren: an item node is not dynamic.');
912	      }
913
914	      if (this.dynamicPromise) {
915	        return this.dynamicPromise;
916	      }
917
918	      this.dynamicPromise = main_core.ajax.runAction('ui.entityselector.getChildren', {
919	        json: {
920	          parentItem: this.getItem().getAjaxJson(),
921	          dialog: this.getDialog().getAjaxJson()
922	        },
923	        getParameters: {
924	          context: this.getDialog().getContext()
925	        }
926	      });
927	      this.dynamicPromise.then(function (response) {
928	        if (response && response.data && main_core.Type.isPlainObject(response.data.dialog)) {
929	          _this3.addChildren(response.data.dialog.items);
930
931	          _this3.render();
932	        }
933
934	        _this3.loaded = true;
935	      });
936	      this.dynamicPromise["catch"](function (error) {
937	        _this3.loaded = false;
938	        _this3.dynamicPromise = null;
939	        console.error(error);
940	      });
941	      return this.dynamicPromise;
942	    }
943	  }, {
944	    key: "setOpen",
945	    value: function setOpen(open) {
946	      if (main_core.Type.isBoolean(open)) {
947	        if (open && this.isDynamic() && !this.isLoaded()) {
948	          this.setAutoOpen(true);
949	        } else {
950	          this.open = open;
951	        }
952	      }
953	    }
954	  }, {
955	    key: "isOpen",
956	    value: function isOpen() {
957	      return this.open;
958	    }
959	  }, {
960	    key: "isAutoOpen",
961	    value: function isAutoOpen() {
962	      return this.autoOpen && this.isDynamic() && !this.isLoaded();
963	    }
964	  }, {
965	    key: "setAutoOpen",
966	    value: function setAutoOpen(autoOpen) {
967	      if (main_core.Type.isBoolean(autoOpen)) {
968	        this.autoOpen = autoOpen;
969	      }
970	    }
971	  }, {
972	    key: "setDynamic",
973	    value: function setDynamic(dynamic) {
974	      if (main_core.Type.isBoolean(dynamic)) {
975	        this.dynamic = dynamic;
976	      }
977	    }
978	  }, {
979	    key: "isDynamic",
980	    value: function isDynamic() {
981	      return this.dynamic;
982	    }
983	  }, {
984	    key: "isLoaded",
985	    value: function isLoaded() {
986	      return this.loaded;
987	    }
988	  }, {
989	    key: "getLoader",
990	    value: function getLoader() {
991	      if (this.loader === null) {
992	        this.loader = new main_loader.Loader({
993	          target: this.getIndicatorContainer(),
994	          size: 30
995	        });
996	      }
997
998	      return this.loader;
999	    }
1000	  }, {
1001	    key: "showLoader",
1002	    value: function showLoader() {
1003	      void this.getLoader().show();
1004	      main_core.Dom.addClass(this.getIndicatorContainer(), 'ui-selector-item-indicator-hidden');
1005	    }
1006	  }, {
1007	    key: "hideLoader",
1008	    value: function hideLoader() {
1009	      void this.getLoader().hide();
1010	      main_core.Dom.removeClass(this.getIndicatorContainer(), 'ui-selector-item-indicator-hidden');
1011	    }
1012	  }, {
1013	    key: "destroyLoader",
1014	    value: function destroyLoader() {
1015	      this.getLoader().destroy();
1016	      this.loader = null;
1017	      main_core.Dom.removeClass(this.getIndicatorContainer(), 'ui-selector-item-indicator-hidden');
1018	    }
1019	  }, {
1020	    key: "expand",
1021	    value: function expand() {
1022	      var _this4 = this;
1023
1024	      if (this.isOpen() || !this.hasChildren() && !this.isDynamic()) {
1025	        return;
1026	      }
1027
1028	      if (this.isDynamic() && !this.isLoaded()) {
1029	        this.loadChildren().then(function () {
1030	          _this4.destroyLoader();
1031
1032	          _this4.expand();
1033	        });
1034	        this.showLoader();
1035	        return;
1036	      }
1037
1038	      main_core.Dom.addClass(this.getOuterContainer(), 'ui-selector-item-box-open');
1039	      main_core.Dom.style(this.getChildrenContainer(), 'height', '0px');
1040	      main_core.Dom.style(this.getChildrenContainer(), 'opacity', 0);
1041	      requestAnimationFrame(function () {
1042	        requestAnimationFrame(function () {
1043	          main_core.Dom.style(_this4.getChildrenContainer(), 'height', "".concat(_this4.getChildrenContainer().scrollHeight, "px"));
1044	          main_core.Dom.style(_this4.getChildrenContainer(), 'opacity', 1);
1045	          Animation.handleTransitionEnd(_this4.getChildrenContainer(), 'height').then(function () {
1046	            main_core.Dom.style(_this4.getChildrenContainer(), 'height', null);
1047	            main_core.Dom.style(_this4.getChildrenContainer(), 'opacity', null);
1048	            main_core.Dom.addClass(_this4.getOuterContainer(), 'ui-selector-item-box-open');
1049
1050	            _this4.setOpen(true);
1051	          });
1052	        });
1053	      });
1054	    }
1055	  }, {
1056	    key: "collapse",
1057	    value: function collapse() {
1058	      var _this5 = this;
1059
1060	      if (!this.isOpen()) {
1061	        return;
1062	      }
1063
1064	      main_core.Dom.style(this.getChildrenContainer(), 'height', "".concat(this.getChildrenContainer().offsetHeight, "px"));
1065	      requestAnimationFrame(function () {
1066	        requestAnimationFrame(function () {
1067	          main_core.Dom.style(_this5.getChildrenContainer(), 'height', '0px');
1068	          main_core.Dom.style(_this5.getChildrenContainer(), 'opacity', 0);
1069	          Animation.handleTransitionEnd(_this5.getChildrenContainer(), 'height').then(function () {
1070	            main_core.Dom.style(_this5.getChildrenContainer(), 'height', null);
1071	            main_core.Dom.style(_this5.getChildrenContainer(), 'opacity', null);
1072	            main_core.Dom.removeClass(_this5.getOuterContainer(), 'ui-selector-item-box-open');
1073
1074	            _this5.setOpen(false);
1075	          });
1076	        });
1077	      });
1078	    }
1079	  }, {
1080	    key: "render",
1081	    value: function render() {
1082	      var _this6 = this;
1083
1084	      var appendChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1085
1086	      if (this.isRoot()) {
1087	        this.renderRoot(appendChildren);
1088	        return;
1089	      }
1090
1091	      var titleNode = this.getTitleNode();
1092
1093	      if (titleNode) {
1094	        titleNode.renderTo(this.getTitleContainer());
1095	      } else {
1096	        this.getTitleContainer().textContent = '';
1097	      }
1098
1099	      var supertitleNode = this.getSupertitleNode();
1100
1101	      if (supertitleNode) {
1102	        supertitleNode.renderTo(this.getSupertitleContainer());
1103	      } else {
1104	        this.getSupertitleContainer().textContent = '';
1105	      }
1106
1107	      var subtitleNode = this.getSubtitleNode();
1108
1109	      if (subtitleNode) {
1110	        subtitleNode.renderTo(this.getSubtitleContainer());
1111	      } else {
1112	        this.getSubtitleContainer().textContent = '';
1113	      }
1114
1115	      var captionNode = this.getCaptionNode();
1116
1117	      if (captionNode) {
1118	        captionNode.renderTo(this.getCaptionContainer());
1119	      } else {
1120	        this.getCaptionContainer().textContent = '';
1121	      }
1122
1123	      var captionFitContent = this.getCaptionOption('fitContent');
1124
1125	      if (main_core.Type.isBoolean(captionFitContent)) {
1126	        main_core.Dom.style(this.getCaptionContainer(), 'flex-shrink', captionFitContent ? 0 : null);
1127	      }
1128
1129	      var captionMaxWidth = this.getCaptionOption('maxWidth');
1130
1131	      if (main_core.Type.isString(captionMaxWidth) || main_core.Type.isNumber(captionMaxWidth)) {
1132	        main_core.Dom.style(this.getCaptionContainer(), 'max-width', main_core.Type.isNumber(captionMaxWidth) ? "".concat(captionMaxWidth, "px") : captionMaxWidth);
1133	      }
1134
1135	      if (main_core.Type.isStringFilled(this.getTextColor())) {
1136	        this.getTitleContainer().style.color = this.getTextColor();
1137	      } else {
1138	        this.getTitleContainer().style.removeProperty('color');
1139	      }
1140
1141	      var avatar = this.getAvatar();
1142
1143	      if (main_core.Type.isStringFilled(avatar)) {
1144	        this.getAvatarContainer().style.backgroundImage = "url('".concat(encodeUrl(avatar), "')");
1145	      } else {
1146	        var bgImage = this.getAvatarOption('bgImage');
1147
1148	        if (main_core.Type.isStringFilled(bgImage)) {
1149	          this.getAvatarContainer().style.backgroundImage = bgImage;
1150	        } else {
1151	          this.getAvatarContainer().style.removeProperty('background-size');
1152	        }
1153	      }
1154
1155	      var bgColor = this.getAvatarOption('bgColor');
1156
1157	      if (main_core.Type.isStringFilled(bgColor)) {
1158	        this.getAvatarContainer().style.backgroundColor = bgColor;
1159	      } else {
1160	        this.getAvatarContainer().style.removeProperty('background-color');
1161	      }
1162
1163	      var bgSize = this.getAvatarOption('bgSize');
1164
1165	      if (main_core.Type.isStringFilled(bgSize)) {
1166	        this.getAvatarContainer().style.backgroundSize = bgSize;
1167	      } else {
1168	        this.getAvatarContainer().style.removeProperty('background-size');
1169	      }
1170
1171	      main_core.Dom.clean(this.getBadgeContainer());
1172	      this.getBadges().forEach(function (badge) {
1173	        badge.renderTo(_this6.getBadgeContainer());
1174	      });
1175	      var badgesFitContent = this.getBadgesOption('fitContent');
1176
1177	      if (main_core.Type.isBoolean(badgesFitContent)) {
1178	        main_core.Dom.style(this.getBadgeContainer(), 'flex-shrink', badgesFitContent ? 0 : null);
1179	      }
1180
1181	      var badgesMaxWidth = this.getBadgesOption('maxWidth');
1182
1183	      if (main_core.Type.isString(badgesMaxWidth) || main_core.Type.isNumber(badgesMaxWidth)) {
1184	        main_core.Dom.style(this.getBadgeContainer(), 'max-width', main_core.Type.isNumber(badgesMaxWidth) ? "".concat(badgesMaxWidth, "px") : badgesMaxWidth);
1185	      }
1186
1187	      var linkTitleNode = this.getLinkTitleNode();
1188
1189	      if (linkTitleNode) {
1190	        linkTitleNode.renderTo(this.getLinkTextContainer());
1191	      } else {
1192	        this.getLinkTextContainer().textContent = '';
1193	      }
1194
1195	      if (this.hasChildren() || this.isDynamic()) {
1196	        main_core.Dom.addClass(this.getOuterContainer(), 'ui-selector-item-box-has-children');
1197
1198	        if (this.getDepthLevel() >= this.getTab().getItemMaxDepth()) {
1199	          main_core.Dom.addClass(this.getOuterContainer(), 'ui-selector-item-box-max-depth');
1200	        }
1201	      } else if (this.getOuterContainer().classList.contains('ui-selector-item-box-has-children')) {
1202	        main_core.Dom.removeClass(this.getOuterContainer(), ['ui-selector-item-box-has-children', 'ui-selector-item-box-max-depth']);
1203	      }
1204
1205	      if (this.hasChildren()) {
1206	        var hasVisibleChild = this.getChildren().getAll().some(function (child) {
1207	          return child.isHidden() !== true;
1208	        });
1209
1210	        if (!hasVisibleChild) {
1211	          _classPrivateMethodGet(this, _setHidden, _setHidden2).call(this, true);
1212	        }
1213	      }
1214
1215	      this.toggleVisibility();
1216	      this.highlight();
1217	      this.renderChildren(appendChildren);
1218
1219	      if (this.isAutoOpen()) {
1220	        this.setAutoOpen(false);
1221	        requestAnimationFrame(function () {
1222	          requestAnimationFrame(function () {
1223	            _this6.expand();
1224	          });
1225	        });
1226	      }
1227
1228	      this.rendered = true;
1229	    }
1230	    /**
1231	     * @private
1232	     */
1233
1234	  }, {
1235	    key: "renderRoot",
1236	    value: function renderRoot() {
1237	      var appendChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1238	      this.renderChildren(appendChildren);
1239	      this.rendered = true;
1240	      var stub = this.getTab().getStub();
1241
1242	      if (stub && stub.isAutoShow() && (this.getDialog().isLoaded() || !this.getDialog().hasDynamicLoad())) {
1243	        if (this.hasChildren()) {
1244	          stub.hide();
1245	        } else {
1246	          stub.show();
1247	        }
1248	      }
1249	    }
1250	    /**
1251	     * @private
1252	     */
1253
1254	  }, {
1255	    key: "renderChildren",
1256	    value: function renderChildren() {
1257	      var _this7 = this;
1258
1259	      var appendChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1260
1261	      if (!appendChildren) {
1262	        if (main_core.Browser.isIE()) {
1263	          main_core.Dom.clean(this.getChildrenContainer());
1264	        } else {
1265	          this.getChildrenContainer().textContent = '';
1266	        }
1267	      }
1268
1269	      if (this.hasChildren()) {
1270	        var previousSibling = null;
1271	        this.getChildren().forEach(function (child) {
1272	          child.render(appendChildren);
1273	          var container = child.getOuterContainer();
1274
1275	          if (!appendChildren) {
1276	            main_core.Dom.append(container, _this7.getChildrenContainer());
1277	          }
1278
1279	          if (!container.parentNode) {
1280	            if (previousSibling !== null) {
1281	              main_core.Dom.insertAfter(container, previousSibling.getOuterContainer());
1282	            } else {
1283	              main_core.Dom.append(container, _this7.getChildrenContainer());
1284	            }
1285	          }
1286
1287	          previousSibling = child;
1288	        });
1289	      }
1290	    }
1291	  }, {
1292	    key: "isRendered",
1293	    value: function isRendered() {
1294	      return this.rendered && this.getDialog() && this.getDialog().isRendered();
1295	    }
1296	  }, {
1297	    key: "enableRender",
1298	    value: function enableRender() {
1299	      this.rendered = true;
1300	    }
1301	  }, {
1302	    key: "disableRender",
1303	    value: function disableRender() {
1304	      this.rendered = false;
1305	    }
1306	  }, {
1307	    key: "getRenderMode",
1308	    value: function getRenderMode() {
1309	      return this.renderMode;
1310	    }
1311	  }, {
1312	    key: "isHidden",
1313	    value: function isHidden() {
1314	      return this.hidden === true || this.getItem().isHidden() === true;
1315	    }
1316	  }, {
1317	    key: "setHidden",
1318	    value: function setHidden(flag) {
1319	      if (!main_core.Type.isBoolean(flag) || this.isRoot()) {
1320	        return;
1321	      }
1322
1323	      _classPrivateMethodGet(this, _setHidden, _setHidden2).call(this, flag);
1324
1325	      if (this.isRendered()) {
1326	        this.toggleVisibility();
1327	        var parentNode = this.getParentNode();
1328	        var isHidden = this.isHidden();
1329
1330	        while (parentNode.isRoot() === false) {
1331	          if (isHidden) {
1332	            var hasVisibleChild = parentNode.getChildren().getAll().some(function (child) {
1333	              return child.isHidden() !== true;
1334	            });
1335
1336	            if (!hasVisibleChild) {
1337	              var _parentNode;
1338
1339	              _classPrivateMethodGet(_parentNode = parentNode, _setHidden, _setHidden2).call(_parentNode, true);
1340	            }
1341
1342	            parentNode.toggleVisibility();
1343	          } else {
1344	            var _parentNode2;
1345
1346	            _classPrivateMethodGet(_parentNode2 = parentNode, _setHidden, _setHidden2).call(_parentNode2, false);
1347
1348	            parentNode.toggleVisibility();
1349
1350	            if (parentNode.isHidden()) {
1351	              break;
1352	            }
1353	          }
1354
1355	          parentNode = parentNode.getParentNode();
1356	        }
1357	      }
1358	    }
1359	  }, {
1360	    key: "toggleVisibility",
1361	    value: function toggleVisibility() {
1362	      if (this.isHidden()) {
1363	        main_core.Dom.addClass(this.getOuterContainer(), '--hidden');
1364	      } else if (this.getOuterContainer().classList.contains('--hidden')) {
1365	        main_core.Dom.removeClass(this.getOuterContainer(), '--hidden');
1366	      }
1367	    }
1368	  }, {
1369	    key: "getTitle",
1370	    value: function getTitle() {
1371	      var titleNode = this.getTitleNode();
1372	      return titleNode !== null ? titleNode.getText() : null;
1373	    }
1374	  }, {
1375	    key: "getTitleNode",
1376	    value: function getTitleNode() {
1377	      return this.title !== null ? this.title : this.getItem().getTitleNode();
1378	    }
1379	  }, {
1380	    key: "setTitle",
1381	    value: function setTitle(title) {
1382	      if (main_core.Type.isString(title) || main_core.Type.isPlainObject(title)) {
1383	        this.title = new TextNode(title);
1384	      } else if (title === null) {
1385	        this.title = null;
1386	      }
1387	    }
1388	  }, {
1389	    key: "getSubtitle",
1390	    value: function getSubtitle() {
1391	      var subtitleNode = this.getSubtitleNode();
1392	      return subtitleNode !== null ? subtitleNode.getText() : null;
1393	    }
1394	  }, {
1395	    key: "getSubtitleNode",
1396	    value: function getSubtitleNode() {
1397	      return this.subtitle !== null ? this.subtitle : this.getItem().getSubtitleNode();
1398	    }
1399	  }, {
1400	    key: "setSubtitle",
1401	    value: function setSubtitle(subtitle) {
1402	      if (main_core.Type.isString(subtitle) || main_core.Type.isPlainObject(subtitle)) {
1403	        this.subtitle = new TextNode(subtitle);
1404	      } else if (subtitle === null) {
1405	        this.subtitle = null;
1406	      }
1407	    }
1408	  }, {
1409	    key: "getSupertitle",
1410	    value: function getSupertitle() {
1411	      var supertitleNode = this.getSupertitleNode();
1412	      return supertitleNode !== null ? supertitleNode.getText() : null;
1413	    }
1414	  }, {
1415	    key: "getSupertitleNode",
1416	    value: function getSupertitleNode() {
1417	      return this.supertitle !== null ? this.supertitle : this.getItem().getSupertitleNode();
1418	    }
1419	  }, {
1420	    key: "setSupertitle",
1421	    value: function setSupertitle(supertitle) {
1422	      if (main_core.Type.isString(supertitle) || main_core.Type.isPlainObject(supertitle)) {
1423	        this.supertitle = new TextNode(supertitle);
1424	      } else if (supertitle === null) {
1425	        this.supertitle = null;
1426	      }
1427	    }
1428	  }, {
1429	    key: "getCaption",
1430	    value: function getCaption() {
1431	      var caption = this.getCaptionNode();
1432	      return caption !== null ? caption.getText() : null;
1433	    }
1434	  }, {
1435	    key: "getCaptionNode",
1436	    value: function getCaptionNode() {
1437	      return this.caption !== null ? this.caption : this.getItem().getCaptionNode();
1438	    }
1439	  }, {
1440	    key: "setCaption",
1441	    value: function setCaption(caption) {
1442	      if (main_core.Type.isString(caption) || main_core.Type.isPlainObject(caption)) {
1443	        this.caption = new TextNode(caption);
1444	      } else if (caption === null) {
1445	        this.caption = null;
1446	      }
1447	    }
1448	  }, {
1449	    key: "getCaptionOption",
1450	    value: function getCaptionOption(option) {
1451	      if (!main_core.Type.isUndefined(this.captionOptions[option])) {
1452	        return this.captionOptions[option];
1453	      }
1454
1455	      return this.getItem().getCaptionOption(option);
1456	    }
1457	  }, {
1458	    key: "setCaptionOption",
1459	    value: function setCaptionOption(option, value) {
1460	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
1461	        this.captionOptions[option] = value;
1462	      }
1463	    }
1464	  }, {
1465	    key: "setCaptionOptions",
1466	    value: function setCaptionOptions(options) {
1467	      var _this8 = this;
1468
1469	      if (main_core.Type.isPlainObject(options)) {
1470	        Object.keys(options).forEach(function (option) {
1471	          _this8.setCaptionOption(option, options[option]);
1472	        });
1473	      }
1474	    }
1475	  }, {
1476	    key: "getAvatar",
1477	    value: function getAvatar() {
1478	      return this.avatar !== null ? this.avatar : this.getItem().getAvatar();
1479	    }
1480	  }, {
1481	    key: "setAvatar",
1482	    value: function setAvatar(avatar) {
1483	      if (main_core.Type.isString(avatar) || avatar === null) {
1484	        this.avatar = avatar;
1485	      }
1486	    }
1487	  }, {
1488	    key: "getAvatarOption",
1489	    value: function getAvatarOption(option) {
1490	      return this.avatarOptions === null || main_core.Type.isUndefined(this.avatarOptions[option]) ? this.getItem().getAvatarOption(option) : this.avatarOptions[option];
1491	    }
1492	  }, {
1493	    key: "setAvatarOption",
1494	    value: function setAvatarOption(option, value) {
1495	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
1496	        if (this.avatarOptions === null) {
1497	          this.avatarOptions = {};
1498	        }
1499
1500	        this.avatarOptions[option] = value;
1501	      }
1502	    }
1503	  }, {
1504	    key: "setAvatarOptions",
1505	    value: function setAvatarOptions(avatarOptions) {
1506	      var _this9 = this;
1507
1508	      if (main_core.Type.isPlainObject(avatarOptions)) {
1509	        Object.keys(avatarOptions).forEach(function (option) {
1510	          _this9.setAvatarOption(option, avatarOptions[option]);
1511	        });
1512	      }
1513	    }
1514	  }, {
1515	    key: "getTextColor",
1516	    value: function getTextColor() {
1517	      return this.textColor !== null ? this.textColor : this.getItem().getTextColor();
1518	    }
1519	  }, {
1520	    key: "setTextColor",
1521	    value: function setTextColor(textColor) {
1522	      if (main_core.Type.isString(textColor) || textColor === null) {
1523	        this.textColor = textColor;
1524	      }
1525	    }
1526	  }, {
1527	    key: "getLink",
1528	    value: function getLink() {
1529	      return this.link !== null ? this.getItem().replaceMacros(this.link) : this.getItem().getLink();
1530	    }
1531	  }, {
1532	    key: "setLink",
1533	    value: function setLink(link) {
1534	      if (main_core.Type.isString(link) || link === null) {
1535	        this.link = link;
1536	      }
1537	    }
1538	  }, {
1539	    key: "getLinkTitle",
1540	    value: function getLinkTitle() {
1541	      var linkTitle = this.getLinkTitleNode();
1542	      return linkTitle !== null ? linkTitle.getText() : null;
1543	    }
1544	  }, {
1545	    key: "getLinkTitleNode",
1546	    value: function getLinkTitleNode() {
1547	      return this.linkTitle !== null ? this.linkTitle : this.getItem().getLinkTitleNode();
1548	    }
1549	  }, {
1550	    key: "setLinkTitle",
1551	    value: function setLinkTitle(title) {
1552	      if (main_core.Type.isString(title) || main_core.Type.isPlainObject(title)) {
1553	        this.linkTitle = new TextNode(title);
1554	      } else if (title === null) {
1555	        this.linkTitle = null;
1556	      }
1557	    }
1558	  }, {
1559	    key: "getBadges",
1560	    value: function getBadges() {
1561	      return this.badges !== null ? this.badges : this.getItem().getBadges();
1562	    }
1563	  }, {
1564	    key: "setBadges",
1565	    value: function setBadges(badges) {
1566	      var _this10 = this;
1567
1568	      if (main_core.Type.isArray(badges)) {
1569	        this.badges = [];
1570	        badges.forEach(function (badge) {
1571	          _this10.badges.push(new ItemBadge(badge));
1572	        });
1573	      } else if (badges === null) {
1574	        this.badges = null;
1575	      }
1576	    }
1577	  }, {
1578	    key: "getBadgesOption",
1579	    value: function getBadgesOption(option) {
1580	      if (!main_core.Type.isUndefined(this.badgesOptions[option])) {
1581	        return this.badgesOptions[option];
1582	      }
1583
1584	      return this.getItem().getBadgesOption(option);
1585	    }
1586	  }, {
1587	    key: "setBadgesOption",
1588	    value: function setBadgesOption(option, value) {
1589	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
1590	        this.badgesOptions[option] = value;
1591	      }
1592	    }
1593	  }, {
1594	    key: "setBadgesOptions",
1595	    value: function setBadgesOptions(options) {
1596	      var _this11 = this;
1597
1598	      if (main_core.Type.isPlainObject(options)) {
1599	        Object.keys(options).forEach(function (option) {
1600	          _this11.setBadgesOption(option, options[option]);
1601	        });
1602	      }
1603	    }
1604	  }, {
1605	    key: "getOuterContainer",
1606	    value: function getOuterContainer() {
1607	      var _this12 = this;
1608
1609	      return this.cache.remember('outer-container', function () {
1610	        var className = '';
1611
1612	        if (_this12.hasChildren() || _this12.isDynamic()) {
1613	          className += ' ui-selector-item-box-has-children';
1614
1615	          if (_this12.getDepthLevel() >= _this12.getTab().getItemMaxDepth()) {
1616	            className += ' ui-selector-item-box-max-depth';
1617	          }
1618	        } else if (_this12.getItem().isSelected()) {
1619	          className += ' ui-selector-item-box-selected';
1620	        }
1621
1622	        if (_this12.isOpen()) {
1623	          className += ' ui-selector-item-box-open';
1624	        }
1625
1626	        var div = document.createElement('div');
1627	        div.className = "ui-selector-item-box".concat(className);
1628	        div.appendChild(_this12.getContainer());
1629	        div.appendChild(_this12.getChildrenContainer());
1630	        return div;
1631	      });
1632	    }
1633	  }, {
1634	    key: "getChildrenContainer",
1635	    value: function getChildrenContainer() {
1636	      if (this.isRoot() && this.getTab()) {
1637	        return this.getTab().getItemsContainer();
1638	      }
1639
1640	      return this.cache.remember('children-container', function () {
1641	        var div = document.createElement('div');
1642	        div.className = 'ui-selector-item-children';
1643	        return div;
1644	      });
1645	    }
1646	  }, {
1647	    key: "getContainer",
1648	    value: function getContainer() {
1649	      var _this13 = this;
1650
1651	      return this.cache.remember('container', function () {
1652	        var div = document.createElement('div');
1653	        div.className = 'ui-selector-item';
1654	        main_core.Event.bind(div, 'click', _this13.handleClick.bind(_this13));
1655	        main_core.Event.bind(div, 'mouseenter', _this13.handleMouseEnter.bind(_this13));
1656	        main_core.Event.bind(div, 'mouseleave', _this13.handleMouseLeave.bind(_this13));
1657	        div.appendChild(_this13.getAvatarContainer());
1658	        div.appendChild(_this13.getTitlesContainer());
1659	        div.appendChild(_this13.getIndicatorContainer());
1660
1661	        if (main_core.Type.isStringFilled(_this13.getLink())) {
1662	          div.appendChild(_this13.getLinkContainer());
1663	        }
1664
1665	        return div;
1666	      });
1667	    }
1668	  }, {
1669	    key: "getAvatarContainer",
1670	    value: function getAvatarContainer() {
1671	      return this.cache.remember('avatar', function () {
1672	        var div = document.createElement('div');
1673	        div.className = 'ui-selector-item-avatar';
1674	        return div;
1675	      });
1676	    }
1677	  }, {
1678	    key: "getTitlesContainer",
1679	    value: function getTitlesContainer() {
1680	      var _this14 = this;
1681
1682	      return this.cache.remember('titles', function () {
1683	        var div = document.createElement('div');
1684	        div.className = 'ui-selector-item-titles';
1685	        div.appendChild(_this14.getSupertitleContainer());
1686	        div.appendChild(_this14.getTitleBoxContainer());
1687	        div.appendChild(_this14.getSubtitleContainer());
1688	        return div;
1689	      });
1690	    }
1691	  }, {
1692	    key: "getTitleBoxContainer",
1693	    value: function getTitleBoxContainer() {
1694	      var _this15 = this;
1695
1696	      return this.cache.remember('title-box', function () {
1697	        var div = document.createElement('div');
1698	        div.className = 'ui-selector-item-title-box';
1699	        div.appendChild(_this15.getTitleContainer());
1700	        div.appendChild(_this15.getBadgeContainer());
1701	        div.appendChild(_this15.getCaptionContainer());
1702	        return div;
1703	      });
1704	    }
1705	  }, {
1706	    key: "getTitleContainer",
1707	    value: function getTitleContainer() {
1708	      return this.cache.remember('title', function () {
1709	        var div = document.createElement('div');
1710	        div.className = 'ui-selector-item-title';
1711	        return div;
1712	      });
1713	    }
1714	  }, {
1715	    key: "getSubtitleContainer",
1716	    value: function getSubtitleContainer() {
1717	      return this.cache.remember('subtitle', function () {
1718	        var div = document.createElement('div');
1719	        div.className = 'ui-selector-item-subtitle';
1720	        return div;
1721	      });
1722	    }
1723	  }, {
1724	    key: "getSupertitleContainer",
1725	    value: function getSupertitleContainer() {
1726	      return this.cache.remember('supertitle', function () {
1727	        var div = document.createElement('div');
1728	        div.className = 'ui-selector-item-supertitle';
1729	        return div;
1730	      });
1731	    }
1732	  }, {
1733	    key: "getCaptionContainer",
1734	    value: function getCaptionContainer() {
1735	      return this.cache.remember('caption', function () {
1736	        var div = document.createElement('div');
1737	        div.className = 'ui-selector-item-caption';
1738	        return div;
1739	      });
1740	    }
1741	  }, {
1742	    key: "getIndicatorContainer",
1743	    value: function getIndicatorContainer() {
1744	      return this.cache.remember('indicator', function () {
1745	        var div = document.createElement('div');
1746	        div.className = 'ui-selector-item-indicator';
1747	        return div;
1748	      });
1749	    }
1750	  }, {
1751	    key: "getBadgeContainer",
1752	    value: function getBadgeContainer() {
1753	      return this.cache.remember('badge', function () {
1754	        var div = document.createElement('div');
1755	        div.className = 'ui-selector-item-badges';
1756	        return div;
1757	      });
1758	    }
1759	  }, {
1760	    key: "getLinkContainer",
1761	    value: function getLinkContainer() {
1762	      var _this16 = this;
1763
1764	      return this.cache.remember('link', function () {
1765	        var anchor = document.createElement('a');
1766	        anchor.className = 'ui-selector-item-link';
1767	        anchor.href = _this16.getLink();
1768	        anchor.target = '_blank';
1769	        anchor.title = '';
1770	        main_core.Event.bind(anchor, 'click', _this16.handleLinkClick.bind(_this16));
1771	        anchor.appendChild(_this16.getLinkTextContainer());
1772	        return anchor;
1773	      });
1774	    }
1775	  }, {
1776	    key: "getLinkTextContainer",
1777	    value: function getLinkTextContainer() {
1778	      return this.cache.remember('link-text', function () {
1779	        var span = document.createElement('span');
1780	        span.className = 'ui-selector-item-link-text';
1781	        return span;
1782	      });
1783	    }
1784	  }, {
1785	    key: "showLink",
1786	    value: function showLink() {
1787	      var _this17 = this;
1788
1789	      if (main_core.Type.isStringFilled(this.getLink())) {
1790	        main_core.Dom.addClass(this.getLinkContainer(), 'ui-selector-item-link--show');
1791	        requestAnimationFrame(function () {
1792	          requestAnimationFrame(function () {
1793	            main_core.Dom.addClass(_this17.getLinkContainer(), 'ui-selector-item-link--animate');
1794	          });
1795	        });
1796	      }
1797	    }
1798	  }, {
1799	    key: "hideLink",
1800	    value: function hideLink() {
1801	      if (main_core.Type.isStringFilled(this.getLink())) {
1802	        main_core.Dom.removeClass(this.getLinkContainer(), ['ui-selector-item-link--show', 'ui-selector-item-link--animate']);
1803	      }
1804	    }
1805	  }, {
1806	    key: "setHighlights",
1807	    value: function setHighlights(highlights) {
1808	      this.highlights = highlights;
1809	    }
1810	  }, {
1811	    key: "getHighlights",
1812	    value: function getHighlights() {
1813	      return this.highlights;
1814	    }
1815	  }, {
1816	    key: "highlight",
1817	    value: function highlight() {
1818	      var _this18 = this;
1819
1820	      this.getHighlights().forEach(function (matchField) {
1821	        var field = matchField.getField();
1822	        var fieldName = field.getName();
1823
1824	        if (field.isCustom()) {
1825	          var text = _this18.getItem().getCustomData().get(fieldName);
1826
1827	          _this18.getSubtitleContainer().innerHTML = Highlighter.mark(text, matchField.getMatches());
1828	        } else if (field.getName() === 'title') {
1829	          _this18.getTitleContainer().innerHTML = Highlighter.mark(_this18.getItem().getTitleNode(), matchField.getMatches());
1830	        } else if (field.getName() === 'subtitle') {
1831	          _this18.getSubtitleContainer().innerHTML = Highlighter.mark(_this18.getItem().getSubtitleNode(), matchField.getMatches());
1832	        } else if (field.getName() === 'supertitle') {
1833	          _this18.getSupertitleContainer().innerHTML = Highlighter.mark(_this18.getItem().getSupertitleNode(), matchField.getMatches());
1834	        }
1835	      });
1836	    }
1837	  }, {
1838	    key: "select",
1839	    value: function select() {
1840	      if (this.hasChildren() || this.isDynamic()) {
1841	        return;
1842	      }
1843
1844	      main_core.Dom.addClass(this.getOuterContainer(), 'ui-selector-item-box-selected');
1845	    }
1846	  }, {
1847	    key: "deselect",
1848	    value: function deselect() {
1849	      if (this.hasChildren() || this.isDynamic()) {
1850	        return;
1851	      }
1852
1853	      main_core.Dom.removeClass(this.getOuterContainer(), 'ui-selector-item-box-selected');
1854	    }
1855	  }, {
1856	    key: "focus",
1857	    value: function focus() {
1858	      if (this.isFocused()) {
1859	        return;
1860	      }
1861
1862	      this.focused = true;
1863	      main_core.Dom.addClass(this.getOuterContainer(), 'ui-selector-item-box-focused');
1864	      this.getDialog().emit('ItemNode:onFocus', {
1865	        node: this
1866	      });
1867	    }
1868	  }, {
1869	    key: "unfocus",
1870	    value: function unfocus() {
1871	      if (!this.isFocused()) {
1872	        return;
1873	      }
1874
1875	      this.focused = false;
1876	      main_core.Dom.removeClass(this.getOuterContainer(), 'ui-selector-item-box-focused');
1877	      this.getDialog().emit('ItemNode:onUnfocus', {
1878	        node: this
1879	      });
1880	    }
1881	  }, {
1882	    key: "isFocused",
1883	    value: function isFocused() {
1884	      return this.focused;
1885	    }
1886	  }, {
1887	    key: "click",
1888	    value: function click() {
1889	      if (this.hasChildren() || this.isDynamic()) {
1890	        if (this.isOpen()) {
1891	          this.collapse();
1892	        } else {
1893	          this.expand();
1894	        }
1895	      } else {
1896	        if (this.getItem().isSelected()) {
1897	          if (this.getItem().isDeselectable()) {
1898	            this.getItem().deselect();
1899	          }
1900
1901	          if (this.getDialog().shouldHideOnDeselect()) {
1902	            this.getDialog().hide();
1903	          }
1904	        } else {
1905	          this.getItem().select();
1906
1907	          if (this.getDialog().shouldClearSearchOnSelect()) {
1908	            this.getDialog().clearSearch();
1909	          }
1910
1911	          if (this.getDialog().shouldHideOnSelect()) {
1912	            this.getDialog().hide();
1913	          }
1914	        }
1915	      }
1916
1917	      this.getDialog().focusSearch();
1918	    }
1919	  }, {
1920	    key: "scrollIntoView",
1921	    value: function scrollIntoView() {
1922	      var tabContainer = this.getTab().getContainer();
1923	      var nodeContainer = this.getContainer();
1924	      var tabRect = main_core.Dom.getPosition(tabContainer);
1925	      var nodeRect = main_core.Dom.getPosition(nodeContainer);
1926	      var margin = 9; // 'ui-selector-items' padding - 'ui-selector-item' margin = 10 - 1
1927
1928	      if (nodeRect.top < tabRect.top) // scroll up
1929	        {
1930	          tabContainer.scrollTop -= tabRect.top - nodeRect.top + margin;
1931	        } else if (nodeRect.bottom > tabRect.bottom) // scroll down
1932	        {
1933	          tabContainer.scrollTop += nodeRect.bottom - tabRect.bottom + margin;
1934	        }
1935	    }
1936	  }, {
1937	    key: "handleClick",
1938	    value: function handleClick() {
1939	      this.click();
1940	    }
1941	  }, {
1942	    key: "handleLinkClick",
1943	    value: function handleLinkClick(event) {
1944	      this.getDialog().emit('ItemNode:onLinkClick', {
1945	        node: this,
1946	        event: event
1947	      });
1948	      event.stopPropagation();
1949	    }
1950	  }, {
1951	    key: "handleMouseEnter",
1952	    value: function handleMouseEnter() {
1953	      this.focus();
1954	      this.showLink();
1955
1956	      _classPrivateMethodGet(this, _makeEllipsisTitle, _makeEllipsisTitle2).call(this);
1957	    }
1958	  }, {
1959	    key: "handleMouseLeave",
1960	    value: function handleMouseLeave() {
1961	      this.unfocus();
1962	      this.hideLink();
1963	    }
1964	  }]);
1965	  return ItemNode;
1966	}();
1967
1968	function _setHidden2(flag) {
1969	  if (main_core.Type.isBoolean(flag) && !this.isRoot()) {
1970	    this.hidden = flag;
1971	  }
1972	}
1973
1974	function _makeEllipsisTitle2() {
1975	  var _this19 = this;
1976
1977	  var _this$constructor;
1978
1979	  if (_classStaticPrivateMethodGet(_this$constructor = this.constructor, ItemNode, _isEllipsisActive).call(_this$constructor, this.getTitleContainer())) {
1980	    var _this$constructor2;
1981
1982	    this.getContainer().setAttribute('title', _classStaticPrivateMethodGet(_this$constructor2 = this.constructor, ItemNode, _sanitizeTitle).call(_this$constructor2, this.getTitleContainer().textContent));
1983	  } else {
1984	    main_core.Dom.attr(this.getContainer(), 'title', null);
1985	  }
1986
1987	  var containers = [this.getSupertitleContainer(), this.getSubtitleContainer(), this.getCaptionContainer()].concat(babelHelpers.toConsumableArray(this.getBadges().map(function (badge) {
1988	    return badge.getContainer(_this19.getBadgeContainer());
1989	  })));
1990	  containers.forEach(function (container) {
1991	    var _this$constructor3;
1992
1993	    if (_classStaticPrivateMethodGet(_this$constructor3 = _this19.constructor, ItemNode, _isEllipsisActive).call(_this$constructor3, container)) {
1994	      var _this$constructor4;
1995
1996	      container.setAttribute('title', _classStaticPrivateMethodGet(_this$constructor4 = _this19.constructor, ItemNode, _sanitizeTitle).call(_this$constructor4, container.textContent));
1997	    } else {
1998	      main_core.Dom.attr(container, 'title', null);
1999	    }
2000	  });
2001	}
2002
2003	function _isEllipsisActive(element) {
2004	  return element.offsetWidth < element.scrollWidth;
2005	}
2006
2007	function _sanitizeTitle(text) {
2008	  return text.replace(/[\t ]+/gm, ' ').replace(/\n+/gm, '\n').trim();
2009	}
2010
2011	var SearchFieldIndex = /*#__PURE__*/function () {
2012	  function SearchFieldIndex(field) {
2013	    var indexes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
2014	    babelHelpers.classCallCheck(this, SearchFieldIndex);
2015	    babelHelpers.defineProperty(this, "field", null);
2016	    babelHelpers.defineProperty(this, "indexes", []);
2017	    this.field = field;
2018	    this.addIndexes(indexes);
2019	  }
2020
2021	  babelHelpers.createClass(SearchFieldIndex, [{
2022	    key: "getField",
2023	    value: function getField() {
2024	      return this.field;
2025	    }
2026	  }, {
2027	    key: "getIndexes",
2028	    value: function getIndexes() {
2029	      return this.indexes;
2030	    }
2031	  }, {
2032	    key: "addIndex",
2033	    value: function addIndex(index) {
2034	      this.getIndexes().push(index);
2035	    }
2036	  }, {
2037	    key: "addIndexes",
2038	    value: function addIndexes(indexes) {
2039	      var _this = this;
2040
2041	      indexes.forEach(function (index) {
2042	        _this.addIndex(index);
2043	      });
2044	    }
2045	  }]);
2046	  return SearchFieldIndex;
2047	}();
2048
2049	var WordIndex = /*#__PURE__*/function () {
2050	  function WordIndex(word, startIndex) {
2051	    babelHelpers.classCallCheck(this, WordIndex);
2052	    babelHelpers.defineProperty(this, "word", '');
2053	    babelHelpers.defineProperty(this, "startIndex", 0);
2054	    this.setWord(word);
2055	    this.setStartIndex(startIndex);
2056	  }
2057
2058	  babelHelpers.createClass(WordIndex, [{
2059	    key: "getWord",
2060	    value: function getWord() {
2061	      return this.word;
2062	    }
2063	  }, {
2064	    key: "setWord",
2065	    value: function setWord(word) {
2066	      if (main_core.Type.isStringFilled(word)) {
2067	        this.word = word;
2068	      }
2069
2070	      return this;
2071	    }
2072	  }, {
2073	    key: "getStartIndex",
2074	    value: function getStartIndex() {
2075	      return this.startIndex;
2076	    }
2077	  }, {
2078	    key: "setStartIndex",
2079	    value: function setStartIndex(index) {
2080	      if (main_core.Type.isNumber(index) && index >= 0) {
2081	        this.startIndex = index;
2082	      }
2083
2084	      return this;
2085	    }
2086	  }]);
2087	  return WordIndex;
2088	}();
2089
2090	/**
2091	 * @license
2092	 * Lodash <https://lodash.com/>
2093	 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
2094	 * Released under MIT license <https://lodash.com/license>
2095	 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2096	 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2097	 */
2098
2099	/** Used to compose unicode character classes. */
2100	var rsAstralRange = "\\ud800-\\udfff";
2101	var rsComboMarksRange = "\\u0300-\\u036f";
2102	var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
2103	var rsComboSymbolsRange = "\\u20d0-\\u20ff";
2104	var rsComboMarksExtendedRange = "\\u1ab0-\\u1aff";
2105	var rsComboMarksSupplementRange = "\\u1dc0-\\u1dff";
2106	var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
2107	var rsDingbatRange = "\\u2700-\\u27bf";
2108	var rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff';
2109	var rsMathOpRange = '\\xac\\xb1\\xd7\\xf7';
2110	var rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf';
2111	var rsPunctuationRange = "\\u2000-\\u206f";
2112	var rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000";
2113	var rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde';
2114	var rsVarRange = "\\ufe0e\\ufe0f";
2115	var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
2116	/** Used to compose unicode capture groups. */
2117
2118	var rsApos = "['\u2019]";
2119	var rsBreak = "[".concat(rsBreakRange, "]");
2120	var rsCombo = "[".concat(rsComboRange, "]");
2121	var rsDigit = '\\d';
2122	var rsDingbat = "[".concat(rsDingbatRange, "]");
2123	var rsLower = "[".concat(rsLowerRange, "]");
2124	var rsMisc = "[^".concat(rsAstralRange).concat(rsBreakRange + rsDigit + rsDingbatRange + rsLowerRange + rsUpperRange, "]");
2125	var rsFitz = "\\ud83c[\\udffb-\\udfff]";
2126	var rsModifier = "(?:".concat(rsCombo, "|").concat(rsFitz, ")");
2127	var rsNonAstral = "[^".concat(rsAstralRange, "]");
2128	var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
2129	var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
2130	var rsUpper = "[".concat(rsUpperRange, "]");
2131	var rsZWJ = "\\u200d";
2132	/** Used to compose unicode regexes. */
2133
2134	var rsMiscLower = "(?:".concat(rsLower, "|").concat(rsMisc, ")");
2135	var rsMiscUpper = "(?:".concat(rsUpper, "|").concat(rsMisc, ")");
2136	var rsOptContrLower = "(?:".concat(rsApos, "(?:d|ll|m|re|s|t|ve))?");
2137	var rsOptContrUpper = "(?:".concat(rsApos, "(?:D|LL|M|RE|S|T|VE))?");
2138	var reOptMod = "".concat(rsModifier, "?");
2139	var rsOptVar = "[".concat(rsVarRange, "]?");
2140	var rsOptJoin = "(?:".concat(rsZWJ, "(?:").concat([rsNonAstral, rsRegional, rsSurrPair].join('|'), ")").concat(rsOptVar + reOptMod, ")*");
2141	var rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])';
2142	var rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])';
2143	var rsSeq = rsOptVar + reOptMod + rsOptJoin;
2144	var rsEmoji = "(?:".concat([rsDingbat, rsRegional, rsSurrPair].join('|'), ")").concat(rsSeq);
2145	var unicodeWordsRegExp = new RegExp(["".concat(rsUpper, "?").concat(rsLower, "+").concat(rsOptContrLower, "(?=").concat([rsBreak, rsUpper, '$'].join('|'), ")"), "".concat(rsMiscUpper, "+").concat(rsOptContrUpper, "(?=").concat([rsBreak, rsUpper + rsMiscLower, '$'].join('|'), ")"), "".concat(rsUpper, "?").concat(rsMiscLower, "+").concat(rsOptContrLower), "".concat(rsUpper, "+").concat(rsOptContrUpper), r
2145sOrdUpper, rsOrdLower, "".concat(rsDigit, "+"), rsEmoji].join('|'), 'g');
2146
2147	var asciiWordRegExp = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2148	var hasUnicodeWordRegExp = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
2149	var nonWhitespaceRegExp = /[^\s]+/g;
2150	var specialChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}";
2151	var specialCharsRegExp = new RegExp("[".concat(specialChars, "]"));
2152
2153	var SearchIndex = /*#__PURE__*/function () {
2154	  function SearchIndex() {
2155	    babelHelpers.classCallCheck(this, SearchIndex);
2156	    babelHelpers.defineProperty(this, "indexes", []);
2157	  }
2158
2159	  babelHelpers.createClass(SearchIndex, [{
2160	    key: "addIndex",
2161	    value: function addIndex(fieldIndex) {
2162	      if (main_core.Type.isObject(fieldIndex)) {
2163	        this.getIndexes().push(fieldIndex);
2164	      }
2165	    }
2166	  }, {
2167	    key: "getIndexes",
2168	    value: function getIndexes() {
2169	      return this.indexes;
2170	    }
2171	  }], [{
2172	    key: "create",
2173	    value: function create(item) {
2174	      var _this = this;
2175
2176	      var index = new SearchIndex();
2177	      var entity = item.getEntity();
2178
2179	      if (!item.isSearchable() || !entity.isSearchable() || item.isHidden()) {
2180	        return index;
2181	      }
2182
2183	      var searchFields = entity.getSearchFields();
2184	      searchFields.forEach(function (field) {
2185	        if (!field.isSearchable()) {
2186	          return;
2187	        }
2188
2189	        if (field.isSystem()) {
2190	          if (field.getName() === 'title') {
2191	            var textNode = item.getTitleNode();
2192	            var stripTags = textNode !== null && textNode.getType() === 'html';
2193	            index.addIndex(_this.createIndex(field, item.getTitle(), stripTags));
2194	          } else if (field.getName() === 'subtitle') {
2195	            var _textNode = item.getSubtitleNode();
2196
2197	            var _stripTags = _textNode !== null && _textNode.getType() === 'html';
2198
2199	            index.addIndex(_this.createIndex(field, item.getSubtitle(), _stripTags));
2200	          } else if (field.getName() === 'supertitle') {
2201	            var _textNode2 = item.getSupertitleNode();
2202
2203	            var _stripTags2 = _textNode2 !== null && _textNode2.getType() === 'html';
2204
2205	            index.addIndex(_this.createIndex(field, item.getSupertitle(), _stripTags2));
2206	          }
2207	        } else {
2208	          var customData = item.getCustomData().get(field.getName());
2209
2210	          if (!main_core.Type.isUndefined(customData)) {
2211	            index.addIndex(_this.createIndex(field, customData));
2212	          }
2213	        }
2214	      });
2215	      return index;
2216	    }
2217	  }, {
2218	    key: "createIndex",
2219	    value: function createIndex(field, text) {
2220	      var stripTags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2221
2222	      if (!main_core.Type.isStringFilled(text)) {
2223	        return null;
2224	      }
2225
2226	      if (stripTags) {
2227	        text = text.replace(/<\/?[^>]+>/g, function (match) {
2228	          return ' '.repeat(match.length);
2229	        });
2230	        text = text.replace(/&(?:#\d+|#x[\da-fA-F]+|[0-9a-zA-Z]+);/g, function (match) {
2231	          return ' '.repeat(match.length);
2232	        });
2233	      }
2234
2235	      var index = null;
2236
2237	      if (field.getType() === 'string') {
2238	        var wordIndexes = this.splitText(text);
2239
2240	        if (main_core.Type.isArrayFilled(wordIndexes)) {
2241	          // "GoPro111 Leto15"
2242	          // [go, pro, 111, leto, 15] + [gopro111, leto15]
2243	          this.fillComplexWords(wordIndexes);
2244	          this.fillNonCharWords(wordIndexes, text);
2245	          index = new SearchFieldIndex(field, wordIndexes);
2246	        }
2247	      } else if (field.getType() === 'email') {
2248	        var position = text.indexOf('@');
2249
2250	        if (position !== -1) {
2251	          index = new SearchFieldIndex(field, [new WordIndex(text.toLowerCase(), 0), new WordIndex(text.substr(position + 1).toLowerCase(), position + 1)]);
2252	        }
2253	      }
2254
2255	      return index;
2256	    }
2257	  }, {
2258	    key: "splitText",
2259	    value: function splitText(text) {
2260	      if (!main_core.Type.isStringFilled(text)) {
2261	        return [];
2262	      }
2263
2264	      return this.hasUnicodeWord(text) ? this.splitUnicodeText(text) : this.splitAsciiText(text);
2265	    }
2266	  }, {
2267	    key: "splitUnicodeText",
2268	    value: function splitUnicodeText(text) {
2269	      return this.splitTextInternal(text, unicodeWordsRegExp);
2270	    }
2271	  }, {
2272	    key: "splitAsciiText",
2273	    value: function splitAsciiText(text) {
2274	      return this.splitTextInternal(text, asciiWordRegExp);
2275	    }
2276	  }, {
2277	    key: "hasUnicodeWord",
2278	    value: function hasUnicodeWord(text) {
2279	      return hasUnicodeWordRegExp.test(text);
2280	    }
2281	  }, {
2282	    key: "splitTextInternal",
2283	    value: function splitTextInternal(text, regExp) {
2284	      var match;
2285	      var result = [];
2286	      regExp.lastIndex = 0;
2287
2288	      while ((match = regExp.exec(text)) !== null) {
2289	        if (match.index === regExp.lastIndex) {
2290	          regExp.lastIndex++;
2291	        }
2292
2293	        result.push(new WordIndex(match[0].toLowerCase(), match.index));
2294	      }
2295
2296	      return result;
2297	    }
2298	    /**
2299	     *  @private
2300	     */
2301
2302	  }, {
2303	    key: "fillComplexWords",
2304	    value: function fillComplexWords(indexes) {
2305	      if (indexes.length < 2) {
2306	        return;
2307	      }
2308
2309	      var complexWord = null;
2310	      var startIndex = null;
2311	      indexes.forEach(function (currentIndex, currentArrayIndex) {
2312	        var nextIndex = indexes[currentArrayIndex + 1];
2313
2314	        if (nextIndex) {
2315	          var sameWord = currentIndex.getStartIndex() + currentIndex.getWord().length === nextIndex.getStartIndex();
2316
2317	          if (sameWord) {
2318	            if (complexWord === null) {
2319	              complexWord = currentIndex.getWord();
2320	              startIndex = currentIndex.getStartIndex();
2321	            }
2322
2323	            complexWord += nextIndex.getWord();
2324	          } else if (complexWord !== null) {
2325	            indexes.push(new WordIndex(complexWord, startIndex));
2326	            complexWord = null;
2327	            startIndex = null;
2328	          }
2329	        } else if (complexWord !== null) {
2330	          indexes.push(new WordIndex(complexWord, startIndex));
2331	          complexWord = null;
2332	          startIndex = null;
2333	        }
2334	      });
2335	    }
2336	    /**
2337	     *  @private
2338	     */
2339
2340	  }, {
2341	    key: "fillNonCharWords",
2342	    value: function fillNonCharWords(indexes, text) {
2343	      if (!specialCharsRegExp.test(text)) {
2344	        return;
2345	      }
2346
2347	      var match;
2348
2349	      while ((match = nonWhitespaceRegExp.exec(text)) !== null) {
2350	        if (match.index === nonWhitespaceRegExp.lastIndex) {
2351	          nonWhitespaceRegExp.lastIndex++;
2352	        }
2353
2354	        var word = match[0];
2355
2356	        if (specialCharsRegExp.test(word)) {
2357	          indexes.push(new WordIndex(word.toLowerCase(), match.index));
2358
2359	          for (var i = 0; i < word.length; i++) {
2360	            var _char = word[i];
2361
2362	            if (!specialChars.includes(_char)) {
2363	              break;
2364	            }
2365
2366	            var wordToIndex = word.substr(i + 1);
2367
2368	            if (wordToIndex.length) {
2369	              indexes.push(new WordIndex(wordToIndex.toLowerCase(), match.index + i + 1));
2370	            }
2371	          }
2372	        }
2373	      }
2374
2375	      nonWhitespaceRegExp.lastIndex = 0;
2376	    }
2377	  }]);
2378	  return SearchIndex;
2379	}();
2380
2381	var EntityFilter = /*#__PURE__*/function () {
2382	  function EntityFilter(filterOptions) {
2383	    babelHelpers.classCallCheck(this, EntityFilter);
2384	    babelHelpers.defineProperty(this, "id", null);
2385	    babelHelpers.defineProperty(this, "options", {});
2386	    var options = main_core.Type.isPlainObject(filterOptions) ? filterOptions : {};
2387	    this.id = options.id;
2388	    this.options = options.options;
2389	  }
2390
2391	  babelHelpers.createClass(EntityFilter, [{
2392	    key: "getId",
2393	    value: function getId() {
2394	      return this.id;
2395	    }
2396	  }, {
2397	    key: "getOptions",
2398	    value: function getOptions() {
2399	      return this.options;
2400	    }
2401	  }, {
2402	    key: "toJSON",
2403	    value: function toJSON() {
2404	      return {
2405	        id: this.getId(),
2406	        options: this.getOptions()
2407	      };
2408	    }
2409	  }]);
2410	  return EntityFilter;
2411	}();
2412
2413	/**
2414	 * @memberof BX.UI.EntitySelector
2415	 */
2416
2417	var Entity = /*#__PURE__*/function () {
2418	  function Entity(entityOptions) {
2419	    var _this = this;
2420
2421	    babelHelpers.classCallCheck(this, Entity);
2422	    babelHelpers.defineProperty(this, "id", null);
2423	    babelHelpers.defineProperty(this, "options", {});
2424	    babelHelpers.defineProperty(this, "searchable", true);
2425	    babelHelpers.defineProperty(this, "searchFields", null);
2426	    babelHelpers.defineProperty(this, "dynamicLoad", false);
2427	    babelHelpers.defineProperty(this, "dynamicSearch", false);
2428	    babelHelpers.defineProperty(this, "searchCacheLimits", []);
2429	    babelHelpers.defineProperty(this, "filters", new Map());
2430	    babelHelpers.defineProperty(this, "itemOptions", {});
2431	    babelHelpers.defineProperty(this, "tagOptions", {});
2432	    babelHelpers.defineProperty(this, "badgeOptions", []);
2433	    babelHelpers.defineProperty(this, "textNodes", new Map());
2434	    var options = main_core.Type.isPlainObject(entityOptions) ? entityOptions : {};
2435
2436	    if (!main_core.Type.isStringFilled(options.id)) {
2437	      throw new Error('EntitySelector.Entity: "id" parameter is required.');
2438	    }
2439
2440	    var defaultOptions = this.constructor.getEntityDefaultOptions(options.id) || {};
2441	    options = main_core.Runtime.merge(JSON.parse(JSON.stringify(defaultOptions)), options);
2442	    this.id = options.id.toLowerCase();
2443	    this.options = main_core.Type.isPlainObject(options.options) ? options.options : {};
2444	    this.itemOptions = main_core.Type.isPlainObject(options.itemOptions) ? options.itemOptions : {};
2445	    this.tagOptions = main_core.Type.isPlainObject(options.tagOptions) ? options.tagOptions : {};
2446	    this.badgeOptions = main_core.Type.isArray(options.badgeOptions) ? options.badgeOptions : [];
2447
2448	    if (main_core.Type.isArray(options.filters)) {
2449	      options.filters.forEach(function (filterOptions) {
2450	        _this.addFilter(filterOptions);
2451	      });
2452	    }
2453
2454	    this.searchFields = new main_core_collections.OrderedArray(function (fieldA, fieldB) {
2455	      if (fieldA.getSort() !== null && fieldB.getSort() === null) {
2456	        return -1;
2457	      } else if (fieldA.getSort() === null && fieldB.getSort() !== null) {
2458	        return 1;
2459	      } else if (fieldA.getSort() === null && fieldB.getSort() === null) {
2460	        return -1;
2461	      } else {
2462	        return fieldA.getSort() - fieldB.getSort();
2463	      }
2464	    });
2465	    this.setSearchable(options.searchable);
2466	    this.setDynamicLoad(options.dynamicLoad);
2467	    this.setDynamicSearch(options.dynamicSearch);
2468	    this.setSearchFields(options.searchFields);
2469	    this.setSearchCacheLimits(options.searchCacheLimits);
2470	  }
2471
2472	  babelHelpers.createClass(Entity, [{
2473	    key: "getId",
2474	    value: function getId() {
2475	      return this.id;
2476	    }
2477	  }, {
2478	    key: "getOptions",
2479	    value: function getOptions() {
2480	      return this.options;
2481	    }
2482	  }, {
2483	    key: "getItemOptions",
2484	    value: function getItemOptions() {
2485	      return this.itemOptions;
2486	    }
2487	  }, {
2488	    key: "getItemOption",
2489	    value: function getItemOption(option, entityType) {
2490	      return this.constructor.getOptionInternal(this.itemOptions, option, entityType);
2491	    }
2492	  }, {
2493	    key: "getTagOptions",
2494	    value: function getTagOptions() {
2495	      return this.tagOptions;
2496	    }
2497	  }, {
2498	    key: "getTagOption",
2499	    value: function getTagOption(option, entityType) {
2500	      return this.constructor.getOptionInternal(this.tagOptions, option, entityType);
2501	    }
2502	  }, {
2503	    key: "getBadges",
2504	    value: function getBadges(item) {
2505	      var entityTypeBadges = this.getItemOption('badges', item.getEntityType()) || [];
2506	      var badges = babelHelpers.toConsumableArray(entityTypeBadges);
2507	      this.badgeOptions.forEach(function (badge) {
2508	        if (main_core.Type.isPlainObject(badge.conditions)) {
2509	          for (var condition in badge.conditions) {
2510	            if (item.getCustomData().get(condition) !== badge.conditions[condition]) {
2511	              return;
2512	            }
2513	          }
2514
2515	          badges.push(badge);
2516	        }
2517	      });
2518	      return badges;
2519	    }
2520	  }, {
2521	    key: "getOptionTextNode",
2522	    value: function getOptionTextNode(option, entityType) {
2523	      if (!main_core.Type.isString(option)) {
2524	        return null;
2525	      }
2526
2527	      if (!main_core.Type.isString(entityType)) {
2528	        entityType = 'default';
2529	      }
2530
2531	      var optionNodes = this.textNodes.get(option);
2532	      var node = optionNodes ? optionNodes.get(entityType) : undefined;
2533
2534	      if (main_core.Type.isUndefined(node)) {
2535	        if (!optionNodes) {
2536	          optionNodes = new Map();
2537	          this.textNodes.set(option, optionNodes);
2538	        }
2539
2540	        var itemOption = this.getItemOption(option, entityType);
2541	        node = main_core.Type.isString(itemOption) || main_core.Type.isPlainObject(itemOption) ? new TextNode(itemOption) : null;
2542	        optionNodes.set(entityType, node);
2543	      }
2544
2545	      return node;
2546	    }
2547	  }, {
2548	    key: "isSearchable",
2549	    value: function isSearchable() {
2550	      return this.searchable;
2551	    }
2552	  }, {
2553	    key: "setSearchable",
2554	    value: function setSearchable(flag) {
2555	      if (main_core.Type.isBoolean(flag)) {
2556	        this.searchable = flag;
2557	      }
2558	    }
2559	  }, {
2560	    key: "getSearchFields",
2561	    value: function getSearchFields() {
2562	      return this.searchFields;
2563	    }
2564	  }, {
2565	    key: "setSearchFields",
2566	    value: function setSearchFields(searchFields) {
2567	      var _this2 = this;
2568
2569	      this.searchFields.clear(); // Default Search Fields
2570
2571	      var titleField = new SearchField({
2572	        name: 'title',
2573	        searchable: true,
2574	        system: true,
2575	        type: 'string'
2576	      });
2577	      var subtitleField = new SearchField({
2578	        name: 'subtitle',
2579	        searchable: true,
2580	        system: true,
2581	        type: 'string'
2582	      });
2583	      this.searchFields.add(titleField);
2584	      this.searchFields.add(subtitleField); // Custom Search Fields
2585
2586	      var customFields = main_core.Type.isArray(searchFields) ? searchFields : [];
2587	      customFields.forEach(function (fieldOptions) {
2588	        var field = new SearchField(fieldOptions);
2589
2590	        if (field.isSystem()) // Entity can override default fields.
2591	          {
2592	            // delete a default title field
2593	            if (field.getName() === 'title') {
2594	              _this2.searchFields["delete"](titleField);
2595	            } else if (field.getName() === 'subtitle') {
2596	              _this2.searchFields["delete"](subtitleField);
2597	            }
2598	          }
2599
2600	        _this2.searchFields.add(field);
2601	      });
2602	      this.searchFields.forEach(function (field, index) {
2603	        field.setSort(index);
2604	      });
2605	    }
2606	  }, {
2607	    key: "setSearchCacheLimits",
2608	    value: function setSearchCacheLimits(limits) {
2609	      var _this3 = this;
2610
2611	      if (main_core.Type.isArrayFilled(limits)) {
2612	        limits.forEach(function (limit) {
2613	          if (main_core.Type.isStringFilled(limit)) {
2614	            _this3.searchCacheLimits.push(new RegExp(limit, 'i'));
2615	          }
2616	        });
2617	      }
2618	    }
2619	  }, {
2620	    key: "getSearchCacheLimits",
2621	    value: function getSearchCacheLimits() {
2622	      return this.searchCacheLimits;
2623	    }
2624	  }, {
2625	    key: "hasDynamicLoad",
2626	    value: function hasDynamicLoad() {
2627	      return this.dynamicLoad;
2628	    }
2629	  }, {
2630	    key: "setDynamicLoad",
2631	    value: function setDynamicLoad(flag) {
2632	      if (main_core.Type.isBoolean(flag)) {
2633	        this.dynamicLoad = flag;
2634	      }
2635	    }
2636	  }, {
2637	    key: "hasDynamicSearch",
2638	    value: function hasDynamicSearch() {
2639	      return this.dynamicSearch;
2640	    }
2641	  }, {
2642	    key: "setDynamicSearch",
2643	    value: function setDynamicSearch(flag) {
2644	      if (main_core.Type.isBoolean(flag)) {
2645	        this.dynamicSearch = flag;
2646	      }
2647	    }
2648	  }, {
2649	    key: "getFilters",
2650	    value: function getFilters() {
2651	      return Array.from(this.filters.values());
2652	    }
2653	  }, {
2654	    key: "addFilters",
2655	    value: function addFilters(filters) {
2656	      var _this4 = this;
2657
2658	      if (main_core.Type.isArray(filters)) {
2659	        filters.forEach(function (filterOptions) {
2660	          _this4.addFilter(filterOptions);
2661	        });
2662	      }
2663	    }
2664	  }, {
2665	    key: "addFilter",
2666	    value: function addFilter(filterOptions) {
2667	      if (main_core.Type.isPlainObject(filterOptions)) {
2668	        var filter = new EntityFilter(filterOptions);
2669	        this.filters.set(filter.getId(), filter);
2670	      }
2671	    }
2672	  }, {
2673	    key: "getFilter",
2674	    value: function getFilter(id) {
2675	      return this.filters.get(id) || null;
2676	    }
2677	  }, {
2678	    key: "toJSON",
2679	    value: function toJSON() {
2680	      return {
2681	        id: this.getId(),
2682	        options: this.getOptions(),
2683	        searchable: this.isSearchable(),
2684	        dynamicLoad: this.hasDynamicLoad(),
2685	        dynamicSearch: this.hasDynamicSearch(),
2686	        filters: this.getFilters()
2687	      };
2688	    }
2689	  }], [{
2690	    key: "getDefaultOptions",
2691	    value: function getDefaultOptions() {
2692	      var _this5 = this;
2693
2694	      if (this.defaultOptions === null) {
2695	        this.defaultOptions = {};
2696	        this.getExtensions().forEach(function (extension) {
2697	          var settings = main_core.Extension.getSettings(extension);
2698	          var entities = settings.get('entities', []);
2699	          entities.forEach(function (entity) {
2700	            if (main_core.Type.isStringFilled(entity.id) && main_core.Type.isPlainObject(entity.options)) {
2701	              _this5.defaultOptions[entity.id] = JSON.parse(JSON.stringify(entity.options)); // clone
2702	            }
2703	          });
2704	        });
2705	      }
2706
2707	      return this.defaultOptions;
2708	    }
2709	  }, {
2710	    key: "getExtensions",
2711	    value: function getExtensions() {
2712	      if (this.extensions === null) {
2713	        var settings = main_core.Extension.getSettings('ui.entity-selector');
2714	        this.extensions = settings.get('extensions', []);
2715	      }
2716
2717	      return this.extensions;
2718	    }
2719	  }, {
2720	    key: "getEntityDefaultOptions",
2721	    value: function getEntityDefaultOptions(entityId) {
2722	      return this.getDefaultOptions()[entityId] || null;
2723	    }
2724	  }, {
2725	    key: "getItemOptions",
2726	    value: function getItemOptions(entityId, entityType) {
2727	      if (!main_core.Type.isStringFilled(entityId)) {
2728	        return null;
2729	      }
2730
2731	      var options = this.getEntityDefaultOptions(entityId);
2732	      var itemOptions = options && options['itemOptions'] ? options['itemOptions'] : null;
2733
2734	      if (main_core.Type.isUndefined(entityType)) {
2735	        return itemOptions;
2736	      } else {
2737	        return itemOptions && !main_core.Type.isUndefined(itemOptions[entityType]) ? itemOptions[entityType] : null;
2738	      }
2739	    }
2740	  }, {
2741	    key: "getTagOptions",
2742	    value: function getTagOptions(entityId, entityType) {
2743	      if (!main_core.Type.isStringFilled(entityId)) {
2744	        return null;
2745	      }
2746
2747	      var options = this.getEntityDefaultOptions(entityId);
2748	      var tagOptions = options && options['tagOptions'] ? options['tagOptions'] : null;
2749
2750	      if (main_core.Type.isUndefined(entityType)) {
2751	        return tagOptions;
2752	      } else {
2753	        return tagOptions && !main_core.Type.isUndefined(tagOptions[entityType]) ? tagOptions[entityType] : null;
2754	      }
2755	    }
2756	  }, {
2757	    key: "getItemOption",
2758	    value: function getItemOption(entityId, option, entityType) {
2759	      return this.getOptionInternal(this.getItemOptions(entityId), option, entityType);
2760	    }
2761	  }, {
2762	    key: "getTagOption",
2763	    value: function getTagOption(entityId, option, entityType) {
2764	      return this.getOptionInternal(this.getTagOptions(entityId), option, entityType);
2765	    }
2766	  }, {
2767	    key: "getOptionInternal",
2768	    value: function getOptionInternal(options, option, type) {
2769	      if (!main_core.Type.isPlainObject(options)) {
2770	        return null;
2771	      }
2772
2773	      if (options[type] && !main_core.Type.isUndefined(options[type][option])) {
2774	        return options[type][option];
2775	      } else if (options['default'] && !main_core.Type.isUndefined(options['default'][option])) {
2776	        return options['default'][option];
2777	      }
2778
2779	      return null;
2780	    }
2781	  }]);
2782	  return Entity;
2783	}();
2784
2785	babelHelpers.defineProperty(Entity, "extensions", null);
2786	babelHelpers.defineProperty(Entity, "defaultOptions", null);
2787
2788	var TypeUtils = /*#__PURE__*/function () {
2789	  function TypeUtils() {
2790	    babelHelpers.classCallCheck(this, TypeUtils);
2791	  }
2792
2793	  babelHelpers.createClass(TypeUtils, null, [{
2794	    key: "createMapFromOptions",
2795	    value: function createMapFromOptions(options) {
2796	      if (main_core.Type.isPlainObject(options)) {
2797	        return new Map(Object.entries(options));
2798	      }
2799
2800	      var map = new Map();
2801
2802	      if (main_core.Type.isArrayFilled(options)) {
2803	        options.forEach(function (element) {
2804	          if (main_core.Type.isArray(element) && element.length === 2 && main_core.Type.isString(element[0])) {
2805	            map.set(element[0], element[1]);
2806	          }
2807	        });
2808	      }
2809
2810	      return map;
2811	    }
2812	  }, {
2813	    key: "convertMapToObject",
2814	    value: function convertMapToObject(map) {
2815	      var obj = {};
2816
2817	      if (main_core.Type.isMap(map)) {
2818	        map.forEach(function (value, key) {
2819	          if (main_core.Type.isString(key)) {
2820	            obj[key] = value;
2821	          }
2822	        });
2823	      }
2824
2825	      return obj;
2826	    }
2827	  }]);
2828	  return TypeUtils;
2829	}();
2830
2831	function _classPrivateMethodInitSpec$1(obj, privateSet) { _checkPrivateRedeclaration$1(obj, privateSet); privateSet.add(obj); }
2832
2833	function _checkPrivateRedeclaration$1(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
2834
2835	function _classPrivateMethodGet$1(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
2836
2837	var _renderNodes = /*#__PURE__*/new WeakSet();
2838
2839	/**
2840	 * @memberof BX.UI.EntitySelector
2841	 * @package ui.entity-selector
2842	 */
2843	var Item = /*#__PURE__*/function () {
2844	  function Item(itemOptions) {
2845	    babelHelpers.classCallCheck(this, Item);
2846
2847	    _classPrivateMethodInitSpec$1(this, _renderNodes);
2848
2849	    babelHelpers.defineProperty(this, "id", null);
2850	    babelHelpers.defineProperty(this, "entityId", null);
2851	    babelHelpers.defineProperty(this, "entityType", null);
2852	    babelHelpers.defineProperty(this, "title", null);
2853	    babelHelpers.defineProperty(this, "subtitle", null);
2854	    babelHelpers.defineProperty(this, "supertitle", null);
2855	    babelHelpers.defineProperty(this, "caption", null);
2856	    babelHelpers.defineProperty(this, "captionOptions", {});
2857	    babelHelpers.defineProperty(this, "avatar", null);
2858	    babelHelpers.defineProperty(this, "avatarOptions", null);
2859	    babelHelpers.defineProperty(this, "textColor", null);
2860	    babelHelpers.defineProperty(this, "link", null);
2861	    babelHelpers.defineProperty(this, "linkTitle", null);
2862	    babelHelpers.defineProperty(this, "tagOptions", null);
2863	    babelHelpers.defineProperty(this, "badges", null);
2864	    babelHelpers.defineProperty(this, "badgesOptions", {});
2865	    babelHelpers.defineProperty(this, "dialog", null);
2866	    babelHelpers.defineProperty(this, "nodes", new Set());
2867	    babelHelpers.defineProperty(this, "selected", false);
2868	    babelHelpers.defineProperty(this, "searchable", true);
2869	    babelHelpers.defineProperty(this, "saveable", true);
2870	    babelHelpers.defineProperty(this, "deselectable", true);
2871	    babelHelpers.defineProperty(this, "hidden", false);
2872	    babelHelpers.defineProperty(this, "searchIndex", null);
2873	    babelHelpers.defineProperty(this, "customData", null);
2874	    babelHelpers.defineProperty(this, "sort", null);
2875	    babelHelpers.defineProperty(this, "contextSort", null);
2876	    babelHelpers.defineProperty(this, "globalSort", null);
2877	    var options = main_core.Type.isPlainObject(itemOptions) ? itemOptions : {};
2878
2879	    if (!main_core.Type.isStringFilled(options.id) && !main_core.Type.isNumber(options.id)) {
2880	      throw new Error('EntitySelector.Item: "id" parameter is required.');
2881	    }
2882
2883	    if (!main_core.Type.isStringFilled(options.entityId)) {
2884	      throw new Error('EntitySelector.Item: "entityId" parameter is required.');
2885	    }
2886
2887	    this.id = options.id;
2888	    this.entityId = options.entityId.toLowerCase();
2889	    this.entityType = main_core.Type.isStringFilled(options.entityType) ? options.entityType : 'default';
2890	    this.selected = main_core.Type.isBoolean(options.selected) ? options.selected : false;
2891	    this.customData = TypeUtils.createMapFromOptions(options.customData);
2892	    this.tagOptions = TypeUtils.createMapFromOptions(options.tagOptions);
2893	    this.setTitle(options.title);
2894	    this.setSubtitle(options.subtitle);
2895	    this.setSupertitle(options.supertitle);
2896	    this.setCaption(options.caption);
2897	    this.setCaptionOptions(options.captionOptions);
2898	    this.setAvatar(options.avatar);
2899	    this.setAvatarOptions(options.avatarOptions);
2900	    this.setTextColor(options.textColor);
2901	    this.setLink(options.link);
2902	    this.setLinkTitle(options.linkTitle);
2903	    this.setBadges(options.badges);
2904	    this.setBadgesOptions(options.badgesOptions);
2905	    this.setSearchable(options.searchable);
2906	    this.setSaveable(options.saveable);
2907	    this.setDeselectable(options.deselectable);
2908	    this.setHidden(options.hidden);
2909	    this.setContextSort(options.contextSort);
2910	    this.setGlobalSort(options.globalSort);
2911	    this.setSort(options.sort);
2912	  }
2913
2914	  babelHelpers.createClass(Item, [{
2915	    key: "getId",
2916	    value: function getId() {
2917	      return this.id;
2918	    }
2919	  }, {
2920	    key: "getEntityId",
2921	    value: function getEntityId() {
2922	      return this.entityId;
2923	    }
2924	  }, {
2925	    key: "getEntity",
2926	    value: function getEntity() {
2927	      var entity = this.getDialog().getEntity(this.getEntityId());
2928
2929	      if (entity === null) {
2930	        entity = new Entity({
2931	          id: this.getEntityId()
2932	        });
2933	        this.getDialog().addEntity(entity);
2934	      }
2935
2936	      return entity;
2937	    }
2938	  }, {
2939	    key: "getEntityType",
2940	    value: function getEntityType() {
2941	      return this.entityType;
2942	    }
2943	  }, {
2944	    key: "getTitle",
2945	    value: function getTitle() {
2946	      var titleNode = this.getTitleNode();
2947	      return titleNode !== null && !titleNode.isNullable() ? titleNode.getText() : '';
2948	    }
2949	  }, {
2950	    key: "getTitleNode",
2951	    value: function getTitleNode() {
2952	      return this.title;
2953	    }
2954	  }, {
2955	    key: "setTitle",
2956	    value: function setTitle(title) {
2957	      if (main_core.Type.isStringFilled(title) || main_core.Type.isPlainObject(title) || title === null) {
2958	        this.title = title === null ? null : new TextNode(title);
2959	        this.resetSearchIndex();
2960
2961	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
2962	      }
2963	    }
2964	  }, {
2965	    key: "getSubtitle",
2966	    value: function getSubtitle() {
2967	      var subtitleNode = this.getSubtitleNode();
2968	      return subtitleNode !== null ? subtitleNode.getText() : null;
2969	    }
2970	  }, {
2971	    key: "getSubtitleNode",
2972	    value: function getSubtitleNode() {
2973	      return this.subtitle !== null ? this.subtitle : this.getEntityTextNode('subtitle');
2974	    }
2975	  }, {
2976	    key: "setSubtitle",
2977	    value: function setSubtitle(subtitle) {
2978	      if (main_core.Type.isString(subtitle) || main_core.Type.isPlainObject(subtitle) || subtitle === null) {
2979	        this.subtitle = subtitle === null ? null : new TextNode(subtitle);
2980	        this.resetSearchIndex();
2981
2982	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
2983	      }
2984	    }
2985	  }, {
2986	    key: "getSupertitle",
2987	    value: function getSupertitle() {
2988	      var supertitleNode = this.getSupertitleNode();
2989	      return supertitleNode !== null ? supertitleNode.getText() : null;
2990	    }
2991	  }, {
2992	    key: "getSupertitleNode",
2993	    value: function getSupertitleNode() {
2994	      return this.supertitle !== null ? this.supertitle : this.getEntityTextNode('supertitle');
2995	    }
2996	  }, {
2997	    key: "setSupertitle",
2998	    value: function setSupertitle(supertitle) {
2999	      if (main_core.Type.isString(supertitle) || main_core.Type.isPlainObject(supertitle) || supertitle === null) {
3000	        this.supertitle = supertitle === null ? null : new TextNode(supertitle);
3001	        this.resetSearchIndex();
3002
3003	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3004	      }
3005	    }
3006	  }, {
3007	    key: "getCaption",
3008	    value: function getCaption() {
3009	      var captionNode = this.getCaptionNode();
3010	      return captionNode !== null ? captionNode.getText() : null;
3011	    }
3012	  }, {
3013	    key: "getCaptionNode",
3014	    value: function getCaptionNode() {
3015	      return this.caption !== null ? this.caption : this.getEntityTextNode('caption');
3016	    }
3017	  }, {
3018	    key: "setCaption",
3019	    value: function setCaption(caption) {
3020	      if (main_core.Type.isString(caption) || main_core.Type.isPlainObject(caption) || caption === null) {
3021	        this.caption = caption === null ? null : new TextNode(caption);
3022	        this.resetSearchIndex();
3023
3024	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3025	      }
3026	    }
3027	  }, {
3028	    key: "getCaptionOption",
3029	    value: function getCaptionOption(option) {
3030	      if (!main_core.Type.isUndefined(this.captionOptions[option])) {
3031	        return this.captionOptions[option];
3032	      }
3033
3034	      var captionOptions = this.getEntityItemOption('captionOptions');
3035
3036	      if (main_core.Type.isPlainObject(captionOptions) && !main_core.Type.isUndefined(captionOptions[option])) {
3037	        return captionOptions[option];
3038	      }
3039
3040	      return null;
3041	    }
3042	  }, {
3043	    key: "setCaptionOption",
3044	    value: function setCaptionOption(option, value) {
3045	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
3046	        this.captionOptions[option] = value;
3047
3048	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3049	      }
3050	    }
3051	  }, {
3052	    key: "setCaptionOptions",
3053	    value: function setCaptionOptions(options) {
3054	      var _this = this;
3055
3056	      if (main_core.Type.isPlainObject(options)) {
3057	        Object.keys(options).forEach(function (option) {
3058	          _this.setCaptionOption(option, options[option]);
3059	        });
3060	      }
3061	    }
3062	  }, {
3063	    key: "getAvatar",
3064	    value: function getAvatar() {
3065	      return this.avatar !== null ? this.avatar : this.getEntityItemOption('avatar');
3066	    }
3067	  }, {
3068	    key: "setAvatar",
3069	    value: function setAvatar(avatar) {
3070	      if (main_core.Type.isString(avatar) || avatar === null) {
3071	        this.avatar = avatar;
3072
3073	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3074	      }
3075	    }
3076	  }, {
3077	    key: "getAvatarOption",
3078	    value: function getAvatarOption(option) {
3079	      if (this.avatarOptions !== null && !main_core.Type.isUndefined(this.avatarOptions[option])) {
3080	        return this.avatarOptions[option];
3081	      }
3082
3083	      var avatarOptions = this.getEntityItemOption('avatarOptions');
3084
3085	      if (main_core.Type.isPlainObject(avatarOptions) && !main_core.Type.isUndefined(avatarOptions[option])) {
3086	        return avatarOptions[option];
3087	      }
3088
3089	      return null;
3090	    }
3091	  }, {
3092	    key: "setAvatarOption",
3093	    value: function setAvatarOption(option, value) {
3094	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
3095	        if (this.avatarOptions === null) {
3096	          this.avatarOptions = {};
3097	        }
3098
3099	        this.avatarOptions[option] = value;
3100
3101	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3102	      }
3103	    }
3104	  }, {
3105	    key: "setAvatarOptions",
3106	    value: function setAvatarOptions(options) {
3107	      var _this2 = this;
3108
3109	      if (main_core.Type.isPlainObject(options)) {
3110	        Object.keys(options).forEach(function (option) {
3111	          _this2.setAvatarOption(option, options[option]);
3112	        });
3113	      }
3114	    }
3115	  }, {
3116	    key: "getTextColor",
3117	    value: function getTextColor() {
3118	      return this.textColor !== null ? this.textColor : this.getEntityItemOption('textColor');
3119	    }
3120	  }, {
3121	    key: "setTextColor",
3122	    value: function setTextColor(textColor) {
3123	      if (main_core.Type.isString(textColor) || textColor === null) {
3124	        this.textColor = textColor;
3125
3126	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3127	      }
3128	    }
3129	  }, {
3130	    key: "getLink",
3131	    value: function getLink() {
3132	      var link = this.link !== null ? this.link : this.getEntityItemOption('link');
3133	      return this.replaceMacros(link);
3134	    }
3135	  }, {
3136	    key: "setLink",
3137	    value: function setLink(link) {
3138	      if (main_core.Type.isString(link) || link === null) {
3139	        this.link = link;
3140
3141	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3142	      }
3143	    }
3144	  }, {
3145	    key: "getLinkTitle",
3146	    value: function getLinkTitle() {
3147	      var linkTitleNode = this.getLinkTitleNode();
3148	      return linkTitleNode !== null ? linkTitleNode.getText() : main_core.Loc.getMessage('UI_SELECTOR_ITEM_LINK_TITLE');
3149	    }
3150	  }, {
3151	    key: "getLinkTitleNode",
3152	    value: function getLinkTitleNode() {
3153	      return this.linkTitle !== null ? this.linkTitle : this.getEntityTextNode('linkTitle');
3154	    }
3155	  }, {
3156	    key: "setLinkTitle",
3157	    value: function setLinkTitle(linkTitle) {
3158	      if (main_core.Type.isString(linkTitle) || main_core.Type.isPlainObject(linkTitle) || linkTitle === null) {
3159	        this.linkTitle = linkTitle === null ? null : new TextNode(linkTitle);
3160
3161	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3162	      }
3163	    }
3164	  }, {
3165	    key: "getBadges",
3166	    value: function getBadges() {
3167	      if (this.badges !== null) {
3168	        return this.badges;
3169	      }
3170
3171	      var badges = this.getEntity().getBadges(this);
3172
3173	      if (main_core.Type.isArray(badges)) {
3174	        this.setBadges(badges);
3175	      } else {
3176	        this.badges = [];
3177	      }
3178
3179	      return this.badges;
3180	    }
3181	  }, {
3182	    key: "setBadges",
3183	    value: function setBadges(badges) {
3184	      var _this3 = this;
3185
3186	      if (main_core.Type.isArray(badges)) {
3187	        this.badges = [];
3188	        badges.forEach(function (badge) {
3189	          _this3.badges.push(new ItemBadge(badge));
3190	        });
3191
3192	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3193	      } else if (badges === null) {
3194	        this.badges = null;
3195
3196	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3197	      }
3198	    }
3199	  }, {
3200	    key: "getBadgesOption",
3201	    value: function getBadgesOption(option) {
3202	      if (!main_core.Type.isUndefined(this.badgesOptions[option])) {
3203	        return this.badgesOptions[option];
3204	      }
3205
3206	      var badgesOptions = this.getEntityItemOption('badgesOptions');
3207
3208	      if (main_core.Type.isPlainObject(badgesOptions) && !main_core.Type.isUndefined(badgesOptions[option])) {
3209	        return badgesOptions[option];
3210	      }
3211
3212	      return null;
3213	    }
3214	  }, {
3215	    key: "setBadgesOption",
3216	    value: function setBadgesOption(option, value) {
3217	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
3218	        this.badgesOptions[option] = value;
3219
3220	        _classPrivateMethodGet$1(this, _renderNodes, _renderNodes2).call(this);
3221	      }
3222	    }
3223	  }, {
3224	    key: "setBadgesOptions",
3225	    value: function setBadgesOptions(options) {
3226	      var _this4 = this;
3227
3228	      if (main_core.Type.isPlainObject(options)) {
3229	        Object.keys(options).forEach(function (option) {
3230	          _this4.setBadgesOption(option, options[option]);
3231	        });
3232	      }
3233	    }
3234	    /**
3235	     * @internal
3236	     */
3237
3238	  }, {
3239	    key: "setDialog",
3240	    value: function setDialog(dialog) {
3241	      this.dialog = dialog;
3242	    }
3243	  }, {
3244	    key: "getDialog",
3245	    value: function getDialog() {
3246	      return this.dialog;
3247	    }
3248	  }, {
3249	    key: "createNode",
3250	    value: function createNode(nodeOptions) {
3251	      var itemNode = new ItemNode(this, nodeOptions);
3252	      this.nodes.add(itemNode);
3253	      return itemNode;
3254	    }
3255	  }, {
3256	    key: "removeNode",
3257	    value: function removeNode(node) {
3258	      this.nodes["delete"](node);
3259	    }
3260	  }, {
3261	    key: "getNodes",
3262	    value: function getNodes() {
3263	      return this.nodes;
3264	    }
3265	  }, {
3266	    key: "select",
3267	    value: function select() {
3268	      var preselectedMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
3269
3270	      if (this.selected) {
3271	        return;
3272	      }
3273
3274	      var dialog = this.getDialog();
3275	      var emitEvents = dialog && !preselectedMode;
3276
3277	      if (emitEvents) {
3278	        var event = new main_core_events.BaseEvent({
3279	          data: {
3280	            item: this
3281	          }
3282	        });
3283	        dialog.emit('Item:onBeforeSelect', event);
3284
3285	        if (event.isDefaultPrevented()) {
3286	          return;
3287	        }
3288	      }
3289
3290	      this.selected = true;
3291
3292	      if (dialog) {
3293	        dialog.handleItemSelect(this, !preselectedMode);
3294	      }
3295
3296	      if (this.isRendered()) {
3297	        this.getNodes().forEach(function (node) {
3298	          node.select();
3299	        });
3300	      }
3301
3302	      if (emitEvents) {
3303	        dialog.emit('Item:onSelect', {
3304	          item: this
3305	        });
3306	        dialog.saveRecentItem(this);
3307	      }
3308	    }
3309	  }, {
3310	    key: "deselect",
3311	    value: function deselect() {
3312	      if (!this.selected) {
3313	        return;
3314	      }
3315
3316	      var dialog = this.getDialog();
3317
3318	      if (dialog) {
3319	        var event = new main_core_events.BaseEvent({
3320	          data: {
3321	            item: this
3322	          }
3323	        });
3324	        dialog.emit('Item:onBeforeDeselect', event);
3325
3326	        if (event.isDefaultPrevented()) {
3327	          return;
3328	        }
3329	      }
3330
3331	      this.selected = false;
3332
3333	      if (this.isRendered()) {
3334	        this.getNodes().forEach(function (node) {
3335	          node.deselect();
3336	        });
3337	      }
3338
3339	      if (dialog) {
3340	        dialog.handleItemDeselect(this);
3341	        dialog.emit('Item:onDeselect', {
3342	          item: this
3343	        });
3344	      }
3345	    }
3346	  }, {
3347	    key: "isSelected",
3348	    value: function isSelected() {
3349	      return this.selected;
3350	    }
3351	  }, {
3352	    key: "setSearchable",
3353	    value: function setSearchable(flag) {
3354	      if (main_core.Type.isBoolean(flag)) {
3355	        this.searchable = flag;
3356	      }
3357	    }
3358	  }, {
3359	    key: "isSearchable",
3360	    value: function isSearchable() {
3361	      return this.searchable;
3362	    }
3363	  }, {
3364	    key: "setSaveable",
3365	    value: function setSaveable(flag) {
3366	      if (main_core.Type.isBoolean(flag)) {
3367	        this.saveable = flag;
3368	      }
3369	    }
3370	  }, {
3371	    key: "isSaveable",
3372	    value: function isSaveable() {
3373	      return this.saveable;
3374	    }
3375	  }, {
3376	    key: "setDeselectable",
3377	    value: function setDeselectable(flag) {
3378	      if (main_core.Type.isBoolean(flag)) {
3379	        this.deselectable = flag;
3380
3381	        if (this.getDialog() && this.getDialog().getTagSelector()) {
3382	          var tag = this.getDialog().getTagSelector().getTag({
3383	            id: this.getId(),
3384	            entityId: this.getEntityId()
3385	          });
3386
3387	          if (tag) {
3388	            tag.setDeselectable(flag);
3389	          }
3390	        }
3391	      }
3392	    }
3393	  }, {
3394	    key: "isDeselectable",
3395	    value: function isDeselectable() {
3396	      return this.deselectable;
3397	    }
3398	  }, {
3399	    key: "setHidden",
3400	    value: function setHidden(flag) {
3401	      if (main_core.Type.isBoolean(flag)) {
3402	        this.hidden = flag;
3403
3404	        if (this.isRendered()) {
3405	          this.getNodes().forEach(function (node) {
3406	            node.setHidden(flag);
3407	          });
3408	        }
3409	      }
3410	    }
3411	  }, {
3412	    key: "isHidden",
3413	    value: function isHidden() {
3414	      return this.hidden;
3415	    }
3416	  }, {
3417	    key: "setContextSort",
3418	    value: function setContextSort(sort) {
3419	      if (main_core.Type.isNumber(sort) || sort === null) {
3420	        this.contextSort = sort;
3421	      }
3422	    }
3423	  }, {
3424	    key: "getContextSort",
3425	    value: function getContextSort() {
3426	      return this.contextSort;
3427	    }
3428	  }, {
3429	    key: "setGlobalSort",
3430	    value: function setGlobalSort(sort) {
3431	      if (main_core.Type.isNumber(sort) || sort === null) {
3432	        this.globalSort = sort;
3433	      }
3434	    }
3435	  }, {
3436	    key: "getGlobalSort",
3437	    value: function getGlobalSort() {
3438	      return this.globalSort;
3439	    }
3440	  }, {
3441	    key: "setSort",
3442	    value: function setSort(sort) {
3443	      if (main_core.Type.isNumber(sort) || sort === null) {
3444	        this.sort = sort;
3445	      }
3446	    }
3447	  }, {
3448	    key: "getSort",
3449	    value: function getSort() {
3450	      return this.sort;
3451	    }
3452	  }, {
3453	    key: "getSearchIndex",
3454	    value: function getSearchIndex() {
3455	      if (this.searchIndex === null) {
3456	        this.searchIndex = SearchIndex.create(this);
3457	      }
3458
3459	      return this.searchIndex;
3460	    }
3461	  }, {
3462	    key: "resetSearchIndex",
3463	    value: function resetSearchIndex() {
3464	      this.searchIndex = null;
3465	    }
3466	  }, {
3467	    key: "getCustomData",
3468	    value: function getCustomData() {
3469	      return this.customData;
3470	    }
3471	  }, {
3472	    key: "isRendered",
3473	    value: function isRendered() {
3474	      return this.getDialog() && this.getDialog().isRendered();
3475	    }
3476	  }, {
3477	    key: "getEntityItemOption",
3478	    value: function getEntityItemOption(option) {
3479	      return this.getEntity().getItemOption(option, this.getEntityType());
3480	    }
3481	  }, {
3482	    key: "getEntityTagOption",
3483	    value: function getEntityTagOption(option) {
3484	      return this.getEntity().getTagOption(option, this.getEntityType());
3485	    }
3486	  }, {
3487	    key: "getEntityTextNode",
3488	    value: function getEntityTextNode(option) {
3489	      return this.getEntity().getOptionTextNode(option, this.getEntityType());
3490	    }
3491	  }, {
3492	    key: "getTagOptions",
3493	    value: function getTagOptions() {
3494	      return this.tagOptions;
3495	    }
3496	  }, {
3497	    key: "getTagOption",
3498	    value: function getTagOption(option) {
3499	      var value = this.getTagOptions().get(option);
3500
3501	      if (!main_core.Type.isUndefined(value)) {
3502	        return value;
3503	      }
3504
3505	      return null;
3506	    }
3507	  }, {
3508	    key: "getTagGlobalOption",
3509	    value: function getTagGlobalOption(option) {
3510	      var useItemOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3511
3512	      if (!main_core.Type.isStringFilled(option)) {
3513	        return null;
3514	      }
3515
3516	      var value = this.getTagOption(option);
3517
3518	      if (value === null && useItemOptions === true && this[option] !== null) {
3519	        value = this[option];
3520	      }
3521
3522	      if (value === null && this.getDialog().getTagSelector()) {
3523	        var fn = "getTag".concat(main_core.Text.toPascalCase(option));
3524
3525	        if (main_core.Type.isFunction(this.getDialog().getTagSelector()[fn])) {
3526	          value = this.getDialog().getTagSelector()[fn]();
3527	        }
3528	      }
3529
3530	      if (value === null) {
3531	        value = this.getEntityTagOption(option);
3532	      }
3533
3534	      if (value === null && useItemOptions === true) {
3535	        value = this.getEntityItemOption(option);
3536	      }
3537
3538	      return value;
3539	    }
3540	  }, {
3541	    key: "getTagBgColor",
3542	    value: function getTagBgColor() {
3543	      return this.getTagGlobalOption('bgColor');
3544	    }
3545	  }, {
3546	    key: "getTagTextColor",
3547	    value: function getTagTextColor() {
3548	      return this.getTagGlobalOption('textColor');
3549	    }
3550	  }, {
3551	    key: "getTagMaxWidth",
3552	    value: function getTagMaxWidth() {
3553	      return this.getTagGlobalOption('maxWidth');
3554	    }
3555	  }, {
3556	    key: "getTagFontWeight",
3557	    value: function getTagFontWeight() {
3558	      return this.getTagGlobalOption('fontWeight');
3559	    }
3560	  }, {
3561	    key: "getTagAvatar",
3562	    value: function getTagAvatar() {
3563	      return this.getTagGlobalOption('avatar', true);
3564	    }
3565	  }, {
3566	    key: "getTagAvatarOptions",
3567	    value: function getTagAvatarOptions() {
3568	      return this.getTagGlobalOption('avatarOptions', true);
3569	    }
3570	  }, {
3571	    key: "getTagLink",
3572	    value: function getTagLink() {
3573	      return this.replaceMacros(this.getTagGlobalOption('link', true));
3574	    }
3575	    /**
3576	     * @internal
3577	     */
3578
3579	  }, {
3580	    key: "replaceMacros",
3581	    value: function replaceMacros(str) {
3582	      if (!main_core.Type.isStringFilled(str)) {
3583	        return str;
3584	      }
3585
3586	      return str.replace(/#id#/i, this.getId()).replace(/#element_id#/i, this.getId());
3587	    }
3588	    /**
3589	     * @internal
3590	     */
3591
3592	  }, {
3593	    key: "createTag",
3594	    value: function createTag() {
3595	      return {
3596	        id: this.getId(),
3597	        entityId: this.getEntityId(),
3598	        entityType: this.getEntityType(),
3599	        title: this.getTagOption('title') || this.getTitleNode() && this.getTitleNode().toJSON() || '',
3600	        deselectable: this.isDeselectable(),
3601	        avatar: this.getTagAvatar(),
3602	        avatarOptions: this.getTagAvatarOptions(),
3603	        link: this.getTagLink(),
3604	        maxWidth: this.getTagMaxWidth(),
3605	        textColor: this.getTagTextColor(),
3606	        bgColor: this.getTagBgColor(),
3607	        fontWeight: this.getTagFontWeight()
3608	      };
3609	    }
3610	  }, {
3611	    key: "getAjaxJson",
3612	    value: function getAjaxJson() {
3613	      return this.toJSON();
3614	    }
3615	  }, {
3616	    key: "toJSON",
3617	    value: function toJSON() {
3618	      return {
3619	        id: this.getId(),
3620	        entityId: this.getEntityId(),
3621	        entityType: this.getEntityType(),
3622	        selected: this.isSelected(),
3623	        deselectable: this.isDeselectable(),
3624	        searchable: this.isSearchable(),
3625	        saveable: this.isSaveable(),
3626	        hidden: this.isHidden(),
3627	        title: this.getTitleNode(),
3628	        link: this.getLink(),
3629	        linkTitle: this.getLinkTitleNode(),
3630	        subtitle: this.getSubtitleNode(),
3631	        supertitle: this.getSupertitleNode(),
3632	        caption: this.getCaptionNode(),
3633	        avatar: this.getAvatar(),
3634	        textColor: this.getTextColor(),
3635	        sort: this.getSort(),
3636	        contextSort: this.getContextSort(),
3637	        globalSort: this.getGlobalSort(),
3638	        customData: TypeUtils.convertMapToObject(this.getCustomData()),
3639	        tagOptions: TypeUtils.convertMapToObject(this.getTagOptions()),
3640	        badges: this.getBadges()
3641	      };
3642	    }
3643	  }]);
3644	  return Item;
3645	}();
3646
3647	function _renderNodes2() {
3648	  if (this.isRendered()) {
3649	    this.getNodes().forEach(function (node) {
3650	      node.render();
3651	    });
3652	  }
3653	}
3654
3655	var _templateObject;
3656
3657	var BaseStub = /*#__PURE__*/function () {
3658	  function BaseStub(tab, options) {
3659	    babelHelpers.classCallCheck(this, BaseStub);
3660	    babelHelpers.defineProperty(this, "tab", null);
3661	    babelHelpers.defineProperty(this, "autoShow", true);
3662	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
3663	    babelHelpers.defineProperty(this, "content", null);
3664	    this.options = main_core.Type.isPlainObject(options) ? options : {};
3665	    this.tab = tab;
3666	    this.autoShow = this.getOption('autoShow', true);
3667	  }
3668	  /**
3669	   * @abstract
3670	   */
3671
3672
3673	  babelHelpers.createClass(BaseStub, [{
3674	    key: "render",
3675	    value: function render() {
3676	      throw new Error('You must implement render() method.');
3677	    }
3678	  }, {
3679	    key: "getTab",
3680	    value: function getTab() {
3681	      return this.tab;
3682	    }
3683	  }, {
3684	    key: "getOuterContainer",
3685	    value: function getOuterContainer() {
3686	      var _this = this;
3687
3688	      return this.cache.remember('outer-container', function () {
3689	        return main_core.Tag.render(_templateObject || (_templateObject = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tab-stub\">", "</div>\n\t\t\t"])), _this.render());
3690	      });
3691	    }
3692	  }, {
3693	    key: "isAutoShow",
3694	    value: function isAutoShow() {
3695	      return this.autoShow;
3696	    }
3697	  }, {
3698	    key: "show",
3699	    value: function show() {
3700	      main_core.Dom.append(this.getOuterContainer(), this.getTab().getContainer());
3701	      /*requestAnimationFrame(() => {
3702	      	Dom.addClass(this.getOuterContainer(), 'ui-selector-tab-stub--show');
3703	      });*/
3704	    }
3705	  }, {
3706	    key: "hide",
3707	    value: function hide() {
3708	      // Dom.removeClass(this.getOuterContainer(), 'ui-selector-tab-stub--show');
3709	      main_core.Dom.remove(this.getOuterContainer());
3710	    }
3711	  }, {
3712	    key: "getOptions",
3713	    value: function getOptions() {
3714	      return this.options;
3715	    }
3716	  }, {
3717	    key: "getOption",
3718	    value: function getOption(option, defaultValue) {
3719	      if (!main_core.Type.isUndefined(this.options[option])) {
3720	        return this.options[option];
3721	      } else if (!main_core.Type.isUndefined(defaultValue)) {
3722	        return defaultValue;
3723	      }
3724
3725	      return null;
3726	    }
3727	  }]);
3728	  return BaseStub;
3729	}();
3730
3731	var _templateObject$1, _templateObject2, _templateObject3, _templateObject4;
3732
3733	var DefaultStub = /*#__PURE__*/function (_BaseStub) {
3734	  babelHelpers.inherits(DefaultStub, _BaseStub);
3735
3736	  function DefaultStub(tab, options) {
3737	    var _this;
3738
3739	    babelHelpers.classCallCheck(this, DefaultStub);
3740	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(DefaultStub).call(this, tab, options));
3741	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "content", null);
3742	    return _this;
3743	  }
3744
3745	  babelHelpers.createClass(DefaultStub, [{
3746	    key: "getContainer",
3747	    value: function getContainer() {
3748	      var _this2 = this;
3749
3750	      return this.cache.remember('container', function () {
3751	        var subtitle = _this2.getOption('subtitle');
3752
3753	        var title = main_core.Type.isStringFilled(_this2.getOption('title')) ? _this2.getOption('title') : _this2.getDefaultTitle();
3754
3755	        var icon = _this2.getOption('icon') || _this2.getTab().getIcon('default');
3756
3757	        var iconOpacity = 35;
3758
3759	        if (main_core.Type.isNumber(_this2.getOption('iconOpacity'))) {
3760	          iconOpacity = Math.min(100, Math.max(0, _this2.getOption('iconOpacity')));
3761	        }
3762
3763	        var iconStyle = main_core.Type.isStringFilled(icon) ? "style=\"background-image: url('".concat(encodeUrl(icon), "'); opacity: ").concat(iconOpacity / 100, ";\"") : '';
3764	        var arrow = _this2.getOption('arrow', false) && _this2.getTab().getDialog().getActiveFooter() !== null;
3765	        return main_core.Tag.render(_templateObject$1 || (_templateObject$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tab-default-stub\">\n\t\t\t\t\t<div class=\"ui-selector-tab-default-stub-icon\" ", "></div>\n\t\t\t\t\t<div class=\"ui-selector-tab-default-stub-titles\">\n\t\t\t\t\t\t<div class=\"ui-selector-tab-default-stub-title\">", "</div>\n\t\t\t\t\t\t", "\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), iconStyle, title, subtitle ? main_core.Tag.render(_templateObject2 || (_templateObject2 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-tab-default-stub-subtitle\">", "</div>"])), subtitle) : '', arrow ? main_core.Tag.render(_templateObject3 || (_templateObject3 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-tab-default-stub-arrow\"></div>"]))) : '');
3766	      });
3767	    }
3768	  }, {
3769	    key: "getDefaultTitle",
3770	    value: function getDefaultTitle() {
3771	      var titleNode = this.getTab().getTitleNode();
3772	      var titleContainer = main_core.Tag.render(_templateObject4 || (_templateObject4 = babelHelpers.taggedTemplateLiteral(["<span class=\"ui-selector-tab-default-stub-title\"></span>"])));
3773	      titleNode.renderTo(titleContainer);
3774	      return main_core.Loc.getMessage('UI_SELECTOR_TAB_STUB_TITLE').replace(/#TAB_TITLE#/, titleContainer.innerHTML);
3775	    }
3776	  }, {
3777	    key: "render",
3778	    value: function render() {
3779	      return this.getContainer();
3780	    }
3781	  }]);
3782	  return DefaultStub;
3783	}(BaseStub);
3784
3785	var _templateObject$2;
3786
3787	var BaseHeader = /*#__PURE__*/function () {
3788	  function BaseHeader(context, options) {
3789	    babelHelpers.classCallCheck(this, BaseHeader);
3790	    babelHelpers.defineProperty(this, "dialog", null);
3791	    babelHelpers.defineProperty(this, "tab", null);
3792	    babelHelpers.defineProperty(this, "container", null);
3793	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
3794	    this.options = main_core.Type.isPlainObject(options) ? options : {};
3795
3796	    if (context instanceof Dialog) {
3797	      this.dialog = context;
3798	    } else {
3799	      this.tab = context;
3800	      this.dialog = this.tab.getDialog();
3801	    }
3802	  }
3803
3804	  babelHelpers.createClass(BaseHeader, [{
3805	    key: "getDialog",
3806	    value: function getDialog() {
3807	      return this.dialog;
3808	    }
3809	  }, {
3810	    key: "getTab",
3811	    value: function getTab() {
3812	      return this.tab;
3813	    }
3814	  }, {
3815	    key: "show",
3816	    value: function show() {
3817	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-header--show');
3818	    }
3819	  }, {
3820	    key: "hide",
3821	    value: function hide() {
3822	      main_core.Dom.removeClass(this.getContainer(), 'ui-selector-header--show');
3823	    }
3824	  }, {
3825	    key: "getOptions",
3826	    value: function getOptions() {
3827	      return this.options;
3828	    }
3829	  }, {
3830	    key: "getOption",
3831	    value: function getOption(option, defaultValue) {
3832	      if (!main_core.Type.isUndefined(this.options[option])) {
3833	        return this.options[option];
3834	      } else if (!main_core.Type.isUndefined(defaultValue)) {
3835	        return defaultValue;
3836	      }
3837
3838	      return null;
3839	    }
3840	  }, {
3841	    key: "getContainer",
3842	    value: function getContainer() {
3843	      if (this.container === null) {
3844	        this.container = main_core.Tag.render(_templateObject$2 || (_templateObject$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-header\">", "</div>\n\t\t\t"])), this.render());
3845	      }
3846
3847	      return this.container;
3848	    }
3849	    /**
3850	     * @abstract
3851	     */
3852
3853	  }, {
3854	    key: "render",
3855	    value: function render() {
3856	      throw new Error('You must implement render() method.');
3857	    }
3858	  }]);
3859	  return BaseHeader;
3860	}();
3861
3862	var _templateObject$3;
3863
3864	var BaseFooter = /*#__PURE__*/function () {
3865	  function BaseFooter(context, options) {
3866	    babelHelpers.classCallCheck(this, BaseFooter);
3867	    babelHelpers.defineProperty(this, "dialog", null);
3868	    babelHelpers.defineProperty(this, "tab", null);
3869	    babelHelpers.defineProperty(this, "container", null);
3870	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
3871	    this.options = main_core.Type.isPlainObject(options) ? options : {};
3872
3873	    if (context instanceof Dialog) {
3874	      this.dialog = context;
3875	    } else {
3876	      this.tab = context;
3877	      this.dialog = this.tab.getDialog();
3878	    }
3879	  }
3880
3881	  babelHelpers.createClass(BaseFooter, [{
3882	    key: "getDialog",
3883	    value: function getDialog() {
3884	      return this.dialog;
3885	    }
3886	  }, {
3887	    key: "getTab",
3888	    value: function getTab() {
3889	      return this.tab;
3890	    }
3891	  }, {
3892	    key: "show",
3893	    value: function show() {
3894	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-footer--show');
3895	    }
3896	  }, {
3897	    key: "hide",
3898	    value: function hide() {
3899	      main_core.Dom.removeClass(this.getContainer(), 'ui-selector-footer--show');
3900	    }
3901	  }, {
3902	    key: "getOptions",
3903	    value: function getOptions() {
3904	      return this.options;
3905	    }
3906	  }, {
3907	    key: "getOption",
3908	    value: function getOption(option, defaultValue) {
3909	      if (!main_core.Type.isUndefined(this.options[option])) {
3910	        return this.options[option];
3911	      } else if (!main_core.Type.isUndefined(defaultValue)) {
3912	        return defaultValue;
3913	      }
3914
3915	      return null;
3916	    }
3917	  }, {
3918	    key: "getContainer",
3919	    value: function getContainer() {
3920	      if (this.container === null) {
3921	        this.container = main_core.Tag.render(_templateObject$3 || (_templateObject$3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-footer\">", "</div>\n\t\t\t"])), this.render());
3922	      }
3923
3924	      return this.container;
3925	    }
3926	    /**
3927	     * @abstract
3928	     */
3929
3930	  }, {
3931	    key: "render",
3932	    value: function render() {
3933	      throw new Error('You must implement render() method.');
3934	    }
3935	  }]);
3936	  return BaseFooter;
3937	}();
3938
3939	var _templateObject$4, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5;
3940
3941	/**
3942	 * @memberof BX.UI.EntitySelector
3943	 */
3944	var Tab = /*#__PURE__*/function () {
3945	  function Tab(dialog, tabOptions) {
3946	    babelHelpers.classCallCheck(this, Tab);
3947	    babelHelpers.defineProperty(this, "id", null);
3948	    babelHelpers.defineProperty(this, "title", null);
3949	    babelHelpers.defineProperty(this, "rootNode", null);
3950	    babelHelpers.defineProperty(this, "dialog", null);
3951	    babelHelpers.defineProperty(this, "stub", null);
3952	    babelHelpers.defineProperty(this, "visible", true);
3953	    babelHelpers.defineProperty(this, "rendered", false);
3954	    babelHelpers.defineProperty(this, "locked", false);
3955	    babelHelpers.defineProperty(this, "selected", false);
3956	    babelHelpers.defineProperty(this, "hovered", false);
3957	    babelHelpers.defineProperty(this, "icon", {});
3958	    babelHelpers.defineProperty(this, "textColor", {});
3959	    babelHelpers.defineProperty(this, "bgColor", {});
3960	    babelHelpers.defineProperty(this, "itemMaxDepth", 5);
3961	    babelHelpers.defineProperty(this, "header", null);
3962	    babelHelpers.defineProperty(this, "showDefaultHeader", true);
3963	    babelHelpers.defineProperty(this, "footer", null);
3964	    babelHelpers.defineProperty(this, "showDefaultFooter", true);
3965	    babelHelpers.defineProperty(this, "showAvatars", null);
3966	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
3967	    var options = main_core.Type.isPlainObject(tabOptions) ? tabOptions : {};
3968
3969	    if (!main_core.Type.isStringFilled(options.id)) {
3970	      throw new Error('EntitySelector.Tab: "id" parameter is required.');
3971	    }
3972
3973	    this.setDialog(dialog);
3974	    this.id = options.id;
3975	    this.showDefaultHeader = options.showDefaultHeader !== false;
3976	    this.showDefaultFooter = options.showDefaultFooter !== false;
3977	    this.rootNode = new ItemNode(null, {
3978	      itemOrder: options.itemOrder
3979	    });
3980	    this.rootNode.setTab(this);
3981	    this.setVisible(options.visible);
3982	    this.setTitle(options.title);
3983	    this.setItemMaxDepth(options.itemMaxDepth);
3984	    this.setIcon(options.icon);
3985	    this.setTextColor(options.textColor);
3986	    this.setBgColor(options.bgColor);
3987	    this.setStub(options.stub, options.stubOptions);
3988	    this.setHeader(options.header, options.headerOptions);
3989	    this.setFooter(options.footer, options.footerOptions);
3990	    this.setShowAvatars(options.showAvatars);
3991	  }
3992
3993	  babelHelpers.createClass(Tab, [{
3994	    key: "getId",
3995	    value: function getId() {
3996	      return this.id;
3997	    }
3998	    /**
3999	     * @internal
4000	     */
4001
4002	  }, {
4003	    key: "setDialog",
4004	    value: function setDialog(dialog) {
4005	      this.dialog = dialog;
4006	    }
4007	  }, {
4008	    key: "getDialog",
4009	    value: function getDialog() {
4010	      return this.dialog;
4011	    }
4012	  }, {
4013	    key: "getStub",
4014	    value: function getStub() {
4015	      return this.stub;
4016	    }
4017	  }, {
4018	    key: "setStub",
4019	    value: function setStub(stub, stubOptions) {
4020	      var instance = null;
4021	      var options = main_core.Type.isPlainObject(stubOptions) ? stubOptions : {};
4022
4023	      if (main_core.Type.isString(stub) || main_core.Type.isFunction(stub)) {
4024	        var className = main_core.Type.isString(stub) ? main_core.Reflection.getClass(stub) : stub;
4025
4026	        if (main_core.Type.isFunction(className)) {
4027	          instance = new className(this, options);
4028
4029	          if (!(instance instanceof BaseStub)) {
4030	            console.error('EntitySelector: stub is not an instance of BaseStub.');
4031	            instance = null;
4032	          }
4033	        }
4034	      }
4035
4036	      if (!instance && stub !== false) {
4037	        instance = new DefaultStub(this, options);
4038	      }
4039
4040	      this.stub = instance;
4041	    }
4042	  }, {
4043	    key: "getHeader",
4044	    value: function getHeader() {
4045	      return this.header;
4046	    }
4047	  }, {
4048	    key: "setHeader",
4049	    value: function setHeader(headerContent, headerOptions) {
4050	      /** @var {BaseHeader} */
4051	      var header = null;
4052
4053	      if (headerContent !== null) {
4054	        header = Dialog.createHeader(this, headerContent, headerOptions);
4055
4056	        if (header === null) {
4057	          return;
4058	        }
4059	      }
4060
4061	      if (this.isRendered() && this.getHeader() !== null) {
4062	        main_core.Dom.remove(this.getHeader().getContainer());
4063	        this.getDialog().adjustHeader();
4064	      }
4065
4066	      this.header = header;
4067
4068	      if (this.isRendered()) {
4069	        this.getDialog().appendHeader(header);
4070	        this.getDialog().adjustHeader();
4071	      }
4072	    }
4073	  }, {
4074	    key: "canShowDefaultHeader",
4075	    value: function canShowDefaultHeader() {
4076	      return this.showDefaultHeader;
4077	    }
4078	  }, {
4079	    key: "enableDefaultHeader",
4080	    value: function enableDefaultHeader() {
4081	      this.showDefaultHeader = true;
4082	      this.getDialog().adjustHeader();
4083	    }
4084	  }, {
4085	    key: "disableDefaultHeader",
4086	    value: function disableDefaultHeader() {
4087	      this.showDefaultHeader = false;
4088	      this.getDialog().adjustHeader();
4089	    }
4090	  }, {
4091	    key: "getFooter",
4092	    value: function getFooter() {
4093	      return this.footer;
4094	    }
4095	  }, {
4096	    key: "setFooter",
4097	    value: function setFooter(footerContent, footerOptions) {
4098	      /** @var {BaseFooter} */
4099	      var footer = null;
4100
4101	      if (footerContent !== null) {
4102	        footer = Dialog.createFooter(this, footerContent, footerOptions);
4103
4104	        if (footer === null) {
4105	          return;
4106	        }
4107	      }
4108
4109	      if (this.isRendered() && this.getFooter() !== null) {
4110	        main_core.Dom.remove(this.getFooter().getContainer());
4111	        this.getDialog().adjustFooter();
4112	      }
4113
4114	      this.footer = footer;
4115
4116	      if (this.isRendered()) {
4117	        this.getDialog().appendFooter(footer);
4118	        this.getDialog().adjustFooter();
4119	      }
4120	    }
4121	  }, {
4122	    key: "canShowDefaultFooter",
4123	    value: function canShowDefaultFooter() {
4124	      return this.showDefaultFooter;
4125	    }
4126	  }, {
4127	    key: "enableDefaultFooter",
4128	    value: function enableDefaultFooter() {
4129	      this.showDefaultFooter = true;
4130	      this.getDialog().adjustFooter();
4131	    }
4132	  }, {
4133	    key: "disableDefaultFooter",
4134	    value: function disableDefaultFooter() {
4135	      this.showDefaultFooter = false;
4136	      this.getDialog().adjustFooter();
4137	    }
4138	  }, {
4139	    key: "setShowAvatars",
4140	    value: function setShowAvatars(flag) {
4141	      if (main_core.Type.isBoolean(flag) || flag === null) {
4142	        this.showAvatars = flag;
4143
4144	        if (this.isRendered()) {
4145	          this.renderContainer();
4146	        }
4147	      }
4148	    }
4149	  }, {
4150	    key: "shouldShowAvatars",
4151	    value: function shouldShowAvatars() {
4152	      var _this$showAvatars;
4153
4154	      return (_this$showAvatars = this.showAvatars) !== null && _this$showAvatars !== void 0 ? _this$showAvatars : this.getDialog().shouldShowAvatars();
4155	    }
4156	  }, {
4157	    key: "getRootNode",
4158	    value: function getRootNode() {
4159	      return this.rootNode;
4160	    }
4161	  }, {
4162	    key: "setTitle",
4163	    value: function setTitle(title) {
4164	      if (main_core.Type.isStringFilled(title) || main_core.Type.isPlainObject(title) || title === null) {
4165	        this.title = title === null ? null : new TextNode(title);
4166
4167	        if (this.isRendered()) {
4168	          this.renderLabel();
4169	        }
4170	      }
4171	    }
4172	  }, {
4173	    key: "getTitle",
4174	    value: function getTitle() {
4175	      var titleNode = this.getTitleNode();
4176	      return titleNode !== null && !titleNode.isNullable() ? titleNode.getText() : '';
4177	    }
4178	  }, {
4179	    key: "getTitleNode",
4180	    value: function getTitleNode() {
4181	      return this.title;
4182	    }
4183	  }, {
4184	    key: "setIcon",
4185	    value: function setIcon(icon) {
4186	      return this.setProperty('icon', icon);
4187	    }
4188	  }, {
4189	    key: "getIcon",
4190	    value: function getIcon(state) {
4191	      return this.getPropertyByState('icon', state);
4192	    }
4193	  }, {
4194	    key: "setBgColor",
4195	    value: function setBgColor(bgColor) {
4196	      return this.setProperty('bgColor', bgColor);
4197	    }
4198	  }, {
4199	    key: "getBgColor",
4200	    value: function getBgColor(state) {
4201	      return this.getPropertyByState('bgColor', state);
4202	    }
4203	  }, {
4204	    key: "setTextColor",
4205	    value: function setTextColor(textColor) {
4206	      return this.setProperty('textColor', textColor);
4207	    }
4208	  }, {
4209	    key: "getTextColor",
4210	    value: function getTextColor(state) {
4211	      return this.getPropertyByState('textColor', state);
4212	    }
4213	    /**
4214	     * @private
4215	     */
4216
4217	  }, {
4218	    key: "setProperty",
4219	    value: function setProperty(name, states) {
4220	      var property = this[name];
4221
4222	      if (!property) {
4223	        return;
4224	      }
4225
4226	      if (main_core.Type.isPlainObject(states)) {
4227	        Object.keys(states).forEach(function (state) {
4228	          if (main_core.Type.isStringFilled(states[state])) {
4229	            property[state] = states[state];
4230	          }
4231	        });
4232	      } else if (main_core.Type.isStringFilled(states)) {
4233	        property['default'] = states;
4234	      }
4235	    }
4236	    /**
4237	     * @private
4238	     */
4239
4240	  }, {
4241	    key: "getPropertyByState",
4242	    value: function getPropertyByState(name, state) {
4243	      var property = this[name];
4244	      var labelState = main_core.Type.isStringFilled(state) ? state : 'default';
4245
4246	      if (!main_core.Type.isUndefined(property) && !main_core.Type.isUndefined(property[labelState])) {
4247	        return property[labelState];
4248	      }
4249
4250	      return null;
4251	    }
4252	    /**
4253	     * @private
4254	     */
4255
4256	  }, {
4257	    key: "getPropertyByCurrentState",
4258	    value: function getPropertyByCurrentState(name) {
4259	      var property = this[name];
4260
4261	      if (this.isSelected() && this.isHovered() && property.selectedHovered) {
4262	        return property.selectedHovered;
4263	      } else if (this.isSelected() && property.selected) {
4264	        return property.selected;
4265	      } else if (this.isHovered() && property.hovered) {
4266	        return property.hovered;
4267	      } else if (property["default"]) {
4268	        return property["default"];
4269	      }
4270
4271	      return null;
4272	    }
4273	  }, {
4274	    key: "setItemMaxDepth",
4275	    value: function setItemMaxDepth(depth) {
4276	      if (main_core.Type.isNumber(depth) && depth > 0) {
4277	        this.itemMaxDepth = depth;
4278	      }
4279	    }
4280	  }, {
4281	    key: "getItemMaxDepth",
4282	    value: function getItemMaxDepth() {
4283	      return this.itemMaxDepth;
4284	    }
4285	  }, {
4286	    key: "getContainer",
4287	    value: function getContainer() {
4288	      var _this = this;
4289
4290	      return this.cache.remember('container', function () {
4291	        return main_core.Tag.render(_templateObject$4 || (_templateObject$4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tab-content\">", "</div>\n\t\t\t"])), _this.getItemsContainer());
4292	      });
4293	    }
4294	  }, {
4295	    key: "getLabelContainer",
4296	    value: function getLabelContainer() {
4297	      var _this2 = this;
4298
4299	      return this.cache.remember('label', function () {
4300	        var className = _this2.isVisible() ? '' : ' ui-selector-tab-label-hidden';
4301	        return main_core.Tag.render(_templateObject2$1 || (_templateObject2$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div \n\t\t\t\t\tclass=\"ui-selector-tab-label", "\" \n\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\tonmouseenter=\"", "\"\n\t\t\t\t\tonmouseleave=\"", "\"\n\t\t\t\t>\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), className, _this2.handleLabelClick.bind(_this2), _this2.handleLabelMouseEnter.bind(_this2), _this2.handleLabelMouseLeave.bind(_this2), _this2.getIconContainer(), _this2.getTitleContainer());
4302	      });
4303	    }
4304	  }, {
4305	    key: "getIconContainer",
4306	    value: function getIconContainer() {
4307	      return this.cache.remember('icon', function () {
4308	        return main_core.Tag.render(_templateObject3$1 || (_templateObject3$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tab-icon\"></div>\n\t\t\t"])));
4309	      });
4310	    }
4311	  }, {
4312	    key: "getTitleContainer",
4313	    value: function getTitleContainer() {
4314	      return this.cache.remember('title', function () {
4315	        return main_core.Tag.render(_templateObject4$1 || (_templateObject4$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tab-title\"></div>\n\t\t\t"])));
4316	      });
4317	    }
4318	  }, {
4319	    key: "getItemsContainer",
4320	    value: function getItemsContainer() {
4321	      return this.cache.remember('items', function () {
4322	        return main_core.Tag.render(_templateObject5 || (_templateObject5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-items\"></div>\n\t\t\t"])));
4323	      });
4324	    }
4325	  }, {
4326	    key: "render",
4327	    value: function render() {
4328	      this.getRootNode().render();
4329	      this.rendered = true;
4330	    }
4331	    /** @internal **/
4332
4333	  }, {
4334	    key: "renderLabel",
4335	    value: function renderLabel() {
4336	      main_core.Dom.style(this.getTitleContainer(), 'color', this.getPropertyByCurrentState('textColor'));
4337	      main_core.Dom.style(this.getLabelContainer(), 'background-color', this.getPropertyByCurrentState('bgColor'));
4338	      var icon = this.getPropertyByCurrentState('icon');
4339	      main_core.Dom.style(this.getIconContainer(), 'background-image', icon ? "url('".concat(encodeUrl(icon), "')") : null);
4340	      var titleNode = this.getTitleNode();
4341
4342	      if (titleNode) {
4343	        this.getTitleNode().renderTo(this.getTitleContainer());
4344	      } else {
4345	        this.getTitleContainer().textContent = '';
4346	      }
4347	    }
4348	    /** @internal **/
4349
4350	  }, {
4351	    key: "renderContainer",
4352	    value: function renderContainer() {
4353	      var className = 'ui-selector-tab-content--hide-avatars';
4354
4355	      if (this.shouldShowAvatars()) {
4356	        main_core.Dom.removeClass(this.getContainer(), className);
4357	      } else {
4358	        main_core.Dom.addClass(this.getContainer(), className);
4359	      }
4360	    }
4361	  }, {
4362	    key: "isVisible",
4363	    value: function isVisible() {
4364	      return this.visible;
4365	    }
4366	  }, {
4367	    key: "setVisible",
4368	    value: function setVisible(flag) {
4369	      if (main_core.Type.isBoolean(flag)) {
4370	        this.visible = flag;
4371
4372	        if (this.isRendered()) {
4373	          if (this.visible) {
4374	            main_core.Dom.remove(this.getLabelContainer(), 'ui-selector-tab-label-hidden');
4375	          } else {
4376	            main_core.Dom.addClass(this.getLabelContainer(), 'ui-selector-tab-label-hidden');
4377	          }
4378	        }
4379	      }
4380	    }
4381	  }, {
4382	    key: "isRendered",
4383	    value: function isRendered() {
4384	      return this.rendered && this.getDialog() && this.getDialog().isRendered();
4385	    }
4386	    /**
4387	     * @internal
4388	     */
4389
4390	  }, {
4391	    key: "select",
4392	    value: function select() {
4393	      if (this.isSelected()) {
4394	        return;
4395	      }
4396
4397	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-tab-content-active');
4398
4399	      if (this.isVisible()) {
4400	        main_core.Dom.addClass(this.getLabelContainer(), 'ui-selector-tab-label-active');
4401	        this.renderLabel();
4402	      }
4403
4404	      this.selected = true;
4405
4406	      if (this.isVisible()) {
4407	        this.renderLabel();
4408	      }
4409
4410	      if (this.getHeader()) {
4411	        this.getHeader().show();
4412	      }
4413
4414	      if (this.getFooter()) {
4415	        this.getFooter().show();
4416	      }
4417
4418	      this.getDialog().emit('Tab:onSelect', {
4419	        tab: this
4420	      });
4421	    }
4422	    /**
4423	     * @internal
4424	     */
4425
4426	  }, {
4427	    key: "deselect",
4428	    value: function deselect() {
4429	      if (!this.isSelected()) {
4430	        return;
4431	      }
4432
4433	      main_core.Dom.removeClass(this.getContainer(), 'ui-selector-tab-content-active');
4434
4435	      if (this.isVisible()) {
4436	        main_core.Dom.removeClass(this.getLabelContainer(), 'ui-selector-tab-label-active');
4437	      }
4438
4439	      this.selected = false;
4440
4441	      if (this.isVisible()) {
4442	        this.renderLabel();
4443	      }
4444
4445	      if (this.getHeader()) {
4446	        this.getHeader().hide();
4447	      }
4448
4449	      if (this.getFooter()) {
4450	        this.getFooter().hide();
4451	      }
4452
4453	      this.getDialog().emit('Tab:onDeselect', {
4454	        tab: this
4455	      });
4456	    }
4457	  }, {
4458	    key: "hover",
4459	    value: function hover() {
4460	      if (this.isHovered()) {
4461	        return;
4462	      }
4463
4464	      main_core.Dom.addClass(this.getLabelContainer(), 'ui-selector-tab-label-hover');
4465	      this.hovered = true;
4466	      this.renderLabel();
4467	    }
4468	  }, {
4469	    key: "unhover",
4470	    value: function unhover() {
4471	      if (!this.isHovered()) {
4472	        return;
4473	      }
4474
4475	      main_core.Dom.removeClass(this.getLabelContainer(), 'ui-selector-tab-label-hover');
4476	      this.hovered = false;
4477	      this.renderLabel();
4478	    }
4479	  }, {
4480	    key: "isSelected",
4481	    value: function isSelected() {
4482	      return this.selected;
4483	    }
4484	  }, {
4485	    key: "isHovered",
4486	    value: function isHovered() {
4487	      return this.hovered;
4488	    }
4489	  }, {
4490	    key: "lock",
4491	    value: function lock() {
4492	      this.locked = true;
4493	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-tab-content-locked');
4494	    }
4495	  }, {
4496	    key: "unlock",
4497	    value: function unlock() {
4498	      this.locked = false;
4499	      main_core.Dom.removeClass(this.getContainer(), 'ui-selector-tab-content-locked');
4500	    }
4501	  }, {
4502	    key: "isLocked",
4503	    value: function isLocked() {
4504	      return this.locked;
4505	    }
4506	  }, {
4507	    key: "handleLabelClick",
4508	    value: function handleLabelClick() {
4509	      this.getDialog().selectTab(this.getId());
4510	    }
4511	  }, {
4512	    key: "handleLabelMouseEnter",
4513	    value: function handleLabelMouseEnter() {
4514	      this.hover();
4515	    }
4516	  }, {
4517	    key: "handleLabelMouseLeave",
4518	    value: function handleLabelMouseLeave() {
4519	      this.unhover();
4520	    }
4521	  }]);
4522	  return Tab;
4523	}();
4524
4525	var _templateObject$5, _templateObject2$2, _templateObject3$2, _templateObject4$2, _templateObject5$1, _templateObject6;
4526
4527	var TagItem = /*#__PURE__*/function () {
4528	  function TagItem(itemOptions) {
4529	    babelHelpers.classCallCheck(this, TagItem);
4530	    babelHelpers.defineProperty(this, "id", null);
4531	    babelHelpers.defineProperty(this, "entityId", null);
4532	    babelHelpers.defineProperty(this, "entityType", null);
4533	    babelHelpers.defineProperty(this, "title", null);
4534	    babelHelpers.defineProperty(this, "avatar", null);
4535	    babelHelpers.defineProperty(this, "avatarOptions", null);
4536	    babelHelpers.defineProperty(this, "maxWidth", null);
4537	    babelHelpers.defineProperty(this, "textColor", null);
4538	    babelHelpers.defineProperty(this, "bgColor", null);
4539	    babelHelpers.defineProperty(this, "fontWeight", null);
4540	    babelHelpers.defineProperty(this, "link", null);
4541	    babelHelpers.defineProperty(this, "onclick", null);
4542	    babelHelpers.defineProperty(this, "deselectable", null);
4543	    babelHelpers.defineProperty(this, "customData", null);
4544	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
4545	    babelHelpers.defineProperty(this, "selector", null);
4546	    babelHelpers.defineProperty(this, "rendered", false);
4547	    var options = main_core.Type.isPlainObject(itemOptions) ? itemOptions : {};
4548
4549	    if (!main_core.Type.isStringFilled(options.id) && !main_core.Type.isNumber(options.id)) {
4550	      throw new Error('TagSelector.TagItem: "id" parameter is required.');
4551	    }
4552
4553	    if (!main_core.Type.isStringFilled(options.entityId)) {
4554	      throw new Error('TagSelector.TagItem: "entityId" parameter is required.');
4555	    }
4556
4557	    this.id = options.id;
4558	    this.entityId = options.entityId.toLowerCase();
4559	    this.entityType = main_core.Type.isStringFilled(options.entityType) ? options.entityType : 'default';
4560	    this.customData = TypeUtils.createMapFromOptions(options.customData);
4561	    this.onclick = main_core.Type.isFunction(options.onclick) ? options.onclick : null;
4562	    this.link = main_core.Type.isStringFilled(options.link) ? options.link : null;
4563	    this.setTitle(options.title);
4564	    this.setDeselectable(options.deselectable);
4565	    this.setAvatar(options.avatar);
4566	    this.setAvatarOptions(options.avatarOptions);
4567	    this.setMaxWidth(options.maxWidth);
4568	    this.setTextColor(options.textColor);
4569	    this.setBgColor(options.bgColor);
4570	    this.setFontWeight(options.fontWeight);
4571	  }
4572
4573	  babelHelpers.createClass(TagItem, [{
4574	    key: "getId",
4575	    value: function getId() {
4576	      return this.id;
4577	    }
4578	  }, {
4579	    key: "getEntityId",
4580	    value: function getEntityId() {
4581	      return this.entityId;
4582	    }
4583	  }, {
4584	    key: "getEntityType",
4585	    value: function getEntityType() {
4586	      return this.entityType;
4587	    }
4588	  }, {
4589	    key: "getSelector",
4590	    value: function getSelector() {
4591	      return this.selector;
4592	    }
4593	  }, {
4594	    key: "setSelector",
4595	    value: function setSelector(selector) {
4596	      this.selector = selector;
4597	    }
4598	  }, {
4599	    key: "getTitle",
4600	    value: function getTitle() {
4601	      return this.getTitleNode() && !this.getTitleNode().isNullable() ? this.getTitleNode().getText() : '';
4602	    }
4603	  }, {
4604	    key: "getTitleNode",
4605	    value: function getTitleNode() {
4606	      return this.title;
4607	    }
4608	  }, {
4609	    key: "setTitle",
4610	    value: function setTitle(title) {
4611	      if (main_core.Type.isStringFilled(title) || main_core.Type.isPlainObject(title) || title === null) {
4612	        this.title = title === null ? null : new TextNode(title);
4613	      }
4614	    }
4615	  }, {
4616	    key: "getAvatar",
4617	    value: function getAvatar() {
4618	      if (this.avatar !== null) {
4619	        return this.avatar;
4620	      } else if (this.getSelector().getTagAvatar() !== null) {
4621	        return this.getSelector().getTagAvatar();
4622	      } else if (this.getEntityTagOption('avatar') !== null) {
4623	        return this.getEntityTagOption('avatar');
4624	      }
4625
4626	      return this.getEntityItemOption('avatar');
4627	    }
4628	  }, {
4629	    key: "setAvatar",
4630	    value: function setAvatar(avatar) {
4631	      if (main_core.Type.isString(avatar) || avatar === null) {
4632	        this.avatar = avatar;
4633	      }
4634	    }
4635	  }, {
4636	    key: "getAvatarOption",
4637	    value: function getAvatarOption(option) {
4638	      if (this.avatarOptions !== null && !main_core.Type.isUndefined(this.avatarOptions[option])) {
4639	        return this.avatarOptions[option];
4640	      }
4641
4642	      var selectorAvatarOption = this.getSelector().getTagAvatarOption(option);
4643
4644	      if (selectorAvatarOption !== null) {
4645	        return selectorAvatarOption[option];
4646	      }
4647
4648	      var entityTagAvatarOptions = this.getEntityTagOption('avatarOptions');
4649
4650	      if (main_core.Type.isPlainObject(entityTagAvatarOptions) && !main_core.Type.isUndefined(entityTagAvatarOptions[option])) {
4651	        return entityTagAvatarOptions[option];
4652	      }
4653
4654	      var entityItemAvatarOptions = this.getEntityItemOption('avatarOptions');
4655
4656	      if (main_core.Type.isPlainObject(entityItemAvatarOptions) && !main_core.Type.isUndefined(entityItemAvatarOptions[option])) {
4657	        return entityItemAvatarOptions[option];
4658	      }
4659
4660	      return null;
4661	    }
4662	  }, {
4663	    key: "setAvatarOption",
4664	    value: function setAvatarOption(option, value) {
4665	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
4666	        if (this.avatarOptions === null) {
4667	          this.avatarOptions = {};
4668	        }
4669
4670	        this.avatarOptions[option] = value;
4671	      }
4672	    }
4673	  }, {
4674	    key: "setAvatarOptions",
4675	    value: function setAvatarOptions(options) {
4676	      var _this = this;
4677
4678	      if (main_core.Type.isPlainObject(options)) {
4679	        Object.keys(options).forEach(function (option) {
4680	          _this.setAvatarOption(option, options[option]);
4681	        });
4682	      }
4683	    }
4684	  }, {
4685	    key: "getTextColor",
4686	    value: function getTextColor() {
4687	      if (this.textColor !== null) {
4688	        return this.textColor;
4689	      } else if (this.getSelector().getTagTextColor() !== null) {
4690	        return this.getSelector().getTagTextColor();
4691	      }
4692
4693	      return this.getEntityTagOption('textColor');
4694	    }
4695	  }, {
4696	    key: "setTextColor",
4697	    value: function setTextColor(textColor) {
4698	      if (main_core.Type.isString(textColor) || textColor === null) {
4699	        this.textColor = textColor;
4700	      }
4701	    }
4702	  }, {
4703	    key: "getBgColor",
4704	    value: function getBgColor() {
4705	      if (this.bgColor !== null) {
4706	        return this.bgColor;
4707	      } else if (this.getSelector().getTagBgColor() !== null) {
4708	        return this.getSelector().getTagBgColor();
4709	      }
4710
4711	      return this.getEntityTagOption('bgColor');
4712	    }
4713	  }, {
4714	    key: "setBgColor",
4715	    value: function setBgColor(bgColor) {
4716	      if (main_core.Type.isString(bgColor) || bgColor === null) {
4717	        this.bgColor = bgColor;
4718	      }
4719	    }
4720	  }, {
4721	    key: "getFontWeight",
4722	    value: function getFontWeight() {
4723	      if (this.fontWeight !== null) {
4724	        return this.fontWeight;
4725	      } else if (this.getSelector().getTagFontWeight() !== null) {
4726	        return this.getSelector().getTagFontWeight();
4727	      }
4728
4729	      return this.getEntityTagOption('fontWeight');
4730	    }
4731	  }, {
4732	    key: "setFontWeight",
4733	    value: function setFontWeight(fontWeight) {
4734	      if (main_core.Type.isString(fontWeight) || fontWeight === null) {
4735	        this.fontWeight = fontWeight;
4736	      }
4737	    }
4738	  }, {
4739	    key: "getMaxWidth",
4740	    value: function getMaxWidth() {
4741	      if (this.maxWidth !== null) {
4742	        return this.maxWidth;
4743	      } else if (this.getSelector().getTagMaxWidth() !== null) {
4744	        return this.getSelector().getTagMaxWidth();
4745	      }
4746
4747	      return this.getEntityTagOption('maxWidth');
4748	    }
4749	  }, {
4750	    key: "setMaxWidth",
4751	    value: function setMaxWidth(width) {
4752	      if (main_core.Type.isNumber(width) && width >= 0 || width === null) {
4753	        this.maxWidth = width;
4754	      }
4755	    }
4756	  }, {
4757	    key: "setDeselectable",
4758	    value: function setDeselectable(flag) {
4759	      if (main_core.Type.isBoolean(flag)) {
4760	        this.deselectable = flag;
4761	      }
4762	    }
4763	  }, {
4764	    key: "isDeselectable",
4765	    value: function isDeselectable() {
4766	      return this.deselectable !== null ? this.deselectable : this.getSelector().isDeselectable();
4767	    }
4768	  }, {
4769	    key: "getCustomData",
4770	    value: function getCustomData() {
4771	      return this.customData;
4772	    }
4773	  }, {
4774	    key: "getLink",
4775	    value: function getLink() {
4776	      return this.link;
4777	    }
4778	  }, {
4779	    key: "getOnclick",
4780	    value: function getOnclick() {
4781	      return this.onclick;
4782	    }
4783	  }, {
4784	    key: "render",
4785	    value: function render() {
4786	      var titleNode = this.getTitleNode();
4787
4788	      if (titleNode) {
4789	        titleNode.renderTo(this.getTitleContainer()); //Dom.attr(this.getContentContainer(), 'title', this.getTitle());
4790	      } else {
4791	        this.getTitleContainer().textContent = '';
4792	        main_core.Dom.attr(this.getContentContainer(), 'title', '');
4793	      }
4794
4795	      var avatar = this.getAvatar();
4796	      var bgImage = this.getAvatarOption('bgImage');
4797
4798	      if (main_core.Type.isStringFilled(avatar)) {
4799	        main_core.Dom.style(this.getAvatarContainer(), 'background-image', "url('".concat(encodeUrl(avatar), "')"));
4800	      } else {
4801	        main_core.Dom.style(this.getAvatarContainer(), 'background-image', bgImage);
4802	      }
4803
4804	      var bgColor = this.getAvatarOption('bgColor');
4805	      var bgSize = this.getAvatarOption('bgSize');
4806	      main_core.Dom.style(this.getAvatarContainer(), 'background-color', bgColor);
4807	      main_core.Dom.style(this.getAvatarContainer(), 'background-size', bgSize);
4808	      var hasAvatar = avatar || bgColor && bgColor !== 'none' || bgImage && bgImage !== 'none';
4809
4810	      if (hasAvatar) {
4811	        main_core.Dom.addClass(this.getContainer(), 'ui-tag-selector-tag--has-avatar');
4812	      } else {
4813	        main_core.Dom.removeClass(this.getContainer(), 'ui-tag-selector-tag--has-avatar');
4814	      }
4815
4816	      var maxWidth = this.getMaxWidth();
4817
4818	      if (maxWidth > 0) {
4819	        main_core.Dom.style(this.getContainer(), 'max-width', "".concat(maxWidth, "px"));
4820	      } else {
4821	        main_core.Dom.style(this.getContainer(), 'max-width', null);
4822	      }
4823
4824	      if (this.isDeselectable()) {
4825	        main_core.Dom.removeClass(this.getContainer(), 'ui-tag-selector-tag-readonly');
4826	      } else {
4827	        main_core.Dom.addClass(this.getContainer(), 'ui-tag-selector-tag-readonly');
4828	      }
4829
4830	      main_core.Dom.style(this.getTitleContainer(), 'color', this.getTextColor());
4831	      main_core.Dom.style(this.getTitleContainer(), 'font-weight', this.getFontWeight());
4832	      main_core.Dom.style(this.getContainer(), 'background-color', this.getBgColor());
4833	      this.rendered = true;
4834	    }
4835	  }, {
4836	    key: "getContainer",
4837	    value: function getContainer() {
4838	      var _this2 = this;
4839
4840	      return this.cache.remember('container', function () {
4841	        return main_core.Tag.render(_templateObject$5 || (_templateObject$5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-item ui-tag-selector-tag\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>"])), _this2.getContentContainer(), _this2.getRemoveIcon());
4842	      });
4843	    }
4844	  }, {
4845	    key: "getContentContainer",
4846	    value: function getContentContainer() {
4847	      var _this3 = this;
4848
4849	      return this.cache.remember('content-container', function () {
4850	        if (main_core.Type.isStringFilled(_this3.getLink())) {
4851	          return main_core.Tag.render(_templateObject2$2 || (_templateObject2$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<a\n\t\t\t\t\t\tclass=\"ui-tag-selector-tag-content\"\n\t\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\t\thref=\"", "\"\n\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t>\n\t\t\t\t\t\t", "\n\t\t\t\t\t\t", "\n\t\t\t\t\t</a>\n\t\t\t\t"])), _this3.handleContainerClick.bind(_this3), _this3.getLink(), _this3.getAvatarContainer(), _this3.getTitleContainer());
4852	        } else {
4853	          var className = main_core.Type.isFunction(_this3.getOnclick()) ? ' ui-tag-selector-tag-content--clickable' : '';
4854	          return main_core.Tag.render(_templateObject3$2 || (_templateObject3$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t\t<div \n\t\t\t\t\t\tclass=\"ui-tag-selector-tag-content", "\" \n\t\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\t>\n\t\t\t\t\t\t", "\n\t\t\t\t\t\t", "\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t"])), className, _this3.handleContainerClick.bind(_this3), _this3.getAvatarContainer(), _this3.getTitleContainer());
4855	        }
4856	      });
4857	    }
4858	  }, {
4859	    key: "getAvatarContainer",
4860	    value: function getAvatarContainer() {
4861	      return this.cache.remember('avatar', function () {
4862	        return main_core.Tag.render(_templateObject4$2 || (_templateObject4$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-tag-avatar\"></div>\n\t\t\t"])));
4863	      });
4864	    }
4865	  }, {
4866	    key: "getTitleContainer",
4867	    value: function getTitleContainer() {
4868	      return this.cache.remember('title', function () {
4869	        return main_core.Tag.render(_templateObject5$1 || (_templateObject5$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-tag-title\"></div>\n\t\t\t"])));
4870	      });
4871	    }
4872	  }, {
4873	    key: "getRemoveIcon",
4874	    value: function getRemoveIcon() {
4875	      var _this4 = this;
4876
4877	      return this.cache.remember('remove-icon', function () {
4878	        return main_core.Tag.render(_templateObject6 || (_templateObject6 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-tag-remove\" onclick=\"", "\"></div>\n\t\t\t"])), _this4.handleRemoveIconClick.bind(_this4));
4879	      });
4880	    }
4881	  }, {
4882	    key: "getEntityTagOption",
4883	    value: function getEntityTagOption(option) {
4884	      return Entity.getTagOption(this.getEntityId(), option, this.getEntityType());
4885	    }
4886	  }, {
4887	    key: "getEntityItemOption",
4888	    value: function getEntityItemOption(option) {
4889	      return Entity.getItemOption(this.getEntityId(), option, this.getEntityType());
4890	    }
4891	  }, {
4892	    key: "isRendered",
4893	    value: function isRendered() {
4894	      return this.rendered && this.getSelector() && this.getSelector().isRendered();
4895	    }
4896	  }, {
4897	    key: "remove",
4898	    value: function remove() {
4899	      var _this5 = this;
4900
4901	      var animate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
4902
4903	      if (animate === false) {
4904	        main_core.Dom.remove(this.getContainer());
4905	        return Promise.resolve();
4906	      }
4907
4908	      return new Promise(function (resolve) {
4909	        main_core.Dom.style(_this5.getContainer(), 'width', "".concat(_this5.getContainer().offsetWidth, "px"));
4910	        main_core.Dom.addClass(_this5.getContainer(), 'ui-tag-selector-tag--remove');
4911	        Animation.handleAnimationEnd(_this5.getContainer(), 'ui-tag-selector-tag-remove').then(function () {
4912	          main_core.Dom.remove(_this5.getContainer());
4913	          resolve();
4914	        });
4915	      });
4916	    }
4917	  }, {
4918	    key: "show",
4919	    value: function show() {
4920	      var _this6 = this;
4921
4922	      return new Promise(function (resolve) {
4923	        main_core.Dom.addClass(_this6.getContainer(), 'ui-tag-selector-tag--show');
4924	        Animation.handleAnimationEnd(_this6.getContainer(), 'ui-tag-selector-tag-show').then(function () {
4925	          main_core.Dom.removeClass(_this6.getContainer(), 'ui-tag-selector-tag--show');
4926	          resolve();
4927	        });
4928	      });
4929	    }
4930	  }, {
4931	    key: "handleContainerClick",
4932	    value: function handleContainerClick() {
4933	      var fn = this.getOnclick();
4934
4935	      if (main_core.Type.isFunction(fn)) {
4936	        fn(this);
4937	      }
4938	    }
4939	  }, {
4940	    key: "handleRemoveIconClick",
4941	    value: function handleRemoveIconClick(event) {
4942	      event.stopPropagation();
4943
4944	      if (this.isDeselectable()) {
4945	        this.getSelector().removeTag(this);
4946	      }
4947	    }
4948	  }]);
4949	  return TagItem;
4950	}();
4951
4952	var _templateObject$6, _templateObject2$3, _templateObject3$3, _templateObject4$3, _templateObject5$2, _templateObject6$1, _templateObject7;
4953
4954	/**
4955	 * @memberof BX.UI.EntitySelector
4956	 */
4957	var TagSelector = /*#__PURE__*/function (_EventEmitter) {
4958	  babelHelpers.inherits(TagSelector, _EventEmitter);
4959
4960	  function TagSelector(selectorOptions) {
4961	    var _this;
4962
4963	    babelHelpers.classCallCheck(this, TagSelector);
4964	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(TagSelector).call(this));
4965	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tags", []);
4966	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "cache", new main_core.Cache.MemoryCache());
4967	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "multiple", true);
4968	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "readonly", false);
4969	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "locked", false);
4970	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "deselectable", true);
4971	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "addButtonCaption", null);
4972	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "addButtonCaptionMore", null);
4973	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "createButtonCaption", null);
4974	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "addButtonVisible", true);
4975	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "createButtonVisible", false);
4976	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "textBoxVisible", false);
4977	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "textBoxWidth", null);
4978	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "maxHeight", null);
4979	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "placeholder", '');
4980	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "textBoxAutoHide", false);
4981	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "textBoxOldValue", '');
4982	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagAvatar", null);
4983	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagAvatarOptions", null);
4984	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagTextColor", null);
4985	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagBgColor", null);
4986	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagFontWeight", null);
4987	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagMaxWidth", null);
4988	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "dialog", null);
4989
4990	    _this.setEventNamespace('BX.UI.EntitySelector.TagSelector');
4991
4992	    var options = main_core.Type.isPlainObject(selectorOptions) ? selectorOptions : {};
4993	    _this.id = main_core.Type.isStringFilled(options.id) ? options.id : "ui-tag-selector-".concat(main_core.Text.getRandom().toLowerCase());
4994	    _this.multiple = main_core.Type.isBoolean(options.multiple) ? options.multiple : true;
4995	    _this.addButtonVisible = options.showAddButton !== false;
4996	    _this.createButtonVisible = options.showCreateButton === true;
4997	    _this.textBoxVisible = options.showTextBox === true;
4998
4999	    _this.setReadonly(options.readonly);
5000
5001	    _this.setLocked(options.locked);
5002
5003	    _this.setAddButtonCaption(options.addButtonCaption);
5004
5005	    _this.setAddButtonCaptionMore(options.addButtonCaptionMore);
5006
5007	    _this.setCreateButtonCaption(options.createButtonCaption);
5008
5009	    _this.setPlaceholder(options.placeholder);
5010
5011	    _this.setTextBoxAutoHide(options.textBoxAutoHide);
5012
5013	    _this.setTextBoxWidth(options.textBoxWidth);
5014
5015	    _this.setDeselectable(options.deselectable);
5016
5017	    _this.setMaxHeight(options.maxHeight);
5018
5019	    _this.setTagAvatar(options.tagAvatar);
5020
5021	    _this.setTagAvatarOptions(options.tagAvatarOptions);
5022
5023	    _this.setTagMaxWidth(options.tagMaxWidth);
5024
5025	    _this.setTagTextColor(options.tagTextColor);
5026
5027	    _this.setTagBgColor(options.tagBgColor);
5028
5029	    _this.setTagFontWeight(options.tagFontWeight);
5030
5031	    if (main_core.Type.isPlainObject(options.dialogOptions)) {
5032	      var selectedItems = main_core.Type.isArray(options.items) ? options.items : [];
5033
5034	      if (main_core.Type.isArray(options.dialogOptions.selectedItems)) {
5035	        selectedItems = selectedItems.concat(options.dialogOptions.selectedItems);
5036	      }
5037
5038	      var dialogOptions = Object.assign({}, options.dialogOptions, {
5039	        tagSelectorOptions: null,
5040	        selectedItems: selectedItems,
5041	        multiple: _this.isMultiple(),
5042	        tagSelector: babelHelpers.assertThisInitialized(_this)
5043	      });
5044	      new Dialog(dialogOptions);
5045	    } else if (main_core.Type.isArray(options.items)) {
5046	      options.items.forEach(function (item) {
5047	        _this.addTag(item);
5048	      });
5049	    }
5050
5051	    _this.subscribeFromOptions(options.events);
5052
5053	    return _this;
5054	  }
5055
5056	  babelHelpers.createClass(TagSelector, [{
5057	    key: "getDialog",
5058	    value: function getDialog() {
5059	      return this.dialog;
5060	    }
5061	    /**
5062	     * @internal
5063	     * @param dialog
5064	     */
5065
5066	  }, {
5067	    key: "setDialog",
5068	    value: function setDialog(dialog) {
5069	      this.dialog = dialog;
5070	    }
5071	  }, {
5072	    key: "setReadonly",
5073	    value: function setReadonly(flag) {
5074	      if (main_core.Type.isBoolean(flag)) {
5075	        this.readonly = flag;
5076
5077	        if (this.isRendered()) {
5078	          if (flag) {
5079	            main_core.Dom.addClass(this.getOuterContainer(), 'ui-tag-selector-container-readonly');
5080	          } else {
5081	            main_core.Dom.removeClass(this.getOuterContainer(), 'ui-tag-selector-container-readonly');
5082	          }
5083	        }
5084	      }
5085	    }
5086	  }, {
5087	    key: "isReadonly",
5088	    value: function isReadonly() {
5089	      return this.readonly;
5090	    }
5091	  }, {
5092	    key: "setLocked",
5093	    value: function setLocked(flag) {
5094	      if (main_core.Type.isBoolean(flag)) {
5095	        this.locked = flag;
5096
5097	        if (flag) {
5098	          main_core.Dom.addClass(this.getOuterContainer(), 'ui-tag-selector-container-locked');
5099	          this.getTextBox().disabled = true;
5100	        } else {
5101	          main_core.Dom.removeClass(this.getOuterContainer(), 'ui-tag-selector-container-locked');
5102	          this.getTextBox().disabled = false;
5103	        }
5104	      }
5105	    }
5106	  }, {
5107	    key: "lock",
5108	    value: function lock() {
5109	      if (!this.isLocked()) {
5110	        this.setLocked(true);
5111	      }
5112	    }
5113	  }, {
5114	    key: "unlock",
5115	    value: function unlock() {
5116	      if (this.isLocked()) {
5117	        this.setLocked(false);
5118	      }
5119	    }
5120	  }, {
5121	    key: "isLocked",
5122	    value: function isLocked() {
5123	      return this.locked;
5124	    }
5125	  }, {
5126	    key: "isMultiple",
5127	    value: function isMultiple() {
5128	      return this.multiple;
5129	    }
5130	  }, {
5131	    key: "setDeselectable",
5132	    value: function setDeselectable(flag) {
5133	      if (main_core.Type.isBoolean(flag)) {
5134	        var changed = this.deselectable !== flag;
5135	        this.deselectable = flag;
5136
5137	        if (changed) {
5138	          this.updateTags();
5139	        }
5140	      }
5141	    }
5142	  }, {
5143	    key: "isDeselectable",
5144	    value: function isDeselectable() {
5145	      return this.deselectable;
5146	    }
5147	  }, {
5148	    key: "getTag",
5149	    value: function getTag(tagItem) {
5150	      if (tagItem instanceof TagItem) {
5151	        return this.getTags().find(function (tag) {
5152	          return tag === tagItem;
5153	        });
5154	      } else if (main_core.Type.isPlainObject(tagItem)) {
5155	        var id = tagItem.id,
5156	            entityId = tagItem.entityId;
5157	        return this.getTags().find(function (tag) {
5158	          return tag.getId() === id && tag.getEntityId() === entityId;
5159	        });
5160	      }
5161
5162	      return null;
5163	    }
5164	  }, {
5165	    key: "addTag",
5166	    value: function addTag(tagOptions) {
5167	      var _this2 = this;
5168
5169	      if (!main_core.Type.isObjectLike(tagOptions)) {
5170	        throw new Error('TagSelector.addTag: wrong item options.');
5171	      }
5172
5173	      if (this.getTag(tagOptions)) {
5174	        return null;
5175	      }
5176
5177	      var tag = new TagItem(tagOptions);
5178	      tag.setSelector(this);
5179	      var event = new main_core_events.BaseEvent({
5180	        data: {
5181	          tag: tag
5182	        }
5183	      });
5184	      this.emit('onBeforeTagAdd', event);
5185
5186	      if (event.isDefaultPrevented()) {
5187	        return null;
5188	      }
5189
5190	      if (!this.isMultiple()) {
5191	        this.removeTags();
5192	      }
5193
5194	      this.tags.push(tag);
5195	      this.emit('onTagAdd', {
5196	        tag: tag
5197	      });
5198
5199	      if (this.isRendered()) {
5200	        tag.render();
5201	        this.getItemsContainer().insertBefore(tag.getContainer(), this.getTextBox());
5202
5203	        if (tagOptions.animate !== false) {
5204	          tag.show().then(function () {
5205	            _this2.getContainer().scrollTop = _this2.getContainer().scrollHeight - _this2.getContainer().offsetHeight;
5206
5207	            _this2.emit('onAfterTagAdd', {
5208	              tag: tag
5209	            });
5210	          });
5211	        } else {
5212	          this.emit('onAfterTagAdd', {
5213	            tag: tag
5214	          });
5215	        }
5216
5217	        this.toggleAddButtonCaption();
5218	      } else {
5219	        this.emit('onAfterTagAdd', {
5220	          tag: tag
5221	        });
5222	      }
5223
5224	      return tag;
5225	    }
5226	  }, {
5227	    key: "removeTag",
5228	    value: function removeTag(item) {
5229	      var _this3 = this;
5230
5231	      var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
5232	      var tagItem = this.getTag(item);
5233
5234	      if (!tagItem) {
5235	        return;
5236	      }
5237
5238	      var event = new main_core_events.BaseEvent({
5239	        data: {
5240	          tag: tagItem
5241	        }
5242	      });
5243	      this.emit('onBeforeTagRemove', event);
5244
5245	      if (event.isDefaultPrevented()) {
5246	        return;
5247	      }
5248
5249	      this.tags = this.tags.filter(function (el) {
5250	        return el !== tagItem;
5251	      });
5252	      this.emit('onTagRemove', {
5253	        tag: tagItem
5254	      });
5255
5256	      if (this.isRendered()) {
5257	        tagItem.remove(animate).then(function () {
5258	          _this3.toggleAddButtonCaption();
5259
5260	          _this3.emit('onAfterTagRemove', {
5261	            tag: tagItem
5262	          });
5263	        });
5264	      } else {
5265	        this.emit('onAfterTagRemove', {
5266	          tag: tagItem
5267	        });
5268	      }
5269	    }
5270	  }, {
5271	    key: "removeTags",
5272	    value: function removeTags() {
5273	      var _this4 = this;
5274
5275	      this.getTags().forEach(function (tag) {
5276	        _this4.removeTag(tag, false);
5277	      });
5278	    }
5279	  }, {
5280	    key: "getTags",
5281	    value: function getTags() {
5282	      return this.tags;
5283	    }
5284	  }, {
5285	    key: "renderTo",
5286	    value: function renderTo(node) {
5287	      var _this5 = this;
5288
5289	      this.rendered = true;
5290	      this.getTags().forEach(function (tag) {
5291	        tag.render();
5292
5293	        _this5.getItemsContainer().insertBefore(tag.getContainer(), _this5.getTextBox());
5294	      });
5295
5296	      if (main_core.Type.isDomNode(node)) {
5297	        main_core.Dom.append(this.getOuterContainer(), node);
5298	      }
5299	    }
5300	  }, {
5301	    key: "isRendered",
5302	    value: function isRendered() {
5303	      return this.rendered;
5304	    }
5305	    /**
5306	     * @private
5307	     */
5308
5309	  }, {
5310	    key: "updateTags",
5311	    value: function updateTags() {
5312	      if (this.isRendered()) {
5313	        this.getTags().forEach(function (tag) {
5314	          tag.render();
5315	        });
5316	      }
5317	    }
5318	  }, {
5319	    key: "getOuterContainer",
5320	    value: function getOuterContainer() {
5321	      var _this6 = this;
5322
5323	      return this.cache.remember('outer-container', function () {
5324	        var className = _this6.isReadonly() ? ' ui-tag-selector-container-readonly' : '';
5325	        className += _this6.isLocked() ? ' ui-tag-selector-container-locked' : '';
5326	        return main_core.Tag.render(_templateObject$6 || (_templateObject$6 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-outer-container", "\">", "</div>\n\t\t\t"])), className, _this6.getContainer());
5327	      });
5328	    }
5329	  }, {
5330	    key: "getContainer",
5331	    value: function getContainer() {
5332	      var _this7 = this;
5333
5334	      return this.cache.remember('container', function () {
5335	        var style = _this7.getMaxHeight() ? " style=\"max-height: ".concat(_this7.getMaxHeight(), "px; -ms-overflow-style: -ms-autohiding-scrollbar;\"") : '';
5336	        return main_core.Tag.render(_templateObject2$3 || (_templateObject2$3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div \n\t\t\t\t\tclass=\"ui-tag-selector-container\" \n\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\t", "\n\t\t\t\t>\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), _this7.handleContainerClick.bind(_this7), style, _this7.getItemsContainer(), _this7.getCreateButton());
5337	      });
5338	    }
5339	  }, {
5340	    key: "getItemsContainer",
5341	    value: function getItemsContainer() {
5342	      var _this8 = this;
5343
5344	      return this.cache.remember('items-container', function () {
5345	        return main_core.Tag.render(_templateObject3$3 || (_templateObject3$3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-items\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), _this8.getTextBox(), _this8.getAddButton());
5346	      });
5347	    }
5348	  }, {
5349	    key: "getTextBox",
5350	    value: function getTextBox() {
5351	      var _this9 = this;
5352
5353	      return this.cache.remember('text-box', function () {
5354	        var className = _this9.textBoxVisible ? '' : ' ui-tag-selector-item-hidden';
5355	        var input = main_core.Tag.render(_templateObject4$3 || (_templateObject4$3 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<input \n\t\t\t\t\ttype=\"text\" \n\t\t\t\t\tclass=\"ui-tag-selector-item ui-tag-selector-text-box", "\" \n\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\tplaceholder=\"", "\"\n\t\t\t\t\toninput=\"", "\"\n\t\t\t\t\tonblur=\"", "\"\n\t\t\t\t\tonkeyup=\"", "\"\n\t\t\t\t\tonkeydown=\"", "\"\n\t\t\t\t\tvalue=\"\"\n\t\t\t\t>\n\t\t\t"])), className, main_core.Text.encode(_this9.getPlaceholder()), _this9.handleTextBoxInput.bind(_this9), _this9.handleTextBoxBlur.bind(_this9), _this9.handleTextBoxKeyUp.bind(_this9), _this9.handleTextBoxKeyDown.bind(_this9));
5356
5357	        var width = _this9.getTextBoxWidth();
5358
5359	        if (width !== null) {
5360	          main_core.Dom.style(input, 'width', main_core.Type.isStringFilled(width) ? width : "".concat(width, "px"));
5361	        }
5362
5363	        if (_this9.isLocked()) {
5364	          input.disabled = true;
5365	        }
5366
5367	        return input;
5368	      });
5369	    }
5370	  }, {
5371	    key: "getItemsHeight",
5372	    value: function getItemsHeight() {
5373	      return this.getItemsContainer().scrollHeight;
5374	    }
5375	  }, {
5376	    key: "calcHeight",
5377	    value: function calcHeight() {
5378	      if (this.getMaxHeight() !== null) {
5379	        return Math.min(this.getItemsHeight(), this.getMaxHeight());
5380	      }
5381
5382	      return Math.max(this.getItemsHeight(), this.getMinHeight());
5383	    }
5384	  }, {
5385	    key: "getTextBoxValue",
5386	    value: function getTextBoxValue() {
5387	      return this.getTextBox().value;
5388	    }
5389	  }, {
5390	    key: "clearTextBox",
5391	    value: function clearTextBox() {
5392	      this.getTextBox().value = '';
5393	      this.textBoxOldValue = '';
5394	    }
5395	  }, {
5396	    key: "showTextBox",
5397	    value: function showTextBox() {
5398	      this.textBoxVisible = true;
5399	      main_core.Dom.removeClass(this.getTextBox(), 'ui-tag-selector-item-hidden');
5400	    }
5401	  }, {
5402	    key: "hideTextBox",
5403	    value: function hideTextBox() {
5404	      this.textBoxVisible = false;
5405	      main_core.Dom.addClass(this.getTextBox(), 'ui-tag-selector-item-hidden');
5406	    }
5407	  }, {
5408	    key: "focusTextBox",
5409	    value: function focusTextBox() {
5410	      this.getTextBox().focus();
5411	    }
5412	  }, {
5413	    key: "setTextBoxAutoHide",
5414	    value: function setTextBoxAutoHide(autoHide) {
5415	      if (main_core.Type.isBoolean(autoHide)) {
5416	        this.textBoxAutoHide = autoHide;
5417	      }
5418	    }
5419	  }, {
5420	    key: "getTextBoxWidth",
5421	    value: function getTextBoxWidth() {
5422	      return this.textBoxWidth;
5423	    }
5424	  }, {
5425	    key: "setTextBoxWidth",
5426	    value: function setTextBoxWidth(width) {
5427	      if (main_core.Type.isStringFilled(width) || width === null) {
5428	        this.textBoxWidth = width;
5429
5430	        if (this.isRendered()) {
5431	          main_core.Dom.style(this.getTextBox(), 'width', width);
5432	        }
5433	      } else if (main_core.Type.isNumber(width) && width > 0) {
5434	        this.textBoxWidth = width;
5435
5436	        if (this.isRendered()) {
5437	          main_core.Dom.style(this.getTextBox(), 'width', "".concat(width, "px"));
5438	        }
5439	      }
5440	    }
5441	  }, {
5442	    key: "getTagMaxWidth",
5443	    value: function getTagMaxWidth() {
5444	      return this.tagMaxWidth;
5445	    }
5446	  }, {
5447	    key: "setTagMaxWidth",
5448	    value: function setTagMaxWidth(width) {
5449	      if (main_core.Type.isNumber(width) && width >= 0 || width === null) {
5450	        this.tagMaxWidth = width;
5451	        this.updateTags();
5452	      }
5453	    }
5454	  }, {
5455	    key: "getTagAvatar",
5456	    value: function getTagAvatar() {
5457	      return this.tagAvatar;
5458	    }
5459	  }, {
5460	    key: "setTagAvatar",
5461	    value: function setTagAvatar(tagAvatar) {
5462	      if (main_core.Type.isString(tagAvatar) || tagAvatar === null) {
5463	        this.tagAvatar = tagAvatar;
5464	        this.updateTags();
5465	      }
5466	    }
5467	  }, {
5468	    key: "getTagAvatarOptions",
5469	    value: function getTagAvatarOptions() {
5470	      return this.tagAvatarOptions;
5471	    }
5472	  }, {
5473	    key: "getTagAvatarOption",
5474	    value: function getTagAvatarOption(option) {
5475	      if (this.tagAvatarOptions !== null && !main_core.Type.isUndefined(this.tagAvatarOptions[option])) {
5476	        return this.tagAvatarOptions[option];
5477	      }
5478
5479	      return null;
5480	    }
5481	  }, {
5482	    key: "setTagAvatarOption",
5483	    value: function setTagAvatarOption(option, value) {
5484	      if (main_core.Type.isStringFilled(option) && !main_core.Type.isUndefined(value)) {
5485	        if (this.tagAvatarOptions === null) {
5486	          this.tagAvatarOptions = {};
5487	        }
5488
5489	        this.tagAvatarOptions[option] = value;
5490	        this.updateTags();
5491	      }
5492	    }
5493	  }, {
5494	    key: "setTagAvatarOptions",
5495	    value: function setTagAvatarOptions(options) {
5496	      var _this10 = this;
5497
5498	      if (main_core.Type.isPlainObject(options)) {
5499	        Object.keys(options).forEach(function (option) {
5500	          _this10.setTagAvatarOption(option, options[option]);
5501	        });
5502	      }
5503	    }
5504	  }, {
5505	    key: "getTagTextColor",
5506	    value: function getTagTextColor() {
5507	      return this.tagTextColor;
5508	    }
5509	  }, {
5510	    key: "setTagTextColor",
5511	    value: function setTagTextColor(textColor) {
5512	      if (main_core.Type.isString(textColor) || textColor === null) {
5513	        this.tagTextColor = textColor;
5514	        this.updateTags();
5515	      }
5516	    }
5517	  }, {
5518	    key: "getTagBgColor",
5519	    value: function getTagBgColor() {
5520	      return this.tagBgColor;
5521	    }
5522	  }, {
5523	    key: "setTagBgColor",
5524	    value: function setTagBgColor(bgColor) {
5525	      if (main_core.Type.isString(bgColor) || bgColor === null) {
5526	        this.tagBgColor = bgColor;
5527	        this.updateTags();
5528	      }
5529	    }
5530	  }, {
5531	    key: "getTagFontWeight",
5532	    value: function getTagFontWeight() {
5533	      return this.tagFontWeight;
5534	    }
5535	  }, {
5536	    key: "setTagFontWeight",
5537	    value: function setTagFontWeight(fontWeight) {
5538	      if (main_core.Type.isString(fontWeight) || fontWeight === null) {
5539	        this.tagFontWeight = fontWeight;
5540	        this.updateTags();
5541	      }
5542	    }
5543	  }, {
5544	    key: "getPlaceholder",
5545	    value: function getPlaceholder() {
5546	      return this.placeholder;
5547	    }
5548	  }, {
5549	    key: "setPlaceholder",
5550	    value: function setPlaceholder(placeholder) {
5551	      if (main_core.Type.isStringFilled(placeholder)) {
5552	        this.placeholder = placeholder;
5553
5554	        if (this.isRendered()) {
5555	          this.getTextBox().placeholder = placeholder;
5556	        }
5557	      }
5558	    }
5559	  }, {
5560	    key: "getMaxHeight",
5561	    value: function getMaxHeight() {
5562	      return this.maxHeight;
5563	    }
5564	  }, {
5565	    key: "getMinHeight",
5566	    value: function getMinHeight() {
5567	      return 33;
5568	    }
5569	  }, {
5570	    key: "setMaxHeight",
5571	    value: function setMaxHeight(height) {
5572	      if (main_core.Type.isNumber(height) && height > 0 || height === null) {
5573	        this.maxHeight = height;
5574
5575	        if (this.isRendered()) {
5576	          main_core.Dom.style(this.getContainer(), 'max-height', height > 0 ? "".concat(height, "px") : null);
5577	          main_core.Dom.style(this.getContainer(), '-ms-overflow-style', height > 0 ? '-ms-autohiding-scrollbar' : null);
5578	        }
5579	      }
5580	    }
5581	  }, {
5582	    key: "getAddButton",
5583	    value: function getAddButton() {
5584	      var _this11 = this;
5585
5586	      return this.cache.remember('add-button', function () {
5587	        var className = _this11.addButtonVisible ? '' : ' ui-tag-selector-item-hidden';
5588	        return main_core.Tag.render(_templateObject5$2 || (_templateObject5$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span class=\"ui-tag-selector-item ui-tag-selector-add-button", "\">\n\t\t\t\t\t", "\n\t\t\t\t</span>\n\t\t\t"])), className, _this11.getAddButtonLink());
5589	      });
5590	    }
5591	  }, {
5592	    key: "getAddButtonLink",
5593	    value: function getAddButtonLink() {
5594	      var _this12 = this;
5595
5596	      return this.cache.remember('add-button-link', function () {
5597	        var caption = main_core.Text.encode(_this12.getActualButtonCaption());
5598	        return main_core.Tag.render(_templateObject6$1 || (_templateObject6$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span \n\t\t\t\t\tclass=\"ui-tag-selector-add-button-caption\" \n\t\t\t\t\tonclick=\"", "\">", "</span>\n\t\t\t"])), _this12.handleAddButtonClick.bind(_this12), caption);
5599	      });
5600	    }
5601	  }, {
5602	    key: "getAddButtonCaption",
5603	    value: function getAddButtonCaption() {
5604	      return this.addButtonCaption === null ? main_core.Loc.getMessage('UI_TAG_SELECTOR_ADD_BUTTON_CAPTION') : this.addButtonCaption;
5605	    }
5606	  }, {
5607	    key: "setAddButtonCaption",
5608	    value: function setAddButtonCaption(caption) {
5609	      if (main_core.Type.isStringFilled(caption)) {
5610	        this.addButtonCaption = caption;
5611
5612	        if (this.isRendered()) {
5613	          this.toggleAddButtonCaption();
5614	        }
5615	      }
5616	    }
5617	  }, {
5618	    key: "getAddButtonCaptionMore",
5619	    value: function getAddButtonCaptionMore() {
5620	      return this.addButtonCaptionMore === null ? this.isMultiple() ? main_core.Loc.getMessage('UI_TAG_SELECTOR_ADD_BUTTON_CAPTION') : main_core.Loc.getMessage('UI_TAG_SELECTOR_ADD_BUTTON_CAPTION_SINGLE') : this.addButtonCaptionMore;
5621	    }
5622	  }, {
5623	    key: "setAddButtonCaptionMore",
5624	    value: function setAddButtonCaptionMore(caption) {
5625	      if (main_core.Type.isStringFilled(caption)) {
5626	        this.addButtonCaptionMore = caption;
5627
5628	        if (this.isRendered()) {
5629	          this.toggleAddButtonCaption();
5630	        }
5631	      }
5632	    }
5633	  }, {
5634	    key: "toggleAddButtonCaption",
5635	    value: function toggleAddButtonCaption() {
5636	      if (this.getAddButtonCaptionMore() === null) {
5637	        return;
5638	      }
5639
5640	      this.getAddButtonLink().textContent = this.getActualButtonCaption();
5641	    }
5642	  }, {
5643	    key: "getActualButtonCaption",
5644	    value: function getActualButtonCaption() {
5645	      return this.getTags().length > 0 && this.getAddButtonCaptionMore() !== null ? this.getAddButtonCaptionMore() : this.getAddButtonCaption();
5646	    }
5647	  }, {
5648	    key: "showAddButton",
5649	    value: function showAddButton() {
5650	      this.addButtonVisible = true;
5651	      main_core.Dom.removeClass(this.getAddButton(), 'ui-tag-selector-item-hidden');
5652	    }
5653	  }, {
5654	    key: "hideAddButton",
5655	    value: function hideAddButton() {
5656	      this.addButtonVisible = false;
5657	      main_core.Dom.addClass(this.getAddButton(), 'ui-tag-selector-item-hidden');
5658	    }
5659	  }, {
5660	    key: "getCreateButton",
5661	    value: function getCreateButton() {
5662	      var _this13 = this;
5663
5664	      return this.cache.remember('create-button', function () {
5665	        var className = _this13.createButtonVisible ? '' : ' ui-tag-selector-item-hidden';
5666	        return main_core.Tag.render(_templateObject7 || (_templateObject7 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-tag-selector-create-button", "\">\n\t\t\t\t\t<span \n\t\t\t\t\t\tclass=\"ui-tag-selector-create-button-caption\"\n\t\t\t\t\t\tonclick=\"", "\"\n\t\t\t\t\t>", "</span>\n\t\t\t\t</div>\n\t\t\t"])), className, _this13.handleCreateButtonClick.bind(_this13), main_core.Text.encode(_this13.getCreateButtonCaption()));
5667	      });
5668	    }
5669	  }, {
5670	    key: "showCreateButton",
5671	    value: function showCreateButton() {
5672	      this.createButtonVisible = true;
5673	      main_core.Dom.removeClass(this.getCreateButton(), 'ui-tag-selector-item-hidden');
5674	    }
5675	  }, {
5676	    key: "hideCreateButton",
5677	    value: function hideCreateButton() {
5678	      this.createButtonVisible = false;
5679	      main_core.Dom.addClass(this.getCreateButton(), 'ui-tag-selector-item-hidden');
5680	    }
5681	  }, {
5682	    key: "getCreateButtonCaption",
5683	    value: function getCreateButtonCaption() {
5684	      return this.createButtonCaption === null ? main_core.Loc.getMessage('UI_TAG_SELECTOR_CREATE_BUTTON_CAPTION') : this.createButtonCaption;
5685	    }
5686	  }, {
5687	    key: "setCreateButtonCaption",
5688	    value: function setCreateButtonCaption(caption) {
5689	      if (main_core.Type.isStringFilled(caption)) {
5690	        this.createButtonCaption = caption;
5691
5692	        if (this.isRendered()) {
5693	          this.getCreateButton().children[0].textContent = caption;
5694	        }
5695	      }
5696	    }
5697	  }, {
5698	    key: "handleContainerClick",
5699	    value: function handleContainerClick(event) {
5700	      this.emit('onContainerClick', {
5701	        event: event
5702	      });
5703	    }
5704	  }, {
5705	    key: "handleTextBoxInput",
5706	    value: function handleTextBoxInput(event) {
5707	      var newValue = this.getTextBoxValue();
5708
5709	      if (newValue !== this.textBoxOldValue) {
5710	        this.textBoxOldValue = newValue;
5711	        this.emit('onInput', {
5712	          event: event
5713	        });
5714	      }
5715	    }
5716	  }, {
5717	    key: "handleTextBoxBlur",
5718	    value: function handleTextBoxBlur(event) {
5719	      this.emit('onBlur', {
5720	        event: event
5721	      });
5722
5723	      if (this.textBoxAutoHide) {
5724	        this.clearTextBox();
5725	        this.showAddButton();
5726	        this.hideTextBox();
5727	      }
5728	    }
5729	  }, {
5730	    key: "handleTextBoxKeyUp",
5731	    value: function handleTextBoxKeyUp(event) {
5732	      this.emit('onKeyUp', {
5733	        event: event
5734	      });
5735
5736	      if (event.key === 'Enter') {
5737	        this.emit('onEnter', {
5738	          event: event
5739	        });
5740
5741	        if (this.textBoxAutoHide) {
5742	          this.clearTextBox();
5743	          this.showAddButton();
5744	          this.hideTextBox();
5745	        }
5746	      }
5747	    }
5748	  }, {
5749	    key: "handleTextBoxKeyDown",
5750	    value: function handleTextBoxKeyDown(event) {
5751	      if (event.key === 'Enter') {
5752	        // prevent a form submit
5753	        event.preventDefault();
5754
5755	        if (main_core.Browser.isMac() && event.metaKey || event.ctrlKey) {
5756	          this.emit('onMetaEnter', {
5757	            event: event
5758	          });
5759	        }
5760	      }
5761
5762	      this.emit('onKeyDown', {
5763	        event: event
5764	      });
5765	    }
5766	  }, {
5767	    key: "handleAddButtonClick",
5768	    value: function handleAddButtonClick(event) {
5769	      this.hideAddButton();
5770	      this.showTextBox();
5771	      this.focusTextBox();
5772	      this.emit('onAddButtonClick', {
5773	        event: event
5774	      });
5775	    }
5776	  }, {
5777	    key: "handleCreateButtonClick",
5778	    value: function handleCreateButtonClick(event) {
5779	      this.emit('onCreateButtonClick', {
5780	        event: event
5781	      });
5782	    }
5783	  }]);
5784	  return TagSelector;
5785	}(main_core_events.EventEmitter);
5786
5787	var Navigation = /*#__PURE__*/function () {
5788	  // IE/Edge compatible event names
5789	  function Navigation(dialog) {
5790	    babelHelpers.classCallCheck(this, Navigation);
5791	    babelHelpers.defineProperty(this, "dialog", null);
5792	    babelHelpers.defineProperty(this, "lockedTab", null);
5793	    babelHelpers.defineProperty(this, "enabled", false);
5794	    this.dialog = dialog;
5795	    this.dialog.subscribe('onShow', this.handleDialogShow.bind(this));
5796	    this.dialog.subscribe('onHide', this.handleDialogHide.bind(this));
5797	    this.dialog.subscribe('onDestroy', this.handleDialogDestroy.bind(this));
5798	    this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
5799	    this.handleDocumentMouseMove = this.handleDocumentMouseMove.bind(this);
5800	  }
5801
5802	  babelHelpers.createClass(Navigation, [{
5803	    key: "getDialog",
5804	    value: function getDialog() {
5805	      return this.dialog;
5806	    }
5807	  }, {
5808	    key: "enable",
5809	    value: function enable() {
5810	      if (!this.isEnabled()) {
5811	        this.bindEvents();
5812	      }
5813
5814	      this.enabled = true;
5815	    }
5816	  }, {
5817	    key: "disable",
5818	    value: function disable() {
5819	      if (this.isEnabled()) {
5820	        this.unbindEvents();
5821	        this.unlockTab();
5822	      }
5823
5824	      this.enabled = false;
5825	    }
5826	  }, {
5827	    key: "isEnabled",
5828	    value: function isEnabled() {
5829	      return this.enabled;
5830	    }
5831	  }, {
5832	    key: "bindEvents",
5833	    value: function bindEvents() {
5834	      main_core.Event.bind(document, 'keydown', this.handleDocumentKeyDown);
5835	    }
5836	  }, {
5837	    key: "unbindEvents",
5838	    value: function unbindEvents() {
5839	      main_core.Event.unbind(document, 'keydown', this.handleDocumentKeyDown);
5840	    }
5841	  }, {
5842	    key: "getNextNode",
5843	    value: function getNextNode() {
5844	      if (!this.getActiveNode()) {
5845	        return null;
5846	      }
5847
5848	      var nextNode = null;
5849	      var currentNode = this.getActiveNode();
5850
5851	      if (currentNode.hasChildren() && currentNode.isOpen()) {
5852	        nextNode = currentNode.getFirstChild();
5853	      }
5854
5855	      while (nextNode === null && currentNode !== null) {
5856	        nextNode = currentNode.getNextSibling();
5857
5858	        if (nextNode) {
5859	          break;
5860	        }
5861
5862	        currentNode = currentNode.getParentNode();
5863	      }
5864
5865	      return nextNode;
5866	    }
5867	  }, {
5868	    key: "getPreviousNode",
5869	    value: function getPreviousNode() {
5870	      if (!this.getActiveNode()) {
5871	        return null;
5872	      }
5873
5874	      var previousNode = this.getActiveNode().getPreviousSibling();
5875
5876	      if (previousNode) {
5877	        while (previousNode.hasChildren() && previousNode.isOpen()) {
5878	          var lastChild = previousNode.getLastChild();
5879
5880	          if (lastChild === null) {
5881	            break;
5882	          }
5883
5884	          previousNode = lastChild;
5885	        }
5886	      } else {
5887	        if (this.getActiveNode().getParentNode() && !this.getActiveNode().getParentNode().isRoot()) {
5888	          previousNode = this.getActiveNode().getParentNode();
5889	        }
5890	      }
5891
5892	      return previousNode;
5893	    }
5894	  }, {
5895	    key: "getFirstNode",
5896	    value: function getFirstNode() {
5897	      var tab = this.getDialog().getActiveTab();
5898	      return tab && tab.getRootNode().getFirstChild();
5899	    }
5900	  }, {
5901	    key: "getLastNode",
5902	    value: function getLastNode() {
5903	      var tab = this.getDialog().getActiveTab();
5904
5905	      if (!tab) {
5906	        return null;
5907	      }
5908
5909	      var lastNode = tab.getRootNode().getLastChild();
5910
5911	      if (lastNode !== null) {
5912	        while (lastNode.hasChildren() && lastNode.isOpen()) {
5913	          var lastChild = lastNode.getLastChild();
5914
5915	          if (lastChild === null) {
5916	            break;
5917	          }
5918
5919	          lastNode = lastChild;
5920	        }
5921	      }
5922
5923	      return lastNode;
5924	    }
5925	  }, {
5926	    key: "getActiveNode",
5927	    value: function getActiveNode() {
5928	      return this.getDialog().getFocusedNode();
5929	    }
5930	  }, {
5931	    key: "focusOnNode",
5932	    value: function focusOnNode(node) {
5933	      if (node) {
5934	        node.focus();
5935	        node.scrollIntoView();
5936	      }
5937	    }
5938	  }, {
5939	    key: "lockTab",
5940	    value: function lockTab() {
5941	      var activeTab = this.getDialog().getActiveTab();
5942
5943	      if (this.lockedTab === activeTab) {
5944	        return;
5945	      } else if (this.lockedTab !== null) {
5946	        this.unlockTab();
5947	      }
5948
5949	      this.lockedTab = activeTab;
5950	      this.lockedTab.lock();
5951	      main_core.Event.bind(document, 'mousemove', this.handleDocumentMouseMove);
5952	    }
5953	  }, {
5954	    key: "unlockTab",
5955	    value: function unlockTab() {
5956	      if (this.lockedTab === null) {
5957	        return;
5958	      }
5959
5960	      this.lockedTab.unlock();
5961	      this.lockedTab = null;
5962	      main_core.Event.unbind(document, 'mousemove', this.handleDocumentMouseMove);
5963	    }
5964	  }, {
5965	    key: "handleDialogShow",
5966	    value: function handleDialogShow() {
5967	      this.enable();
5968	    }
5969	  }, {
5970	    key: "handleDialogHide",
5971	    value: function handleDialogHide() {
5972	      this.disable();
5973	    }
5974	  }, {
5975	    key: "handleDialogDestroy",
5976	    value: function handleDialogDestroy() {
5977	      this.disable();
5978	    }
5979	  }, {
5980	    key: "handleDocumentMouseMove",
5981	    value: function handleDocumentMouseMove() {
5982	      this.unlockTab();
5983	    }
5984	  }, {
5985	    key: "handleDocumentKeyDown",
5986	    value: function handleDocumentKeyDown(event) {
5987	      if (!this.getDialog().isOpen()) {
5988	        this.unbindEvents();
5989	        return;
5990	      }
5991
5992	      if (event.metaKey || event.ctrlKey || event.altKey) {
5993	        return;
5994	      }
5995
5996	      var activeTab = this.getDialog().getActiveTab();
5997
5998	      if (!activeTab) {
5999	        return;
6000	      }
6001
6002	      var keyName = this.constructor.keyMap[event.key] || event.key;
6003
6004	      if (activeTab === this.getDialog().getSearchTab() && ['ArrowLeft', 'ArrowRight'].includes(keyName)) {
6005	        return;
6006	      }
6007
6008	      var handler = this["handle".concat(keyName, "Press")];
6009
6010	      if (handler) {
6011	        handler.call(this, event);
6012	        this.lockTab(activeTab);
6013	        event.preventDefault();
6014	      }
6015	    }
6016	  }, {
6017	    key: "handleArrowDownPress",
6018	    value: function handleArrowDownPress() {
6019	      if (!this.getActiveNode()) {
6020	        var firstNode = this.getFirstNode();
6021	        this.focusOnNode(firstNode);
6022	      } else {
6023	        var nextNode = this.getNextNode();
6024
6025	        if (nextNode) {
6026	          this.focusOnNode(nextNode);
6027	        } else {
6028	          var _firstNode = this.getFirstNode();
6029
6030	          this.focusOnNode(_firstNode);
6031	        }
6032	      }
6033	    }
6034	  }, {
6035	    key: "handleArrowUpPress",
6036	    value: function handleArrowUpPress() {
6037	      if (!this.getActiveNode()) {
6038	        var lastNode = this.getLastNode();
6039	        this.focusOnNode(lastNode);
6040	      } else {
6041	        var previousNode = this.getPreviousNode();
6042
6043	        if (previousNode) {
6044	          this.focusOnNode(previousNode);
6045	        } else {
6046	          var _lastNode = this.getLastNode();
6047
6048	          this.focusOnNode(_lastNode);
6049	        }
6050	      }
6051	    }
6052	  }, {
6053	    key: "handleArrowRightPress",
6054	    value: function handleArrowRightPress() {
6055	      if (this.getActiveNode()) {
6056	        this.getActiveNode().expand();
6057	      }
6058	    }
6059	  }, {
6060	    key: "handleArrowLeftPress",
6061	    value: function handleArrowLeftPress() {
6062	      if (!this.getActiveNode()) {
6063	        return;
6064	      }
6065
6066	      if (this.getActiveNode().isOpen()) {
6067	        this.getActiveNode().collapse();
6068	      } else {
6069	        var parentNode = this.getActiveNode().getParentNode();
6070
6071	        if (parentNode && !parentNode.isRoot()) {
6072	          this.focusOnNode(parentNode);
6073	        }
6074	      }
6075	    }
6076	  }, {
6077	    key: "handleEnterPress",
6078	    value: function handleEnterPress() {
6079	      if (this.getActiveNode()) {
6080	        this.getActiveNode().click();
6081	      }
6082	    }
6083	    /*handleSpacePress(event: KeyboardEvent): void
6084	    {
6085	    	const searchQuery = this.getDialog().getTagSelector() && this.getDialog().getTagSelector().getTextBoxValue();
6086	    	if (this.getActiveNode() && !Type.isStringFilled(searchQuery))
6087	    	{
6088	    		this.getActiveNode().click();
6089	    		event.preventDefault();
6090	    	}
6091	    }*/
6092
6093	  }, {
6094	    key: "handleTabPress",
6095	    value: function handleTabPress(event) {
6096	      var activeTab = this.getDialog().getActiveTab();
6097
6098	      if (!activeTab) {
6099	        this.getDialog().selectFirstTab();
6100	        return;
6101	      }
6102
6103	      if (event.shiftKey) {
6104	        var previousTab = this.getDialog().getPreviousTab();
6105
6106	        if (previousTab) {
6107	          this.getDialog().selectTab(previousTab.getId());
6108	        } else {
6109	          this.getDialog().selectLastTab();
6110	        }
6111	      } else {
6112	        var nextTab = this.getDialog().getNextTab();
6113
6114	        if (nextTab) {
6115	          this.getDialog().selectTab(nextTab.getId());
6116	        } else {
6117	          this.getDialog().selectFirstTab();
6118	        }
6119	      }
6120	    }
6121	  }]);
6122	  return Navigation;
6123	}();
6124
6125	babelHelpers.defineProperty(Navigation, "keyMap", {
6126	  'Down': 'ArrowDown',
6127	  'Up': 'ArrowUp',
6128	  'Left': 'ArrowLeft',
6129	  'Right': 'ArrowRight',
6130	  'Spacebar': 'Space',
6131	  ' ': 'Space' // For all browsers
6132
6133	});
6134
6135	var SliderIntegration = /*#__PURE__*/function () {
6136	  function SliderIntegration(dialog) {
6137	    babelHelpers.classCallCheck(this, SliderIntegration);
6138	    babelHelpers.defineProperty(this, "dialog", null);
6139	    babelHelpers.defineProperty(this, "sliders", new Set());
6140	    this.dialog = dialog;
6141	    this.dialog.subscribe('onShow', this.handleDialogShow.bind(this));
6142	    this.dialog.subscribe('onHide', this.handleDialogHide.bind(this));
6143	    this.dialog.subscribe('onDestroy', this.handleDialogDestroy.bind(this));
6144	    this.handleSliderOpen = this.handleSliderOpen.bind(this);
6145	    this.handleSliderClose = this.handleSliderClose.bind(this);
6146	    this.handleSliderDestroy = this.handleSliderDestroy.bind(this);
6147	  }
6148
6149	  babelHelpers.createClass(SliderIntegration, [{
6150	    key: "getDialog",
6151	    value: function getDialog() {
6152	      return this.dialog;
6153	    }
6154	  }, {
6155	    key: "bindEvents",
6156	    value: function bindEvents() {
6157	      this.unbindEvents();
6158
6159	      if (top.BX) {
6160	        top.BX.Event.EventEmitter.subscribe('SidePanel.Slider:onOpen', this.handleSliderOpen);
6161	        top.BX.Event.EventEmitter.subscribe('SidePanel.Slider:onCloseComplete', this.handleSliderClose);
6162	        top.BX.Event.EventEmitter.subscribe('SidePanel.Slider:onDestroy', this.handleSliderDestroy);
6163	      }
6164	    }
6165	  }, {
6166	    key: "unbindEvents",
6167	    value: function unbindEvents() {
6168	      if (top.BX) {
6169	        top.BX.Event.EventEmitter.unsubscribe('SidePanel.Slider:onOpen', this.handleSliderOpen);
6170	        top.BX.Event.EventEmitter.unsubscribe('SidePanel.Slider:onCloseComplete', this.handleSliderClose);
6171	        top.BX.Event.EventEmitter.unsubscribe('SidePanel.Slider:onDestroy', this.handleSliderDestroy);
6172	      }
6173	    }
6174	  }, {
6175	    key: "isDialogInSlider",
6176	    value: function isDialogInSlider(slider) {
6177	      if (slider.getFrameWindow()) {
6178	        return slider.getFrameWindow().document.contains(this.getDialog().getContainer());
6179	      } else {
6180	        return slider.getContainer().contains(this.getDialog().getContainer());
6181	      }
6182	    }
6183	  }, {
6184	    key: "handleDialogShow",
6185	    value: function handleDialogShow() {
6186	      this.bindEvents();
6187	    }
6188	  }, {
6189	    key: "handleDialogHide",
6190	    value: function handleDialogHide() {
6191	      this.sliders.clear();
6192	      this.unbindEvents();
6193	      this.getDialog().unfreeze();
6194	    }
6195	  }, {
6196	    key: "handleDialogDestroy",
6197	    value: function handleDialogDestroy() {
6198	      this.sliders.clear();
6199	      this.unbindEvents();
6200	      this.getDialog().unfreeze();
6201	    }
6202	  }, {
6203	    key: "handleSliderOpen",
6204	    value: function handleSliderOpen(event) {
6205	      var _event$getData = event.getData(),
6206	          _event$getData2 = babelHelpers.slicedToArray(_event$getData, 1),
6207	          sliderEvent = _event$getData2[0];
6208
6209	      var slider = sliderEvent.getSlider();
6210
6211	      if (!this.isDialogInSlider(slider)) {
6212	        this.sliders.add(slider);
6213	        this.getDialog().freeze();
6214	      }
6215	    }
6216	  }, {
6217	    key: "handleSliderClose",
6218	    value: function handleSliderClose(event) {
6219	      var _event$getData3 = event.getData(),
6220	          _event$getData4 = babelHelpers.slicedToArray(_event$getData3, 1),
6221	          sliderEvent = _event$getData4[0];
6222
6223	      var slider = sliderEvent.getSlider();
6224	      this.sliders["delete"](slider);
6225
6226	      if (this.sliders.size === 0) {
6227	        this.getDialog().unfreeze();
6228	      }
6229	    }
6230	  }, {
6231	    key: "handleSliderDestroy",
6232	    value: function handleSliderDestroy(event) {
6233	      var _event$getData5 = event.getData(),
6234	          _event$getData6 = babelHelpers.slicedToArray(_event$getData5, 1),
6235	          sliderEvent = _event$getData6[0];
6236
6237	      var slider = sliderEvent.getSlider();
6238
6239	      if (this.isDialogInSlider(slider)) {
6240	        this.unbindEvents();
6241	        this.dialog.destroy();
6242	      } else {
6243	        this.sliders["delete"](slider);
6244
6245	        if (this.sliders.size === 0) {
6246	          this.getDialog().unfreeze();
6247	        }
6248	      }
6249	    }
6250	  }]);
6251	  return SliderIntegration;
6252	}();
6253
6254	var _templateObject$7;
6255
6256	var DefaultHeader = /*#__PURE__*/function (_BaseHeader) {
6257	  babelHelpers.inherits(DefaultHeader, _BaseHeader);
6258
6259	  function DefaultHeader(context, options) {
6260	    var _this;
6261
6262	    babelHelpers.classCallCheck(this, DefaultHeader);
6263	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(DefaultHeader).call(this, context, options));
6264	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "content", null);
6265
6266	    _this.setContent(_this.getOption('content'));
6267
6268	    return _this;
6269	  }
6270
6271	  babelHelpers.createClass(DefaultHeader, [{
6272	    key: "render",
6273	    value: function render() {
6274	      var container = main_core.Tag.render(_templateObject$7 || (_templateObject$7 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div>\n\t\t\t\t", "\n\t\t\t</div>\n\t\t"])), this.getContent() ? this.getContent() : '');
6275	      var className = this.getOption('containerClass', 'ui-selector-header-default');
6276	      var containerStyles = this.getOption('containerStyles', {});
6277	      main_core.Dom.addClass(container, className);
6278	      main_core.Dom.style(container, containerStyles);
6279	      return container;
6280	    }
6281	  }, {
6282	    key: "getContent",
6283	    value: function getContent() {
6284	      return this.content;
6285	    }
6286	  }, {
6287	    key: "setContent",
6288	    value: function setContent(content) {
6289	      if (main_core.Type.isStringFilled(content) || main_core.Type.isDomNode(content) || main_core.Type.isArrayFilled(content)) {
6290	        this.content = content;
6291	      }
6292	    }
6293	  }]);
6294	  return DefaultHeader;
6295	}(BaseHeader);
6296
6297	var _templateObject$8;
6298
6299	var DefaultFooter = /*#__PURE__*/function (_BaseFooter) {
6300	  babelHelpers.inherits(DefaultFooter, _BaseFooter);
6301
6302	  function DefaultFooter(context, options) {
6303	    var _this;
6304
6305	    babelHelpers.classCallCheck(this, DefaultFooter);
6306	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(DefaultFooter).call(this, context, options));
6307	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "content", null);
6308
6309	    _this.setContent(_this.getOption('content'));
6310
6311	    return _this;
6312	  }
6313
6314	  babelHelpers.createClass(DefaultFooter, [{
6315	    key: "render",
6316	    value: function render() {
6317	      var container = main_core.Tag.render(_templateObject$8 || (_templateObject$8 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div>\n\t\t\t\t", "\n\t\t\t</div>\n\t\t"])), this.getContent() ? this.getContent() : '');
6318	      var className = this.getOption('containerClass', 'ui-selector-footer-default');
6319	      var containerStyles = this.getOption('containerStyles', {});
6320	      main_core.Dom.addClass(container, className);
6321	      main_core.Dom.style(container, containerStyles);
6322	      return container;
6323	    }
6324	  }, {
6325	    key: "getContent",
6326	    value: function getContent() {
6327	      return this.content;
6328	    }
6329	  }, {
6330	    key: "setContent",
6331	    value: function setContent(content) {
6332	      if (main_core.Type.isStringFilled(content) || main_core.Type.isDomNode(content) || main_core.Type.isArrayFilled(content)) {
6333	        this.content = content;
6334	      }
6335	    }
6336	  }]);
6337	  return DefaultFooter;
6338	}(BaseFooter);
6339
6340	var RecentTab = /*#__PURE__*/function (_Tab) {
6341	  babelHelpers.inherits(RecentTab, _Tab);
6342
6343	  function RecentTab(dialog, tabOptions) {
6344	    babelHelpers.classCallCheck(this, RecentTab);
6345	    var icon = 'data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2223%22%20height%3D%2223%22%20fill%3D%' + '22none%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Cpath%20d%3D%22M14.432%2013.985a.96.' + '96%200%2000-.96-.96H8.505a.96.96%200%20000%201.92h4.967c.53%200%20.96-.43.96-.96zM14.432%2011.' + '009a.96.96%200%2000-.96-.96H8.505a.96.96%200%20000%201.92h4.967c.53%200%20.96-.43.96-.96zM14.' + '432%208.033a.96.96%200%2000-.96-.96H8.505a.96.96%200%20000%201.92h4.967c.53%200%20.96-.43.96-.' + '96z%22%20fill%3D%22%23ABB1B8%22/%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd' + '%22%20d%3D%22M10.988%2019.52c1.8%200%203.469-.558%204.844-1.51l2.205%202.204a1.525%201.525%200%20' + '102.157-2.157l-2.205-2.205a8.512%208.512%200%2010-7%203.668zm0-2.403a6.108%206.108%200%20100-12.2' + '16%206.108%206.108%200%20000%2012.216z%22%20fill%3D%22%23ABB1B8%22/%3E%3C/svg%3E';
6346	    var defaults = {
6347	      title: main_core.Loc.getMessage('UI_SELECTOR_RECENT_TAB_TITLE'),
6348	      itemOrder: {
6349	        sort: 'asc'
6350	      },
6351	      visible: !dialog.isDropdownMode(),
6352	      stub: !dialog.isDropdownMode(),
6353	      icon: {
6354	        //default: '/bitrix/js/ui/entity-selector/src/css/images/recent-tab-icon.svg',
6355	        //selected: '/bitrix/js/ui/entity-selector/src/css/images/recent-tab-icon-selected.svg'
6356	        "default": icon,
6357	        selected: icon.replace(/ABB1B8/g, 'fff')
6358	      }
6359	    };
6360	    var options = Object.assign({}, defaults, tabOptions);
6361	    options.id = 'recents';
6362	    return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(RecentTab).call(this, dialog, options));
6363	  }
6364
6365	  return RecentTab;
6366	}(Tab);
6367
6368	var MatchResult = /*#__PURE__*/function () {
6369	  function MatchResult(item, queryWords) {
6370	    var matchIndexes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6371	    babelHelpers.classCallCheck(this, MatchResult);
6372	    babelHelpers.defineProperty(this, "item", null);
6373	    babelHelpers.defineProperty(this, "queryWords", null);
6374	    babelHelpers.defineProperty(this, "matchFields", new Map());
6375	    babelHelpers.defineProperty(this, "sort", null);
6376	    this.item = item;
6377	    this.queryWords = queryWords;
6378	    this.addIndexes(matchIndexes);
6379	  }
6380
6381	  babelHelpers.createClass(MatchResult, [{
6382	    key: "getItem",
6383	    value: function getItem() {
6384	      return this.item;
6385	    }
6386	  }, {
6387	    key: "getQueryWords",
6388	    value: function getQueryWords() {
6389	      return this.queryWords;
6390	    }
6391	  }, {
6392	    key: "getMatchFields",
6393	    value: function getMatchFields() {
6394	      return this.matchFields;
6395	    }
6396	  }, {
6397	    key: "getSort",
6398	    value: function getSort() {
6399	      return this.sort;
6400	    }
6401	  }, {
6402	    key: "addIndex",
6403	    value: function addIndex(matchIndex) {
6404	      var matchField = this.matchFields.get(matchIndex.getField());
6405
6406	      if (!matchField) {
6407	        matchField = new MatchField(matchIndex.getField());
6408	        this.matchFields.set(matchIndex.getField(), matchField);
6409	        var fieldSort = matchIndex.getField().getSort();
6410
6411	        if (fieldSort !== null) {
6412	          this.sort = this.sort === null ? fieldSort : Math.min(this.sort, fieldSort);
6413	        }
6414	      }
6415
6416	      matchField.addIndex(matchIndex);
6417	    }
6418	  }, {
6419	    key: "addIndexes",
6420	    value: function addIndexes(matchIndexes) {
6421	      var _this = this;
6422
6423	      matchIndexes.forEach(function (matchIndex) {
6424	        _this.addIndex(matchIndex);
6425	      });
6426	    }
6427	  }]);
6428	  return MatchResult;
6429	}();
6430
6431	var collator = new Intl.Collator(undefined, {
6432	  sensitivity: 'base'
6433	});
6434
6435	var SearchEngine = /*#__PURE__*/function () {
6436	  function SearchEngine() {
6437	    babelHelpers.classCallCheck(this, SearchEngine);
6438	  }
6439
6440	  babelHelpers.createClass(SearchEngine, null, [{
6441	    key: "matchItems",
6442	    value: function matchItems(items, searchQuery) {
6443	      var matchResults = [];
6444	      var queryWords = searchQuery.getQueryWords();
6445	      var limit = searchQuery.getResultLimit();
6446
6447	      for (var i = 0; i < items.length; i++) {
6448	        if (limit === 0) {
6449	          break;
6450	        }
6451
6452	        var item = items[i];
6453
6454	        if (item.isSelected() || !item.isSearchable() || item.isHidden() || !item.getEntity().isSearchable()) {
6455	          continue;
6456	        }
6457
6458	        var matchResult = this.matchItem(item, queryWords);
6459
6460	        if (matchResult) {
6461	          matchResults.push(matchResult);
6462	          limit--;
6463	        }
6464	      }
6465
6466	      return matchResults;
6467	    }
6468	  }, {
6469	    key: "matchItem",
6470	    value: function matchItem(item, queryWords) {
6471	      var matches = [];
6472
6473	      for (var i = 0; i < queryWords.length; i++) {
6474	        var queryWord = queryWords[i];
6475	        var results = this.matchWord(item, queryWord); //const match = this.matchWord(item, queryWord);
6476	        //if (match === null)
6477
6478	        if (results.length === 0) {
6479	          return null;
6480	        } else {
6481	          matches = matches.concat(results); //matches.push(match);
6482	        }
6483	      }
6484
6485	      if (matches.length > 0) {
6486	        return new MatchResult(item, queryWords, matches);
6487	      } else {
6488	        return null;
6489	      }
6490	    }
6491	  }, {
6492	    key: "matchWord",
6493	    value: function matchWord(item, queryWord) {
6494	      var searchIndexes = item.getSearchIndex().getIndexes();
6495	      var matches = [];
6496
6497	      for (var i = 0; i < searchIndexes.length; i++) {
6498	        var fieldIndex = searchIndexes[i];
6499	        var indexes = fieldIndex.getIndexes();
6500
6501	        for (var j = 0; j < indexes.length; j++) {
6502	          var index = indexes[j];
6503	          var word = index.getWord().substring(0, queryWord.length);
6504
6505	          if (collator.compare(queryWord, word) === 0) {
6506	            matches.push(new MatchIndex(fieldIndex.getField(), queryWord, index.getStartIndex())); //return new MatchIndex(field, queryWord, index[i][1]);
6507	          }
6508	        }
6509
6510	        if (matches.length > 0) {
6511	          break;
6512	        }
6513	      }
6514
6515	      return matches; //return null;
6516	    }
6517	  }]);
6518	  return SearchEngine;
6519	}();
6520
6521	var SearchQuery = /*#__PURE__*/function () {
6522	  function SearchQuery(query) {
6523	    babelHelpers.classCallCheck(this, SearchQuery);
6524	    babelHelpers.defineProperty(this, "queryWords", []);
6525	    babelHelpers.defineProperty(this, "query", '');
6526	    babelHelpers.defineProperty(this, "cacheable", true);
6527	    babelHelpers.defineProperty(this, "dynamicSearchEntities", []);
6528	    babelHelpers.defineProperty(this, "resultLimit", 100);
6529	    this.query = query.trim().replace(/\s\s+/g, ' ');
6530	    this.queryWords = main_core.Type.isStringFilled(this.query) ? this.query.split(' ') : [];
6531	  }
6532
6533	  babelHelpers.createClass(SearchQuery, [{
6534	    key: "getQueryWords",
6535	    value: function getQueryWords() {
6536	      return this.queryWords;
6537	    }
6538	  }, {
6539	    key: "getQuery",
6540	    value: function getQuery() {
6541	      return this.query;
6542	    }
6543	  }, {
6544	    key: "isEmpty",
6545	    value: function isEmpty() {
6546	      return this.getQueryWords().length === 0;
6547	    }
6548	  }, {
6549	    key: "setCacheable",
6550	    value: function setCacheable(flag) {
6551	      if (main_core.Type.isBoolean(flag)) {
6552	        this.cacheable = flag;
6553	      }
6554	    }
6555	  }, {
6556	    key: "isCacheable",
6557	    value: function isCacheable() {
6558	      return this.cacheable;
6559	    }
6560	  }, {
6561	    key: "setResultLimit",
6562	    value: function setResultLimit(limit) {
6563	      if (main_core.Type.isNumber(limit) && limit >= 0) {
6564	        this.resultLimit = limit;
6565	      }
6566	    }
6567	  }, {
6568	    key: "getResultLimit",
6569	    value: function getResultLimit() {
6570	      return this.resultLimit;
6571	    }
6572	  }, {
6573	    key: "hasDynamicSearch",
6574	    value: function hasDynamicSearch() {
6575	      return this.getDynamicSearchEntities().length > 0;
6576	    }
6577	  }, {
6578	    key: "hasDynamicSearchEntity",
6579	    value: function hasDynamicSearchEntity(entityId) {
6580	      return this.getDynamicSearchEntities().includes(entityId);
6581	    }
6582	  }, {
6583	    key: "setDynamicSearchEntities",
6584	    value: function setDynamicSearchEntities(entities) {
6585	      var _this = this;
6586
6587	      if (main_core.Type.isArrayFilled(entities)) {
6588	        entities.forEach(function (entityId) {
6589	          if (main_core.Type.isStringFilled(entityId) && !_this.hasDynamicSearchEntity(entityId)) {
6590	            _this.dynamicSearchEntities.push(entityId);
6591	          }
6592	        });
6593	      }
6594
6595	      return this.dynamicSearchEntities;
6596	    }
6597	  }, {
6598	    key: "getDynamicSearchEntities",
6599	    value: function getDynamicSearchEntities() {
6600	      return this.dynamicSearchEntities;
6601	    }
6602	  }, {
6603	    key: "getAjaxJson",
6604	    value: function getAjaxJson() {
6605	      return this.toJSON();
6606	    }
6607	  }, {
6608	    key: "toJSON",
6609	    value: function toJSON() {
6610	      return {
6611	        queryWords: this.getQueryWords(),
6612	        query: this.getQuery(),
6613	        dynamicSearchEntities: this.getDynamicSearchEntities()
6614	      };
6615	    }
6616	  }]);
6617	  return SearchQuery;
6618	}();
6619
6620	var _templateObject$9, _templateObject2$4, _templateObject3$4, _templateObject4$4, _templateObject5$3;
6621
6622	var SearchLoader = /*#__PURE__*/function () {
6623	  function SearchLoader(tab) {
6624	    babelHelpers.classCallCheck(this, SearchLoader);
6625	    babelHelpers.defineProperty(this, "tab", null);
6626	    babelHelpers.defineProperty(this, "loader", null);
6627	    babelHelpers.defineProperty(this, "cache", new main_core.Cache.MemoryCache());
6628	    this.tab = tab;
6629	  }
6630
6631	  babelHelpers.createClass(SearchLoader, [{
6632	    key: "getTab",
6633	    value: function getTab() {
6634	      return this.tab;
6635	    }
6636	  }, {
6637	    key: "getLoader",
6638	    value: function getLoader() {
6639	      if (this.loader === null) {
6640	        this.loader = new main_loader.Loader({
6641	          target: this.getIconContainer(),
6642	          size: 32
6643	        });
6644	      }
6645
6646	      return this.loader;
6647	    }
6648	  }, {
6649	    key: "getContainer",
6650	    value: function getContainer() {
6651	      var _this = this;
6652
6653	      return this.cache.remember('container', function () {
6654	        return main_core.Tag.render(_templateObject$9 || (_templateObject$9 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-search-loader\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>
6654\n\t\t\t"])), _this.getBoxContainer(), _this.getSpacerContainer());
6655	      });
6656	    }
6657	  }, {
6658	    key: "getBoxContainer",
6659	    value: function getBoxContainer() {
6660	      var _this2 = this;
6661
6662	      return this.cache.remember('box-container', function () {
6663	        return main_core.Tag.render(_templateObject2$4 || (_templateObject2$4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-search-loader-box\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>"])), _this2.getIconContainer(), _this2.getTextContainer());
6664	      });
6665	    }
6666	  }, {
6667	    key: "getIconContainer",
6668	    value: function getIconContainer() {
6669	      return this.cache.remember('icon', function () {
6670	        return main_core.Tag.render(_templateObject3$4 || (_templateObject3$4 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-search-loader-icon\"></div>"])));
6671	      });
6672	    }
6673	  }, {
6674	    key: "getTextContainer",
6675	    value: function getTextContainer() {
6676	      return this.cache.remember('text', function () {
6677	        return main_core.Tag.render(_templateObject4$4 || (_templateObject4$4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-search-loader-text\">", "</div>\n\t\t\t"])), main_core.Loc.getMessage('UI_SELECTOR_SEARCH_LOADER_TEXT'));
6678	      });
6679	    }
6680	  }, {
6681	    key: "getSpacerContainer",
6682	    value: function getSpacerContainer() {
6683	      return this.cache.remember('spacer', function () {
6684	        return main_core.Tag.render(_templateObject5$3 || (_templateObject5$3 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-search-loader-spacer\"></div>"])));
6685	      });
6686	    }
6687	  }, {
6688	    key: "show",
6689	    value: function show() {
6690	      var _this3 = this;
6691
6692	      if (!this.getContainer().parentNode) {
6693	        main_core.Dom.append(this.getContainer(), this.getTab().getContainer());
6694	      }
6695
6696	      void this.getLoader().show();
6697	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-search-loader--show');
6698	      requestAnimationFrame(function () {
6699	        main_core.Dom.addClass(_this3.getContainer(), 'ui-selector-search-loader--animate');
6700	      });
6701	    }
6702	  }, {
6703	    key: "hide",
6704	    value: function hide() {
6705	      if (this.loader === null) {
6706	        return;
6707	      }
6708
6709	      main_core.Dom.removeClass(this.getContainer(), ['ui-selector-search-loader--show', 'ui-selector-search-loader--animate']);
6710	      void this.getLoader().hide();
6711	    }
6712	  }, {
6713	    key: "isShown",
6714	    value: function isShown() {
6715	      return this.loader !== null && this.loader.isShown();
6716	    }
6717	  }]);
6718	  return SearchLoader;
6719	}();
6720
6721	var _templateObject$a, _templateObject2$5, _templateObject3$5, _templateObject4$5;
6722
6723	var SearchTabFooter = /*#__PURE__*/function (_BaseFooter) {
6724	  babelHelpers.inherits(SearchTabFooter, _BaseFooter);
6725
6726	  function SearchTabFooter(tab, options) {
6727	    var _this;
6728
6729	    babelHelpers.classCallCheck(this, SearchTabFooter);
6730	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(SearchTabFooter).call(this, tab, options));
6731	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "loader", null);
6732
6733	    _this.getDialog().subscribe('onSearch', _this.handleOnSearch.bind(babelHelpers.assertThisInitialized(_this)));
6734
6735	    var tagSelector = _this.getDialog().getTagSelector();
6736
6737	    if (tagSelector) {
6738	      tagSelector.subscribe('onMetaEnter', _this.handleMetaEnter.bind(babelHelpers.assertThisInitialized(_this)));
6739	    }
6740
6741	    return _this;
6742	  }
6743
6744	  babelHelpers.createClass(SearchTabFooter, [{
6745	    key: "render",
6746	    value: function render() {
6747	      return main_core.Tag.render(_templateObject$a || (_templateObject$a = babelHelpers.taggedTemplateLiteral(["\n\t\t\t<div class=\"ui-selector-search-footer\" onclick=\"", "\">\n\t\t\t\t<div class=\"ui-selector-search-footer-box\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t\t<div class=\"ui-selector-search-footer-cmd\">", "</div>\n\t\t\t</div>\n\t\t"])), this.handleClick.bind(this), this.getLabelContainer(), this.getQueryContainer(), this.getLoaderContainer(), main_core.Browser.isMac() ? '&#8984;+Enter' : 'Ctrl+Enter');
6748	    }
6749	  }, {
6750	    key: "getLoader",
6751	    value: function getLoader() {
6752	      if (this.loader === null) {
6753	        this.loader = new main_loader.Loader({
6754	          target: this.getLoaderContainer(),
6755	          size: 17,
6756	          color: 'rgba(82, 92, 105, 0.9)'
6757	        });
6758	      }
6759
6760	      return this.loader;
6761	    }
6762	  }, {
6763	    key: "showLoader",
6764	    value: function showLoader() {
6765	      void this.getLoader().show();
6766	    }
6767	  }, {
6768	    key: "hideLoader",
6769	    value: function hideLoader() {
6770	      void this.getLoader().hide();
6771	    }
6772	  }, {
6773	    key: "setLabel",
6774	    value: function setLabel(label) {
6775	      if (main_core.Type.isString(label)) {
6776	        this.getLabelContainer().textContent = label;
6777	      }
6778	    }
6779	  }, {
6780	    key: "getLabelContainer",
6781	    value: function getLabelContainer() {
6782	      var _this2 = this;
6783
6784	      return this.cache.remember('label', function () {
6785	        return main_core.Tag.render(_templateObject2$5 || (_templateObject2$5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span class=\"ui-selector-search-footer-label\">", "</span>\n\t\t\t"])), _this2.getOption('label', main_core.Loc.getMessage('UI_SELECTOR_CREATE_ITEM_LABEL')));
6786	      });
6787	    }
6788	  }, {
6789	    key: "getQueryContainer",
6790	    value: function getQueryContainer() {
6791	      return this.cache.remember('name-container', function () {
6792	        return main_core.Tag.render(_templateObject3$5 || (_templateObject3$5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<span class=\"ui-selector-search-footer-query\"></span>\n\t\t\t"])));
6793	      });
6794	    }
6795	  }, {
6796	    key: "getLoaderContainer",
6797	    value: function getLoaderContainer() {
6798	      return this.cache.remember('loader', function () {
6799	        return main_core.Tag.render(_templateObject4$5 || (_templateObject4$5 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-search-footer-loader\"></div>\n\t\t\t"])));
6800	      });
6801	    }
6802	  }, {
6803	    key: "createItem",
6804	    value: function createItem() {
6805	      var _this3 = this;
6806
6807	      var tagSelector = this.getDialog().getTagSelector();
6808
6809	      if (tagSelector && tagSelector.isLocked()) {
6810	        return;
6811	      }
6812
6813	      var finalize = function finalize() {
6814	        _this3.hideLoader();
6815
6816	        if (_this3.getDialog().getTagSelector()) {
6817	          _this3.getDialog().getTagSelector().unlock();
6818
6819	          _this3.getDialog().focusSearch();
6820	        }
6821	      };
6822
6823	      event.preventDefault();
6824	      this.showLoader();
6825
6826	      if (tagSelector) {
6827	        tagSelector.lock();
6828	      }
6829
6830	      this.getDialog().emitAsync('Search:onItemCreateAsync', {
6831	        searchQuery: this.getTab().getLastSearchQuery()
6832	      }).then(function () {
6833	        _this3.getTab().clearResults();
6834
6835	        _this3.getDialog().clearSearch();
6836
6837	        if (_this3.getDialog().getActiveTab() === _this3.getTab()) {
6838	          _this3.getDialog().selectFirstTab();
6839	        }
6840
6841	        finalize();
6842	      })["catch"](function () {
6843	        finalize();
6844	      });
6845	    }
6846	  }, {
6847	    key: "handleClick",
6848	    value: function handleClick() {
6849	      this.createItem();
6850	    }
6851	  }, {
6852	    key: "handleMetaEnter",
6853	    value: function handleMetaEnter(event) {
6854	      if (this.getDialog().getActiveTab() !== this.getTab()) {
6855	        return;
6856	      }
6857
6858	      this.handleClick();
6859	    }
6860	  }, {
6861	    key: "handleOnSearch",
6862	    value: function handleOnSearch(event) {
6863	      var _event$getData = event.getData(),
6864	          query = _event$getData.query;
6865
6866	      this.getQueryContainer().textContent = query;
6867	    }
6868	  }]);
6869	  return SearchTabFooter;
6870	}(BaseFooter);
6871
6872	var SearchTab = /*#__PURE__*/function (_Tab) {
6873	  babelHelpers.inherits(SearchTab, _Tab);
6874
6875	  function SearchTab(dialog, tabOptions, searchOptions) {
6876	    var _this;
6877
6878	    babelHelpers.classCallCheck(this, SearchTab);
6879	    var defaults = {
6880	      title: main_core.Loc.getMessage('UI_SELECTOR_SEARCH_TAB_TITLE'),
6881	      visible: false,
6882	      stub: true,
6883	      stubOptions: {
6884	        autoShow: false,
6885	        title: main_core.Loc.getMessage('UI_SELECTOR_SEARCH_STUB_TITLE'),
6886	        subtitle: main_core.Loc.getMessage('UI_SELECTOR_SEARCH_STUB_SUBTITLE')
6887	      }
6888	    };
6889	    var options = Object.assign({}, defaults, tabOptions);
6890	    options.id = 'search';
6891	    options.stubOptions.autoShow = false;
6892	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(SearchTab).call(this, dialog, options));
6893	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "lastSearchQuery", null);
6894	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "queryCache", new Set());
6895	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "queryXhr", null);
6896	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "searchLoader", new SearchLoader(babelHelpers.assertThisInitialized(_this)));
6897	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "allowCreateItem", false);
6898	    searchOptions = main_core.Type.isPlainObject(searchOptions) ? searchOptions : {};
6899
6900	    _this.setAllowCreateItem(searchOptions.allowCreateItem, searchOptions.footerOptions);
6901
6902	    _this.loadWithDebounce = main_core.Runtime.debounce(function () {
6903	      _this.load(_this.getLastSearchQuery());
6904	    }, 500);
6905	    return _this;
6906	  }
6907
6908	  babelHelpers.createClass(SearchTab, [{
6909	    key: "search",
6910	    value: function search(query) {
6911	      var searchQuery = new SearchQuery(query);
6912	      var dynamicEntities = this.getDynamicEntities(searchQuery);
6913	      searchQuery.setDynamicSearchEntities(dynamicEntities);
6914
6915	      if (searchQuery.isEmpty()) {
6916	        this.getSearchLoader().hide();
6917	        return;
6918	      }
6919
6920	      this.lastSearchQuery = searchQuery;
6921	      var matchResults = SearchEngine.matchItems(this.getDialog().getItems(), searchQuery);
6922	      this.clearResults();
6923	      this.appendResults(matchResults);
6924
6925	      if (this.getDialog().shouldFocusOnFirst()) {
6926	        this.getDialog().focusOnFirstNode();
6927	      }
6928
6929	      if (this.shouldLoad(searchQuery)) {
6930	        this.loadWithDebounce();
6931
6932	        if (!this.isEmptyResult()) {
6933	          this.getStub().hide();
6934	        }
6935	      } else {
6936	        if (!this.getSearchLoader().isShown()) {
6937	          this.toggleEmptyResult();
6938	        }
6939	      }
6940	    }
6941	  }, {
6942	    key: "getLastSearchQuery",
6943	    value: function getLastSearchQuery() {
6944	      return this.lastSearchQuery;
6945	    }
6946	  }, {
6947	    key: "setAllowCreateItem",
6948	    value: function setAllowCreateItem(flag, options) {
6949	      if (main_core.Type.isBoolean(flag)) {
6950	        this.allowCreateItem = flag;
6951
6952	        if (flag) {
6953	          this.setFooter(SearchTabFooter, options);
6954	        } else {
6955	          this.setFooter(null);
6956	        }
6957	      }
6958	    }
6959	  }, {
6960	    key: "canCreateItem",
6961	    value: function canCreateItem() {
6962	      return this.allowCreateItem;
6963	    }
6964	  }, {
6965	    key: "appendResults",
6966	    value: function appendResults(matchResults) {
6967	      var _this2 = this;
6968
6969	      matchResults.sort(function (a, b) {
6970	        var matchSortA = a.getSort();
6971	        var matchSortB = b.getSort();
6972
6973	        if (matchSortA !== null && matchSortB !== null && matchSortA !== matchSortB) {
6974	          return matchSortA - matchSortB;
6975	        }
6976
6977	        if (matchSortA !== null && matchSortB === null) {
6978	          return -1;
6979	        } else if (matchSortA === null && matchSortB !== null) {
6980	          return 1;
6981	        }
6982
6983	        var contextSortA = a.getItem().getContextSort();
6984	        var contextSortB = b.getItem().getContextSort();
6985
6986	        if (contextSortA !== null && contextSortB === null) {
6987	          return -1;
6988	        } else if (contextSortA === null && contextSortB !== null) {
6989	          return 1;
6990	        } else if (contextSortA !== null && contextSortB !== null) {
6991	          return contextSortB - contextSortA;
6992	        } else {
6993	          var globalSortA = a.getItem().getGlobalSort();
6994	          var globalSortB = b.getItem().getGlobalSort();
6995
6996	          if (globalSortA !== null && globalSortB === null) {
6997	            return -1;
6998	          } else if (globalSortA === null && globalSortB !== null) {
6999	            return 1;
7000	          } else if (globalSortA !== null && globalSortB !== null) {
7001	            return globalSortB - globalSortA;
7002	          }
7003
7004	          return 0;
7005	        }
7006	      });
7007	      this.getRootNode().disableRender();
7008	      matchResults.forEach(function (matchResult) {
7009	        var item = matchResult.getItem();
7010
7011	        if (!_this2.getRootNode().hasItem(item)) {
7012	          var node = _this2.getRootNode().addItem(item);
7013
7014	          node.setHighlights(matchResult.getMatchFields());
7015	        }
7016	      });
7017	      this.getRootNode().enableRender();
7018	      this.getRootNode().render(true);
7019	    }
7020	  }, {
7021	    key: "getDynamicEntities",
7022	    value: function getDynamicEntities(searchQuery) {
7023	      var result = [];
7024	      this.getDialog().getEntities().forEach(function (entity) {
7025	        if (entity.isSearchable()) {
7026	          var hasCacheLimit = entity.getSearchCacheLimits().some(function (pattern) {
7027	            return pattern.test(searchQuery.getQuery());
7028	          });
7029
7030	          if (hasCacheLimit) {
7031	            result.push(entity.getId());
7032	          }
7033	        }
7034	      });
7035	      return result;
7036	    }
7037	  }, {
7038	    key: "isQueryCacheable",
7039	    value: function isQueryCacheable(searchQuery) {
7040	      return searchQuery.isCacheable() && !searchQuery.hasDynamicSearch();
7041	    }
7042	  }, {
7043	    key: "isQueryLoaded",
7044	    value: function isQueryLoaded(searchQuery) {
7045	      var found = false;
7046	      this.queryCache.forEach(function (query) {
7047	        if (found === false && searchQuery.getQuery().startsWith(query)) {
7048	          found = true;
7049	        }
7050	      });
7051	      return found;
7052	    }
7053	  }, {
7054	    key: "addCacheQuery",
7055	    value: function addCacheQuery(searchQuery) {
7056	      if (this.isQueryCacheable(searchQuery)) {
7057	        this.queryCache.add(searchQuery.getQuery());
7058	      }
7059	    }
7060	  }, {
7061	    key: "removeCacheQuery",
7062	    value: function removeCacheQuery(searchQuery) {
7063	      this.queryCache["delete"](searchQuery.getQuery());
7064	    }
7065	  }, {
7066	    key: "shouldLoad",
7067	    value: function shouldLoad(searchQuery) {
7068	      if (!this.isQueryCacheable(searchQuery)) {
7069	        return true;
7070	      }
7071
7072	      if (!this.getDialog().hasDynamicSearch()) {
7073	        return false;
7074	      }
7075
7076	      return !this.isQueryLoaded(searchQuery);
7077	    }
7078	  }, {
7079	    key: "load",
7080	    value: function load(searchQuery) {
7081	      var _this3 = this;
7082
7083	      if (!this.shouldLoad(searchQuery)) {
7084	        return;
7085	      }
7086	      /*if (this.queryXhr)
7087	      {
7088	      	this.queryXhr.abort();
7089	      }*/
7090
7091
7092	      this.addCacheQuery(searchQuery);
7093	      this.getStub().hide();
7094	      this.getSearchLoader().show();
7095	      main_core.ajax.runAction('ui.entityselector.doSearch', {
7096	        json: {
7097	          dialog: this.getDialog().getAjaxJson(),
7098	          searchQuery: searchQuery.getAjaxJson()
7099	        },
7100	        onrequeststart: function onrequeststart(xhr) {
7101	          _this3.queryXhr = xhr;
7102	        },
7103	        getParameters: {
7104	          context: this.getDialog().getContext()
7105	        }
7106	      }).then(function (response) {
7107	        _this3.getSearchLoader().hide();
7108
7109	        if (!response || !response.data || !response.data.dialog || !response.data.dialog.items) {
7110	          _this3.removeCacheQuery(searchQuery);
7111
7112	          _this3.toggleEmptyResult();
7113
7114	          _this3.getDialog().emit('SearchTab:onLoad', {
7115	            searchTab: _this3
7116	          });
7117
7118	          return;
7119	        }
7120
7121	        if (response.data.searchQuery && response.data.searchQuery.cacheable === false) {
7122	          _this3.removeCacheQuery(searchQuery);
7123	        }
7124
7125	        if (main_core.Type.isArrayFilled(response.data.dialog.items)) {
7126	          var items = new Set();
7127	          response.data.dialog.items.forEach(function (itemOptions) {
7128	            delete itemOptions.tabs;
7129	            delete itemOptions.children;
7130
7131	            var item = _this3.getDialog().addItem(itemOptions);
7132
7133	            items.add(item);
7134	          });
7135
7136	          var isTabEmpty = _this3.isEmptyResult();
7137
7138	          var matchResults = SearchEngine.matchItems(Array.from(items.values()), _this3.getLastSearchQuery());
7139
7140	          _this3.appendResults(matchResults);
7141
7142	          if (isTabEmpty && _this3.getDialog().shouldFocusOnFirst()) {
7143	            _this3.getDialog().focusOnFirstNode();
7144	          }
7145	        }
7146
7147	        _this3.toggleEmptyResult();
7148
7149	        _this3.getDialog().emit('SearchTab:onLoad', {
7150	          searchTab: _this3
7151	        });
7152	      })["catch"](function (error) {
7153	        _this3.removeCacheQuery(searchQuery);
7154
7155	        _this3.getSearchLoader().hide();
7156
7157	        _this3.toggleEmptyResult();
7158
7159	        console.error(error);
7160	      });
7161	    }
7162	  }, {
7163	    key: "getSearchLoader",
7164	    value: function getSearchLoader() {
7165	      return this.searchLoader;
7166	    }
7167	  }, {
7168	    key: "clearResults",
7169	    value: function clearResults() {
7170	      this.getRootNode().removeChildren();
7171	    }
7172	  }, {
7173	    key: "isEmptyResult",
7174	    value: function isEmptyResult() {
7175	      return !this.getRootNode().hasChildren();
7176	    }
7177	  }, {
7178	    key: "toggleEmptyResult",
7179	    value: function toggleEmptyResult() {
7180	      if (this.isEmptyResult()) {
7181	        this.getStub().show();
7182	      } else {
7183	        this.getStub().hide();
7184	      }
7185	    }
7186	  }]);
7187	  return SearchTab;
7188	}(Tab);
7189
7190	var _templateObject$b, _templateObject2$6, _templateObject3$6, _templateObject4$6, _templateObject5$4, _templateObject6$2, _templateObject7$1;
7191
7192	var LoadState = function LoadState() {
7193	  babelHelpers.classCallCheck(this, LoadState);
7194	};
7195
7196	babelHelpers.defineProperty(LoadState, "UNSENT", 'UNSENT');
7197	babelHelpers.defineProperty(LoadState, "LOADING", 'LOADING');
7198	babelHelpers.defineProperty(LoadState, "DONE", 'DONE');
7199
7200	var TagSelectorMode = function TagSelectorMode() {
7201	  babelHelpers.classCallCheck(this, TagSelectorMode);
7202	};
7203
7204	babelHelpers.defineProperty(TagSelectorMode, "INSIDE", 'INSIDE');
7205	babelHelpers.defineProperty(TagSelectorMode, "OUTSIDE", 'OUTSIDE');
7206	var instances = new Map();
7207	/**
7208	 * @memberof BX.UI.EntitySelector
7209	 */
7210
7211	var Dialog = /*#__PURE__*/function (_EventEmitter) {
7212	  babelHelpers.inherits(Dialog, _EventEmitter);
7213	  babelHelpers.createClass(Dialog, null, [{
7214	    key: "getById",
7215	    value: function getById(id) {
7216	      return instances.get(id) || null;
7217	    }
7218	  }, {
7219	    key: "getInstances",
7220	    value: function getInstances() {
7221	      return Array.from(instances.values());
7222	    }
7223	  }]);
7224
7225	  function Dialog(dialogOptions) {
7226	    var _this;
7227
7228	    babelHelpers.classCallCheck(this, Dialog);
7229	    _this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(Dialog).call(this));
7230	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "id", null);
7231	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "items", new Map());
7232	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tabs", new Map());
7233	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "entities", new Map());
7234	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "targetNode", null);
7235	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "popup", null);
7236	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "cache", new main_core.Cache.MemoryCache());
7237	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "multiple", true);
7238	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "hideOnSelect", null);
7239	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "hideOnDeselect", null);
7240	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "clearSearchOnSelect", true);
7241	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "context", null);
7242	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "selectedItems", new Set());
7243	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "preselectedItems", []);
7244	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "undeselectedItems", []);
7245	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "dropdownMode", false);
7246	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "frozen", false);
7247	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "frozenProps", {});
7248	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "hideByEsc", true);
7249	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "autoHide", true);
7250	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "autoHideHandler", null);
7251	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "offsetTop", 5);
7252	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "offsetLeft", 0);
7253	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "cacheable", true);
7254	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "width", 565);
7255	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "height", 420);
7256	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "maxLabelWidth", 160);
7257	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "minLabelWidth", 45);
7258	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "showAvatars", true);
7259	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "compactView", false);
7260	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "activeTab", null);
7261	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "recentTab", null);
7262	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "searchTab", null);
7263	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "rendered", false);
7264	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "loadState", LoadState.UNSENT);
7265	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "loader", null);
7266	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagSelector", null);
7267	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagSelectorMode", null);
7268	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "tagSelectorHeight", null);
7269	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "saveRecentItemsWithDebounce", main_core.Runtime.debounce(_this.saveRecentItems, 2000, babelHelpers.assertThisInitialized(_this)));
7270	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "recentItemsToSave", []);
7271	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "navigation", null);
7272	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "header", null);
7273	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "footer", null);
7274	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "popupOptions", {});
7275	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "focusOnFirst", true);
7276	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "focusedNode", null);
7277	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "clearUnavailableItems", false);
7278	    babelHelpers.defineProperty(babelHelpers.assertThisInitialized(_this), "overlappingObserver", null);
7279
7280	    _this.setEventNamespace('BX.UI.EntitySelector.Dialog');
7281
7282	    var options = main_core.Type.isPlainObject(dialogOptions) ? dialogOptions : {};
7283	    _this.id = main_core.Type.isStringFilled(options.id) ? options.id : "ui-selector-".concat(main_core.Text.getRandom().toLowerCase());
7284	    _this.multiple = main_core.Type.isBoolean(options.multiple) ? options.multiple : true;
7285	    _this.context = main_core.Type.isStringFilled(options.context) ? options.context : null;
7286	    _this.clearUnavailableItems = options.clearUnavailableItems === true;
7287	    _this.compactView = options.compactView === true;
7288	    _this.dropdownMode = main_core.Type.isBoolean(options.dropdownMode) ? options.dropdownMode : false;
7289
7290	    if (main_core.Type.isArray(options.entities)) {
7291	      options.entities.forEach(function (entity) {
7292	        _this.addEntity(entity);
7293	      });
7294	    }
7295
7296	    if (options.tagSelector instanceof TagSelector) {
7297	      _this.tagSelectorMode = TagSelectorMode.OUTSIDE;
7298
7299	      _this.setTagSelector(options.tagSelector);
7300	    } else if (options.enableSearch === true) {
7301	      var defaultOptions = {
7302	        placeholder: main_core.Loc.getMessage('UI_TAG_SELECTOR_SEARCH_PLACEHOLDER'),
7303	        maxHeight: 99,
7304	        textBoxWidth: 105
7305	      };
7306	      var customOptions = main_core.Type.isPlainObject(options.tagSelectorOptions) ? options.tagSelectorOptions : {};
7307	      var mandatoryOptions = {
7308	        dialogOptions: null,
7309	        showTextBox: true,
7310	        showAddButton: false,
7311	        showCreateButton: false,
7312	        multiple: _this.isMultiple()
7313	      };
7314	      var tagSelectorOptions = Object.assign(defaultOptions, customOptions, mandatoryOptions);
7315	      var tagSelector = new TagSelector(tagSelectorOptions);
7316	      _this.tagSelectorMode = TagSelectorMode.INSIDE;
7317
7318	      _this.setTagSelector(tagSelector);
7319	    }
7320
7321	    _this.setTargetNode(options.targetNode);
7322
7323	    _this.setHideOnSelect(options.hideOnSelect);
7324
7325	    _this.setHideOnDeselect(options.hideOnDeselect);
7326
7327	    _this.setClearSearchOnSelect(options.clearSearchOnSelect);
7328
7329	    _this.setWidth(options.width);
7330
7331	    void _this.setHeight(options.height);
7332
7333	    _this.setAutoHide(options.autoHide);
7334
7335	    _this.setAutoHideHandler(options.autoHideHandler);
7336
7337	    _this.setHideByEsc(options.hideByEsc);
7338
7339	    _this.setOffsetLeft(options.offsetLeft);
7340
7341	    _this.setOffsetTop(options.offsetTop);
7342
7343	    _this.setCacheable(options.cacheable);
7344
7345	    _this.setFocusOnFirst(options.focusOnFirst);
7346
7347	    _this.setShowAvatars(options.showAvatars);
7348
7349	    _this.recentTab = new RecentTab(babelHelpers.assertThisInitialized(_this), options.recentTabOptions);
7350	    _this.searchTab = new SearchTab(babelHelpers.assertThisInitialized(_this), options.searchTabOptions, options.searchOptions);
7351
7352	    _this.addTab(_this.recentTab);
7353
7354	    _this.addTab(_this.searchTab);
7355
7356	    _this.setPreselectedItems(options.preselectedItems);
7357
7358	    _this.setUndeselectedItems(options.undeselectedItems);
7359
7360	    _this.setOptions(options);
7361
7362	    var preload = options.preload === true || _this.getPreselectedItems().length > 0;
7363
7364	    if (preload) {
7365	      _this.load();
7366	    }
7367
7368	    if (main_core.Type.isPlainObject(options.popupOptions)) {
7369	      var allowedOptions = ['overlay', 'bindOptions', 'targetContainer', 'zIndexOptions'];
7370	      var popupOptions = {};
7371	      Object.keys(options.popupOptions).forEach(function (option) {
7372	        if (allowedOptions.includes(option)) {
7373	          popupOptions[option] = options.popupOptions[option];
7374	        }
7375	      });
7376	      _this.popupOptions = popupOptions;
7377	    }
7378
7379	    _this.navigation = new Navigation(babelHelpers.assertThisInitialized(_this));
7380	    new SliderIntegration(babelHelpers.assertThisInitialized(_this));
7381
7382	    _this.subscribe('ItemNode:onFocus', _this.handleItemNodeFocus.bind(babelHelpers.assertThisInitialized(_this)));
7383
7384	    _this.subscribe('ItemNode:onUnfocus', _this.handleItemNodeUnfocus.bind(babelHelpers.assertThisInitialized(_this)));
7385
7386	    _this.subscribeFromOptions(options.events);
7387
7388	    instances.set(_this.id, babelHelpers.assertThisInitialized(_this));
7389	    return _this;
7390	  }
7391
7392	  babelHelpers.createClass(Dialog, [{
7393	    key: "show",
7394	    value: function show() {
7395	      this.load();
7396	      this.getPopup().show();
7397	    }
7398	  }, {
7399	    key: "hide",
7400	    value: function hide() {
7401	      this.getPopup().close();
7402	    }
7403	  }, {
7404	    key: "destroy",
7405	    value: function destroy() {
7406	      if (this.destroying) {
7407	        return;
7408	      }
7409
7410	      this.destroying = true;
7411	      this.emit('onDestroy');
7412	      this.disconnectTabOverlapping();
7413	      instances["delete"](this.getId());
7414
7415	      if (this.isRendered()) {
7416	        this.getPopup().destroy();
7417	      }
7418
7419	      for (var property in this) {
7420	        if (this.hasOwnProperty(property)) {
7421	          delete this[property];
7422	        }
7423	      }
7424
7425	      Object.setPrototypeOf(this, null);
7426	    }
7427	  }, {
7428	    key: "isOpen",
7429	    value: function isOpen() {
7430	      return this.popup && this.popup.isShown();
7431	    }
7432	  }, {
7433	    key: "adjustPosition",
7434	    value: function adjustPosition() {
7435	      if (this.isRendered()) {
7436	        this.getPopup().adjustPosition();
7437	      }
7438	    }
7439	  }, {
7440	    key: "search",
7441	    value: function search(queryString) {
7442	      var query = main_core.Type.isStringFilled(queryString) ? queryString.trim() : '';
7443	      var event = new main_core_events.BaseEvent({
7444	        data: {
7445	          query: query
7446	        }
7447	      });
7448	      this.emit('onBeforeSearch', event);
7449
7450	      if (event.isDefaultPrevented()) {
7451	        return;
7452	      }
7453
7454	      if (!main_core.Type.isStringFilled(query)) {
7455	        this.selectFirstTab();
7456
7457	        if (this.getSearchTab()) {
7458	          this.getSearchTab().clearResults();
7459	        }
7460	      } else if (this.getSearchTab()) {
7461	        this.selectTab(this.getSearchTab().getId());
7462	        this.getSearchTab().search(query);
7463	      }
7464
7465	      this.emit('onSearch', {
7466	        query: query
7467	      });
7468	    }
7469	  }, {
7470	    key: "addItem",
7471	    value: function addItem(options) {
7472	      var _this2 = this;
7473
7474	      if (!main_core.Type.isPlainObject(options)) {
7475	        throw new Error('EntitySelector.addItem: wrong item options.');
7476	      }
7477
7478	      var item = this.getItem(options);
7479
7480	      if (!item) {
7481	        item = new Item(options);
7482	        var undeselectable = this.getUndeselectedItems().some(function (itemId) {
7483	          return itemId[0] === item.getEntityId() && String(itemId[1]) === String(item.getId());
7484	        });
7485
7486	        if (undeselectable) {
7487	          item.setDeselectable(false);
7488	        }
7489
7490	        item.setDialog(this);
7491	        var entity = this.getEntity(item.getEntityId());
7492
7493	        if (entity === null) {
7494	          this.addEntity({
7495	            id: item.getEntityId()
7496	          });
7497	        }
7498
7499	        var entityItems = this.items.get(item.getEntityId());
7500
7501	        if (!entityItems) {
7502	          entityItems = new Map();
7503	          this.items.set(item.getEntityId(), entityItems);
7504	        }
7505
7506	        entityItems.set(String(item.getId()), item);
7507
7508	        if (item.isSelected()) {
7509	          this.handleItemSelect(item);
7510	        }
7511	      }
7512
7513	      var tabs = [];
7514
7515	      if (main_core.Type.isArray(options.tabs)) {
7516	        tabs = options.tabs;
7517	      } else if (main_core.Type.isStringFilled(options.tabs)) {
7518	        tabs = [options.tabs];
7519	      }
7520
7521	      var children = main_core.Type.isArray(options.children) ? options.children : [];
7522	      tabs.forEach(function (tabId) {
7523	        var tab = _this2.getTab(tabId);
7524
7525	        if (tab) {
7526	          var itemNode = tab.getRootNode().addItem(item, options.nodeOptions);
7527	          itemNode.addChildren(children);
7528	        }
7529	      });
7530	      return item;
7531	    }
7532	  }, {
7533	    key: "removeItem",
7534	    value: function removeItem(item) {
7535	      item = this.getItem(item);
7536
7537	      if (item) {
7538	        this.handleItemDeselect(item);
7539	        item.getNodes().forEach(function (node) {
7540	          node.getParentNode().removeChild(node);
7541	        });
7542	        var entityItems = this.getEntityItemsInternal(item.getEntityId());
7543
7544	        if (entityItems) {
7545	          entityItems["delete"](String(item.getId()));
7546
7547	          if (entityItems.size === 0) {
7548	            this.items["delete"](item.getEntityId());
7549	          }
7550	        }
7551	      }
7552
7553	      return item;
7554	    }
7555	  }, {
7556	    key: "removeItems",
7557	    value: function removeItems() {
7558	      var _this3 = this;
7559
7560	      this.getItemsInternal().forEach(function (items) {
7561	        items.forEach(function (item) {
7562	          _this3.removeItem(item);
7563	        });
7564	      });
7565	    }
7566	  }, {
7567	    key: "getItem",
7568	    value: function getItem(item) {
7569	      var id = null;
7570	      var entityId = null;
7571
7572	      if (main_core.Type.isArray(item) && item.length === 2) {
7573	        var _item = babelHelpers.slicedToArray(item, 2);
7574
7575	        entityId = _item[0];
7576	        id = _item[1];
7577	      } else if (item instanceof Item) {
7578	        id = item.getId();
7579	        entityId = item.getEntityId();
7580	      } else if (main_core.Type.isObjectLike(item)) {
7581	        id = item.id;
7582	        entityId = item.entityId;
7583	      }
7584
7585	      var entityItems = this.getEntityItemsInternal(entityId);
7586
7587	      if (entityItems) {
7588	        return entityItems.get(String(id)) || null;
7589	      }
7590
7591	      return null;
7592	    }
7593	  }, {
7594	    key: "getSelectedItems",
7595	    value: function getSelectedItems() {
7596	      return Array.from(this.selectedItems);
7597	    }
7598	  }, {
7599	    key: "getItems",
7600	    value: function getItems() {
7601	      var items = [];
7602	      this.getItemsInternal().forEach(function (entityItems) {
7603	        Array.prototype.push.apply(items, Array.from(entityItems.values()));
7604	      });
7605	      return items;
7606	    }
7607	    /**
7608	     * @internal
7609	     */
7610
7611	  }, {
7612	    key: "getItemsInternal",
7613	    value: function getItemsInternal() {
7614	      return this.items;
7615	    }
7616	  }, {
7617	    key: "getEntityItems",
7618	    value: function getEntityItems(entityId) {
7619	      var items = this.getEntityItemsInternal(entityId);
7620	      return items === null ? [] : Array.from(items.values());
7621	    }
7622	    /**
7623	     * @internal
7624	     */
7625
7626	  }, {
7627	    key: "getEntityItemsInternal",
7628	    value: function getEntityItemsInternal(entityId) {
7629	      return this.items.get(entityId) || null;
7630	    }
7631	    /**
7632	     * @private
7633	     */
7634
7635	  }, {
7636	    key: "validateItemIds",
7637	    value: function validateItemIds(itemIds) {
7638	      if (!main_core.Type.isArrayFilled(itemIds)) {
7639	        return [];
7640	      }
7641
7642	      var result = [];
7643	      itemIds.forEach(function (itemId) {
7644	        if (!main_core.Type.isArray(itemId) || itemId.length !== 2) {
7645	          return;
7646	        }
7647
7648	        var _itemId = babelHelpers.slicedToArray(itemId, 2),
7649	            entityId = _itemId[0],
7650	            id = _itemId[1];
7651
7652	        if (main_core.Type.isStringFilled(entityId) && (main_core.Type.isStringFilled(id) || main_core.Type.isNumber(id))) {
7653	          result.push(itemId);
7654	        }
7655	      });
7656	      return result;
7657	    }
7658	  }, {
7659	    key: "addTab",
7660	    value: function addTab(tab) {
7661	      if (main_core.Type.isPlainObject(tab)) {
7662	        tab = new Tab(this, tab);
7663	      }
7664
7665	      if (!(tab instanceof Tab)) {
7666	        throw new Error('EntitySelector: a tab must be an instance of EntitySelector.Tab.');
7667	      }
7668
7669	      if (this.getTab(tab.getId())) {
7670	        console.error("EntitySelector: the \"".concat(tab.getId(), "\" tab is already existed."));
7671	        return tab;
7672	      }
7673
7674	      tab.setDialog(this);
7675	      this.tabs.set(tab.getId(), tab);
7676
7677	      if (this.isRendered()) {
7678	        this.insertTab(tab);
7679	      }
7680
7681	      return tab;
7682	    }
7683	  }, {
7684	    key: "getTabs",
7685	    value: function getTabs() {
7686	      return Array.from(this.tabs.values());
7687	    }
7688	  }, {
7689	    key: "getTab",
7690	    value: function getTab(id) {
7691	      return this.tabs.get(id) || null;
7692	    }
7693	  }, {
7694	    key: "getRecentTab",
7695	    value: function getRecentTab() {
7696	      return this.recentTab;
7697	    }
7698	  }, {
7699	    key: "getSearchTab",
7700	    value: function getSearchTab() {
7701	      return this.searchTab;
7702	    }
7703	  }, {
7704	    key: "selectTab",
7705	    value: function selectTab(id) {
7706	      var _this4 = this;
7707
7708	      var newActiveTab = this.getTab(id);
7709
7710	      if (!newActiveTab || newActiveTab === this.getActiveTab()) {
7711	        return newActiveTab;
7712	      }
7713
7714	      if (this.getActiveTab()) {
7715	        this.getActiveTab().deselect();
7716	      }
7717
7718	      this.activeTab = newActiveTab;
7719	      newActiveTab.select();
7720
7721	      if (!newActiveTab.isRendered()) {
7722	        newActiveTab.render();
7723	      }
7724
7725	      requestAnimationFrame(function () {
7726	        requestAnimationFrame(function () {
7727	          _this4.focusSearch();
7728	        });
7729	      });
7730	      this.clearNodeFocus();
7731
7732	      if (this.shouldFocusOnFirst()) {
7733	        this.focusOnFirstNode();
7734	      }
7735
7736	      this.adjustHeader();
7737	      this.adjustFooter();
7738	      return newActiveTab;
7739	    }
7740	    /**
7741	     * @private
7742	     */
7743
7744	  }, {
7745	    key: "insertTab",
7746	    value: function insertTab(tab) {
7747	      tab.renderLabel();
7748	      tab.renderContainer();
7749	      main_core.Dom.append(tab.getLabelContainer(), this.getLabelsContainer());
7750	      main_core.Dom.append(tab.getContainer(), this.getTabContentsContainer());
7751
7752	      if (tab.getHeader()) {
7753	        main_core.Dom.append(tab.getHeader().getContainer(), this.getHeaderContainer());
7754	      }
7755
7756	      if (tab.getFooter()) {
7757	        main_core.Dom.append(tab.getFooter().getContainer(), this.getFooterContainer());
7758	      }
7759	    }
7760	  }, {
7761	    key: "selectFirstTab",
7762	    value: function selectFirstTab() {
7763	      var onlyVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7764	      var tabs = this.getTabs();
7765
7766	      for (var i = 0; i < tabs.length; i++) {
7767	        var tab = tabs[i];
7768
7769	        if (onlyVisible === false || tab.isVisible()) {
7770	          return this.selectTab(tab.getId());
7771	        }
7772	      }
7773
7774	      if (this.isDropdownMode()) {
7775	        return this.selectTab(this.getRecentTab().getId());
7776	      }
7777
7778	      return null;
7779	    }
7780	  }, {
7781	    key: "selectLastTab",
7782	    value: function selectLastTab() {
7783	      var onlyVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7784	      var tabs = this.getTabs();
7785
7786	      for (var i = tabs.length - 1; i >= 0; i--) {
7787	        var tab = tabs[i];
7788
7789	        if (onlyVisible === false || tab.isVisible()) {
7790	          return this.selectTab(tab.getId());
7791	        }
7792	      }
7793
7794	      if (this.isDropdownMode()) {
7795	        return this.selectTab(this.getRecentTab().getId());
7796	      }
7797
7798	      return null;
7799	    }
7800	  }, {
7801	    key: "getActiveTab",
7802	    value: function getActiveTab() {
7803	      return this.activeTab;
7804	    }
7805	  }, {
7806	    key: "getNextTab",
7807	    value: function getNextTab() {
7808	      var onlyVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7809	      var nextTab = null;
7810	      var activeFound = false;
7811	      var tabs = this.getTabs();
7812
7813	      for (var i = 0; i < tabs.length; i++) {
7814	        var tab = tabs[i];
7815
7816	        if (onlyVisible && !tab.isVisible()) {
7817	          continue;
7818	        }
7819
7820	        if (tab === this.getActiveTab()) {
7821	          activeFound = true;
7822	        } else if (activeFound) {
7823	          nextTab = tab;
7824	          break;
7825	        }
7826	      }
7827
7828	      return nextTab;
7829	    }
7830	  }, {
7831	    key: "getPreviousTab",
7832	    value: function getPreviousTab() {
7833	      var onlyVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
7834	      var previousTab = null;
7835	      var activeFound = false;
7836	      var tabs = this.getTabs();
7837
7838	      for (var i = tabs.length - 1; i >= 0; i--) {
7839	        var tab = tabs[i];
7840
7841	        if (onlyVisible && !tab.isVisible()) {
7842	          continue;
7843	        }
7844
7845	        if (tab === this.getActiveTab()) {
7846	          activeFound = true;
7847	        } else if (activeFound) {
7848	          previousTab = tab;
7849	          break;
7850	        }
7851	      }
7852
7853	      return previousTab;
7854	    }
7855	  }, {
7856	    key: "removeTab",
7857	    value: function removeTab(id) {
7858	      var tab = this.getTab(id);
7859
7860	      if (!tab) {
7861	        return;
7862	      }
7863
7864	      tab.getRootNode().removeChildren();
7865	      this.tabs["delete"](id);
7866	      main_core.Dom.remove(tab.getLabelContainer(), this.getLabelsContainer());
7867	      main_core.Dom.remove(tab.getContainer(), this.getTabContentsContainer());
7868
7869	      if (tab.getHeader()) {
7870	        main_core.Dom.remove(tab.getHeader().getContainer(), this.getHeaderContainer());
7871	      }
7872
7873	      if (tab.getFooter()) {
7874	        main_core.Dom.remove(tab.getFooter().getContainer(), this.getFooterContainer());
7875	      }
7876
7877	      this.selectFirstTab();
7878	    }
7879	  }, {
7880	    key: "addEntity",
7881	    value: function addEntity(entity) {
7882	      if (main_core.Type.isPlainObject(entity)) {
7883	        entity = new Entity(entity);
7884	      }
7885
7886	      if (!(entity instanceof Entity)) {
7887	        throw new Error('EntitySelector: an entity must be an instance of EntitySelector.Entity.');
7888	      }
7889
7890	      if (this.hasEntity(entity.getId())) {
7891	        console.error("EntitySelector: the \"".concat(entity.getId(), "\" entity is already existed."));
7892	        return entity;
7893	      }
7894
7895	      this.entities.set(entity.getId(), entity);
7896	      return entity;
7897	    }
7898	  }, {
7899	    key: "getEntity",
7900	    value: function getEntity(id) {
7901	      return this.entities.get(id) || null;
7902	    }
7903	  }, {
7904	    key: "hasEntity",
7905	    value: function hasEntity(id) {
7906	      return this.entities.has(id);
7907	    }
7908	  }, {
7909	    key: "getEntities",
7910	    value: function getEntities() {
7911	      return Array.from(this.entities.values());
7912	    }
7913	  }, {
7914	    key: "removeEntity",
7915	    value: function removeEntity(id) {
7916	      this.removeEntityItems(id);
7917	      this.entities["delete"](id);
7918	    }
7919	  }, {
7920	    key: "removeEntityItems",
7921	    value: function removeEntityItems(id) {
7922	      var _this5 = this;
7923
7924	      var items = this.getEntityItemsInternal(id);
7925
7926	      if (items) {
7927	        items.forEach(function (item) {
7928	          _this5.removeItem(item);
7929	        });
7930	      }
7931	    }
7932	  }, {
7933	    key: "getHeader",
7934	    value: function getHeader() {
7935	      return this.header;
7936	    }
7937	  }, {
7938	    key: "getActiveHeader",
7939	    value: function getActiveHeader() {
7940	      if (!this.getActiveTab()) {
7941	        return null;
7942	      }
7943
7944	      if (this.getActiveTab().getHeader()) {
7945	        return this.getActiveTab().getHeader();
7946	      }
7947
7948	      return this.getHeader() && this.getActiveTab().canShowDefaultHeader() ? this.getHeader() : null;
7949	    }
7950	    /**
7951	     * @internal
7952	     */
7953
7954	  }, {
7955	    key: "adjustHeader",
7956	    value: function adjustHeader() {
7957	      if (!this.getActiveTab()) {
7958	        return;
7959	      }
7960
7961	      if (this.getActiveTab().getHeader()) {
7962	        if (this.getHeader()) {
7963	          this.getHeader().hide();
7964	        }
7965
7966	        this.getActiveTab().getHeader().show();
7967	      } else {
7968	        if (this.getHeader()) {
7969	          if (this.getActiveTab().canShowDefaultHeader()) {
7970	            this.getHeader().show();
7971	          } else {
7972	            this.getHeader().hide();
7973	          }
7974	        }
7975	      }
7976	    }
7977	  }, {
7978	    key: "setHeader",
7979	    value: function setHeader(headerContent, headerOptions) {
7980	      /** @var {BaseHeader} */
7981	      var header = null;
7982
7983	      if (headerContent !== null) {
7984	        header = this.constructor.createHeader(this, headerContent, headerOptions);
7985
7986	        if (header === null) {
7987	          return null;
7988	        }
7989	      }
7990
7991	      if (this.isRendered() && this.getHeader() !== null) {
7992	        main_core.Dom.remove(this.getHeader().getContainer());
7993	        this.adjustHeader();
7994	      }
7995
7996	      this.header = header;
7997
7998	      if (this.isRendered()) {
7999	        this.appendHeader(header);
8000	        this.adjustHeader();
8001	      }
8002
8003	      return header;
8004	    }
8005	    /**
8006	     * @internal
8007	     */
8008
8009	  }, {
8010	    key: "appendHeader",
8011	    value: function appendHeader(header) {
8012	      if (header instanceof BaseHeader) {
8013	        main_core.Dom.append(header.getContainer(), this.getHeaderContainer());
8014	      }
8015	    }
8016	    /**
8017	     * @internal
8018	     */
8019
8020	  }, {
8021	    key: "getFooter",
8022	    value: function getFooter() {
8023	      return this.footer;
8024	    }
8025	  }, {
8026	    key: "getActiveFooter",
8027	    value: function getActiveFooter() {
8028	      if (!this.getActiveTab()) {
8029	        return null;
8030	      }
8031
8032	      if (this.getActiveTab().getFooter()) {
8033	        return this.getActiveTab().getFooter();
8034	      }
8035
8036	      return this.getFooter() && this.getActiveTab().canShowDefaultFooter() ? this.getFooter() : null;
8037	    }
8038	    /**
8039	     * @internal
8040	     */
8041
8042	  }, {
8043	    key: "adjustFooter",
8044	    value: function adjustFooter() {
8045	      if (!this.getActiveTab()) {
8046	        return;
8047	      }
8048
8049	      if (this.getActiveTab().getFooter()) {
8050	        if (this.getFooter()) {
8051	          this.getFooter().hide();
8052	        }
8053
8054	        this.getActiveTab().getFooter().show();
8055	      } else {
8056	        if (this.getFooter()) {
8057	          if (this.getActiveTab().canShowDefaultFooter()) {
8058	            this.getFooter().show();
8059	          } else {
8060	            this.getFooter().hide();
8061	          }
8062	        }
8063	      }
8064	    }
8065	  }, {
8066	    key: "setFooter",
8067	    value: function setFooter(footerContent, footerOptions) {
8068	      /** @var {BaseFooter} */
8069	      var footer = null;
8070
8071	      if (footerContent !== null) {
8072	        footer = this.constructor.createFooter(this, footerContent, footerOptions);
8073
8074	        if (footer === null) {
8075	          return null;
8076	        }
8077	      }
8078
8079	      if (this.isRendered() && this.getFooter() !== null) {
8080	        main_core.Dom.remove(this.getFooter().getContainer());
8081	        this.adjustFooter();
8082	      }
8083
8084	      this.footer = footer;
8085
8086	      if (this.isRendered()) {
8087	        this.appendFooter(footer);
8088	        this.adjustFooter();
8089	      }
8090
8091	      return footer;
8092	    }
8093	    /**
8094	     * @internal
8095	     */
8096
8097	  }, {
8098	    key: "appendFooter",
8099	    value: function appendFooter(footer) {
8100	      if (footer instanceof BaseFooter) {
8101	        main_core.Dom.append(footer.getContainer(), this.getFooterContainer());
8102	      }
8103	    }
8104	    /**
8105	     * @internal
8106	     */
8107
8108	  }, {
8109	    key: "getId",
8110	    value: function getId() {
8111	      return this.id;
8112	    }
8113	  }, {
8114	    key: "getContext",
8115	    value: function getContext() {
8116	      return this.context;
8117	    }
8118	  }, {
8119	    key: "getNavigation",
8120	    value: function getNavigation() {
8121	      return this.navigation;
8122	    }
8123	  }, {
8124	    key: "deselectAll",
8125	    value: function deselectAll() {
8126	      this.getSelectedItems().forEach(function (item) {
8127	        item.deselect();
8128	      });
8129	    }
8130	  }, {
8131	    key: "isMultiple",
8132	    value: function isMultiple() {
8133	      return this.multiple;
8134	    }
8135	  }, {
8136	    key: "setTargetNode",
8137	    value: function setTargetNode(node) {
8138	      if (!main_core.Type.isDomNode(node) && !main_core.Type.isNull(node) && !main_core.Type.isObject(node)) {
8139	        return;
8140	      }
8141
8142	      this.targetNode = node;
8143
8144	      if (this.isRendered()) {
8145	        this.getPopup().setBindElement(this.targetNode);
8146	        this.getPopup().adjustPosition();
8147	      }
8148	    }
8149	  }, {
8150	    key: "getTargetNode",
8151	    value: function getTargetNode() {
8152	      if (this.targetNode === null) {
8153	        if (this.getTagSelectorMode() === TagSelectorMode.OUTSIDE) {
8154	          return this.getTagSelector().getOuterContainer();
8155	        }
8156	      }
8157
8158	      return this.targetNode;
8159	    }
8160	  }, {
8161	    key: "setHideOnSelect",
8162	    value: function setHideOnSelect(flag) {
8163	      if (main_core.Type.isBoolean(flag)) {
8164	        this.hideOnSelect = flag;
8165	      }
8166	    }
8167	  }, {
8168	    key: "shouldHideOnSelect",
8169	    value: function shouldHideOnSelect() {
8170	      if (this.hideOnSelect !== null) {
8171	        return this.hideOnSelect;
8172	      }
8173
8174	      return !this.isMultiple();
8175	    }
8176	  }, {
8177	    key: "setHideOnDeselect",
8178	    value: function setHideOnDeselect(flag) {
8179	      if (main_core.Type.isBoolean(flag)) {
8180	        this.hideOnDeselect = flag;
8181	      }
8182	    }
8183	  }, {
8184	    key: "shouldHideOnDeselect",
8185	    value: function shouldHideOnDeselect() {
8186	      if (this.hideOnDeselect !== null) {
8187	        return this.hideOnDeselect;
8188	      }
8189
8190	      return false;
8191	    }
8192	  }, {
8193	    key: "setClearSearchOnSelect",
8194	    value: function setClearSearchOnSelect(flag) {
8195	      if (main_core.Type.isBoolean(flag)) {
8196	        this.clearSearchOnSelect = flag;
8197	      }
8198	    }
8199	  }, {
8200	    key: "shouldClearSearchOnSelect",
8201	    value: function shouldClearSearchOnSelect() {
8202	      return this.clearSearchOnSelect;
8203	    }
8204	  }, {
8205	    key: "setShowAvatars",
8206	    value: function setShowAvatars(flag) {
8207	      if (main_core.Type.isBoolean(flag)) {
8208	        this.showAvatars = flag;
8209
8210	        if (this.isRendered()) {
8211	          this.getTabs().forEach(function (tab) {
8212	            tab.renderContainer();
8213	          });
8214	        }
8215	      }
8216	    }
8217	  }, {
8218	    key: "shouldShowAvatars",
8219	    value: function shouldShowAvatars() {
8220	      return this.showAvatars;
8221	    }
8222	  }, {
8223	    key: "isCompactView",
8224	    value: function isCompactView() {
8225	      return this.compactView;
8226	    }
8227	  }, {
8228	    key: "setAutoHide",
8229	    value: function setAutoHide(enable) {
8230	      if (main_core.Type.isBoolean(enable)) {
8231	        this.autoHide = enable;
8232
8233	        if (this.isRendered()) {
8234	          this.getPopup().setAutoHide(enable);
8235	        }
8236	      }
8237	    }
8238	  }, {
8239	    key: "isAutoHide",
8240	    value: function isAutoHide() {
8241	      return this.autoHide;
8242	    }
8243	  }, {
8244	    key: "setAutoHideHandler",
8245	    value: function setAutoHideHandler(handler) {
8246	      if (main_core.Type.isFunction(handler) || handler === null) {
8247	        this.autoHideHandler = handler;
8248	      }
8249	    }
8250	  }, {
8251	    key: "setHideByEsc",
8252	    value: function setHideByEsc(enable) {
8253	      if (main_core.Type.isBoolean(enable)) {
8254	        this.hideByEsc = enable;
8255
8256	        if (this.isRendered()) {
8257	          this.getPopup().setClosingByEsc(enable);
8258	        }
8259	      }
8260	    }
8261	  }, {
8262	    key: "shouldHideByEsc",
8263	    value: function shouldHideByEsc() {
8264	      return this.hideByEsc;
8265	    }
8266	  }, {
8267	    key: "getWidth",
8268	    value: function getWidth() {
8269	      return this.width;
8270	    }
8271	  }, {
8272	    key: "setWidth",
8273	    value: function setWidth(width) {
8274	      if (main_core.Type.isNumber(width) && width > 0) {
8275	        this.width = width;
8276
8277	        if (this.isRendered()) {
8278	          main_core.Dom.style(this.getContainer(), 'width', "".concat(width, "px"));
8279	        }
8280	      }
8281	    }
8282	  }, {
8283	    key: "getHeight",
8284	    value: function getHeight() {
8285	      return this.height;
8286	    }
8287	  }, {
8288	    key: "setHeight",
8289	    value: function setHeight(height) {
8290	      if (main_core.Type.isNumber(height) && height > 0) {
8291	        this.height = height;
8292
8293	        if (this.isRendered()) {
8294	          main_core.Dom.style(this.getContainer(), 'height', "".concat(height, "px"));
8295	          return Animation.handleTransitionEnd(this.getContainer(), 'height');
8296	        } else {
8297	          return Promise.resolve();
8298	        }
8299	      } else {
8300	        return Promise.resolve();
8301	      }
8302	    }
8303	  }, {
8304	    key: "getOffsetLeft",
8305	    value: function getOffsetLeft() {
8306	      return this.offsetLeft;
8307	    }
8308	  }, {
8309	    key: "setOffsetLeft",
8310	    value: function setOffsetLeft(offset) {
8311	      if (main_core.Type.isNumber(offset) && offset >= 0) {
8312	        this.offsetLeft = offset;
8313
8314	        if (this.isRendered()) {
8315	          this.getPopup().setOffset({
8316	            offsetLeft: offset
8317	          });
8318	          this.adjustPosition();
8319	        }
8320	      }
8321	    }
8322	  }, {
8323	    key: "getOffsetTop",
8324	    value: function getOffsetTop() {
8325	      return this.offsetTop;
8326	    }
8327	  }, {
8328	    key: "setOffsetTop",
8329	    value: function setOffsetTop(offset) {
8330	      if (main_core.Type.isNumber(offset) && offset >= 0) {
8331	        this.offsetTop = offset;
8332
8333	        if (this.isRendered()) {
8334	          this.getPopup().setOffset({
8335	            offsetTop: offset
8336	          });
8337	          this.adjustPosition();
8338	        }
8339	      }
8340	    }
8341	  }, {
8342	    key: "getZindex",
8343	    value: function getZindex() {
8344	      return this.getPopup().getZindex();
8345	    }
8346	  }, {
8347	    key: "isCacheable",
8348	    value: function isCacheable() {
8349	      return this.cacheable;
8350	    }
8351	  }, {
8352	    key: "setCacheable",
8353	    value: function setCacheable(cacheable) {
8354	      if (main_core.Type.isBoolean(cacheable)) {
8355	        this.cacheable = cacheable;
8356
8357	        if (this.isRendered()) {
8358	          this.getPopup().setCacheable(cacheable);
8359	        }
8360	      }
8361	    }
8362	  }, {
8363	    key: "shouldFocusOnFirst",
8364	    value: function shouldFocusOnFirst() {
8365	      return this.focusOnFirst;
8366	    }
8367	  }, {
8368	    key: "setFocusOnFirst",
8369	    value: function setFocusOnFirst(flag) {
8370	      if (main_core.Type.isBoolean(flag)) {
8371	        this.focusOnFirst = flag;
8372	      }
8373	    }
8374	  }, {
8375	    key: "focusOnFirstNode",
8376	    value: function focusOnFirstNode() {
8377	      if (this.getActiveTab()) {
8378	        var itemNode = this.getActiveTab().getRootNode().getFirstChild();
8379
8380	        if (itemNode) {
8381	          itemNode.focus();
8382	          return itemNode;
8383	        }
8384	      }
8385
8386	      return null;
8387	    }
8388	  }, {
8389	    key: "getFocusedNode",
8390	    value: function getFocusedNode() {
8391	      return this.focusedNode;
8392	    }
8393	  }, {
8394	    key: "clearNodeFocus",
8395	    value: function clearNodeFocus() {
8396	      if (this.focusedNode) {
8397	        this.focusedNode.unfocus();
8398	        this.focusedNode = null;
8399	      }
8400	    }
8401	  }, {
8402	    key: "isDropdownMode",
8403	    value: function isDropdownMode() {
8404	      return this.dropdownMode;
8405	    }
8406	  }, {
8407	    key: "setPreselectedItems",
8408	    value: function setPreselectedItems(itemIds) {
8409	      this.preselectedItems = this.validateItemIds(itemIds);
8410	    }
8411	  }, {
8412	    key: "getPreselectedItems",
8413	    value: function getPreselectedItems() {
8414	      return this.preselectedItems;
8415	    }
8416	  }, {
8417	    key: "setUndeselectedItems",
8418	    value: function setUndeselectedItems(itemIds) {
8419	      this.undeselectedItems = this.validateItemIds(itemIds);
8420	    }
8421	  }, {
8422	    key: "getUndeselectedItems",
8423	    value: function getUndeselectedItems() {
8424	      return this.undeselectedItems;
8425	    }
8426	    /**
8427	     * @private
8428	     */
8429
8430	  }, {
8431	    key: "setOptions",
8432	    value: function setOptions(dialogOptions) {
8433	      var _this6 = this;
8434
8435	      var options = main_core.Type.isPlainObject(dialogOptions) ? dialogOptions : {};
8436
8437	      if (main_core.Type.isArray(options.tabs)) {
8438	        options.tabs.forEach(function (tab) {
8439	          _this6.addTab(tab);
8440	        });
8441	      }
8442
8443	      if (main_core.Type.isArray(options.selectedItems)) {
8444	        options.selectedItems.forEach(function (itemOptions) {
8445	          var options = Object.assign({}, main_core.Type.isPlainObject(itemOptions) ? itemOptions : {});
8446	          options.selected = true;
8447
8448	          _this6.addItem(options);
8449	        });
8450	      }
8451
8452	      if (main_core.Type.isArray(options.items)) {
8453	        options.items.forEach(function (itemOptions) {
8454	          _this6.addItem(itemOptions);
8455	        });
8456	      }
8457
8458	      this.setHeader(options.header, options.headerOptions);
8459	      this.setFooter(options.footer, options.footerOptions);
8460	    }
8461	  }, {
8462	    key: "getMaxLabelWidth",
8463	    value: function getMaxLabelWidth() {
8464	      return this.maxLabelWidth;
8465	    }
8466	  }, {
8467	    key: "getMinLabelWidth",
8468	    value: function getMinLabelWidth() {
8469	      return this.minLabelWidth;
8470	    }
8471	  }, {
8472	    key: "getTagSelector",
8473	    value: function getTagSelector() {
8474	      return this.tagSelector;
8475	    }
8476	  }, {
8477	    key: "getTagSelectorMode",
8478	    value: function getTagSelectorMode() {
8479	      return this.tagSelectorMode;
8480	    }
8481	  }, {
8482	    key: "isTagSelectorInside",
8483	    value: function isTagSelectorInside() {
8484	      return this.getTagSelector() && this.getTagSelectorMode() === TagSelectorMode.INSIDE;
8485	    }
8486	  }, {
8487	    key: "isTagSelectorOutside",
8488	    value: function isTagSelectorOutside() {
8489	      return this.getTagSelector() && this.getTagSelectorMode() === TagSelectorMode.OUTSIDE;
8490	    }
8491	  }, {
8492	    key: "getTagSelectorQuery",
8493	    value: function getTagSelectorQuery() {
8494	      return this.getTagSelector() ? this.getTagSelector().getTextBoxValue() : '';
8495	    }
8496	    /**
8497	     * @private
8498	     */
8499
8500	  }, {
8501	    key: "setTagSelector",
8502	    value: function setTagSelector(tagSelector) {
8503	      this.tagSelector = tagSelector;
8504	      this.tagSelector.subscribe('onInput', main_core.Runtime.debounce(this.handleTagSelectorInput, 200, this));
8505	      this.tagSelector.subscribe('onAddButtonClick', this.handleTagSelectorAddButtonClick.bind(this));
8506	      this.tagSelector.subscribe('onTagRemove', this.handleTagSelectorTagRemove.bind(this));
8507	      this.tagSelector.subscribe('onAfterTagRemove', this.handleTagSelectorAfterTagRemove.bind(this));
8508	      this.tagSelector.subscribe('onAfterTagAdd', this.handleTagSelectorAfterTagAdd.bind(this));
8509	      this.tagSelector.subscribe('onContainerClick', this.handleTagSelectorClick.bind(this));
8510	      this.tagSelector.setDialog(this);
8511	    }
8512	  }, {
8513	    key: "focusSearch",
8514	    value: function focusSearch() {
8515	      if (this.getTagSelector()) {
8516	        if (this.getActiveTab() !== this.getSearchTab()) {
8517	          this.getTagSelector().clearTextBox();
8518	        }
8519
8520	        this.getTagSelector().focusTextBox();
8521	      }
8522	    }
8523	  }, {
8524	    key: "clearSearch",
8525	    value: function clearSearch() {
8526	      if (this.getTagSelector()) {
8527	        this.getTagSelector().clearTextBox();
8528
8529	        if (this.getActiveTab() === this.getSearchTab()) {
8530	          this.selectFirstTab();
8531	        }
8532	      }
8533	    }
8534	  }, {
8535	    key: "getLoader",
8536	    value: function getLoader() {
8537	      if (this.loader === null) {
8538	        this.loader = new main_loader.Loader({
8539	          target: this.getTabsContainer(),
8540	          size: 100
8541	        });
8542	      }
8543
8544	      return this.loader;
8545	    }
8546	  }, {
8547	    key: "showLoader",
8548	    value: function showLoader() {
8549	      void this.getLoader().show();
8550	    }
8551	  }, {
8552	    key: "hideLoader",
8553	    value: function hideLoader() {
8554	      if (this.loader !== null) {
8555	        void this.getLoader().hide();
8556	      }
8557	    }
8558	  }, {
8559	    key: "destroyLoader",
8560	    value: function destroyLoader() {
8561	      if (this.loader !== null) {
8562	        this.getLoader().destroy();
8563	      }
8564
8565	      this.loader = null;
8566	    }
8567	  }, {
8568	    key: "getPopup",
8569	    value: function getPopup() {
8570	      var _this7 = this;
8571
8572	      if (this.popup !== null) {
8573	        return this.popup;
8574	      }
8575
8576	      this.getTabs().forEach(function (tab) {
8577	        _this7.insertTab(tab);
8578	      });
8579	      this.popup = new main_popup.Popup(Object.assign({
8580	        contentPadding: 0,
8581	        padding: 0,
8582	        offsetTop: this.getOffsetTop(),
8583	        offsetLeft: this.getOffsetLeft(),
8584	        animation: {
8585	          showClassName: 'ui-selector-popup-animation-show',
8586	          closeClassName: 'ui-selector-popup-animation-close',
8587	          closeAnimationType: 'animation'
8588	        },
8589	        bindElement: this.getTargetNode(),
8590	        bindOptions: {
8591	          forceBindPosition: true
8592	        },
8593	        autoHide: this.isAutoHide(),
8594	        autoHideHandler: this.handleAutoHide.bind(this),
8595	        closeByEsc: this.shouldHideByEsc(),
8596	        cacheable: this.isCacheable(),
8597	        events: {
8598	          onFirstShow: this.handlePopupFirstShow.bind(this),
8599	          onAfterShow: this.handlePopupAfterShow.bind(this),
8600	          onAfterClose: this.handlePopupAfterClose.bind(this),
8601	          onDestroy: this.handlePopupDestroy.bind(this)
8602	        },
8603	        content: this.getContainer()
8604	      }, this.popupOptions));
8605	      this.rendered = true;
8606	      this.selectFirstTab();
8607	      return this.popup;
8608	    }
8609	  }, {
8610	    key: "isRendered",
8611	    value: function isRendered() {
8612	      return this.rendered;
8613	    }
8614	  }, {
8615	    key: "getContainer",
8616	    value: function getContainer() {
8617	      var _this8 = this;
8618
8619	      return this.cache.remember('container', function () {
8620	        var searchContainer = '';
8621
8622	        if (_this8.getTagSelectorMode() === TagSelectorMode.INSIDE) {
8623	          searchContainer = main_core.Tag.render(_templateObject$b || (_templateObject$b = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-search\"></div>"])));
8624
8625	          _this8.getTagSelector().renderTo(searchContainer);
8626	        }
8627
8628	        var className = _this8.isCompactView() ? ' ui-selector-dialog--compact-view' : '';
8629	        return main_core.Tag.render(_templateObject2$6 || (_templateObject2$6 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div \n\t\t\t\t\tclass=\"ui-selector-dialog", "\" \n\t\t\t\t\tstyle=\"width:", "px; height:", "px;\"\n\t\t\t\t>\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), className, _this8.getWidth(), _this8.getHeight(), _this8.getHeaderContainer(), searchContainer, _this8.getTabsContainer(), _this8.getFooterContainer());
8630	      });
8631	    }
8632	  }, {
8633	    key: "getTabsContainer",
8634	    value: function getTabsContainer() {
8635	      var _this9 = this;
8636
8637	      return this.cache.remember('tabs-container', function () {
8638	        return main_core.Tag.render(_templateObject3$6 || (_templateObject3$6 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-tabs\">\n\t\t\t\t\t", "\n\t\t\t\t\t", "\n\t\t\t\t</div>\n\t\t\t"])), _this9.getTabContentsContainer(), _this9.getLabelsContainer());
8639	      });
8640	    }
8641	  }, {
8642	    key: "getTabContentsContainer",
8643	    value: function getTabContentsContainer() {
8644	      return this.cache.remember('tab-contents', function () {
8645	        return main_core.Tag.render(_templateObject4$6 || (_templateObject4$6 = babelHelpers.taggedTemplateLiteral(["<div class=\"ui-selector-tab-contents\"></div>"])));
8646	      });
8647	    }
8648	  }, {
8649	    key: "getLabelsContainer",
8650	    value: function getLabelsContainer() {
8651	      var _this10 = this;
8652
8653	      return this.cache.remember('labels-container', function () {
8654	        return main_core.Tag.render(_templateObject5$4 || (_templateObject5$4 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div \n\t\t\t\t\tclass=\"ui-selector-tab-labels\"\n\t\t\t\t\tonmouseenter=\"", "\"\n\t\t\t\t\tonmouseleave=\"", "\"\n\t\t\t\t></div>\n\t\t\t"])), _this10.handleLabelsMouseEnter.bind(_this10), _this10.handleLabelsMouseLeave.bind(_this10));
8655	      });
8656	    }
8657	  }, {
8658	    key: "getHeaderContainer",
8659	    value: function getHeaderContainer() {
8660	      var _this11 = this;
8661
8662	      return this.cache.remember('header', function () {
8663	        var header = _this11.getHeader() && _this11.getHeader().getContainer();
8664
8665	        return main_core.Tag.render(_templateObject6$2 || (_templateObject6$2 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-header-container\">", "</div>\n\t\t\t"])), header ? header : '');
8666	      });
8667	    }
8668	  }, {
8669	    key: "getFooterContainer",
8670	    value: function getFooterContainer() {
8671	      var _this12 = this;
8672
8673	      return this.cache.remember('footer', function () {
8674	        var footer = _this12.getFooter() && _this12.getFooter().getContainer();
8675
8676	        return main_core.Tag.render(_templateObject7$1 || (_templateObject7$1 = babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div class=\"ui-selector-footer-container\">", "</div>\n\t\t\t"])), footer ? footer : '');
8677	      });
8678	    }
8679	  }, {
8680	    key: "freeze",
8681	    value: function freeze() {
8682	      if (this.isFrozen()) {
8683	        return;
8684	      }
8685
8686	      this.frozenProps = {
8687	        autoHide: this.isAutoHide(),
8688	        hideByEsc: this.shouldHideByEsc()
8689	      };
8690	      this.setAutoHide(false);
8691	      this.setHideByEsc(false);
8692	      this.getNavigation().disable();
8693	      main_core.Dom.addClass(this.getContainer(), 'ui-selector-dialog--freeze');
8694	      this.frozen = true;
8695	    }
8696	  }, {
8697	    key: "unfreeze",
8698	    value: function unfreeze() {
8699	      if (!this.isFrozen()) {
8700	        return;
8701	      }
8702
8703	      this.setAutoHide(this.frozenProps.autoHide !== false);
8704	      this.setHideByEsc(this.frozenProps.hideByEsc !== false);
8705	      this.getNavigation().enable();
8706	      main_core.Dom.removeClass(this.getContainer(), 'ui-selector-dialog--freeze');
8707	      this.frozen = false;
8708	    }
8709	  }, {
8710	    key: "isFrozen",
8711	    value: function isFrozen() {
8712	      return this.frozen;
8713	    }
8714	  }, {
8715	    key: "hasRecentItems",
8716	    value: function hasRecentItems() {
8717	      var _this13 = this;
8718
8719	      return new Promise(function (resolve, reject) {
8720	        main_core.ajax.runAction('ui.entityselector.load', {
8721	          json: {
8722	            dialog: _this13.getAjaxJson()
8723	          },
8724	          getParameters: {
8725	            context: _this13.getContext()
8726	          }
8727	        }).then(function (response) {
8728	          resolve(response.data && response.data.dialog && main_core.Type.isArrayFilled(response.data.dialog.recentItems));
8729	        })["catch"](function (error) {
8730	          reject(error);
8731	        });
8732	      });
8733	    }
8734	  }, {
8735	    key: "load",
8736	    value: function load() {
8737	      var _this14 = this;
8738
8739	      if (this.loadState !== LoadState.UNSENT || !this.hasDynamicLoad()) {
8740	        return;
8741	      }
8742
8743	      if (this.getTagSelector()) {
8744	        this.getTagSelector().lock();
8745	      }
8746
8747	      setTimeout(function () {
8748	        if (_this14.isLoading()) {
8749	          _this14.showLoader();
8750	        }
8751	      }, 400);
8752	      this.loadState = LoadState.LOADING;
8753	      main_core.ajax.runAction('ui.entityselector.load', {
8754	        json: {
8755	          dialog: this.getAjaxJson()
8756	        },
8757	        getParameters: {
8758	          context: this.getContext()
8759	        }
8760	      }).then(function (response) {
8761	        if (response && response.data && main_core.Type.isPlainObject(response.data.dialog)) {
8762	          _this14.loadState = LoadState.DONE;
8763	          var entities = main_core.Type.isArrayFilled(response.data.dialog.entities) ? response.data.dialog.entities : [];
8764	          entities.forEach(function (entityOptions) {
8765	            var entity = _this14.getEntity(entityOptions.id);
8766
8767	            if (entity) {
8768	              entity.setDynamicSearch(entityOptions.dynamicSearch);
8769	            }
8770	          });
8771
8772	          _this14.setOptions(response.data.dialog);
8773
8774	          _this14.getPreselectedItems().forEach(function (preselectedItem) {
8775	            var item = _this14.getItem(preselectedItem);
8776
8777	            if (item) {
8778	              item.select(true);
8779	            }
8780	          });
8781
8782	          var recentItems = response.data.dialog.recentItems;
8783
8784	          if (main_core.Type.isArray(recentItems)) {
8785	            var nodeOptionsMap = new Map();
8786	            var itemsOptions = response.data.dialog.items;
8787
8788	            if (main_core.Type.isArray(itemsOptions)) {
8789	              itemsOptions.forEach(function (itemOptions) {
8790	                if (itemOptions.nodeOptions) {
8791	                  var item = _this14.getItem(itemOptions);
8792
8793	                  if (item) {
8794	                    nodeOptionsMap.set(item, itemOptions.nodeOptions);
8795	                  }
8796	                }
8797	              });
8798	            }
8799
8800	            var items = recentItems.map(function (recentItem) {
8801	              var item = _this14.getItem(recentItem);
8802
8803	              return [item, nodeOptionsMap.get(item)];
8804	            });
8805
8806	            _this14.getRecentTab().getRootNode().addItems(items);
8807	          }
8808
8809	          if (!_this14.getRecentTab().getRootNode().hasChildren() && _this14.getRecentTab().getStub()) {
8810	            _this14.getRecentTab().getStub().show();
8811	          }
8812
8813	          if (_this14.getTagSelector()) {
8814	            _this14.getTagSelector().unlock();
8815	          }
8816
8817	          if (_this14.isRendered()) {
8818	            if (_this14.isDropdownMode() && _this14.getActiveTab() === _this14.getRecentTab()) {
8819	              _this14.selectFirstTab();
8820	            } else if (!_this14.getActiveTab()) {
8821	              _this14.selectFirstTab();
8822	            }
8823	          }
8824
8825	          _this14.focusSearch();
8826
8827	          _this14.destroyLoader();
8828
8829	          if (_this14.shouldFocusOnFirst()) {
8830	            _this14.focusOnFirstNode();
8831	          }
8832
8833	          _this14.emit('onLoad');
8834	        }
8835	      })["catch"](function (error) {
8836	        _this14.loadState = LoadState.UNSENT;
8837
8838	        if (_this14.getTagSelector()) {
8839	          _this14.getTagSelector().unlock();
8840	        }
8841
8842	        _this14.focusSearch();
8843
8844	        _this14.destroyLoader();
8845
8846	        _this14.emit('onLoadError', {
8847	          error: error
8848	        });
8849
8850	        console.error(error);
8851	      });
8852	    }
8853	  }, {
8854	    key: "isLoaded",
8855	    value: function isLoaded() {
8856	      return this.loadState === LoadState.DONE;
8857	    }
8858	  }, {
8859	    key: "isLoading",
8860	    value: function isLoading() {
8861	      return this.loadState === LoadState.LOADING;
8862	    }
8863	  }, {
8864	    key: "hasDynamicLoad",
8865	    value: function hasDynamicLoad() {
8866	      var hasDynamicLoad = false;
8867	      this.entities.forEach(function (entity) {
8868	        hasDynamicLoad = hasDynamicLoad || entity.hasDynamicLoad();
8869	      });
8870	      return hasDynamicLoad;
8871	    }
8872	  }, {
8873	    key: "hasDynamicSearch",
8874	    value: function hasDynamicSearch() {
8875	      var hasDynamicSearch = false;
8876	      this.entities.forEach(function (entity) {
8877	        hasDynamicSearch = hasDynamicSearch || entity.isSearchable() && entity.hasDynamicSearch();
8878	      });
8879	      return hasDynamicSearch;
8880	    }
8881	  }, {
8882	    key: "saveRecentItem",
8883	    value: function saveRecentItem(item) {
8884	      if (this.getContext() === null || !item.isSaveable()) {
8885	        return;
8886	      }
8887
8888	      this.recentItemsToSave.push(item);
8889	      this.saveRecentItemsWithDebounce();
8890	    }
8891	    /**
8892	     * @private
8893	     */
8894
8895	  }, {
8896	    key: "saveRecentItems",
8897	    value: function saveRecentItems() {
8898	      if (!main_core.Type.isArrayFilled(this.recentItemsToSave)) {
8899	        return;
8900	      }
8901
8902	      main_core.ajax.runAction('ui.entityselector.saveRecentItems', {
8903	        json: {
8904	          dialog: this.getAjaxJson(),
8905	          recentItems: this.recentItemsToSave.map(function (item) {
8906	            return item.getAjaxJson();
8907	          })
8908	        },
8909	        getParameters: {
8910	          context: this.getContext()
8911	        }
8912	      }).then(function (response) {})["catch"](function (error) {
8913	        console.error(error);
8914	      });
8915	      this.recentItemsToSave = [];
8916	    }
8917	  }, {
8918	    key: "shouldClearUnavailableItems",
8919	    value: function shouldClearUnavailableItems() {
8920	      return this.clearUnavailableItems;
8921	    }
8922	    /**
8923	     * @private
8924	     */
8925
8926	  }, {
8927	    key: "handleTagSelectorInput",
8928	    value: function handleTagSelectorInput() {
8929	      if (this.getTagSelectorMode() === TagSelectorMode.OUTSIDE && !this.isOpen()) {
8930	        this.show();
8931	      }
8932
8933	      var query = this.getTagSelector().getTextBoxValue();
8934	      this.search(query);
8935	    }
8936	    /**
8937	     * @private
8938	     */
8939
8940	  }, {
8941	    key: "handleTagSelectorAddButtonClick",
8942	    value: function handleTagSelectorAddButtonClick() {
8943	      this.show();
8944	    }
8945	    /**
8946	     * @private
8947	     */
8948
8949	  }, {
8950	    key: "handleTagSelectorTagRemove",
8951	    value: function handleTagSelectorTagRemove(event) {
8952	      var _event$getData = event.getData(),
8953	          tag = _event$getData.tag;
8954
8955	      var item = this.getItem({
8956	        id: tag.getId(),
8957	        entityId: tag.getEntityId()
8958	      });
8959
8960	      if (item) {
8961	        item.deselect();
8962	      }
8963
8964	      this.focusSearch();
8965	    }
8966	    /**
8967	     * @private
8968	     */
8969
8970	  }, {
8971	    key: "handleTagSelectorAfterTagRemove",
8972	    value: function handleTagSelectorAfterTagRemove() {
8973	      this.adjustByTagSelector();
8974	    }
8975	    /**
8976	     * @private
8977	     */
8978
8979	  }, {
8980	    key: "handleTagSelectorAfterTagAdd",
8981	    value: function handleTagSelectorAfterTagAdd() {
8982	      this.adjustByTagSelector();
8983	    }
8984	    /**
8985	     * @private
8986	     */
8987
8988	  }, {
8989	    key: "adjustByTagSelector",
8990	    value: function adjustByTagSelector() {
8991	      var _this15 = this;
8992
8993	      if (this.getTagSelectorMode() === TagSelectorMode.OUTSIDE) {
8994	        this.adjustPosition();
8995	      } else if (this.getTagSelectorMode() === TagSelectorMode.INSIDE) {
8996	        var newTagSelectorHeight = this.getTagSelector().calcHeight();
8997
8998	        if (newTagSelectorHeight > 0) {
8999	          var offset = newTagSelectorHeight - (this.tagSelectorHeight || this.getTagSelector().getMinHeight());
9000	          this.tagSelectorHeight = newTagSelectorHeight;
9001
9002	          if (offset !== 0) {
9003	            var height = this.getHeight();
9004	            this.setHeight(height + offset).then(function () {
9005	              _this15.adjustPosition();
9006	            });
9007	          }
9008	        }
9009	      }
9010	    }
9011	    /**
9012	     * @private
9013	     */
9014
9015	  }, {
9016	    key: "handleTagSelectorClick",
9017	    value: function handleTagSelectorClick() {
9018	      this.focusSearch();
9019	    }
9020	    /**
9021	     * @internal
9022	     */
9023
9024	  }, {
9025	    key: "handleItemSelect",
9026	    value: function handleItemSelect(item) {
9027	      var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
9028
9029	      if (!this.isMultiple()) {
9030	        this.deselectAll();
9031
9032	        if (this.getSelectedItems().length > 0) {
9033	          console.error('EntitySelector: some items are still selected.', this.get
9033SelectedItems());
9034	        }
9035	      }
9036
9037	      if (this.getTagSelector() && (this.isMultiple() || this.isTagSelectorOutside())) {
9038	        var tag = item.createTag();
9039	        tag.animate = animate;
9040	        this.getTagSelector().addTag(tag);
9041	      }
9042
9043	      this.selectedItems.add(item);
9044	    }
9045	    /**
9046	     * @internal
9047	     */
9048
9049	  }, {
9050	    key: "handleItemDeselect",
9051	    value: function handleItemDeselect(item) {
9052	      this.selectedItems["delete"](item);
9053
9054	      if (this.getTagSelector()) {
9055	        this.getTagSelector().removeTag({
9056	          id: item.getId(),
9057	          entityId: item.getEntityId()
9058	        });
9059	      }
9060	    }
9061	    /**
9062	     * @private
9063	     */
9064
9065	  }, {
9066	    key: "handlePopupAfterShow",
9067	    value: function handlePopupAfterShow() {
9068	      this.focusSearch();
9069	      this.adjustByTagSelector();
9070	      this.emit('onShow');
9071	    }
9072	    /**
9073	     * @private
9074	     */
9075
9076	  }, {
9077	    key: "handlePopupFirstShow",
9078	    value: function handlePopupFirstShow() {
9079	      var _this16 = this;
9080
9081	      this.emit('onFirstShow');
9082	      requestAnimationFrame(function () {
9083	        requestAnimationFrame(function () {
9084	          main_core.Dom.addClass(_this16.getPopup().getPopupContainer(), 'ui-selector-popup-container');
9085	        });
9086	      });
9087	      this.observeTabOverlapping();
9088	    }
9089	    /**
9090	     * @private
9091	     */
9092
9093	  }, {
9094	    key: "handleAutoHide",
9095	    value: function handleAutoHide(event) {
9096	      var target = event.target;
9097	      var el = this.getPopup().getPopupContainer();
9098
9099	      if (target === el || el.contains(target)) {
9100	        return false;
9101	      }
9102
9103	      if (this.isTagSelectorOutside() && target === this.getTagSelector().getTextBox() && main_core.Type.isStringFilled(this.getTagSelector().getTextBoxValue())) {
9104	        return false;
9105	      }
9106
9107	      if (this.autoHideHandler !== null) {
9108	        var result = this.autoHideHandler(event, this);
9109
9110	        if (main_core.Type.isBoolean(result)) {
9111	          return result;
9112	        }
9113	      }
9114
9115	      return true;
9116	    }
9117	    /**
9118	     * @private
9119	     */
9120
9121	  }, {
9122	    key: "observeTabOverlapping",
9123	    value: function observeTabOverlapping() {
9124	      var _this17 = this;
9125
9126	      this.disconnectTabOverlapping();
9127	      this.overlappingObserver = new MutationObserver(function () {
9128	        if (_this17.getLabelsContainer().offsetWidth > 0) {
9129	          var left = parseInt(_this17.getPopup().getPopupContainer().style.left, 10);
9130
9131	          if (left < _this17.getMinLabelWidth()) {
9132	            main_core.Dom.style(_this17.getPopup().getPopupContainer(), 'left', "".concat(_this17.getMinLabelWidth(), "px"));
9133	          }
9134	        }
9135	      });
9136	      this.overlappingObserver.observe(this.getPopup().getPopupContainer(), {
9137	        attributes: true,
9138	        attributeFilter: ['style']
9139	      });
9140	    }
9141	    /**
9142	     * @private
9143	     */
9144
9145	  }, {
9146	    key: "disconnectTabOverlapping",
9147	    value: function disconnectTabOverlapping() {
9148	      if (this.overlappingObserver) {
9149	        this.overlappingObserver.disconnect();
9150	      }
9151	    }
9152	    /**
9153	     * @private
9154	     */
9155
9156	  }, {
9157	    key: "handlePopupAfterClose",
9158	    value: function handlePopupAfterClose() {
9159	      if (this.isTagSelectorOutside()) {
9160	        if (this.getActiveTab() && this.getActiveTab() === this.getSearchTab()) {
9161	          this.selectFirstTab();
9162	        }
9163
9164	        this.getTagSelector().clearTextBox();
9165	        this.getTagSelector().showAddButton();
9166	        this.getTagSelector().hideTextBox();
9167	      }
9168
9169	      this.emit('onHide');
9170	    }
9171	    /**
9172	     * @private
9173	     */
9174
9175	  }, {
9176	    key: "handlePopupDestroy",
9177	    value: function handlePopupDestroy() {
9178	      this.destroy();
9179	    }
9180	    /**
9181	     * @private
9182	     */
9183
9184	  }, {
9185	    key: "handleLabelsMouseEnter",
9186	    value: function handleLabelsMouseEnter() {
9187	      var _this18 = this;
9188
9189	      var rect = main_core.Dom.getRelativePosition(this.getLabelsContainer(), this.getPopup().getTargetContainer());
9190	      var freeSpace = rect.right;
9191
9192	      if (freeSpace > this.getMinLabelWidth()) {
9193	        main_core.Dom.removeClass(this.getLabelsContainer(), 'ui-selector-tab-labels--animate-hide');
9194	        main_core.Dom.addClass(this.getLabelsContainer(), 'ui-selector-tab-labels--animate-show');
9195	        main_core.Dom.style(this.getLabelsContainer(), 'max-width', "".concat(Math.min(freeSpace, this.getMaxLabelWidth()), "px"));
9196	        Animation.handleTransitionEnd(this.getLabelsContainer(), 'max-width').then(function () {
9197	          main_core.Dom.removeClass(_this18.getLabelsContainer(), 'ui-selector-tab-labels--animate-show');
9198	          main_core.Dom.addClass(_this18.getLabelsContainer(), 'ui-selector-tab-labels--active');
9199	        });
9200	      } else {
9201	        main_core.Dom.addClass(this.getLabelsContainer(), 'ui-selector-tab-labels--active');
9202	      }
9203	    }
9204	    /**
9205	     * @private
9206	     */
9207
9208	  }, {
9209	    key: "handleLabelsMouseLeave",
9210	    value: function handleLabelsMouseLeave() {
9211	      var _this19 = this;
9212
9213	      main_core.Dom.addClass(this.getLabelsContainer(), 'ui-selector-tab-labels--animate-hide');
9214	      main_core.Dom.removeClass(this.getLabelsContainer(), 'ui-selector-tab-labels--animate-show');
9215	      main_core.Dom.removeClass(this.getLabelsContainer(), 'ui-selector-tab-labels--active');
9216	      Animation.handleTransitionEnd(this.getLabelsContainer(), 'max-width').then(function () {
9217	        main_core.Dom.removeClass(_this19.getLabelsContainer(), 'ui-selector-tab-labels--animate-hide');
9218	      });
9219	      main_core.Dom.style(this.getLabelsContainer(), 'max-width', null);
9220	    }
9221	    /**
9222	     * @private
9223	     */
9224
9225	  }, {
9226	    key: "handleItemNodeFocus",
9227	    value: function handleItemNodeFocus(event) {
9228	      var _event$getData2 = event.getData(),
9229	          node = _event$getData2.node;
9230
9231	      if (this.focusedNode === node) {
9232	        return;
9233	      }
9234
9235	      this.clearNodeFocus();
9236	      this.focusedNode = node;
9237	    }
9238	    /**
9239	     * @private
9240	     */
9241
9242	  }, {
9243	    key: "handleItemNodeUnfocus",
9244	    value: function handleItemNodeUnfocus() {
9245	      this.clearNodeFocus();
9246	    }
9247	  }, {
9248	    key: "getAjaxJson",
9249	    value: function getAjaxJson() {
9250	      return {
9251	        id: this.getId(),
9252	        context: this.getContext(),
9253	        entities: this.getEntities(),
9254	        preselectedItems: this.getPreselectedItems(),
9255	        clearUnavailableItems: this.shouldClearUnavailableItems()
9256	      };
9257	    }
9258	  }], [{
9259	    key: "createHeader",
9260	    value: function createHeader(context, headerContent, headerOptions) {
9261	      if (!main_core.Type.isStringFilled(headerContent) && !main_core.Type.isArrayFilled(headerContent) && !main_core.Type.isDomNode(headerContent) && !main_core.Type.isFunction(headerContent)) {
9262	        return null;
9263	      }
9264	      /** @var {BaseHeader} */
9265
9266
9267	      var header = null;
9268	      var options = main_core.Type.isPlainObject(headerOptions) ? headerOptions : {};
9269
9270	      if (main_core.Type.isFunction(headerContent) || main_core.Type.isString(headerContent)) {
9271	        var className = main_core.Type.isString(headerContent) ? main_core.Reflection.getClass(headerContent) : headerContent;
9272
9273	        if (main_core.Type.isFunction(className)) {
9274	          header = new className(context, options);
9275
9276	          if (!(header instanceof BaseHeader)) {
9277	            console.error('EntitySelector: header is not an instance of BaseHeader.');
9278	            header = null;
9279	          }
9280	        }
9281	      }
9282
9283	      if (headerContent !== null && !header) {
9284	        header = new DefaultHeader(context, Object.assign({}, options, {
9285	          content: headerContent
9286	        }));
9287	      }
9288
9289	      return header;
9290	    }
9291	  }, {
9292	    key: "createFooter",
9293	    value: function createFooter(context, footerContent, footerOptions) {
9294	      if (!main_core.Type.isStringFilled(footerContent) && !main_core.Type.isArrayFilled(footerContent) && !main_core.Type.isDomNode(footerContent) && !main_core.Type.isFunction(footerContent)) {
9295	        return null;
9296	      }
9297	      /** @var {BaseFooter} */
9298
9299
9300	      var footer = null;
9301	      var options = main_core.Type.isPlainObject(footerOptions) ? footerOptions : {};
9302
9303	      if (main_core.Type.isFunction(footerContent) || main_core.Type.isString(footerContent)) {
9304	        var className = main_core.Type.isString(footerContent) ? main_core.Reflection.getClass(footerContent) : footerContent;
9305
9306	        if (main_core.Type.isFunction(className)) {
9307	          footer = new className(context, options);
9308
9309	          if (!(footer instanceof BaseFooter)) {
9310	            console.error('EntitySelector: footer is not an instance of BaseFooter.');
9311	            footer = null;
9312	          }
9313	        }
9314	      }
9315
9316	      if (footerContent !== null && !footer) {
9317	        footer = new DefaultFooter(context, Object.assign({}, options, {
9318	          content: footerContent
9319	        }));
9320	      }
9321
9322	      return footer;
9323	    }
9324	  }]);
9325	  return Dialog;
9326	}(main_core_events.EventEmitter);
9327
9328	var EntitySelector = {
9329	  Dialog: Dialog,
9330	  Item: Item,
9331	  Tab: Tab,
9332	  Entity: Entity,
9333	  TagSelector: TagSelector,
9334	  BaseHeader: BaseHeader,
9335	  DefaultHeader: DefaultHeader,
9336	  BaseFooter: BaseFooter,
9337	  DefaultFooter: DefaultFooter,
9338	  BaseStub: BaseStub,
9339	  DefaultStub: DefaultStub
9340	};
9341
9342	exports.EntitySelector = EntitySelector;
9343	exports.Dialog = Dialog;
9344	exports.Item = Item;
9345	exports.Tab = Tab;
9346	exports.Entity = Entity;
9347	exports.TagSelector = TagSelector;
9348	exports.BaseHeader = BaseHeader;
9349	exports.DefaultHeader = DefaultHeader;
9350	exports.BaseFooter = BaseFooter;
9351	exports.DefaultFooter = DefaultFooter;
9352	exports.BaseStub = BaseStub;
9353	exports.DefaultStub = DefaultStub;
9354
9355}((this.BX.UI.EntitySelector = this.BX.UI.EntitySelector || {}),BX.Main,BX.Collections,BX.Event,BX,BX));
9356//# sourceMappingURL=entity-selector.bundle.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.